Merge branch 'magicbox1.5' into feature-guard-patrol

This commit is contained in:
2023-05-09 18:40:04 -05:00
10 changed files with 48 additions and 100 deletions
+4 -4
View File
@@ -2269,14 +2269,14 @@ public class Enum {
public enum CityBoundsType {
GRID(512),
ZONE(576),
SIEGE(1040);
GRID(640),
ZONE(875),
PLACEMENT(1050);
public final float extents;
CityBoundsType(float extents) {
this.extents = extents;
this.extents = extents;
}
}
@@ -53,9 +53,9 @@ public class MovementUtilities {
//Guards recall distance = 814.
if (tol != null){
if (agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.SIEGE.extents)) {
return false;
}
if (agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.extents)) {
return false;
}
}
}
+11 -2
View File
@@ -204,7 +204,10 @@ public class RemoveObjectCmd extends AbstractDevCmd {
return;
}
// Remove npc from hirelings list.
if (npc.building != null)
npc.building.getHirelings().remove(npc);
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
@@ -225,6 +228,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
private void removeMob(PlayerCharacter pc, Mob mob) {
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
if (currentZone == null) {
this.throwbackError(pc, "Could not locate zone for player.");
return;
@@ -235,8 +239,13 @@ public class RemoveObjectCmd extends AbstractDevCmd {
return;
}
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
// Remove npc from hirelings list.
if (mob.building != null)
mob.building.getHirelings().remove(mob);
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
+5 -48
View File
@@ -271,24 +271,6 @@ public enum ZoneManager {
return true;
}
/**
* Gets a MacroZone by name.
*
* @param inputName MacroZone name to search for
* @return Zone of the MacroZone, or Null
*/
public static Zone findMacroZoneByName(String inputName) {
synchronized (ZoneManager.macroZones) {
for (Zone zone : ZoneManager.macroZones) {
String zoneName = zone.getName();
if (zoneName.equalsIgnoreCase(inputName))
return zone;
}
}
return null;
}
// Converts world coordinates to coordinates local to a given zone.
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
@@ -353,10 +335,11 @@ public enum ZoneManager {
// convert from SB rotation value to radians
if (building.getBounds().getQuaternion() == null)
return building.getLoc();
Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion());
// handle building rotation
// handle building translation
@@ -371,6 +354,7 @@ public enum ZoneManager {
Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion());
// handle building rotation
// handle building translation
@@ -380,7 +364,6 @@ public enum ZoneManager {
public static Vector3fImmutable convertWorldToLocal(Building building, Vector3fImmutable WorldPos) {
Vector3fImmutable convertLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), WorldPos, -building.getBounds().getQuaternion().angleY);
convertLoc = convertLoc.subtract(building.getLoc());
// convert from SB rotation value to radians
@@ -389,14 +372,8 @@ public enum ZoneManager {
}
public static Vector3fImmutable convertNPCLoc(Building building, Vector3fImmutable npcLoc) {
return Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, npcLoc, -building.getBounds().getQuaternion().angleY);
}
// Method returns a city if the given location is within
// a city siege radius.
// a city zone.
public static City getCityAtLocation(Vector3fImmutable worldLoc) {
@@ -409,25 +386,6 @@ public enum ZoneManager {
if (currentZone.isPlayerCity())
return City.getCity(currentZone.getPlayerCityUUID());
// Not currently on a city grid. Test nearby cities
// to see if we are on one of their seige bounds.
zoneList = currentZone.getNodes();
for (Zone zone : zoneList) {
if (zone == currentZone)
continue;
if (zone.isPlayerCity() == false)
continue;
city = City.getCity(zone.getPlayerCityUUID());
if (worldLoc.isInsideCircle(city.getLoc(), Enum.CityBoundsType.SIEGE.extents))
return city;
}
return null;
}
@@ -449,11 +407,10 @@ public enum ZoneManager {
treeBounds = Bounds.borrow();
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.SIEGE.extents, Enum.CityBoundsType.SIEGE.extents), 0.0f);
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.extents, Enum.CityBoundsType.PLACEMENT.extents), 0.0f);
zoneList = currentZone.getNodes();
for (Zone zone : zoneList) {
if (zone.isContinent())
@@ -346,11 +346,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
return false;
}
// Set the server zone to the city zone in order to account for being inside
// the siege bounds buffer area
serverZone = serverCity.getParent();
// Must belong to either attacker or defenders.
if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) == false)
@@ -427,7 +422,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (!building.getBlueprint().isSiegeEquip())
continue;
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), Enum.CityBoundsType.SIEGE.extents))
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), CityBoundsType.ZONE.extents))
continue;
if (building.getGuild() == null)
@@ -929,28 +924,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
// Method deletes one item from the player's inventory
// based on the mesh UUID the deed/seed spawns
private static void removeDeedByMeshUUID(PlayerCharacter player, int meshUUID) {
CharacterItemManager inventoryManager;
ArrayList<Item> itemList;
inventoryManager = player.getCharItemManager();
itemList = player.getInventory();
for (Item inventoryItem : itemList) {
if (inventoryItem.getItemBase().getUseID() == meshUUID) {
inventoryManager.delete(inventoryItem);
inventoryManager.updateInventory();
return;
}
}
}
// Method validates the location we have selected for our new city
private static boolean validateTreeOfLifePlacement(PlayerCharacter playerCharacter, Realm serverRealm, Zone serverZone,
+2 -3
View File
@@ -135,15 +135,14 @@ public final class Bane {
return false;
}
// Cannot place banestones underwater;
// Cannot place banestone underwater;
if (HeightMap.isLocUnderwater(player.getLoc())) {
PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater
return false;
}
// figure out which city we're standing on
// must be within a city's seige Bounds
// figure out which city zone we are standing on.
targetCity = ZoneManager.getCityAtLocation(player.getLoc());
+2 -2
View File
@@ -276,14 +276,14 @@ public class Building extends AbstractWorldObject {
if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)){
if (this.getGuild() != null){
if (this.getGuild().getOwnedCity() != null){
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), Enum.CityBoundsType.SIEGE.extents))
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.extents))
return this.getGuild().getOwnedCity();
}else{
Bane bane = Bane.getBaneByAttackerGuild(this.getGuild());
if (bane != null){
if (bane.getCity() != null){
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), Enum.CityBoundsType.SIEGE.extents))
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.extents))
return bane.getCity();
}
}
+3 -3
View File
@@ -943,7 +943,7 @@ public class City extends AbstractWorldObject {
public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) {
return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.SIEGE.extents);
return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.extents);
}
@@ -1001,9 +1001,9 @@ public class City extends AbstractWorldObject {
HashSet<Integer> currentMemory;
PlayerCharacter player;
// Gather current list of players within a distance defined by the seige bounds
// Gather current list of players within the zone bounds
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.SIEGE.extents, MBServerStatics.MASK_PLAYER);
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER);
currentMemory = new HashSet<>();
for (AbstractWorldObject playerObject : currentPlayers) {
+9 -6
View File
@@ -184,9 +184,12 @@ public class NPC extends AbstractCharacter {
if (this.contract != null)
this.loadID = this.contract.getMobbaseID();
else
this.loadID = 2011; //default to human
this.loadID = rs.getInt("npc_raceID");
this.loadID = rs.getInt("npc_raceID");
// Default to human male
if (loadID == 0)
loadID = 2100;
this.mobBase = MobBase.getMobBase(this.loadID);
this.level = rs.getByte("npc_level");
@@ -242,11 +245,11 @@ public class NPC extends AbstractCharacter {
this.name = rs.getString("npc_name");
// Name override for player owned npcs
// Name override for npc
// with an owner.
if (this.building != null &&
this.building.getOwner() != null &&
this.building.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter))
if (this.guild != null &&
!this.guild.isEmptyGuild())
this.name += " the " + this.contract.getName();
}catch(Exception e){
+8 -1
View File
@@ -26,13 +26,20 @@ public class Portal {
private long lastActive = 0;
public Portal(Building sourceGate, PortalType portalType, Building targetGate) {
Vector3fImmutable tmpLocation;
this.active = false;
this.sourceGate = sourceGate;
this.targetGate = targetGate;
this.portalType = portalType;
this.portalLocation = sourceGate.getLoc().add(new Vector3fImmutable(portalType.offset.x, 6, portalType.offset.y));
tmpLocation = sourceGate.getLoc().add(new Vector3fImmutable(portalType.offset.x, 6, portalType.offset.y));
// Rotate portal by gate rotation
tmpLocation = Vector3fImmutable.rotateAroundPoint(sourceGate.getLoc(), tmpLocation, sourceGate.getBounds().getQuaternion().angleY);
this.portalLocation = tmpLocation;
}
public boolean isActive() {