ref: CustomXP function, fix: DamageTypes out of bounds
- CustomXP function refactoring; - fix "out of bounds" error: ScriptWarning: Accessed array 'ServerExtMut_0.DamageTypes' out of bounds (2/2) 011ServerExtMut KF-BigRoom2020.TheWorld:PersistentLevel.ServerExtMut_0 011Function ServerExtMut.ServerExtMut:CustomXP:01CB
This commit is contained in:
parent
cb8b9d52b3
commit
54fd79c924
@ -532,68 +532,69 @@ function bool IsFromMod(Object O)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bool HasModsInDamageInfo(DamageInfo DI)
|
||||||
|
{
|
||||||
|
local class<Actor> DamageCauser;
|
||||||
|
local class<KFDamageType> DamageType;
|
||||||
|
|
||||||
|
foreach DI.DamageCausers(DamageCauser)
|
||||||
|
if (IsFromMod(DamageCauser))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
foreach DI.DamageTypes(DamageType)
|
||||||
|
if (IsFromMod(DamageType))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function CustomXP(Controller Killer, Controller Killed)
|
function CustomXP(Controller Killer, Controller Killed)
|
||||||
{
|
{
|
||||||
local KFPlayerController KFPC;
|
local KFPlayerController KFPC;
|
||||||
local KFPawn_Monster KFM;
|
local KFPawn_Monster KFM;
|
||||||
local int i, j;
|
local int i;
|
||||||
local KFPlayerReplicationInfo DamagerKFPRI;
|
local KFPlayerReplicationInfo DamagerKFPRI;
|
||||||
local float XP;
|
local float XP;
|
||||||
local KFPerk InstigatorPerk;
|
local KFPerk InstigatorPerk;
|
||||||
local bool cont;
|
local DamageInfo DamageInfo;
|
||||||
|
local class<KFPerk> DamagePerk;
|
||||||
|
|
||||||
KFM = KFPawn_Monster(Killed.Pawn);
|
KFM = KFPawn_Monster(Killed.Pawn);
|
||||||
for (i = 0; i < KFM.DamageHistory.Length; i++)
|
foreach KFM.DamageHistory(DamageInfo)
|
||||||
{
|
{
|
||||||
DamagerKFPRI = KFPlayerReplicationInfo(KFM.DamageHistory[i].DamagerPRI);
|
DamagerKFPRI = KFPlayerReplicationInfo(DamageInfo.DamagerPRI);
|
||||||
if (DamagerKFPRI != None)
|
if (DamagerKFPRI == None) continue;
|
||||||
|
|
||||||
|
// if no mods - exit the loop, the game will add experience by itself
|
||||||
|
if (!HasModsInDamageInfo(DamageInfo) && !KFGIA.IsCustomZed(KFM.class)) continue;
|
||||||
|
|
||||||
|
KFPC = KFPlayerController(DamagerKFPRI.Owner);
|
||||||
|
if (KFPC == None) continue;
|
||||||
|
|
||||||
|
i = CustomZedXPArray.Find('zedclass', KFM.Class);
|
||||||
|
if (i != INDEX_NONE)
|
||||||
{
|
{
|
||||||
// Check that no mods are used in this kill
|
XP = CustomZedXPArray[i].XPValues[MyKFGI.GameDifficulty];
|
||||||
cont = true;
|
}
|
||||||
for (j=0; j < KFM.DamageHistory[i].DamageCausers.Length; j++)
|
else
|
||||||
{
|
{
|
||||||
if (IsFromMod(KFM.DamageHistory[i].DamageCausers[j]) || IsFromMod(KFM.DamageHistory[i].DamageTypes[j]))
|
XP = KFM.static.GetXPValue(MyKFGI.GameDifficulty);
|
||||||
{
|
}
|
||||||
cont = false;
|
|
||||||
break;
|
InstigatorPerk = KFPC.GetPerk();
|
||||||
}
|
|
||||||
}
|
// Special for survivalist - he gets experience for everything
|
||||||
if (cont && !KFGIA.IsCustomZed(KFM.class))
|
// and for TF2Sentry - it has no perk in DamageHistory
|
||||||
{
|
if (InstigatorPerk.ShouldGetAllTheXP() || DamageInfo.DamagePerks.Length == 0)
|
||||||
// No mods - exit the loop, the game will add experience by itself
|
{
|
||||||
continue;
|
KFPC.OnPlayerXPAdded(XP, InstigatorPerk.Class);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
// Distribute experience points
|
|
||||||
KFPC = KFPlayerController(DamagerKFPRI.Owner);
|
XP /= DamageInfo.DamagePerks.Length;
|
||||||
if (KFPC != none)
|
foreach DamageInfo.DamagePerks(DamagePerk)
|
||||||
{
|
{
|
||||||
j = CustomZedXPArray.Find('zedclass', KFM.Class);
|
KFPC.OnPlayerXPAdded(FCeil(XP), DamagePerk);
|
||||||
if(j != -1)
|
|
||||||
{
|
|
||||||
XP = CustomZedXPArray[j].XPValues[MyKFGI.GameDifficulty];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user