From 7ed0b8a052a3d0bf144cab4a6610737dcba7b7ea Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 13:03:41 -0500 Subject: [PATCH 01/11] wall archers given BehaviourType in initializeMob --- 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 abe71aa8..b328da32 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -916,7 +916,7 @@ public class Mob extends AbstractIntelligenceAgent { this.charItemManager.load(); //load AI for general mobs. - + if(this.contract != null && NPC.ISWallArcher(this.contract)) this.BehaviourType = MobBehaviourType.GuardWallArcher; if (isPet || isSiege || (isGuard && this.contract == null)) this.currentID = (--Mob.staticID); else this.currentID = this.dbID; From 3a7ad74ab67d2dcb1544dd4e2deefc017ee6b828 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 13:35:25 -0500 Subject: [PATCH 02/11] wall archers no longer spawn with level * 10 --- src/engine/gameManager/BuildingManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 1f2141e8..9a3c79b4 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -297,7 +297,7 @@ public enum BuildingManager { for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) { if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC) - ((NPC) slottedNPC).remove(); + ((NPC)slottedNPC).remove(); else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob) NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building); } @@ -475,7 +475,7 @@ public enum BuildingManager { NPC npc = null; - npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, false, zone, (short) rank, building); + npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, false, zone, (short)rank, building); if (npc == null) return false; @@ -508,7 +508,7 @@ public enum BuildingManager { if (NPC.ISWallArcher(contract)) { - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank * 10); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); if (mob == null) return false; From 0bc41323b1c9fdb96578bc87a6917613af748209 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 13:47:15 -0500 Subject: [PATCH 03/11] guard minions added to captains parentZone.zoneMobSet --- src/engine/objects/Mob.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b328da32..2d2aed6d 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -762,7 +762,8 @@ public class Mob extends AbstractIntelligenceAgent { mob.spawnTime = 900; mob.npcOwner = guardCaptain; mob.BehaviourType = Enum.MobBehaviourType.GuardMinion; - + //add mob to zone set of captain + guardCaptain.getParentZone().zoneMobSet.add(mob); return mob; } @@ -916,7 +917,10 @@ public class Mob extends AbstractIntelligenceAgent { this.charItemManager.load(); //load AI for general mobs. - if(this.contract != null && NPC.ISWallArcher(this.contract)) this.BehaviourType = MobBehaviourType.GuardWallArcher; + if(this.contract != null && NPC.ISWallArcher(this.contract)){ + this.BehaviourType = MobBehaviourType.GuardWallArcher; + this.isPlayerGuard = true; + } if (isPet || isSiege || (isGuard && this.contract == null)) this.currentID = (--Mob.staticID); else this.currentID = this.dbID; From e52b8e894b873f206b7aba8d800ce5014c06f599 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 14:55:12 -0500 Subject: [PATCH 04/11] guard minion logic work --- src/engine/ai/MobileFSM.java | 15 +++++++++------ src/engine/objects/Mob.java | 3 +-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 6023032e..68404682 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -199,7 +199,7 @@ public class MobileFSM { mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); MovementUtilities.aiMove(mob, mob.destination, true); mob.lastPatrolPointIndex += 1; - if (mob.isPlayerGuard()) { + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { for (Entry minion : mob.siegeMinionMap.entrySet()) { //make sure mob is out of combat stance if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) { @@ -320,6 +320,12 @@ public class MobileFSM { if (mob.playerAgroMap.isEmpty()) //no players loaded, no need to proceed return; + if (mob.isCombat() && mob.getCombatTarget() == null) { + mob.setCombat(false); + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(mob); + DispatchMessage.sendToAllInRange(mob, rwss); + } CheckToSendMobHome(mob); mob.updateLocation(); switch (mob.BehaviourType) { @@ -378,6 +384,8 @@ public class MobileFSM { return; mob.updateLocation(); if (mob.BehaviourType != Enum.MobBehaviourType.Pet1) { + if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal() && ((Mob)mob.npcOwner).despawned == true) + return; if (mob.getCombatTarget() == null) Patrol(mob); else @@ -505,11 +513,6 @@ public class MobileFSM { CheckForAttack(mob); } public static void GuardMinionLogic(Mob mob) { - if (mob.despawned || !mob.isAlive()) { - if (System.currentTimeMillis() > mob.deathTime + (mob.spawnTime * 1000)) - mob.respawn(); - return; - } if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { CheckForPlayerGuardAggro(mob); return; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 2d2aed6d..b731bb49 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1285,7 +1285,6 @@ public class Mob extends AbstractIntelligenceAgent { public void respawn() { //Commenting out Mob ID rotation. - this.despawned = false; this.playerAgroMap.clear(); this.setCombatTarget(null); @@ -1304,7 +1303,7 @@ public class Mob extends AbstractIntelligenceAgent { this.recalculateStats(); this.setHealth(this.healthMax); - + this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); if (!this.isSiege && !this.isPlayerGuard && contract == null) loadInventory(); } From 56a6b9d2044abc64713457f84352519f99b17bd4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 15:04:12 -0500 Subject: [PATCH 05/11] guard minion logic work --- src/engine/ai/MobileFSM.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 68404682..3149945e 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -384,12 +384,15 @@ public class MobileFSM { return; mob.updateLocation(); if (mob.BehaviourType != Enum.MobBehaviourType.Pet1) { - if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal() && ((Mob)mob.npcOwner).despawned == true) - return; - if (mob.getCombatTarget() == null) + if (mob.getCombatTarget() == null) { + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal() && (mob.npcOwner).isAlive()) { + return; + } Patrol(mob); - else + } + else { chaseTarget(mob); + } } else { //pet logic if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { From 6868c9de2431cff0197fe7bd8110f77458654bf1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 16:05:48 -0500 Subject: [PATCH 06/11] player placed mobiles now show correct names --- src/engine/ai/MobileFSM.java | 4 ++-- src/engine/objects/Mob.java | 29 ++++++++++------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 3149945e..5714a4f9 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -385,9 +385,9 @@ public class MobileFSM { mob.updateLocation(); if (mob.BehaviourType != Enum.MobBehaviourType.Pet1) { if (mob.getCombatTarget() == null) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal() && (mob.npcOwner).isAlive()) { + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) return; - } + Patrol(mob); } else { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b731bb49..ec8302a0 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -120,7 +120,9 @@ public class Mob extends AbstractIntelligenceAgent { if (contractID == 0) this.contract = null; else this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); - + if(building != null && building.getOwner()!= null){ + this.lastName = "the " + contract.getName(); + } clearStatic(); } @@ -253,13 +255,13 @@ 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.contract != null) { this.equipmentSetID = this.contract.getEquipmentSet(); - this.nameOverride = this.getContract().getName(); + this.lastName = this.getContract().getName(); } else { this.equipmentSetID = rs.getInt("equipmentSet"); - this.nameOverride = rs.getString("mob_name"); + } if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); @@ -328,14 +330,11 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(0xFF665EC3); //Spi writer.putInt(0); - if (!mob.nameOverride.isEmpty()) { - writer.putString(mob.nameOverride); - writer.putInt(0); - } else { + writer.putString(mob.firstName); writer.putString(mob.lastName); - } + writer.putInt(0); writer.putInt(0); @@ -706,10 +705,7 @@ public class Mob extends AbstractIntelligenceAgent { else if (guardCaptain.getRank() == 6) rank = MBServerStatics.VETERAN; else rank = MBServerStatics.ELITE; - if (rank.isEmpty()) - mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName(); - else - mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName(); + } } @@ -888,11 +884,6 @@ public class Mob extends AbstractIntelligenceAgent { this.mana.set(this.manaMax); this.stamina.set(this.staminaMax); - if (!this.nameOverride.isEmpty()) - this.firstName = this.nameOverride; - else - this.firstName = this.mobBase.getFirstName(); - if (isPet) this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks()); @@ -1990,7 +1981,7 @@ public class Mob extends AbstractIntelligenceAgent { } public String getNameOverride() { - return nameOverride; + return firstName + " " + lastName; } public void processUpgradeMob(PlayerCharacter player) { From ad4f9d3540c605dd83cf52e67e17791ff781b756 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 16:09:17 -0500 Subject: [PATCH 07/11] player placed NPCs now show correct names --- src/engine/objects/NPC.java | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 6971a3eb..65bb4d36 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -87,7 +87,6 @@ public class NPC extends AbstractCharacter { public ArrayList forgedItems = new ArrayList<>(); public HashMap equip = null; - private String nameOverride = ""; private int equipmentSetID = 0; public int runeSetID = 0; @@ -240,8 +239,10 @@ public class NPC extends AbstractCharacter { if (this.upgradeDateTime != null) submitUpgradeJob(); - this.name = this.contract.getName(); - this.nameOverride = rs.getString("npc_name"); + this.name = rs.getString("npc_name"); + if(this.building != null && this.building.getOwner() != null){ + this.name += " the " + this.contract.getName(); + } }catch(Exception e){ Logger.error(e); @@ -620,23 +621,8 @@ public class NPC extends AbstractCharacter { writer.putInt(0xFF665EC3); //Spi writer.putInt(0); - if (!npc.nameOverride.isEmpty()){ - writer.putString(npc.nameOverride); - writer.putInt(0); - }else - if (npc.contract != null) { - - if (npc.contract.isTrainer()) { - writer.putString(npc.name + ", " + npc.contract.getName()); - writer.putString(""); - } else { - writer.putString(npc.name); - writer.putString(npc.contract.getName()); - } - } else { - writer.putString(npc.name); - writer.putString(""); - } + writer.putString(npc.name); + writer.putString(""); writer.putInt(0); writer.putInt(0); @@ -1473,7 +1459,7 @@ public class NPC extends AbstractCharacter { } public String getNameOverride() { - return nameOverride; + return name; } public static NPCProfits GetNPCProfits(NPC npc){ From d4e7a6691ccc5190ba73d4aeaf0634361520a53e Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 16:12:00 -0500 Subject: [PATCH 08/11] removed unused nameOverride variable --- src/engine/objects/Mob.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index ec8302a0..932cbf0e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -67,7 +67,6 @@ public class Mob extends AbstractIntelligenceAgent { public boolean isPlayerGuard = false; public AbstractCharacter npcOwner; public long deathTime = 0; - public String nameOverride = ""; public int equipmentSetID = 0; public int runeSet = 0; public int bootySet = 0; From 9fefebd4a3a68c0c04847442d8af6b8e6cdcd09b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 16:19:53 -0500 Subject: [PATCH 09/11] wild mob naes and world NPC names corrected --- src/engine/objects/Mob.java | 3 +++ src/engine/objects/NPC.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 932cbf0e..b9b89d7a 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -255,6 +255,9 @@ 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()){ + this.firstName = this.mobBase.getFirstName(); + } if (this.contract != null) { this.equipmentSetID = this.contract.getEquipmentSet(); this.lastName = this.getContract().getName(); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 65bb4d36..a705e08b 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -240,7 +240,7 @@ public class NPC extends AbstractCharacter { submitUpgradeJob(); this.name = rs.getString("npc_name"); - if(this.building != null && this.building.getOwner() != null){ + if(this.building != null && this.building.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)){ this.name += " the " + this.contract.getName(); } From 0b932119b07be060045c56a4c39585c81bca7870 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 16:54:39 -0500 Subject: [PATCH 10/11] guard work --- src/engine/Enum.java | 5 +++-- src/engine/ai/MobileFSM.java | 11 ++++++----- src/engine/objects/Mob.java | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 180ecbda..2d2c919a 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2636,8 +2636,9 @@ public class Enum { TEMPLEGUARD(1575,1652, MinionClass.MELEE,"Guard","Temple"), TEMPLEMAGE(1577, 1656, MinionClass.MAGE,"Confessor","Temple"), UNDEADGUARD(980100,1674,MinionClass.MELEE,"Guard","Undead"), - UNDEADMAGE(980102,1675,MinionClass.MAGE,"Adept","Undead"); - + UNDEADMAGE(980102,1675,MinionClass.MAGE,"Adept","Undead"), + WEREWOLFGUARD(980111,0,MinionClass.MELEE,"Guard","Werewolf"), + WEREBEARGUARD(980110,0,MinionClass.MELEE,"Guard","Werebear"); private final int captainContractID; private final int equipSetID; private final MinionClass minionClass; diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 5714a4f9..caae9949 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -385,12 +385,13 @@ public class MobileFSM { mob.updateLocation(); if (mob.BehaviourType != Enum.MobBehaviourType.Pet1) { if (mob.getCombatTarget() == null) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) - return; - + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { + if (mob.npcOwner.isAlive() == true) { + return; + } + } Patrol(mob); - } - else { + }else { chaseTarget(mob); } } else { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b9b89d7a..72359434 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -707,7 +707,8 @@ public class Mob extends AbstractIntelligenceAgent { else if (guardCaptain.getRank() == 6) rank = MBServerStatics.VETERAN; else rank = MBServerStatics.ELITE; - + mob.firstName = NPC.getPirateName(mob.getMobBaseID()); + mob.lastName = rank + " " + minionType.getRace() + " " + minionType.name(); } } @@ -715,6 +716,7 @@ public class Mob extends AbstractIntelligenceAgent { // mob.setMob(); mob.isPlayerGuard = true; + DbManager.addToCache(mob); RuneBase guardRune = RuneBase.getRuneBase(252621); From 566bb8144aabb8f78265b82622fbc4aa826aab8f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Apr 2023 17:17:20 -0500 Subject: [PATCH 11/11] were guard contract ID in enum --- src/engine/Enum.java | 4 ++-- src/engine/objects/Mob.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 2d2c919a..ccd2db53 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2637,8 +2637,8 @@ public class Enum { TEMPLEMAGE(1577, 1656, MinionClass.MAGE,"Confessor","Temple"), UNDEADGUARD(980100,1674,MinionClass.MELEE,"Guard","Undead"), UNDEADMAGE(980102,1675,MinionClass.MAGE,"Adept","Undead"), - WEREWOLFGUARD(980111,0,MinionClass.MELEE,"Guard","Werewolf"), - WEREBEARGUARD(980110,0,MinionClass.MELEE,"Guard","Werebear"); + WEREWOLFGUARD(980104,0,MinionClass.MELEE,"Guard","Werewolf"), + WEREBEARGUARD(980103,0,MinionClass.MELEE,"Guard","Werebear"); private final int captainContractID; private final int equipSetID; private final MinionClass minionClass; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 72359434..2b2603a4 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -708,7 +708,7 @@ public class Mob extends AbstractIntelligenceAgent { else rank = MBServerStatics.ELITE; mob.firstName = NPC.getPirateName(mob.getMobBaseID()); - mob.lastName = rank + " " + minionType.getRace() + " " + minionType.name(); + mob.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); } }