Addition of getMainDamageDealer method.

This commit is contained in:
MobiusDevelopment
2021-10-27 21:26:39 +00:00
parent ebddd951ed
commit 6b069bb28a
46 changed files with 562 additions and 59 deletions

View File

@@ -679,6 +679,27 @@ public class Attackable extends Npc
getAttackByList().add(creature);
}
public Creature getMainDamageDealer()
{
if (_aggroList.isEmpty())
{
return null;
}
int damage = 0;
Creature damageDealer = null;
for (AggroInfo info : _aggroList.values())
{
if ((info != null) && (info.getDamage() > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info.getAttacker(), true))
{
damage = info.getDamage();
damageDealer = info.getAttacker();
}
}
return damageDealer;
}
/**
* Add damage and hate to the attacker AggroInfo of the Attackable _aggroList.
* @param attacker The Creature that gave damages to this Attackable

View File

@@ -73,6 +73,7 @@ import org.l2jmobius.gameserver.model.TimeStamp;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.WorldRegion;
import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.QuestGuardInstance;
@@ -2432,6 +2433,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
setDead(true);
}
// Calculate rewards for main damage dealer.
final Creature mainDamageDealer = isMonster() ? ((MonsterInstance) this).getMainDamageDealer() : null;
calculateRewards(mainDamageDealer != null ? mainDamageDealer : killer);
// Set target to null and cancel Attack or Cast
setTarget(null);
@@ -2458,8 +2463,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
stopAllEffectsExceptThoseThatLastThroughDeath();
}
calculateRewards(killer);
// Send the Server->Client packet StatusUpdate with current HP and MP to all other PlayerInstance to inform
broadcastStatusUpdate();