53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Weapon/LMRevolver.h"
|
|
|
|
#include "LMUtils.h"
|
|
#include "Player/LMBulletInfo.h"
|
|
#include "Player/LMPlayer.h"
|
|
|
|
|
|
ALMRevolver::ALMRevolver()
|
|
{
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
}
|
|
|
|
void ALMRevolver::PrimaryFire()
|
|
{
|
|
if (!Player)
|
|
return;
|
|
|
|
State = EWeaponState::EWS_Firing;
|
|
|
|
if (ClipAmmo <= 0)
|
|
{
|
|
if (!Reload())
|
|
{
|
|
PlayEvent(DryFireSound);
|
|
GetWorldTimerManager().SetTimer(FireTimer, this, &ALMRevolver::AllowRefire, RefireDelay / 2);
|
|
}
|
|
return;
|
|
}
|
|
|
|
PlayEvent(FireEvent);
|
|
PlayAnimation(PrimaryFireAnimation);
|
|
Player->PlayAnimation(PrimaryFireArmsAnimation);
|
|
|
|
const FVector Origin = Player->GetWeaponFiringOrigin();
|
|
const FVector Direction = Player->GetAimVector();
|
|
|
|
const int InfiniteClip = LMCheats::CVarInfiniteClip.GetValueOnGameThread();
|
|
if (InfiniteClip == 0)
|
|
ClipAmmo--;
|
|
else if (InfiniteClip == 1 and ClipAmmo > 1)
|
|
ClipAmmo--;
|
|
|
|
FLMBulletInfo ShotInfo = FLMBulletInfo(1, Origin, Direction, WeaponSpread, MaxDistance, DamageFalloff, AmmoType, Damage);
|
|
|
|
Player->FireBullets(ShotInfo);
|
|
OnFire();
|
|
GetWorldTimerManager().SetTimer(FireTimer, this, &ALMRevolver::AllowRefire, RefireDelay);
|
|
}
|
|
|