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

@@ -753,6 +753,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

View File

@@ -1703,7 +1703,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);