diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 71687ac6..3a9b8a09 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -44,7 +44,7 @@ public class RegionCmd extends AbstractDevCmd { }else{ output += "Player Info: " + ((AbstractCharacter) target).getName() + newline; output += "Region Building: " + building.getName() + newline; - output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline; + output += "Region Height: " + region.lerpY(((AbstractCharacter)target).loc) + newline; output += "is Stairs: " + region.isStairs() + newline; output += "is Outside: " + region.isOutside() + newline; for(Vector3f point : region.regionPoints) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 87b8b14b..779c0505 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -103,7 +103,7 @@ public class MobAI { if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); - if (!MovementUtilities.inRangeDropAggro(mob, target)) { + if (MovementUtilities.inRangeDropAggro(mob, target)) { mob.setCombatTarget(null); return; } @@ -834,7 +834,7 @@ public class MobAI { if (mob.getCombatTarget() == null) return; - if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && + if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) && mob.agentType.equals(Enum.AIAgentType.PET) == false) { mob.setCombatTarget(null); diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index e95e6098..ce57c254 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -107,19 +107,13 @@ private static final int cellGap = 1; } public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) { + float range = MobAIThread.AI_BASE_AGGRO_RANGE * MobAIThread.AI_BASE_AGGRO_RANGE; + if(agent.isPlayerGuard()) + range = 62500; + if(agent.isSiege()) + range = agent.getRange() * agent.getRange(); - Vector3fImmutable sl = agent.getLoc(); - Vector3fImmutable tl = target.getLoc(); - - float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target - - float range = agent.getRange() + 150; - - if (range > 200) - range = 200; - - - return distanceSquaredToTarget < sqr(range); + return agent.loc.distanceSquared(target.loc) > range; } @@ -448,7 +442,9 @@ private static final int cellGap = 1; if(building == null) return false;//no building at this location means nothing obstructing the walking path - if(Regions.getRegionAtLocation(point) != null) + Regions region = Regions.getRegionAtLocation(point); + if(region != null) + if(region.lerpY(point) <= point.y) return false; Zone currentZone = ZoneManager.findSmallestZone(point); diff --git a/src/engine/net/client/handlers/ChangeAltitudeHandler.java b/src/engine/net/client/handlers/ChangeAltitudeHandler.java index cdc2ea99..89910d16 100644 --- a/src/engine/net/client/handlers/ChangeAltitudeHandler.java +++ b/src/engine/net/client/handlers/ChangeAltitudeHandler.java @@ -79,7 +79,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler { float startAlt = 0; Building regionBuilding = Regions.GetBuildingForRegion(upRegion); if (upRegion != null) - startAlt = upRegion.lerpY(pc) - regionBuilding.getLoc().y; + startAlt = upRegion.lerpY(pc.loc) - regionBuilding.getLoc().y; float rounded = startAlt * .10f; rounded = ((int) rounded) * 10; @@ -143,7 +143,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler { float landingAltitude = 0; Building building = Regions.GetBuildingForRegion(region); if (building != null) - landingAltitude = region.lerpY(pc) - building.getLoc().y; + landingAltitude = region.lerpY(pc.loc) - building.getLoc().y; if (landingAltitude >= targetAlt) { pc.landingRegion = region; diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 0c95e175..0ff48126 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -993,7 +993,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { float regionHeightOffset = 0; if(region != null){ this.region = region; - regionHeightOffset = region.lerpY(this); + regionHeightOffset = region.lerpY(this.loc); this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc this.inBuildingID = region.parentBuildingID; this.inFloorID = region.room; diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 0bf5939a..6b5eb42c 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -179,7 +179,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { if (region.center.y == region.highLerp.y) worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude()); else - worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject) + worldObject.getAltitude()); + worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject.loc) + worldObject.getAltitude()); return region; } @@ -504,7 +504,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { this.loc = loc; if(this instanceof AbstractCharacter && this.region != null){ - this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude()); + this.loc = this.loc.setY(this.region.lerpY(this.loc) + this.getAltitude()); } else{ this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index d68c16cd..b0f60079 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4828,7 +4828,7 @@ public class PlayerCharacter extends AbstractCharacter { if (this.landingRegion != null) { this.altitude = 0; this.region = this.landingRegion; - this.loc = this.loc.setY(this.landingRegion.lerpY(this)); + this.loc = this.loc.setY(this.landingRegion.lerpY(this.loc)); } else this.altitude = this.getDesiredAltitude(); diff --git a/src/engine/objects/Regions.java b/src/engine/objects/Regions.java index 36a2fcff..12d54918 100644 --- a/src/engine/objects/Regions.java +++ b/src/engine/objects/Regions.java @@ -180,7 +180,7 @@ public class Regions { boolean movingUp = false; boolean movingDown = false; - float yLerp = worldObject.region.lerpY(worldObject); + float yLerp = worldObject.region.lerpY(worldObject.loc); if (yLerp == (worldObject.region.highLerp.y)) movingUp = true; @@ -338,10 +338,10 @@ public class Regions { return inside; } - public float lerpY(AbstractWorldObject lerper) { + public float lerpY(Vector3fImmutable lerper) { Vector3fImmutable lengthVector = this.highLerp.subtract2D(this.lowLerp); - Vector3fImmutable characterVector = lerper.getLoc().subtract2D(this.lowLerp); + Vector3fImmutable characterVector = lerper.subtract2D(this.lowLerp); float lengthVectorMagnitude = lengthVector.magnitude(); float characterVectorMagnitude = characterVector.magnitude(); float percentDistance = characterVectorMagnitude / lengthVectorMagnitude;