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; return true;
} }
function ScoreKill(Controller Killer, Controller Killed) function CustomXP(Controller Killer, Controller Killed)
{ {
local KFPlayerController KFPC;
local KFPawn_Monster KFM; local KFPawn_Monster KFM;
local int i, j; local int i, j;
local KFPlayerReplicationInfo DamagerKFPRI; local KFPlayerReplicationInfo DamagerKFPRI;
@ -577,32 +578,15 @@ function ScoreKill(Controller Killer, Controller Killed)
local KFPerk InstigatorPerk; local KFPerk InstigatorPerk;
local bool cont; local bool cont;
local KFPlayerController KFPC;
local ExtPerkManager KillersPerk;
if (bRespawnCheck && Killed.bIsPlayer)
CheckRespawn(Killed);
KFM = KFPawn_Monster(Killed.Pawn); KFM = KFPawn_Monster(Killed.Pawn);
if (KFM!=None && Killed.GetTeamNum()!=0 && Killer.bIsPlayer && Killer.GetTeamNum()==0) for (i = 0; i < KFM.DamageHistory.Length; i++)
{
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); DamagerKFPRI = KFPlayerReplicationInfo(KFM.DamageHistory[i].DamagerPRI);
if (DamagerKFPRI != None) if (DamagerKFPRI != None)
{ {
if (KFM.DamageHistory[i].DamagePerks.Length <= 0) // Check that no mods are used in this kill
{
continue;
}
cont = true; cont = true;
for (j=0;j<KFM.DamageHistory[i].DamageCausers.Length;j++) for (j=0; j < KFM.DamageHistory[i].DamageCausers.Length; j++)
{ {
if (IsFromMod(KFM.DamageHistory[i].DamageCausers[j]) || IsFromMod(KFM.DamageHistory[i].DamageTypes[j])) if (IsFromMod(KFM.DamageHistory[i].DamageCausers[j]) || IsFromMod(KFM.DamageHistory[i].DamageTypes[j]))
{ {
@ -611,16 +595,17 @@ function ScoreKill(Controller Killer, Controller Killed)
} }
} }
if (cont && !IsFromMod(KFM)) if (cont && !IsFromMod(KFM))
{
// No mods - exit the loop, the game will add experience by itself
continue; continue;
}
// Distribute experience points // Distribute experience points
KFPC = KFPlayerController(DamagerKFPRI.Owner); KFPC = KFPlayerController(DamagerKFPRI.Owner);
if (KFPC != none) if (KFPC != none)
{ {
`log("ScoreKill:"@PathName(KFM));
XP = 0; XP = 0;
for (j=0;j<CustomZedXPArray.Length;j++) for (j = 0; j < CustomZedXPArray.Length; j++)
{ {
if (KFM.Class == CustomZedXPArray[j].zedclass) if (KFM.Class == CustomZedXPArray[j].zedclass)
{ {
@ -628,18 +613,23 @@ function ScoreKill(Controller Killer, Controller Killed)
break; break;
} }
} }
if (XP == 0) if (XP == 0)
{
XP = KFM.static.GetXPValue(MyKFGI.GameDifficulty); XP = KFM.static.GetXPValue(MyKFGI.GameDifficulty);
}
InstigatorPerk = KFPC.GetPerk(); InstigatorPerk = KFPC.GetPerk();
if (InstigatorPerk.ShouldGetAllTheXP())
// 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); KFPC.OnPlayerXPAdded(XP, InstigatorPerk.Class);
continue; continue;
} }
XP /= KFM.DamageHistory[i].DamagePerks.Length; XP /= KFM.DamageHistory[i].DamagePerks.Length;
for (j = 0; j < KFM.DamageHistory[i].DamagePerks.Length; j++) for (j = 0; j < KFM.DamageHistory[i].DamagePerks.Length; j++)
{ {
KFPC.OnPlayerXPAdded(FCeil(XP), KFM.DamageHistory[i].DamagePerks[j]); KFPC.OnPlayerXPAdded(FCeil(XP), KFM.DamageHistory[i].DamagePerks[j]);
@ -647,27 +637,44 @@ function ScoreKill(Controller Killer, Controller Killed)
} }
} }
} }
}
function ScoreKill(Controller Killer, Controller Killed)
{
local KFPlayerController KFPC;
local ExtPerkManager KillersPerk;
if (bRespawnCheck && Killed.bIsPlayer)
CheckRespawn(Killed);
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);
CustomXP(Killer, Killed);
} }
}
if (MyKFGI != None && MyKFGI.IsZedTimeActive() && KFPawn_Monster(Killed.Pawn) != None) if (MyKFGI != None && MyKFGI.IsZedTimeActive() && KFPawn_Monster(Killed.Pawn) != None)
{ {
KFPC = KFPlayerController(Killer); KFPC = KFPlayerController(Killer);
if (KFPC != none) if (KFPC != none)
{ {
KillersPerk = ExtPerkManager(KFPC.GetPerk()); 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.DramaticEvent(1.0);
MyKFGI.ZedTimeExtensionsUsed++; MyKFGI.ZedTimeExtensionsUsed++;
} }
} }
} }
if (ExtPlayerController(Killed)!=None)
if (ExtPlayerController(Killed) != None)
CheckPerkChange(ExtPlayerController(Killed)); CheckPerkChange(ExtPlayerController(Killed));
if (NextMutator != None) if (NextMutator != None)
NextMutator.ScoreKill(Killer, Killed); NextMutator.ScoreKill(Killer, Killed);
else
Super.ScoreKill(Killer, Killed);
} }
function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation) function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)