forked from MagicBane/Server
region work
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user