This repository has been archived on 2025-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
TjgL fd942ed309 Fixed weapon firing animation being incorrect
Signed-off-by: TjgL <lithmoneo@gmail.com>
2025-03-14 12:45:32 +01:00

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