46 lines
988 B
C++
46 lines
988 B
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Weapon/LMShotgun.h"
|
|
|
|
#include "Player/LMBulletInfo.h"
|
|
#include "Player/LMPlayer.h"
|
|
|
|
|
|
ALMShotgun::ALMShotgun()
|
|
{
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
}
|
|
|
|
void ALMShotgun::PrimaryFire()
|
|
{
|
|
if (!Player)
|
|
return;
|
|
|
|
State = EWeaponState::EWS_Firing;
|
|
|
|
if (ClipAmmo <= 0)
|
|
{
|
|
if (!Reload())
|
|
{
|
|
PlaySound(DryFireSound, true);
|
|
GetWorldTimerManager().SetTimer(FireTimer, this, &ALMShotgun::AllowRefire, RefireDelay / 2);
|
|
}
|
|
return;
|
|
}
|
|
|
|
PlaySound(FireSound, true);
|
|
PlayAnimation(PrimaryFireAnimation);
|
|
|
|
const FVector Origin = Player->GetWeaponFiringOrigin();
|
|
const FVector Direction = Player->GetAimVector();
|
|
|
|
ClipAmmo--;
|
|
|
|
FLMBulletInfo ShotInfo = FLMBulletInfo(PelletCount, Origin, Direction, WeaponSpread, MaxDistance, DamageFalloff, AmmoType, Damage);
|
|
|
|
Player->FireBullets(ShotInfo);
|
|
GetWorldTimerManager().SetTimer(FireTimer, this, &ALMShotgun::AllowRefire, RefireDelay);
|
|
}
|
|
|