From 425ceb05d07e0f7c5288821fdb1f4aea945b58fe Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 6 Nov 2023 14:01:44 +0000 Subject: [PATCH 1/6] Edited BaseShotgun Values for more Realism --- .../Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset index ca208dae..9e27e54c 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:329bb4534943e949f235c44d9782f62012b4e728fa4a566615a718a2ae0f1bde -size 124581 +oid sha256:4fda447259ef98facee7f9589076d5a60c5c04fbb317483cd9995c7914ca2670 +size 124503 From a790a4a790472095996fde3b54e0b035a3d01033 Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 6 Nov 2023 14:01:57 +0000 Subject: [PATCH 2/6] Added Shotgun Functionality Firing --- .../WeaponSystem/ShotgunClass.cpp | 33 +++++++++++++++++++ .../WeaponSystem/ShotgunClass.h | 3 ++ 2 files changed, 36 insertions(+) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp index 266ae616..3e07de32 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp @@ -2,9 +2,42 @@ #include "ShotgunClass.h" +#include "EndlessVendetta/AI/EnemyCharacter.h" +#include "Engine/DamageEvents.h" AShotgunClass::AShotgunClass() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; } + +void AShotgunClass::Fire() +{ + if(currentAmmoCount > 0) + { + traceStart = GunStartArrow->GetComponentLocation(); + if (GetWorldTimerManager().IsTimerActive(timerHandle)) return; + for (int i = 0; i < 5; i++) + { + FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, FVector(10,10,10)); + traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance); + GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams); + DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Red , false, 100.f, 0U, 1.f); + currentAmmoCount --; + } + playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1); + GenerateRecoilVector(); + ClickDetectionTimer(); + bulletCountShoot += 1; + bStopShooting = false; + if (outHit.bBlockingHit) + { + if (!Cast(outHit.GetActor())) return; + Cast(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); + } + } + else if(currentAmmoCount <= 0) + { + UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount); + } +} diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h index 8bf23c16..fe567b38 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h @@ -17,5 +17,8 @@ class ENDLESSVENDETTA_API AShotgunClass : public ABaseWeaponClass public: // Sets default values for this actor's properties AShotgunClass(); + +protected: + virtual void Fire() override; }; From 0608015705a79f73198ddd54f963730296bd94aa Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 6 Nov 2023 15:57:34 +0000 Subject: [PATCH 3/6] Added editable weapon spread to all shotguns --- .../Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset index 9e27e54c..553a5baf 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fda447259ef98facee7f9589076d5a60c5c04fbb317483cd9995c7914ca2670 -size 124503 +oid sha256:bba3bf378d328c6d79162626cf4bacaa27fc7f676b78429891f5acb435480cd0 +size 125722 From 34ef5c6e40babd6998b1718a72fd336f5228e50c Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 6 Nov 2023 15:58:01 +0000 Subject: [PATCH 4/6] Added a temporary weapon damage for Damage Fall Off --- .../WeaponSystem/BaseWeaponClass.cpp | 2 +- .../WeaponSystem/BaseWeaponClass.h | 4 +--- .../WeaponSystem/ShotgunClass.cpp | 18 +++++++++++++++++- .../WeaponSystem/ShotgunClass.h | 6 ++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index 74dac6e0..81c1597e 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -23,7 +23,7 @@ ABaseWeaponClass::ABaseWeaponClass() void ABaseWeaponClass::BeginPlay() { Super::BeginPlay(); - + tempWeaponDamage = WeaponDamage; collisionParams.AddIgnoredActor(playerInWorld); collisionParams.AddIgnoredActor(this); diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 531048b8..6442a8f3 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -180,12 +180,10 @@ protected: UArrowComponent* GunStartArrow; bool bStopShooting = false; -private: + int tempWeaponDamage; float originalMagnitude; float originalMaxAngleLeft; float originalMaxAngleRight; float originalMinMultiplier; - - }; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp index 3e07de32..37c26400 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp @@ -9,6 +9,12 @@ AShotgunClass::AShotgunClass() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; + ShotgunBulletSpread = FVector(10,10,10); +} + +void AShotgunClass::BeginPlay() +{ + Super::BeginPlay(); } void AShotgunClass::Fire() @@ -19,8 +25,17 @@ void AShotgunClass::Fire() if (GetWorldTimerManager().IsTimerActive(timerHandle)) return; for (int i = 0; i < 5; i++) { - FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, FVector(10,10,10)); + FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread); traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance); + if (outHit.Distance >= FMath::Floor(BulletDistance/1.5)) + { + tempWeaponDamage /= 2; + GLog->Log("Bullet distance reached a quarter"); + } + else + { + tempWeaponDamage = WeaponDamage; + } GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams); DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Red , false, 100.f, 0U, 1.f); currentAmmoCount --; @@ -41,3 +56,4 @@ void AShotgunClass::Fire() UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount); } } + diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h index fe567b38..e174653f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h @@ -18,7 +18,13 @@ public: // Sets default values for this actor's properties AShotgunClass(); + //How far apart the bullets will be to eachother when shot with a shotgun + UPROPERTY(EditAnywhere, Category = "Weapon") + FVector ShotgunBulletSpread; + protected: virtual void Fire() override; + + virtual void BeginPlay() override; }; From 783e7bd136540d3b0ee1ad457a9f973e1e9afb3b Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 6 Nov 2023 17:21:34 +0000 Subject: [PATCH 5/6] Added Full Weapon Damage Drop Off To All Guns --- .../BaseWeapons/WBP_AmmoCount.uasset | 4 ++-- .../BaseWeapons/WBP_WeaponStatsPrompt.uasset | 4 ++-- .../WeaponSystem/BaseWeaponClass.cpp | 10 +++++++++- .../WeaponSystem/BaseWeaponClass.h | 1 + .../WeaponSystem/ShotgunClass.cpp | 19 +++++++++---------- .../WeaponSystem/SniperClass.cpp | 11 +++++++++-- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset index 8506b4d5..8cd31cc0 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12a2bf04dd00e6b7507070952dc3382734b02f049bd6a73a24f066b802071ca6 -size 64438 +oid sha256:04af06327094d9d5557376fbe5a7886c7d7776759de2af4a93d52cdfacf59e9a +size 64443 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_WeaponStatsPrompt.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_WeaponStatsPrompt.uasset index 3c992595..dde4061d 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_WeaponStatsPrompt.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_WeaponStatsPrompt.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4ab6367925f65273a78ac37e31eea98096d127474edeb245b8ec54d07e5dbb3 -size 186618 +oid sha256:ead2d32698cc8f6f60af3405fa3b9f5f1452791c2c759e631744a26cebf6749e +size 185820 diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index 81c1597e..f743b5ef 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -183,8 +183,16 @@ void ABaseWeaponClass::Fire() bStopShooting = false; if (outHit.bBlockingHit) { + if (outHit.Distance >= FMath::Floor(BulletDistance/2)) + { + tempWeaponDamage = WeaponDamage / 2; + } + else + { + tempWeaponDamage = WeaponDamage; + } if (!Cast(outHit.GetActor())) return; - Cast(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); + Cast(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); } } else if(currentAmmoCount <= 0) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 6442a8f3..2637e31f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -180,6 +180,7 @@ protected: UArrowComponent* GunStartArrow; bool bStopShooting = false; + UPROPERTY(VisibleAnywhere) int tempWeaponDamage; float originalMagnitude; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp index 37c26400..8be88ccc 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp @@ -27,15 +27,6 @@ void AShotgunClass::Fire() { FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread); traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance); - if (outHit.Distance >= FMath::Floor(BulletDistance/1.5)) - { - tempWeaponDamage /= 2; - GLog->Log("Bullet distance reached a quarter"); - } - else - { - tempWeaponDamage = WeaponDamage; - } GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams); DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Red , false, 100.f, 0U, 1.f); currentAmmoCount --; @@ -47,8 +38,16 @@ void AShotgunClass::Fire() bStopShooting = false; if (outHit.bBlockingHit) { + if (outHit.Distance >= FMath::Floor(BulletDistance/2)) + { + tempWeaponDamage = WeaponDamage / 2; + } + else + { + tempWeaponDamage = WeaponDamage; + } if (!Cast(outHit.GetActor())) return; - Cast(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); + Cast(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); } } else if(currentAmmoCount <= 0) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp index 9ace82f6..43f17bc9 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp @@ -58,9 +58,16 @@ void ASniperClass::Fire() this->GetWorld()->GetTimerManager().SetTimer(SniperTimerHandle, this, &ASniperClass::StopFire, FireRate, false); if (outHit.bBlockingHit) { - UE_LOG(LogTemp, Display, TEXT("Hit: %s"), *outHit.GetActor()->GetName()); + if (outHit.Distance >= FMath::Floor(BulletDistance/2)) + { + tempWeaponDamage = WeaponDamage / 2; + } + else + { + tempWeaponDamage = WeaponDamage; + } if (!Cast(outHit.GetActor())) return; - Cast(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); + Cast(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); } } else if(currentAmmoCount <= 0) From 4e4267cb383b07f1392728e108f08a06e1109b81 Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 6 Nov 2023 17:27:05 +0000 Subject: [PATCH 6/6] ReAdded back old values. Finished Shotgun Class --- .../Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp index 8be88ccc..a4a8cf61 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp @@ -28,7 +28,7 @@ void AShotgunClass::Fire() FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread); traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance); GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams); - DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Red , false, 100.f, 0U, 1.f); + DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Black , false, 0.2f, 0U, 0.2f); currentAmmoCount --; } playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);