fix: XP for killing with TF2Sentry

This commit is contained in:
GenZmeY 2020-11-29 01:51:29 +03:00
parent e68d21f1d9
commit f26d0163b4

View File

@ -568,8 +568,9 @@ function bool IsFromMod(Object O)
return true;
}
function ScoreKill(Controller Killer, Controller Killed)
function CustomXP(Controller Killer, Controller Killed)
{
local KFPlayerController KFPC;
local KFPawn_Monster KFM;
local int i, j;
local KFPlayerReplicationInfo DamagerKFPRI;
@ -577,97 +578,103 @@ function ScoreKill(Controller Killer, Controller Killed)
local KFPerk InstigatorPerk;
local bool cont;
KFM = KFPawn_Monster(Killed.Pawn);
for (i = 0; i < KFM.DamageHistory.Length; i++)
{
DamagerKFPRI = KFPlayerReplicationInfo(KFM.DamageHistory[i].DamagerPRI);
if (DamagerKFPRI != None)
{
// Check that no mods are used in this kill
cont = true;
for (j=0; j < KFM.DamageHistory[i].DamageCausers.Length; j++)
{
if (IsFromMod(KFM.DamageHistory[i].DamageCausers[j]) || IsFromMod(KFM.DamageHistory[i].DamageTypes[j]))
{
cont = false;
break;
}
}
if (cont && !IsFromMod(KFM))
{
// No mods - exit the loop, the game will add experience by itself
continue;
}
// Distribute experience points
KFPC = KFPlayerController(DamagerKFPRI.Owner);
if (KFPC != none)
{
XP = 0;
for (j = 0; j < CustomZedXPArray.Length; j++)
{
if (KFM.Class == CustomZedXPArray[j].zedclass)
{
XP = CustomZedXPArray[j].XPValues[MyKFGI.GameDifficulty];
break;
}
}
if (XP == 0)
{
XP = KFM.static.GetXPValue(MyKFGI.GameDifficulty);
}
InstigatorPerk = KFPC.GetPerk();
// Special for survivalist - he gets experience for everything
// And for TF2Sentry - he has no perk in DamageHistory
if (InstigatorPerk.ShouldGetAllTheXP() || KFM.DamageHistory[i].DamagePerks.Length == 0)
{
KFPC.OnPlayerXPAdded(XP, InstigatorPerk.Class);
continue;
}
XP /= KFM.DamageHistory[i].DamagePerks.Length;
for (j = 0; j < KFM.DamageHistory[i].DamagePerks.Length; j++)
{
KFPC.OnPlayerXPAdded(FCeil(XP), KFM.DamageHistory[i].DamagePerks[j]);
}
}
}
}
}
function ScoreKill(Controller Killer, Controller Killed)
{
local KFPlayerController KFPC;
local ExtPerkManager KillersPerk;
if (bRespawnCheck && Killed.bIsPlayer)
CheckRespawn(Killed);
KFM = KFPawn_Monster(Killed.Pawn);
if (KFM!=None && Killed.GetTeamNum()!=0 && Killer.bIsPlayer && Killer.GetTeamNum()==0)
if (KFPawn_Monster(Killed.Pawn) != None && Killed.GetTeamNum() != 0 && Killer.bIsPlayer && Killer.GetTeamNum() == 0)
{
if (ExtPlayerController(Killer)!=None && ExtPlayerController(Killer).ActivePerkManager!=None)
ExtPlayerController(Killer).ActivePerkManager.PlayerKilled(KFPawn_Monster(Killed.Pawn),LastKillDamageType);
if (bKillMessages && Killer.PlayerReplicationInfo!=None)
BroadcastKillMessage(Killed.Pawn,Killer);
if (KFM.DamageHistory.Length > 0)
{
for (i = 0; i<KFM.DamageHistory.Length; i++)
{
DamagerKFPRI = KFPlayerReplicationInfo(KFM.DamageHistory[i].DamagerPRI);
if (DamagerKFPRI != None)
{
if (KFM.DamageHistory[i].DamagePerks.Length <= 0)
{
continue;
}
cont = true;
for (j=0;j<KFM.DamageHistory[i].DamageCausers.Length;j++)
{
if (IsFromMod(KFM.DamageHistory[i].DamageCausers[j]) || IsFromMod(KFM.DamageHistory[i].DamageTypes[j]))
{
cont = false;
break;
}
}
if (cont && !IsFromMod(KFM))
continue;
// Distribute experience points
KFPC = KFPlayerController(DamagerKFPRI.Owner);
if (KFPC != none)
{
`log("ScoreKill:"@PathName(KFM));
XP = 0;
for (j=0;j<CustomZedXPArray.Length;j++)
{
if (KFM.Class == CustomZedXPArray[j].zedclass)
{
XP = CustomZedXPArray[j].XPValues[MyKFGI.GameDifficulty];
break;
}
}
if (XP == 0)
XP = KFM.static.GetXPValue(MyKFGI.GameDifficulty);
InstigatorPerk = KFPC.GetPerk();
if (InstigatorPerk.ShouldGetAllTheXP())
{
KFPC.OnPlayerXPAdded(XP, InstigatorPerk.Class);
continue;
}
XP /= KFM.DamageHistory[i].DamagePerks.Length;
for (j = 0; j < KFM.DamageHistory[i].DamagePerks.Length; j++)
{
KFPC.OnPlayerXPAdded(FCeil(XP), KFM.DamageHistory[i].DamagePerks[j]);
}
}
}
}
}
CustomXP(Killer, Killed);
}
if (MyKFGI != None && MyKFGI.IsZedTimeActive() && KFPawn_Monster(Killed.Pawn) != None)
{
KFPC = KFPlayerController(Killer);
if (KFPC != none)
{
KillersPerk = ExtPerkManager(KFPC.GetPerk());
if (MyKFGI.ZedTimeRemaining > 0.f && KillersPerk != none && KillersPerk.GetZedTimeExtensions(KFPC.GetLevel()) > MyKFGI.ZedTimeExtensionsUsed)
if (MyKFGI.ZedTimeRemaining > 0.f && KillersPerk != none && KillersPerk.GetZedTimeExtensions( KFPC.GetLevel() ) > MyKFGI.ZedTimeExtensionsUsed)
{
MyKFGI.DramaticEvent(1.0);
MyKFGI.ZedTimeExtensionsUsed++;
}
}
}
if (ExtPlayerController(Killed)!=None)
if (ExtPlayerController(Killed) != None)
CheckPerkChange(ExtPlayerController(Killed));
if (NextMutator != None)
NextMutator.ScoreKill(Killer, Killed);
else
Super.ScoreKill(Killer, Killed);
}
function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)