From c16ea8f3dd844a0bd71d18abd440e39d3cfe5882 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 23 Apr 2024 20:51:22 -0500 Subject: [PATCH] movement sync bug squashed --- .../mobileAI/utilities/MovementUtilities.java | 67 +------------------ src/engine/objects/AbstractCharacter.java | 2 +- 2 files changed, 2 insertions(+), 67 deletions(-) diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 9bda3497..8d78b817 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -115,39 +115,8 @@ public class MovementUtilities { } - public static Vector3fImmutable GetMoveLocation(Mob aiAgent, AbstractCharacter aggroTarget) { - - // Player isnt moving and neither is mob. Just return - // the mobile's current location. Ain't goin nowhere! - // *** Refactor: Check to ensure methods calling us - // all don't sent move messages when not moving. - - if ((aggroTarget.isMoving() == false)) - return aggroTarget.getLoc(); - - if (aggroTarget.getEndLoc().x != 0) { - - float aggroTargetDistanceSquared = aggroTarget.getLoc().distanceSquared2D(aggroTarget.getEndLoc()); - float aiAgentDistanceSquared = aiAgent.getLoc().distanceSquared2D(aggroTarget.getEndLoc()); - - if (aiAgentDistanceSquared >= aggroTargetDistanceSquared) - return aggroTarget.getEndLoc(); - else { - float distanceToMove = sqrt(aggroTargetDistanceSquared + aiAgentDistanceSquared) * .5f; - - return aggroTarget.getFaceDir().scaleAdd(distanceToMove, aggroTarget.getLoc()); - - } - } - - // One of us is moving so let's calculate our destination loc for this - // simulation frame. We will simply project our position onto the - // character's movement vector and return the closest point. - - return aiAgent.getLoc().ClosestPointOnLine(aggroTarget.getLoc(), aggroTarget.getEndLoc()); - } - public static void moveToLocation(Mob agent, Vector3fImmutable newLocation, float offset) { + agent.resetLastSetLocUpdate(); try { //don't move farther than 30 units from player. @@ -172,21 +141,6 @@ public class MovementUtilities { return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None)); } - public static Vector3fImmutable randomPatrolLocation(Mob agent, Vector3fImmutable center, float radius) { - - //Determing where I want to move. - return new Vector3fImmutable((center.x - radius) + ((ThreadLocalRandom.current().nextFloat() + .1f * 2) * radius), - center.y, - (center.z - radius) + ((ThreadLocalRandom.current().nextFloat() + .1f * 2) * radius)); - } - - public static Long estimateMovementTime(Mob agent) { - if (agent.getEndLoc().x == 0 && agent.getEndLoc().y == 0) - return 0L; - - return (long) ((agent.getLoc().distance2D(agent.getEndLoc()) * 1000) / agent.getSpeed()); - } - public static void aiMove(Mob agent, Vector3fImmutable vect, boolean isWalking) { //update our walk/run state. @@ -273,23 +227,4 @@ public class MovementUtilities { return character.getLoc(); } - public static boolean updateMovementToCharacter(Mob aiAgent, AbstractCharacter aggroTarget) { - - if (aiAgent.destination.equals(Vector3fImmutable.ZERO)) - return true; - - if (!aiAgent.isMoving()) - return true; - - - if (aggroTarget.isMoving()) { - return !aiAgent.destination.equals(aggroTarget.getEndLoc()) && !aiAgent.destination.equals(aggroTarget.getLoc()); - } else { - if (aiAgent.destination.equals(aggroTarget.getLoc())) - return false; - } - - return false; - } - } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 3d788dbe..22c9e864 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -994,7 +994,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { if (this.takeOffTime != 0) return super.getLoc(); - return super.getLoc().moveTowards(this.endLoc, this.getSpeed() * ((System.currentTimeMillis() - lastSetLocUpdate) * .001f)); + return super.getLoc().moveTowards(this.endLoc, this.getSpeed() * ((System.currentTimeMillis() - this.lastSetLocUpdate) * .001f)); }