From 7ef338be1d59e799e13aeddcd8e627980a2fd69e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 4 Apr 2023 10:31:59 -0400 Subject: [PATCH] Bugfix in slotting blueprint buildings --- src/engine/gameManager/BuildingManager.java | 32 ++++++++++----------- src/engine/objects/Mob.java | 1 - src/engine/objects/NPC.java | 12 ++++---- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 5e84494e..9d51282f 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -450,7 +450,7 @@ public enum BuildingManager { } - public static synchronized boolean addHireling(Building building, PlayerCharacter contractOwner, Vector3fImmutable NpcLoc, Zone zone, Contract NpcID, Item item) { + public static synchronized boolean addHireling(Building building, PlayerCharacter contractOwner, Vector3fImmutable NpcLoc, Zone zone, Contract contractID, Item item) { int rank = 1; @@ -460,7 +460,7 @@ public enum BuildingManager { if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) return false; - String pirateName = NPC.getPirateName(NpcID.getMobbaseID()); + String pirateName = NPC.getPirateName(contractID.getMobbaseID()); if (item.getChargesRemaining() > 0) rank = item.getChargesRemaining() * 10; @@ -469,9 +469,9 @@ public enum BuildingManager { Mob mob = null; NPC npc = null; - if (NPC.ISGuardCaptain(NpcID.getContractID())) { + if (NPC.ISGuardCaptain(contractID.getContractID())) { - mob = Mob.createMob( NpcID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, NpcID.getContractID()); + mob = Mob.createMob( contractID.getMobbaseID(), NpcLoc, contractOwner.getGuild(), true, zone, building, contractID.getContractID()); if (mob == null) return false; @@ -480,25 +480,23 @@ public enum BuildingManager { mob.setPlayerGuard(true); mob.setParentZone(zone); return true; - } else { - npc = NPC.createNPC( pirateName, NpcID.getObjectUUID(), NpcLoc, contractOwner.getGuild(), false, zone, (short) rank, false, building); - - if (npc == null) - return false; + } + npc = NPC.createNPC( pirateName, contractID.getObjectUUID(), NpcLoc, contractOwner.getGuild(), false, zone, (short) rank, false, building); + if (npc == null) + return false; - npc.setBindLoc(NpcLoc.x - zone.getAbsX(), NpcLoc.y - zone.getAbsY(), NpcLoc.z - zone.getAbsZ()); + npc.setBindLoc(NpcLoc.x - zone.getAbsX(), NpcLoc.y - zone.getAbsY(), NpcLoc.z - zone.getAbsZ()); - npc.setBuilding(building); - npc.setParentZone(zone); + npc.setBuilding(building); + npc.setParentZone(zone); - if (NPC.GetNPCProfits(npc) == null) - NPCProfits.CreateProfits(npc); + if (NPC.GetNPCProfits(npc) == null) + NPCProfits.CreateProfits(npc); - WorldGrid.addObject(npc, contractOwner); + WorldGrid.addObject(npc, contractOwner); - return true; - } + return true; } public static boolean IsWallPiece(Building building) { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 9d8a7268..a0dcfbe0 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -940,7 +940,6 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone = zone; } - if ( this.building != null) { Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat,this.statAlt,this.statLon); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 36c90f31..aed36832 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -348,15 +348,13 @@ public class NPC extends AbstractCharacter { this.setHealth(this.healthMax); this.mana.set(this.manaMax); this.stamina.set(this.staminaMax); - //this.firstName = this.minionMobBase.getFirstName(); - //this.lastName = ""; - //this.level = (short)(this.minionMobBase.getLevel()); } //add this npc to building - if (this.building != null && this.loadID != 0) { - if (building.getBlueprint() != null){ + if (this.building != null) { + + if (building.getBlueprint() != null) { int maxSlots; maxSlots = building.getBlueprint().getSlotsForRank(this.building.getRank()); @@ -368,8 +366,7 @@ public class NPC extends AbstractCharacter { break; } } - //npc created by an admin without a blueprint, just default max slot size to 10. - }else{ + } else { int maxSlots = 10; @@ -1094,6 +1091,7 @@ public class NPC extends AbstractCharacter { // *** Refactor : this has a useInit flag that can be removed public static NPC createNPC(String name, int contractID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, short level, boolean useInit, Building building) { + NPC npcWithoutID = new NPC(name, (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 1, 0, false, false, false, spawn, spawn, Vector3fImmutable.ZERO, (short) 1, (short) 1, (short) 1, guild, (byte) 0, 0, isMob, building, contractID, parent);