From a113295058153f10c05f53bfdc04c8c5d39a359c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 5 May 2023 08:51:49 -0400 Subject: [PATCH 1/8] Player zone radius now reflects 24.3 at 875. --- src/engine/Enum.java | 7 +++---- src/engine/ai/utilities/MovementUtilities.java | 6 +++--- src/engine/gameManager/ZoneManager.java | 5 ++--- src/engine/net/client/handlers/PlaceAssetMsgHandler.java | 2 +- src/engine/objects/Building.java | 4 ++-- src/engine/objects/City.java | 6 +++--- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index ccd2db53..dd8e7fff 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2269,14 +2269,13 @@ public class Enum { public enum CityBoundsType { - GRID(512), - ZONE(576), - SIEGE(1040); + GRID(640), + ZONE(875); public final float extents; CityBoundsType(float extents) { - this.extents = extents; + this.extents = extents; } } diff --git a/src/engine/ai/utilities/MovementUtilities.java b/src/engine/ai/utilities/MovementUtilities.java index f160d987..9b905ad1 100644 --- a/src/engine/ai/utilities/MovementUtilities.java +++ b/src/engine/ai/utilities/MovementUtilities.java @@ -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; + } } } diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index c2008eb2..bc32a63d 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -424,7 +424,7 @@ public enum ZoneManager { city = City.getCity(zone.getPlayerCityUUID()); - if (worldLoc.isInsideCircle(city.getLoc(), Enum.CityBoundsType.SIEGE.extents)) + if (worldLoc.isInsideCircle(city.getLoc(), Enum.CityBoundsType.ZONE.extents)) return city; } @@ -449,11 +449,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.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f); zoneList = currentZone.getNodes(); - for (Zone zone : zoneList) { if (zone.isContinent()) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 18b8c835..780779db 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -427,7 +427,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) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 75cc4c54..b1dfa9d2 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -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(); } } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index dba734b8..a63bb9f6 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -942,7 +942,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); } @@ -1000,9 +1000,9 @@ public class City extends AbstractWorldObject { HashSet 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) { From b73eae787c4e52991b2a0cb238570fe9287ef78e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 May 2023 08:13:41 -0400 Subject: [PATCH 2/8] Rotation portals --- src/engine/objects/Portal.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Portal.java b/src/engine/objects/Portal.java index 666d0d2d..78e382c3 100644 --- a/src/engine/objects/Portal.java +++ b/src/engine/objects/Portal.java @@ -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() { From ffafd44fa723b73c6f7fa808d3177ed86d924e71 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 May 2023 10:20:53 -0400 Subject: [PATCH 3/8] Siege bounds related bonus code removal. --- src/engine/gameManager/ZoneManager.java | 50 ++----------------- .../client/handlers/PlaceAssetMsgHandler.java | 5 -- src/engine/objects/Bane.java | 5 +- 3 files changed, 6 insertions(+), 54 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index bc32a63d..b2eba4a1 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -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.ZONE.extents)) - return city; - } - return null; } diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 780779db..64e85b2e 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -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) diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index 45774964..b05a6807 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -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()); From e73f4cbe633c35bfce8542b0684457db7656bca8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 May 2023 10:55:27 -0400 Subject: [PATCH 4/8] Placement bounds of 1.2% city zone size. --- src/engine/Enum.java | 3 ++- src/engine/gameManager/ZoneManager.java | 2 +- .../client/handlers/PlaceAssetMsgHandler.java | 22 ------------------- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index dd8e7fff..7097664a 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2270,7 +2270,8 @@ public class Enum { public enum CityBoundsType { GRID(640), - ZONE(875); + ZONE(875), + PLACEMENT(1050); public final float extents; diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index b2eba4a1..eab3393e 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -407,7 +407,7 @@ public enum ZoneManager { treeBounds = Bounds.borrow(); - treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f); + treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.extents, Enum.CityBoundsType.PLACEMENT.extents), 0.0f); zoneList = currentZone.getNodes(); diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 64e85b2e..71b172d5 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -924,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 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, From f85fb8f2247adfb21ab65b411957200fe1eaa4ae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 May 2023 08:18:12 -0400 Subject: [PATCH 5/8] bugfix in ./remove dev cmd. --- src/engine/devcmd/cmds/RemoveObjectCmd.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index cd0eaf86..4979205f 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -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); From 322b88a1f4d1eb3088bf8462583638d91880555c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 May 2023 09:20:56 -0400 Subject: [PATCH 6/8] Naming logic changed to have a valid guild. --- src/engine/objects/NPC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 760df693..63f59b92 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -246,7 +246,7 @@ public class NPC extends AbstractCharacter { if (this.building != null && this.building.getOwner() != null && - this.building.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) + this.building.getOwner().guild != null) this.name += " the " + this.contract.getName(); }catch(Exception e){ From 8068082768e23765497930d8a12e613eaeaee5d4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 May 2023 09:29:11 -0400 Subject: [PATCH 7/8] Naming logic changed to have a valid guild. --- src/engine/objects/NPC.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 63f59b92..720b8db4 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -242,11 +242,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().guild != null) + if (this.guild != null && + !this.guild.isEmptyGuild()) this.name += " the " + this.contract.getName(); }catch(Exception e){ From 7168813ba5da3a0afea106ae7eabea094243281c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 9 May 2023 15:16:24 -0400 Subject: [PATCH 8/8] Tweak to set model logic. --- src/engine/objects/NPC.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 720b8db4..00642a37 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -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");