CitizensDev/Citizens — Issue #708: Bouncer not returning to baseLocation because of false target
Author: EinCodierer
Created: 2012-01-29 19:46:25+00:00
State: open

So after alot of debugging and frustration of the issue where bouncers would not move back to the baseLocation, I realized that the bouncers weren't going back because the entity targeted is dead. I don't know why the entity isn't released on death, but this modified method should do the trick.

private boolean findTarget(HumanNPC npc)
{
Guard guard = npc.getType("guard");
if (!guard.isAggressive())
return false;
LivingEntity entity = Targeter.findTarget(Targeter.getNearby(
npc.getPlayer(), guard.getProtectionRadius()), npc);
if (entity != null
&& LocationUtils.withinRange(entity.getLocation(),
npc.getBaseLocation(), guard.getProtectionRadius()))
{
if (entity.isDead())
{
return false;
}

guard.target(entity, npc);
return true;
}
return false;
}