Olympiad support for Player onPlayerKill method.

This commit is contained in:
MobiusDevelopment
2022-02-06 00:08:49 +00:00
parent 987629ea69
commit 1c5ea90557
46 changed files with 384 additions and 135 deletions

View File

@@ -175,6 +175,7 @@ public abstract class Playable extends Creature
qs.getQuest().notifyDeath((killer == null ? this : killer), this, qs);
}
}
// Notify instance
if (isPlayer())
{
@@ -188,7 +189,7 @@ public abstract class Playable extends Creature
if (killer != null)
{
final Player killerPlayer = killer.getActingPlayer();
if ((killerPlayer != null) && isPlayable())
if (killerPlayer != null)
{
killerPlayer.onPlayerKill(this);
}

View File

@@ -5157,11 +5157,15 @@ public class Player extends Playable
}
}
public void onPlayerKill(Playable killedPlayable)
public void onPlayerKill(Playable target)
{
final Player killedPlayer = killedPlayable.getActingPlayer();
if ((target == null) || !target.isPlayable())
{
return;
}
// Avoid nulls && check if player != killedPlayer
final Player killedPlayer = target.getActingPlayer();
if ((killedPlayer == null) || (this == killedPlayer))
{
return;
@@ -5174,6 +5178,12 @@ public class Player extends Playable
return;
}
// Olympiad support
if (isInOlympiadMode() || killedPlayer.isInOlympiadMode())
{
return;
}
// Duel support
if (isInDuel() && killedPlayer.isInDuel())
{
@@ -5227,13 +5237,13 @@ public class Player extends Playable
{
if ((_isGood && killedPlayer.isGood()) || (_isEvil && killedPlayer.isEvil()))
{
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), killedPlayable.isSummon()));
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), target.isSummon()));
setPkKills(getPkKills() + 1);
}
}
else
{
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), killedPlayable.isSummon()));
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), target.isSummon()));
setPkKills(getPkKills() + 1);
}
}