Addition of getMainDamageDealer method.
This commit is contained in:
@@ -921,6 +921,27 @@ public class Attackable extends NpcInstance
|
||||
}
|
||||
}
|
||||
|
||||
public Creature getMainDamageDealer()
|
||||
{
|
||||
if (_aggroList.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int damage = 0;
|
||||
Creature damageDealer = null;
|
||||
for (AggroInfo info : _aggroList.values())
|
||||
{
|
||||
if ((info != null) && (info._damage > damage) && Util.checkIfInRange(Config.ALT_PARTY_RANGE, this, info._attacker, true))
|
||||
{
|
||||
damage = info._damage;
|
||||
damageDealer = info._attacker;
|
||||
}
|
||||
}
|
||||
|
||||
return damageDealer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add damage and hate to the attacker AggroInfo of the Attackable _aggroList.
|
||||
* @param attacker The Creature that gave damages to this Attackable
|
||||
|
@@ -1817,6 +1817,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
|
||||
setKilledAlready(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);
|
||||
|
||||
@@ -1885,28 +1890,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
stopAllEffects();
|
||||
}
|
||||
}
|
||||
else
|
||||
// this means all other characters, including Summons
|
||||
else // this means all other characters, including Summons
|
||||
{
|
||||
stopAllEffects();
|
||||
}
|
||||
|
||||
// if killer is the same then the most damager/hated
|
||||
Creature mostHated = null;
|
||||
if (this instanceof Attackable)
|
||||
{
|
||||
mostHated = ((Attackable) this)._mostHated;
|
||||
}
|
||||
|
||||
if ((mostHated != null) && isInsideRadius2D(mostHated, 200))
|
||||
{
|
||||
calculateRewards(mostHated);
|
||||
}
|
||||
else
|
||||
{
|
||||
calculateRewards(killer);
|
||||
}
|
||||
|
||||
// Send the Server->Client packet StatusUpdate with current HP and MP to all other PlayerInstance to inform
|
||||
broadcastStatusUpdate();
|
||||
|
||||
|
Reference in New Issue
Block a user