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.
2025-01-23 23:41:37 +01:00

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