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; };