*/
@Override
protected void onEvtAggression(L2Character target, int aggro)
{
if (_actor == null) return;
L2Attackable me = (L2Attackable) _actor;
if (target != null)
{
// Add the target to the actor _aggroList or update hate if already present
me.addDamageHate(target, 0, aggro);
// Get the hate of the actor against the target
aggro = me.getHating(target);
if (aggro <= 0)
{
if (me.getMostHated() == null)
{
_globalAggro = -25;
me.clearAggroList();
setIntention(AI_INTENTION_IDLE, null, null);
}
return;
}
// Set the actor AI Intention to AI_INTENTION_ATTACK
if (getIntention() != CtrlIntention.AI_INTENTION_ATTACK)
{
// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
if (!_actor.isRunning()) _actor.setRunning();
L2SiegeGuardInstance sGuard = (L2SiegeGuardInstance) _actor;
double homeX = target.getX() - sGuard.getHomeX();
double homeY = target.getY() - sGuard.getHomeY();
// Check if the L2SiegeGuardInstance is not too far from its home location
if (homeX * homeX + homeY * homeY < 3240000) // 1800 * 1800
setIntention(CtrlIntention.AI_INTENTION_ATTACK, target, null);
}
}
else
{
// currently only for setting lower general aggro
if(aggro >= 0) return;
L2Character mostHated = me.getMostHated();
if (mostHated == null)
{
_globalAggro = -25;
return;
}
for(L2Character aggroed : me.getAggroListRP().keySet())
me.addDamageHate(aggroed, 0, aggro);
aggro = me.getHating(mostHated);
if (aggro <= 0)
{
_globalAggro = -25;
me.clearAggroList();
setIntention(AI_INTENTION_IDLE, null, null);
}
}
}