FatBoy-DOTC 1 year ago
parent
commit
f002de704b
  1. 2
      src/engine/devcmd/cmds/RegionCmd.java
  2. 19
      src/engine/mobileAI/utilities/MovementUtilities.java
  3. 13
      src/engine/objects/Building.java
  4. 1
      src/engine/objects/Zone.java

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

@ -54,7 +54,7 @@ public class RegionCmd extends AbstractDevCmd { @@ -54,7 +54,7 @@ public class RegionCmd extends AbstractDevCmd {
}else {
output += "zone: null" + newline;
}
this.throwbackInfo(pc, "No Region Found.");
this.throwbackInfo(pc, output);
}
@Override

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

@ -20,6 +20,7 @@ import engine.gameManager.ChatManager; @@ -20,6 +20,7 @@ import engine.gameManager.ChatManager;
import engine.gameManager.MovementManager;
import engine.gameManager.ZoneManager;
import engine.math.Bounds;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.net.client.msg.MoveToPointMsg;
@ -303,9 +304,23 @@ private static final int cellGap = 1; @@ -303,9 +304,23 @@ private static final int cellGap = 1;
if(character.region == null && Regions.getRegionAtLocation(goal) != null) {//mover not inside a building
Building building = BuildingManager.getBuildingAtLocation(goal);
for (Regions region : building.getBounds().getRegions())
ArrayList<Regions> entrances = new ArrayList<>();
for (Regions region : building.getBounds().getRegions()) {
if (region.exit && region.level == 0)
goal = new Vector3fImmutable(region.center.x, region.center.y, region.center.z);
entrances.add(region);
}
Regions cheapest = null;
for(Regions entrance : entrances){
if(cheapest == null) {
cheapest = entrance;
continue;
}
if(getCost(new Vector3fImmutable(entrance.center),character.loc,goal) < getCost(new Vector3fImmutable(cheapest.center),character.loc,goal))
cheapest = entrance;
}
goal = new Vector3fImmutable(cheapest.center.x, cheapest.center.y, cheapest.center.z);
}
ArrayList<Vector3fImmutable> path = getOptimizedPath(getPath(character.loc, goal), getPath(goal, character.loc));

13
src/engine/objects/Building.java

@ -33,6 +33,9 @@ import engine.net.client.msg.ApplyBuildingEffectMsg; @@ -33,6 +33,9 @@ import engine.net.client.msg.ApplyBuildingEffectMsg;
import engine.net.client.msg.UpdateObjectMsg;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.awt.*;
import java.awt.geom.Area;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
@ -1533,11 +1536,13 @@ public class Building extends AbstractWorldObject { @@ -1533,11 +1536,13 @@ public class Building extends AbstractWorldObject {
}
public void updateNavMesh(){
int xPoint = (int)(this.loc.x - this.getBounds().getHalfExtents().x);
int zPoint = (int) (this.loc.z - this.getBounds().getHalfExtents().y);
int extentsX = (int) (this.getBounds().getHalfExtents().x * 2);
int extentsZ = (int) (this.getBounds().getHalfExtents().y * 2);
this.parentZone.navMesh.subtract( new Area(new Rectangle(xPoint, zPoint, extentsX, extentsZ)));//remove entire footprint of building from navMesh
for(Regions region : this.getBounds().getRegions())
this.parentZone.navMesh.add(region.getArea());
MeshBounds meshBounds = Bounds.meshBoundsCache.get(this.getMeshUUID());
if(meshBounds != null)
this.parentZone.navMesh.subtract(meshBounds.getArea(this.loc.x,this.loc.z));
}
}

1
src/engine/objects/Zone.java

@ -189,7 +189,6 @@ public class Zone extends AbstractWorldObject { @@ -189,7 +189,6 @@ public class Zone extends AbstractWorldObject {
}
public void createNavMesh(){
Vector3fImmutable location = this.loc;
int xPoint = (int)(this.absX - this.bounds.getHalfExtents().x);
int zPoint = (int) (this.absZ - this.bounds.getHalfExtents().y);
int extentsX = (int) (this.bounds.getHalfExtents().x * 2);

Loading…
Cancel
Save