Browse Source

region work

hull4
FatBoy-DOTC 1 year ago
parent
commit
4229999848
  1. 2
      src/engine/devcmd/cmds/RegionCmd.java
  2. 4
      src/engine/mobileAI/MobAI.java
  3. 22
      src/engine/mobileAI/utilities/MovementUtilities.java
  4. 4
      src/engine/net/client/handlers/ChangeAltitudeHandler.java
  5. 2
      src/engine/objects/AbstractCharacter.java
  6. 4
      src/engine/objects/AbstractWorldObject.java
  7. 2
      src/engine/objects/PlayerCharacter.java
  8. 6
      src/engine/objects/Regions.java

2
src/engine/devcmd/cmds/RegionCmd.java

@ -44,7 +44,7 @@ public class RegionCmd extends AbstractDevCmd {
}else{ }else{
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline; output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
output += "Region Building: " + building.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 Stairs: " + region.isStairs() + newline;
output += "is Outside: " + region.isOutside() + newline; output += "is Outside: " + region.isOutside() + newline;
for(Vector3f point : region.regionPoints) for(Vector3f point : region.regionPoints)

4
src/engine/mobileAI/MobAI.java

@ -103,7 +103,7 @@ public class MobAI {
if (mob.behaviourType.callsForHelp) if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
if (!MovementUtilities.inRangeDropAggro(mob, target)) { if (MovementUtilities.inRangeDropAggro(mob, target)) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
@ -834,7 +834,7 @@ public class MobAI {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
return; 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.agentType.equals(Enum.AIAgentType.PET) == false) {
mob.setCombatTarget(null); mob.setCombatTarget(null);

22
src/engine/mobileAI/utilities/MovementUtilities.java

@ -107,19 +107,13 @@ private static final int cellGap = 1;
} }
public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) { 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(); return agent.loc.distanceSquared(target.loc) > range;
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);
} }
@ -448,7 +442,9 @@ private static final int cellGap = 1;
if(building == null) if(building == null)
return false;//no building at this location means nothing obstructing the walking path 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; return false;
Zone currentZone = ZoneManager.findSmallestZone(point); Zone currentZone = ZoneManager.findSmallestZone(point);

4
src/engine/net/client/handlers/ChangeAltitudeHandler.java

@ -79,7 +79,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
float startAlt = 0; float startAlt = 0;
Building regionBuilding = Regions.GetBuildingForRegion(upRegion); Building regionBuilding = Regions.GetBuildingForRegion(upRegion);
if (upRegion != null) if (upRegion != null)
startAlt = upRegion.lerpY(pc) - regionBuilding.getLoc().y; startAlt = upRegion.lerpY(pc.loc) - regionBuilding.getLoc().y;
float rounded = startAlt * .10f; float rounded = startAlt * .10f;
rounded = ((int) rounded) * 10; rounded = ((int) rounded) * 10;
@ -143,7 +143,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
float landingAltitude = 0; float landingAltitude = 0;
Building building = Regions.GetBuildingForRegion(region); Building building = Regions.GetBuildingForRegion(region);
if (building != null) if (building != null)
landingAltitude = region.lerpY(pc) - building.getLoc().y; landingAltitude = region.lerpY(pc.loc) - building.getLoc().y;
if (landingAltitude >= targetAlt) { if (landingAltitude >= targetAlt) {
pc.landingRegion = region; pc.landingRegion = region;

2
src/engine/objects/AbstractCharacter.java

@ -993,7 +993,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
float regionHeightOffset = 0; float regionHeightOffset = 0;
if(region != null){ if(region != null){
this.region = region; 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.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc
this.inBuildingID = region.parentBuildingID; this.inBuildingID = region.parentBuildingID;
this.inFloorID = region.room; this.inFloorID = region.room;

4
src/engine/objects/AbstractWorldObject.java

@ -179,7 +179,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
if (region.center.y == region.highLerp.y) if (region.center.y == region.highLerp.y)
worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude()); worldObject.loc = worldObject.loc.setY(region.center.y + worldObject.getAltitude());
else else
worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject) + worldObject.getAltitude()); worldObject.loc = worldObject.loc.setY(region.lerpY(worldObject.loc) + worldObject.getAltitude());
return region; return region;
} }
@ -504,7 +504,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
this.loc = loc; this.loc = loc;
if(this instanceof AbstractCharacter && this.region != null){ 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{ } else{
this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude());
} }

2
src/engine/objects/PlayerCharacter.java

@ -4828,7 +4828,7 @@ public class PlayerCharacter extends AbstractCharacter {
if (this.landingRegion != null) { if (this.landingRegion != null) {
this.altitude = 0; this.altitude = 0;
this.region = this.landingRegion; this.region = this.landingRegion;
this.loc = this.loc.setY(this.landingRegion.lerpY(this)); this.loc = this.loc.setY(this.landingRegion.lerpY(this.loc));
} else } else
this.altitude = this.getDesiredAltitude(); this.altitude = this.getDesiredAltitude();

6
src/engine/objects/Regions.java

@ -180,7 +180,7 @@ public class Regions {
boolean movingUp = false; boolean movingUp = false;
boolean movingDown = false; boolean movingDown = false;
float yLerp = worldObject.region.lerpY(worldObject); float yLerp = worldObject.region.lerpY(worldObject.loc);
if (yLerp == (worldObject.region.highLerp.y)) if (yLerp == (worldObject.region.highLerp.y))
movingUp = true; movingUp = true;
@ -338,10 +338,10 @@ public class Regions {
return inside; return inside;
} }
public float lerpY(AbstractWorldObject lerper) { public float lerpY(Vector3fImmutable lerper) {
Vector3fImmutable lengthVector = this.highLerp.subtract2D(this.lowLerp); 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 lengthVectorMagnitude = lengthVector.magnitude();
float characterVectorMagnitude = characterVector.magnitude(); float characterVectorMagnitude = characterVector.magnitude();
float percentDistance = characterVectorMagnitude / lengthVectorMagnitude; float percentDistance = characterVectorMagnitude / lengthVectorMagnitude;

Loading…
Cancel
Save