2017-10-20 02:00:49 +00:00
|
|
|
class Ext_T_SupplierInteract extends KFUsablePerkTrigger;
|
|
|
|
|
|
|
|
struct FActiveUsers
|
|
|
|
{
|
|
|
|
var Pawn Player;
|
|
|
|
var transient float NextUseTime;
|
|
|
|
};
|
|
|
|
var array<FActiveUsers> ActiveUsers;
|
|
|
|
|
|
|
|
var repnotify KFPawn_Human PlayerOwner;
|
|
|
|
var Ext_PerkBase PerkOwner;
|
|
|
|
|
|
|
|
var() float ReuseTime;
|
|
|
|
var bool bGrenades;
|
|
|
|
|
|
|
|
replication
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (true)
|
2017-10-20 02:00:49 +00:00
|
|
|
PlayerOwner,bGrenades;
|
|
|
|
}
|
|
|
|
|
|
|
|
simulated event ReplicatedEvent(name VarName)
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (VarName=='PlayerOwner' && PlayerOwner!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
SetLocation(PlayerOwner.Location);
|
|
|
|
SetBase(PlayerOwner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
simulated function int GetInteractionIndex(Pawn User)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
return (bGrenades ? IMT_ReceiveGrenades : InteractionIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
simulated event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
|
|
|
|
{
|
|
|
|
local KFPawn_Human KFP;
|
|
|
|
|
|
|
|
Super.Touch(Other, OtherComp, HitLocation, HitNormal);
|
|
|
|
|
|
|
|
KFP = KFPawn_Human(Other);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (KFP != none && KFP.Controller != none && KFP != PlayerOwner)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
KFPlayerController(KFP.Controller).SetPendingInteractionMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
simulated event UnTouch(Actor Other)
|
|
|
|
{
|
|
|
|
local KFPawn_Human KFP;
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
super.UnTouch(Other);
|
2017-10-20 02:00:49 +00:00
|
|
|
|
|
|
|
KFP = KFPawn_Human(Other);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (KFP != none && KFP.Controller != none && KFP != PlayerOwner)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
KFPlayerController(KFP.Controller).SetPendingInteractionMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
simulated function RecheckUser()
|
|
|
|
{
|
|
|
|
local KFPawn_Human Toucher;
|
|
|
|
|
|
|
|
// Notify local player owner that this is available again.
|
|
|
|
foreach TouchingActors(class'KFPawn_Human', Toucher)
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Toucher.IsLocallyControlled())
|
2017-10-20 02:00:49 +00:00
|
|
|
Touch(Toucher,None,Location,vect(1,0,0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
simulated function bool GetCanInteract(Pawn User, optional bool bInteractIfTrue = false)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int i;
|
|
|
|
local ExtPlayerReplicationInfo PRI;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PlayerOwner==None || User==PlayerOwner || KFPawn_Human(User)==None || User.Health<=0)
|
2017-10-20 02:00:49 +00:00
|
|
|
return false;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (WorldInfo.NetMode==NM_Client)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
PRI = ExtPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (!User.IsLocallyControlled() || PRI==None || !PRI.CanUseSupply(User))
|
2017-10-20 02:00:49 +00:00
|
|
|
return false;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bInteractIfTrue)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
PRI.UsedSupply(User,ReuseTime);
|
|
|
|
SetTimer(ReuseTime+0.1,false,'RecheckUser');
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (KFPlayerController(User.Controller)!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
KFPlayerController(User.Controller).SetPendingInteractionMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = ActiveUsers.Find('Player',User);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i>=0 && ActiveUsers[i].NextUseTime>WorldInfo.TimeSeconds)
|
2017-10-20 02:00:49 +00:00
|
|
|
return false;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bInteractIfTrue)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i==-1)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
i = ActiveUsers.Length;
|
|
|
|
ActiveUsers.Length = i+1;
|
|
|
|
ActiveUsers[i].Player = User;
|
|
|
|
SetTimer(10.f,true,'CleanupUsers');
|
|
|
|
}
|
|
|
|
ActiveUsers[i].NextUseTime = WorldInfo.TimeSeconds+ReuseTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bInteractIfTrue && WorldInfo.NetMode!=NM_Client)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
GiveAmmunition(KFPawn_Human(User));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function CleanupUsers()
|
|
|
|
{
|
|
|
|
local int i;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=(ActiveUsers.Length-1); i>=0; --i)
|
|
|
|
if (ActiveUsers[i].Player==None || ActiveUsers[i].Player.Health<=0 || ActiveUsers[i].NextUseTime<WorldInfo.TimeSeconds)
|
2017-10-20 02:00:49 +00:00
|
|
|
ActiveUsers.Remove(i,1);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ActiveUsers.Length==0)
|
2017-10-20 02:00:49 +00:00
|
|
|
ClearTimer('CleanupUsers');
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
final function GiveAmmunition(KFPawn_Human Other)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local KFWeapon KFW;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PlayerController(PlayerOwner.Controller)!=None)
|
2020-11-28 20:04:55 +00:00
|
|
|
PlayerController(PlayerOwner.Controller).ReceiveLocalizedMessage(class'KFLocalMessage_Game', (bGrenades ? GMT_GaveGrenadesTo : GMT_GaveAmmoTo), Other.PlayerReplicationInfo);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PlayerController(Other.Controller)!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:04:55 +00:00
|
|
|
PlayerController(Other.Controller).ReceiveLocalizedMessage(class'KFLocalMessage_Game', (bGrenades ? GMT_ReceivedGrenadesFrom : GMT_ReceivedAmmoFrom), PlayerOwner.PlayerReplicationInfo);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (ExtPlayerController(Other.Controller)!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
ExtPlayerController(Other.Controller).ClientUsedAmmo(Self);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PerkOwner!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
PerkOwner.EarnedEXP(25);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bGrenades)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (KFInventoryManager(Other.InvManager)!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
KFInventoryManager(Other.InvManager).AddGrenades(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-28 20:04:55 +00:00
|
|
|
foreach Other.InvManager.InventoryActors(class'KFWeapon', KFW)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (KFW.DenyPerkResupply())
|
2017-10-20 02:00:49 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// resupply 1 mag for every 5 initial mags
|
2020-11-28 20:04:55 +00:00
|
|
|
KFW.AddAmmo(Max(KFW.InitialSpareMags[0] / 3, 1) * KFW.MagazineCapacity[0]);
|
2017-10-20 02:00:49 +00:00
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (KFW.CanRefillSecondaryAmmo())
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
// resupply 1 mag for every 5 initial mags
|
2020-11-28 20:04:55 +00:00
|
|
|
KFW.AddSecondaryAmmo(Max(KFW.InitialSpareMags[1] / 3, 1));
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
simulated final function UsedOnClient(Pawn User)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local ExtPlayerReplicationInfo PRI;
|
|
|
|
|
|
|
|
PRI = ExtPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PRI!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
PRI.UsedSupply(User,ReuseTime);
|
|
|
|
SetTimer(ReuseTime+0.1,false,'RecheckUser');
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (WorldInfo.NetMode==NM_Client && KFPlayerController(User.Controller)!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
KFPlayerController(User.Controller).SetPendingInteractionMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
simulated function Destroyed()
|
|
|
|
{
|
|
|
|
local KFPawn_Human Toucher;
|
|
|
|
|
|
|
|
//notify all touching actors that they are not touching this non existing trigger anymore
|
|
|
|
foreach TouchingActors(class'KFPawn_Human', Toucher)
|
|
|
|
{
|
|
|
|
UnTouch(Toucher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DefaultProperties
|
|
|
|
{
|
|
|
|
InteractionIndex=IMT_ReceiveAmmo
|
|
|
|
RemoteRole=ROLE_SimulatedProxy
|
|
|
|
bSkipActorPropertyReplication=true
|
|
|
|
bHidden=false
|
|
|
|
ReuseTime=90
|
|
|
|
bProjTarget=false
|
|
|
|
|
|
|
|
Components.Empty()
|
|
|
|
Components.Add(CollisionCylinder)
|
|
|
|
}
|