Addition of getMainDamageDealer method.
This commit is contained in:
@@ -726,6 +726,27 @@ public class Attackable extends Npc
|
||||
getAttackByList().add(new WeakReference<>(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
|
||||
|
@@ -1692,7 +1692,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
abortAttack();
|
||||
abortCast();
|
||||
|
||||
calculateRewards(killer);
|
||||
// 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);
|
||||
|
Reference in New Issue
Block a user