Fixed NeedReloadText & Added it so you cant spam fire shotgun
This commit is contained in:
parent
2fc034892d
commit
b74e7bee9a
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/DoorTestLevel/0/GQ/QPISORMXEPSB0MNOUMBIZ4.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/DoorTestLevel/0/GQ/QPISORMXEPSB0MNOUMBIZ4.uasset
(Stored with Git LFS)
Binary file not shown.
@ -18,10 +18,18 @@ void AShotgunClass::BeginPlay()
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void AShotgunClass::ClickDetectionTimer()
|
||||
{
|
||||
Super::ClickDetectionTimer();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Magenta, TEXT("ClickDetectionTimer Activated"));
|
||||
}
|
||||
|
||||
void AShotgunClass::Fire()
|
||||
{
|
||||
if(currentAmmoCount > 0)
|
||||
if(currentAmmoCount > 0 && !bSingleShotOnly)
|
||||
{
|
||||
bSingleShotOnly = true;
|
||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Magenta, TEXT("Fire Activated"));
|
||||
traceStart = GunStartArrow->GetComponentLocation();
|
||||
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
||||
for (int i = 0; i < 5; i++)
|
||||
@ -30,11 +38,12 @@ void AShotgunClass::Fire()
|
||||
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 --;
|
||||
}
|
||||
currentAmmoCount --;
|
||||
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
|
||||
GenerateRecoilVector();
|
||||
ClickDetectionTimer();
|
||||
this->GetWorld()->GetTimerManager().SetTimer(ShotgunTimerHandle, this, &AShotgunClass::StopFire, FireRate, false);
|
||||
bulletCountShoot += 1;
|
||||
bStopShooting = false;
|
||||
if (outHit.bBlockingHit)
|
||||
@ -51,10 +60,23 @@ void AShotgunClass::Fire()
|
||||
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||
}
|
||||
HideNeedReloadUI();
|
||||
}
|
||||
else if(currentAmmoCount <= 0)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
|
||||
ShowNeedReloadUI();
|
||||
}
|
||||
}
|
||||
|
||||
void AShotgunClass::CancelFire()
|
||||
{
|
||||
Super::CancelFire();
|
||||
}
|
||||
|
||||
void AShotgunClass::StopFire()
|
||||
{
|
||||
bSingleShotOnly = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,9 +22,20 @@ public:
|
||||
UPROPERTY(EditAnywhere, Category = "Weapon")
|
||||
FVector ShotgunBulletSpread;
|
||||
|
||||
FTimerHandle ShotgunTimerHandle;
|
||||
|
||||
void StopFire();
|
||||
|
||||
|
||||
bool bSingleShotOnly;
|
||||
|
||||
protected:
|
||||
virtual void Fire() override;
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void ClickDetectionTimer() override;
|
||||
|
||||
virtual void CancelFire() override;
|
||||
|
||||
};
|
||||
|
@ -72,10 +72,12 @@ void ASniperClass::Fire()
|
||||
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||
}
|
||||
HideNeedReloadUI();
|
||||
}
|
||||
else if(currentAmmoCount <= 0)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
|
||||
ShowNeedReloadUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user