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

920 lines
23 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
/*
Extended Perk Manager
Written by Marco
*/
Class ExtPerkManager extends KFPerk;
enum EReplicateState
{
REP_CustomCharacters,
REP_CustomInventory,
REP_PerkClasses,
REP_Done
};
const CUR_SaveVersion=2;
var int UserDataVersion;
var transient float LastNapalmTime;
// Server -> Client rep status
var byte RepState;
var int RepIndex;
var array<Ext_PerkBase> UserPerks;
var Ext_PerkBase CurrentPerk;
var int ExpUpStatus[2];
var string StrPerkName;
var ExtPlayerReplicationInfo PRIOwner;
var Controller PlayerOwner;
// Stats
var int TotalEXP,TotalKills,TotalPlayTime;
var bool bStatsDirty,bServerReady,bUserStatsBroken,bCurrentlyHealing;
// SWAT Enforcer
var array<Actor> CurrentBumpedActors; // The unique list of actors that have been bumped before the last cooldown reset
var float LastBumpTime; // The last time a zed was bumped using battering ram
var float BumpCooldown; // The amount of time between when the last actor was bumped and another actor can be bumped again
var float BumpMomentum; // Amount of momentum when bumping zeds
var int BumpDamageAmount; // Amount of damage Battering Ram bumps deal
var class<DamageType> BumpDamageType; // Damage type used for Battering Ram bump damage
2017-10-20 02:00:49 +00:00
replication
{
// Things the server should send to the client.
2020-11-28 20:04:55 +00:00
if (bNetDirty)
2017-10-20 02:00:49 +00:00
CurrentPerk;
}
2020-11-28 20:04:55 +00:00
final function SetGrenadeCap(byte AddedCap)
2017-10-20 02:00:49 +00:00
{
MaxGrenadeCount = Default.MaxGrenadeCount + AddedCap;
2020-11-28 20:12:58 +00:00
if (RepState==REP_Done)
2017-10-20 02:00:49 +00:00
ClientSetGrenadeCap(MaxGrenadeCount);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated reliable client function ClientSetGrenadeCap(byte NewCap)
2017-10-20 02:00:49 +00:00
{
MaxGrenadeCount = NewCap;
}
2020-11-28 20:04:55 +00:00
function bool ApplyPerkClass(class<Ext_PerkBase> P)
2017-10-20 02:00:49 +00:00
{
local int i;
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
if (UserPerks[i].Class==P)
2017-10-20 02:00:49 +00:00
{
ApplyPerk(UserPerks[i]);
return true;
}
return false;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function bool ApplyPerkName(string S)
2017-10-20 02:00:49 +00:00
{
local int i;
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
if (string(UserPerks[i].Class.Name)~=S)
2017-10-20 02:00:49 +00:00
{
ApplyPerk(UserPerks[i]);
return true;
}
return false;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function ApplyPerk(Ext_PerkBase P)
2017-10-20 02:00:49 +00:00
{
local KFPawn_Human HP;
local KFInventoryManager InvMan;
local Ext_T_ZEDHelper H;
local int i;
2020-11-28 20:12:58 +00:00
if (P==None)
2017-10-20 02:00:49 +00:00
return;
2020-11-28 20:12:58 +00:00
if (PlayerOwner.Pawn != None)
{
InvMan = KFInventoryManager(PlayerOwner.Pawn.InvManager);
2020-11-28 20:12:58 +00:00
if (InvMan != None)
InvMan.MaxCarryBlocks = InvMan.Default.MaxCarryBlocks;
foreach PlayerOwner.Pawn.ChildActors(class'Ext_T_ZEDHelper',H)
{
H.Destroy();
}
HP = KFPawn_Human(PlayerOwner.Pawn);
2020-11-28 20:12:58 +00:00
if (HP != None)
HP.DefaultInventory = HP.Default.DefaultInventory;
}
2020-11-28 20:12:58 +00:00
if (CurrentPerk != None)
{
2017-10-20 02:00:49 +00:00
CurrentPerk.DeactivateTraits();
2020-11-28 20:12:58 +00:00
for (i=0; i<CurrentPerk.PerkTraits.Length; ++i)
{
CurrentPerk.PerkTraits[i].TraitType.Static.CancelEffectOn(KFPawn_Human(PlayerOwner.Pawn),CurrentPerk,CurrentPerk.PerkTraits[i].CurrentLevel,CurrentPerk.PerkTraits[i].Data);
}
}
2017-10-20 02:00:49 +00:00
bStatsDirty = true;
CurrentPerk = P;
2020-11-28 20:12:58 +00:00
if (PRIOwner!=None)
2017-10-20 02:00:49 +00:00
{
PRIOwner.ECurrentPerk = P.Class;
PRIOwner.FCurrentPerk = P;
2017-10-20 02:00:49 +00:00
P.UpdatePRILevel();
}
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
{
2017-10-20 02:00:49 +00:00
CurrentPerk.ActivateTraits();
2020-11-28 20:12:58 +00:00
if (PlayerOwner.Pawn != None)
{
HP = KFPawn_Human(PlayerOwner.Pawn);
2020-11-28 20:12:58 +00:00
if (HP != None)
{
HP.HealthMax = HP.default.Health;
HP.MaxArmor = HP.default.MaxArmor;
ModifyHealth(HP.HealthMax);
ModifyArmor(HP.MaxArmor);
CurrentPerk.UpdateAmmoStatus(HP.InvManager);
2020-11-28 20:12:58 +00:00
if (HP.Health > HP.HealthMax) HP.Health = HP.HealthMax;
if (HP.Armor > HP.MaxArmor) HP.Armor = HP.MaxArmor;
}
}
}
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 Ext_PerkBase FindPerk(class<Ext_PerkBase> P)
2017-10-20 02:00:49 +00:00
{
local int i;
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
if (UserPerks[i].Class==P)
2017-10-20 02:00:49 +00:00
return UserPerks[i];
return None;
}
simulated function PostBeginPlay()
{
SetTimer(0.01,false,'InitPerks');
2020-11-28 20:12:58 +00:00
if (WorldInfo.NetMode!=NM_Client)
2017-10-20 02:00:49 +00:00
SetTimer(1,true,'CheckPlayTime');
}
simulated function InitPerks()
{
local Ext_PerkBase P;
2020-11-28 20:12:58 +00:00
if (WorldInfo.NetMode==NM_Client)
2017-10-20 02:00:49 +00:00
{
foreach DynamicActors(class'Ext_PerkBase',P)
2020-11-28 20:12:58 +00:00
if (P.PerkManager!=Self)
2017-10-20 02:00:49 +00:00
RegisterPerk(P);
}
2020-11-28 20:12:58 +00:00
else if (PRIOwner!=PlayerOwner.PlayerReplicationInfo) // See if was assigned an inactive PRI.
2017-10-20 02:00:49 +00:00
{
PRIOwner = ExtPlayerReplicationInfo(PlayerOwner.PlayerReplicationInfo);
2020-11-28 20:12:58 +00:00
if (PRIOwner!=None)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
{
PRIOwner.ECurrentPerk = CurrentPerk.Class;
CurrentPerk.UpdatePRILevel();
}
PRIOwner.RepKills = TotalKills;
PRIOwner.RepEXP = TotalEXP;
PRIOwner.SetInitPlayTime(TotalPlayTime);
PRIOwner.PerkManager = Self;
}
}
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function CheckPlayTime()
{
++TotalPlayTime; // Stats.
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function ServerInitPerks()
{
local int i;
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
2017-10-20 02:00:49 +00:00
UserPerks[i].SetInitialLevel();
bServerReady = true;
CurrentPerk = None;
2020-11-28 20:12:58 +00:00
if (StrPerkName!="")
2017-10-20 02:00:49 +00:00
ApplyPerkName(StrPerkName);
2020-11-28 20:12:58 +00:00
if (CurrentPerk==None)
2017-10-20 02:00:49 +00:00
ApplyPerk(UserPerks[Rand(UserPerks.Length)]);
}
2020-11-28 20:04:55 +00:00
simulated function RegisterPerk(Ext_PerkBase P)
2017-10-20 02:00:49 +00:00
{
UserPerks[UserPerks.Length] = P;
P.PerkManager = Self;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function UnregisterPerk(Ext_PerkBase P)
2017-10-20 02:00:49 +00:00
{
UserPerks.RemoveItem(P);
P.PerkManager = None;
}
function Destroyed()
{
local int i;
2020-11-28 20:12:58 +00:00
for (i=(UserPerks.Length-1); i>=0; --i)
2017-10-20 02:00:49 +00:00
{
UserPerks[i].PerkManager = None;
UserPerks[i].Destroy();
}
}
2020-11-28 20:04:55 +00:00
function EarnedEXP(int EXP, optional byte Mode)
2017-10-20 02:00:49 +00:00
{
2020-06-22 06:45:04 +00:00
// `log("EarnedEXP" @ GetScriptTrace());
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
{
// Limit how much EXP we got for healing and welding.
2020-11-28 20:12:58 +00:00
switch (Mode)
2017-10-20 02:00:49 +00:00
{
case 1:
ExpUpStatus[0]+=EXP;
EXP = ExpUpStatus[0]/CurrentPerk.WeldExpUpNum;
2020-11-28 20:12:58 +00:00
if (EXP>0)
2017-10-20 02:00:49 +00:00
ExpUpStatus[0]-=(EXP*CurrentPerk.WeldExpUpNum);
break;
case 2:
ExpUpStatus[1]+=EXP;
EXP = ExpUpStatus[1]/CurrentPerk.HealExpUpNum;
2020-11-28 20:12:58 +00:00
if (EXP>0)
2017-10-20 02:00:49 +00:00
ExpUpStatus[1]-=(EXP*CurrentPerk.HealExpUpNum);
break;
}
2020-11-28 20:12:58 +00:00
if (EXP>0 && CurrentPerk.EarnedEXP(EXP))
2017-10-20 02:00:49 +00:00
{
TotalEXP+=EXP;
PRIOwner.RepEXP+=EXP;
bStatsDirty = true;
}
}
}
// XML stat writing
2020-11-28 20:04:55 +00:00
function OutputXML(ExtStatWriter Data)
2017-10-20 02:00:49 +00:00
{
local string S;
local int i;
Data.StartIntendent("user","ver",string(CUR_SaveVersion));
Data.WriteValue("id64",OnlineSubsystemSteamworks(class'GameEngine'.Static.GetOnlineSubsystem()).UniqueNetIdToInt64(PRIOwner.UniqueId));
Data.WriteValue("name",PRIOwner.PlayerName);
Data.WriteValue("exp",string(TotalEXP));
Data.WriteValue("kills",string(TotalKills));
Data.WriteValue("time",string(TotalPlayTime));
2020-11-28 20:12:58 +00:00
if (ExtPlayerController(Owner)!=None && ExtPlayerController(Owner).PendingPerkClass!=None)
2017-10-20 02:00:49 +00:00
S = string(ExtPlayerController(Owner).PendingPerkClass.Name);
else S = (CurrentPerk!=None ? string(CurrentPerk.Class.Name) : "None");
Data.WriteValue("activeperk",S);
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
if (UserPerks[i].HasAnyProgress())
2017-10-20 02:00:49 +00:00
UserPerks[i].OutputXML(Data);
Data.EndIntendent();
}
// Data saving.
2020-11-28 20:04:55 +00:00
function SaveData(ExtSaveDataBase Data)
2017-10-20 02:00:49 +00:00
{
local int i,o;
Data.FlushData();
Data.SetSaveVersion(++UserDataVersion);
Data.SetArVer(CUR_SaveVersion);
// Write global stats.
Data.SaveInt(TotalEXP,3);
Data.SaveInt(TotalKills,3);
Data.SaveInt(TotalPlayTime,3);
// Write character.
2020-11-28 20:12:58 +00:00
if (PRIOwner!=None)
2017-10-20 02:00:49 +00:00
PRIOwner.SaveCustomCharacter(Data);
else class'ExtPlayerReplicationInfo'.Static.DummySaveChar(Data);
// Write selected perk.
2020-11-28 20:12:58 +00:00
if (ExtPlayerController(Owner)!=None && ExtPlayerController(Owner).PendingPerkClass!=None)
2017-10-20 02:00:49 +00:00
Data.SaveStr(string(ExtPlayerController(Owner).PendingPerkClass.Name));
else Data.SaveStr(CurrentPerk!=None ? string(CurrentPerk.Class.Name) : "");
// Count how many progressed perks we have.
o = 0;
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
if (UserPerks[i].HasAnyProgress())
2017-10-20 02:00:49 +00:00
++o;
// Then write count we have.
Data.SaveInt(o);
// Then perk stats.
2020-11-28 20:12:58 +00:00
for (i=0; i<UserPerks.Length; ++i)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (!UserPerks[i].HasAnyProgress()) // Skip this perk.
2017-10-20 02:00:49 +00:00
continue;
Data.SaveStr(string(UserPerks[i].Class.Name));
o = Data.TellOffset(); // Mark checkpoint.
Data.SaveInt(0,1); // Reserve space for later.
UserPerks[i].SaveData(Data);
// Now save the skip offset for perk data incase perk gets removed from server.
Data.SeekOffset(o);
Data.SaveInt(Data.TotalSize(),1);
Data.ToEnd();
}
}
// Data loading.
2020-11-28 20:04:55 +00:00
function LoadData(ExtSaveDataBase Data)
2017-10-20 02:00:49 +00:00
{
local int i,j,l,o;
local string S;
Data.ToStart();
UserDataVersion = Data.GetSaveVersion();
// Read global stats.
TotalEXP = Data.ReadInt(3);
TotalKills = Data.ReadInt(3);
TotalPlayTime = Data.ReadInt(3);
// Read character.
2020-11-28 20:12:58 +00:00
if (PRIOwner!=None)
2017-10-20 02:00:49 +00:00
{
PRIOwner.RepKills = TotalKills;
PRIOwner.RepEXP = TotalEXP;
PRIOwner.SetInitPlayTime(TotalPlayTime);
PRIOwner.LoadCustomCharacter(Data);
}
else class'ExtPlayerReplicationInfo'.Static.DummyLoadChar(Data);
// Find selected perk.
CurrentPerk = None;
StrPerkName = Data.ReadStr();
l = Data.ReadInt(); // Perk stats length.
2020-11-28 20:12:58 +00:00
for (i=0; i<l; ++i)
2017-10-20 02:00:49 +00:00
{
S = Data.ReadStr();
o = Data.ReadInt(1); // Read skip offset.
Data.PushEOFLimit(o);
2020-11-28 20:12:58 +00:00
for (j=0; j<UserPerks.Length; ++j)
if (S~=string(UserPerks[j].Class.Name))
2017-10-20 02:00:49 +00:00
{
UserPerks[j].LoadData(Data);
break;
}
Data.PopEOFLimit();
Data.SeekOffset(o); // Jump to end of this section.
}
bStatsDirty = false;
}
2020-11-28 20:04:55 +00:00
function AddDefaultInventory(KFPawn P)
2017-10-20 02:00:49 +00:00
{
local KFInventoryManager KFIM;
2020-11-28 20:12:58 +00:00
if (P != none && P.InvManager != none)
2017-10-20 02:00:49 +00:00
{
KFIM = KFInventoryManager(P.InvManager);
2020-11-28 20:12:58 +00:00
if (KFIM != none)
2017-10-20 02:00:49 +00:00
{
//Grenades added on spawn
KFIM.GiveInitialGrenadeCount();
}
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.AddDefaultInventory(P);
}
}
simulated function PlayerDied()
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.PlayerDied();
}
function PreNotifyPlayerLeave()
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.DeactivateTraits();
}
// Start client replication of perks data.
// Call this once the stats has been properly loaded serverside!
function InitiateClientRep()
{
RepState = 0;
RepIndex = 0;
SetTimer(0.01,true,'ReplicateTimer');
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function ReplicateTimer()
{
2020-11-28 20:12:58 +00:00
switch (RepState)
2017-10-20 02:00:49 +00:00
{
case REP_CustomCharacters: // Replicate custom characters.
2020-11-28 20:12:58 +00:00
if (RepIndex>=PRIOwner.CustomCharList.Length)
2017-10-20 02:00:49 +00:00
{
PRIOwner.AllCharReceived();
RepIndex = 0;
++RepState;
}
else
{
PRIOwner.ReceivedCharacter(RepIndex,PRIOwner.CustomCharList[RepIndex]);
++RepIndex;
}
break;
case REP_CustomInventory: // Replicate custom trader inventory
2020-11-28 20:12:58 +00:00
if (!PRIOwner.OnRepNextItem(PRIOwner,RepIndex))
2017-10-20 02:00:49 +00:00
{
RepIndex = 0;
++RepState;
}
else ++RepIndex;
break;
case REP_PerkClasses: // Open up all actor channel connections.
2020-11-28 20:12:58 +00:00
if (RepIndex>=UserPerks.Length)
2017-10-20 02:00:49 +00:00
{
RepIndex = 0;
++RepState;
}
2020-11-28 20:12:58 +00:00
else if (UserPerks[RepIndex].bClientAuthorized)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (UserPerks[RepIndex].bPerkNetReady)
2017-10-20 02:00:49 +00:00
++RepIndex;
}
else
{
UserPerks[RepIndex].RemoteRole = ROLE_SimulatedProxy;
2020-11-28 20:12:58 +00:00
if (UserPerks[RepIndex].NextAuthTime<WorldInfo.RealTimeSeconds)
2017-10-20 02:00:49 +00:00
{
UserPerks[RepIndex].NextAuthTime = WorldInfo.RealTimeSeconds+0.5;
UserPerks[RepIndex].ClientAuth();
}
}
break;
default:
2020-11-28 20:12:58 +00:00
if (MaxGrenadeCount!=Default.MaxGrenadeCount)
2017-10-20 02:00:49 +00:00
ClientSetGrenadeCap(MaxGrenadeCount);
ClearTimer('ReplicateTimer');
}
}
2020-11-28 20:04:55 +00:00
function bool CanEarnSmallRadiusKillXP(class<DamageType> DT)
2017-10-20 02:00:49 +00:00
{
return true;
}
2020-11-28 20:04:55 +00:00
simulated function ModifySpeed(out float Speed)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
Speed *= CurrentPerk.Modifiers[0];
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function ModifyDamageGiven(out int InDamage, optional Actor DamageCauser, optional KFPawn_Monster MyKFPM, optional KFPlayerController DamageInstigator, optional class<KFDamageType> DamageType, optional int HitZoneIdx)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyDamageGiven(InDamage,DamageCauser,MyKFPM,DamageInstigator,DamageType,HitZoneIdx);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyDamageTaken(out int InDamage, optional class<DamageType> DamageType, optional Controller InstigatedBy)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyDamageTaken(InDamage,DamageType,InstigatedBy);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyRecoil(out float CurrentRecoilModifier, KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyRecoil(CurrentRecoilModifier,KFW);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifySpread(out float InSpread)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifySpread(InSpread);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyRateOfFire(out float InRate, KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyRateOfFire(InRate,KFW);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function float GetReloadRateScale(KFWeapon KFW)
{
return (CurrentPerk!=None ? CurrentPerk.GetReloadRateScale(KFW) : 1.f);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function bool GetUsingTactialReload(KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetUsingTactialReload(KFW) : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function ModifyHealth(out int InHealth)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyHealth(InHealth);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function ModifyArmor(out byte MaxArmor)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyArmor(MaxArmor);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function float GetKnockdownPowerModifier(optional class<DamageType> DamageType, optional byte BodyPart, optional bool bIsSprinting=false)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetKnockdownPowerModifier() : 1.f);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function float GetStumblePowerModifier(optional KFPawn KFP, optional class<KFDamageType> DamageType, optional out float CooldownModifier, optional byte BodyPart)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetKnockdownPowerModifier() : 1.f);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function float GetStunPowerModifier(optional class<DamageType> DamageType, optional byte HitZoneIdx)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetStunPowerModifier(DamageType,HitZoneIdx) : 1.f);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyMeleeAttackSpeed(out float InDuration, KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyMeleeAttackSpeed(InDuration);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function class<KFProj_Grenade> GetGrenadeClass()
{
2020-11-28 19:53:57 +00:00
return (CurrentPerk!=None ? CurrentPerk.GrenadeClass : GrenadeClass);
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 function ModifyWeldingRate(out float FastenRate, out float UnfastenRate)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyWeldingRate(FastenRate,UnfastenRate);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function bool HasNightVision()
{
return (CurrentPerk!=None ? CurrentPerk.bHasNightVision : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function bool RepairArmor(Pawn HealTarget)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.RepairArmor(HealTarget) : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function bool ModifyHealAmount(out float HealAmount)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.ModifyHealAmount(HealAmount) : false);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function bool CanNotBeGrabbed()
{
return (CurrentPerk!=None ? !CurrentPerk.bCanBeGrabbed : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyMagSizeAndNumber(KFWeapon KFW, out int MagazineCapacity, optional array< Class<KFPerk> > WeaponPerkClass, optional bool bSecondary=false, optional name WeaponClassname)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyMagSizeAndNumber(KFW,MagazineCapacity,WeaponPerkClass,bSecondary,WeaponClassname);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifySpareAmmoAmount(KFWeapon KFW, out int PrimarySpareAmmo, optional const out STraderItem TraderItem, optional bool bSecondary=false)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifySpareAmmoAmount(KFW,PrimarySpareAmmo,TraderItem,bSecondary);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyMaxSpareAmmoAmount(KFWeapon KFW, out int SpareAmmoCapacity, optional const out STraderItem TraderItem, optional bool bSecondary=false)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifySpareAmmoAmount(KFW,SpareAmmoCapacity,TraderItem,bSecondary);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function bool ShouldMagSizeModifySpareAmmo(KFWeapon KFW, optional Class<KFPerk> WeaponPerkClass)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.ShouldMagSizeModifySpareAmmo(KFW,WeaponPerkClass) : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function ModifyHealerRechargeTime(out float RechargeRate)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyHealerRechargeTime(RechargeRate);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function bool CanExplosiveWeld()
{
return (CurrentPerk!=None ? CurrentPerk.bExplosiveWeld : false);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function bool IsOnContactActive()
{
return (CurrentPerk!=None ? CurrentPerk.bExplodeOnContact : false);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function bool CanSpreadNapalm()
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None && CurrentPerk.bNapalmFire && LastNapalmTime!=WorldInfo.TimeSeconds)
2017-10-20 02:00:49 +00:00
{
LastNapalmTime = WorldInfo.TimeSeconds; // Avoid infinite script recursion in KFPawn_Monster.
return true;
}
return false;
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function bool IsRangeActive()
{
return MyPRI!=None ? MyPRI.bExtraFireRange : false;
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function DrawSpecialPerkHUD(Canvas C)
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.DrawSpecialPerkHUD(C);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function PlayerKilled(KFPawn_Monster Victim, class<DamageType> DamageType)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.PlayerKilled(Victim,DamageType);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function ModifyBloatBileDoT(out float DoTScaler)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.ModifyBloatBileDoT(DoTScaler);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function bool GetIsUberAmmoActive(KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetIsUberAmmoActive(KFW) : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function UpdatePerkHeadShots(ImpactInfo Impact, class<DamageType> DamageType, int NumHit)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
CurrentPerk.UpdatePerkHeadShots(Impact,DamageType,NumHit);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function CheckForAirborneAgent(KFPawn HealTarget, class<DamageType> DamType, int HealAmount)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (!bCurrentlyHealing && CurrentPerk!=None)
2017-10-20 02:00:49 +00:00
{
// Using boolean to avoid infinite recursion.
bCurrentlyHealing = true;
CurrentPerk.CheckForAirborneAgent(HealTarget,DamType,HealAmount);
bCurrentlyHealing = false;
}
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function float GetZedTimeModifier(KFWeapon W)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetZedTimeModifier(W) : 0.f);
}
// Poison darts
function bool IsAcidicCompoundActive()
{
return (CurrentPerk!=None ? CurrentPerk.bToxicDart : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function ModifyACDamage(out int InDamage)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPerk!=None && CurrentPerk.bToxicDart)
2017-10-20 02:00:49 +00:00
InDamage += CurrentPerk.ToxicDartDamage;
}
// Zombie explosion!
2020-11-28 20:04:55 +00:00
function bool CouldBeZedShrapnel(class<KFDamageType> KFDT)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? (CurrentPerk.bFireExplode && class<KFDT_Fire>(KFDT)!=None) : false);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function bool ShouldShrapnel()
{
return (CurrentPerk!=None ? (CurrentPerk.bFireExplode && Rand(3)==0) : false);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function GameExplosion GetExplosionTemplate()
{
return class'KFPerk_Firebug'.Default.ExplosionTemplate;
}
// Additional functions
function OnWaveEnded()
{
CurrentPerk.OnWaveEnded();
}
2020-11-28 21:54:57 +00:00
function NotifyZedTimeStarted()
{
CurrentPerk.NotifyZedTimeStarted();
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function float GetZedTimeExtensions(byte Level)
{
return CurrentPerk.GetZedTimeExtensions(Level);
}
2017-10-20 02:00:49 +00:00
// SWAT:
simulated function bool HasHeavyArmor()
{
return (CurrentPerk!=None && CurrentPerk.bHeavyArmor);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function float GetIronSightSpeedModifier(KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetIronSightSpeedModifier(KFW) : 1.f);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function float GetCrouchSpeedModifier(KFWeapon KFW)
2017-10-20 02:00:49 +00:00
{
return (CurrentPerk!=None ? CurrentPerk.GetIronSightSpeedModifier(KFW) : 1.f);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function bool ShouldKnockDownOnBump()
{
return (CurrentPerk!=None && CurrentPerk.bHasSWATEnforcer);
}
simulated function OnBump(Actor BumpedActor, KFPawn_Human BumpInstigator, vector BumpedVelocity, rotator BumpedRotation)
{
local KFPawn_Monster KFPM;
local bool CanBump;
if (ShouldKnockDownOnBump() && Normal(BumpedVelocity) dot Vector(BumpedRotation) > 0.7f)
{
KFPM = KFPawn_Monster(BumpedActor);
if (KFPM != none)
{
// cooldown so that the same zed can't be bumped multiple frames back to back
// especially relevant if they can't be knocked down or stumbled so the player is always bumping them
if (WorldInfo.TimeSeconds - LastBumpTime > BumpCooldown)
{
CurrentBumpedActors.length = 0;
CurrentBumpedActors.AddItem(BumpedActor);
CanBump = true;
}
// if still within the cooldown time, can still bump the actor as long as it hasn't been bumped yet
else if (CurrentBumpedActors.Find(BumpedActor) == INDEX_NONE)
{
CurrentBumpedActors.AddItem(BumpedActor);
CanBump = true;
}
LastBumpTime = WorldInfo.TimeSeconds;
if (CanBump)
{
if (KFPM.IsHeadless())
{
KFPM.TakeDamage(KFPM.HealthMax, BumpInstigator.Controller, BumpInstigator.Location,
Normal(vector(BumpedRotation)) * BumpMomentum, BumpDamageType);
}
else
{
KFPM.TakeDamage(BumpDamageAmount, BumpInstigator.Controller, BumpInstigator.Location,
Normal(vector(BumpedRotation)) * BumpMomentum, BumpDamageType);
KFPM.Knockdown(BumpedVelocity * 3, vect(1, 1, 1), KFPM.Location, 1000, 100);
}
}
}
}
}
// DEMO:
simulated function bool ShouldRandSirenResist()
{
return (Ext_PerkDemolition(CurrentPerk)!=None ? Ext_PerkDemolition(CurrentPerk).bSirenResistance : false);
}
2020-11-28 21:54:57 +00:00
simulated function bool IsAoEActive()
{
return (Ext_PerkDemolition(CurrentPerk)!=None ? Ext_PerkDemolition(CurrentPerk).AOEMult > 1.0f : false);
}
2020-11-28 21:54:57 +00:00
simulated function bool ShouldSacrifice()
{
return (Ext_PerkDemolition(CurrentPerk)!=None ? (Ext_PerkDemolition(CurrentPerk).bCanUseSacrifice && !Ext_PerkDemolition(CurrentPerk).bUsedSacrifice) : false);
}
2020-11-28 21:54:57 +00:00
simulated function bool ShouldNeverDud()
{
return (Ext_PerkDemolition(CurrentPerk)!=None ? Ext_PerkDemolition(CurrentPerk).bProfessionalActive : false);
}
2020-11-28 21:54:57 +00:00
function NotifyPerkSacrificeExploded()
{
2020-11-28 20:12:58 +00:00
if (Ext_PerkDemolition(CurrentPerk) != none) Ext_PerkDemolition(CurrentPerk).bUsedSacrifice = true;
}
2020-11-28 21:54:57 +00:00
simulated function float GetAoERadiusModifier()
{
return (Ext_PerkDemolition(CurrentPerk)!=None ? Ext_PerkDemolition(CurrentPerk).GetAoERadiusModifier() : 1.0);
}
// MEDIC:
simulated function bool GetHealingSpeedBoostActive()
{
return (Ext_PerkFieldMedic(CurrentPerk)!=None ? Ext_PerkFieldMedic(CurrentPerk).GetHealingSpeedBoostActive() : false);
}
2020-11-28 21:54:57 +00:00
simulated function bool GetHealingDamageBoostActive()
{
return (Ext_PerkFieldMedic(CurrentPerk)!=None ? Ext_PerkFieldMedic(CurrentPerk).GetHealingDamageBoostActive() : false);
}
2020-11-28 21:54:57 +00:00
simulated function bool GetHealingShieldActive()
{
return (Ext_PerkFieldMedic(CurrentPerk)!=None ? Ext_PerkFieldMedic(CurrentPerk).GetHealingShieldActive() : false);
}
2020-11-28 21:54:57 +00:00
simulated function float GetSelfHealingSurgePct()
{
return (Ext_PerkFieldMedic(CurrentPerk)!=None ? Ext_PerkFieldMedic(CurrentPerk).GetSelfHealingSurgePct() : 0.f);
}
2020-11-28 21:54:57 +00:00
function bool IsToxicDmgActive()
{
return (Ext_PerkFieldMedic(CurrentPerk)!=None ? Ext_PerkFieldMedic(CurrentPerk).bUseToxicDamage : false);
}
2020-11-28 21:54:57 +00:00
static function class<KFDamageType> GetToxicDmgTypeClass()
{
return class'Ext_PerkFieldMedic'.static.GetToxicDmgTypeClass();
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
static function ModifyToxicDmg(out int ToxicDamage)
{
ToxicDamage = class'Ext_PerkFieldMedic'.static.ModifyToxicDmg(ToxicDamage);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function float GetSnarePower(optional class<DamageType> DamageType, optional byte HitZoneIdx)
{
return (Ext_PerkFieldMedic(CurrentPerk)!=None ? Ext_PerkFieldMedic(CurrentPerk).GetSnarePower(DamageType, HitZoneIdx) : 0.f);
}
// SUPPORT:
2017-10-22 09:16:27 +00:00
simulated function bool CanRepairDoors()
{
return (Ext_PerkSupport(CurrentPerk)!=None ? Ext_PerkSupport(CurrentPerk).CanRepairDoors() : false);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
simulated function float GetPenetrationModifier(byte Level, class<KFDamageType> DamageType, optional bool bForce )
{
return (Ext_PerkSupport(CurrentPerk)!=None ? Ext_PerkSupport(CurrentPerk).GetPenetrationModifier(Level, DamageType, bForce) : 0.f);
}
// Other
function ApplySkillsToPawn()
{
2020-11-28 20:12:58 +00:00
if (CheckOwnerPawn())
{
OwnerPawn.UpdateGroundSpeed();
OwnerPawn.bMovesFastInZedTime = false;
2020-11-28 20:12:58 +00:00
if (MyPRI == none)
MyPRI = KFPlayerReplicationInfo(OwnerPawn.PlayerReplicationInfo);
ApplyWeightLimits();
}
}
2017-10-20 02:00:49 +00:00
defaultproperties
{
bTickIsDisabled=false
NetPriority=3.5
// SWAT bumping
BumpCooldown = 0.1f
BumpMomentum=1.f
BumpDamageAmount=450
BumpDamageType=class'KFDT_SWATBatteringRam'
2017-10-20 02:00:49 +00:00
}