KF2-Server-Extension/ServerExt/Classes/Ext_T_AutoFireHelper.uc

62 lines
1.4 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class Ext_T_AutoFireHelper extends Info
transient;
var class<KFPerk> AssociatedPerkClass;
var Pawn PawnOwner;
var PlayerController LocalPC;
var bool bNetworkOwner;
replication
{
2020-11-28 20:04:55 +00:00
if (bNetOwner)
2017-10-20 02:00:49 +00:00
PawnOwner,AssociatedPerkClass;
}
function PostBeginPlay()
{
PawnOwner = Pawn(Owner);
2020-11-28 20:12:58 +00:00
if (PawnOwner==None)
2017-10-20 02:00:49 +00:00
Destroy();
else SetTimer(0.5+FRand()*0.4,true);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function Timer()
{
2020-11-28 20:12:58 +00:00
if (PawnOwner==None || PawnOwner.Health<=0 || PawnOwner.InvManager==None)
2017-10-20 02:00:49 +00:00
Destroy();
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function Tick(float Delta)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:04:55 +00:00
if (WorldInfo.NetMode==NM_DedicatedServer
2020-10-05 18:38:02 +00:00
|| PawnOwner==None
|| PawnOwner.InvManager==None
|| KFWeapon(PawnOwner.Weapon)==None
2020-11-28 20:04:55 +00:00
|| (KFWeapon(PawnOwner.Weapon).GetWeaponPerkClass(AssociatedPerkClass) != AssociatedPerkClass && AssociatedPerkClass != class'KFPerk_Survivalist'))
2017-10-20 02:00:49 +00:00
return;
2023-05-14 02:49:12 +00:00
2017-10-20 02:00:49 +00:00
// Find local playercontroller.
2020-11-28 20:12:58 +00:00
if (LocalPC==None)
2017-10-20 02:00:49 +00:00
{
LocalPC = PlayerController(PawnOwner.Controller);
2020-11-28 20:12:58 +00:00
if (LocalPC==None)
2017-10-20 02:00:49 +00:00
return;
bNetworkOwner = (LocalPlayer(LocalPC.Player)!=None);
}
2020-11-28 20:12:58 +00:00
if (!bNetworkOwner)
2017-10-20 02:00:49 +00:00
return;
// Force always to pending fire.
2020-11-28 20:12:58 +00:00
if (LocalPC.bFire!=0 && !PawnOwner.InvManager.IsPendingFire(None,0))
2017-10-20 02:00:49 +00:00
PawnOwner.Weapon.StartFire(0);
2020-11-28 20:12:58 +00:00
else if (LocalPC.bAltFire!=0 && !PawnOwner.InvManager.IsPendingFire(None,1))
2017-10-20 02:00:49 +00:00
PawnOwner.Weapon.StartFire(1);
}
defaultproperties
{
Components.Empty()
RemoteRole=ROLE_SimulatedProxy
bOnlyRelevantToOwner=true
}