Fixed monster random movement.

This commit is contained in:
MobiusDevelopment
2022-08-29 11:15:06 +00:00
parent 20fbd93b25
commit 20275f28e7
29 changed files with 53 additions and 29 deletions

View File

@ -69,6 +69,7 @@ public class AttackableAI extends CreatureAI
private static final int RANDOM_WALK_RATE = 30; // confirmed
private static final int MAX_ATTACK_TIMEOUT = 1200; // int ticks, i.e. 2min
/**
* The delay after which the attacked is stopped.
*/
@ -478,7 +479,7 @@ public class AttackableAI extends CreatureAI
}
// Order this attackable to return to its spawn because there's no target to attack
if (!npc.isWalker() && ((getTarget() == null) || getTarget().isInvisible() || (getTarget().isPlayer() && !Config.ATTACKABLES_CAMP_PLAYER_CORPSES && getTarget().getActingPlayer().isAlikeDead())))
if (!npc.isWalker() && (npc.getSpawn() != null) && (npc.calculateDistance2D(npc.getSpawn()) > Config.MAX_DRIFT_RANGE) && ((getTarget() == null) || getTarget().isInvisible() || (getTarget().isPlayer() && !Config.ATTACKABLES_CAMP_PLAYER_CORPSES && getTarget().getActingPlayer().isAlikeDead())))
{
npc.setWalking();
npc.returnHome();