diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset index ca208dae..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:329bb4534943e949f235c44d9782f62012b4e728fa4a566615a718a2ae0f1bde -size 124581 +oid sha256:bba3bf378d328c6d79162626cf4bacaa27fc7f676b78429891f5acb435480cd0 +size 125722 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 74dac6e0..f743b5ef 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); @@ -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 531048b8..2637e31f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -180,12 +180,11 @@ protected: UArrowComponent* GunStartArrow; bool bStopShooting = false; -private: + UPROPERTY(VisibleAnywhere) + 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 266ae616..a4a8cf61 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp @@ -2,9 +2,57 @@ #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; + ShotgunBulletSpread = FVector(10,10,10); } + +void AShotgunClass::BeginPlay() +{ + Super::BeginPlay(); +} + +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, ShotgunBulletSpread); + traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance); + GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams); + DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Black , false, 0.2f, 0U, 0.2f); + currentAmmoCount --; + } + playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1); + GenerateRecoilVector(); + ClickDetectionTimer(); + bulletCountShoot += 1; + 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(tempWeaponDamage, 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..e174653f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h @@ -17,5 +17,14 @@ class ENDLESSVENDETTA_API AShotgunClass : public ABaseWeaponClass 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; }; 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)