Refactored components of the ScriptAPI to more efficiently utilize pathfinding
Implemented a global limit on pathfinding distance (server.max_pathfind_dist) Pathfinding limit is enforced at the packet level as well as elsewhere (ContentAPI, etc)
This commit is contained in:
@@ -78,6 +78,8 @@ public abstract class MovementPulse extends Pulse {
|
||||
|
||||
private Function2<Entity,Node,Location> overrideMethod;
|
||||
|
||||
private Location previousLoc;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MovementPulse} {@code Object}.
|
||||
*
|
||||
@@ -263,7 +265,7 @@ public abstract class MovementPulse extends Pulse {
|
||||
else if (inside) {
|
||||
loc = findBorderLocation();
|
||||
}
|
||||
}
|
||||
} else if (loc == previousLoc) return;
|
||||
|
||||
if (destination == null) {
|
||||
return;
|
||||
@@ -293,6 +295,7 @@ public abstract class MovementPulse extends Pulse {
|
||||
}
|
||||
|
||||
Path path = Pathfinder.find(mover, loc != null ? loc : destination, true, pathfinder);
|
||||
loc = destination.getLocation();
|
||||
near = !path.isSuccessful() || path.isMoveNear();
|
||||
interactLocation = mover.getLocation();
|
||||
boolean canMove = true;
|
||||
@@ -330,6 +333,7 @@ public abstract class MovementPulse extends Pulse {
|
||||
}
|
||||
}
|
||||
}
|
||||
previousLoc = loc;
|
||||
}
|
||||
last = destination.getLocation();
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ class ScriptProcessor(val entity: Entity) {
|
||||
if (entity !is Player) return
|
||||
if (!entity.delayed() && canProcess && interactTarget != null) {
|
||||
if (opScript != null && inOperableDistance()) {
|
||||
face(entity, interactTarget?.centerLocation ?: return)
|
||||
face(entity, interactTarget?.getFaceLocation(entity.location) ?: return)
|
||||
processInteractScript(opScript ?: return)
|
||||
}
|
||||
else if (apScript != null && inApproachDistance(apScript ?: return)) {
|
||||
face(entity, interactTarget?.centerLocation ?: return)
|
||||
face(entity, interactTarget?.getFaceLocation(entity.location) ?: return)
|
||||
processInteractScript(apScript ?: return)
|
||||
}
|
||||
else if (apScript == null && opScript == null && inOperableDistance()) {
|
||||
|
||||
Reference in New Issue
Block a user