From 48172fb220d0b5addf3bbb1b43c449a9f1526a0c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 08:26:43 -0400 Subject: [PATCH 01/24] Rotation slot location by building rotation. --- src/engine/objects/Mob.java | 10 ++++++++-- src/engine/objects/NPC.java | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index bfc60eca..60d8b5fb 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -917,8 +917,14 @@ public class Mob extends AbstractIntelligenceAgent { slotLocation = BuildingManager.getSlotLocation(building, slot); this.bindLoc = building.getLoc().add(slotLocation); - this.loc = building.getLoc().add(slotLocation); - this.endLoc = bindLoc; + + // Rotate slot position by the building rotation + + Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); + + this.loc = new Vector3fImmutable(bindLoc); + this.endLoc = new Vector3fImmutable(bindLoc); + ; } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 40db0b76..1ec3ecaf 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -361,7 +361,12 @@ public class NPC extends AbstractCharacter { slotLocation = BuildingManager.getSlotLocation(building, slot); this.bindLoc = building.getLoc().add(slotLocation); - this.loc = building.getLoc().add(slotLocation); + + // Rotate slot position by the building rotation + + Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); + + this.loc = new Vector3fImmutable(bindLoc); // Configure region and floor/level for this NPC From b7c2e09b81e2742ba6b757eabfc6d82224192d17 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 08:39:03 -0400 Subject: [PATCH 02/24] Rotation slot location by building rotation. --- src/engine/objects/Mob.java | 13 +++++-------- src/engine/objects/NPC.java | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 60d8b5fb..8c8d06d6 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -896,8 +896,6 @@ public class Mob extends AbstractIntelligenceAgent { this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); this.bindLoc = this.building.getLoc().add(this.bindLoc); - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); } else { @@ -918,15 +916,14 @@ public class Mob extends AbstractIntelligenceAgent { this.bindLoc = building.getLoc().add(slotLocation); - // Rotate slot position by the building rotation + } - Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); + // Rotate slot position by the building rotation - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); - ; + this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); - } + this.loc = new Vector3fImmutable(bindLoc); + this.endLoc = new Vector3fImmutable(bindLoc); // Configure building region and floor/level for this Mobile diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1ec3ecaf..bb8ffb81 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -364,7 +364,7 @@ public class NPC extends AbstractCharacter { // Rotate slot position by the building rotation - Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); + this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); this.loc = new Vector3fImmutable(bindLoc); From e745c260f0ce546c70a2ffbe768a1e60b5b8fe76 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 08:46:43 -0400 Subject: [PATCH 03/24] Positive rotation not negative. --- src/engine/objects/Mob.java | 2 +- src/engine/objects/NPC.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 8c8d06d6..7065623c 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -920,7 +920,7 @@ public class Mob extends AbstractIntelligenceAgent { // Rotate slot position by the building rotation - this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); + this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, building.getBounds().getQuaternion().angleY); this.loc = new Vector3fImmutable(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index bb8ffb81..ecb1fb8e 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -364,7 +364,7 @@ public class NPC extends AbstractCharacter { // Rotate slot position by the building rotation - this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, -building.getBounds().getQuaternion().angleY); + this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, building.getBounds().getQuaternion().angleY); this.loc = new Vector3fImmutable(bindLoc); From 715abf144419233ef8065cc8f4404f8b13eace96 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 09:10:41 -0400 Subject: [PATCH 04/24] Building Location rotations are now a quaternion. --- src/engine/devcmd/cmds/SlotTestCmd.java | 2 +- src/engine/gameManager/BuildingManager.java | 18 +++++- src/engine/objects/Building.java | 2 +- src/engine/objects/BuildingLocation.java | 63 ++++----------------- src/engine/objects/Mob.java | 13 ++--- 5 files changed, 35 insertions(+), 63 deletions(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index 0c60cce0..d096b947 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -37,7 +37,7 @@ public class SlotTestCmd extends AbstractDevCmd { Building building = (Building)target; for (BuildingLocation buildingLocation : BuildingManager._slotLocations.get(building.meshUUID)) - outString += buildingLocation.getSlot() + buildingLocation.getLoc().toString() + "\r\n"; + outString += buildingLocation.getSlot() + buildingLocation.getLocation().toString() + "\r\n"; outString += "\r\nNeext Available Slot: " + BuildingManager.getAvailableSlot(building); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index ba4c106d..280609aa 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -18,6 +18,7 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeBuildingJob; import engine.math.Bounds; +import engine.math.Quaternion; import engine.math.Vector3fImmutable; import engine.net.client.msg.ErrorPopupMsg; import engine.objects.*; @@ -67,7 +68,22 @@ public enum BuildingManager { Logger.error("Invalid slot for building: " + building.getObjectUUID()); } - return buildingLocation.getLoc(); + return buildingLocation.getLocation(); + } + + public static Quaternion getSlotRotation(Building building, int slot) { + + if (slot == -1) + return new Quaternion(); + + BuildingLocation buildingLocation; + buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index + + if (buildingLocation == null) { + Logger.error("Invalid slot rotation for building: " + building.getObjectUUID()); + } + + return buildingLocation.getRotation(); } public static boolean playerCanManage(PlayerCharacter player, Building building) { diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 95e7dc08..0d255c0c 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -1285,7 +1285,7 @@ public class Building extends AbstractWorldObject { stuckLocations.isEmpty()) return this.getLoc(); - stuckLocation = stuckLocations.get(ThreadLocalRandom.current().nextInt(stuckLocations.size())).getLoc(); + stuckLocation = stuckLocations.get(ThreadLocalRandom.current().nextInt(stuckLocations.size())).getLocation(); return stuckLocation; } diff --git a/src/engine/objects/BuildingLocation.java b/src/engine/objects/BuildingLocation.java index e4a03826..c3b54ca4 100644 --- a/src/engine/objects/BuildingLocation.java +++ b/src/engine/objects/BuildingLocation.java @@ -11,6 +11,7 @@ package engine.objects; import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; +import engine.math.Quaternion; import engine.math.Vector3fImmutable; import java.sql.ResultSet; @@ -25,9 +26,8 @@ public class BuildingLocation extends AbstractGameObject { private final int type; private final int slot; private final int unknown; - private final Vector3fImmutable loc; - private final Vector3fImmutable rot; - private final float w; + private final Vector3fImmutable location; + private final Quaternion rotation; /** @@ -39,9 +39,8 @@ public class BuildingLocation extends AbstractGameObject { this.type = rs.getInt("type"); this.slot = rs.getInt("slot"); this.unknown = rs.getInt("unknown"); - this.loc = new Vector3fImmutable(rs.getFloat("locX"), rs.getFloat("locY"), rs.getFloat("locZ")); - this.rot = new Vector3fImmutable(rs.getFloat("rotX"), rs.getFloat("rotY"), rs.getFloat("rotZ")); - this.w = rs.getFloat("w"); + this.location = new Vector3fImmutable(rs.getFloat("locX"), rs.getFloat("locY"), rs.getFloat("locZ")); + this.rotation = new Quaternion(rs.getFloat("rotX"), rs.getFloat("rotY"), rs.getFloat("rotZ"), rs.getFloat("w")); } /* @@ -52,24 +51,6 @@ public class BuildingLocation extends AbstractGameObject { return this.buildingUUID; } - public Vector3fImmutable rotatedLoc() { - Vector3fImmutable convertLoc = null; - - - double rotY = 2.0 * Math.asin(this.rot.y); - - - // handle building rotation - - convertLoc = new Vector3fImmutable( - (float) ((loc.z * Math.sin(rotY)) + (loc.x * Math.cos(rotY))), - loc.y, - (float) ((loc.z * Math.cos(rotY)) - (loc.x * Math.sin(rotY)))); - - return convertLoc; - - } - public int getType() { return this.type; } @@ -83,42 +64,22 @@ public class BuildingLocation extends AbstractGameObject { } public float getLocX() { - return this.loc.x; + return this.location.x; } public float getLocY() { - return this.loc.y; + return this.location.y; } - public float getLocZ() { - return this.loc.z; - } - - public float getRotX() { - return this.rot.x; - } - - public float getRotY() { - return this.rot.y; - } - - public float getRotZ() { - return this.rot.z; - } - - public float getW() { - return this.w; - } - public Vector3fImmutable getLoc() { - return this.loc; + public Vector3fImmutable getLocation() { + return this.location; } - public Vector3fImmutable getRot() { - return this.rot; + public Quaternion getRotation() { + return this.rotation; } - @Override public void updateDatabase() { } @@ -141,7 +102,7 @@ public class BuildingLocation extends AbstractGameObject { break; } - // Add location to the collection in BuildingManager + // Add location to collection in BuildingManager if (locationCollection.containsKey(buildingLocation.buildingUUID)) locationCollection.get(buildingLocation.buildingUUID).add(buildingLocation); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 7065623c..46651af5 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -265,16 +265,16 @@ public class Mob extends AbstractIntelligenceAgent { this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class); this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class); this.firstName = rs.getString("mob_name"); - if (this.firstName.isEmpty()) { + + if (this.firstName.isEmpty()) this.firstName = this.mobBase.getFirstName(); - } + if (this.contract != null) { this.equipmentSetID = this.contract.getEquipmentSet(); this.lastName = this.getContract().getName(); - } else { + } else this.equipmentSetID = rs.getInt("equipmentSet"); - } if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); @@ -370,11 +370,6 @@ public class Mob extends AbstractIntelligenceAgent { writer.putFloat(1.0f); } - // Location serialization matches NPC - - if (mob.region != null) - writer.putVector3f(ZoneManager.convertWorldToLocal(mob.building, mob.getLoc())); - else writer.putVector3f(mob.getLoc()); //Rotation From 10a6eec3daf681adba08bfdd0d20336bc85b3edb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 12:26:34 -0400 Subject: [PATCH 05/24] more Bonus Code removal. --- src/engine/objects/Building.java | 58 +++++--------------------------- 1 file changed, 9 insertions(+), 49 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 0d255c0c..75cc4c54 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -474,7 +474,8 @@ public class Building extends AbstractWorldObject { for (Building building : city.getParent().zoneBuildingSet) { - //dont add -1 rank buildings. + //don't add -1 rank buildings. + if (building.rank <= 0) continue; if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) @@ -553,8 +554,6 @@ public class Building extends AbstractWorldObject { return; } - // Handling of exploding TOL's - // Must remove a bane before considering destruction of a TOL if (bane != null) { @@ -673,10 +672,6 @@ public class Building extends AbstractWorldObject { return this.w; } - public final void setMeshScale(Vector3f value) { - this.meshScale = value; - } - public final Vector3f getMeshScale() { return this.meshScale; } @@ -1049,7 +1044,9 @@ public class Building extends AbstractWorldObject { public final void rebuildMine(){ this.setRank(1); this.meshUUID = this.getBlueprint().getMeshForRank(this.rank); + // New rank mean new max hitpoints. + this.healthMax = this.getBlueprint().getMaxHealth(this.rank); this.setCurrentHitPoints(this.healthMax); this.getBounds().setBounds(this); @@ -1077,8 +1074,6 @@ public class Building extends AbstractWorldObject { // Submit upgrade job if building is currently set to rank. - - try { DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID); this.ownerIsNPC = (objectType == DbObjectType.NPC); @@ -1142,6 +1137,7 @@ public class Building extends AbstractWorldObject { //create a new list for children if the building is not a child. children list default is null. //TODO Remove Furniture/Child buildings from building class and move them into a seperate class. + if (this.parentBuildingID == 0) this.children = new ArrayList<>(); @@ -1150,7 +1146,9 @@ public class Building extends AbstractWorldObject { if (parent != null){ parent.children.add(this); + //add furniture to region cache. floor and level are reversed in database, //TODO Fix + Regions region = BuildingManager.GetRegion(parent, this.level,this.floor, this.getLoc().x, this.getLoc().z); if (region != null) Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); @@ -1161,28 +1159,6 @@ public class Building extends AbstractWorldObject { if (this.upgradeDateTime != null) BuildingManager.submitUpgradeJob(this); - // Run Once move buildings - // 64 / -64 to align with pads - - // Don't move furniture -/* - if (parentBuildingID != 0) - return; - - // Don't move buildings not on a city zone - // or buildings that are in npc owned city - - City city = getCity(); - - if (city == null) - return; - - if (city.getIsNpcOwned() == 1) - return; - - PullCmd.MoveBuilding(this, null, getLoc().add(new Vector3fImmutable(0, 0, 0)), getParentZone()); -*/ - }catch (Exception e){ e.printStackTrace(); } @@ -1196,21 +1172,8 @@ public class Building extends AbstractWorldObject { else newOwnerID = newOwner.getObjectUUID(); - // ***BONUS CODE BELOW! - /* - if (newOwner == null) { - this.ownerIsNPC = false; - this.ownerUUID = 0; - } else if (newOwner instanceof PlayerCharacter) { - this.ownerIsNPC = false; - this.ownerUUID = newOwner.getObjectUUID(); - } else { - this.ownerIsNPC = true; - this.ownerUUID = newOwner.getObjectUUID(); - } - */ - try { + // Save new owner to database if (!DbManager.BuildingQueries.updateBuildingOwner(this, newOwnerID)) @@ -1316,6 +1279,7 @@ public class Building extends AbstractWorldObject { // Can't have an invalid door number // Log error? + if (doorNumber < 1 || doorNumber > 16) return false; @@ -1344,10 +1308,6 @@ public class Building extends AbstractWorldObject { return true; } - public int getDoorstate(){ - return this.doorState; - } - public void updateEffects() { ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(0x00720063, 1, this.getObjectType().ordinal(), this.getObjectUUID(), this.effectFlags); From a3c8241b8d260943cdb39ef2769073b5b352aca3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 12:40:51 -0400 Subject: [PATCH 06/24] Unused methods removed. --- src/engine/gameManager/MovementManager.java | 55 --------------------- src/engine/objects/AbstractCharacter.java | 14 ------ 2 files changed, 69 deletions(-) diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index a3bc0a17..d5e30fce 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -13,7 +13,6 @@ import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; import engine.InterestManagement.InterestManager; -import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; import engine.math.Bounds; import engine.math.Vector3f; @@ -27,7 +26,6 @@ import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.util.HashSet; import java.util.Set; import static engine.math.FastMath.sqr; @@ -500,59 +498,6 @@ public enum MovementManager { InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter)teleporter); } - - public static void translocateToObject(AbstractCharacter teleporter, AbstractWorldObject worldObject) { - - Vector3fImmutable targetLoc = teleporter.getLoc(); - - Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc()); - - teleporter.stopMovement(teleporter.getLoc()); - - //mobs ignore region sets for now. - if (teleporter.getObjectType().equals(GameObjectType.Mob)){ - teleporter.setInBuildingID(0); - teleporter.setInBuilding(-1); - teleporter.setInFloorID(-1); - TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); - DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); - return; - } - - boolean collide = false; - int maxFloor = -1; - int buildingID = 0; - boolean isGroundLevel = false; - HashSet buildings = WorldGrid.getObjectsInRangePartial(teleporter, 200, MBServerStatics.MASK_BUILDING); - for (AbstractWorldObject awo : buildings) { - Building building = (Building) awo; - if (collide) - break; - } - - if (!collide) { - teleporter.setInBuildingID(0); - teleporter.setInBuilding(-1); - teleporter.setInFloorID(-1); - } else { - if (isGroundLevel) { - teleporter.setInBuilding(0); - teleporter.setInFloorID(-1); - } else { - teleporter.setInBuilding(maxFloor - 1); - teleporter.setInFloorID(0); - } - } - - TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); - //we shouldnt need to send teleport message to new area, as loadjob should pick it up. - // DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - - if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter)) - InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter)teleporter); - - } private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) { ac.teleport(ac.getLoc()); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 097f4dee..372c8c6d 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -1301,20 +1301,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { locationLock.writeLock().unlock(); } } - - - public void teleportToObject(final AbstractWorldObject worldObject) { - locationLock.writeLock().lock(); - try{ - MovementManager.translocateToObject(this, worldObject); - }catch(Exception e){ - Logger.error(e); - }finally{ - locationLock.writeLock().unlock(); - } - } - - /* * Serializing From ce516f24c0baa0b562cf01caee35c5bbcf24b8b3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 13:08:02 -0400 Subject: [PATCH 07/24] Contracted Mob/Npc rotation derived from slot position. --- src/engine/gameManager/BuildingManager.java | 9 +++++---- src/engine/objects/BuildingLocation.java | 10 ++++++++++ src/engine/objects/Mob.java | 10 +++++++++- src/engine/objects/NPC.java | 9 ++++++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 280609aa..95984cb3 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -56,19 +56,20 @@ public enum BuildingManager { return -1; } - public static Vector3fImmutable getSlotLocation(Building building, int slot) { + public static BuildingLocation getSlotLocation(Building building, int slot) { + + BuildingLocation buildingLocation = new BuildingLocation(); if (slot == -1) - return Vector3fImmutable.ZERO; + return buildingLocation; - BuildingLocation buildingLocation; buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index if (buildingLocation == null) { Logger.error("Invalid slot for building: " + building.getObjectUUID()); } - return buildingLocation.getLocation(); + return buildingLocation; } public static Quaternion getSlotRotation(Building building, int slot) { diff --git a/src/engine/objects/BuildingLocation.java b/src/engine/objects/BuildingLocation.java index c3b54ca4..4c9c0d6a 100644 --- a/src/engine/objects/BuildingLocation.java +++ b/src/engine/objects/BuildingLocation.java @@ -30,6 +30,16 @@ public class BuildingLocation extends AbstractGameObject { private final Quaternion rotation; + public BuildingLocation() { + + this.buildingUUID = 0; + this.type = 0; + this.slot = 0; + this.unknown = 0; + this.location = Vector3fImmutable.ZERO; + this.rotation = new Quaternion(); + } + /** * ResultSet Constructor */ diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 46651af5..ea8d1f95 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -20,6 +20,8 @@ import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; import engine.loot.LootManager; import engine.math.Bounds; +import engine.math.Quaternion; +import engine.math.Vector3f; import engine.math.Vector3fImmutable; import engine.net.ByteBufferWriter; import engine.net.Dispatch; @@ -863,6 +865,7 @@ public class Mob extends AbstractIntelligenceAgent { int slot; Vector3fImmutable slotLocation; + Quaternion slotRotation; if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; @@ -907,10 +910,15 @@ public class Mob extends AbstractIntelligenceAgent { // Override bind and location for this contracted Mobile // derived from BuildingManager slot location data. - slotLocation = BuildingManager.getSlotLocation(building, slot); + slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation(); this.bindLoc = building.getLoc().add(slotLocation); + // Rotate MOB by slot rotation + + slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation(); + this.setRot(new Vector3f(0, slotRotation.y, 0)); + } // Rotate slot position by the building rotation diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index ecb1fb8e..cdd5e166 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -18,6 +18,7 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeNPCJob; import engine.math.Bounds; +import engine.math.Quaternion; import engine.math.Vector3f; import engine.math.Vector3fImmutable; import engine.net.ByteBufferWriter; @@ -319,6 +320,7 @@ public class NPC extends AbstractCharacter { int slot; Vector3fImmutable slotLocation; + Quaternion slotRotation; if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; @@ -358,7 +360,7 @@ public class NPC extends AbstractCharacter { // Override bind and location for this npc derived // from BuildingManager slot location data. - slotLocation = BuildingManager.getSlotLocation(building, slot); + slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation(); this.bindLoc = building.getLoc().add(slotLocation); @@ -368,6 +370,11 @@ public class NPC extends AbstractCharacter { this.loc = new Vector3fImmutable(bindLoc); + // Rotate NPC by slot rotation + + slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation(); + this.setRot(new Vector3f(0, slotRotation.y, 0)); + // Configure region and floor/level for this NPC this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); From 52160d48c4414407ba3e35e252aa882f946fb5cb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 13:17:34 -0400 Subject: [PATCH 08/24] Adding building rotation to mobile rotation. --- src/engine/objects/Mob.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index ea8d1f95..d7f98359 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -41,6 +41,7 @@ import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static engine.math.FastMath.acos; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; public class Mob extends AbstractIntelligenceAgent { @@ -928,6 +929,12 @@ public class Mob extends AbstractIntelligenceAgent { this.loc = new Vector3fImmutable(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc); + // Rotate mobile's rotation by the building's rotation + + slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y), 0); + slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); + this.setRot(new Vector3f(0, slotRotation.y, 0)); + // Configure building region and floor/level for this Mobile this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); From c56d5567f2fc898c381a9c297833218771f9c630 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 13:21:40 -0400 Subject: [PATCH 09/24] bugfix in quaternion math. --- src/engine/objects/Mob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d7f98359..5cf420fb 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -931,7 +931,7 @@ public class Mob extends AbstractIntelligenceAgent { // Rotate mobile's rotation by the building's rotation - slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y), 0); + slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0); slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); this.setRot(new Vector3f(0, slotRotation.y, 0)); From 82aeba3a05fecd13bfa796625bcf613607cf26ba Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 13:51:31 -0400 Subject: [PATCH 10/24] NPC rotations inherit building rotation. --- src/engine/objects/Mob.java | 2 +- src/engine/objects/NPC.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 5cf420fb..d7fb700e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -929,7 +929,7 @@ public class Mob extends AbstractIntelligenceAgent { this.loc = new Vector3fImmutable(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc); - // Rotate mobile's rotation by the building's rotation + // Rotate mobile rotation by the building's rotation slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0); slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index cdd5e166..c0b5169d 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -38,6 +38,7 @@ import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static engine.math.FastMath.acos; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; import static engine.objects.MobBase.loadEquipmentSet; @@ -375,6 +376,12 @@ public class NPC extends AbstractCharacter { slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation(); this.setRot(new Vector3f(0, slotRotation.y, 0)); + // Rotate NPC rotation by the building's rotation + + slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0); + slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); + this.setRot(new Vector3f(0, slotRotation.y, 0)); + // Configure region and floor/level for this NPC this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); From e488627fcc97e20508b217fdd7ee7f4604029d97 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 14:29:58 -0400 Subject: [PATCH 11/24] Slot one is reserved on arty towers. --- src/engine/objects/NPC.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index c0b5169d..76b37dd8 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -356,6 +356,12 @@ public class NPC extends AbstractCharacter { if (slot == -1) Logger.error("No available slot for NPC: " + this.getObjectUUID()); + // Slot one is reserved on Arty towers for the trebuchet + + if (building.getBlueprint() != null && + building.getBlueprint().getBuildingGroup().equals(BuildingGroup.ARTYTOWER)) + slot = slot + 1; + building.getHirelings().put(this, slot); // Override bind and location for this npc derived From 7a3e3b394bf30eb5360d496b053550c7240f33ed Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 14:44:22 -0400 Subject: [PATCH 12/24] Slot two is reserved on arty towers. --- src/engine/gameManager/BuildingManager.java | 8 ++++++++ src/engine/objects/NPC.java | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 95984cb3..f2928afe 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -50,6 +50,14 @@ public enum BuildingManager { int numOfSlots = _slotLocations.get(building.meshUUID).size(); for (int i = 1; i <= numOfSlots; i++) { + + // Slot two is reserved on Arty towers for the trebuchet + + if (i == 2 && + building.getBlueprint() != null && + building.getBlueprint().getBuildingGroup().equals(BuildingGroup.ARTYTOWER)) + continue; + if (!building.getHirelings().containsValue(i)) return i; } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 76b37dd8..c0b5169d 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -356,12 +356,6 @@ public class NPC extends AbstractCharacter { if (slot == -1) Logger.error("No available slot for NPC: " + this.getObjectUUID()); - // Slot one is reserved on Arty towers for the trebuchet - - if (building.getBlueprint() != null && - building.getBlueprint().getBuildingGroup().equals(BuildingGroup.ARTYTOWER)) - slot = slot + 1; - building.getHirelings().put(this, slot); // Override bind and location for this npc derived From f526bda748404f139bf97ae70203db2021b31a20 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 14:51:02 -0400 Subject: [PATCH 13/24] Slot one is reserved on arty towers. --- src/engine/gameManager/BuildingManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index f2928afe..183855a2 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -53,7 +53,7 @@ public enum BuildingManager { // Slot two is reserved on Arty towers for the trebuchet - if (i == 2 && + if (i == 1 && building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.ARTYTOWER)) continue; From 7dcefdf5d7cba5474b98bf12f759daae52009b62 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 15:09:09 -0400 Subject: [PATCH 14/24] Contract moved to AbstractCharacter. Arty tower restricted to a single tower captain. --- src/engine/gameManager/BuildingManager.java | 2 +- .../net/client/handlers/ActivateNPCMsgHandler.java | 3 +++ src/engine/objects/AbstractCharacter.java | 5 +++-- src/engine/objects/Contract.java | 10 ++++++++-- src/engine/objects/Mob.java | 1 - src/engine/objects/NPC.java | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 183855a2..92deb31e 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -51,7 +51,7 @@ public enum BuildingManager { for (int i = 1; i <= numOfSlots; i++) { - // Slot two is reserved on Arty towers for the trebuchet + // Slot one is reserved on Arty towers for the trebuchet if (i == 1 && building.getBlueprint() != null && diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index f1e2532a..7aaa4d87 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -49,9 +49,12 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { for (Item hirelings : player.getInventory()) { if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) { + contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID()); + if (contract == null) continue; + if (contract.canSlotinBuilding(building)) ItemLists.add(hirelings); } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 372c8c6d..6535ebe4 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -117,9 +117,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject { private long lastHateUpdate = 0; private boolean collided = false; protected Regions lastRegion = null; - + protected boolean movingUp = false; - + public Contract contract; + /** * No Id Constructor diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index b4ed0fb9..b85a756d 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -254,10 +254,16 @@ public class Contract extends AbstractGameObject { if (this.allowedBuildings.size() == 0) return false; + // Restrict arty towers to a single captain + + if (this.getContractID() == 842) // Tower Arty Captain + for (AbstractCharacter hireling : building.getHirelings().keySet()) + if (hireling.contract.getContractID() == 842) + return false; + // Binary match return (building.getBlueprint().getBuildingGroup().elementOf(this.allowedBuildings)); - - } + } public int getEquipmentSet() { return equipmentSet; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d7fb700e..82ffc22e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -65,7 +65,6 @@ public class Mob extends AbstractIntelligenceAgent { public int spawnTime; public Zone parentZone; public Building building; - public Contract contract; public boolean hasLoot = false; public boolean isPlayerGuard = false; public AbstractCharacter npcOwner; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index c0b5169d..760df693 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -52,7 +52,7 @@ public class NPC extends AbstractCharacter { protected MobBase mobBase; protected String name; public Building building; - protected Contract contract; + protected int dbID; protected int currentID; private DateTime upgradeDateTime = null; From 033c008263422ae366d392356cc579beadd2bf8d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 14:25:30 -0400 Subject: [PATCH 15/24] bugfix: bow restriction limited to attacker. --- src/engine/net/client/handlers/PlaceAssetMsgHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index abac1b38..18b8c835 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -368,11 +368,11 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; } - //cannot place on grid until bane is live + // Attackers cannot place on grid until bane is live - if(bane.getSiegePhase() != SiegePhase.WAR && - serverCity.isLocationOnCityGrid(buildingList.getLoc()) == true) - { + if (bane.getSiegePhase() != SiegePhase.WAR && + player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) && + serverCity.isLocationOnCityGrid(buildingList.getLoc())) { PlaceAssetMsg.sendPlaceAssetError(origin, 53, player.getName()); // Buildings of war cannot be placed around a city grid unless there is an active bane return false; } From 6fb30928a1404b3c143ed291466919fefcaf0e5b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 14:43:49 -0400 Subject: [PATCH 16/24] Bugfix in slottest command. --- src/engine/devcmd/cmds/SlotTestCmd.java | 40 +++++++++++-------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index d096b947..7ba17dd8 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -16,6 +16,8 @@ import engine.gameManager.BuildingManager; import engine.gameManager.ChatManager; import engine.objects.*; +import java.util.ArrayList; + public class SlotTestCmd extends AbstractDevCmd { public SlotTestCmd() { @@ -26,6 +28,7 @@ public class SlotTestCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter playerCharacter, String[] args, AbstractGameObject target) { + ArrayList buildingLocations; String outString = "Available Slots\r\n"; if (target == null) @@ -34,36 +37,29 @@ public class SlotTestCmd extends AbstractDevCmd { if (target.getObjectType() != GameObjectType.Building) return; - Building building = (Building)target; + Building building = (Building) target; + + buildingLocations = BuildingManager._slotLocations.get(building.meshUUID); + + if (buildingLocations == null) { + outString = "No slot information for mesh: " + building.meshUUID; + ChatManager.chatSystemInfo(playerCharacter, outString); + return; + } for (BuildingLocation buildingLocation : BuildingManager._slotLocations.get(building.meshUUID)) outString += buildingLocation.getSlot() + buildingLocation.getLocation().toString() + "\r\n"; - outString += "\r\nNeext Available Slot: " + BuildingManager.getAvailableSlot(building); + outString += "\r\nNext Available Slot: " + BuildingManager.getAvailableSlot(building); if (building.getHirelings().isEmpty() == false) { outString += "\r\n\r\n"; - outString += "Hirelings List: name / slot / floor"; - - for (AbstractCharacter hireling : building.getHirelings().keySet()) { - - NPC npc; - Mob mob; - - outString += "\r\n" + hireling.getName() + " slot " + building.getHirelings().get(hireling); - - /* if (hireling.getObjectType().equals(GameObjectType.NPC)) { - npc = (NPC) hireling; - outString += "\r\n" + "location " + npc.inBuildingLoc.toString(); - continue; - } + outString += "Hirelings List:"; - mob = (Mob) hireling; + for (AbstractCharacter hireling : building.getHirelings().keySet()) + outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling); - outString += "\r\n" + "location " + mob.inBuildingLoc.toString(); - */ - } } ChatManager.chatSystemInfo(playerCharacter,outString); @@ -72,12 +68,12 @@ public class SlotTestCmd extends AbstractDevCmd { @Override protected String _getHelpString() { - return "Temporarily Changes SubRace"; + return "Displays slot information for building"; } @Override protected String _getUsageString() { - return "' /setBuildingCollidables add/remove 'add creates a collision line.' needs 4 integers. startX, endX, startY, endY"; + return "./slottest "; } From 21c6695a0507a54855b7f307774b7c47c961b3af Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 15:44:46 -0400 Subject: [PATCH 17/24] Arty captains hardcoded to slot 4. --- src/engine/objects/NPC.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 760df693..b3ecb653 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -356,6 +356,9 @@ public class NPC extends AbstractCharacter { if (slot == -1) Logger.error("No available slot for NPC: " + this.getObjectUUID()); + if (this.contract.getContractID() == 839) // Arty Captains are hardcoded to slot 4 + slot = 4; + building.getHirelings().put(this, slot); // Override bind and location for this npc derived From 294f8fe02b1487bd80d834fbe286edbb4c497629 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 16:17:53 -0400 Subject: [PATCH 18/24] Override removed edge case handed in db. --- src/engine/gameManager/BuildingManager.java | 7 ------- src/engine/objects/Contract.java | 9 +-------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 92deb31e..33b6b660 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -51,13 +51,6 @@ public enum BuildingManager { for (int i = 1; i <= numOfSlots; i++) { - // Slot one is reserved on Arty towers for the trebuchet - - if (i == 1 && - building.getBlueprint() != null && - building.getBlueprint().getBuildingGroup().equals(BuildingGroup.ARTYTOWER)) - continue; - if (!building.getHirelings().containsValue(i)) return i; } diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index b85a756d..c31f59af 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -246,7 +246,7 @@ public class Contract extends AbstractGameObject { if (building == null) return false; - // Can't slot in anything but a blueprintted building + // Can't slot in anything but a blueprinted building if (building.getBlueprintUUID() == 0) return false; @@ -254,13 +254,6 @@ public class Contract extends AbstractGameObject { if (this.allowedBuildings.size() == 0) return false; - // Restrict arty towers to a single captain - - if (this.getContractID() == 842) // Tower Arty Captain - for (AbstractCharacter hireling : building.getHirelings().keySet()) - if (hireling.contract.getContractID() == 842) - return false; - // Binary match return (building.getBlueprint().getBuildingGroup().elementOf(this.allowedBuildings)); } From ce7b203b9c8c8abc30e4051e1396869991c90cb8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 18:04:42 -0400 Subject: [PATCH 19/24] slottest function expanded. --- src/engine/devcmd/cmds/SlotTestCmd.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index 7ba17dd8..2d48f9f2 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -14,6 +14,7 @@ import engine.Enum.GameObjectType; import engine.devcmd.AbstractDevCmd; import engine.gameManager.BuildingManager; import engine.gameManager.ChatManager; +import engine.math.Vector3fImmutable; import engine.objects.*; import java.util.ArrayList; @@ -47,6 +48,20 @@ public class SlotTestCmd extends AbstractDevCmd { return; } + // Goto slot location + + if (args.length == 1) { + + int slot = Integer.parseInt(args[0]); + Vector3fImmutable slotPosition; + BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); + slotPosition = slotLocation.getLocation(); + slotPosition = Vector3fImmutable.rotateAroundPoint(building.getLoc(), slotPosition, building.getBounds().getQuaternion().angleY); + playerCharacter.teleport(slotPosition); + return; + } + + for (BuildingLocation buildingLocation : BuildingManager._slotLocations.get(building.meshUUID)) outString += buildingLocation.getSlot() + buildingLocation.getLocation().toString() + "\r\n"; @@ -73,7 +88,7 @@ public class SlotTestCmd extends AbstractDevCmd { @Override protected String _getUsageString() { - return "./slottest "; + return "./slottest n"; } From d5ca5993aa096fad69a190694c762569e67ae7fa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 18:06:28 -0400 Subject: [PATCH 20/24] slottest function expanded. --- src/engine/devcmd/cmds/SlotTestCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index 2d48f9f2..2024978c 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -55,7 +55,7 @@ public class SlotTestCmd extends AbstractDevCmd { int slot = Integer.parseInt(args[0]); Vector3fImmutable slotPosition; BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); - slotPosition = slotLocation.getLocation(); + slotPosition = building.getLoc().add(slotLocation.getLocation()); slotPosition = Vector3fImmutable.rotateAroundPoint(building.getLoc(), slotPosition, building.getBounds().getQuaternion().angleY); playerCharacter.teleport(slotPosition); return; From 9649538a566b46c915befdfd5a03ae17d5f87904 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 18:07:06 -0400 Subject: [PATCH 21/24] slottest function expanded. --- src/engine/devcmd/cmds/SlotTestCmd.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index 2024978c..acddd1de 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -53,11 +53,11 @@ public class SlotTestCmd extends AbstractDevCmd { if (args.length == 1) { int slot = Integer.parseInt(args[0]); - Vector3fImmutable slotPosition; - BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); - slotPosition = building.getLoc().add(slotLocation.getLocation()); - slotPosition = Vector3fImmutable.rotateAroundPoint(building.getLoc(), slotPosition, building.getBounds().getQuaternion().angleY); - playerCharacter.teleport(slotPosition); + Vector3fImmutable slotLocation; + BuildingLocation buildingLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); + slotLocation = building.getLoc().add(buildingLocation.getLocation()); + slotLocation = Vector3fImmutable.rotateAroundPoint(building.getLoc(), slotLocation, building.getBounds().getQuaternion().angleY); + playerCharacter.teleport(slotLocation); return; } From c44cddfb925ab32e3d797bd5335b03cfd3cc79c6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 18:12:19 -0400 Subject: [PATCH 22/24] slottest function expanded. --- src/engine/devcmd/cmds/SlotTestCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index acddd1de..7ab33737 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -50,7 +50,7 @@ public class SlotTestCmd extends AbstractDevCmd { // Goto slot location - if (args.length == 1) { + if (args[0].isEmpty() == false) { int slot = Integer.parseInt(args[0]); Vector3fImmutable slotLocation; From 2a52f9adef8ac84dc88c5d379f038cad67359f30 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 18:20:47 -0400 Subject: [PATCH 23/24] slottest function expanded. --- src/engine/devcmd/cmds/SlotTestCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index 7ab33737..6fbac8a9 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -54,7 +54,7 @@ public class SlotTestCmd extends AbstractDevCmd { int slot = Integer.parseInt(args[0]); Vector3fImmutable slotLocation; - BuildingLocation buildingLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); + BuildingLocation buildingLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot - 1); slotLocation = building.getLoc().add(buildingLocation.getLocation()); slotLocation = Vector3fImmutable.rotateAroundPoint(building.getLoc(), slotLocation, building.getBounds().getQuaternion().angleY); playerCharacter.teleport(slotLocation); From 3191c20a8c54f25fb61a375ee89552aede937428 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 3 May 2023 18:31:20 -0400 Subject: [PATCH 24/24] Captain slot no longer overridden. --- src/engine/objects/NPC.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index b3ecb653..760df693 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -356,9 +356,6 @@ public class NPC extends AbstractCharacter { if (slot == -1) Logger.error("No available slot for NPC: " + this.getObjectUUID()); - if (this.contract.getContractID() == 839) // Arty Captains are hardcoded to slot 4 - slot = 4; - building.getHirelings().put(this, slot); // Override bind and location for this npc derived