Update Legacy Weapons for Sound

This commit is contained in:
Philip W 2024-03-22 12:41:41 +00:00
parent 1559c61e8e
commit a7976f6749
4 changed files with 12 additions and 13 deletions

View File

@ -120,7 +120,7 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float StaminaDecreaseRate = 0.2; float StaminaDecreaseRate = 0.2;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float StaminaRegenRate = 0.05; float StaminaRegenRate = 0.1;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float SprintSpeed = 900; float SprintSpeed = 900;

View File

@ -10,7 +10,7 @@ AShotgunClass::AShotgunClass()
{ {
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. // 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; PrimaryActorTick.bCanEverTick = true;
ShotgunBulletSpread = FVector(10,10,10); ShotgunBulletSpread = FVector(10, 10, 10);
} }
void AShotgunClass::BeginPlay() void AShotgunClass::BeginPlay()
@ -26,7 +26,7 @@ void AShotgunClass::ClickDetectionTimer()
void AShotgunClass::Fire() void AShotgunClass::Fire()
{ {
if(currentAmmoCount > 0 && !bSingleShotOnly) if (currentAmmoCount > 0 && !bSingleShotOnly)
{ {
bSingleShotOnly = true; bSingleShotOnly = true;
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Magenta, TEXT("Fire Activated")); GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Magenta, TEXT("Fire Activated"));
@ -37,13 +37,14 @@ void AShotgunClass::Fire()
FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread); FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread);
traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance); traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance);
GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams); GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams);
DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Yellow , false, 500.2f, 0U, 0.2f); DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Yellow, false, 500.2f, 0U, 0.2f);
if (outHit.bBlockingHit) if (outHit.bBlockingHit)
{ {
GEngine->AddOnScreenDebugMessage(-1, 20.f, FColor::Orange, FString(TEXT("SHOTGUN HIT"))); GEngine->AddOnScreenDebugMessage(-1, 20.f, FColor::Orange, FString(TEXT("SHOTGUN HIT")));
} }
} }
currentAmmoCount --; currentAmmoCount--;
WeaponFired.Broadcast();
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1); playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
GenerateRecoilVector(); GenerateRecoilVector();
ClickDetectionTimer(); ClickDetectionTimer();
@ -52,7 +53,7 @@ void AShotgunClass::Fire()
bStopShooting = false; bStopShooting = false;
if (outHit.bBlockingHit) if (outHit.bBlockingHit)
{ {
if (outHit.Distance >= FMath::Floor(BulletDistance/2)) if (outHit.Distance >= FMath::Floor(BulletDistance / 2))
{ {
tempWeaponDamage = WeaponDamage / 2; tempWeaponDamage = WeaponDamage / 2;
} }
@ -66,7 +67,7 @@ void AShotgunClass::Fire()
} }
HideNeedReloadUI(); HideNeedReloadUI();
} }
else if(currentAmmoCount <= 0) else if (currentAmmoCount <= 0)
{ {
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount); UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
ShowNeedReloadUI(); ShowNeedReloadUI();
@ -82,5 +83,3 @@ void AShotgunClass::StopFire()
{ {
bSingleShotOnly = false; bSingleShotOnly = false;
} }