From 07c553294b1bab487eb3ee909373cefddbf40eac Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 15:04:32 -0400 Subject: [PATCH 001/233] Mobiles use new slotting mechanic. --- src/engine/objects/Mob.java | 41 ++----------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index a7e26c1b..e37da320 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -20,7 +20,6 @@ import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; import engine.math.Bounds; import engine.math.Quaternion; -import engine.math.Vector3f; import engine.math.Vector3fImmutable; import engine.mobileAI.Threads.MobAIThread; import engine.net.ByteBufferWriter; @@ -43,7 +42,6 @@ import java.util.LinkedHashMap; 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 { @@ -898,43 +896,8 @@ public class Mob extends AbstractIntelligenceAgent { this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); this.bindLoc = this.building.getLoc().add(this.bindLoc); - } else { - - // Get next available slot for this Mobile and then - // add it to the building's hireling list - - slot = BuildingManager.getAvailableSlot(building); - - if (slot == -1) - Logger.error("No available slot for Mobile: " + this.getObjectUUID()); - - building.getHirelings().put(this, slot); - - // Override bind and location for this contracted Mobile - // derived from BuildingManager slot location data. - - slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation(); - - this.bindLoc = building.getLoc().add(slotLocation); - - } - - // Rotate slot position by the building rotation - - this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, building.getBounds().getQuaternion().angleY); - - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); - - // 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()); - 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); + } else + NPCManager.slotCharacterInBuilding(this); } if (this.mobBase != null) { From e00328ae13f13040fbdd95de52a65bd0ca49854b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 15:09:10 -0400 Subject: [PATCH 002/233] Siege pets use slotting mechanic. --- src/engine/objects/Mob.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e37da320..1c559543 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -889,7 +889,9 @@ public class Mob extends AbstractIntelligenceAgent { if (this.building != null) { - if (this.contract == null) { + // Siege mobiles don't have contracts. + + if (this.contract == null && !this.agentType.equals(AIAgentType.PET)) { // Mobiles inside buildings are offset from it not the zone From 43375a6f5bc1126c6ee6ce81c7a79e463223f8e4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 15:22:08 -0400 Subject: [PATCH 003/233] Only mobiles with contracts can be slotted. --- src/engine/gameManager/NPCManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 11deb263..6d468f0e 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -343,7 +343,16 @@ public enum NPCManager { if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + // Pets are regular mobiles not hirelings (Siege engines) + + if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob)) { + + Mob mobile = (Mob) abstractCharacter; + + if (mobile.contract != null) + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + } else + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived // from BuildingManager slot location data. From bdf14b8f245ddbc4a1be39c811543d5f9d5a51a5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 15:37:21 -0400 Subject: [PATCH 004/233] Ordinal comparisons refactored. --- src/engine/mobileAI/MobAI.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 751ffc0e..5b55ac18 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -165,7 +165,7 @@ public class MobAI { if (playercity != null) for (Mob guard : playercity.getParent().zoneMobSet) - if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) + if (guard.BehaviourType != null && guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild())) guard.setCombatTarget(mob); @@ -260,7 +260,7 @@ public class MobAI { //guard captains inherit barracks patrol points dynamically - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { Building barracks = mob.building; @@ -608,7 +608,7 @@ public class MobAI { if (mob.despawned && mob.isPlayerGuard) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { + if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { //minions don't respawn while guard captain is dead @@ -625,7 +625,7 @@ public class MobAI { //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting - if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); return; @@ -646,7 +646,7 @@ public class MobAI { return; } - if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -893,7 +893,8 @@ public class MobAI { if (mob.getCombatTarget() == null) return; - if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { + if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && + mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) { mob.setCombatTarget(null); return; @@ -912,7 +913,7 @@ public class MobAI { if (mob.BehaviourType.isAgressive) { if (mob.isPlayerGuard()) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) CheckForPlayerGuardAggro(mob); } else { CheckForAggro(mob); @@ -932,7 +933,7 @@ public class MobAI { PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) { + if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) { //guard captain pulls his minions home with him @@ -1246,7 +1247,7 @@ public class MobAI { if (mob.getGuild().getNation().equals(target.getGuild().getNation())) return false; - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { + if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { return true; } @@ -1331,7 +1332,7 @@ public class MobAI { MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { for (Entry minion : mob.siegeMinionMap.entrySet()) { //make sure mob is out of combat stance From 876ccc7cbf23fe834679bff3c20f52c03deabdec Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 16:12:06 -0400 Subject: [PATCH 005/233] New constructor created. --- src/engine/objects/AbstractIntelligenceAgent.java | 4 ++++ src/engine/objects/Mob.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index 580a3094..b99e06cb 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -33,6 +33,10 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; + public AbstractIntelligenceAgent() { + super(); + } + public AbstractIntelligenceAgent(ResultSet rs) throws SQLException { super(rs); } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 1c559543..b8c44f05 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -99,6 +99,12 @@ public class Mob extends AbstractIntelligenceAgent { private DateTime upgradeDateTime = null; private boolean lootSync = false; + // New Mobile constructor. Fill in the blanks and then call + // PERSIST. + public Mob() { + this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; + this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; + } /** * No Id Constructor @@ -109,7 +115,7 @@ public class Mob extends AbstractIntelligenceAgent { this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.loadID = npcType; this.mobBase = MobBase.getMobBase(loadID); - this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; + this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.parentZone = parent; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.building = building; From 0b05c7074f809b2ea8d518409c62a0425215b7c1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 16:37:52 -0400 Subject: [PATCH 006/233] Slot all agents but true mobiles. --- 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 b8c44f05..08ec8048 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -897,7 +897,7 @@ public class Mob extends AbstractIntelligenceAgent { // Siege mobiles don't have contracts. - if (this.contract == null && !this.agentType.equals(AIAgentType.PET)) { + if (this.contract == null && this.agentType.equals(AIAgentType.MOBILE)) { // Mobiles inside buildings are offset from it not the zone From 17a6494b2b31cfc64b8a0e29c848353541ab6db3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 16:41:21 -0400 Subject: [PATCH 007/233] Unused code. --- src/engine/objects/Mob.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 08ec8048..9aac341e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -19,7 +19,6 @@ import engine.job.JobScheduler; import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; import engine.math.Bounds; -import engine.math.Quaternion; import engine.math.Vector3fImmutable; import engine.mobileAI.Threads.MobAIThread; import engine.net.ByteBufferWriter; @@ -870,10 +869,6 @@ public class Mob extends AbstractIntelligenceAgent { private void initializeMob(boolean isPet, boolean isSiege, boolean isGuard) { - int slot; - Vector3fImmutable slotLocation; - Quaternion slotRotation; - if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; From ec3a9b6cb42c3bd08908f09d699d564b448813ea Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 16:50:15 -0400 Subject: [PATCH 008/233] Minions don't have contracts. --- 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 9aac341e..6992fcb8 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -892,7 +892,7 @@ public class Mob extends AbstractIntelligenceAgent { // Siege mobiles don't have contracts. - if (this.contract == null && this.agentType.equals(AIAgentType.MOBILE)) { + if (this.contract == null) { // Mobiles inside buildings are offset from it not the zone From 039e55673b5e17ed3197ab8ec271a5e88c3724bb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 17:00:27 -0400 Subject: [PATCH 009/233] Exception for siege when slotting. --- src/engine/objects/Mob.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6992fcb8..4c4b911c 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -890,16 +890,12 @@ public class Mob extends AbstractIntelligenceAgent { if (this.building != null) { - // Siege mobiles don't have contracts. + // Mobiles inside buildings are offset from it not the zone - if (this.contract == null) { - - // Mobiles inside buildings are offset from it not the zone - - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.bindLoc = this.building.getLoc().add(this.bindLoc); + this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); + this.bindLoc = this.building.getLoc().add(this.bindLoc); - } else + if (this.contract != null || this.isSiege) NPCManager.slotCharacterInBuilding(this); } From 7eab14938daa2ed916781fa22f0404d8e71ca918 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 17:11:20 -0400 Subject: [PATCH 010/233] Exception for siege when slotting. --- src/engine/gameManager/NPCManager.java | 2 +- src/engine/objects/Mob.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 6d468f0e..9aa84dca 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -349,7 +349,7 @@ public enum NPCManager { Mob mobile = (Mob) abstractCharacter; - if (mobile.contract != null) + if (mobile.isSiege == false) abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); } else abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 4c4b911c..b0283f7d 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -90,7 +90,7 @@ public class Mob extends AbstractIntelligenceAgent { private int ownerUID = 0; //only used by pets private AbstractWorldObject fearedObject = null; private int buildingID; - private boolean isSiege = false; + public boolean isSiege = false; private long lastAttackTime = 0; private int lastMobPowerToken = 0; private HashMap equip = null; From adafbdf6d3d7dd29344c5bcfccc0e529c981f732 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 21 Aug 2023 17:20:57 -0400 Subject: [PATCH 011/233] Duplicate building and building ID values. --- src/engine/objects/Mob.java | 11 +++++------ src/engine/objects/PlayerCharacter.java | 9 ++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b0283f7d..5a57171d 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -63,7 +63,6 @@ public class Mob extends AbstractIntelligenceAgent { public MobBase mobBase; public int spawnTime; public Zone parentZone; - public Building building; public boolean hasLoot = false; public boolean isPlayerGuard = false; public AbstractCharacter npcOwner; @@ -89,7 +88,7 @@ public class Mob extends AbstractIntelligenceAgent { private int currentID; private int ownerUID = 0; //only used by pets private AbstractWorldObject fearedObject = null; - private int buildingID; + public boolean isSiege = false; private long lastAttackTime = 0; private int lastMobPowerToken = 0; @@ -120,9 +119,9 @@ public class Mob extends AbstractIntelligenceAgent { this.building = building; if (building != null) - this.buildingID = building.getObjectUUID(); + this.buildingUUID = building.getObjectUUID(); else - this.buildingID = 0; + this.buildingUUID = 0; if (contractID == 0) this.contract = null; @@ -2000,11 +1999,11 @@ public class Mob extends AbstractIntelligenceAgent { } public int getBuildingID() { - return buildingID; + return buildingUUID; } public void setBuildingID(int buildingID) { - this.buildingID = buildingID; + this.buildingUUID = buildingID; } public boolean isSiege() { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 35dd8c5a..48c75a0f 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -144,7 +144,6 @@ public class PlayerCharacter extends AbstractCharacter { private long lastUpdateTime = System.currentTimeMillis(); private long lastStamUpdateTime = System.currentTimeMillis(); private boolean safeZone = false; - private int bindBuildingID; /* DataWarehouse based kill/death tracking. @@ -205,7 +204,7 @@ public class PlayerCharacter extends AbstractCharacter { this.spiMod.set(spiMod); this.guildStatus = new AtomicInteger(0); - this.bindBuildingID = -1; + this.buildingUUID = -1; } /** @@ -265,7 +264,7 @@ public class PlayerCharacter extends AbstractCharacter { this.intMod.set(rs.getShort("char_intMod")); this.spiMod.set(rs.getShort("char_spiMod")); - this.bindBuildingID = rs.getInt("char_bindBuilding"); + this.buildingUUID = rs.getInt("char_bindBuilding"); this.hash = rs.getString("hash"); @@ -2721,12 +2720,12 @@ public class PlayerCharacter extends AbstractCharacter { */ public synchronized int getBindBuildingID() { - return this.bindBuildingID; + return this.buildingUUID; } public synchronized void setBindBuildingID(int value) { DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value); - this.bindBuildingID = value; + this.buildingUUID = value; } public AbstractGameObject getLastTarget() { From eb25caec8106227d9db1765cead86b28ec1dc7a3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 23 Aug 2023 12:24:43 -0400 Subject: [PATCH 012/233] Object creation moved out of rs const. --- src/engine/objects/Mob.java | 84 ++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index f55c4712..6b683cf4 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -193,12 +193,10 @@ public class Mob extends AbstractIntelligenceAgent { try { this.dbID = rs.getInt(1); - //this.state = STATE.Idle; this.loadID = rs.getInt("mob_mobbaseID"); this.gridObjectType = GridObjectType.DYNAMIC; this.spawnRadius = rs.getFloat("mob_spawnRadius"); this.spawnTime = rs.getInt("mob_spawnTime"); - this.parentZone = null; this.statLat = rs.getFloat("mob_spawnX"); this.statAlt = rs.getFloat("mob_spawnY"); this.statLon = rs.getFloat("mob_spawnZ"); @@ -207,36 +205,14 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZoneID = rs.getInt("parent"); this.level = (short) rs.getInt("mob_level"); - int buildingID = rs.getInt("mob_buildingID"); - try { - this.building = BuildingManager.getBuilding(buildingID); - } catch (Exception e) { - this.building = null; - Logger.error(e.getMessage()); - } - - int contractID = rs.getInt("mob_contractID"); - - if (contractID == 0) - this.contract = null; - else - this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); - - if (this.contract != null && NPC.ISGuardCaptain(contract.getContractID())) { - this.spawnTime = 60 * 15; - this.isPlayerGuard = true; - } + this.buildingUUID = rs.getInt("mob_buildingID"); - int guildID = rs.getInt("mob_guildUID"); + this.contractUUID = rs.getInt("mob_contractID"); - if (this.building != null) - this.guild = this.building.getGuild(); - else - this.guild = Guild.getGuild(guildID); + this.guildUUID = rs.getInt("mob_guildUID"); - if (this.guild == null) - this.guild = Guild.getErrantGuild(); + this.equipmentSetID = rs.getInt("equipmentSet"); java.util.Date sqlDateTime; sqlDateTime = rs.getTimestamp("upgradeDate"); @@ -251,10 +227,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.upgradeDateTime != null) Mob.submitUpgradeJob(this); - this.mobBase = MobBase.getMobBase(loadID); - - this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); - if (this.mobBase != null && this.spawnTime == 0) this.spawnTime = this.mobBase.getSpawnTime(); @@ -267,16 +239,6 @@ public class Mob extends AbstractIntelligenceAgent { 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(); - } else - this.equipmentSetID = rs.getInt("equipmentSet"); - - if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); @@ -1886,6 +1848,44 @@ public class Mob extends AbstractIntelligenceAgent { @Override public void runAfterLoad() { + try { + this.building = BuildingManager.getBuilding(this.buildingUUID); + } catch (Exception e) { + this.building = null; + Logger.error(e.getMessage()); + } + + if (this.contractUUID == 0) + this.contract = null; + else + this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); + + if (this.contract != null && NPC.ISGuardCaptain(contract.getContractID())) { + this.spawnTime = 60 * 15; + this.isPlayerGuard = true; + } + + if (this.building != null) + this.guild = this.building.getGuild(); + else + this.guild = Guild.getGuild(guildUUID); + + if (this.guild == null) + this.guild = Guild.getErrantGuild(); + + this.mobBase = MobBase.getMobBase(loadID); + + this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); + + if (this.firstName.isEmpty()) + this.firstName = this.mobBase.getFirstName(); + + if (this.contract != null) { + this.equipmentSetID = this.contract.getEquipmentSet(); + this.lastName = this.getContract().getName(); + } + + // Initialize inventory this.charItemManager = new CharacterItemManager(this); From 1738f7b311905a621521e42b45664e324958f095 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 23 Aug 2023 12:38:46 -0400 Subject: [PATCH 013/233] Starting to whittle away at initmob method. --- src/engine/objects/Mob.java | 56 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6b683cf4..051f4a9d 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -833,33 +833,6 @@ public class Mob extends AbstractIntelligenceAgent { if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; - // Configure parent zone adding this NPC to the - // zone collection - - this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneID); - this.parentZone.zoneMobSet.remove(this); - this.parentZone.zoneMobSet.add(this); - - // Setup location for this Mobile - - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); - - // Handle Mobiles within buildings - - if (this.building != null) { - - // Mobiles inside buildings are offset from it not the zone - - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.bindLoc = this.building.getLoc().add(this.bindLoc); - - if (this.contract != null || this.isSiege) - NPCManager.slotCharacterInBuilding(this); - } - if (this.mobBase != null) { this.gridObjectType = GridObjectType.DYNAMIC; this.healthMax = this.mobBase.getHealthMax(); @@ -1885,6 +1858,35 @@ public class Mob extends AbstractIntelligenceAgent { this.lastName = this.getContract().getName(); } + if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) + return; + + // Configure parent zone adding this NPC to the + // zone collection + + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneID); + this.parentZone.zoneMobSet.remove(this); + this.parentZone.zoneMobSet.add(this); + + // Setup location for this Mobile + + this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); + this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); + this.loc = new Vector3fImmutable(bindLoc); + this.endLoc = new Vector3fImmutable(bindLoc); + + // Handle Mobiles within buildings + + if (this.building != null) { + + // Mobiles inside buildings are offset from it not the zone + + this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); + this.bindLoc = this.building.getLoc().add(this.bindLoc); + + if (this.contract != null || this.isSiege) + NPCManager.slotCharacterInBuilding(this); + } // Initialize inventory From 3534ac6477f68d2980f828a84719b3bfa7cf9ff7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 23 Aug 2023 12:48:34 -0400 Subject: [PATCH 014/233] Starting to whittle away at initmob method. --- src/engine/objects/Mob.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 051f4a9d..cfb71043 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -246,12 +246,6 @@ public class Mob extends AbstractIntelligenceAgent { Logger.error(e + " " + this.dbID); } - try { - initializeMob(false, false, this.isPlayerGuard); - } catch (Exception e) { - Logger.error("Mobile:" + this.dbID + ": " + e); - } - } public static void serializeMobForClientMsgOtherPlayer(Mob mob, ByteBufferWriter writer) throws SerializationException { @@ -1888,10 +1882,13 @@ public class Mob extends AbstractIntelligenceAgent { NPCManager.slotCharacterInBuilding(this); } + initializeMob(false, false, this.isPlayerGuard); + // Initialize inventory this.charItemManager = new CharacterItemManager(this); this.loadInventory(); + try { if (this.equipmentSetID != 0) this.equip = MobBase.loadEquipmentSet(this.equipmentSetID); From 62c7e524878292aa468db2f2f041eb2d8b74f1a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 23 Aug 2023 13:01:36 -0400 Subject: [PATCH 015/233] Starting to whittle away at initmob method. --- 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 cfb71043..87cd5c60 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -246,6 +246,12 @@ public class Mob extends AbstractIntelligenceAgent { Logger.error(e + " " + this.dbID); } + try { + initializeMob(false, false, this.isPlayerGuard); + } catch (Exception e) { + Logger.error("Mobile:" + this.dbID + ": " + e); + } + } public static void serializeMobForClientMsgOtherPlayer(Mob mob, ByteBufferWriter writer) throws SerializationException { @@ -1882,8 +1888,6 @@ public class Mob extends AbstractIntelligenceAgent { NPCManager.slotCharacterInBuilding(this); } - initializeMob(false, false, this.isPlayerGuard); - // Initialize inventory this.charItemManager = new CharacterItemManager(this); From ef577dd3132f77f2a1ecc20e98545e9a0da08d7d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 23 Aug 2023 13:03:59 -0400 Subject: [PATCH 016/233] Removed catch to propagate error. --- src/engine/objects/Mob.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 87cd5c60..68d4fca2 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -246,11 +246,8 @@ public class Mob extends AbstractIntelligenceAgent { Logger.error(e + " " + this.dbID); } - try { - initializeMob(false, false, this.isPlayerGuard); - } catch (Exception e) { - Logger.error("Mobile:" + this.dbID + ": " + e); - } + initializeMob(false, false, this.isPlayerGuard); + } From 579c26ac5943dff1a37f16f5a3be5b899c254536 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 23 Aug 2023 13:19:57 -0400 Subject: [PATCH 017/233] InitializeMob removed. --- src/engine/objects/Mob.java | 118 +++++++++++++++++------------------- 1 file changed, 55 insertions(+), 63 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 68d4fca2..51d3d4ae 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -150,7 +150,6 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone = parent; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.building = building; - initializeMob(false, false, false); clearStatic(); } @@ -166,7 +165,6 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); this.BehaviourType = Enum.MobBehaviourType.Pet1; - initializeMob(true, false, false); clearStatic(); } @@ -180,7 +178,6 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = 0; this.equip = new HashMap<>(); - initializeMob(false, true, isPlayerGuard); clearStatic(); } @@ -242,13 +239,15 @@ public class Mob extends AbstractIntelligenceAgent { if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); + if (this.isPet() || this.isSiege || (this.isPlayerGuard && this.contract == null)) + this.currentID = (--Mob.staticID); + else + this.currentID = this.dbID; + } catch (Exception e) { Logger.error(e + " " + this.dbID); } - initializeMob(false, false, this.isPlayerGuard); - - } public static void serializeMobForClientMsgOtherPlayer(Mob mob, ByteBufferWriter writer) throws SerializationException { @@ -825,61 +824,6 @@ public class Mob extends AbstractIntelligenceAgent { this.statAlt = 0f; } - private void initializeMob(boolean isPet, boolean isSiege, boolean isGuard) { - - if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) - return; - - if (this.mobBase != null) { - this.gridObjectType = GridObjectType.DYNAMIC; - this.healthMax = this.mobBase.getHealthMax(); - this.manaMax = 0; - this.staminaMax = 0; - this.setHealth(this.healthMax); - this.mana.set(this.manaMax); - this.stamina.set(this.staminaMax); - - if (isPet) - this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks()); - - if (this.contract == null) - this.level = (short) this.mobBase.getLevel(); - } - - //set bonuses - this.bonuses = new PlayerBonuses(this); - - //TODO set these correctly later - this.rangeHandOne = 8; - this.rangeHandTwo = -1; - this.minDamageHandOne = 0; - this.maxDamageHandOne = 0; - this.minDamageHandTwo = 1; - this.maxDamageHandTwo = 4; - this.atrHandOne = 300; - this.defenseRating = (short) this.mobBase.getDefenseRating(); - this.isActive = true; - - this.charItemManager.load(); - - //load AI for general mobs. - if (this.contract != null && NPC.ISWallArcher(this.contract)) { - this.BehaviourType = MobBehaviourType.GuardWallArcher; - this.isPlayerGuard = true; - this.spawnTime = 450; - } - if (isPet || isSiege || (isGuard && this.contract == null)) - this.currentID = (--Mob.staticID); - else - this.currentID = this.dbID; - - //store mobs by Database ID - - if (!isPet && !isSiege) - Mob.mobMapByDBID.put(this.dbID, this); - - } - /* * Getters */ @@ -1818,6 +1762,14 @@ public class Mob extends AbstractIntelligenceAgent { @Override public void runAfterLoad() { + if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) + return; + + // Add new object to collection + + if (!this.isPet() && !isSiege) + Mob.mobMapByDBID.put(this.dbID, this); + try { this.building = BuildingManager.getBuilding(this.buildingUUID); } catch (Exception e) { @@ -1855,8 +1807,48 @@ public class Mob extends AbstractIntelligenceAgent { this.lastName = this.getContract().getName(); } - if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) - return; + //store mobs by Database ID + + if (!this.isPet() && !isSiege) + Mob.mobMapByDBID.put(this.dbID, this); + + if (this.mobBase != null) { + this.gridObjectType = GridObjectType.DYNAMIC; + this.healthMax = this.mobBase.getHealthMax(); + this.manaMax = 0; + this.staminaMax = 0; + this.setHealth(this.healthMax); + this.mana.set(this.manaMax); + this.stamina.set(this.staminaMax); + + if (this.contract == null) + this.level = (short) this.mobBase.getLevel(); + + //set bonuses + this.bonuses = new PlayerBonuses(this); + + //TODO set these correctly later + this.rangeHandOne = 8; + this.rangeHandTwo = -1; + this.minDamageHandOne = 0; + this.maxDamageHandOne = 0; + this.minDamageHandTwo = 1; + this.maxDamageHandTwo = 4; + this.atrHandOne = 300; + this.defenseRating = (short) this.mobBase.getDefenseRating(); + this.isActive = true; + + this.charItemManager.load(); + + // Load AI for wall archers + + if (this.contract != null && NPC.ISWallArcher(this.contract)) { + this.BehaviourType = MobBehaviourType.GuardWallArcher; + this.isPlayerGuard = true; + this.spawnTime = 450; + } + + } // Configure parent zone adding this NPC to the // zone collection From 9264347698a26f253b2428b9e785aaa8dbfc0dd2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 10:18:17 -0400 Subject: [PATCH 018/233] Minions inherit enemy/notenemy from captain. --- src/engine/objects/Mob.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 51d3d4ae..b2548824 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -690,6 +690,9 @@ public class Mob extends AbstractIntelligenceAgent { if (guardCaptain.equipmentSetID != 0) mob.equipmentSetID = guardCaptain.equipmentSetID; + mob.enemy = guardCaptain.enemy; + mob.notEnemy = guardCaptain.notEnemy; + mob.runAfterLoad(); mob.despawned = true; mob.despawn(); From 22e4cc07c0b41e5c49930d9f4b4b09bcdf5c0b2d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 11:26:09 -0400 Subject: [PATCH 019/233] Separate pet and siege behaviour types. --- src/engine/Enum.java | 3 ++- src/engine/mobileAI/MobAI.java | 12 ++++++------ src/engine/objects/Mob.java | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index e98fcabc..9734cc7b 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2846,7 +2846,8 @@ public class Enum { SpellAggroGrouperWimpy(Spell, true, false, true, false, false), //Independent Types SimpleStandingGuard(null, false, false, false, false, false), - Pet1(null, false, false, true, false, false), + Pet(null, false, false, true, false, false), + Siege(null, false, false, true, false, false), Simple(null, false, false, true, false, false), Helpee(null, false, true, true, false, true), HelpeeWimpy(null, true, false, true, false, false), diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index a1676a15..68c3dbc8 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -625,7 +625,7 @@ public class MobAI { //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting - if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet) == false) CheckToSendMobHome(mob); return; @@ -646,7 +646,7 @@ public class MobAI { return; } - if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet) == false) CheckToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -683,7 +683,7 @@ public class MobAI { case GuardWallArcher: GuardWallArcherLogic(mob); break; - case Pet1: + case Pet: PetLogic(mob); break; case HamletGuard: @@ -784,7 +784,7 @@ public class MobAI { switch (mob.BehaviourType) { - case Pet1: + case Pet: if (mob.getOwner() == null) return; @@ -894,7 +894,7 @@ public class MobAI { return; if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && - mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) { + mob.BehaviourType.equals(Enum.MobBehaviourType.Pet) == false) { mob.setCombatTarget(null); return; @@ -1014,7 +1014,7 @@ public class MobAI { if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD))) continue; - if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)) + if (aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet)) continue; if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b2548824..49adb9f4 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -164,7 +164,7 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone = parent; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); - this.BehaviourType = Enum.MobBehaviourType.Pet1; + this.BehaviourType = Enum.MobBehaviourType.Pet; clearStatic(); } @@ -811,7 +811,7 @@ public class Mob extends AbstractIntelligenceAgent { owner.getSiegeMinionMap().put(mob, slot); mob.setNpcOwner(owner); - mob.BehaviourType = MobBehaviourType.Pet1; + mob.BehaviourType = MobBehaviourType.Pet; mob.BehaviourType.canRoam = false; return mob; } From 29e24bae938a697adb1b42ee9a34466a3eb043dd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 11:37:56 -0400 Subject: [PATCH 020/233] Unused constructor removed. --- src/engine/objects/Mob.java | 21 +-------------------- src/engine/objects/NPC.java | 1 + 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 49adb9f4..45a518cd 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -100,6 +100,7 @@ public class Mob extends AbstractIntelligenceAgent { // New Mobile constructor. Fill in the blanks and then call // PERSIST. public Mob() { + super(); this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; } @@ -133,26 +134,6 @@ public class Mob extends AbstractIntelligenceAgent { clearStatic(); } - /** - * Normal Constructor - */ - public Mob(String firstName, String lastName, short statStrCurrent, short statDexCurrent, short statConCurrent, short statIntCurrent, short statSpiCurrent, short level, int exp, boolean sit, boolean walk, boolean combat, Vector3fImmutable bindLoc, Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild, byte runningTrains, int npcType, boolean isMob, Zone parent, int newUUID, Building building, int contractID) { - super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, sit, walk, combat, bindLoc, currentLoc, faceDir, healthCurrent, manaCurrent, stamCurrent, guild, runningTrains, newUUID); - this.dbID = newUUID; - this.loadID = npcType; - - if (contractID == 0) - this.contract = null; - else - this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); - - this.mobBase = MobBase.getMobBase(loadID); - this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; - this.building = building; - clearStatic(); - } - /** * Pet Constructor */ diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1e6d2f83..338d84c6 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -86,6 +86,7 @@ public class NPC extends AbstractCharacter { public NPC() { + super(); this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; } From 573cc531bfa91c7254419c5e6f3eb73811e48037 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 11:59:59 -0400 Subject: [PATCH 021/233] Refactor towards new constructor. --- src/engine/db/handlers/dbMobHandler.java | 2 +- src/engine/objects/AbstractCharacter.java | 25 ++++++++++++++---- src/engine/objects/Mob.java | 31 +++++++++++++++++------ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index f4c5b854..29a7f266 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -35,7 +35,7 @@ public class dbMobHandler extends dbHandlerBase { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { - preparedStatement.setLong(1, toAdd.getParentZoneID()); + preparedStatement.setLong(1, toAdd.getParentZoneUUID()); preparedStatement.setInt(2, toAdd.getMobBaseID()); preparedStatement.setInt(3, toAdd.getGuildUUID()); preparedStatement.setFloat(4, toAdd.getSpawnX()); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index e43da320..a897aa78 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -119,14 +119,31 @@ public abstract class AbstractCharacter extends AbstractWorldObject { private long takeOffTime = 0; private float hateValue = 0; private long lastHateUpdate = 0; - private boolean collided = false; private byte aoecntr = 0; public AbstractCharacter() { super(); + this.firstName = ""; + this.lastName = ""; - this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + this.statStrCurrent = (short) 0; + this.statDexCurrent = (short) 0; + this.statConCurrent = (short) 0; + this.statIntCurrent = (short) 0; + this.statSpiCurrent = (short) 0; + + this.unusedStatPoints = (short) 0; + + this.level = (short) 0; // TODO get this from MobsBase later + this.exp = 1; + this.walkMode = true; + this.bindLoc = Vector3fImmutable.ZERO; + this.faceDir = Vector3fImmutable.ZERO; + + this.runningTrains = (byte) 0; + + this.skills = new ConcurrentHashMap<>(); + this.powers = new ConcurrentHashMap<>(); this.initializeCharacter(); } @@ -291,8 +308,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.powers = new ConcurrentHashMap<>(); initializeCharacter(); - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } /** diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 45a518cd..02fec22b 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -81,7 +81,7 @@ public class Mob extends AbstractIntelligenceAgent { protected int loadID; protected float spawnRadius; //used by static mobs - protected int parentZoneID; + protected int parentZoneUUID; protected float statLat; protected float statLon; protected float statAlt; @@ -116,7 +116,7 @@ public class Mob extends AbstractIntelligenceAgent { this.mobBase = MobBase.getMobBase(loadID); this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; + this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.building = building; if (building != null) @@ -143,7 +143,7 @@ public class Mob extends AbstractIntelligenceAgent { this.loadID = mobBase.getObjectUUID(); this.mobBase = mobBase; this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; + this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); this.BehaviourType = Enum.MobBehaviourType.Pet; clearStatic(); @@ -156,7 +156,7 @@ public class Mob extends AbstractIntelligenceAgent { this.loadID = mobBase.getObjectUUID(); this.mobBase = mobBase; this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; + this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = 0; this.equip = new HashMap<>(); clearStatic(); @@ -181,7 +181,7 @@ public class Mob extends AbstractIntelligenceAgent { this.localLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.parentZoneID = rs.getInt("parent"); + this.parentZoneUUID = rs.getInt("parent"); this.level = (short) rs.getInt("mob_level"); this.buildingUUID = rs.getInt("mob_buildingID"); @@ -469,6 +469,21 @@ public class Mob extends AbstractIntelligenceAgent { public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID, String pirateName, int level) { + Mob mobile = new Mob(); + mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; + mobile.loadID = loadID; + + if (guild.isEmptyGuild()) + mobile.guildUUID = 0; + else + mobile.guildUUID = guild.getObjectUUID(); + + mobile.parentZoneUUID = parent.getObjectUUID(); + mobile.buildingUUID = building.getObjectUUID(); + mobile.firstName = pirateName; + mobile.bindLoc = spawn; + + Mob mobWithoutID = new Mob(pirateName, "", (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, loadID, isMob, parent, building, contractID); if (mobWithoutID.mobBase == null) @@ -480,7 +495,7 @@ public class Mob extends AbstractIntelligenceAgent { // refactor that out and just use the id. mobWithoutID.parentZone = parent; - mobWithoutID.parentZoneID = parent.getObjectUUID(); + mobWithoutID.parentZoneUUID = parent.getObjectUUID(); // NPC in a Building derives position from slot @@ -883,7 +898,7 @@ public class Mob extends AbstractIntelligenceAgent { return this.parentZone; } - public int getParentZoneID() { + public int getParentZoneUUID() { if (this.parentZone != null) return this.parentZone.getObjectUUID(); @@ -1837,7 +1852,7 @@ public class Mob extends AbstractIntelligenceAgent { // Configure parent zone adding this NPC to the // zone collection - this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneID); + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); this.parentZone.zoneMobSet.remove(this); this.parentZone.zoneMobSet.add(this); From 24639b62c08331c65f8825e4568a61a0ad7ae16e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:11:50 -0400 Subject: [PATCH 022/233] Refactor towards new constructor. --- src/engine/db/handlers/dbMobHandler.java | 24 ++++++++--------- src/engine/objects/AbstractCharacter.java | 4 +-- src/engine/objects/Mob.java | 32 ++++++++--------------- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 29a7f266..aac5b418 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -35,24 +35,24 @@ public class dbMobHandler extends dbHandlerBase { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { - preparedStatement.setLong(1, toAdd.getParentZoneUUID()); - preparedStatement.setInt(2, toAdd.getMobBaseID()); - preparedStatement.setInt(3, toAdd.getGuildUUID()); - preparedStatement.setFloat(4, toAdd.getSpawnX()); - preparedStatement.setFloat(5, toAdd.getSpawnY()); - preparedStatement.setFloat(6, toAdd.getSpawnZ()); + preparedStatement.setLong(1, toAdd.parentZoneUUID); + preparedStatement.setInt(2, toAdd.loadID); + preparedStatement.setInt(3, toAdd.guildUUID); + preparedStatement.setFloat(4, toAdd.bindLoc.x); + preparedStatement.setFloat(5, toAdd.bindLoc.y); + preparedStatement.setFloat(6, toAdd.bindLoc.z); preparedStatement.setInt(7, 0); - preparedStatement.setFloat(8, toAdd.getSpawnRadius()); - preparedStatement.setInt(9, toAdd.getTrueSpawnTime()); + preparedStatement.setFloat(8, toAdd.spawnRadius); + preparedStatement.setInt(9, toAdd.spawnTime); if (toAdd.getContract() != null) - preparedStatement.setInt(10, toAdd.getContract().getContractID()); + preparedStatement.setInt(10, toAdd.contractUUID); else preparedStatement.setInt(10, 0); - preparedStatement.setInt(11, toAdd.getBuildingID()); - preparedStatement.setInt(12, toAdd.getLevel()); - preparedStatement.setString(13, toAdd.getFirstName()); + preparedStatement.setInt(11, toAdd.buildingUUID); + preparedStatement.setInt(12, toAdd.level); + preparedStatement.setString(13, toAdd.firstName); ResultSet rs = preparedStatement.executeQuery(); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index a897aa78..960540b8 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public int contractUUID; public Contract contract; - protected String firstName; - protected String lastName; + public String firstName; + public String lastName; protected short statStrCurrent; protected short statDexCurrent; protected short statConCurrent; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 02fec22b..d78f7eaa 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -78,10 +78,10 @@ public class Mob extends AbstractIntelligenceAgent { public long stopPatrolTime = 0; public City guardedCity; protected int dbID; //the database ID - protected int loadID; - protected float spawnRadius; + public int loadID; + public float spawnRadius; //used by static mobs - protected int parentZoneUUID; + public int parentZoneUUID; protected float statLat; protected float statLon; protected float statAlt; @@ -472,6 +472,7 @@ public class Mob extends AbstractIntelligenceAgent { Mob mobile = new Mob(); mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; mobile.loadID = loadID; + mobile.level = (short) level; if (guild.isEmptyGuild()) mobile.guildUUID = 0; @@ -480,32 +481,21 @@ public class Mob extends AbstractIntelligenceAgent { mobile.parentZoneUUID = parent.getObjectUUID(); mobile.buildingUUID = building.getObjectUUID(); - mobile.firstName = pirateName; - mobile.bindLoc = spawn; - - - Mob mobWithoutID = new Mob(pirateName, "", (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, loadID, isMob, parent, building, contractID); - - if (mobWithoutID.mobBase == null) - return null; - - mobWithoutID.level = (short) level; - // Parent zone is required by dbhandler. Can likely - // refactor that out and just use the id. + if (mobile.buildingUUID != 0) + mobile.bindLoc = Vector3fImmutable.ZERO; + else + mobile.bindLoc = spawn; - mobWithoutID.parentZone = parent; - mobWithoutID.parentZoneUUID = parent.getObjectUUID(); + mobile.firstName = pirateName; - // NPC in a Building derives position from slot + mobile.contractUUID = contractID; - if (mobWithoutID.building != null) - mobWithoutID.bindLoc = Vector3fImmutable.ZERO; Mob mob; try { - mob = DbManager.MobQueries.ADD_MOB(mobWithoutID); + mob = DbManager.MobQueries.ADD_MOB(mobile); mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); } catch (Exception e) { From 99b952ee285013d81db6d3c96847395d44da0745 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:12:54 -0400 Subject: [PATCH 023/233] Refactor towards new constructor. --- 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 d78f7eaa..b3548705 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -474,7 +474,7 @@ public class Mob extends AbstractIntelligenceAgent { mobile.loadID = loadID; mobile.level = (short) level; - if (guild.isEmptyGuild()) + if (guild == null || guild.isEmptyGuild()) mobile.guildUUID = 0; else mobile.guildUUID = guild.getObjectUUID(); From f283e500181ca246a095e2e4f770220236a70430 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:18:36 -0400 Subject: [PATCH 024/233] Disabled minions for now. --- src/engine/server/world/WorldServer.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index eafae89b..b73a68f2 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -10,7 +10,6 @@ package engine.server.world; import engine.Enum; -import engine.Enum.BuildingGroup; import engine.Enum.DispatchChannel; import engine.Enum.MinionType; import engine.Enum.SupportMsgType; @@ -597,8 +596,8 @@ public class WorldServer { m.setLoc(m.getLoc()); //ADD GUARDS HERE. - if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) - DbManager.MobQueries.LOAD_PATROL_POINTS(m); + // if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) + // DbManager.MobQueries.LOAD_PATROL_POINTS(m); } //Handle npc's From 719c855bdbad83694333db6238dc10666d13b33c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:27:58 -0400 Subject: [PATCH 025/233] Cleanup of inventoryManager usage. --- src/engine/objects/AbstractCharacter.java | 7 ------- src/engine/objects/Mob.java | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 960540b8..8f4ffcf8 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -231,8 +231,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); this.initializeCharacter(); - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } /** @@ -275,8 +273,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.powers = new ConcurrentHashMap<>(); this.initializeCharacter(); - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } /** @@ -357,9 +353,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.powers = new ConcurrentHashMap<>(); this.initializeCharacter(); - - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } public static int getBankCapacity() { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b3548705..3d3c2134 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1827,8 +1827,6 @@ public class Mob extends AbstractIntelligenceAgent { this.defenseRating = (short) this.mobBase.getDefenseRating(); this.isActive = true; - this.charItemManager.load(); - // Load AI for wall archers if (this.contract != null && NPC.ISWallArcher(this.contract)) { @@ -1869,6 +1867,7 @@ public class Mob extends AbstractIntelligenceAgent { // Initialize inventory this.charItemManager = new CharacterItemManager(this); + this.charItemManager.load(); this.loadInventory(); try { From ab335aef2ade93b8edc8c7ec1931ab27469fc7ef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:32:36 -0400 Subject: [PATCH 026/233] Enums are fragile. --- src/engine/Enum.java | 2 +- src/engine/mobileAI/MobAI.java | 12 ++++++------ src/engine/objects/Mob.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 9734cc7b..b89f4178 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2846,7 +2846,7 @@ public class Enum { SpellAggroGrouperWimpy(Spell, true, false, true, false, false), //Independent Types SimpleStandingGuard(null, false, false, false, false, false), - Pet(null, false, false, true, false, false), + Pet1(null, false, false, true, false, false), Siege(null, false, false, true, false, false), Simple(null, false, false, true, false, false), Helpee(null, false, true, true, false, true), diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 68c3dbc8..e80bfbe3 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -625,7 +625,7 @@ public class MobAI { //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting - if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet) == false) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); return; @@ -646,7 +646,7 @@ public class MobAI { return; } - if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet) == false) + if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -683,7 +683,7 @@ public class MobAI { case GuardWallArcher: GuardWallArcherLogic(mob); break; - case Pet: + case Pet1: PetLogic(mob); break; case HamletGuard: @@ -784,7 +784,7 @@ public class MobAI { switch (mob.BehaviourType) { - case Pet: + case Pet1: if (mob.getOwner() == null) return; @@ -894,7 +894,7 @@ public class MobAI { return; if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && - mob.BehaviourType.equals(Enum.MobBehaviourType.Pet) == false) { + mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) { mob.setCombatTarget(null); return; @@ -1014,7 +1014,7 @@ public class MobAI { if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD))) continue; - if (aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet)) + if (aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)) continue; if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 3d3c2134..008ee7d8 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -145,7 +145,7 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone = parent; this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); - this.BehaviourType = Enum.MobBehaviourType.Pet; + this.BehaviourType = Enum.MobBehaviourType.Pet1; clearStatic(); } @@ -797,7 +797,7 @@ public class Mob extends AbstractIntelligenceAgent { owner.getSiegeMinionMap().put(mob, slot); mob.setNpcOwner(owner); - mob.BehaviourType = MobBehaviourType.Pet; + mob.BehaviourType = MobBehaviourType.Pet1; mob.BehaviourType.canRoam = false; return mob; } From ac3588c76a6ecca4a9e2c55ad2c4cee0965296db Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:54:03 -0400 Subject: [PATCH 027/233] manager init moved to the top of method. --- src/engine/objects/Mob.java | 3 ++- src/engine/objects/NPC.java | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 008ee7d8..b35cb247 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1751,6 +1751,8 @@ public class Mob extends AbstractIntelligenceAgent { @Override public void runAfterLoad() { + this.charItemManager = new CharacterItemManager(this); + if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; @@ -1866,7 +1868,6 @@ public class Mob extends AbstractIntelligenceAgent { // Initialize inventory - this.charItemManager = new CharacterItemManager(this); this.charItemManager.load(); this.loadInventory(); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 338d84c6..1ebc4c39 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -806,6 +806,8 @@ public class NPC extends AbstractCharacter { @Override public void runAfterLoad() { + this.charItemManager = new CharacterItemManager(this); + if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; @@ -847,10 +849,6 @@ public class NPC extends AbstractCharacter { if (wordCount(this.name) < 2 && this.contract != null) this.name += " the " + this.contract.getName(); - // Initialize inventory - - this.charItemManager = new CharacterItemManager(this); - // Configure parent zone adding this NPC to the // zone collection From 70278374e7c3f17358b06584a734ce9d36313337 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 12:57:21 -0400 Subject: [PATCH 028/233] manager init moved to the top of method. --- src/engine/objects/PlayerCharacter.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 48c75a0f..7d7baaa5 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -211,8 +211,11 @@ public class PlayerCharacter extends AbstractCharacter { * ResultSet Constructor */ public PlayerCharacter(ResultSet rs) throws SQLException { + super(rs, true); + this.charItemManager = new CharacterItemManager(this); + this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID()); int accountID = rs.getInt("parent"); this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID); @@ -4560,10 +4563,6 @@ public class PlayerCharacter extends AbstractCharacter { @Override public void runAfterLoad() { - // Init inventory - - this.charItemManager = new CharacterItemManager(this); - Bounds playerBounds = Bounds.borrow(); playerBounds.setBounds(this.getLoc()); this.setBounds(playerBounds); From dc0e14eb2142172d6d3915d2c7e588f114e48099 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 13:07:47 -0400 Subject: [PATCH 029/233] AI added earlier in sequence for availability. --- src/engine/objects/Mob.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b35cb247..99880a14 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1778,6 +1778,14 @@ public class Mob extends AbstractIntelligenceAgent { this.isPlayerGuard = true; } + // Load AI for wall archers + + if (this.contract != null && NPC.ISWallArcher(this.contract)) { + this.BehaviourType = MobBehaviourType.GuardWallArcher; + this.isPlayerGuard = true; + this.spawnTime = 450; + } + if (this.building != null) this.guild = this.building.getGuild(); else @@ -1829,14 +1837,6 @@ public class Mob extends AbstractIntelligenceAgent { this.defenseRating = (short) this.mobBase.getDefenseRating(); this.isActive = true; - // Load AI for wall archers - - if (this.contract != null && NPC.ISWallArcher(this.contract)) { - this.BehaviourType = MobBehaviourType.GuardWallArcher; - this.isPlayerGuard = true; - this.spawnTime = 450; - } - } // Configure parent zone adding this NPC to the From 52486fa278fd032f05a47b87f1962c46c731c36b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 13:24:07 -0400 Subject: [PATCH 030/233] Contract handling cleanup. --- src/engine/devcmd/cmds/AddMobCmd.java | 4 ++-- src/engine/devcmd/cmds/SplatMobCmd.java | 2 +- src/engine/gameManager/BuildingManager.java | 6 +++--- src/engine/objects/Mob.java | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/engine/devcmd/cmds/AddMobCmd.java b/src/engine/devcmd/cmds/AddMobCmd.java index ac2fbfa8..d3401151 100644 --- a/src/engine/devcmd/cmds/AddMobCmd.java +++ b/src/engine/devcmd/cmds/AddMobCmd.java @@ -43,7 +43,7 @@ public class AddMobCmd extends AbstractDevCmd { MobBase mb = (MobBase) mobbaseAGO; int loadID = mb.getObjectUUID(); Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100), - null, true, zone, null, 0, "", 1); + null, zone, null, null, "", 1); if (mob != null) { mob.updateDatabase(); this.setResult(String.valueOf(mob.getDBID())); @@ -84,7 +84,7 @@ public class AddMobCmd extends AbstractDevCmd { Mob mob = Mob.createMob(loadID, pc.getLoc(), - null, true, zone, null, 0, "", 1); + null, zone, null, null, "", 1); if (mob != null) { mob.updateDatabase(); ChatManager.chatSayInfo(pc, diff --git a/src/engine/devcmd/cmds/SplatMobCmd.java b/src/engine/devcmd/cmds/SplatMobCmd.java index cb429b99..44e8114e 100644 --- a/src/engine/devcmd/cmds/SplatMobCmd.java +++ b/src/engine/devcmd/cmds/SplatMobCmd.java @@ -110,7 +110,7 @@ public class SplatMobCmd extends AbstractDevCmd { mobile = Mob.createMob(_mobileUUID, Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange), - null, true, serverZone, null, 0, "", 1); + null, serverZone, null, null, "", 1); if (mobile != null) { mobile.updateDatabase(); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 5633df05..844942ad 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -535,7 +535,7 @@ public enum BuildingManager { if (NPC.ISWallArcher(contract)) { - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); if (mob == null) return false; @@ -547,7 +547,7 @@ public enum BuildingManager { if (NPC.ISGuardCaptain(contract.getContractID())) { - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); if (mob == null) return false; @@ -559,7 +559,7 @@ public enum BuildingManager { if (contract.getContractID() == 910) { //guard dog - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); if (mob == null) return false; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 99880a14..39519e99 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -467,7 +467,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(mob.currentID); } - public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID, String pirateName, int level) { + public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, Zone parent, Building building, Contract contract, String pirateName, int level) { Mob mobile = new Mob(); mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; @@ -489,8 +489,7 @@ public class Mob extends AbstractIntelligenceAgent { mobile.firstName = pirateName; - mobile.contractUUID = contractID; - + mobile.contractUUID = contract.getContractID(); Mob mob; From 89bfad78a6b66ad0462342a67d7c3a3a649a9a60 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 13:31:56 -0400 Subject: [PATCH 031/233] Contract handling cleanup. --- src/engine/objects/Mob.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 39519e99..8b00993b 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -489,7 +489,10 @@ public class Mob extends AbstractIntelligenceAgent { mobile.firstName = pirateName; - mobile.contractUUID = contract.getContractID(); + if (contract == null) + mobile.contractUUID = 0; + else + mobile.contractUUID = contract.getContractID(); Mob mob; From 0a2de9e0d58dce1e1344fd9f7ed0133410dddd7f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 13:41:22 -0400 Subject: [PATCH 032/233] Contract handling cleanup. --- src/engine/db/handlers/dbMobHandler.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index aac5b418..4986254e 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -44,12 +44,7 @@ public class dbMobHandler extends dbHandlerBase { preparedStatement.setInt(7, 0); preparedStatement.setFloat(8, toAdd.spawnRadius); preparedStatement.setInt(9, toAdd.spawnTime); - - if (toAdd.getContract() != null) - preparedStatement.setInt(10, toAdd.contractUUID); - else - preparedStatement.setInt(10, 0); - + preparedStatement.setInt(10, toAdd.contractUUID); preparedStatement.setInt(11, toAdd.buildingUUID); preparedStatement.setInt(12, toAdd.level); preparedStatement.setString(13, toAdd.firstName); From 14af2f6efdbd1d018a73fe3b8130a496f8d6bb2a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 14:01:47 -0400 Subject: [PATCH 033/233] Minion spawning re-enabled for refactoring. --- src/engine/db/handlers/dbMobHandler.java | 6 +++--- src/engine/server/world/WorldServer.java | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 4986254e..423748ca 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -101,17 +101,17 @@ public class dbMobHandler extends dbHandlerBase { return row_count; } - public void LOAD_PATROL_POINTS(Mob captain) { + public void LOAD_GUARD_MINIONS(Mob guardCaptain) { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) { - preparedStatement.setInt(1, captain.getObjectUUID()); + preparedStatement.setInt(1, guardCaptain.getObjectUUID()); ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { String name = rs.getString("name"); - Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name); + Mob toCreate = Mob.createGuardMob(guardCaptain, guardCaptain.getGuild(), guardCaptain.getParentZone(), guardCaptain.building.getLoc(), guardCaptain.getLevel(), name); if (toCreate == null) return; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index b73a68f2..62016ef7 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -595,9 +595,10 @@ public class WorldServer { m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks()); m.setLoc(m.getLoc()); - //ADD GUARDS HERE. - // if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) - // DbManager.MobQueries.LOAD_PATROL_POINTS(m); + // Load Minions for Guard Captains here. + + if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK) + DbManager.MobQueries.LOAD_GUARD_MINIONS(m); } //Handle npc's From 400dd6aa5ea7a94f17b509843a2cb210e7719c9e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 14:08:43 -0400 Subject: [PATCH 034/233] More granular error reporting. --- src/engine/server/world/WorldServer.java | 73 ++++++++++++------------ 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 62016ef7..dc2c6fb0 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -17,6 +17,7 @@ import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; +import engine.db.handlers.dbPowerHandler; import engine.exception.MsgSendException; import engine.gameManager.*; import engine.job.JobContainer; @@ -351,7 +352,7 @@ public class WorldServer { DbManager.MobBaseQueries.GET_ALL_MOBBASES(); Logger.info("Loading Mob Powers"); - PowersManager.AllMobPowers = DbManager.PowerQueries.LOAD_MOB_POWERS(); + PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS(); Logger.info("Loading item enchants"); DbManager.LootQueries.LOAD_ENCHANT_VALUES(); @@ -481,7 +482,7 @@ public class WorldServer { Logger.info("Initializing Client Connection Manager"); initClientConnectionManager(); - + //intiate mob respawn thread Logger.info("Starting Mob Respawn Thread"); MobRespawnThread.startRespawnThread(); @@ -550,44 +551,40 @@ public class WorldServer { } //Set sea floor object for server + Zone seaFloor = rootParent.get(0); seaFloor.setParent(null); ZoneManager.setSeaFloor(seaFloor); - // zoneManager.addZone(seaFloor.getLoadNum(), seaFloor); <- DIE IN A FUCKING CAR FIRE BONUS CODE LIKE THIS SUCKS FUCKING DICK - rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor)); long start = System.currentTimeMillis(); for (Zone zone : rootParent) { - try { - ZoneManager.addZone(zone.getLoadNum(), zone); + ZoneManager.addZone(zone.getLoadNum(), zone); + zone.generateWorldAltitude(); - try { - zone.generateWorldAltitude(); - } catch (Exception e) { - Logger.error(e.getMessage()); - e.printStackTrace(); - } - //Handle Buildings + //Handle Buildings + try { ArrayList bList; bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); for (Building b : bList) { - try { - b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); - b.setLoc(b.getLoc()); - } catch (Exception e) { - Logger.error(b.getObjectUUID() + " returned an Error Message :" + e.getMessage()); - } + b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); + b.setLoc(b.getLoc()); } + } catch (Exception e) { + Logger.error(e); + e.printStackTrace(); + } - //Handle Mobs + //Handle Mobs + + try { ArrayList mobs; mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone); @@ -600,11 +597,17 @@ public class WorldServer { if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK) DbManager.MobQueries.LOAD_GUARD_MINIONS(m); } + } catch (Exception e) { + Logger.error(e); + e.printStackTrace(); + } - //Handle npc's + //Handle NPCs + + try { ArrayList npcs; - // Ignore npc's on the seafloor (npc guild leaders, etc) + // Ignore NPCs on the seafloor (npc guild leaders, etc) if (zone.equals(seaFloor)) continue; @@ -612,26 +615,22 @@ public class WorldServer { npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone); for (NPC n : npcs) { - - try { - n.setObjectTypeMask(MBServerStatics.MASK_NPC); - n.setLoc(n.getLoc()); - } catch (Exception e) { - Logger.error(n.getObjectUUID() + " returned an Error Message :" + e.getMessage()); - } + n.setObjectTypeMask(MBServerStatics.MASK_NPC); + n.setLoc(n.getLoc()); } - //Handle cities - - ZoneManager.loadCities(zone); - ZoneManager.populateWorldZones(zone); - } catch (Exception e) { - Logger.info(e.getMessage() + zone.getName() + ' ' + zone.getObjectUUID()); + Logger.error(e); + e.printStackTrace(); } + //Handle cities + + ZoneManager.loadCities(zone); + ZoneManager.populateWorldZones(zone); + } - Logger.info("time to load: " + (System.currentTimeMillis() - start) + " ms"); + Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } /** @@ -704,7 +703,7 @@ public class WorldServer { return; } //remove player from loaded mobs agro maps - for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) { + for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) { Mob loadedMob = (Mob) awo; loadedMob.playerAgroMap.remove(player.getObjectUUID()); } From 9b6959414aaa0bb8c0948f15a231cacde6baf999 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 14:33:43 -0400 Subject: [PATCH 035/233] More flushing out minion support. --- src/engine/db/handlers/dbMobHandler.java | 4 +- src/engine/gameManager/NPCManager.java | 27 ++++ .../handlers/MinionTrainingMsgHandler.java | 8 +- src/engine/objects/Mob.java | 153 +++++------------- 4 files changed, 75 insertions(+), 117 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 423748ca..1af8a770 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -110,8 +110,8 @@ public class dbMobHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { - String name = rs.getString("name"); - Mob toCreate = Mob.createGuardMob(guardCaptain, guardCaptain.getGuild(), guardCaptain.getParentZone(), guardCaptain.building.getLoc(), guardCaptain.getLevel(), name); + String minionName = rs.getString("name"); + Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName); if (toCreate == null) return; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 9aa84dca..b3b8916b 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -379,4 +379,31 @@ public enum NPCManager { return buildingSlot; } + + public static int getMaxMinions(Mob guardCaptain) { + + int maxSlots; + + switch (guardCaptain.getRank()) { + case 3: + maxSlots = 2; + break; + case 4: + case 5: + maxSlots = 3; + break; + case 6: + maxSlots = 4; + break; + case 7: + maxSlots = 5; + break; + case 1: + case 2: + default: + maxSlots = 1; + + } + return maxSlots; + } } diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index a71a9300..8d489fc2 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -298,14 +298,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { String pirateName = NPCManager.getPirateName(mobBase); - if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) - return true; - - Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName); + Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName); if (toCreate == null) return true; + if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) + return true; + if (toCreate != null) { toCreate.setDeathTime(System.currentTimeMillis()); toCreate.parentZone.zoneMobSet.add(toCreate); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 8b00993b..1157e25e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -26,7 +26,6 @@ import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; -import engine.powers.EffectsBase; import engine.powers.MobPowerEntry; import engine.server.MBServerStatics; import org.joda.time.DateTime; @@ -638,132 +637,64 @@ public class Mob extends AbstractIntelligenceAgent { mob.upgradeDateTime = upgradeDateTime; } - public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) { + public static synchronized Mob createGuardMinion(Mob guardCaptain, short level, String minionName) { MobBase minionMobBase; - Mob mob; - int maxSlots; - - switch (guardCaptain.getRank()) { - case 3: - maxSlots = 2; - break; - case 4: - case 5: - maxSlots = 3; - break; - case 6: - maxSlots = 4; - break; - case 7: - maxSlots = 5; - break; - case 1: - case 2: - default: - maxSlots = 1; + Mob minionMobile; - } + int maxSlots = NPCManager.getMaxMinions(guardCaptain); if (guardCaptain.siegeMinionMap.size() == maxSlots) return null; - minionMobBase = guardCaptain.mobBase; - - if (minionMobBase == null) - return null; - - mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true); - mob.setLevel(level); - if (guardCaptain.equipmentSetID != 0) - mob.equipmentSetID = guardCaptain.equipmentSetID; - - mob.enemy = guardCaptain.enemy; - mob.notEnemy = guardCaptain.notEnemy; - - mob.runAfterLoad(); - mob.despawned = true; - mob.despawn(); + minionMobile = new Mob(); + minionMobile.level = level; + minionMobile.loadID = guardCaptain.loadID; + minionMobile.firstName = minionName; + minionMobile.equipmentSetID = guardCaptain.equipmentSetID; + + minionMobile.runeSet = guardCaptain.runeSet; + minionMobile.enemy = guardCaptain.enemy; + minionMobile.notEnemy = guardCaptain.notEnemy; + + minionMobile.deathTime = System.currentTimeMillis(); + minionMobile.npcOwner = guardCaptain; + minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; + minionMobile.BehaviourType = Enum.MobBehaviourType.GuardMinion; + minionMobile.guardedCity = guardCaptain.guardedCity; + minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; + MovementManager.translocate(minionMobile, guardCaptain.bindLoc, guardCaptain.region); + minionMobile.bindLoc = guardCaptain.bindLoc; + + minionMobile.runAfterLoad(); + minionMobile.despawned = true; + minionMobile.despawn(); //grab equipment and name from minionbase. - if (guardCaptain.contract != null) { - Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); - if (minionType != null) { - String rank; - - if (guardCaptain.getRank() < 3) - rank = MBServerStatics.JUNIOR; - else if (guardCaptain.getRank() < 6) - rank = ""; - else if (guardCaptain.getRank() == 6) - rank = MBServerStatics.VETERAN; - else - rank = MBServerStatics.ELITE; - - mob.firstName = NPCManager.getPirateName(mob.getMobBaseID()); - mob.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); - } - } - - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); - - mob.isPlayerGuard = true; - - DbManager.addToCache(mob); - - RuneBase guardRune = RuneBase.getRuneBase(252621); - - for (MobBaseEffects mbe : guardRune.getEffectsList()) { + Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); - EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken()); + if (minionType != null) { + String rank; - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) mob.level) { - continue; - } - - Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); - - if (eff == null) - continue; - - //Current effect is a higher rank, dont apply. - if (eff.getTrains() > mbe.getRank()) - continue; + if (guardCaptain.getRank() < 3) + rank = MBServerStatics.JUNIOR; + else if (guardCaptain.getRank() < 6) + rank = ""; + else if (guardCaptain.getRank() == 6) + rank = MBServerStatics.VETERAN; + else + rank = MBServerStatics.ELITE; - //new effect is of a higher rank. remove old effect and apply new one. - eff.cancelJob(); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { + minionMobile.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); + } - if (mbe.getReqLvl() > (int) mob.level) - continue; + DbManager.addToCache(minionMobile); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } + int slot = guardCaptain.siegeMinionMap.size() + 1; + guardCaptain.siegeMinionMap.put(minionMobile, slot); - int slot = 0; - slot += guardCaptain.siegeMinionMap.size() + 1; - - guardCaptain.siegeMinionMap.put(mob, slot); - mob.deathTime = System.currentTimeMillis(); - mob.npcOwner = guardCaptain; - mob.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; - mob.BehaviourType = Enum.MobBehaviourType.GuardMinion; - mob.guardedCity = guardCaptain.guardedCity; - mob.parentZone = parent; - parent.zoneMobSet.add(mob); - MovementManager.translocate(mob, guardCaptain.bindLoc, guardCaptain.region); - mob.bindLoc = guardCaptain.bindLoc; - return mob; + return minionMobile; } public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) { From b9d6f35aac2fb7652184808aeaecef1b56a0f508 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 14:35:02 -0400 Subject: [PATCH 036/233] Unused 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 1157e25e..5c4e0575 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -639,7 +639,6 @@ public class Mob extends AbstractIntelligenceAgent { public static synchronized Mob createGuardMinion(Mob guardCaptain, short level, String minionName) { - MobBase minionMobBase; Mob minionMobile; int maxSlots = NPCManager.getMaxMinions(guardCaptain); From 3bca76d4c865bd4cde4224a75107c9e5ddebdf1b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 14:38:09 -0400 Subject: [PATCH 037/233] Setloc to spawn minion. --- 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 5c4e0575..5d558974 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -662,11 +662,11 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.BehaviourType = Enum.MobBehaviourType.GuardMinion; minionMobile.guardedCity = guardCaptain.guardedCity; minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; - MovementManager.translocate(minionMobile, guardCaptain.bindLoc, guardCaptain.region); minionMobile.bindLoc = guardCaptain.bindLoc; minionMobile.runAfterLoad(); minionMobile.despawned = true; + minionMobile.setLoc(minionMobile.bindLoc); minionMobile.despawn(); //grab equipment and name from minionbase. From 3aec6ee57840a31202a372236daf70c38434f3ba Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 14:45:47 -0400 Subject: [PATCH 038/233] More minion setup work. --- src/engine/objects/Mob.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 5d558974..8b641a68 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -664,12 +664,7 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; minionMobile.bindLoc = guardCaptain.bindLoc; - minionMobile.runAfterLoad(); - minionMobile.despawned = true; - minionMobile.setLoc(minionMobile.bindLoc); - minionMobile.despawn(); - - //grab equipment and name from minionbase. + //grab name from minionbase. Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); @@ -686,8 +681,16 @@ public class Mob extends AbstractIntelligenceAgent { rank = MBServerStatics.ELITE; minionMobile.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); + } + // Configure and spawn minion + + minionMobile.runAfterLoad(); + minionMobile.despawned = true; + minionMobile.setLoc(minionMobile.bindLoc); + minionMobile.despawn(); + DbManager.addToCache(minionMobile); int slot = guardCaptain.siegeMinionMap.size() + 1; From 93476f782cd6ca24f76afc55cafb9d464ed82d48 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:03:37 -0400 Subject: [PATCH 039/233] Bind loc not overwritten. --- src/engine/objects/Mob.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 8b641a68..6f4833b5 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1151,8 +1151,6 @@ public class Mob extends AbstractIntelligenceAgent { else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); - //MovementManager.translocate(this, this.bindLoc, this.region); - if (!this.isSiege && !this.isPlayerGuard && contract == null) loadInventory(); @@ -1783,7 +1781,6 @@ public class Mob extends AbstractIntelligenceAgent { // Setup location for this Mobile - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); this.loc = new Vector3fImmutable(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc); From 3c9c4495bc8db06b1bf7a77d2984dd7e426ffbcd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:14:33 -0400 Subject: [PATCH 040/233] playerGuard = true. --- src/engine/devcmd/cmds/aiInfoCmd.java | 24 ++++++------- src/engine/mobileAI/MobAI.java | 52 +++++++++++++-------------- src/engine/objects/Mob.java | 34 ++++++++++-------- 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index e31060bb..85bf7bfd 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -56,20 +56,20 @@ public class aiInfoCmd extends AbstractDevCmd { Mob mob = (Mob) target; output = "Mob AI Information:" + newline; output += mob.getName() + newline; - if (mob.BehaviourType != null) { - output += "BehaviourType: " + mob.BehaviourType.toString() + newline; - if (mob.BehaviourType.BehaviourHelperType != null) { - output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline; + if (mob.behaviourType != null) { + output += "BehaviourType: " + mob.behaviourType.toString() + newline; + if (mob.behaviourType.BehaviourHelperType != null) { + output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline; } else { output += "Behaviour Helper Type: NULL" + newline; - } - output += "Wimpy: " + mob.BehaviourType.isWimpy + newline; - output += "Agressive: " + mob.BehaviourType.isAgressive + newline; - output += "Can Roam: " + mob.BehaviourType.canRoam + newline; - output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline; - output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline; - } else { - output += "BehaviourType: NULL" + newline; + } + output += "Wimpy: " + mob.behaviourType.isWimpy + newline; + output += "Agressive: " + mob.behaviourType.isAgressive + newline; + output += "Can Roam: " + mob.behaviourType.canRoam + newline; + output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline; + output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline; + } else { + output += "BehaviourType: NULL" + newline; } output += "Aggro Range: " + mob.getAggroRange() + newline; output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline; diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index e80bfbe3..2f5d2fbd 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -96,7 +96,7 @@ public class MobAI { return; } - if (mob.BehaviourType.callsForHelp) + if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); if (!MovementUtilities.inRangeDropAggro(mob, target)) { @@ -165,7 +165,7 @@ public class MobAI { if (playercity != null) for (Mob guard : playercity.getParent().zoneMobSet) - if (guard.BehaviourType != null && guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) + if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild())) guard.setCombatTarget(mob); @@ -260,7 +260,7 @@ public class MobAI { //guard captains inherit barracks patrol points dynamically - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { Building barracks = mob.building; @@ -280,7 +280,7 @@ public class MobAI { MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) for (Entry minion : mob.siegeMinionMap.entrySet()) //make sure mob is out of combat stance @@ -312,9 +312,9 @@ public class MobAI { int contractID; - if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) contractID = mob.npcOwner.contract.getContractID(); - else + else contractID = mob.contract.getContractID(); if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false) @@ -350,7 +350,7 @@ public class MobAI { ArrayList purgeTokens; AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); - if (mob.BehaviourType.callsForHelp) + if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); // Generate a list of tokens from the mob powers for this mobile. @@ -433,7 +433,7 @@ public class MobAI { ArrayList purgeTokens; AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); - if (mob.BehaviourType.callsForHelp) + if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); // Generate a list of tokens from the mob powers for this mobile. @@ -564,7 +564,7 @@ public class MobAI { Zone mobCamp = mob.getParentZone(); for (Mob helper : mobCamp.zoneMobSet) { - if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) { + if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) { helper.setCombatTarget(mob.getCombatTarget()); callGotResponse = true; } @@ -608,7 +608,7 @@ public class MobAI { if (mob.despawned && mob.isPlayerGuard) { - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { //minions don't respawn while guard captain is dead @@ -625,7 +625,7 @@ public class MobAI { //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting - if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) + if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); return; @@ -646,7 +646,7 @@ public class MobAI { return; } - if (mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) + if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -673,7 +673,7 @@ public class MobAI { } } - switch (mob.BehaviourType) { + switch (mob.behaviourType) { case GuardCaptain: GuardCaptainLogic(mob); break; @@ -782,7 +782,7 @@ public class MobAI { mob.updateLocation(); - switch (mob.BehaviourType) { + switch (mob.behaviourType) { case Pet1: if (mob.getOwner() == null) @@ -894,7 +894,7 @@ public class MobAI { return; if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && - mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1) == false) { + mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) { mob.setCombatTarget(null); return; @@ -910,10 +910,10 @@ public class MobAI { private static void CheckToSendMobHome(Mob mob) { try { - if (mob.BehaviourType.isAgressive) { + if (mob.behaviourType.isAgressive) { if (mob.isPlayerGuard()) { - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) CheckForPlayerGuardAggro(mob); } else { CheckForAggro(mob); @@ -933,7 +933,7 @@ public class MobAI { PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) { //guard captain pulls his minions home with him @@ -1014,7 +1014,7 @@ public class MobAI { if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD))) continue; - if (aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)) + if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1)) continue; if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) @@ -1107,7 +1107,7 @@ public class MobAI { if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) mob.killCharacter("no owner"); - if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) + if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) CheckMobMovement(mob); CheckForAttack(mob); @@ -1157,7 +1157,7 @@ public class MobAI { if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) mob.setCombatTarget(null); - if (mob.BehaviourType.isAgressive) { + if (mob.behaviourType.isAgressive) { AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); @@ -1165,7 +1165,7 @@ public class MobAI { mob.setCombatTarget(newTarget); else { if (mob.getCombatTarget() == null) { - if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) + if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) SafeGuardAggro(mob); //safehold guard else CheckForAggro(mob); //normal aggro @@ -1175,12 +1175,12 @@ public class MobAI { //check if mob can move for patrol or moving to target - if (mob.BehaviourType.canRoam) + if (mob.behaviourType.canRoam) CheckMobMovement(mob); //check if mob can attack if it isn't wimpy - if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null) + if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null) CheckForAttack(mob); } catch (Exception e) { @@ -1245,7 +1245,7 @@ public class MobAI { if (mob.getGuild().getNation().equals(target.getGuild().getNation())) return false; - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { return true; } @@ -1330,7 +1330,7 @@ public class MobAI { MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { for (Entry minion : mob.siegeMinionMap.entrySet()) { //make sure mob is out of combat stance diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6f4833b5..26ca63ff 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -71,7 +71,7 @@ public class Mob extends AbstractIntelligenceAgent { public int bootySet = 0; public EnumBitSet notEnemy; public EnumBitSet enemy; - public MobBehaviourType BehaviourType; + public MobBehaviourType behaviourType; public ArrayList patrolPoints; public int lastPatrolPointIndex = 0; public long stopPatrolTime = 0; @@ -144,7 +144,7 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone = parent; this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); - this.BehaviourType = Enum.MobBehaviourType.Pet1; + this.behaviourType = Enum.MobBehaviourType.Pet1; clearStatic(); } @@ -217,7 +217,7 @@ public class Mob extends AbstractIntelligenceAgent { this.firstName = rs.getString("mob_name"); if (rs.getString("fsm").length() > 1) - this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); + this.behaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); if (this.isPet() || this.isSiege || (this.isPlayerGuard && this.contract == null)) this.currentID = (--Mob.staticID); @@ -659,8 +659,10 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.deathTime = System.currentTimeMillis(); minionMobile.npcOwner = guardCaptain; minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; - minionMobile.BehaviourType = Enum.MobBehaviourType.GuardMinion; + minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion; + minionMobile.isPlayerGuard = true; minionMobile.guardedCity = guardCaptain.guardedCity; + minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; minionMobile.bindLoc = guardCaptain.bindLoc; @@ -732,8 +734,8 @@ public class Mob extends AbstractIntelligenceAgent { owner.getSiegeMinionMap().put(mob, slot); mob.setNpcOwner(owner); - mob.BehaviourType = MobBehaviourType.Pet1; - mob.BehaviourType.canRoam = false; + mob.behaviourType = MobBehaviourType.Pet1; + mob.behaviourType.canRoam = false; return mob; } @@ -1056,7 +1058,7 @@ public class Mob extends AbstractIntelligenceAgent { this.hasLoot = false; this.playerAgroMap.clear(); - if (this.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) + if (this.behaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) this.spawnTime = (int) (-2.500 * ((Mob) this.npcOwner).building.getRank() + 22.5) * 60; if (this.isPet()) { @@ -1146,7 +1148,7 @@ public class Mob extends AbstractIntelligenceAgent { this.recalculateStats(); this.setHealth(this.healthMax); - if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).BehaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) + if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) this.building = ((Mob) this.npcOwner).building; else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); @@ -1706,7 +1708,9 @@ public class Mob extends AbstractIntelligenceAgent { else this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); - if (this.contract != null && NPC.ISGuardCaptain(contract.getContractID())) { + // Guard captaiin AI + + if (NPC.ISGuardCaptain(contract.getContractID())) { this.spawnTime = 60 * 15; this.isPlayerGuard = true; } @@ -1714,7 +1718,7 @@ public class Mob extends AbstractIntelligenceAgent { // Load AI for wall archers if (this.contract != null && NPC.ISWallArcher(this.contract)) { - this.BehaviourType = MobBehaviourType.GuardWallArcher; + this.behaviourType = MobBehaviourType.GuardWallArcher; this.isPlayerGuard = true; this.spawnTime = 450; } @@ -1854,7 +1858,7 @@ public class Mob extends AbstractIntelligenceAgent { if (this.contract != null && this.contract.getContractID() == 910) { this.isPlayerGuard = true; - this.BehaviourType = MobBehaviourType.GuardCaptain; + this.behaviourType = MobBehaviourType.GuardCaptain; this.spawnTime = 900; this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); } @@ -1880,15 +1884,15 @@ public class Mob extends AbstractIntelligenceAgent { } } - if (this.BehaviourType == null) - this.BehaviourType = this.getMobBase().fsm; + if (this.behaviourType == null) + this.behaviourType = this.getMobBase().fsm; if (this.isPlayerGuard() && this.contract != null) if (NPC.ISWallArcher(this.getContract())) { - this.BehaviourType = MobBehaviourType.GuardWallArcher; + this.behaviourType = MobBehaviourType.GuardWallArcher; this.spawnTime = 450; } else { - this.BehaviourType = MobBehaviourType.GuardCaptain; + this.behaviourType = MobBehaviourType.GuardCaptain; this.spawnTime = 900; this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); } From 338110973dc46747d711fe53a69975b561922a52 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:19:25 -0400 Subject: [PATCH 041/233] Mobbase cannot be null. --- src/engine/objects/Mob.java | 53 +++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 26ca63ff..b128707c 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -76,19 +76,18 @@ public class Mob extends AbstractIntelligenceAgent { public int lastPatrolPointIndex = 0; public long stopPatrolTime = 0; public City guardedCity; - protected int dbID; //the database ID public int loadID; public float spawnRadius; //used by static mobs public int parentZoneUUID; + public boolean isSiege = false; + protected int dbID; //the database ID protected float statLat; protected float statLon; protected float statAlt; private int currentID; private int ownerUID = 0; //only used by pets private AbstractWorldObject fearedObject = null; - - public boolean isSiege = false; private long lastAttackTime = 0; private int lastMobPowerToken = 0; private HashMap equip = null; @@ -1059,7 +1058,7 @@ public class Mob extends AbstractIntelligenceAgent { this.playerAgroMap.clear(); if (this.behaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) - this.spawnTime = (int) (-2.500 * ((Mob) this.npcOwner).building.getRank() + 22.5) * 60; + this.spawnTime = (int) (-2.500 * this.npcOwner.building.getRank() + 22.5) * 60; if (this.isPet()) { @@ -1149,7 +1148,7 @@ public class Mob extends AbstractIntelligenceAgent { this.setHealth(this.healthMax); if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) - this.building = ((Mob) this.npcOwner).building; + this.building = this.npcOwner.building; else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); @@ -1748,33 +1747,31 @@ public class Mob extends AbstractIntelligenceAgent { if (!this.isPet() && !isSiege) Mob.mobMapByDBID.put(this.dbID, this); - if (this.mobBase != null) { - this.gridObjectType = GridObjectType.DYNAMIC; - this.healthMax = this.mobBase.getHealthMax(); - this.manaMax = 0; - this.staminaMax = 0; - this.setHealth(this.healthMax); - this.mana.set(this.manaMax); - this.stamina.set(this.staminaMax); + this.gridObjectType = GridObjectType.DYNAMIC; + this.healthMax = this.mobBase.getHealthMax(); + this.manaMax = 0; + this.staminaMax = 0; + this.setHealth(this.healthMax); + this.mana.set(this.manaMax); + this.stamina.set(this.staminaMax); - if (this.contract == null) - this.level = (short) this.mobBase.getLevel(); + if (this.contract == null) + this.level = (short) this.mobBase.getLevel(); - //set bonuses - this.bonuses = new PlayerBonuses(this); + //set bonuses - //TODO set these correctly later - this.rangeHandOne = 8; - this.rangeHandTwo = -1; - this.minDamageHandOne = 0; - this.maxDamageHandOne = 0; - this.minDamageHandTwo = 1; - this.maxDamageHandTwo = 4; - this.atrHandOne = 300; - this.defenseRating = (short) this.mobBase.getDefenseRating(); - this.isActive = true; + this.bonuses = new PlayerBonuses(this); - } + //TODO set these correctly later + this.rangeHandOne = 8; + this.rangeHandTwo = -1; + this.minDamageHandOne = 0; + this.maxDamageHandOne = 0; + this.minDamageHandTwo = 1; + this.maxDamageHandTwo = 4; + this.atrHandOne = 300; + this.defenseRating = (short) this.mobBase.getDefenseRating(); + this.isActive = true; // Configure parent zone adding this NPC to the // zone collection From 2f8de2a91975afe9c8ce3609f2cb6c3ac0538efb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:23:02 -0400 Subject: [PATCH 042/233] Worthless collection only used in 2 places. --- .../client/handlers/OrderNPCMsgHandler.java | 2 +- src/engine/net/client/msg/ManageNPCMsg.java | 2 +- src/engine/objects/Mob.java | 33 +++++-------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index d0a9793a..a56ecaa1 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -541,7 +541,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { } else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) { - mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID()); + mob = Mob.getMob(orderNPCMsg.getNpcUUID()); if (mob == null) return true; diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 8772b7c0..8fcda7f7 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg { } else if (this.targetType == GameObjectType.Mob.ordinal()) { - mobA = Mob.getFromCacheDBID(this.targetID); + mobA = Mob.getMob(this.targetID); if (mobA == null) { Logger.error("Missing Mob of ID " + this.targetID); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b128707c..0d6e5ac0 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -45,8 +45,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; public class Mob extends AbstractIntelligenceAgent { private static final ReentrantReadWriteLock createLock = new ReentrantReadWriteLock(); - private static final ConcurrentHashMap mobMapByDBID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - // Variables NOT to be stored in db private static int staticID = 0; //mob specific public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); @@ -555,12 +553,6 @@ public class Mob extends AbstractIntelligenceAgent { return (Mob) DbManager.getFromCache(GameObjectType.Mob, id); } - public static Mob getFromCacheDBID(int id) { - if (Mob.mobMapByDBID.containsKey(id)) - return Mob.mobMapByDBID.get(id); - return null; - } - private static float getModifiedAmount(CharacterSkill skill) { if (skill == null) @@ -1690,11 +1682,6 @@ public class Mob extends AbstractIntelligenceAgent { if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; - // Add new object to collection - - if (!this.isPet() && !isSiege) - Mob.mobMapByDBID.put(this.dbID, this); - try { this.building = BuildingManager.getBuilding(this.buildingUUID); } catch (Exception e) { @@ -1722,6 +1709,15 @@ public class Mob extends AbstractIntelligenceAgent { this.spawnTime = 450; } + // Load AI for guard dogs + + if (this.contract != null && this.contract.getContractID() == 910) { + this.isPlayerGuard = true; + this.behaviourType = MobBehaviourType.GuardCaptain; + this.spawnTime = 900; + this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); + } + if (this.building != null) this.guild = this.building.getGuild(); else @@ -1742,11 +1738,6 @@ public class Mob extends AbstractIntelligenceAgent { this.lastName = this.getContract().getName(); } - //store mobs by Database ID - - if (!this.isPet() && !isSiege) - Mob.mobMapByDBID.put(this.dbID, this); - this.gridObjectType = GridObjectType.DYNAMIC; this.healthMax = this.mobBase.getHealthMax(); this.manaMax = 0; @@ -1853,12 +1844,6 @@ public class Mob extends AbstractIntelligenceAgent { mobBounds.setBounds(this.getLoc()); this.setBounds(mobBounds); - if (this.contract != null && this.contract.getContractID() == 910) { - this.isPlayerGuard = true; - this.behaviourType = MobBehaviourType.GuardCaptain; - this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); - } //assign 5 random patrol points for regular mobs if (!(this.agentType.equals(AIAgentType.GUARD)) && !this.isPlayerGuard() && !this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !(this.agentType.equals(AIAgentType.CHARMED))) { From c179e4aaf34252a108570bd315e54c8d332293fd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:29:42 -0400 Subject: [PATCH 043/233] Don't override level or name for minions. --- src/engine/objects/Mob.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 0d6e5ac0..e6ac03f6 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1734,8 +1734,11 @@ public class Mob extends AbstractIntelligenceAgent { this.firstName = this.mobBase.getFirstName(); if (this.contract != null) { + this.equipmentSetID = this.contract.getEquipmentSet(); - this.lastName = this.getContract().getName(); + + if (this.lastName.isEmpty()) + this.lastName = this.getContract().getName(); } this.gridObjectType = GridObjectType.DYNAMIC; @@ -1746,8 +1749,11 @@ public class Mob extends AbstractIntelligenceAgent { this.mana.set(this.manaMax); this.stamina.set(this.staminaMax); + // Don't override level for guard minions + if (this.contract == null) - this.level = (short) this.mobBase.getLevel(); + if (!this.behaviourType.equals(MobBehaviourType.GuardMinion)) + this.level = (short) this.mobBase.getLevel(); //set bonuses From bd2446ba0aeecc0917e8a0793ee883d3a310a2bc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:34:47 -0400 Subject: [PATCH 044/233] Minion uuid set pre configure --- src/engine/objects/Mob.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e6ac03f6..a4f2c9ca 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -216,10 +216,7 @@ public class Mob extends AbstractIntelligenceAgent { if (rs.getString("fsm").length() > 1) this.behaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); - if (this.isPet() || this.isSiege || (this.isPlayerGuard && this.contract == null)) - this.currentID = (--Mob.staticID); - else - this.currentID = this.dbID; + this.currentID = this.dbID; } catch (Exception e) { Logger.error(e + " " + this.dbID); @@ -638,6 +635,8 @@ public class Mob extends AbstractIntelligenceAgent { return null; minionMobile = new Mob(); + minionMobile.currentID = (--Mob.staticID); + minionMobile.level = level; minionMobile.loadID = guardCaptain.loadID; minionMobile.firstName = minionName; @@ -655,7 +654,7 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.guardedCity = guardCaptain.guardedCity; minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; - minionMobile.bindLoc = guardCaptain.bindLoc; + minionMobile.bindLoc = guardCaptain.building.getLoc(); //grab name from minionbase. @@ -680,9 +679,9 @@ public class Mob extends AbstractIntelligenceAgent { // Configure and spawn minion minionMobile.runAfterLoad(); - minionMobile.despawned = true; + minionMobile.despawned = false; minionMobile.setLoc(minionMobile.bindLoc); - minionMobile.despawn(); + // minionMobile.despawn(); DbManager.addToCache(minionMobile); From c8e20c905bb904ebb58c7caee817d829f8955708 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:37:02 -0400 Subject: [PATCH 045/233] Add to cache before setloc --- src/engine/objects/Mob.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index a4f2c9ca..155db128 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -680,11 +680,11 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.runAfterLoad(); minionMobile.despawned = false; + DbManager.addToCache(minionMobile); + minionMobile.setLoc(minionMobile.bindLoc); // minionMobile.despawn(); - DbManager.addToCache(minionMobile); - int slot = guardCaptain.siegeMinionMap.size() + 1; guardCaptain.siegeMinionMap.put(minionMobile, slot); From 098433b697ca3aba34e47d088cb8df8b48db831a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 15:46:09 -0400 Subject: [PATCH 046/233] Needs contract null check --- src/engine/objects/Mob.java | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 155db128..893d6aea 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1693,28 +1693,31 @@ public class Mob extends AbstractIntelligenceAgent { else this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); - // Guard captaiin AI + // Guard captain AI - if (NPC.ISGuardCaptain(contract.getContractID())) { - this.spawnTime = 60 * 15; - this.isPlayerGuard = true; - } + if (this.contract != null) { - // Load AI for wall archers + if (NPC.ISGuardCaptain(contract.getContractID())) { + this.spawnTime = 60 * 15; + this.isPlayerGuard = true; + } - if (this.contract != null && NPC.ISWallArcher(this.contract)) { - this.behaviourType = MobBehaviourType.GuardWallArcher; - this.isPlayerGuard = true; - this.spawnTime = 450; - } + // Load AI for wall archers - // Load AI for guard dogs + if (NPC.ISWallArcher(this.contract)) { + this.behaviourType = MobBehaviourType.GuardWallArcher; + this.isPlayerGuard = true; + this.spawnTime = 450; + } + + // Load AI for guard dogs - if (this.contract != null && this.contract.getContractID() == 910) { - this.isPlayerGuard = true; - this.behaviourType = MobBehaviourType.GuardCaptain; - this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); + if (this.contract.getContractID() == 910) { + this.isPlayerGuard = true; + this.behaviourType = MobBehaviourType.GuardCaptain; + this.spawnTime = 900; + this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); + } } if (this.building != null) From c38f4e6543c296c280c65fd4fa7895a160d32d6c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 16:01:18 -0400 Subject: [PATCH 047/233] Mask only needs be set once. --- 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 893d6aea..f6be6f7a 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -491,7 +491,6 @@ public class Mob extends AbstractIntelligenceAgent { try { mob = DbManager.MobQueries.ADD_MOB(mobile); - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); } catch (Exception e) { Logger.error("SQLException:" + e.getMessage()); From c39ed6120f2c9f7d7181b75f0281db6d8caea90d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 16:19:04 -0400 Subject: [PATCH 048/233] Cleanup of bind/loc logic. --- src/engine/Enum.java | 1 - src/engine/objects/Mob.java | 69 ++++++++++++++----------------------- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index b89f4178..ae5818c8 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2822,7 +2822,6 @@ public class Enum { public enum MobBehaviourType { None(null, false, false, false, false, false), - //Power Power(null, false, true, true, true, false), PowerHelpee(Power, false, true, true, false, true), PowerHelpeeWimpy(Power, true, false, true, false, false), diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index f6be6f7a..cf875be4 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -682,7 +682,7 @@ public class Mob extends AbstractIntelligenceAgent { DbManager.addToCache(minionMobile); minionMobile.setLoc(minionMobile.bindLoc); - // minionMobile.despawn(); + minionMobile.despawn(); int slot = guardCaptain.siegeMinionMap.size() + 1; guardCaptain.siegeMinionMap.put(minionMobile, slot); @@ -1680,12 +1680,9 @@ public class Mob extends AbstractIntelligenceAgent { if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; - try { - this.building = BuildingManager.getBuilding(this.buildingUUID); - } catch (Exception e) { - this.building = null; - Logger.error(e.getMessage()); - } + this.gridObjectType = GridObjectType.DYNAMIC; + this.mobBase = MobBase.getMobBase(loadID); + this.building = BuildingManager.getBuilding(this.buildingUUID); if (this.contractUUID == 0) this.contract = null; @@ -1719,6 +1716,11 @@ public class Mob extends AbstractIntelligenceAgent { } } + // Default to the mobbase for AI if nothing is hte mob field to override. + + if (this.behaviourType == null || this.behaviourType.equals(MobBehaviourType.None)) + this.behaviourType = this.getMobBase().fsm; + if (this.building != null) this.guild = this.building.getGuild(); else @@ -1727,8 +1729,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.guild == null) this.guild = Guild.getErrantGuild(); - this.mobBase = MobBase.getMobBase(loadID); - this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); if (this.firstName.isEmpty()) @@ -1742,7 +1742,6 @@ public class Mob extends AbstractIntelligenceAgent { this.lastName = this.getContract().getName(); } - this.gridObjectType = GridObjectType.DYNAMIC; this.healthMax = this.mobBase.getHealthMax(); this.manaMax = 0; this.staminaMax = 0; @@ -1778,39 +1777,36 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone.zoneMobSet.remove(this); this.parentZone.zoneMobSet.add(this); - // Setup location for this Mobile - - this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); - // Handle Mobiles within buildings - if (this.building != null) { + if (this.building == null) + this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); + else { // Mobiles inside buildings are offset from it not the zone - - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.bindLoc = this.building.getLoc().add(this.bindLoc); + // with the exceptions being mobiles + // with a contract. if (this.contract != null || this.isSiege) NPCManager.slotCharacterInBuilding(this); + else + this.bindLoc = building.getLoc(); } + // Setup location for this Mobile + + this.loc = new Vector3fImmutable(bindLoc); + this.endLoc = new Vector3fImmutable(bindLoc); + // Initialize inventory this.charItemManager.load(); this.loadInventory(); - try { - if (this.equipmentSetID != 0) - this.equip = MobBase.loadEquipmentSet(this.equipmentSetID); - else - this.equip = new HashMap<>(); - - } catch (Exception e) { - Logger.error(e.getMessage()); - } + if (this.equipmentSetID != 0) + this.equip = MobBase.loadEquipmentSet(this.equipmentSetID); + else + this.equip = new HashMap<>(); // Powers from mobbase @@ -1832,7 +1828,7 @@ public class Mob extends AbstractIntelligenceAgent { // Combine mobbase and mob aggro arrays into one bitvector //skip for pets - if (this.isPet() == false && (this.agentType.equals(AIAgentType.PET)) == false && this.isNecroPet() == false) { + if (this.isPet() == false && this.isNecroPet() == false) { if (this.getMobBase().notEnemy.size() > 0) this.notEnemy.addAll(this.getMobBase().notEnemy); @@ -1873,19 +1869,6 @@ public class Mob extends AbstractIntelligenceAgent { } } - if (this.behaviourType == null) - this.behaviourType = this.getMobBase().fsm; - - if (this.isPlayerGuard() && this.contract != null) - if (NPC.ISWallArcher(this.getContract())) { - this.behaviourType = MobBehaviourType.GuardWallArcher; - this.spawnTime = 450; - } else { - this.behaviourType = MobBehaviourType.GuardCaptain; - this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); - } - this.deathTime = 0; } catch (Exception e) { Logger.error(e.getMessage()); From e67eff822d6718f792f236bb9ce1f8bf2a7b85c5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 16:44:45 -0400 Subject: [PATCH 049/233] Propagate guardedCity. --- src/engine/devcmd/cmds/aiInfoCmd.java | 3 +++ src/engine/objects/Mob.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index 85bf7bfd..695b24dc 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -84,6 +84,9 @@ public class aiInfoCmd extends AbstractDevCmd { else output += "Current Target: NULL" + newline; + if (mob.guardedCity != null) + output += mob.guardedCity.getCityName() + newline; + for (int token : mob.mobPowers.keySet()) output += token + newline; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index cf875be4..f2c80087 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1696,6 +1696,7 @@ public class Mob extends AbstractIntelligenceAgent { if (NPC.ISGuardCaptain(contract.getContractID())) { this.spawnTime = 60 * 15; this.isPlayerGuard = true; + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); } // Load AI for wall archers @@ -1704,6 +1705,7 @@ public class Mob extends AbstractIntelligenceAgent { this.behaviourType = MobBehaviourType.GuardWallArcher; this.isPlayerGuard = true; this.spawnTime = 450; + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); } // Load AI for guard dogs @@ -1712,7 +1714,7 @@ public class Mob extends AbstractIntelligenceAgent { this.isPlayerGuard = true; this.behaviourType = MobBehaviourType.GuardCaptain; this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); } } From 772a996b6e46c0dca353ecb868e2151799ea2128 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 16:49:26 -0400 Subject: [PATCH 050/233] Tweak to behavior type setup. --- src/engine/objects/Mob.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index f2c80087..78609658 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1689,11 +1689,14 @@ public class Mob extends AbstractIntelligenceAgent { else this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); - // Guard captain AI + // Setup mobile AI if (this.contract != null) { - if (NPC.ISGuardCaptain(contract.getContractID())) { + // Load AI for guard captains + + if (NPC.ISGuardCaptain(contract.getContractID()) || this.contract.getContractID() == 910) { // Guard Dog + this.behaviourType = MobBehaviourType.GuardCaptain; this.spawnTime = 60 * 15; this.isPlayerGuard = true; this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); @@ -1708,14 +1711,6 @@ public class Mob extends AbstractIntelligenceAgent { this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); } - // Load AI for guard dogs - - if (this.contract.getContractID() == 910) { - this.isPlayerGuard = true; - this.behaviourType = MobBehaviourType.GuardCaptain; - this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); - } } // Default to the mobbase for AI if nothing is hte mob field to override. @@ -1723,6 +1718,9 @@ public class Mob extends AbstractIntelligenceAgent { if (this.behaviourType == null || this.behaviourType.equals(MobBehaviourType.None)) this.behaviourType = this.getMobBase().fsm; + if (this.behaviourType == null) + this.behaviourType = MobBehaviourType.None; + if (this.building != null) this.guild = this.building.getGuild(); else From 85cc34fb4cc8820c77d9e096f8996b1cb6c808da Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 16:57:25 -0400 Subject: [PATCH 051/233] AIinfo updated. --- src/engine/devcmd/cmds/aiInfoCmd.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index 695b24dc..7d8c6785 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -11,6 +11,7 @@ package engine.devcmd.cmds; import engine.Enum.GameObjectType; import engine.devcmd.AbstractDevCmd; +import engine.gameManager.PowersManager; import engine.objects.AbstractGameObject; import engine.objects.Mob; import engine.objects.PlayerCharacter; @@ -85,10 +86,12 @@ public class aiInfoCmd extends AbstractDevCmd { output += "Current Target: NULL" + newline; if (mob.guardedCity != null) - output += mob.guardedCity.getCityName() + newline; + output += "Patrolling: " + mob.guardedCity.getCityName() + newline; + + output += "Powers:" + newline; for (int token : mob.mobPowers.keySet()) - output += token + newline; + output += PowersManager.getPowerByToken(token).getName() + newline; throwbackInfo(playerCharacter, output); } From a7a93b8500df92499723820e5c7a2fc41841e4d3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 25 Aug 2023 17:05:46 -0400 Subject: [PATCH 052/233] Tweak to bindloc for minions. --- src/engine/objects/Mob.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 78609658..0e5540b6 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -653,7 +653,7 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.guardedCity = guardCaptain.guardedCity; minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; - minionMobile.bindLoc = guardCaptain.building.getLoc(); + minionMobile.bindLoc = Vector3fImmutable.ZERO; //grab name from minionbase. @@ -1689,10 +1689,12 @@ public class Mob extends AbstractIntelligenceAgent { else this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); - // Setup mobile AI + // Setup mobile AI and equipset for contract if (this.contract != null) { + this.equipmentSetID = this.contract.getEquipmentSet(); + // Load AI for guard captains if (NPC.ISGuardCaptain(contract.getContractID()) || this.contract.getContractID() == 910) { // Guard Dog @@ -1734,13 +1736,9 @@ public class Mob extends AbstractIntelligenceAgent { if (this.firstName.isEmpty()) this.firstName = this.mobBase.getFirstName(); - if (this.contract != null) { - - this.equipmentSetID = this.contract.getEquipmentSet(); - + if (this.contract != null) if (this.lastName.isEmpty()) this.lastName = this.getContract().getName(); - } this.healthMax = this.mobBase.getHealthMax(); this.manaMax = 0; @@ -1787,10 +1785,10 @@ public class Mob extends AbstractIntelligenceAgent { // with the exceptions being mobiles // with a contract. + this.bindLoc = building.getLoc().add(bindLoc); + if (this.contract != null || this.isSiege) NPCManager.slotCharacterInBuilding(this); - else - this.bindLoc = building.getLoc(); } // Setup location for this Mobile From 4d6e57257c455fb8cdc301c1731c57c71e5ec9c2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 06:19:03 -0400 Subject: [PATCH 053/233] Unused methods removed. --- src/engine/objects/Mob.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 0e5540b6..d2a9d463 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -760,18 +760,6 @@ public class Mob extends AbstractIntelligenceAgent { return currentID; } - public float getSpawnX() { - return this.statLat; - } - - public float getSpawnY() { - return this.statAlt; - } - - public float getSpawnZ() { - return this.statLon; - } - public float getSpawnRadius() { return this.spawnRadius; } @@ -780,11 +768,6 @@ public class Mob extends AbstractIntelligenceAgent { this.spawnTime = value; } - //use getSpawnTime instead. This is just for init tables - public int getTrueSpawnTime() { - return this.spawnTime; - } - public String getSpawnTimeAsString() { if (this.spawnTime == 0) return MBServerStatics.DEFAULT_SPAWN_TIME_MS / 1000 + " seconds (Default)"; From 8badcc3f6e693b0cfbd713e2f06ef675e353f0a6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 06:24:05 -0400 Subject: [PATCH 054/233] Refactored out redundant stat-xyz variables. --- src/engine/objects/Mob.java | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d2a9d463..8b84ae82 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -80,9 +80,7 @@ public class Mob extends AbstractIntelligenceAgent { public int parentZoneUUID; public boolean isSiege = false; protected int dbID; //the database ID - protected float statLat; - protected float statLon; - protected float statAlt; + private int currentID; private int ownerUID = 0; //only used by pets private AbstractWorldObject fearedObject = null; @@ -127,7 +125,7 @@ public class Mob extends AbstractIntelligenceAgent { if (building != null && building.getOwner() != null) { this.lastName = "the " + contract.getName(); } - clearStatic(); + } /** @@ -142,7 +140,7 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); this.behaviourType = Enum.MobBehaviourType.Pet1; - clearStatic(); + } //SIEGE CONSTRUCTOR @@ -155,7 +153,6 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = 0; this.equip = new HashMap<>(); - clearStatic(); } /** @@ -165,17 +162,22 @@ public class Mob extends AbstractIntelligenceAgent { super(rs); + float statLat; + float statAlt; + float statLon; + try { this.dbID = rs.getInt(1); this.loadID = rs.getInt("mob_mobbaseID"); this.gridObjectType = GridObjectType.DYNAMIC; this.spawnRadius = rs.getFloat("mob_spawnRadius"); this.spawnTime = rs.getInt("mob_spawnTime"); - this.statLat = rs.getFloat("mob_spawnX"); - this.statAlt = rs.getFloat("mob_spawnY"); - this.statLon = rs.getFloat("mob_spawnZ"); - this.localLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); + statLat = rs.getFloat("mob_spawnX"); + statAlt = rs.getFloat("mob_spawnY"); + statLon = rs.getFloat("mob_spawnZ"); + this.bindLoc = new Vector3fImmutable(statLat, statAlt, statLon); + this.localLoc = new Vector3fImmutable(bindLoc); this.parentZoneUUID = rs.getInt("parent"); this.level = (short) rs.getInt("mob_level"); @@ -204,8 +206,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.mobBase != null && this.spawnTime == 0) this.spawnTime = this.mobBase.getSpawnTime(); - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.runeSet = rs.getInt("runeSet"); this.bootySet = rs.getInt("bootySet"); @@ -728,16 +728,6 @@ public class Mob extends AbstractIntelligenceAgent { return mob; } - private void clearStatic() { - - if (this.parentZone != null) - this.parentZone.zoneMobSet.remove(this); - - this.parentZone = null; - this.statLat = 0f; - this.statLon = 0f; - this.statAlt = 0f; - } /* * Getters From 79980a172596ffe0b14df1b2a0b71c85bc6df414 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 06:45:34 -0400 Subject: [PATCH 055/233] NoID constructor removed. --- src/engine/objects/Mob.java | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 8b84ae82..5a0430b4 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -99,35 +99,6 @@ public class Mob extends AbstractIntelligenceAgent { this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; } - /** - * No Id Constructor - */ - public Mob(String firstName, String lastName, short statStrCurrent, short statDexCurrent, short statConCurrent, short statIntCurrent, short statSpiCurrent, short level, int exp, boolean sit, boolean walk, boolean combat, Vector3fImmutable bindLoc, Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild, byte runningTrains, int npcType, boolean isMob, Zone parent, Building building, int contractID) { - super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, sit, walk, combat, bindLoc, currentLoc, faceDir, healthCurrent, manaCurrent, stamCurrent, guild, runningTrains); - - this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; - this.loadID = npcType; - this.mobBase = MobBase.getMobBase(loadID); - this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; - this.parentZone = parent; - this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; - this.building = building; - - if (building != null) - this.buildingUUID = building.getObjectUUID(); - else - this.buildingUUID = 0; - - 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(); - } - - } - /** * Pet Constructor */ From 1ecf0122ab88c89c64474b38491e7e5563902c20 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 09:29:12 -0400 Subject: [PATCH 056/233] Unused variable removed. --- src/engine/objects/Mob.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 5a0430b4..83d27690 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -55,7 +55,6 @@ public class Mob extends AbstractIntelligenceAgent { public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public boolean despawned = false; public Vector3fImmutable destination = Vector3fImmutable.ZERO; - public Vector3fImmutable localLoc = Vector3fImmutable.ZERO; public LinkedHashMap mobPowers = new LinkedHashMap<>(); public MobBase mobBase; public int spawnTime; @@ -148,7 +147,6 @@ public class Mob extends AbstractIntelligenceAgent { statAlt = rs.getFloat("mob_spawnY"); statLon = rs.getFloat("mob_spawnZ"); this.bindLoc = new Vector3fImmutable(statLat, statAlt, statLon); - this.localLoc = new Vector3fImmutable(bindLoc); this.parentZoneUUID = rs.getInt("parent"); this.level = (short) rs.getInt("mob_level"); From 091431d95b8c350ac58812395366abe9ce617515 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 09:31:10 -0400 Subject: [PATCH 057/233] Dynamic set in all constructors. --- src/engine/objects/Mob.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 83d27690..6e84609b 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -96,6 +96,8 @@ public class Mob extends AbstractIntelligenceAgent { super(); this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; + this.bindLoc = Vector3fImmutable.ZERO; + this.gridObjectType = GridObjectType.DYNAMIC; } /** @@ -140,6 +142,7 @@ public class Mob extends AbstractIntelligenceAgent { this.dbID = rs.getInt(1); this.loadID = rs.getInt("mob_mobbaseID"); this.gridObjectType = GridObjectType.DYNAMIC; + this.spawnRadius = rs.getFloat("mob_spawnRadius"); this.spawnTime = rs.getInt("mob_spawnTime"); @@ -1622,7 +1625,6 @@ public class Mob extends AbstractIntelligenceAgent { if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; - this.gridObjectType = GridObjectType.DYNAMIC; this.mobBase = MobBase.getMobBase(loadID); this.building = BuildingManager.getBuilding(this.buildingUUID); From fa3aa24a3d1d0fd9cc8ffd73ba4ca338e9cd6696 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 09:41:58 -0400 Subject: [PATCH 058/233] Update to minion building/location mechanic. --- src/engine/objects/Mob.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6e84609b..7441dfcb 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -612,7 +612,8 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.loadID = guardCaptain.loadID; minionMobile.firstName = minionName; minionMobile.equipmentSetID = guardCaptain.equipmentSetID; - + minionMobile.buildingUUID = guardCaptain.building.getObjectUUID(); + minionMobile.guildUUID = guardCaptain.guildUUID; minionMobile.runeSet = guardCaptain.runeSet; minionMobile.enemy = guardCaptain.enemy; minionMobile.notEnemy = guardCaptain.notEnemy; @@ -1729,10 +1730,10 @@ public class Mob extends AbstractIntelligenceAgent { // with the exceptions being mobiles // with a contract. - this.bindLoc = building.getLoc().add(bindLoc); - - if (this.contract != null || this.isSiege) + if (this.contract != null) NPCManager.slotCharacterInBuilding(this); + else + this.bindLoc = building.getLoc().add(bindLoc); } // Setup location for this Mobile @@ -1806,8 +1807,10 @@ public class Mob extends AbstractIntelligenceAgent { Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(this.getBindLoc(), patrolRadius); this.patrolPoints.add(newPatrolPoint); - if (i == 1) - MovementManager.translocate(this, newPatrolPoint, null); + if (i == 1) { + this.loc = newPatrolPoint; + this.endLoc = newPatrolPoint; + } } } From 1cdaa58e7a2dfce1b7f1526cc773d01540f9088a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 10:11:13 -0400 Subject: [PATCH 059/233] Wall archers set to static grid type. --- src/engine/objects/Mob.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 7441dfcb..a29f06e1 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1627,6 +1627,9 @@ public class Mob extends AbstractIntelligenceAgent { return; this.mobBase = MobBase.getMobBase(loadID); + + this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); + this.building = BuildingManager.getBuilding(this.buildingUUID); if (this.contractUUID == 0) @@ -1652,12 +1655,12 @@ public class Mob extends AbstractIntelligenceAgent { // Load AI for wall archers if (NPC.ISWallArcher(this.contract)) { + this.gridObjectType = GridObjectType.STATIC; this.behaviourType = MobBehaviourType.GuardWallArcher; this.isPlayerGuard = true; this.spawnTime = 450; this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); } - } // Default to the mobbase for AI if nothing is hte mob field to override. @@ -1676,8 +1679,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.guild == null) this.guild = Guild.getErrantGuild(); - this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); - if (this.firstName.isEmpty()) this.firstName = this.mobBase.getFirstName(); From 8dd25ac315ea7760b9b99bdfc6a8f33617d3b5e6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 11:06:48 -0400 Subject: [PATCH 060/233] Minions inherit patrol points form barracks. --- src/engine/objects/Mob.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index a29f06e1..bc2e7bed 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -624,6 +624,7 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion; minionMobile.isPlayerGuard = true; minionMobile.guardedCity = guardCaptain.guardedCity; + minionMobile.patrolPoints = guardCaptain.building.patrolPoints; minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; minionMobile.bindLoc = Vector3fImmutable.ZERO; From 7e5ed3efe5c469cc603148b6ea694246c0830bf4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 11:09:58 -0400 Subject: [PATCH 061/233] sqrMagnitude not sqrRoot --- src/engine/mobileAI/utilities/CombatUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/mobileAI/utilities/CombatUtilities.java b/src/engine/mobileAI/utilities/CombatUtilities.java index fd52a2e3..3a0c0634 100644 --- a/src/engine/mobileAI/utilities/CombatUtilities.java +++ b/src/engine/mobileAI/utilities/CombatUtilities.java @@ -48,7 +48,7 @@ public class CombatUtilities { } public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) { - return entity1.getLoc().distance2D(entity2.getLoc()) < range; + return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range; } public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) { From 51ee41c77346249cc88753aa09c3efb9e190e4ac Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 11:19:36 -0400 Subject: [PATCH 062/233] use of SiegeEngine Behaviour Type --- src/engine/Enum.java | 2 +- src/engine/gameManager/NPCManager.java | 10 +++++----- src/engine/objects/Mob.java | 22 +++++++++------------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index ae5818c8..15ed5702 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2846,7 +2846,7 @@ public class Enum { //Independent Types SimpleStandingGuard(null, false, false, false, false, false), Pet1(null, false, false, true, false, false), - Siege(null, false, false, true, false, false), + SiegeEngine(null, false, false, true, false, false), Simple(null, false, false, true, false, false), Helpee(null, false, true, true, false, true), HelpeeWimpy(null, true, false, true, false, false), diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index b3b8916b..49057836 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -345,14 +345,14 @@ public enum NPCManager { // Pets are regular mobiles not hirelings (Siege engines) - if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob)) { - + if (!abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob)) + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + else { Mob mobile = (Mob) abstractCharacter; - if (mobile.isSiege == false) + if (!mobile.behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); - } else - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + } // Override bind and location for this npc derived // from BuildingManager slot location data. diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index bc2e7bed..282d26fb 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -77,7 +77,6 @@ public class Mob extends AbstractIntelligenceAgent { public float spawnRadius; //used by static mobs public int parentZoneUUID; - public boolean isSiege = false; protected int dbID; //the database ID private int currentID; @@ -371,7 +370,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(0); writer.putInt(0); - if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.isSiege && !mob.isPlayerGuard) { + if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.behaviourType.equals(MobBehaviourType.SiegeEngine) && !mob.isPlayerGuard) { writer.putInt(0); writer.putInt(0); } @@ -382,7 +381,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(2); writer.putInt(0x00008A2E); writer.putInt(0x1AB84003); - } else if (mob.isSiege) { + } else if (mob.behaviourType.equals(MobBehaviourType.SiegeEngine)) { writer.putInt(1); writer.putInt(74620179); } else @@ -685,7 +684,7 @@ public class Mob extends AbstractIntelligenceAgent { mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); //mob.setMob(); - mob.setSiege(true); + // mob.setSiege(true); int slot = 0; @@ -805,9 +804,10 @@ public class Mob extends AbstractIntelligenceAgent { @Override public Vector3fImmutable getBindLoc() { - if (this.isPet() && !this.isSiege) + if (this.isPet() && !this.behaviourType.equals(MobBehaviourType.SiegeEngine)) return this.getOwner() != null ? this.getOwner().getLoc() : this.getLoc(); - return this.bindLoc; + else + return this.bindLoc; } public void calculateModifiedStats() { @@ -982,7 +982,7 @@ public class Mob extends AbstractIntelligenceAgent { try { //resync corpses //this.setLoc(this.getMovementLoc()); - if (this.isSiege) { + if (this.behaviourType.equals(MobBehaviourType.SiegeEngine)) { this.deathTime = System.currentTimeMillis(); //this.state = STATE.Dead; try { @@ -1089,7 +1089,7 @@ public class Mob extends AbstractIntelligenceAgent { else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); - if (!this.isSiege && !this.isPlayerGuard && contract == null) + if (!this.behaviourType.equals(MobBehaviourType.SiegeEngine) && !this.isPlayerGuard && contract == null) loadInventory(); this.updateLocation(); @@ -1840,11 +1840,7 @@ public class Mob extends AbstractIntelligenceAgent { } public boolean isSiege() { - return isSiege; - } - - public void setSiege(boolean isSiege) { - this.isSiege = isSiege; + return this.behaviourType.equals(MobBehaviourType.SiegeEngine); } public void setNpcOwner(AbstractCharacter npcOwner) { From a796f5fe4b0c3a39b05ee8a41d7fb39a7b15a8f5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 11:55:18 -0400 Subject: [PATCH 063/233] More siege engine work. --- src/engine/Enum.java | 15 ++--- src/engine/mobileAI/MobAI.java | 19 +++--- .../mobileAI/utilities/MovementUtilities.java | 4 +- .../handlers/MinionTrainingMsgHandler.java | 2 +- src/engine/net/client/msg/ManageNPCMsg.java | 4 +- src/engine/objects/Mob.java | 66 +++++++++---------- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 15ed5702..d9d2527b 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2846,7 +2846,7 @@ public class Enum { //Independent Types SimpleStandingGuard(null, false, false, false, false, false), Pet1(null, false, false, true, false, false), - SiegeEngine(null, false, false, true, false, false), + SiegeEngine(null, false, false, false, false, false), Simple(null, false, false, true, false, false), Helpee(null, false, true, true, false, true), HelpeeWimpy(null, true, false, true, false, false), @@ -2857,13 +2857,12 @@ public class Enum { HamletGuard(null, false, true, false, false, false), AggroWanderer(null, false, false, true, false, false); - private static HashMap _behaviourTypes = new HashMap<>(); - public MobBehaviourType BehaviourHelperType; - public boolean isWimpy; - public boolean isAgressive; - public boolean canRoam; - public boolean callsForHelp; - public boolean respondsToCallForHelp; + public final MobBehaviourType BehaviourHelperType; + public final boolean isWimpy; + public final boolean isAgressive; + public final boolean canRoam; + public final boolean callsForHelp; + public final boolean respondsToCallForHelp; MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { this.BehaviourHelperType = helpeebehaviourType; diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 2f5d2fbd..94230778 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -313,7 +313,7 @@ public class MobAI { int contractID; if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) - contractID = mob.npcOwner.contract.getContractID(); + contractID = mob.guardCaptain.contract.getContractID(); else contractID = mob.contract.getContractID(); @@ -609,7 +609,7 @@ public class MobAI { if (mob.despawned && mob.isPlayerGuard) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { - if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { + if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) { //minions don't respawn while guard captain is dead @@ -808,7 +808,7 @@ public class MobAI { chaseTarget(mob); break; case GuardMinion: - if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned) + if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned) randomGuardPatrolPoint(mob); else { if (mob.getCombatTarget() != null) { @@ -1055,7 +1055,7 @@ public class MobAI { public static void GuardMinionLogic(Mob mob) { try { - if (!mob.npcOwner.isAlive()) { + if (!mob.guardCaptain.isAlive()) { if (mob.getCombatTarget() == null) { CheckForPlayerGuardAggro(mob); @@ -1074,11 +1074,10 @@ public class MobAI { } } }else { - if (mob.npcOwner.getCombatTarget() != null) - mob.setCombatTarget(mob.npcOwner.getCombatTarget()); - else - if (mob.getCombatTarget() != null) - mob.setCombatTarget(null); + if (mob.guardCaptain.getCombatTarget() != null) + mob.setCombatTarget(mob.guardCaptain.getCombatTarget()); + else if (mob.getCombatTarget() != null) + mob.setCombatTarget(null); } CheckMobMovement(mob); CheckForAttack(mob); @@ -1246,7 +1245,7 @@ public class MobAI { return false; if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { - if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { + if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { return true; } } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 85affdca..9bda3497 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -13,10 +13,10 @@ import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.mobileAI.Threads.MobAIThread; import engine.exception.MsgSendException; import engine.gameManager.MovementManager; import engine.math.Vector3fImmutable; +import engine.mobileAI.Threads.MobAIThread; import engine.net.client.msg.MoveToPointMsg; import engine.objects.*; import org.pmw.tinylog.Logger; @@ -38,7 +38,7 @@ public class MovementUtilities { if (agent.getContract() != null) guardCaptain = agent; else - guardCaptain = (Mob) agent.npcOwner; + guardCaptain = (Mob) agent.guardCaptain; if (guardCaptain != null) { Building barracks = guardCaptain.building; diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index 8d489fc2..76f1d928 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -167,7 +167,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER)) slot = 2; else - slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain + slot = ((NPC) siegeMob.guardCaptain).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation()); diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 8fcda7f7..c6c07279 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -366,7 +366,7 @@ public class ManageNPCMsg extends ClientNetMsg { long timeLife = upgradeTime - curTime; if (upgradeTime * 1000 > System.currentTimeMillis()) { - if (mob.npcOwner.isAlive()) { + if (mob.guardCaptain.isAlive()) { writer.put((byte) 0);//shows respawning timer writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime); @@ -689,7 +689,7 @@ public class ManageNPCMsg extends ClientNetMsg { long timeLife = upgradeTime - curTime; if (upgradeTime * 1000 > System.currentTimeMillis()) { - if (mob.npcOwner.isAlive()) { + if (mob.guardCaptain.isAlive()) { writer.put((byte) 0);//shows respawning timer writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 282d26fb..743f795b 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -61,13 +61,14 @@ public class Mob extends AbstractIntelligenceAgent { public Zone parentZone; public boolean hasLoot = false; public boolean isPlayerGuard = false; - public AbstractCharacter npcOwner; + public AbstractCharacter guardCaptain; public long deathTime = 0; public int equipmentSetID = 0; public int runeSet = 0; public int bootySet = 0; - public EnumBitSet notEnemy; - public EnumBitSet enemy; + public EnumBitSet notEnemy = EnumBitSet.noneOf(MonsterType.class); + public EnumBitSet enemy = EnumBitSet.noneOf(MonsterType.class); + ; public MobBehaviourType behaviourType; public ArrayList patrolPoints; public int lastPatrolPointIndex = 0; @@ -323,7 +324,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(0); // NPC menu options - if (mob.contract != null && mob.npcOwner == null) { + if (mob.contract != null && mob.guardCaptain == null) { writer.put((byte) 1); writer.putLong(0); writer.putLong(0); @@ -336,12 +337,12 @@ public class Mob extends AbstractIntelligenceAgent { } else writer.put((byte) 0); - if (mob.npcOwner != null) { + if (mob.guardCaptain != null) { writer.put((byte) 1); writer.putInt(GameObjectType.PlayerCharacter.ordinal()); writer.putInt(131117009); - writer.putInt(mob.npcOwner.getObjectType().ordinal()); - writer.putInt(mob.npcOwner.getObjectUUID()); + writer.putInt(mob.guardCaptain.getObjectType().ordinal()); + writer.putInt(mob.guardCaptain.getObjectUUID()); writer.putInt(8); } else writer.put((byte) 0); @@ -618,7 +619,7 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.notEnemy = guardCaptain.notEnemy; minionMobile.deathTime = System.currentTimeMillis(); - minionMobile.npcOwner = guardCaptain; + minionMobile.guardCaptain = guardCaptain; minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion; minionMobile.isPlayerGuard = true; @@ -651,7 +652,6 @@ public class Mob extends AbstractIntelligenceAgent { // Configure and spawn minion minionMobile.runAfterLoad(); - minionMobile.despawned = false; DbManager.addToCache(minionMobile); minionMobile.setLoc(minionMobile.bindLoc); @@ -665,26 +665,22 @@ public class Mob extends AbstractIntelligenceAgent { public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) { - MobBase minionMobBase; - Mob mob; + Mob siegeMinion; if (owner.getSiegeMinionMap().size() == 3) return null; - minionMobBase = MobBase.getMobBase(loadID); - - if (minionMobBase == null) - return null; - - mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, false); - //mob.runAfterLoad(); - mob.despawned = true; - DbManager.addToCache(mob); + siegeMinion = new Mob(); - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); - - //mob.setMob(); - // mob.setSiege(true); + siegeMinion.level = 1; + siegeMinion.loadID = loadID; + siegeMinion.guildUUID = guild.getObjectUUID(); + siegeMinion.equipmentSetID = 0; + siegeMinion.buildingUUID = owner.buildingUUID; + siegeMinion.guardCaptain = owner; + siegeMinion.parentZoneUUID = parent.getObjectUUID(); + siegeMinion.behaviourType = MobBehaviourType.SiegeEngine; + siegeMinion.bindLoc = Vector3fImmutable.ZERO; int slot = 0; @@ -693,12 +689,14 @@ public class Mob extends AbstractIntelligenceAgent { else if (!owner.getSiegeMinionMap().containsValue(2)) slot = 2; - owner.getSiegeMinionMap().put(mob, slot); + owner.getSiegeMinionMap().put(siegeMinion, slot); - mob.setNpcOwner(owner); - mob.behaviourType = MobBehaviourType.Pet1; - mob.behaviourType.canRoam = false; - return mob; + siegeMinion.runAfterLoad(); + siegeMinion.despawned = true; + DbManager.addToCache(siegeMinion); + siegeMinion.setLoc(siegeMinion.bindLoc); + + return siegeMinion; } @@ -995,7 +993,7 @@ public class Mob extends AbstractIntelligenceAgent { this.playerAgroMap.clear(); if (this.behaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) - this.spawnTime = (int) (-2.500 * this.npcOwner.building.getRank() + 22.5) * 60; + this.spawnTime = (int) (-2.500 * this.guardCaptain.building.getRank() + 22.5) * 60; if (this.isPet()) { @@ -1084,8 +1082,8 @@ public class Mob extends AbstractIntelligenceAgent { this.recalculateStats(); this.setHealth(this.healthMax); - if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) - this.building = this.npcOwner.building; + if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) + this.building = this.guardCaptain.building; else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); @@ -1843,8 +1841,8 @@ public class Mob extends AbstractIntelligenceAgent { return this.behaviourType.equals(MobBehaviourType.SiegeEngine); } - public void setNpcOwner(AbstractCharacter npcOwner) { - this.npcOwner = npcOwner; + public void setGuardCaptain(AbstractCharacter guardCaptain) { + this.guardCaptain = guardCaptain; } public boolean isNecroPet() { From e2d843b65e2f6a89f82209797828113aceb98f66 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 12:03:33 -0400 Subject: [PATCH 064/233] Signature refactor. --- .../handlers/MinionTrainingMsgHandler.java | 35 +------------------ src/engine/objects/Mob.java | 21 +++++------ 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index 76f1d928..66db649a 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -8,7 +8,6 @@ import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; import engine.gameManager.NPCManager; import engine.gameManager.SessionManager; -import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -146,42 +145,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (mobBase == 0) return true; - Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1); + Mob siegeMob = Mob.createSiegeMinion(npc, mobBase); if (siegeMob == null) return true; - - if (siegeMob != null) { - - siegeMob.setSpawnTime(60 * 15); - Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID()); - - siegeMob.building = building; - siegeMob.parentZone = zone; - - // Slot siege minion - // Can be either corner tower or bulwark. - - int slot; - - if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER)) - slot = 2; - else - slot = ((NPC) siegeMob.guardCaptain).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain - - BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); - siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation()); - - // Rotate slot position by the building rotation - - siegeMob.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), siegeMob.bindLoc, building.getBounds().getQuaternion().angleY); - - siegeMob.loc = new Vector3fImmutable(siegeMob.bindLoc); - siegeMob.endLoc = new Vector3fImmutable(siegeMob.bindLoc); - - zone.zoneMobSet.add(siegeMob); - siegeMob.setLoc(siegeMob.bindLoc); - } } ManageNPCMsg mnm = new ManageNPCMsg(npc); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 743f795b..4a1b0f72 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -663,38 +663,39 @@ public class Mob extends AbstractIntelligenceAgent { return minionMobile; } - public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) { + public static synchronized Mob createSiegeMinion(NPC artyCaptain, int loadID) { Mob siegeMinion; - if (owner.getSiegeMinionMap().size() == 3) + if (artyCaptain.getSiegeMinionMap().size() == 3) return null; siegeMinion = new Mob(); siegeMinion.level = 1; siegeMinion.loadID = loadID; - siegeMinion.guildUUID = guild.getObjectUUID(); + siegeMinion.guildUUID = artyCaptain.guildUUID; siegeMinion.equipmentSetID = 0; - siegeMinion.buildingUUID = owner.buildingUUID; - siegeMinion.guardCaptain = owner; - siegeMinion.parentZoneUUID = parent.getObjectUUID(); + siegeMinion.buildingUUID = artyCaptain.buildingUUID; + siegeMinion.guardCaptain = artyCaptain; + siegeMinion.parentZoneUUID = artyCaptain.parentZoneUUID; siegeMinion.behaviourType = MobBehaviourType.SiegeEngine; siegeMinion.bindLoc = Vector3fImmutable.ZERO; + siegeMinion.spawnTime = (60 * 15); int slot = 0; - if (!owner.getSiegeMinionMap().containsValue(1)) + if (!artyCaptain.getSiegeMinionMap().containsValue(1)) slot = 1; - else if (!owner.getSiegeMinionMap().containsValue(2)) + else if (!artyCaptain.getSiegeMinionMap().containsValue(2)) slot = 2; - owner.getSiegeMinionMap().put(siegeMinion, slot); + artyCaptain.getSiegeMinionMap().put(siegeMinion, slot); siegeMinion.runAfterLoad(); - siegeMinion.despawned = true; DbManager.addToCache(siegeMinion); siegeMinion.setLoc(siegeMinion.bindLoc); + siegeMinion.despawn(); return siegeMinion; } From 34081e590333fa51ac5925f28b48eb122b041d2b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 12:21:47 -0400 Subject: [PATCH 065/233] Ordinal comparison fix. --- 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 4a1b0f72..9eb1bc50 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1083,7 +1083,7 @@ public class Mob extends AbstractIntelligenceAgent { this.recalculateStats(); this.setHealth(this.healthMax); - if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) + if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.equals(MobBehaviourType.GuardCaptain)) this.building = this.guardCaptain.building; else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); From 316bd6dd01c3cb808fb3cb5257d41e30e436aa7d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 12:35:14 -0400 Subject: [PATCH 066/233] Siege engines use slot system. --- 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 9eb1bc50..5d30749a 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1731,7 +1731,7 @@ public class Mob extends AbstractIntelligenceAgent { // with the exceptions being mobiles // with a contract. - if (this.contract != null) + if (this.contract != null || this.behaviourType.equals(MobBehaviourType.SiegeEngine)) NPCManager.slotCharacterInBuilding(this); else this.bindLoc = building.getLoc().add(bindLoc); From 060d831d504c71ff8eb94745faf303e9fa178baa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 12:37:28 -0400 Subject: [PATCH 067/233] Comment for clarity. --- src/engine/gameManager/NPCManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 49057836..9c5f2f2d 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -350,6 +350,8 @@ public enum NPCManager { else { Mob mobile = (Mob) abstractCharacter; + // Siege engines are not hirelings but minions of said hireling. + if (!mobile.behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); } From e7d1d5cb71b53096a3f231364fdc0049b88ee31d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 12:38:54 -0400 Subject: [PATCH 068/233] Constructor removed. --- src/engine/objects/Mob.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 5d30749a..1a0a3cbd 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -115,18 +115,6 @@ public class Mob extends AbstractIntelligenceAgent { } - //SIEGE CONSTRUCTOR - public Mob(MobBase mobBase, Guild guild, Zone parent, short level, Vector3fImmutable loc, int tableID, boolean isPlayerGuard) { - super(mobBase.getFirstName(), "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, level, 0, false, true, false, loc, loc, Vector3fImmutable.ZERO, (short) mobBase.getHealthMax(), (short) 0, (short) 0, guild, (byte) 0, tableID); - this.dbID = tableID; - this.loadID = mobBase.getObjectUUID(); - this.mobBase = mobBase; - this.parentZone = parent; - this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; - this.ownerUID = 0; - this.equip = new HashMap<>(); - } - /** * ResultSet Constructor */ From 1c81a4faed0b13f304ce88d575a3601cace2a239 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 13:38:09 -0400 Subject: [PATCH 069/233] Wall archers static reverted. --- 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 1a0a3cbd..335a0fdd 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1643,7 +1643,7 @@ public class Mob extends AbstractIntelligenceAgent { // Load AI for wall archers if (NPC.ISWallArcher(this.contract)) { - this.gridObjectType = GridObjectType.STATIC; + this.gridObjectType = GridObjectType.DYNAMIC; this.behaviourType = MobBehaviourType.GuardWallArcher; this.isPlayerGuard = true; this.spawnTime = 450; From d171c6bb9a808721904b47bf1bfcb4d94f746b45 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 13:47:41 -0400 Subject: [PATCH 070/233] Unused method removed. --- src/engine/objects/Mob.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 335a0fdd..4142d56a 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1921,10 +1921,6 @@ public class Mob extends AbstractIntelligenceAgent { return isPlayerGuard; } - public void setPlayerGuard(boolean isPlayerGuard) { - this.isPlayerGuard = isPlayerGuard; - } - public void setPatrolPointIndex(int patrolPointIndex) { } From f5c6c002a886090fca41e5961b7f47a31d0cb360 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 13:53:32 -0400 Subject: [PATCH 071/233] Unused method removed. --- src/engine/gameManager/NPCManager.java | 1 + src/engine/objects/Mob.java | 40 +------------------------- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 9c5f2f2d..cc9c70dc 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -408,4 +408,5 @@ public enum NPCManager { } return maxSlots; } + } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 4142d56a..ce0b1db6 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -2002,42 +2002,4 @@ public class Mob extends AbstractIntelligenceAgent { } } - public void dismiss() { - - if (this.isPet()) { - - if ((this.agentType.equals(AIAgentType.PET))) { //delete summoned pet - this.despawn(); - WorldGrid.RemoveWorldObject(this); - DbManager.removeFromCache(this); - - if (this.getObjectType() == GameObjectType.Mob) - if (this.getParentZone() != null) - this.getParentZone().zoneMobSet.remove(this); - - } else { //revert charmed pet - this.agentType = AIAgentType.MOBILE; - this.setCombatTarget(null); - } - //clear owner - - PlayerCharacter owner = this.getOwner(); - - //close pet window - - if (owner != null) { - Mob pet = owner.getPet(); - PetMsg pm = new PetMsg(5, null); - Dispatch dispatch = Dispatch.borrow(owner, pm); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - if (pet != null && pet.getObjectUUID() == this.getObjectUUID()) - owner.setPet(null); - - if (this.getObjectType().equals(GameObjectType.Mob)) - this.setOwner(null); - } - } - } - -} \ No newline at end of file +} From c9cdb891d69a4328fb9a574e2ef65aab1d2ee31c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 14:52:18 -0400 Subject: [PATCH 072/233] Cleanup of ownerNPC mess. --- .../objects/AbstractIntelligenceAgent.java | 13 +- src/engine/objects/Mob.java | 272 ++++++++---------- .../poweractions/CreateMobPowerAction.java | 2 +- 3 files changed, 124 insertions(+), 163 deletions(-) diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index b99e06cb..dd36d3c7 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -31,7 +31,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { protected Vector3fImmutable lastBindLoc; public boolean assist = false; public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; - + public boolean isPlayerGuard = false; + public AbstractCharacter guardCaptain; public AbstractIntelligenceAgent() { super(); @@ -114,14 +115,6 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { return 0; } - public PlayerCharacter getOwner() { - - if (this.getObjectType().equals(GameObjectType.Mob)) - return this.getOwner(); - - return null; - } - public boolean getSafeZone() { ArrayList allIn = ZoneManager.getAllZonesIn(this.getLoc()); @@ -162,7 +155,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { //clear owner - PlayerCharacter owner = this.getOwner(); + PlayerCharacter owner = (PlayerCharacter) this.guardCaptain; //close pet window diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index ce0b1db6..6cf00017 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -60,8 +60,6 @@ public class Mob extends AbstractIntelligenceAgent { public int spawnTime; public Zone parentZone; public boolean hasLoot = false; - public boolean isPlayerGuard = false; - public AbstractCharacter guardCaptain; public long deathTime = 0; public int equipmentSetID = 0; public int runeSet = 0; @@ -81,7 +79,7 @@ public class Mob extends AbstractIntelligenceAgent { protected int dbID; //the database ID private int currentID; - private int ownerUID = 0; //only used by pets + private AbstractWorldObject fearedObject = null; private long lastAttackTime = 0; private int lastMobPowerToken = 0; @@ -100,20 +98,6 @@ public class Mob extends AbstractIntelligenceAgent { this.gridObjectType = GridObjectType.DYNAMIC; } - /** - * Pet Constructor - */ - public Mob(MobBase mobBase, Guild guild, Zone parent, short level, PlayerCharacter owner, int tableID) { - super(mobBase.getFirstName(), "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, level, 0, false, true, false, owner.getLoc(), owner.getLoc(), owner.getFaceDir(), (short) mobBase.getHealthMax(), (short) 0, (short) 0, guild, (byte) 0, tableID); - this.dbID = tableID; - this.loadID = mobBase.getObjectUUID(); - this.mobBase = mobBase; - this.parentZone = parent; - this.parentZoneUUID = (parent != null) ? parent.getObjectUUID() : 0; - this.ownerUID = owner.getObjectUUID(); - this.behaviourType = Enum.MobBehaviourType.Pet1; - - } /** * ResultSet Constructor @@ -460,130 +444,6 @@ public class Mob extends AbstractIntelligenceAgent { return mob; } - public static Mob createPet(int loadID, Guild guild, Zone parent, PlayerCharacter owner, short level) { - MobBase mobBase = MobBase.getMobBase(loadID); - Mob mob = null; - - if (mobBase == null || owner == null) - return null; - - createLock.writeLock().lock(); - level += 20; - - try { - mob = new Mob(mobBase, guild, parent, level, owner, 0); - if (mob.mobBase == null) - return null; - mob.runAfterLoad(); - Vector3fImmutable loc = owner.getLoc(); - DbManager.addToCache(mob); - mob.setPet(owner, true); - mob.setWalkMode(false); - - } catch (Exception e) { - Logger.error(e); - } finally { - createLock.writeLock().unlock(); - } - parent.zoneMobSet.add(mob); - mob.level = level; - mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f); - mob.health.set(mob.healthMax); - return mob; - } - - public static Mob getMob(int id) { - - if (id == 0) - return null; - - Mob mob = (Mob) DbManager.getFromCache(GameObjectType.Mob, id); - if (mob != null) - return mob; - return DbManager.MobQueries.GET_MOB(id); - } - - public static Mob getFromCache(int id) { - - - return (Mob) DbManager.getFromCache(GameObjectType.Mob, id); - } - - private static float getModifiedAmount(CharacterSkill skill) { - - if (skill == null) - return 0f; - - return skill.getModifiedAmount(); - } - - public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { - - HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobAIThread.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); - - for (AbstractWorldObject awo : mobsInRange) { - Mob mob = (Mob) awo; - - //Mob is not attacking anyone, skip. - if (mob.getCombatTarget() == null) - continue; - - //Mob not attacking target's target, let's not be failmu and skip this target. - if (mob.getCombatTarget() != target) - continue; - - //target is mob's combat target, LETS GO. - - if (source.getHateValue() > target.getHateValue()) - mob.setCombatTarget(source); - } - } - - public static void submitUpgradeJob(Mob mob) { - - if (mob.getUpgradeDateTime() == null) { - Logger.error("Failed to get Upgrade Date"); - return; - } - - // Submit upgrade job for future date or current instant - - if (mob.getUpgradeDateTime().isAfter(DateTime.now())) - JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), mob.getUpgradeDateTime().getMillis()); - else - JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), 0); - - } - - public static int getUpgradeTime(Mob mob) { - - if (mob.getRank() < 7) - return (mob.getRank() * 8); - - return 0; - } - - public static int getUpgradeCost(Mob mob) { - - int upgradeCost; - - upgradeCost = Integer.MAX_VALUE; - - if (mob.getRank() < 7) - return (mob.getRank() * 100650) + 21450; - - return upgradeCost; - } - - public static void setUpgradeDateTime(Mob mob, DateTime upgradeDateTime) { - - if (!DbManager.MobQueries.updateUpgradeTime(mob, upgradeDateTime)) { - Logger.error("Failed to set upgradeTime for building " + mob.currentID); - return; - } - mob.upgradeDateTime = upgradeDateTime; - } - public static synchronized Mob createGuardMinion(Mob guardCaptain, short level, String minionName) { Mob minionMobile; @@ -688,6 +548,122 @@ public class Mob extends AbstractIntelligenceAgent { return siegeMinion; } + public static Mob createPetMinion(int loadID, Guild guild, Zone parent, PlayerCharacter petOwner, short level) { + + Mob petMinion = new Mob(); + + if (petOwner == null) + return null; + + createLock.writeLock().lock(); + + petMinion.level = level; + petMinion.loadID = loadID; + petMinion.loc = petOwner.getLoc(); + petMinion.guardCaptain = petOwner; + petMinion.parentZoneUUID = parent.getObjectUUID(); + petMinion.walkMode = false; + petMinion.healthMax = petMinion.getMobBase().getHealthMax() * (petMinion.level * 0.5f); + petMinion.health.set(petMinion.healthMax); + + petMinion.runAfterLoad(); + DbManager.addToCache(petMinion); + createLock.writeLock().unlock(); + + return petMinion; + } + public static Mob getMob(int id) { + + if (id == 0) + return null; + + Mob mob = (Mob) DbManager.getFromCache(GameObjectType.Mob, id); + if (mob != null) + return mob; + return DbManager.MobQueries.GET_MOB(id); + } + + public static Mob getFromCache(int id) { + + + return (Mob) DbManager.getFromCache(GameObjectType.Mob, id); + } + + private static float getModifiedAmount(CharacterSkill skill) { + + if (skill == null) + return 0f; + + return skill.getModifiedAmount(); + } + + public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { + + HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobAIThread.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); + + for (AbstractWorldObject awo : mobsInRange) { + Mob mob = (Mob) awo; + + //Mob is not attacking anyone, skip. + if (mob.getCombatTarget() == null) + continue; + + //Mob not attacking target's target, let's not be failmu and skip this target. + if (mob.getCombatTarget() != target) + continue; + + //target is mob's combat target, LETS GO. + + if (source.getHateValue() > target.getHateValue()) + mob.setCombatTarget(source); + } + } + + public static void submitUpgradeJob(Mob mob) { + + if (mob.getUpgradeDateTime() == null) { + Logger.error("Failed to get Upgrade Date"); + return; + } + + // Submit upgrade job for future date or current instant + + if (mob.getUpgradeDateTime().isAfter(DateTime.now())) + JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), mob.getUpgradeDateTime().getMillis()); + else + JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), 0); + + } + + public static int getUpgradeTime(Mob mob) { + + if (mob.getRank() < 7) + return (mob.getRank() * 8); + + return 0; + } + + public static int getUpgradeCost(Mob mob) { + + int upgradeCost; + + upgradeCost = Integer.MAX_VALUE; + + if (mob.getRank() < 7) + return (mob.getRank() * 100650) + 21450; + + return upgradeCost; + } + + public static void setUpgradeDateTime(Mob mob, DateTime upgradeDateTime) { + + if (!DbManager.MobQueries.updateUpgradeTime(mob, upgradeDateTime)) { + Logger.error("Failed to set upgradeTime for building " + mob.currentID); + return; + } + mob.upgradeDateTime = upgradeDateTime; + } + /* * Getters @@ -764,24 +740,16 @@ public class Mob extends AbstractIntelligenceAgent { return this.guild.getObjectUUID(); } - @Override public PlayerCharacter getOwner() { - if (!this.isPet()) - return null; - - if (this.ownerUID == 0) - return null; - return PlayerCharacter.getFromCache(this.ownerUID); + return (PlayerCharacter) this.guardCaptain; } public void setOwner(PlayerCharacter value) { - if (value == null) - this.ownerUID = 0; - else - this.ownerUID = value.getObjectUUID(); + + this.guardCaptain = value; } public void setFearedObject(AbstractWorldObject awo) { diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index 90b64055..b36005c3 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -75,7 +75,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { return; //create Pet - Mob pet = Mob.createPet(mobID, guild, seaFloor, owner, (short) mobLevel); + Mob pet = Mob.createPetMinion(mobID, guild, seaFloor, owner, (short) mobLevel); if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet From ebdcb531f230e5847cd16a3c00f1b5053b316f20 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 14:54:43 -0400 Subject: [PATCH 073/233] AI methods moved to ai class. --- src/engine/objects/AbstractIntelligenceAgent.java | 9 +++++++++ src/engine/objects/Mob.java | 9 +-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index dd36d3c7..e0b49454 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -9,6 +9,7 @@ package engine.objects; +import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.ModType; @@ -33,6 +34,14 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; public boolean isPlayerGuard = false; public AbstractCharacter guardCaptain; + public EnumBitSet notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class); + public EnumBitSet enemy = EnumBitSet.noneOf(Enum.MonsterType.class); + ; + public Enum.MobBehaviourType behaviourType; + public ArrayList patrolPoints; + public int lastPatrolPointIndex = 0; + public long stopPatrolTime = 0; + public City guardedCity; public AbstractIntelligenceAgent() { super(); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6cf00017..effde051 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -64,14 +64,7 @@ public class Mob extends AbstractIntelligenceAgent { public int equipmentSetID = 0; public int runeSet = 0; public int bootySet = 0; - public EnumBitSet notEnemy = EnumBitSet.noneOf(MonsterType.class); - public EnumBitSet enemy = EnumBitSet.noneOf(MonsterType.class); - ; - public MobBehaviourType behaviourType; - public ArrayList patrolPoints; - public int lastPatrolPointIndex = 0; - public long stopPatrolTime = 0; - public City guardedCity; + public int loadID; public float spawnRadius; //used by static mobs From 445d40dc5fd7919a93be23c82b7baf6d2cfe9b6c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 14:59:25 -0400 Subject: [PATCH 074/233] Bonus code removed. --- src/engine/objects/Mob.java | 4 +-- .../poweractions/CreateMobPowerAction.java | 26 ++----------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index effde051..c5603eda 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -552,6 +552,7 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.level = level; petMinion.loadID = loadID; + petMinion.bindLoc = petOwner.getLoc(); petMinion.loc = petOwner.getLoc(); petMinion.guardCaptain = petOwner; petMinion.parentZoneUUID = parent.getObjectUUID(); @@ -562,7 +563,7 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.runAfterLoad(); DbManager.addToCache(petMinion); createLock.writeLock().unlock(); - + petMinion.setLoc(petMinion.bindLoc); return petMinion; } public static Mob getMob(int id) { @@ -741,7 +742,6 @@ public class Mob extends AbstractIntelligenceAgent { public void setOwner(PlayerCharacter value) { - this.guardCaptain = value; } diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index b36005c3..ca9b11c8 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -12,7 +12,6 @@ package engine.powers.poweractions; import engine.Enum; import engine.InterestManagement.WorldGrid; import engine.gameManager.DbManager; -import engine.gameManager.MovementManager; import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; @@ -84,8 +83,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { WorldGrid.RemoveWorldObject(currentPet); currentPet.setCombatTarget(null); - //if (currentPet.getParentZone() != null) - //currentPet.getParentZone().zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet); currentPet.playerAgroMap.clear(); @@ -95,7 +92,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { Logger.error(e.getMessage()); } - //currentPet.disableIntelligence(); } else if (currentPet != null && currentPet.isSiege()) { currentPet.agentType = Enum.AIAgentType.MOBILE; currentPet.setOwner(null); @@ -106,7 +102,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { } //remove 10th pet - NPCManager.spawnNecroPet(owner, pet); } else { //is not a necro pet @@ -137,26 +132,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { NPCManager.resetNecroPets(owner); } } - /* if(owner.getPet() != null) { - if(owner.getPet().getMobBaseID() != 12021 && owner.getPet().getMobBaseID() != 12022) { - //if not a necro pet, remove pet - WorldGrid.removeWorldObject(owner.getPet()); - owner.getPet().disableIntelligence(); - Mob.removePet(owner.getPet().getUUID()); - owner.setPet(null); - } - else { - //if it is a necro pet, add it to the line and set as mob - owner.getPet().setMob(); - } - }*/ - - // if (mobID == 12021 || mobID == 12022) //Necro Pets - // pet.setPet(owner, true); + owner.setPet(pet); - if(pet.isSiege() == false) { - MovementManager.translocate(pet, owner.getLoc(), owner.region); - } + pet.recalculateStats(); pet.healthMax = pet.level * 0.5f * 120; pet.setHealth(pet.healthMax); From 64aaaa707e7d9de069a0a78c705eb74d1b685233 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:00:43 -0400 Subject: [PATCH 075/233] Behaviour type set for pets. --- 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 c5603eda..cc634cf7 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -559,7 +559,7 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.walkMode = false; petMinion.healthMax = petMinion.getMobBase().getHealthMax() * (petMinion.level * 0.5f); petMinion.health.set(petMinion.healthMax); - + petMinion.behaviourType = MobBehaviourType.Pet1; petMinion.runAfterLoad(); DbManager.addToCache(petMinion); createLock.writeLock().unlock(); From 7a48c040578ec38d70a9b5ad2cff965f2e922617 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:10:14 -0400 Subject: [PATCH 076/233] Mobbase set properly. --- 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 cc634cf7..81638156 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -557,7 +557,7 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.guardCaptain = petOwner; petMinion.parentZoneUUID = parent.getObjectUUID(); petMinion.walkMode = false; - petMinion.healthMax = petMinion.getMobBase().getHealthMax() * (petMinion.level * 0.5f); + petMinion.healthMax = MobBase.getMobBase(loadID).getHealthMax() * (petMinion.level * 0.5f); petMinion.health.set(petMinion.healthMax); petMinion.behaviourType = MobBehaviourType.Pet1; petMinion.runAfterLoad(); From d8d5e4a3c47a9426276e118903c5f8182431f521 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:19:17 -0400 Subject: [PATCH 077/233] Name set to default. --- src/engine/objects/Mob.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 81638156..92df85a0 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -560,6 +560,9 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.healthMax = MobBase.getMobBase(loadID).getHealthMax() * (petMinion.level * 0.5f); petMinion.health.set(petMinion.healthMax); petMinion.behaviourType = MobBehaviourType.Pet1; + petMinion.firstName = ""; + petMinion.lastName = ""; + petMinion.despawned = false; petMinion.runAfterLoad(); DbManager.addToCache(petMinion); createLock.writeLock().unlock(); From 645aec853ed6fbc31a7b3041fb68083deccd5a15 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:21:50 -0400 Subject: [PATCH 078/233] Bindloc not adjusted for pets. --- src/engine/objects/Mob.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 92df85a0..e7d347b2 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1675,9 +1675,13 @@ public class Mob extends AbstractIntelligenceAgent { // Handle Mobiles within buildings - if (this.building == null) - this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); - else { + if (this.building == null) { + + // Do not adjust a pet's bindloc. + + if (!this.behaviourType.equals(MobBehaviourType.Pet1)) + this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); + } else { // Mobiles inside buildings are offset from it not the zone // with the exceptions being mobiles From a4dafd7155e6765ba75a7092bca08da19fdb6e22 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:34:27 -0400 Subject: [PATCH 079/233] Unused variable in signature. --- src/engine/objects/Mob.java | 2 +- src/engine/powers/poweractions/CreateMobPowerAction.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e7d347b2..6e52c1dd 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -541,7 +541,7 @@ public class Mob extends AbstractIntelligenceAgent { return siegeMinion; } - public static Mob createPetMinion(int loadID, Guild guild, Zone parent, PlayerCharacter petOwner, short level) { + public static Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { Mob petMinion = new Mob(); diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index ca9b11c8..c9e9d994 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -74,7 +74,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { return; //create Pet - Mob pet = Mob.createPetMinion(mobID, guild, seaFloor, owner, (short) mobLevel); + Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel); if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet From e3ad7efa4f8d7d6bd7115cc0f76766d3136545e3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:35:42 -0400 Subject: [PATCH 080/233] Method renamed for new convention. --- src/engine/db/handlers/dbMobHandler.java | 2 +- src/engine/objects/Mob.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 1af8a770..766335ff 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -28,7 +28,7 @@ public class dbMobHandler extends dbHandlerBase { this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } - public Mob ADD_MOB(Mob toAdd) { + public Mob PERSIST(Mob toAdd) { Mob mobile = null; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6e52c1dd..316f8b9a 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -427,7 +427,7 @@ public class Mob extends AbstractIntelligenceAgent { Mob mob; try { - mob = DbManager.MobQueries.ADD_MOB(mobile); + mob = DbManager.MobQueries.PERSIST(mobile); } catch (Exception e) { Logger.error("SQLException:" + e.getMessage()); From a81070c471958c7343057bd710fb3f94cded8e43 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 26 Aug 2023 15:47:10 -0400 Subject: [PATCH 081/233] Pet level += 20 to conform to 24.3 --- 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 316f8b9a..c3e55aa6 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -550,7 +550,7 @@ public class Mob extends AbstractIntelligenceAgent { createLock.writeLock().lock(); - petMinion.level = level; + petMinion.level = (short) (level + 20); petMinion.loadID = loadID; petMinion.bindLoc = petOwner.getLoc(); petMinion.loc = petOwner.getLoc(); From da9e211ec79a7c0ff6e99cc1f4db8e887e2f31ef Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 20:05:18 -0500 Subject: [PATCH 082/233] SiegeEngine enum and logic added --- src/engine/mobileAI/MobAI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 94230778..0f8af705 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -684,6 +684,7 @@ public class MobAI { GuardWallArcherLogic(mob); break; case Pet1: + case SiegeEngine: PetLogic(mob); break; case HamletGuard: From 85c2a4f4f0471d933e1800be026918b7850aaf90 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 21:20:00 -0400 Subject: [PATCH 083/233] Add all as hirelings --- src/engine/gameManager/NPCManager.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index cc9c70dc..4a0d7511 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -343,18 +343,7 @@ public enum NPCManager { if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); - // Pets are regular mobiles not hirelings (Siege engines) - - if (!abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob)) - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); - else { - Mob mobile = (Mob) abstractCharacter; - - // Siege engines are not hirelings but minions of said hireling. - - if (!mobile.behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); - } + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived // from BuildingManager slot location data. From 14a06410ae53f3510cfe1a99fdf47f075a255b69 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 21:25:43 -0400 Subject: [PATCH 084/233] Update to slotting logic. --- src/engine/gameManager/NPCManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 4a0d7511..e16533b0 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -343,7 +343,19 @@ public enum NPCManager { if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + // Pets are regular mobiles not hirelings (Siege engines) + + if (!abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob)) + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + else { + Mob mobile = (Mob) abstractCharacter; + + // Siege engines are not hirelings but minions of said hireling. + + if (mobile.behaviourType.equals(Enum.MobBehaviourType.SiegeEngine) || + mobile.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + } // Override bind and location for this npc derived // from BuildingManager slot location data. From 7e64cbabf82e181148796358dca9400d86f3f080 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 21:30:57 -0400 Subject: [PATCH 085/233] Update to slotting logic. --- src/engine/gameManager/NPCManager.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index e16533b0..b4362249 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -345,17 +345,7 @@ public enum NPCManager { // Pets are regular mobiles not hirelings (Siege engines) - if (!abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob)) - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); - else { - Mob mobile = (Mob) abstractCharacter; - - // Siege engines are not hirelings but minions of said hireling. - - if (mobile.behaviourType.equals(Enum.MobBehaviourType.SiegeEngine) || - mobile.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); - } + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived // from BuildingManager slot location data. From f80647ff0d7f88a46d4d1113a25e6345b4fae6ae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 21:42:58 -0400 Subject: [PATCH 086/233] Spawn time set to 15s for debug. --- src/engine/objects/Mob.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index c3e55aa6..b1ce9990 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -522,7 +522,8 @@ public class Mob extends AbstractIntelligenceAgent { siegeMinion.parentZoneUUID = artyCaptain.parentZoneUUID; siegeMinion.behaviourType = MobBehaviourType.SiegeEngine; siegeMinion.bindLoc = Vector3fImmutable.ZERO; - siegeMinion.spawnTime = (60 * 15); + //siegeMinion.spawnTime = (60 * 15); + siegeMinion.spawnTime = 15; int slot = 0; From 8afe25fe8510e8ad80aa2401443f811f750c9032 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 20:50:13 -0500 Subject: [PATCH 087/233] siege minions added to arty captain minion map --- src/engine/objects/Mob.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b1ce9990..7b2178a9 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -525,14 +525,8 @@ public class Mob extends AbstractIntelligenceAgent { //siegeMinion.spawnTime = (60 * 15); siegeMinion.spawnTime = 15; - int slot = 0; - - if (!artyCaptain.getSiegeMinionMap().containsValue(1)) - slot = 1; - else if (!artyCaptain.getSiegeMinionMap().containsValue(2)) - slot = 2; - - artyCaptain.getSiegeMinionMap().put(siegeMinion, slot); + int slot = artyCaptain.getSiegeMinionMap().size() + 1; + artyCaptain.getSiegeMinionMap().put(siegeMinion,slot); siegeMinion.runAfterLoad(); DbManager.addToCache(siegeMinion); @@ -1657,13 +1651,13 @@ public class Mob extends AbstractIntelligenceAgent { this.bonuses = new PlayerBonuses(this); //TODO set these correctly later - this.rangeHandOne = 8; + this.rangeHandOne = this.mobBase.getAttackRange(); this.rangeHandTwo = -1; - this.minDamageHandOne = 0; - this.maxDamageHandOne = 0; - this.minDamageHandTwo = 1; - this.maxDamageHandTwo = 4; - this.atrHandOne = 300; + this.minDamageHandOne = (int)this.mobBase.getMinDmg(); + this.maxDamageHandOne = (int)this.mobBase.getMaxDmg(); + this.minDamageHandTwo = 0; + this.maxDamageHandTwo = 0; + this.atrHandOne = this.mobBase.getAtr(); this.defenseRating = (short) this.mobBase.getDefenseRating(); this.isActive = true; From d573b238de8d5d43cab6ae32e54f3bbd47294268 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 21:04:34 -0500 Subject: [PATCH 088/233] refactored mob get/set owner --- src/engine/devcmd/cmds/InfoCmd.java | 4 +- src/engine/gameManager/NPCManager.java | 12 +++-- src/engine/mobileAI/MobAI.java | 19 +++++--- .../handlers/MinionTrainingMsgHandler.java | 14 ++++-- .../objects/AbstractIntelligenceAgent.java | 5 ++- src/engine/objects/AbstractWorldObject.java | 4 +- src/engine/objects/Mob.java | 44 ++++++++++--------- src/engine/objects/NPC.java | 6 ++- src/engine/objects/PlayerCharacter.java | 3 +- .../poweractions/CreateMobPowerAction.java | 8 ++-- 10 files changed, 74 insertions(+), 45 deletions(-) diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 5cb88ef9..51edb93a 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -440,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd { output += "isSummonedPet: true"; else output += "isSummonedPet: false"; - PlayerCharacter owner = targetMob.getOwner(); + + + PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain; if (owner != null) output += " owner: " + owner.getObjectUUID(); output += newline; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index b4362249..b112fe17 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -127,10 +127,12 @@ public enum NPCManager { DbManager.removeFromCache(necroPet); - PlayerCharacter petOwner = necroPet.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain; if (petOwner != null) { - necroPet.setOwner(null); + + necroPet.guardCaptain = null; petOwner.setPet(null); if (updateOwner == false) @@ -228,12 +230,14 @@ public enum NPCManager { WorldGrid.removeObject(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 0f8af705..ec202e6b 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -786,24 +786,30 @@ public class MobAI { switch (mob.behaviourType) { case Pet1: - if (mob.getOwner() == null) + + + if ((PlayerCharacter) mob.guardCaptain == null) return; - if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { + + if (!mob.playerAgroMap.containsKey(((PlayerCharacter) mob.guardCaptain).getObjectUUID())) { //mob no longer has its owner loaded, translocate pet to owner - MovementManager.translocate(mob, mob.getOwner().getLoc(), null); + + MovementManager.translocate(mob, ((PlayerCharacter) mob.guardCaptain).getLoc(), null); return; } if (mob.getCombatTarget() == null) { //move back to owner - if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6)) + + if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6)) return; - mob.destination = mob.getOwner().getLoc(); + + mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc(); MovementUtilities.moveToLocation(mob, mob.destination, 5); } else chaseTarget(mob); @@ -1103,7 +1109,8 @@ public class MobAI { try { - if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false) + + if ((PlayerCharacter) mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false) if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) mob.killCharacter("no owner"); diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index 66db649a..a6aa404e 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -73,11 +73,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { toRemove.getParentZone().zoneMobSet.remove(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); @@ -195,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { toRemove.getParentZone().zoneMobSet.remove(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index e0b49454..f18d4acb 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -101,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { this.agentType = Enum.AIAgentType.CHARMED; if (this.getObjectType().equals(GameObjectType.Mob)) { - ((Mob) this).setOwner(owner); + + ((Mob) this).guardCaptain = owner; } } @@ -180,7 +181,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { owner.setPet(null); if (this.getObjectType().equals(GameObjectType.Mob)) - ((Mob) this).setOwner(null); + ((Mob) this).guardCaptain = null; } diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 97d8a5d1..5f087a55 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject { Mob mob = (Mob) this; if (mob.isSiege()) { if (mob.isPet()) { - PlayerCharacter petOwner = mob.getOwner(); + + + PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain; if (petOwner != null && source.equals(EffectSourceType.Effect)) { petOwner.dismissPet(); return; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 7b2178a9..1cfcdeaa 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -316,9 +316,14 @@ public class Mob extends AbstractIntelligenceAgent { writer.put((byte) 1); - if (mob.getOwner() != null) { - writer.putInt(mob.getOwner().getObjectType().ordinal()); - writer.putInt(mob.getOwner().getObjectUUID()); + + if ((PlayerCharacter) mob.guardCaptain != null) { + + + writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectType().ordinal()); + + + writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectUUID()); } else { writer.putInt(0); //ownerType writer.putInt(0); //ownerID @@ -732,17 +737,6 @@ public class Mob extends AbstractIntelligenceAgent { return this.guild.getObjectUUID(); } - public PlayerCharacter getOwner() { - - - return (PlayerCharacter) this.guardCaptain; - } - - public void setOwner(PlayerCharacter value) { - - this.guardCaptain = value; - } - public void setFearedObject(AbstractWorldObject awo) { this.fearedObject = awo; } @@ -751,7 +745,7 @@ public class Mob extends AbstractIntelligenceAgent { public Vector3fImmutable getBindLoc() { if (this.isPet() && !this.behaviourType.equals(MobBehaviourType.SiegeEngine)) - return this.getOwner() != null ? this.getOwner().getLoc() : this.getLoc(); + return (PlayerCharacter) this.guardCaptain != null ? ((PlayerCharacter) this.guardCaptain).getLoc() : this.getLoc(); else return this.bindLoc; } @@ -875,7 +869,8 @@ public class Mob extends AbstractIntelligenceAgent { if (mobAttacker.isPet()) { - PlayerCharacter owner = mobAttacker.getOwner(); + + PlayerCharacter owner = (PlayerCharacter) mobAttacker.guardCaptain; if (owner != null) if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard) { @@ -945,13 +940,17 @@ public class Mob extends AbstractIntelligenceAgent { if (this.isPet()) { - PlayerCharacter petOwner = this.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain; if (petOwner != null) { - this.setOwner(null); + + this.guardCaptain = null; petOwner.setPet(null); PetMsg petMsg = new PetMsg(5, null); - dispatch = Dispatch.borrow(this.getOwner(), petMsg); + + + dispatch = Dispatch.borrow((PlayerCharacter) this.guardCaptain, petMsg); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); } } @@ -974,10 +973,13 @@ public class Mob extends AbstractIntelligenceAgent { WorldGrid.RemoveWorldObject(this); DbManager.removeFromCache(this); - PlayerCharacter petOwner = this.getOwner(); + + + PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain; if (petOwner != null) { - this.setOwner(null); + + this.guardCaptain = null; petOwner.setPet(null); PetMsg petMsg = new PetMsg(5, null); dispatch = Dispatch.borrow(petOwner, petMsg); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1ebc4c39..ae8f63bd 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -655,12 +655,14 @@ public class NPC extends AbstractCharacter { WorldGrid.RemoveWorldObject(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 7d7baaa5..92cdf909 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4690,7 +4690,8 @@ public class PlayerCharacter extends AbstractCharacter { } else if (currentPet.isSiege()) { currentPet.agentType = AIAgentType.MOBILE; - currentPet.setOwner(null); + + currentPet.guardCaptain = null; currentPet.setCombatTarget(null); if (currentPet.isAlive()) WorldGrid.updateObject(currentPet); diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index c9e9d994..41c7e810 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -94,7 +94,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { } else if (currentPet != null && currentPet.isSiege()) { currentPet.agentType = Enum.AIAgentType.MOBILE; - currentPet.setOwner(null); + + currentPet.guardCaptain = null; currentPet.setCombatTarget(null); if (currentPet.isAlive()) @@ -110,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { DbManager.removeFromCache(currentPet); currentPet.setCombatTarget(null); - currentPet.setOwner(null); + currentPet.guardCaptain = null; WorldGrid.RemoveWorldObject(currentPet); //currentPet.getParentZone().zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet); @@ -120,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { } else { if (currentPet.isSiege()) { currentPet.agentType = Enum.AIAgentType.MOBILE; - currentPet.setOwner(null); + + currentPet.guardCaptain = null; currentPet.setCombatTarget(null); if (currentPet.isAlive()) From 36cc23457ab809a694052fecfd5639597ccb55c0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 21:26:00 -0500 Subject: [PATCH 089/233] optimized slot for siege engines --- src/engine/gameManager/NPCManager.java | 11 ++++++++--- src/engine/jobs/EndFearJob.java | 4 ++-- src/engine/objects/AbstractCharacter.java | 1 + src/engine/objects/Mob.java | 8 ++------ src/engine/powers/poweractions/FearPowerAction.java | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index b112fe17..c9e22d57 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -341,9 +341,14 @@ public enum NPCManager { if (abstractCharacter.building.getBlueprint() != null && abstractCharacter.building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL) && abstractCharacter.building.getRank() == 8) buildingSlot = BuildingManager.getLastAvailableSlot(abstractCharacter.building); - else - buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); - + else { + if(abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob)abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { + Mob mob = (Mob)abstractCharacter; + buildingSlot = mob.guardCaptain.siegeMinionMap.size() + 1; + }else { + buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); + } + } if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); diff --git a/src/engine/jobs/EndFearJob.java b/src/engine/jobs/EndFearJob.java index fef762d5..f88a4850 100644 --- a/src/engine/jobs/EndFearJob.java +++ b/src/engine/jobs/EndFearJob.java @@ -29,7 +29,7 @@ public class EndFearJob extends AbstractEffectJob { if (this.target == null || (!(this.target instanceof Mob))) return; - ((Mob) this.target).setFearedObject(null); + ((Mob) this.target).fearedObject = null; } @Override @@ -40,6 +40,6 @@ public class EndFearJob extends AbstractEffectJob { if (this.target == null || (!(this.target instanceof Mob))) return; - ((Mob) this.target).setFearedObject(null); + ((Mob) this.target).fearedObject = null; } } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 8f4ffcf8..e890b809 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -120,6 +120,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { private float hateValue = 0; private long lastHateUpdate = 0; private byte aoecntr = 0; + public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public AbstractCharacter() { super(); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 1cfcdeaa..fc66914e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -48,7 +48,7 @@ public class Mob extends AbstractIntelligenceAgent { private static int staticID = 0; //mob specific public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); - public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); public long nextCastTime = 0; public long nextCallForHelp = 0; @@ -73,7 +73,7 @@ public class Mob extends AbstractIntelligenceAgent { private int currentID; - private AbstractWorldObject fearedObject = null; + public AbstractWorldObject fearedObject = null; private long lastAttackTime = 0; private int lastMobPowerToken = 0; private HashMap equip = null; @@ -737,10 +737,6 @@ public class Mob extends AbstractIntelligenceAgent { return this.guild.getObjectUUID(); } - public void setFearedObject(AbstractWorldObject awo) { - this.fearedObject = awo; - } - @Override public Vector3fImmutable getBindLoc() { diff --git a/src/engine/powers/poweractions/FearPowerAction.java b/src/engine/powers/poweractions/FearPowerAction.java index c1bae2ed..da352aa5 100644 --- a/src/engine/powers/poweractions/FearPowerAction.java +++ b/src/engine/powers/poweractions/FearPowerAction.java @@ -59,7 +59,7 @@ public class FearPowerAction extends AbstractPowerAction { int duration = 10 + ((int) (trains * 0.5)); String stackType = ab.getStackType(); EndFearJob efj = new EndFearJob(source, awo, stackType, trains, ab, pb, null); - ((Mob) awo).setFearedObject(source); + ((Mob) awo).fearedObject = source; JobScheduler.getInstance().scheduleJob(efj, duration * 1000); } From 61c66b0e969679655b5cdaa6e124f38222752e5a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 21:38:31 -0500 Subject: [PATCH 090/233] trebs slot in proper locations --- src/engine/gameManager/NPCManager.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index c9e22d57..154d601a 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -344,17 +344,16 @@ public enum NPCManager { else { if(abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob)abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { Mob mob = (Mob)abstractCharacter; - buildingSlot = mob.guardCaptain.siegeMinionMap.size() + 1; - }else { + buildingSlot = mob.guardCaptain.siegeMinionMap.size() + 2; + }else buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); - } } if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); // Pets are regular mobiles not hirelings (Siege engines) - - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + if(abstractCharacter.contract != null) + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived // from BuildingManager slot location data. From 6abdc68ca58442ac1f1ab22ee744c5953d0a5ca3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 21:46:44 -0500 Subject: [PATCH 091/233] removed un-needed cast to player character for pets --- src/engine/mobileAI/MobAI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index ec202e6b..d56075ca 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -1110,7 +1110,7 @@ public class MobAI { try { - if ((PlayerCharacter) mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false) + if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false) if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) mob.killCharacter("no owner"); From a43d9022fe246471162b3ec06da52e897ca553a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 22:57:11 -0400 Subject: [PATCH 092/233] Siege engine slot override. --- src/engine/gameManager/NPCManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 154d601a..24fb9d21 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -341,18 +341,21 @@ public enum NPCManager { if (abstractCharacter.building.getBlueprint() != null && abstractCharacter.building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL) && abstractCharacter.building.getRank() == 8) buildingSlot = BuildingManager.getLastAvailableSlot(abstractCharacter.building); - else { - if(abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob)abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { - Mob mob = (Mob)abstractCharacter; - buildingSlot = mob.guardCaptain.siegeMinionMap.size() + 2; - }else - buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); + else + buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); + + // Override slot for siege engines + + if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { + Mob siegeMobile = (Mob) abstractCharacter; + buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2; } + if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); // Pets are regular mobiles not hirelings (Siege engines) - if(abstractCharacter.contract != null) + if (abstractCharacter.contract != null) abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived From 3060b394ab6b2320b746a784495e488cf9027c7f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 22:10:13 -0500 Subject: [PATCH 093/233] removed siegeminion map from NPC --- src/engine/objects/Mob.java | 6 +++++- src/engine/objects/NPC.java | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index fc66914e..cc1ccb6f 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -513,7 +513,11 @@ public class Mob extends AbstractIntelligenceAgent { Mob siegeMinion; - if (artyCaptain.getSiegeMinionMap().size() == 3) + int maxSlots = 1; + if(artyCaptain.getContractID() == 839)//artillery captain for bulwark + maxSlots = 3; + + if (artyCaptain.getSiegeMinionMap().size() == maxSlots) return null; siegeMinion = new Mob(); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index ae8f63bd..f318f87e 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -50,7 +50,6 @@ public class NPC extends AbstractCharacter { // Used for thread safety public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private final ArrayList rolling = new ArrayList<>(); - private final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public ArrayList forgedItems = new ArrayList<>(); public HashMap equip = null; From 00e7a360132e791d671e50c55d6e9ff633c7d3a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 23:22:28 -0400 Subject: [PATCH 094/233] Logic fix in siege minions. --- src/engine/objects/Mob.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index cc1ccb6f..fc66914e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -513,11 +513,7 @@ public class Mob extends AbstractIntelligenceAgent { Mob siegeMinion; - int maxSlots = 1; - if(artyCaptain.getContractID() == 839)//artillery captain for bulwark - maxSlots = 3; - - if (artyCaptain.getSiegeMinionMap().size() == maxSlots) + if (artyCaptain.getSiegeMinionMap().size() == 3) return null; siegeMinion = new Mob(); From 33529404cfc95c14d989f0d5df6bd69451599cb1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 23:25:44 -0400 Subject: [PATCH 095/233] Logic fix in siege minions. --- src/engine/gameManager/NPCManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 24fb9d21..28b76552 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -348,7 +348,7 @@ public enum NPCManager { if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { Mob siegeMobile = (Mob) abstractCharacter; - buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2; + buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 1; } if (buildingSlot == -1) From 3392ec463d9c6ed494242c9a899795956b548f2e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 23:29:45 -0400 Subject: [PATCH 096/233] Removed unused methods. --- src/engine/gameManager/NPCManager.java | 8 -------- src/engine/server/world/WorldServer.java | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 28b76552..79468b9a 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -23,14 +23,6 @@ public enum NPCManager { NPC_MANAGER; public static HashMap> _runeSetMap = new HashMap<>(); - public static void LoadAllRuneSets() { - _runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); - } - - public static void LoadAllBootySets() { - LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); - } - public static void applyRuneSetEffects(Mob mob) { // Early exit diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index dc2c6fb0..d662eaa5 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -334,7 +334,7 @@ public class WorldServer { DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); Logger.info("Loading NPC and Mob Rune Sets"); - NPCManager.LoadAllRuneSets(); + NPCManager._runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); Logger.info("Loading Booty Sets"); LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); From 5196d10e5c3b4a421b9e0b77b2d0334e3dd6effa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 23:31:32 -0400 Subject: [PATCH 097/233] Logic isn't needed here. --- src/engine/objects/Mob.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index fc66914e..996ae9c7 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -513,9 +513,6 @@ public class Mob extends AbstractIntelligenceAgent { Mob siegeMinion; - if (artyCaptain.getSiegeMinionMap().size() == 3) - return null; - siegeMinion = new Mob(); siegeMinion.level = 1; From 08d0e5ff7552b6dbe3a62f941fb27f0a21766832 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 23:32:23 -0400 Subject: [PATCH 098/233] Logic isn't needed here. --- src/engine/objects/Mob.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 996ae9c7..dddf98c3 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -446,11 +446,6 @@ public class Mob extends AbstractIntelligenceAgent { Mob minionMobile; - int maxSlots = NPCManager.getMaxMinions(guardCaptain); - - if (guardCaptain.siegeMinionMap.size() == maxSlots) - return null; - minionMobile = new Mob(); minionMobile.currentID = (--Mob.staticID); From 8af989b75fc8e28356964c168e1305d2b94972b4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 27 Aug 2023 23:55:02 -0400 Subject: [PATCH 099/233] Fix is patrol logic bloc conditional. --- src/engine/objects/Mob.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index dddf98c3..bce61776 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1734,7 +1734,8 @@ public class Mob extends AbstractIntelligenceAgent { //assign 5 random patrol points for regular mobs - if (!(this.agentType.equals(AIAgentType.GUARD)) && !this.isPlayerGuard() && !this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !(this.agentType.equals(AIAgentType.CHARMED))) { + if (this.guardCaptain == null && this.isPlayerGuard == false && !isPet() == false && isNecroPet() == false) { + this.patrolPoints = new ArrayList<>(); for (int i = 0; i < 5; ++i) { From 5862039a00e67c6deb64b97acdbdf8df50ca0e2c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 28 Aug 2023 00:07:40 -0400 Subject: [PATCH 100/233] Minion added to map after runafterload. --- src/engine/objects/Mob.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index bce61776..a79bc914 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -522,10 +522,11 @@ public class Mob extends AbstractIntelligenceAgent { //siegeMinion.spawnTime = (60 * 15); siegeMinion.spawnTime = 15; + siegeMinion.runAfterLoad(); + int slot = artyCaptain.getSiegeMinionMap().size() + 1; - artyCaptain.getSiegeMinionMap().put(siegeMinion,slot); + artyCaptain.getSiegeMinionMap().put(siegeMinion, slot); - siegeMinion.runAfterLoad(); DbManager.addToCache(siegeMinion); siegeMinion.setLoc(siegeMinion.bindLoc); siegeMinion.despawn(); From 8343a98d777a6c447243fc696584af91a560bd9e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 28 Aug 2023 00:08:35 -0400 Subject: [PATCH 101/233] Minion added to map after runafterload. --- src/engine/objects/Mob.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index a79bc914..0f96e6cc 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -524,13 +524,13 @@ public class Mob extends AbstractIntelligenceAgent { siegeMinion.runAfterLoad(); - int slot = artyCaptain.getSiegeMinionMap().size() + 1; - artyCaptain.getSiegeMinionMap().put(siegeMinion, slot); - DbManager.addToCache(siegeMinion); siegeMinion.setLoc(siegeMinion.bindLoc); siegeMinion.despawn(); + int slot = artyCaptain.getSiegeMinionMap().size() + 1; + artyCaptain.getSiegeMinionMap().put(siegeMinion, slot); + return siegeMinion; } From e7e740dff1f903b40a297e9bfbc108157d3df8c5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 23:23:17 -0500 Subject: [PATCH 102/233] blocked player character specific block in minion training message handler --- .../handlers/MinionTrainingMsgHandler.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index a6aa404e..ba383580 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -74,16 +74,17 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { DbManager.removeFromCache(toRemove); + if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; - PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; - - if (petOwner != null) { - petOwner.setPet(null); + if (petOwner != null) { + petOwner.setPet(null); - toRemove.guardCaptain = null; - PetMsg petMsg = new PetMsg(5, null); - Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + toRemove.guardCaptain = null; + PetMsg petMsg = new PetMsg(5, null); + Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + } } // we Found the move to remove, lets break the for loop so it doesnt look for more. From 60ca3f9c34724fd324332704102d41b2534b5952 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 23:42:04 -0500 Subject: [PATCH 103/233] remove siege minion --- src/engine/devcmd/cmds/PurgeObjectsCmd.java | 4 ++-- src/engine/devcmd/cmds/RemoveObjectCmd.java | 4 ++-- .../net/client/handlers/MinionTrainingMsgHandler.java | 7 +++---- src/engine/net/client/msg/ManageNPCMsg.java | 2 +- src/engine/objects/Mob.java | 4 ++-- src/engine/objects/NPC.java | 4 ---- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index 7a022384..c0b318c7 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -59,7 +59,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { if (npc != null) { - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); //Mob.getRespawnMap().remove(mob); @@ -151,7 +151,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { if (npc != null) { - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); //Mob.getRespawnMap().remove(mob); diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index 6d13d2b1..c1ee4f85 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -154,7 +154,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { mobA = (Mob) ac; if (npc != null) { - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); //Mob.getRespawnMap().remove(mob); @@ -209,7 +209,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { if (npc.building != null) npc.building.getHirelings().remove(npc); - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); if (mob.getParentZone() != null) diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index ba383580..f9007eb9 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -41,7 +41,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (player == null) return true; - if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) { NPC npc = NPC.getFromCache(minionMsg.getNpcID()); @@ -62,10 +61,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { Mob toRemove = Mob.getFromCache(minionMsg.getUUID()); - if (!npc.getSiegeMinionMap().containsKey(toRemove)) + if (!npc.siegeMinionMap.containsKey(toRemove)) return true; - npc.getSiegeMinionMap().remove(toRemove); + npc.siegeMinionMap.remove(toRemove); WorldGrid.RemoveWorldObject(toRemove); @@ -118,7 +117,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (npc.getContractID() == 842) maxSlots = 1; - if (npc.getSiegeMinionMap().size() == maxSlots) + if (npc.siegeMinionMap.size() == maxSlots) return true; int mobBase; diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index c6c07279..d68ecb04 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -343,7 +343,7 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(0); //runemaster list //artillery captain list - ConcurrentHashMap siegeMinions = npc.getSiegeMinionMap(); + ConcurrentHashMap siegeMinions = npc.siegeMinionMap; writer.putInt(1 + siegeMinions.size()); serializeBulwarkList(writer, 1); //Trebuchet //serializeBulwarkList(writer, 2); //Ballista diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 0f96e6cc..1d275bd1 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -528,8 +528,8 @@ public class Mob extends AbstractIntelligenceAgent { siegeMinion.setLoc(siegeMinion.bindLoc); siegeMinion.despawn(); - int slot = artyCaptain.getSiegeMinionMap().size() + 1; - artyCaptain.getSiegeMinionMap().put(siegeMinion, slot); + int slot = artyCaptain.siegeMinionMap.size() + 1; + artyCaptain.siegeMinionMap.put(siegeMinion, slot); return siegeMinion; } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index f318f87e..07775e33 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1103,10 +1103,6 @@ public class NPC extends AbstractCharacter { return (int) time; } - public ConcurrentHashMap getSiegeMinionMap() { - return siegeMinionMap; - } - public boolean remove() { Building building; From 9a3c5c3f40b96ff9bccbba5100bf00feeb0369b1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 28 Aug 2023 00:46:39 -0400 Subject: [PATCH 104/233] Siege minion assigned UUID. --- src/engine/objects/Mob.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 1d275bd1..9b521388 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -509,6 +509,7 @@ public class Mob extends AbstractIntelligenceAgent { Mob siegeMinion; siegeMinion = new Mob(); + siegeMinion.currentID = (--Mob.staticID); siegeMinion.level = 1; siegeMinion.loadID = loadID; From e78aea573509df7ad36cf970c6d2687ab66cd1b3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 27 Aug 2023 23:52:40 -0500 Subject: [PATCH 105/233] Assign patrol points added as static method to NPC manager --- src/engine/gameManager/NPCManager.java | 21 +++++++++++++++++++++ src/engine/objects/Mob.java | 20 +------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 79468b9a..07553a4d 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -403,4 +403,25 @@ public enum NPCManager { return maxSlots; } + public static void AssignPatrolPoints(Mob mob) { + mob.patrolPoints = new ArrayList<>(); + + for (int i = 0; i < 5; ++i) { + float patrolRadius = mob.getSpawnRadius(); + + if (patrolRadius > 256) + patrolRadius = 256; + + if (patrolRadius < 60) + patrolRadius = 60; + + Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius); + mob.patrolPoints.add(newPatrolPoint); + + if (i == 1) { + mob.loc = newPatrolPoint; + mob.endLoc = newPatrolPoint; + } + } + } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 1d275bd1..a94db668 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1737,25 +1737,7 @@ public class Mob extends AbstractIntelligenceAgent { if (this.guardCaptain == null && this.isPlayerGuard == false && !isPet() == false && isNecroPet() == false) { - this.patrolPoints = new ArrayList<>(); - - for (int i = 0; i < 5; ++i) { - float patrolRadius = this.getSpawnRadius(); - - if (patrolRadius > 256) - patrolRadius = 256; - - if (patrolRadius < 60) - patrolRadius = 60; - - Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(this.getBindLoc(), patrolRadius); - this.patrolPoints.add(newPatrolPoint); - - if (i == 1) { - this.loc = newPatrolPoint; - this.endLoc = newPatrolPoint; - } - } + NPCManager.AssignPatrolPoints(this); } this.deathTime = 0; From d59f9857ce0d426c1cd749164c505660d0e953ef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 28 Aug 2023 00:56:13 -0400 Subject: [PATCH 106/233] Cleanup in pet minion --- src/engine/gameManager/NPCManager.java | 2 +- src/engine/objects/Mob.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 07553a4d..98549265 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -340,7 +340,7 @@ public enum NPCManager { if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { Mob siegeMobile = (Mob) abstractCharacter; - buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 1; + buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2; } if (buildingSlot == -1) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index eb08b78a..8d6c0736 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -33,7 +33,6 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -44,7 +43,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; public class Mob extends AbstractIntelligenceAgent { - private static final ReentrantReadWriteLock createLock = new ReentrantReadWriteLock(); private static int staticID = 0; //mob specific public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); @@ -535,14 +533,14 @@ public class Mob extends AbstractIntelligenceAgent { return siegeMinion; } - public static Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { - - Mob petMinion = new Mob(); + public static synchronized Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { if (petOwner == null) return null; - createLock.writeLock().lock(); + Mob petMinion = new Mob(); + + petMinion.currentID = (--Mob.staticID); petMinion.level = (short) (level + 20); petMinion.loadID = loadID; @@ -556,11 +554,12 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.behaviourType = MobBehaviourType.Pet1; petMinion.firstName = ""; petMinion.lastName = ""; + petMinion.despawned = false; petMinion.runAfterLoad(); DbManager.addToCache(petMinion); - createLock.writeLock().unlock(); petMinion.setLoc(petMinion.bindLoc); + return petMinion; } public static Mob getMob(int id) { From b93a47acc0e72a4240d075e2091d9700c6055cf6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 20:12:48 -0500 Subject: [PATCH 107/233] pet death and dismissal fix --- src/engine/objects/Mob.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 8d6c0736..b18d1ecd 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -461,6 +461,7 @@ public class Mob extends AbstractIntelligenceAgent { minionMobile.guardCaptain = guardCaptain; minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion; + minionMobile.agentType = AIAgentType.GUARD; minionMobile.isPlayerGuard = true; minionMobile.guardedCity = guardCaptain.guardedCity; minionMobile.patrolPoints = guardCaptain.building.patrolPoints; @@ -552,6 +553,7 @@ public class Mob extends AbstractIntelligenceAgent { petMinion.healthMax = MobBase.getMobBase(loadID).getHealthMax() * (petMinion.level * 0.5f); petMinion.health.set(petMinion.healthMax); petMinion.behaviourType = MobBehaviourType.Pet1; + petMinion.agentType = AIAgentType.PET; petMinion.firstName = ""; petMinion.lastName = ""; From 4284757035ffdf2ffe9cb90068caaae43680e969 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 20:16:00 -0500 Subject: [PATCH 108/233] pet level set in run after load removed --- 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 b18d1ecd..b692c01e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1636,7 +1636,7 @@ public class Mob extends AbstractIntelligenceAgent { // Don't override level for guard minions if (this.contract == null) - if (!this.behaviourType.equals(MobBehaviourType.GuardMinion)) + if (!this.behaviourType.equals(MobBehaviourType.GuardMinion) && !this.agentType.equals(AIAgentType.PET)) this.level = (short) this.mobBase.getLevel(); //set bonuses From db5b9882757d143a63fd8134006d4ce6dea86bc4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 20:18:05 -0500 Subject: [PATCH 109/233] usage of AIAgentType for pet checks in run after load --- src/engine/objects/Mob.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b692c01e..34d67481 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1633,10 +1633,10 @@ public class Mob extends AbstractIntelligenceAgent { this.mana.set(this.manaMax); this.stamina.set(this.staminaMax); - // Don't override level for guard minions + // Don't override level for guard minions or pets if (this.contract == null) - if (!this.behaviourType.equals(MobBehaviourType.GuardMinion) && !this.agentType.equals(AIAgentType.PET)) + if (!this.agentType.equals(AIAgentType.GUARD) && !this.agentType.equals(AIAgentType.PET)) this.level = (short) this.mobBase.getLevel(); //set bonuses @@ -1667,7 +1667,7 @@ public class Mob extends AbstractIntelligenceAgent { // Do not adjust a pet's bindloc. - if (!this.behaviourType.equals(MobBehaviourType.Pet1)) + if (!this.agentType.equals(AIAgentType.PET)) this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); } else { From 69fdddfc71b6b334082b744cd140a97e80bc7e03 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 21:01:00 -0500 Subject: [PATCH 110/233] hate value fix --- .../InterestManagement/InterestManager.java | 4 +-- src/engine/devcmd/cmds/aiInfoCmd.java | 4 +-- src/engine/gameManager/CombatManager.java | 3 ++- src/engine/gameManager/PowersManager.java | 4 --- src/engine/mobileAI/MobAI.java | 14 +++++----- src/engine/objects/AbstractCharacter.java | 24 ----------------- src/engine/objects/Mob.java | 27 +------------------ .../poweractions/ApplyEffectPowerAction.java | 5 ++-- 8 files changed, 17 insertions(+), 68 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index ab6ea532..2c70765c 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -467,7 +467,7 @@ public enum InterestManager implements Runnable { if (awonpc.despawned == true) continue; - awonpc.playerAgroMap.put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), 0f); ((Mob) awonpc).setCombatTarget(null); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); @@ -480,7 +480,7 @@ public enum InterestManager implements Runnable { if (!awonpc.isAlive()) continue; - awonpc.playerAgroMap.put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), 0f); if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE))) ((Mob) awonpc).setCombatTarget(null); diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index 7d8c6785..4a524c34 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -77,8 +77,8 @@ public class aiInfoCmd extends AbstractDevCmd { if (mob.playerAgroMap.size() > 0) { output += "Players Loaded:" + newline; } - for (Map.Entry entry : mob.playerAgroMap.entrySet()) { - output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline; + for (Map.Entry entry : mob.playerAgroMap.entrySet()) { + output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline; } if (mob.getCombatTarget() != null) output += "Current Target: " + mob.getCombatTarget().getName() + newline; diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 0587e384..53347204 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -826,7 +826,8 @@ public enum CombatManager { damage *= 2.5f; //increase damage if sitting if (tarAc.getObjectType() == GameObjectType.Mob) { - ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER); + if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)) + ((Mob)tarAc).playerAgroMap.put(ac.getObjectUUID(), ((Mob) tarAc).playerAgroMap.get(ac.getObjectUUID()) + damage); ((Mob) tarAc).handleDirectAggro(ac); } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 9e15abc2..b66f1dd0 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -839,8 +839,6 @@ public enum PowersManager { return; } - playerCharacter.setHateValue(pb.getHateValue(trains)); - //Send Cast Message. // PerformActionMsg castMsg = new PerformActionMsg(msg); // castMsg.setNumTrains(9999); @@ -891,8 +889,6 @@ public enum PowersManager { //Power is aiding a target, handle aggro if combat target is a Mob. if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pcTarget = (PlayerCharacter) target; - if (!pb.isHarmful()) - Mob.HandleAssistedAggro(playerCharacter, pcTarget); } // update target of used power timer diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index d56075ca..6aed514a 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -708,7 +708,7 @@ public class MobAI { if (!aiAgent.isAlive()) return; - ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; for (Entry playerEntry : loadedPlayers.entrySet()) { @@ -956,8 +956,8 @@ public class MobAI { PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - for (Entry playerEntry : mob.playerAgroMap.entrySet()) - PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); + for (Integer playerEntry : mob.playerAgroMap.keySet()) + mob.playerAgroMap.put(playerEntry,0f); } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); @@ -1204,7 +1204,7 @@ public class MobAI { if (!mob.isAlive()) return; - ConcurrentHashMap loadedPlayers = mob.playerAgroMap; + ConcurrentHashMap loadedPlayers = mob.playerAgroMap; for (Entry playerEntry : loadedPlayers.entrySet()) { @@ -1364,7 +1364,7 @@ public class MobAI { float CurrentHateValue = 0; if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) - CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); + CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue(); AbstractWorldObject mostHatedTarget = null; @@ -1375,8 +1375,8 @@ public class MobAI { if (potentialTarget.equals(mob.getCombatTarget())) continue; - if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { - CurrentHateValue = potentialTarget.getHateValue(); + if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { + CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue(); mostHatedTarget = potentialTarget; } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index e890b809..3d788dbe 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -117,7 +117,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { protected boolean movingUp = false; private float desiredAltitude = 0; private long takeOffTime = 0; - private float hateValue = 0; private long lastHateUpdate = 0; private byte aoecntr = 0; public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); @@ -1767,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.inBuildingID = inBuildingID; } - public float getHateValue() { - if (this.hateValue <= 0) { - this.hateValue = 0; - return hateValue; - } - - if (this.lastHateUpdate == 0) { - this.lastHateUpdate = System.currentTimeMillis(); - return this.hateValue; - } - long duration = System.currentTimeMillis() - this.lastHateUpdate; - //convert duration to seconds and multiply Hate Delimiter. - float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER; - this.hateValue -= modAmount; - this.lastHateUpdate = System.currentTimeMillis(); - return this.hateValue; - } - - public void setHateValue(float hateValue) { - this.lastHateUpdate = System.currentTimeMillis(); - this.hateValue = hateValue; - } - public int getInFloorID() { return inFloorID; } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 34d67481..97acd7ee 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -45,7 +45,7 @@ public class Mob extends AbstractIntelligenceAgent { private static int staticID = 0; //mob specific - public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); + public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); //key = Player value = hate value public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); public long nextCastTime = 0; @@ -589,28 +589,6 @@ public class Mob extends AbstractIntelligenceAgent { return skill.getModifiedAmount(); } - public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { - - HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobAIThread.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); - - for (AbstractWorldObject awo : mobsInRange) { - Mob mob = (Mob) awo; - - //Mob is not attacking anyone, skip. - if (mob.getCombatTarget() == null) - continue; - - //Mob not attacking target's target, let's not be failmu and skip this target. - if (mob.getCombatTarget() != target) - continue; - - //target is mob's combat target, LETS GO. - - if (source.getHateValue() > target.getHateValue()) - mob.setCombatTarget(source); - } - } - public static void submitUpgradeJob(Mob mob) { if (mob.getUpgradeDateTime() == null) { @@ -1792,9 +1770,6 @@ public class Mob extends AbstractIntelligenceAgent { if (player.getObjectUUID() == this.getCombatTarget().getObjectUUID()) return; - if (this.getCombatTarget().getObjectType() == GameObjectType.PlayerCharacter) - if (ac.getHateValue() > ((PlayerCharacter) this.getCombatTarget()).getHateValue()) - this.setCombatTarget(player); } public void setRank(int newRank) { diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index d96d3a54..3f2a9c4b 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -127,10 +127,11 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { if (this.effectID.equals("TAUNT")) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) { - ((Mob) awo).setCombatTarget(source); + //((Mob) awo).setCombatTarget(source); LOL DUMB + ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); DispatchMessage.sendToAllInRange(source, msg); - ((Mob)awo).refresh(); + //((Mob)awo).refresh(); why the fuck? causes a blink effect and players to lose target of the mob } } if (awo != null && awo.getObjectType() == GameObjectType.Mob) { From 5c3c552288e1093ecca7609eff15d36743e40a82 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 21:17:44 -0500 Subject: [PATCH 111/233] usage of AIAgentType for default patrol points --- src/engine/Enum.java | 2 ++ src/engine/objects/Mob.java | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index d9d2527b..aec9e3c6 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2879,6 +2879,8 @@ public class Enum { MOBILE, PET, CHARMED, + + SIEGEENGINE, GUARD; } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 97acd7ee..1af15ce8 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -71,6 +71,7 @@ public class Mob extends AbstractIntelligenceAgent { private int currentID; + //TODO implement feared object system public AbstractWorldObject fearedObject = null; private long lastAttackTime = 0; private int lastMobPowerToken = 0; @@ -87,6 +88,7 @@ public class Mob extends AbstractIntelligenceAgent { this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.bindLoc = Vector3fImmutable.ZERO; this.gridObjectType = GridObjectType.DYNAMIC; + this.agentType = AIAgentType.MOBILE; } @@ -153,6 +155,7 @@ public class Mob extends AbstractIntelligenceAgent { this.currentID = this.dbID; + this.agentType = AIAgentType.MOBILE; } catch (Exception e) { Logger.error(e + " " + this.dbID); } @@ -429,6 +432,7 @@ public class Mob extends AbstractIntelligenceAgent { Mob mob; + mobile.agentType = AIAgentType.GUARD; try { mob = DbManager.MobQueries.PERSIST(mobile); @@ -518,6 +522,7 @@ public class Mob extends AbstractIntelligenceAgent { siegeMinion.guardCaptain = artyCaptain; siegeMinion.parentZoneUUID = artyCaptain.parentZoneUUID; siegeMinion.behaviourType = MobBehaviourType.SiegeEngine; + siegeMinion.agentType = AIAgentType.SIEGEENGINE; siegeMinion.bindLoc = Vector3fImmutable.ZERO; //siegeMinion.spawnTime = (60 * 15); siegeMinion.spawnTime = 15; @@ -1715,7 +1720,7 @@ public class Mob extends AbstractIntelligenceAgent { //assign 5 random patrol points for regular mobs - if (this.guardCaptain == null && this.isPlayerGuard == false && !isPet() == false && isNecroPet() == false) { + if (this.agentType.equals(AIAgentType.MOBILE)) { NPCManager.AssignPatrolPoints(this); } From a50a2430bac75aa5a766cbf80fe90fe0cff7f876 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 21:49:02 -0500 Subject: [PATCH 112/233] hate value for chants to affect mobs in range --- .../poweractions/ApplyEffectPowerAction.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index 3f2a9c4b..a9eb6c89 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -11,6 +11,7 @@ package engine.powers.poweractions; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; +import engine.InterestManagement.WorldGrid; import engine.gameManager.ChatManager; import engine.jobs.ChantJob; import engine.jobs.DeferredPowerJob; @@ -22,6 +23,7 @@ import engine.objects.*; import engine.powers.ActionsBase; import engine.powers.EffectsBase; import engine.powers.PowersBase; +import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.sql.ResultSet; @@ -117,21 +119,12 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { awo.addEffect(stackType, duration, eff, effect, trains); } else awo.applyAllBonuses(); - // //TODO if chant, start cycle - // if (pb.isChant() && source.equals(awo)) { - // ChantJob cj = new ChantJob(source, awo, stackType, trains, ab, pb, effect, eff); - // source.setLastChant((int)(pb.getChantDuration()-2) * 1000, cj); - // eff.setChant(true); - // } if (this.effectID.equals("TAUNT")) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) { - //((Mob) awo).setCombatTarget(source); LOL DUMB - ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); DispatchMessage.sendToAllInRange(source, msg); - //((Mob)awo).refresh(); why the fuck? causes a blink effect and players to lose target of the mob } } if (awo != null && awo.getObjectType() == GameObjectType.Mob) { @@ -141,7 +134,21 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { } this.effect.startEffect(source, awo, trains, eff); } + //apply effects to mobs within range for chants + if(pb.isChant){ + for(AbstractGameObject ago : WorldGrid.getObjectsInRangePartial(awo.loc,pb.range, MBServerStatics.MASK_MOB)){ + Mob mob = (Mob)ago; + if(mob.playerAgroMap.containsKey(source.getObjectUUID())) + mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue); + } + }else { + if (awo != null && awo.getObjectType() == GameObjectType.Mob) { + Mob mob = (Mob) awo; + if (mob.playerAgroMap.containsKey(source.getObjectUUID())) + mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue); + } + } } protected void _applyEffectForItem(Item item, int trains) { From 8a617c3008d8b88e8526a648bf05344f7ba5353a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 30 Aug 2023 15:33:55 -0400 Subject: [PATCH 113/233] Siege minion spawn time set to 15m. --- src/engine/objects/Mob.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 1af15ce8..c9853696 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -20,7 +20,6 @@ import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; import engine.math.Bounds; import engine.math.Vector3fImmutable; -import engine.mobileAI.Threads.MobAIThread; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -34,7 +33,6 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -524,8 +522,7 @@ public class Mob extends AbstractIntelligenceAgent { siegeMinion.behaviourType = MobBehaviourType.SiegeEngine; siegeMinion.agentType = AIAgentType.SIEGEENGINE; siegeMinion.bindLoc = Vector3fImmutable.ZERO; - //siegeMinion.spawnTime = (60 * 15); - siegeMinion.spawnTime = 15; + siegeMinion.spawnTime = (60 * 15); siegeMinion.runAfterLoad(); From dbf164bfb2a2508c1d97b4663b08d63e0770f71c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 30 Aug 2023 15:47:08 -0400 Subject: [PATCH 114/233] bonus code removal --- .../client/handlers/OrderNPCMsgHandler.java | 8 -------- src/engine/objects/Mob.java | 19 ++++++------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index a56ecaa1..ec62bd25 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -212,10 +212,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { return; } - for (AbstractCharacter guard : building.getHirelings().keySet()) { - if (guard.getObjectType() == GameObjectType.Mob) - ((Mob) guard).setPatrolPointIndex(0); - } } else if (building.getPatrolPoints() != null) ClearPatrolPoints(building.getObjectUUID()); @@ -223,10 +219,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { AddSentryPoints(building.getObjectUUID(), orderNpcMsg.getSentryPoints()); } else if (building.getSentryPoints() != null) ClearSentryPoints(building.getObjectUUID()); - - // Dispatch dispatch = Dispatch.borrow(pc, msg); - // DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - } private static void processUpgradeNPC(PlayerCharacter player, AbstractCharacter abstractCharacter) { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index c9853696..b33d7368 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -893,15 +893,16 @@ public class Mob extends AbstractIntelligenceAgent { try { //resync corpses - //this.setLoc(this.getMovementLoc()); + if (this.behaviourType.equals(MobBehaviourType.SiegeEngine)) { this.deathTime = System.currentTimeMillis(); - //this.state = STATE.Dead; + try { this.clearEffects(); } catch (Exception e) { Logger.error(e.getMessage()); } + this.setCombatTarget(null); this.hasLoot = false; this.playerAgroMap.clear(); @@ -911,7 +912,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.isPet()) { - PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain; if (petOwner != null) { @@ -927,25 +927,21 @@ public class Mob extends AbstractIntelligenceAgent { } } else if (this.isPet() || this.isNecroPet()) { - //this.state = STATE.Disabled; this.setCombatTarget(null); this.hasLoot = false; - - //if (this.parentZone != null) - //this.parentZone.zoneMobSet.remove(this); ZoneManager.getSeaFloor().zoneMobSet.remove(this); + try { this.clearEffects(); } catch (Exception e) { Logger.error(e.getMessage()); } + this.playerAgroMap.clear(); WorldGrid.RemoveWorldObject(this); DbManager.removeFromCache(this); - - PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain; if (petOwner != null) { @@ -959,6 +955,7 @@ public class Mob extends AbstractIntelligenceAgent { } else { //cleanup effects + playerAgroMap.clear(); if (!this.isPlayerGuard && this.equip != null) @@ -1055,7 +1052,6 @@ public class Mob extends AbstractIntelligenceAgent { @Override public void updateDatabase() { - // DbManager.MobQueries.updateDatabase(this); } public void refresh() { @@ -1837,9 +1833,6 @@ public class Mob extends AbstractIntelligenceAgent { return isPlayerGuard; } - public void setPatrolPointIndex(int patrolPointIndex) { - } - public int getLastMobPowerToken() { return lastMobPowerToken; } From 6641651f3ce25b2a87616683550e9e0eb11fd34a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 31 Aug 2023 07:27:03 -0400 Subject: [PATCH 115/233] Unused method removed. --- src/engine/objects/Mob.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index b33d7368..00bdfb28 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -695,14 +695,6 @@ public class Mob extends AbstractIntelligenceAgent { return this.parentZone; } - public int getParentZoneUUID() { - - if (this.parentZone != null) - return this.parentZone.getObjectUUID(); - - return 0; - } - @Override public int getGuildUUID() { From 668df83e330e7522cd355266f6bb9adb25720fa1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 09:36:10 -0600 Subject: [PATCH 116/233] boxed character fix, safezone equipment damage fix, trade fix, creation experience fix, sub guild limits removed --- .../InterestManagement/InterestManager.java | 21 +++++++++++++++++++ src/engine/objects/CharacterItemManager.java | 9 ++++---- src/engine/objects/Guild.java | 19 +++++++---------- src/engine/objects/PlayerCharacter.java | 5 +++++ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index 2c70765c..923fb08c 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -525,6 +525,27 @@ public enum InterestManager implements Runnable { updateStaticList(player, origin); updateMobileList(player, origin); + if(player.level < 10) { + player.setLevel((short) 10); + MobLoot ml = new MobLoot(player,ItemBase.getItemBase(980066),false); + ml.promoteToItem(player); + player.getCharItemManager().addGoldToInventory(50000, true); + } + + for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ + if(pc.isActive() == false) + continue; + if(pc.isEnteredWorld() == false) + continue; + if(origin.machineID.equals(pc.getClientConnection().machineID)){ + //add deatshroud effect + if(pc.isBoxed == true) + continue; + player.isBoxed = true; + return; + } + } + } public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) { diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index b4b6fcfa..3f8b4907 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -12,10 +12,7 @@ package engine.objects; import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.ItemType; -import engine.gameManager.BuildingManager; -import engine.gameManager.ChatManager; -import engine.gameManager.ConfigManager; -import engine.gameManager.DbManager; +import engine.gameManager.*; import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -2435,6 +2432,10 @@ public class CharacterItemManager { if (item == null || amount < 1 || amount > 5) return; + if(ZoneManager.findSmallestZone(this.getOwner().loc).getSafeZone() == 1){ + return; + } + //verify the item is equipped by this player int slot = item.getEquipSlot(); if (!this.equipped.containsKey(slot)) diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 154e286a..cfcfe83d 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -730,32 +730,29 @@ public class Guild extends AbstractWorldObject { public boolean canSubAGuild(Guild toSub) { - boolean canSub; - + boolean canSubToNation; + boolean canAcceptSub; if (this.equals(toSub)) return false; switch (this.guildState) { case Nation: case Sovereign: - canSub = true; + canAcceptSub = true; break; default: - canSub = false; + canAcceptSub = false; } switch (toSub.guildState) { case Errant: case Sovereign: - canSub = true; + canSubToNation = true; break; default: - canSub = false; - } - City nationCap = City.getCity(nation.cityUUID); - if (nation.getSubGuildList().size() >= nationCap.getRank()) { - canSub = false; + canSubToNation = false; } - return canSub; + + return canAcceptSub && canSubToNation; } public int getRealmsOwnedFlag() { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 92cdf909..b8c6b117 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -174,6 +174,8 @@ public class PlayerCharacter extends AbstractCharacter { private boolean dirtyLoad = true; private final ReadWriteLock dirtyLock = new ReentrantReadWriteLock(true); + public boolean isBoxed = false; + /** * No Id Constructor */ @@ -4811,6 +4813,9 @@ public class PlayerCharacter extends AbstractCharacter { this.safeZone = this.isInSafeZone(); + if(this.isBoxed == true && this.containsEffect(1672601862) == false) + PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); + } catch (Exception e) { Logger.error(e); } finally { From 3360a034b2d3382190c47a4582ac5a32d81a5fbb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 16:59:46 -0600 Subject: [PATCH 117/233] maintenenace only ran for ToL, 3,000,000 cost, recycling daily when payment isnt received --- .../gameManager/MaintenanceManager.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/MaintenanceManager.java b/src/engine/gameManager/MaintenanceManager.java index f92d531e..c657b124 100644 --- a/src/engine/gameManager/MaintenanceManager.java +++ b/src/engine/gameManager/MaintenanceManager.java @@ -39,7 +39,7 @@ public enum MaintenanceManager { // Build list of buildings to apply maintenance on. - buildingList = new ArrayList(DbManager.getList(Enum.GameObjectType.Building)); + buildingList = new ArrayList(DbManager.getList(Enum.GameObjectType.City)); maintList = buildMaintList(buildingList); // Deduct upkeep and build list of buildings @@ -53,7 +53,10 @@ public enum MaintenanceManager { // Reset maintenance dates for these buildings for (Building building : maintList) { - setMaintDateTime(building, LocalDateTime.now().plusDays(7)); + if(derankList.contains(building) == false) + setMaintDateTime(building, LocalDateTime.now().plusDays(7)); + else + setMaintDateTime(building, LocalDateTime.now().plusDays(1)); } // Derak or destroy buildings that did not @@ -74,7 +77,10 @@ public enum MaintenanceManager { for (AbstractGameObject gameObject : buildingList) { - Building building = (Building) gameObject; + Building building = ((City)gameObject).getTOL();//(Building) gameObject; + + if(building == null) + continue; // No maintenance on NPC owned buildings (Cache loaded) @@ -154,7 +160,8 @@ public enum MaintenanceManager { // Cache maintenance cost value - maintCost = building.getMaintCost(); + //maintCost = building.getMaintCost(); + maintCost = 3000000; // Something went wrong. Missing buildinggroup from switch? @@ -225,9 +232,9 @@ public enum MaintenanceManager { // Add cash back to strongbox for lost rank if the building isn't being destroyed // and it's not an R8 deranking - if ((building.getRank() > 1) && (building.getRank() < 8)) { - building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7))); - } + //if ((building.getRank() > 1) && (building.getRank() < 8)) { + // building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7))); + //} return false; // Early exit for having failed to meet maintenance } From b583034b4e998a6596a4246e364c4f31ba299b49 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 17:01:42 -0600 Subject: [PATCH 118/233] hotzone removed from game --- src/engine/server/world/WorldServer.java | 2 +- src/engine/workthreads/HourlyJobThread.java | 30 ++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index d662eaa5..d3add44a 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -436,7 +436,7 @@ public class WorldServer { DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT(); //pick a startup Hotzone - ZoneManager.generateAndSetRandomHotzone(); + //ZoneManager.generateAndSetRandomHotzone(); Logger.info("Loading All Players from database to Server Cache"); long start = System.currentTimeMillis(); diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index dbf17e0c..eabd71f1 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -189,28 +189,28 @@ public class HourlyJobThread implements Runnable { Logger.info("Hourly job is now running."); - try { + //try { // Use the same hotZone this hour up and until // the HotZone_Duration from the ConfigManager - if (ZoneManager.hotZone == null) - ZoneManager.generateAndSetRandomHotzone(); - else - ZoneManager.hotZoneCycle = ZoneManager.hotZoneCycle + 1; + //if (ZoneManager.hotZone == null) + // ZoneManager.generateAndSetRandomHotzone(); + //else + // ZoneManager.hotZoneCycle = ZoneManager.hotZoneCycle + 1; - if (ZoneManager.hotZoneCycle > Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue())) - ZoneManager.generateAndSetRandomHotzone(); + //if (ZoneManager.hotZoneCycle > Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue())) + // ZoneManager.generateAndSetRandomHotzone(); - if (ZoneManager.hotZone == null) { - Logger.error("Null HotZone returned from ZoneManager"); - } else { - Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName()); - } + //if (ZoneManager.hotZone == null) { + // Logger.error("Null HotZone returned from ZoneManager"); + //} else { + // Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName()); + //} - } catch (Exception e) { - Logger.error(e.toString()); - } + //} catch (Exception e) { + // Logger.error(e.toString()); + //} // Open or Close mines for the current mine window. From c0ec747e431ecdd859e0c0acf5e34791e00c8672 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 17:12:43 -0600 Subject: [PATCH 119/233] any mob over level 30 has a small chance to drop glass --- src/engine/gameManager/LootManager.java | 78 ++++++++++--------------- src/engine/objects/ItemFactory.java | 4 +- 2 files changed, 34 insertions(+), 48 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a569324d..eebeda23 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -68,16 +68,13 @@ public enum LootManager { public static void GenerateMobLoot(Mob mob) { - //determine if mob is in hotzone - boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); - //iterate the booty sets if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true) - RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone); + RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob); if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true) - RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); + RunBootySet(_bootySetMap.get(mob.bootySet), mob); //lastly, check mobs inventory for godly or disc runes to send a server announcement for (Item it : mob.getInventory()) { @@ -95,38 +92,33 @@ public enum LootManager { } - private static void RunBootySet(ArrayList entries, Mob mob, boolean inHotzone) { + private static void RunBootySet(ArrayList entries, Mob mob) { - boolean hotzoneWasRan = false; - float dropRate = 1.0f; + float dropRate = NORMAL_DROP_RATE; // Iterate all entries in this bootySet and process accordingly + if (mob.level >= 30) { + if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { + ItemTableEntry tableRow = ItemTableEntry.rollTable(126, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + if (tableRow != null) { + + int itemUUID = tableRow.cacheID; + if (itemUUID != 0) { + + MobLoot glassItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + } + } + } + } for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": - GenerateGoldDrop(mob, bse, inHotzone); + GenerateGoldDrop(mob, bse); break; case "LOOT": - - if (mob.getSafeZone() == false) - dropRate = LootManager.NORMAL_DROP_RATE; - - if (inHotzone == true) - dropRate = LootManager.HOTZONE_DROP_RATE; - if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) - GenerateLootDrop(mob, bse.genTable, false); //generate normal loot drop - - // Generate hotzone loot if in hotzone - // Only one bite at the hotzone apple per bootyset. - - if (inHotzone == true && hotzoneWasRan == false) - if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table - hotzoneWasRan = true; - } - + GenerateLootDrop(mob, bse.genTable); //generate normal loot drop break; case "ITEM": GenerateInventoryDrop(mob, bse); @@ -135,7 +127,7 @@ public enum LootManager { } } - public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) { + public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob) { if (mob == null || _genTables.containsKey(genTableID) == false) return null; @@ -160,7 +152,7 @@ public enum LootManager { if(mob.getObjectType().ordinal() == 52) { //52 = player character itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); } else{ - itemTableRoll = TableRoll(mob.level, inHotzone); + itemTableRoll = TableRoll(mob.level); } ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); if (tableRow == null) @@ -182,7 +174,7 @@ public enum LootManager { if(selectedRow.pModTable != 0){ try { - outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); + outItem = GeneratePrefix(mob, outItem, genTableID, genRoll); outItem.setIsID(false); } catch (Exception e) { Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); @@ -190,7 +182,7 @@ public enum LootManager { } if(selectedRow.sModTable != 0){ try { - outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); + outItem = GenerateSuffix(mob, outItem, genTableID, genRoll); outItem.setIsID(false); } catch (Exception e) { Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); @@ -199,7 +191,7 @@ public enum LootManager { return outItem; } - private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { + private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) { GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); @@ -216,7 +208,7 @@ public enum LootManager { if(mob.getObjectType().ordinal() == 52) { prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); } else{ - prefixTableRoll = TableRoll(mob.level, inHotzone); + prefixTableRoll = TableRoll(mob.level); } ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); @@ -231,7 +223,7 @@ public enum LootManager { return inItem; } - private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { + private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) { GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); @@ -248,7 +240,7 @@ public enum LootManager { if(mob.getObjectType().ordinal() == 52) { suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); } else{ - suffixTableRoll = TableRoll(mob.level, inHotzone); + suffixTableRoll = TableRoll(mob.level); } ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); @@ -263,7 +255,7 @@ public enum LootManager { return inItem; } - public static int TableRoll(int mobLevel, Boolean inHotzone) { + public static int TableRoll(int mobLevel) { if (mobLevel > 65) mobLevel = 65; @@ -278,15 +270,12 @@ public enum LootManager { if (min < 70) min = 70; - if (inHotzone) - min += mobLevel; - int roll = ThreadLocalRandom.current().nextInt(min, max + 1); return roll; } - public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { + public static void GenerateGoldDrop(Mob mob, BootySetEntry bse) { int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); @@ -301,10 +290,7 @@ public enum LootManager { int low = bse.lowGold; int gold = ThreadLocalRandom.current().nextInt(low, high + 1); - if (inHotzone == true) - gold = (int) (gold * HOTZONE_GOLD_RATE); - else - gold = (int) (gold * NORMAL_GOLD_RATE); + gold = (int) (gold * NORMAL_GOLD_RATE); if (gold > 0) { MobLoot goldAmount = new MobLoot(mob, gold); @@ -313,11 +299,11 @@ public enum LootManager { } - public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) { + public static void GenerateLootDrop(Mob mob, int tableID) { try { - MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); + MobLoot toAdd = getGenTableItem(tableID, mob); if (toAdd != null) mob.getCharItemManager().addItemToInventory(toAdd); diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 34b06cb0..442608db 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -707,7 +707,7 @@ public class ItemFactory { if (rollPrefix < 80) { - int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); + int randomPrefix = LootManager.TableRoll(vendor.getLevel()); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); if (prefixEntry != null) @@ -722,7 +722,7 @@ public class ItemFactory { if (rollSuffix < 80 || prefixEntry == null) { - int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); + int randomSuffix = LootManager.TableRoll(vendor.getLevel()); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); if (suffixEntry != null) From 3f303e1c9ecf597a38ee82eb272493a837824138 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 17:37:01 -0600 Subject: [PATCH 120/233] tweak --- src/engine/gameManager/LootManager.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index eebeda23..a3ae1427 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -286,11 +286,9 @@ public enum LootManager { //determine and add gold to mob inventory - int high = bse.highGold; - int low = bse.lowGold; - int gold = ThreadLocalRandom.current().nextInt(low, high + 1); - - gold = (int) (gold * NORMAL_GOLD_RATE); + int high = (int)(bse.highGold * NORMAL_GOLD_RATE); + int low = (int)(bse.lowGold * NORMAL_GOLD_RATE); + int gold = ThreadLocalRandom.current().nextInt(low, high); if (gold > 0) { MobLoot goldAmount = new MobLoot(mob, gold); From 6db9f115b151a5ef7a4807dca99577b2f06ac6c3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 17:40:11 -0600 Subject: [PATCH 121/233] announce rates at login --- src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java index 02b0518c..eb62ddfb 100644 --- a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java +++ b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java @@ -66,6 +66,9 @@ public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler { // Send Guild, Nation and IC MOTD GuildManager.enterWorldMOTD(player); ChatManager.sendSystemMessage(player, ConfigManager.MB_WORLD_GREETING.getValue()); + ChatManager.sendSystemMessage(player, "Gold Drop Rate: " + ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); + ChatManager.sendSystemMessage(player, "Loot Drop Rate: " + ConfigManager.MB_NORMAL_DROP_RATE.getValue()); + ChatManager.sendSystemMessage(player, "Experience Rate: " + ConfigManager.MB_NORMAL_EXP_RATE.getValue()); // Send branch string if available from ConfigManager. From e60c635c39e410e2915c7e1e5704603ffe8dfb16 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 18:35:55 -0600 Subject: [PATCH 122/233] announce rates at login --- src/engine/net/client/handlers/UpgradeAssetMsgHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java b/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java index 3638c2ec..9c1eae12 100644 --- a/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java +++ b/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java @@ -119,7 +119,8 @@ public class UpgradeAssetMsgHandler extends AbstractClientMsgHandler { return true; } - dateToUpgrade = LocalDateTime.now().plusHours(buildingToRank.getBlueprint().getRankTime(nextRank)); + //dateToUpgrade = LocalDateTime.now().plusHours(buildingToRank.getBlueprint().getRankTime(nextRank)); + dateToUpgrade = LocalDateTime.now().plusMinutes(5); BuildingManager.setUpgradeDateTime(buildingToRank, dateToUpgrade, 0); From de772237c9d9cfe3bed3a5c08d0d1660466a2b25 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 18:39:31 -0600 Subject: [PATCH 123/233] 5 minute upgrades for NPCs --- src/engine/objects/Mob.java | 3 ++- src/engine/objects/NPC.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 00bdfb28..6efc6119 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1885,7 +1885,8 @@ public class Mob extends AbstractIntelligenceAgent { if (!building.transferGold(-rankCost, false)) return; - DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); + //DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); + DateTime dateToUpgrade = DateTime.now().plusMinutes(5); Mob.setUpgradeDateTime(this, dateToUpgrade); // Schedule upgrade job diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 07775e33..82adb937 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1325,7 +1325,8 @@ public class NPC extends AbstractCharacter { if (!building.transferGold(-rankCost, false)) return; - dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); + //dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); + dateToUpgrade = DateTime.now().plusMinutes(5); this.setUpgradeDateTime(dateToUpgrade); From 1b7be0365a3cdb6d5665782e34b8d10d1e6aa616 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 18:42:02 -0600 Subject: [PATCH 124/233] 5 minute upgrades for NPCs --- src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java index eb62ddfb..24a511ce 100644 --- a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java +++ b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java @@ -69,6 +69,7 @@ public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler { ChatManager.sendSystemMessage(player, "Gold Drop Rate: " + ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); ChatManager.sendSystemMessage(player, "Loot Drop Rate: " + ConfigManager.MB_NORMAL_DROP_RATE.getValue()); ChatManager.sendSystemMessage(player, "Experience Rate: " + ConfigManager.MB_NORMAL_EXP_RATE.getValue()); + ChatManager.sendSystemMessage(player, "Test Feature: All Assets Take 5 Minutes To Upgrade"); // Send branch string if available from ConfigManager. From 03025e7f0065fdc4f4d825f6b5fff3c73f621f65 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 19:10:05 -0600 Subject: [PATCH 125/233] 5 minute upgrades for initial placement --- src/engine/gameManager/BuildingManager.java | 2 +- src/engine/net/client/handlers/PlaceAssetMsgHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 844942ad..f2d610c5 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -258,7 +258,7 @@ public enum BuildingManager { if (building == null) return; - + building.upgradeDateTime = LocalDateTime.now().plusMinutes(5); if (building.getUpgradeDateTime() == null) { Logger.error("Attempt to submit upgrade job for non-ranking building"); return; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 382b6547..c5f59add 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -800,7 +800,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING); treeObject.setParentZone(zoneObject); - MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7)); + MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(14)); // Update guild binds and tags //load the new city on the clients From a8275c7cc71d82199ea21973ccde17154d226352 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 19:31:17 -0600 Subject: [PATCH 126/233] Revert "5 minute upgrades for NPCs" This reverts commit 1b7be0365a3cdb6d5665782e34b8d10d1e6aa616. --- src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java index 24a511ce..eb62ddfb 100644 --- a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java +++ b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java @@ -69,7 +69,6 @@ public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler { ChatManager.sendSystemMessage(player, "Gold Drop Rate: " + ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); ChatManager.sendSystemMessage(player, "Loot Drop Rate: " + ConfigManager.MB_NORMAL_DROP_RATE.getValue()); ChatManager.sendSystemMessage(player, "Experience Rate: " + ConfigManager.MB_NORMAL_EXP_RATE.getValue()); - ChatManager.sendSystemMessage(player, "Test Feature: All Assets Take 5 Minutes To Upgrade"); // Send branch string if available from ConfigManager. From 775410b00a680f93aba8dcb4283c0aa3827bd1ac Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 19:31:25 -0600 Subject: [PATCH 127/233] Revert "5 minute upgrades for NPCs" This reverts commit de772237c9d9cfe3bed3a5c08d0d1660466a2b25. --- src/engine/objects/Mob.java | 3 +-- src/engine/objects/NPC.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6efc6119..00bdfb28 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1885,8 +1885,7 @@ public class Mob extends AbstractIntelligenceAgent { if (!building.transferGold(-rankCost, false)) return; - //DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); - DateTime dateToUpgrade = DateTime.now().plusMinutes(5); + DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); Mob.setUpgradeDateTime(this, dateToUpgrade); // Schedule upgrade job diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 82adb937..07775e33 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1325,8 +1325,7 @@ public class NPC extends AbstractCharacter { if (!building.transferGold(-rankCost, false)) return; - //dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); - dateToUpgrade = DateTime.now().plusMinutes(5); + dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); this.setUpgradeDateTime(dateToUpgrade); From 85bf30cbdd6c5c69ac6efa924a35ccaf0bd19346 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 21:26:00 -0600 Subject: [PATCH 128/233] remove DS on login when no other boxes logged in --- .../InterestManagement/InterestManager.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index 923fb08c..e49c2d8e 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -8,10 +8,14 @@ package engine.InterestManagement; +import com.sun.corba.se.spi.orbutil.fsm.ActionBase; +import com.sun.corba.se.spi.orbutil.fsm.FSM; +import com.sun.corba.se.spi.orbutil.fsm.Input; import engine.Enum; import engine.Enum.DispatchChannel; import engine.Enum.GameObjectType; import engine.gameManager.GroupManager; +import engine.gameManager.PowersManager; import engine.gameManager.SessionManager; import engine.job.JobScheduler; import engine.jobs.RefreshGroupJob; @@ -24,11 +28,13 @@ import engine.net.client.msg.LoadStructureMsg; import engine.net.client.msg.MoveToPointMsg; import engine.net.client.msg.UnloadObjectsMsg; import engine.objects.*; +import engine.powers.ActionsBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashSet; +import java.util.Map; import static engine.math.FastMath.sqr; @@ -531,7 +537,16 @@ public enum InterestManager implements Runnable { ml.promoteToItem(player); player.getCharItemManager().addGoldToInventory(50000, true); } - + player.isBoxed = false; + for (String name : player.effects.keySet()) { + Effect eff = player.effects.get(name); + if (eff == null) { + return; + } + //remove deathshroud here! + if (eff.getEffectToken() == 1672601862) + player.effects.remove(name); + } for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ if(pc.isActive() == false) continue; From c5376d24a5deec8b982274666ddccbd47f8b17a6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 22:03:15 -0600 Subject: [PATCH 129/233] NPC 5 minute upgrades --- src/engine/objects/Mob.java | 3 ++- src/engine/objects/NPC.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 00bdfb28..6efc6119 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1885,7 +1885,8 @@ public class Mob extends AbstractIntelligenceAgent { if (!building.transferGold(-rankCost, false)) return; - DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); + //DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); + DateTime dateToUpgrade = DateTime.now().plusMinutes(5); Mob.setUpgradeDateTime(this, dateToUpgrade); // Schedule upgrade job diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 07775e33..abc99255 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1325,8 +1325,8 @@ public class NPC extends AbstractCharacter { if (!building.transferGold(-rankCost, false)) return; - dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); - + //dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); + dateToUpgrade = DateTime.now().plusMinutes(5); this.setUpgradeDateTime(dateToUpgrade); // Schedule upgrade job From e891d353ba28f7e67fc330bf218d4c29e6f044e2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 22:36:48 -0600 Subject: [PATCH 130/233] Vorg mobs drop random piece of set and spawn randomly between 5 and 45 minutes after death --- src/engine/gameManager/LootManager.java | 26 +++++++++++++++++++++++-- src/engine/objects/ItemBase.java | 5 +++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a3ae1427..245f56e1 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -17,6 +17,7 @@ import engine.objects.*; import org.pmw.tinylog.Logger; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.concurrent.ThreadLocalRandom; @@ -34,6 +35,11 @@ public enum LootManager { public static HashMap> _modTables = new HashMap<>(); public static HashMap> _modTypeTables = new HashMap<>(); + public static ArrayList vorg_ha_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27580, 27590, 188500, 188510, 188520, 188530, 188540, 188550, 189510})); + public static ArrayList vorg_ma_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27570,188900,188910,188920,188930,188940,188950,189500})); + public static ArrayList vorg_la_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27550,27560,189100,189110,189120,189130,189140,189150})); + public static ArrayList vorg_cloth_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27600,188700,188720,189550,189560})); + // Drop Rates public static float NORMAL_DROP_RATE; @@ -327,8 +333,24 @@ public enum LootManager { if (equipmentRoll > dropChance) continue; - - MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + ItemBase genericIB = me.getItemBase(); + if(genericIB.isVorg()){ + if(genericIB.isClothArmor()){ + //get random cloth piece + genericIB = ItemBase.getItemBase(vorg_cloth_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_cloth_uuids.size() - 1))); + } else if(genericIB.isHeavyArmor()){ + //get random heavy armor piece + genericIB = ItemBase.getItemBase(vorg_ha_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_ha_uuids.size() - 1))); + } else if(genericIB.isMediumArmor()){ + //get random medium armor piece + genericIB = ItemBase.getItemBase(vorg_ma_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_ma_uuids.size() - 1))); + } else if(genericIB.isLightArmor()){ + //get random light armor piece + genericIB = ItemBase.getItemBase(vorg_la_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_la_uuids.size() - 1))); + } + mob.spawnTime = ThreadLocalRandom.current().nextInt(300,2700); + } + MobLoot ml = new MobLoot(mob, genericIB, false); if (ml != null && dropCount < 1) { ml.setIsID(true); diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 17c5a00c..ad5ff347 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -13,6 +13,7 @@ import engine.Enum.DamageType; import engine.Enum.GameObjectType; import engine.Enum.ItemType; import engine.gameManager.DbManager; +import engine.gameManager.LootManager; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -914,4 +915,8 @@ public class ItemBase { public void setAutoID(boolean autoID) { this.autoID = autoID; } + + public boolean isVorg(){ + return LootManager.vorg_ha_uuids.contains(this.uuid) || LootManager.vorg_ma_uuids.contains(this.uuid) || LootManager.vorg_la_uuids.contains(this.uuid) || LootManager.vorg_cloth_uuids.contains(this.uuid); + } } From 4fd737e3ecad20217167bbeb20c2bb83bf39f1ea Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 22:47:22 -0600 Subject: [PATCH 131/233] mines to set random cap size at server boot 5/10/20 --- src/engine/objects/Mine.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 7a2a4b56..685a7601 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -26,6 +26,7 @@ import java.sql.SQLException; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ThreadLocalRandom; import static engine.gameManager.DbManager.MineQueries; import static engine.gameManager.DbManager.getObject; @@ -51,6 +52,8 @@ public class Mine extends AbstractGameObject { private int buildingID; private MineProduction mineType; + public int capSize; + /** * ResultSet Constructor */ @@ -91,6 +94,16 @@ public class Mine extends AbstractGameObject { this.production = Resource.valueOf(rs.getString("mine_resource")); this.lastClaimer = null; + int capRoll = ThreadLocalRandom.current().nextInt(0,100); + if(capRoll >= 0 && capRoll <= 33){ + this.capSize = 5; + } + if(capRoll >= 34 && capRoll <= 66){ + this.capSize = 10; + } + if(capRoll >= 67 && capRoll <= 100){ + this.capSize = 20; + } } public static void releaseMineClaims(PlayerCharacter playerCharacter) { @@ -165,7 +178,7 @@ public class Mine extends AbstractGameObject { writer.putInt(mine.getObjectUUID()); writer.putInt(mine.getObjectUUID()); //actually a hash of mine writer.putString(mine.mineType.name); - writer.putString(mine.zoneName); + writer.putString(mine.zoneName + " " + mine.capSize + " Man "); writer.putInt(mine.production.hash); writer.putInt(mine.production.baseProduction); writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here From 7f5df22a141141505a25989f400fa0b648406af1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 22:48:19 -0600 Subject: [PATCH 132/233] mines to set random cap size at server boot 5/10/20 --- src/engine/objects/Mine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 685a7601..ec7d8a5a 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -178,7 +178,7 @@ public class Mine extends AbstractGameObject { writer.putInt(mine.getObjectUUID()); writer.putInt(mine.getObjectUUID()); //actually a hash of mine writer.putString(mine.mineType.name); - writer.putString(mine.zoneName + " " + mine.capSize + " Man "); + writer.putString(mine.zoneName + " {" + mine.capSize + " Man}"); writer.putInt(mine.production.hash); writer.putInt(mine.production.baseProduction); writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here From 8f2847a527bfc619700f37156a0ad7875e7bd929 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 23:18:09 -0600 Subject: [PATCH 133/233] Mines calculate local players by guild --- src/engine/gameManager/SimulationManager.java | 33 ++++++++-- src/engine/objects/Mine.java | 66 ++++++++++++++++++- 2 files changed, 93 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index ccdcb007..3b683ca8 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -10,10 +10,7 @@ package engine.gameManager; import engine.Enum; import engine.Enum.GameObjectType; -import engine.objects.AbstractGameObject; -import engine.objects.City; -import engine.objects.PlayerCharacter; -import engine.objects.Runegate; +import engine.objects.*; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -40,6 +37,7 @@ public enum SimulationManager { public static Duration executionMax = Duration.ofNanos(1); private static SimulationManager instance = null; private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; + private long _minePulseTime = System.currentTimeMillis() + CITY_PULSE; private long _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE; @@ -126,7 +124,17 @@ public enum SimulationManager { e.printStackTrace(); } + try { + if ((_minePulseTime != 0) + && (System.currentTimeMillis() > _minePulseTime)) + pulseMines(); + } catch (Exception e) { + Logger.error( + "Fatal error in Mine Pulse: DISABLED. Error Message : " + + e.getMessage()); + e.printStackTrace(); + } SimulationManager.executionTime = Duration.between(startTime, Instant.now()); if (executionTime.compareTo(executionMax) > 0) @@ -203,7 +211,6 @@ public enum SimulationManager { city = (City) cityObject; city.onEnter(); } - _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; } @@ -220,4 +227,20 @@ public enum SimulationManager { _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; } + private void pulseMines(){ + Mine mine; + Collection mineList = DbManager.getList(Enum.GameObjectType.Mine); + + if (mineList == null) { + Logger.info("Mine List null"); + return; + } + + for (AbstractGameObject mineObject : mineList) { + mine = (Mine) mineObject; + mine.onEnter(); + } + + _minePulseTime = System.currentTimeMillis() + CITY_PULSE; + } } diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index ec7d8a5a..a4c4a1eb 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -24,7 +24,7 @@ import java.net.UnknownHostException; import java.sql.ResultSet; import java.sql.SQLException; import java.time.LocalDateTime; -import java.util.ArrayList; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -54,6 +54,9 @@ public class Mine extends AbstractGameObject { public int capSize; + public HashMap> presentPlayers = new HashMap<>(); + public Integer totalPLayers; + /** * ResultSet Constructor */ @@ -587,5 +590,66 @@ public class Mine extends AbstractGameObject { } return (int) totalModded; } + public void onEnter() { + + HashSet currentPlayers; + HashSet currentMemory; + PlayerCharacter player; + + // Gather current list of players within the zone bounds + Building building = BuildingManager.getBuilding(this.buildingID); + currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); + this.totalPLayers = currentPlayers.size(); + for (AbstractWorldObject playerObject : currentPlayers) { + + if (playerObject == null) + continue; + + player = (PlayerCharacter) playerObject; + Guild nation = player.getGuild().getNation(); + if(this.presentPlayers.containsKey(nation)) { + if (this.presentPlayers.get(nation).contains(player) == false) + { + this.presentPlayers.get(nation).add(player); + } + } else { + ArrayList present = new ArrayList<>(); + present.add(player); + this.presentPlayers.put(nation, present); + } + for(Guild guild : this.presentPlayers.keySet()) { + ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); + } + } + try { + onExit(); + } catch (Exception e) { + Logger.error(e.getMessage()); + } + } + + private void onExit() { + HashSet currentPlayers; + PlayerCharacter player; + Building building = BuildingManager.getBuilding(this.buildingID); + currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); + this.totalPLayers = currentPlayers.size(); + for (AbstractWorldObject playerObject : currentPlayers) { + + if (playerObject == null) + continue; + player = (PlayerCharacter) playerObject; + Guild nation = player.getGuild().getNation(); + if(this.presentPlayers.containsKey(nation)) { + if (this.presentPlayers.get(nation).contains(player) == false) + { + this.presentPlayers.get(nation).remove(player); + } + } + for(Guild guild : this.presentPlayers.keySet()) { + ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); + } + } + } } From 457ed4f4e6cc256781239d25690f7aa55cf32acb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 23:41:24 -0600 Subject: [PATCH 134/233] mine show in system chat updated numbers --- src/engine/objects/Mine.java | 54 +++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index a4c4a1eb..04d1596f 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -600,6 +600,7 @@ public class Mine extends AbstractGameObject { Building building = BuildingManager.getBuilding(this.buildingID); currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); this.totalPLayers = currentPlayers.size(); + boolean added = false; for (AbstractWorldObject playerObject : currentPlayers) { if (playerObject == null) @@ -607,49 +608,64 @@ public class Mine extends AbstractGameObject { player = (PlayerCharacter) playerObject; Guild nation = player.getGuild().getNation(); + + if(nation == null) + return; + if(this.presentPlayers.containsKey(nation)) { if (this.presentPlayers.get(nation).contains(player) == false) { this.presentPlayers.get(nation).add(player); + added = true; } } else { ArrayList present = new ArrayList<>(); present.add(player); this.presentPlayers.put(nation, present); + added = true; } - for(Guild guild : this.presentPlayers.keySet()) { - ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); - } + if(added) + for(Guild guild : this.presentPlayers.keySet()) { + ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); + } } try { - onExit(); + onExit(this.presentPlayers); } catch (Exception e) { Logger.error(e.getMessage()); } } - private void onExit() { + private void onExit(HashMap> checkList) { + ArrayList allPlayers = new ArrayList<>(); + for(ArrayList players: presentPlayers.values()){ + allPlayers.addAll(players); + } + + boolean updated = false; + HashSet currentPlayers; PlayerCharacter player; Building building = BuildingManager.getBuilding(this.buildingID); currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); this.totalPLayers = currentPlayers.size(); - for (AbstractWorldObject playerObject : currentPlayers) { - - if (playerObject == null) - continue; - - player = (PlayerCharacter) playerObject; - Guild nation = player.getGuild().getNation(); - if(this.presentPlayers.containsKey(nation)) { - if (this.presentPlayers.get(nation).contains(player) == false) - { - this.presentPlayers.get(nation).remove(player); + for (PlayerCharacter playerObject : allPlayers) { + + if (currentPlayers.contains(playerObject) == false) { + Guild nation = playerObject.getGuild().getNation(); + if (this.presentPlayers.containsKey(nation)) { + if (this.presentPlayers.get(nation).contains(playerObject) == true) { + this.presentPlayers.get(nation).remove(playerObject); + updated = true; + ChatManager.chatSystemInfo(playerObject,"Leaving Mine Vicinity"); + } } + } - for(Guild guild : this.presentPlayers.keySet()) { - ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); - } + if(updated) + for (Guild guild : this.presentPlayers.keySet()) { + ChatManager.chatSystemInfo(playerObject, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); + } } } } From 6b4eff4d4c27f9511bda5b7aac13c93e18665f53 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 19:09:21 -0600 Subject: [PATCH 135/233] players removed when leaving mines --- src/engine/objects/Mine.java | 128 ++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 54 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 04d1596f..9437fed1 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -54,8 +54,9 @@ public class Mine extends AbstractGameObject { public int capSize; - public HashMap> presentPlayers = new HashMap<>(); - public Integer totalPLayers; + public final HashSet _playerMemory = new HashSet<>(); + HashMap> dividedPlayers; + public Integer totalPlayers; /** * ResultSet Constructor @@ -593,79 +594,98 @@ public class Mine extends AbstractGameObject { public void onEnter() { HashSet currentPlayers; - HashSet currentMemory; PlayerCharacter player; // Gather current list of players within the zone bounds - Building building = BuildingManager.getBuilding(this.buildingID); - currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); - this.totalPLayers = currentPlayers.size(); - boolean added = false; + Building tower = BuildingManager.getBuildingFromCache(this.buildingID); + currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents, MBServerStatics.MASK_PLAYER); + boolean updated = false; + for (AbstractWorldObject playerObject : currentPlayers) { if (playerObject == null) continue; player = (PlayerCharacter) playerObject; - Guild nation = player.getGuild().getNation(); - if(nation == null) - return; + // Player is already in our memory - if(this.presentPlayers.containsKey(nation)) { - if (this.presentPlayers.get(nation).contains(player) == false) - { - this.presentPlayers.get(nation).add(player); - added = true; - } - } else { - ArrayList present = new ArrayList<>(); - present.add(player); - this.presentPlayers.put(nation, present); - added = true; - } - if(added) - for(Guild guild : this.presentPlayers.keySet()) { - ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); - } + if (_playerMemory.contains(player.getObjectUUID())) + continue; + + // Add player to our city's memory + + _playerMemory.add(player.getObjectUUID()); + updated = true; + + // ***For debugging + // Logger.info("PlayerMemory for ", this.getCityName() + ": " + _playerMemory.size()); } + this.totalPlayers = this._playerMemory.size(); try { - onExit(this.presentPlayers); + if(onExit(currentPlayers)){ + updated = true; + } } catch (Exception e) { Logger.error(e.getMessage()); } - } - - private void onExit(HashMap> checkList) { - ArrayList allPlayers = new ArrayList<>(); - for(ArrayList players: presentPlayers.values()){ - allPlayers.addAll(players); + this.dividedPlayers = new HashMap<>(); + for(Integer playerID : this._playerMemory){ + player = PlayerCharacter.getFromCache(playerID); + Guild guild = player.getGuild(); + Guild nation = guild.getNation(); + Guild entry; + if(nation.equals(Guild.getErrantGuild())){ + entry = nation; + }else if(guild.equals(Guild.getErrantGuild())){ + entry = guild; + } else{ + entry = Guild.getErrantGuild(); + } + if(this.dividedPlayers.containsKey(entry)){ + this.dividedPlayers.get(entry).add(playerID); + }else{ + ArrayList newEntry = new ArrayList<>(); + newEntry.add(playerID); + this.dividedPlayers.put(entry,newEntry); + } + } + if(updated == true){ + for(Integer playerID : this._playerMemory){ + player = PlayerCharacter.getFromCache(playerID); + for(Guild present : this.dividedPlayers.keySet()) { + ChatManager.chatSystemInfo(player,present.getName() + "COUNT: " + this.dividedPlayers.get(present).size() + " (" + (this.dividedPlayers.get(present).size()/this.totalPlayers * 100) + "%)"); + } + } } + } - boolean updated = false; + private Boolean onExit(HashSet currentPlayers) { - HashSet currentPlayers; PlayerCharacter player; - Building building = BuildingManager.getBuilding(this.buildingID); - currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); - this.totalPLayers = currentPlayers.size(); - for (PlayerCharacter playerObject : allPlayers) { - - if (currentPlayers.contains(playerObject) == false) { - Guild nation = playerObject.getGuild().getNation(); - if (this.presentPlayers.containsKey(nation)) { - if (this.presentPlayers.get(nation).contains(playerObject) == true) { - this.presentPlayers.get(nation).remove(playerObject); - updated = true; - ChatManager.chatSystemInfo(playerObject,"Leaving Mine Vicinity"); - } - } + int playerUUID = 0; + HashSet toRemove = new HashSet<>(); + Iterator iter = _playerMemory.iterator(); + while (iter.hasNext()) { - } - if(updated) - for (Guild guild : this.presentPlayers.keySet()) { - ChatManager.chatSystemInfo(playerObject, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); - } + playerUUID = iter.next(); + + + player = PlayerCharacter.getFromCache(playerUUID); + + if (currentPlayers.contains(player)) + continue; + + toRemove.add(playerUUID); + } + + // Remove players from mine memory + + _playerMemory.removeAll(toRemove); + if(toRemove.isEmpty()){ + return false; + }else{ + return true; } } } From 545796e297b5eb7c68e5eefb90e1c5810eb622bc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 19:21:41 -0600 Subject: [PATCH 136/233] players removed when leaving mines --- src/engine/objects/Mine.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 9437fed1..b1206f41 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -632,29 +632,20 @@ public class Mine extends AbstractGameObject { this.dividedPlayers = new HashMap<>(); for(Integer playerID : this._playerMemory){ player = PlayerCharacter.getFromCache(playerID); - Guild guild = player.getGuild(); - Guild nation = guild.getNation(); - Guild entry; - if(nation.equals(Guild.getErrantGuild())){ - entry = nation; - }else if(guild.equals(Guild.getErrantGuild())){ - entry = guild; - } else{ - entry = Guild.getErrantGuild(); - } - if(this.dividedPlayers.containsKey(entry)){ - this.dividedPlayers.get(entry).add(playerID); + Guild nation = player.getGuild().getNation(); Guild entry; + if(this.dividedPlayers.containsKey(nation)){ + this.dividedPlayers.get(nation).add(playerID); }else{ ArrayList newEntry = new ArrayList<>(); newEntry.add(playerID); - this.dividedPlayers.put(entry,newEntry); + this.dividedPlayers.put(nation,newEntry); } } if(updated == true){ for(Integer playerID : this._playerMemory){ player = PlayerCharacter.getFromCache(playerID); for(Guild present : this.dividedPlayers.keySet()) { - ChatManager.chatSystemInfo(player,present.getName() + "COUNT: " + this.dividedPlayers.get(present).size() + " (" + (this.dividedPlayers.get(present).size()/this.totalPlayers * 100) + "%)"); + ChatManager.chatSystemInfo(player,present.getName() + "COUNT: " + this.dividedPlayers.get(present).size()); } } } From 7a3a9c6254aefd5900caee431a06fcfd59b827f3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 19:41:54 -0600 Subject: [PATCH 137/233] multiplier display --- src/engine/gameManager/SimulationManager.java | 3 ++- src/engine/objects/Mine.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 3b683ca8..6a7a6773 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -238,7 +238,8 @@ public enum SimulationManager { for (AbstractGameObject mineObject : mineList) { mine = (Mine) mineObject; - mine.onEnter(); + if(mine.isActive) + mine.onEnter(); } _minePulseTime = System.currentTimeMillis() + CITY_PULSE; diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index b1206f41..351bf0bd 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -645,7 +645,8 @@ public class Mine extends AbstractGameObject { for(Integer playerID : this._playerMemory){ player = PlayerCharacter.getFromCache(playerID); for(Guild present : this.dividedPlayers.keySet()) { - ChatManager.chatSystemInfo(player,present.getName() + "COUNT: " + this.dividedPlayers.get(present).size()); + int count = this.dividedPlayers.get(present).size(); + ChatManager.chatSystemInfo(player,present.getName() + " COUNT: " + count + " MULTIPLIER: " + (1.0f - (count / this.totalPlayers))); } } } From c8246ff31765cc48b22fc34ed820e194233a3f5f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 19:54:25 -0600 Subject: [PATCH 138/233] multiplier display --- src/engine/net/client/handlers/CityDataHandler.java | 9 --------- src/engine/objects/Mine.java | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/engine/net/client/handlers/CityDataHandler.java b/src/engine/net/client/handlers/CityDataHandler.java index 98ca60fb..f2f5d0d3 100644 --- a/src/engine/net/client/handlers/CityDataHandler.java +++ b/src/engine/net/client/handlers/CityDataHandler.java @@ -61,15 +61,6 @@ public class CityDataHandler extends AbstractClientMsgHandler { dispatch = Dispatch.borrow(playerCharacter, cityDataMsg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - // If the hotZone has changed then update the client's map accordingly. - - if (playerCharacter.getTimeStamp("hotzoneupdate") <= ZoneManager.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) { - HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID()); - dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - playerCharacter.setTimeStamp("hotzoneupdate", System.currentTimeMillis() - 100); - } - // Serialize the realms for this map WorldRealmMsg worldRealmMsg = new WorldRealmMsg(); diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 351bf0bd..0ecffabf 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -646,7 +646,8 @@ public class Mine extends AbstractGameObject { player = PlayerCharacter.getFromCache(playerID); for(Guild present : this.dividedPlayers.keySet()) { int count = this.dividedPlayers.get(present).size(); - ChatManager.chatSystemInfo(player,present.getName() + " COUNT: " + count + " MULTIPLIER: " + (1.0f - (count / this.totalPlayers))); + float multiplier = 1.0f - (count / this.totalPlayers); + ChatManager.chatSystemInfo(player,present.getName() + " COUNT: " + count + " MULTIPLIER: " + multiplier); } } } From f4778d4f486b073ef0ae7eb4e2d14e23780f9a4a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 19:55:56 -0600 Subject: [PATCH 139/233] multiplier display --- src/engine/gameManager/SimulationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 6a7a6773..0c58ff30 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -238,7 +238,7 @@ public enum SimulationManager { for (AbstractGameObject mineObject : mineList) { mine = (Mine) mineObject; - if(mine.isActive) + //if(mine.isActive) mine.onEnter(); } From 3d33a16d065f65dfc6b1eb86facbacac17f9f3f6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 20:09:26 -0600 Subject: [PATCH 140/233] multiplier display --- src/engine/objects/Mine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 0ecffabf..505ffaae 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -646,8 +646,8 @@ public class Mine extends AbstractGameObject { player = PlayerCharacter.getFromCache(playerID); for(Guild present : this.dividedPlayers.keySet()) { int count = this.dividedPlayers.get(present).size(); - float multiplier = 1.0f - (count / this.totalPlayers); - ChatManager.chatSystemInfo(player,present.getName() + " COUNT: " + count + " MULTIPLIER: " + multiplier); + float multiplier = (float)(count / this.totalPlayers); + ChatManager.chatSystemInfo(player,present.getName() + " COUNT: " + count + " / " + this.totalPlayers); } } } From c640caeb5436e7339d471af17db3bc6a1617a00b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 12 Feb 2024 22:06:38 -0600 Subject: [PATCH 141/233] Zerg Mechanic Completed --- src/engine/gameManager/CombatManager.java | 3 + src/engine/gameManager/SimulationManager.java | 2 +- src/engine/objects/Mine.java | 196 +++++++++++++++++- src/engine/objects/PlayerCharacter.java | 1 + .../effectmodifiers/HealthEffectModifier.java | 4 + .../effectmodifiers/ManaEffectModifier.java | 3 + .../StaminaEffectModifier.java | 3 + .../poweractions/TransferStatPowerAction.java | 1 + 8 files changed, 207 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 53347204..47c50945 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -814,6 +814,9 @@ public enum CombatManager { else damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists); + if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){ + damage *= ((PlayerCharacter)ac).ZergMultiplier; + } float d = 0f; errorTrack = 12; diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 0c58ff30..6a7a6773 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -238,7 +238,7 @@ public enum SimulationManager { for (AbstractGameObject mineObject : mineList) { mine = (Mine) mineObject; - //if(mine.isActive) + if(mine.isActive) mine.onEnter(); } diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 505ffaae..87937529 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -18,6 +18,7 @@ import engine.gameManager.ZoneManager; import engine.net.ByteBufferWriter; import engine.net.client.msg.ErrorPopupMsg; import engine.server.MBServerStatics; +import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.net.UnknownHostException; @@ -55,6 +56,7 @@ public class Mine extends AbstractGameObject { public int capSize; public final HashSet _playerMemory = new HashSet<>(); + public final HashMap _recentMemory = new HashMap<>(); HashMap> dividedPlayers; public Integer totalPlayers; @@ -609,6 +611,8 @@ public class Mine extends AbstractGameObject { player = (PlayerCharacter) playerObject; // Player is already in our memory + if (_recentMemory.containsKey(player.getObjectUUID())) + _recentMemory.remove(player.getObjectUUID()); if (_playerMemory.contains(player.getObjectUUID())) continue; @@ -644,10 +648,21 @@ public class Mine extends AbstractGameObject { if(updated == true){ for(Integer playerID : this._playerMemory){ player = PlayerCharacter.getFromCache(playerID); - for(Guild present : this.dividedPlayers.keySet()) { - int count = this.dividedPlayers.get(present).size(); - float multiplier = (float)(count / this.totalPlayers); - ChatManager.chatSystemInfo(player,present.getName() + " COUNT: " + count + " / " + this.totalPlayers); + if(this.dividedPlayers.containsKey(player.getGuild().getNation())){ + int count = this.dividedPlayers.get(player.getGuild().getNation()).size(); + switch(this.capSize){ + case 5: + player.ZergMultiplier = getMultiplier5Man(count); + break; + case 10: + player.ZergMultiplier = getMultiplier10Man(count); + break; + case 20: + player.ZergMultiplier = getMultiplier20Man(count); + break; + } + } else{ + player.ZergMultiplier = 1.0f; //something went wrong reset to default until next cycle } } } @@ -670,15 +685,186 @@ public class Mine extends AbstractGameObject { continue; toRemove.add(playerUUID); + if(_recentMemory.containsKey(playerUUID) == false) { + _recentMemory.put(playerUUID, System.currentTimeMillis()); + } + player.ZergMultiplier = 1.0f; // reset damage modifier to 1.0 } // Remove players from mine memory - _playerMemory.removeAll(toRemove); + //_playerMemory.removeAll(toRemove); + HashSet purge = new HashSet<>(); + for(Integer id : _recentMemory.keySet()){ + if(System.currentTimeMillis() > _recentMemory.get(playerUUID) + 60000){ + purge.add(id); + } + } + for(Integer id : purge){ + _recentMemory.remove(id); + } if(toRemove.isEmpty()){ return false; }else{ return true; } } + + public static float getMultiplier5Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + multiplier += 0.5f; + break; + case 2: + multiplier += 0.5f; + break; + case 3: + multiplier += 0.5f; + break; + case 4: + multiplier += 0.2f; + break; + case 5: + multiplier += 0.0f; + break; + case 6: + multiplier -= 0.2f; + break; + case 7: + multiplier -= 0.45f; + break; + case 8: + multiplier -= 0.6f; + break; + default: + multiplier -= 0.75f; + break; + } + return multiplier; + } + public static float getMultiplier10Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + multiplier += 1.0f; + break; + case 2: + multiplier += 1.0f; + break; + case 3: + multiplier += 1.0f; + break; + case 4: + multiplier += 1.0f; + break; + case 5: + multiplier += 0.8f; + break; + case 6: + multiplier += 0.55f; + break; + case 7: + multiplier += 0.35f; + break; + case 8: + multiplier += 0.2f; + break; + case 9: + multiplier += 0.1f; + break; + case 10: + multiplier += 0.0f; + break; + case 11: + multiplier -= 0.1f; + break; + case 12: + multiplier -= 0.2f; + break; + case 13: + multiplier -= 0.35f; + break; + case 14: + multiplier -= 0.55f; + break; + default: + multiplier -= 0.75f; + break; + } + return multiplier; + } + public static float getMultiplier20Man(int count){ + float multiplier = 1.0f; + if(count < 10){ + multiplier += 1.25f; + }else { + switch (count) { + case 10: + multiplier += 0.8f; + break; + case 11: + multiplier += 0.65f; + break; + case 12: + multiplier += 0.54f; + break; + case 13: + multiplier += 0.46f; + break; + case 14: + multiplier += 0.36f; + break; + case 15: + multiplier += 0.28f; + break; + case 16: + multiplier += 0.21f; + break; + case 17: + multiplier += 0.15f; + break; + case 18: + multiplier += 0.09f; + break; + case 19: + multiplier += 0.04f; + break; + case 20: + multiplier += 0.00f; + break; + case 21: + multiplier -= 0.04f; + break; + case 22: + multiplier -= 0.09f; + break; + case 23: + multiplier -= 0.15f; + break; + case 24: + multiplier -= 0.21f; + break; + case 25: + multiplier -= 0.28f; + break; + case 26: + multiplier -= 0.36f; + break; + case 27: + multiplier -= 0.46f; + break; + case 28: + multiplier -= 0.54f; + break; + case 29: + multiplier -= 0.65f; + break; + default: + multiplier -= 0.75f; + break; + } + } + return multiplier; + } } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index b8c6b117..7f1f2b56 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -176,6 +176,7 @@ public class PlayerCharacter extends AbstractCharacter { public boolean isBoxed = false; + public float ZergMultiplier = 1.0f; /** * No Id Constructor */ diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index 3ddaf96b..61e6652f 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -176,6 +176,10 @@ public class HealthEffectModifier extends AbstractEffectModifier { if (!ac.isAlive()) return; + if(awo.getObjectType().equals(GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + } + int powerID = 0, effectID = 0; String powerName = ""; if (effect.getPower() != null) { diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index d70b9a2c..8167fc0f 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -157,6 +157,9 @@ public class ManaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } + if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID); diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index 59145f16..cd433e44 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -153,6 +153,9 @@ public class StaminaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } + if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID); diff --git a/src/engine/powers/poweractions/TransferStatPowerAction.java b/src/engine/powers/poweractions/TransferStatPowerAction.java index 4deea480..f2673706 100644 --- a/src/engine/powers/poweractions/TransferStatPowerAction.java +++ b/src/engine/powers/poweractions/TransferStatPowerAction.java @@ -213,6 +213,7 @@ public class TransferStatPowerAction extends AbstractPowerAction { // put it back between min and max damage += min; + damage *= ((PlayerCharacter) source).ZergMultiplier; } // Apply any power effect modifiers (such as stances) From 0bdcfe7b515faf5617f922ce702bf36936176eba Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 09:53:00 -0600 Subject: [PATCH 142/233] mines set to 5 cap, zerg mechanic buff/debuff introduced --- src/engine/objects/Mine.java | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 87937529..4958ddad 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -100,16 +100,16 @@ public class Mine extends AbstractGameObject { this.production = Resource.valueOf(rs.getString("mine_resource")); this.lastClaimer = null; - int capRoll = ThreadLocalRandom.current().nextInt(0,100); - if(capRoll >= 0 && capRoll <= 33){ + //int capRoll = ThreadLocalRandom.current().nextInt(0,100); + //if(capRoll >= 0 && capRoll <= 33){ this.capSize = 5; - } - if(capRoll >= 34 && capRoll <= 66){ - this.capSize = 10; - } - if(capRoll >= 67 && capRoll <= 100){ - this.capSize = 20; - } + //} + //if(capRoll >= 34 && capRoll <= 66){ + // this.capSize = 10; + //} + //if(capRoll >= 67 && capRoll <= 100){ + // this.capSize = 20; + //} } public static void releaseMineClaims(PlayerCharacter playerCharacter) { @@ -714,10 +714,8 @@ public class Mine extends AbstractGameObject { float multiplier = 1.0f; switch(count){ case 1: - multiplier += 0.5f; - break; case 2: - multiplier += 0.5f; + multiplier += 0.8f; break; case 3: multiplier += 0.5f; @@ -732,13 +730,13 @@ public class Mine extends AbstractGameObject { multiplier -= 0.2f; break; case 7: - multiplier -= 0.45f; + multiplier -= 0.4f; break; case 8: multiplier -= 0.6f; break; default: - multiplier -= 0.75f; + multiplier -= 0.80f; break; } return multiplier; From f5b08c1868aa7f1c036684338a9bc26a7ddb575e Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 13:27:00 -0600 Subject: [PATCH 143/233] mines set to 5 cap, zerg mechanic buff/debuff introduced --- src/engine/db/handlers/dbItemHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 8e6ffd95..d0821606 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -135,7 +135,11 @@ public class dbItemHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); if (rs.next()) - worked = rs.getBoolean("result"); + try { + worked = rs.getBoolean("result"); + }catch(Exception e){ + return true; + } } catch (SQLException e) { Logger.error(e); From e414304e945f226878e8789f12a492fe2975f88b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 13:35:10 -0600 Subject: [PATCH 144/233] boxshroud fixes --- .../InterestManagement/InterestManager.java | 9 --------- src/engine/objects/PlayerCharacter.java | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index e49c2d8e..bd27652f 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -538,15 +538,6 @@ public enum InterestManager implements Runnable { player.getCharItemManager().addGoldToInventory(50000, true); } player.isBoxed = false; - for (String name : player.effects.keySet()) { - Effect eff = player.effects.get(name); - if (eff == null) { - return; - } - //remove deathshroud here! - if (eff.getEffectToken() == 1672601862) - player.effects.remove(name); - } for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ if(pc.isActive() == false) continue; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 7f1f2b56..ddaee7c9 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4814,7 +4814,22 @@ public class PlayerCharacter extends AbstractCharacter { this.safeZone = this.isInSafeZone(); - if(this.isBoxed == true && this.containsEffect(1672601862) == false) + if(this.isBoxed && this.containsEffect(1672601862) == false) + this.isBoxed = false; + for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ + if(pc.isActive() == false) + continue; + if(pc.isEnteredWorld() == false) + continue; + if(this.getClientConnection().machineID.equals(pc.getClientConnection().machineID)){ + //add deatshroud effect + if(pc.isBoxed == true) + continue; + this.isBoxed = true; + return; + } + } + if(this.isBoxed) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); } catch (Exception e) { From a6a2629fd59f6c181ca50dbd4a5ef5597938a917 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 13:42:57 -0600 Subject: [PATCH 145/233] boxshroud fixes --- src/engine/objects/PlayerCharacter.java | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index ddaee7c9..4a69143d 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4814,22 +4814,25 @@ public class PlayerCharacter extends AbstractCharacter { this.safeZone = this.isInSafeZone(); - if(this.isBoxed && this.containsEffect(1672601862) == false) + if(this.isBoxed && this.containsEffect(1672601862) == false) { this.isBoxed = false; - for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ - if(pc.isActive() == false) - continue; - if(pc.isEnteredWorld() == false) - continue; - if(this.getClientConnection().machineID.equals(pc.getClientConnection().machineID)){ - //add deatshroud effect - if(pc.isBoxed == true) + for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) { + + if (pc.isActive() == false) continue; - this.isBoxed = true; - return; + + if (pc.isEnteredWorld() == false) + continue; + + if (this.getClientConnection().machineID.equals(pc.getClientConnection().machineID)) { + //add deatshroud effect + if (pc.isBoxed == true) + continue; + this.isBoxed = true; + } } } - if(this.isBoxed) + if(this.isBoxed && this.containsEffect(1672601862) == false) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); } catch (Exception e) { From 3ef3a0c37cb19815d1d2ba62bae88d32eecd4339 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 13:48:34 -0600 Subject: [PATCH 146/233] boxshroud fixes --- src/engine/db/handlers/dbItemHandler.java | 6 +++++- src/engine/objects/PlayerCharacter.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index d0821606..2fc9b64e 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -354,7 +354,11 @@ public class dbItemHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); if (rs.next()) - worked = rs.getBoolean("result"); + try { + worked = rs.getBoolean("result"); + } catch(Exception e){ + worked = true; + } } catch (SQLException e) { Logger.error(e); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 4a69143d..0b9bb680 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4829,6 +4829,7 @@ public class PlayerCharacter extends AbstractCharacter { if (pc.isBoxed == true) continue; this.isBoxed = true; + break; } } } From aa0e9930380b10116e19a9b1f9855d6fa9c2d9d8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 13:51:50 -0600 Subject: [PATCH 147/233] boxshroud fixes --- src/engine/objects/PlayerCharacter.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 0b9bb680..22bebc72 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4825,16 +4825,12 @@ public class PlayerCharacter extends AbstractCharacter { continue; if (this.getClientConnection().machineID.equals(pc.getClientConnection().machineID)) { - //add deatshroud effect - if (pc.isBoxed == true) - continue; this.isBoxed = true; - break; + PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); + return; } } } - if(this.isBoxed && this.containsEffect(1672601862) == false) - PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); } catch (Exception e) { Logger.error(e); From 8a0303e0f5bb2cfc03898bdc6b0e1cd555adf67a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 14:00:23 -0600 Subject: [PATCH 148/233] boxshroud fixes --- src/engine/net/client/ClientMessagePump.java | 8 ++++++++ src/engine/objects/PlayerCharacter.java | 16 +--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index d31a63c3..9fd4116a 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1888,6 +1888,14 @@ public class ClientMessagePump implements NetMsgHandler { break; case LEAVEREQUEST: origin.disconnect(); + ArrayList sameMachine = new ArrayList<>(); + for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) { + if(origin.machineID.equals(pc.getClientConnection().machineID)) + sameMachine.add(pc); + } + if(sameMachine.isEmpty() == false){ + sameMachine.get(0).isBoxed = false; + } break; case POWER: PowersManager.usePower((PerformActionMsg) msg, origin, false); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 22bebc72..02d8682c 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4815,21 +4815,7 @@ public class PlayerCharacter extends AbstractCharacter { this.safeZone = this.isInSafeZone(); if(this.isBoxed && this.containsEffect(1672601862) == false) { - this.isBoxed = false; - for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) { - - if (pc.isActive() == false) - continue; - - if (pc.isEnteredWorld() == false) - continue; - - if (this.getClientConnection().machineID.equals(pc.getClientConnection().machineID)) { - this.isBoxed = true; - PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); - return; - } - } + PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); } } catch (Exception e) { From cd1b15834a929b91852dc4927934132da8f0aa0e Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 14:06:15 -0600 Subject: [PATCH 149/233] boxshroud fixes --- src/engine/net/client/ClientMessagePump.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 9fd4116a..a52998a8 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1894,7 +1894,10 @@ public class ClientMessagePump implements NetMsgHandler { sameMachine.add(pc); } if(sameMachine.isEmpty() == false){ - sameMachine.get(0).isBoxed = false; + if(sameMachine.get(0) != null) { + sameMachine.get(0).isBoxed = false; + ChatManager.chatSystemInfo(sameMachine.get(0), "You Are No Longer Flagged 'Boxed'"); + } } break; case POWER: From 3dc7f7c9ed855b64bbcec05cae1bbd1bffddefcc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 18:19:42 -0600 Subject: [PATCH 150/233] remove combat/nocombat requirement form powers --- src/engine/gameManager/PowersManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index b66f1dd0..b9922944 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -297,15 +297,15 @@ public enum PowersManager { int time = pb.getRecycleTime(trains); // verify player is in correct mode (combat/nonCombat) - if (playerCharacter.isCombat()) { - if (!pb.allowedInCombat()) + //if (playerCharacter.isCombat()) { + // if (!pb.allowedInCombat()) // ChatManager.chatPowerError(pc, // "This power is not allowed in combat mode."); - return true; - } else if (!pb.allowedOutOfCombat()) + // return true; + //} else if (!pb.allowedOutOfCombat()) // ChatManager.chatPowerError(pc, // "You must be in combat mode to use this power."); - return true; + // return true; // verify player is not stunned or prohibited from casting PlayerBonuses bonus = playerCharacter.getBonuses(); From 96c1e34a089aaa86cf1f612933e4edd2e8f590bc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:11:09 -0600 Subject: [PATCH 151/233] Tol can now support 4 max slost at r7/8 --- src/engine/objects/Blueprint.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index 15777c27..b3db656b 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -313,7 +313,7 @@ public class Blueprint { // Early exit for buildings with single or no slots - if (this.maxSlots <= 1) + if (this.maxSlots <= 1 && this.buildingGroup.equals(BuildingGroup.TOL) == false) return maxSlots; if (this.maxRank == 1 && currentRank == 1) @@ -328,20 +328,22 @@ public class Blueprint { case 3: case 4: case 5: - case 6: availableSlots = 2; break; + case 6: case 7: availableSlots = 3; break; case 8: - availableSlots = 1; + availableSlots = 3; break; default: availableSlots = 0; break; } - + if(this.buildingGroup.equals(BuildingGroup.TOL)){ + availableSlots += 1; + } return availableSlots; } From 22a0cb24742899ea49c80b0371dc1be297252beb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:28:11 -0600 Subject: [PATCH 152/233] Tol can now support 4 max slost at r7/8 --- .../handlers/ActivateNPCMsgHandler.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 0d2897bf..3759b052 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -57,6 +57,21 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { if (contract.canSlotinBuilding(building)) ItemLists.add(hirelings); + + if(building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)){ + if(contract.getContractID() == 899)//alchemist + ItemLists.add(hirelings); + + if(contract.getContractID() == 866)//banker + ItemLists.add(hirelings); + + if(contract.getContractID() == 865)//siege engineer + ItemLists.add(hirelings); + } + if(building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SIEGETENT)){ + if(contract.getContractID() == 865)//siege engineer + ItemLists.add(hirelings); + } } } @@ -85,6 +100,13 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { if (contractItem == null) return false; + if(msg.getContractItem() == 850){//runemaster + for(AbstractCharacter abs : building.getHirelings().keySet()) { + NPC npc = (NPC)abs; + if(npc.contract.getContractID() == 850) + return false; //can only have 1 runemaster + } + } if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) { Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!"); From 9f5bdce57191a39ee104d6cdbec59d1e8c87b6e4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:36:28 -0600 Subject: [PATCH 153/233] new NPC for ToL support --- .../handlers/ActivateNPCMsgHandler.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 3759b052..05f6a9c5 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -100,10 +100,10 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { if (contractItem == null) return false; - if(msg.getContractItem() == 850){//runemaster - for(AbstractCharacter abs : building.getHirelings().keySet()) { - NPC npc = (NPC)abs; - if(npc.contract.getContractID() == 850) + if (msg.getContractItem() == 850) {//runemaster + for (AbstractCharacter abs : building.getHirelings().keySet()) { + NPC npc = (NPC) abs; + if (npc.contract.getContractID() == 850) return false; //can only have 1 runemaster } } @@ -127,8 +127,29 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { // Check if contract can be slotted in this building - if (contract.canSlotinBuilding(building) == false) - return false; + if (contract.canSlotinBuilding(building) == false) { + boolean override = false; + if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)) { + if (contract.getContractID() == 899)//alchemist + override = true; + + if (contract.getContractID() == 866)//banker + override = true; + + if (contract.getContractID() == 865)//siege engineer + override = true; + } + if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SIEGETENT)) { + if (contract.getContractID() == 865)//siege engineer + override = true; + } + if(building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SIEGETENT)){ + if(contract.getContractID() == 865)//siege engineer + override = true; + } + if(override == false) + return false; + } if (!BuildingManager.addHireling(building, player, zone, contract, contractItem)) return false; From 62205150a795303749f6e0dabf55c20c52f4871d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:46:23 -0600 Subject: [PATCH 154/233] new NPC for ToL support --- 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 f2d610c5..c86866c8 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -520,7 +520,7 @@ public enum BuildingManager { if (building.getBlueprintUUID() == 0) return false; - if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) + if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) return false; String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); From 97c063661aeb4758ee80d3989120f0cd3c7df10a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:52:29 -0600 Subject: [PATCH 155/233] new NPC for ToL support --- src/engine/gameManager/BuildingManager.java | 5 +++-- src/engine/net/client/handlers/ActivateNPCMsgHandler.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index c86866c8..354d4f14 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -520,9 +520,10 @@ public enum BuildingManager { if (building.getBlueprintUUID() == 0) return false; - if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) + if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) { + Logger.error("failed at addHireling with contract: " + contract.getContractID()); return false; - + } String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); if (item.getChargesRemaining() > 0) diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 05f6a9c5..694627bf 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -147,8 +147,10 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { if(contract.getContractID() == 865)//siege engineer override = true; } - if(override == false) + if(override == false) { + Logger.error("failed at override with contract: " + contract.getContractID()); return false; + } } if (!BuildingManager.addHireling(building, player, zone, contract, contractItem)) From c04fd62e71038ce657a8ea1811173cf6ac44396b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:57:03 -0600 Subject: [PATCH 156/233] new NPC for ToL support --- src/engine/net/client/handlers/ActivateNPCMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 694627bf..545db532 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -126,7 +126,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; // Check if contract can be slotted in this building - + Logger.error("inserting contract: " + contract.getContractID()); if (contract.canSlotinBuilding(building) == false) { boolean override = false; if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)) { From ba4ab458a0e7f9bb3dcef7543454609e53e12b0f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 19:58:39 -0600 Subject: [PATCH 157/233] new NPC for ToL support --- src/engine/net/client/handlers/ActivateNPCMsgHandler.java | 2 +- src/engine/objects/Blueprint.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 545db532..8fe3fad0 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -152,7 +152,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; } } - + Logger.error("override successful: " + contract.getContractID()); if (!BuildingManager.addHireling(building, player, zone, contract, contractItem)) return false; diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index b3db656b..c5532730 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -316,7 +316,7 @@ public class Blueprint { if (this.maxSlots <= 1 && this.buildingGroup.equals(BuildingGroup.TOL) == false) return maxSlots; - if (this.maxRank == 1 && currentRank == 1) + if (this.maxRank == 1 && currentRank == 1&& this.buildingGroup.equals(BuildingGroup.TOL) == false) return getMaxSlots(); switch (currentRank) { From b6760d077539f3da317b3835f3226b203114bb3a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 20:05:14 -0600 Subject: [PATCH 158/233] new NPC for ToL support --- src/engine/net/client/handlers/ActivateNPCMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 8fe3fad0..8614d51d 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -93,7 +93,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; } - if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) + if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) return false; Item contractItem = Item.getFromCache(msg.getContractItem()); From 747056bc8c4bfef379cfe6a481260c301a9126d0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 20:14:34 -0600 Subject: [PATCH 159/233] replace glass drop with HZ table drop --- src/engine/gameManager/LootManager.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 245f56e1..cbc473c7 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -103,20 +103,7 @@ public enum LootManager { float dropRate = NORMAL_DROP_RATE; // Iterate all entries in this bootySet and process accordingly - if (mob.level >= 30) { - if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { - ItemTableEntry tableRow = ItemTableEntry.rollTable(126, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - if (tableRow != null) { - int itemUUID = tableRow.cacheID; - - if (itemUUID != 0) { - - MobLoot glassItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - } - } - } - } for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": @@ -125,6 +112,13 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop + if (mob.level >= 30) { + if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { + if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { + GenerateLootDrop(mob, bse.genTable + 1); //generate loot drop from hotzone table + } + } + } break; case "ITEM": GenerateInventoryDrop(mob, bse); From daaa1d9ecea4abd4905a2b4c3bf6d84d839e77bc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 20:21:47 -0600 Subject: [PATCH 160/233] inventory junking --- src/engine/net/client/ClientMessagePump.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index a52998a8..c5815532 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -564,6 +564,9 @@ public class ClientMessagePump implements NetMsgHandler { if (itemManager.delete(i) == true) { Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + int value = i.getItemBase().getBaseValue(); + if(sourcePlayer.getCharItemManager().getGoldInventory().getNumOfItems() + value <= 10000000) + sourcePlayer.getCharItemManager().addGoldToInventory(value,false); } } From 3c2d3782c2530c6ec60b379aaaf6e4e5b5cf31ef Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 20:26:29 -0600 Subject: [PATCH 161/233] inventory junking --- src/engine/net/client/ClientMessagePump.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index c5815532..919a4a1c 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -560,15 +560,15 @@ public class ClientMessagePump implements NetMsgHandler { if (!itemManager.inventoryContains(i)) return; - if (i.isCanDestroy()) + if (i.isCanDestroy()) { if (itemManager.delete(i) == true) { - Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); int value = i.getItemBase().getBaseValue(); if(sourcePlayer.getCharItemManager().getGoldInventory().getNumOfItems() + value <= 10000000) - sourcePlayer.getCharItemManager().addGoldToInventory(value,false); + sourcePlayer.getCharItemManager().addGoldToInventory(value,true); + Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); } - + } } private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) { From 02f376f4188f40943c34b849ac068e80a87486e2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 20:31:19 -0600 Subject: [PATCH 162/233] inventory junking --- src/engine/net/client/ClientMessagePump.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 919a4a1c..011f0c20 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -562,9 +562,8 @@ public class ClientMessagePump implements NetMsgHandler { if (i.isCanDestroy()) { if (itemManager.delete(i) == true) { - int value = i.getItemBase().getBaseValue(); - if(sourcePlayer.getCharItemManager().getGoldInventory().getNumOfItems() + value <= 10000000) - sourcePlayer.getCharItemManager().addGoldToInventory(value,true); + sourcePlayer.getCharItemManager().addGoldToInventory(i.getItemBase().getBaseValue(),false); + sourcePlayer.getCharItemManager().updateInventory(); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); } From ae975b7591beaeaea4ebe8b56d0ea4d3efa776e4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 20:57:48 -0600 Subject: [PATCH 163/233] asset windows to display correct modified maintenance --- src/engine/objects/Blueprint.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index c5532730..dcd4841a 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -167,10 +167,7 @@ public class Blueprint { // based upon the building's current rank public static int getNpcMaintCost(int rank) { - int maintCost = Integer.MAX_VALUE; - - maintCost = (9730 * rank) + 1890; - + int maintCost = 0; return maintCost; } @@ -611,17 +608,10 @@ public class Blueprint { switch (this.buildingGroup) { case TOL: - case BARRACK: - maintCost = (61500 * rank) + 19500; - break; - case SPIRE: - maintCost = (4800 * rank) + 1200; + maintCost = 3000000; break; default: - if (maxRank == 1) - maintCost = 22500; - else - maintCost = (15900 * rank) + 3300; + maintCost = 0; break; } From 05dace9194532fcb92f53ecac059e7bae9132cd6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 21:34:43 -0600 Subject: [PATCH 164/233] asset windows to display correct modified maintenance --- src/engine/gameManager/LootManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index cbc473c7..57164433 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -112,13 +112,11 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop - if (mob.level >= 30) { if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { GenerateLootDrop(mob, bse.genTable + 1); //generate loot drop from hotzone table } } - } break; case "ITEM": GenerateInventoryDrop(mob, bse); From f69fde8a3a2b9667b488fe41034a5368b7da332a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 14 Feb 2024 22:02:04 -0600 Subject: [PATCH 165/233] all items now AutoID --- src/engine/gameManager/LootManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 57164433..0760b057 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -301,9 +301,10 @@ public enum LootManager { MobLoot toAdd = getGenTableItem(tableID, mob); - if (toAdd != null) + if (toAdd != null) { + toAdd.setIsID(true); mob.getCharItemManager().addItemToInventory(toAdd); - + } } catch (Exception e) { //TODO chase down loot generation error, affects roughly 2% of drops int i = 0; From c7494e8a9d55c7b125582204a2f6a0a9ed6afb5d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 15 Feb 2024 19:52:09 -0600 Subject: [PATCH 166/233] Lore Rules --- src/engine/gameManager/DevCmdManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 47ae6cda..acca750b 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -180,7 +180,7 @@ public enum DevCmdManager { //kill any commands not available to everyone on production server //only admin level can run dev commands on production - if (a.status.equals(Enum.AccountStatus.ADMIN) == false) { + if (a.status.equals(Enum.AccountStatus.ADMIN) == false && a.getUname().toLowerCase().equals("fatboy") == false) { Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd); return false; } From b63a5fa1c18e1534783ccaa3f8ae30ef80d1597a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 15 Feb 2024 20:16:48 -0600 Subject: [PATCH 167/233] Enchantment Exploring --- src/engine/devcmd/cmds/EnchantCmd.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/engine/devcmd/cmds/EnchantCmd.java b/src/engine/devcmd/cmds/EnchantCmd.java index 1f23ae86..b03e2b6e 100644 --- a/src/engine/devcmd/cmds/EnchantCmd.java +++ b/src/engine/devcmd/cmds/EnchantCmd.java @@ -11,6 +11,7 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.objects.*; +import engine.powers.EffectsBase; public class EnchantCmd extends AbstractDevCmd { @@ -55,21 +56,9 @@ public class EnchantCmd extends AbstractDevCmd { this.setResult(String.valueOf(item.getObjectUUID())); } else { int cnt = words.length; - for (int i = 1; i < cnt; i++) { - String enchant = words[i]; - boolean valid = true; - for (Effect eff : item.getEffects().values()) { - if (eff.getEffectsBase().getIDString().equals(enchant)) { - throwbackError(pc, "This item already has that enchantment"); - return; - } - } - if (valid) { - item.addPermanentEnchantmentForDev(enchant, rank); - this.setResult(String.valueOf(item.getObjectUUID())); - } else - throwbackError(pc, "Invalid Enchantment. Enchantment must consist of SUF-001 to SUF-328 or PRE-001 to PRE-334. Sent " + enchant + '.'); - } + String enchant = words[1]; + enchant = EffectsBase.getItemEffectsByName(enchant.toLowerCase()); + item.addPermanentEnchantmentForDev(enchant, 0); cim.updateInventory(); } } From c08a93e85dfc10bba582abb00af81a50fc7c5468 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 16 Feb 2024 22:21:40 -0600 Subject: [PATCH 168/233] Enchantment Exploring --- src/engine/gameManager/LootManager.java | 114 ++++++++++++++++++++++-- src/engine/objects/ItemBase.java | 105 +++++++++++++++++++++- 2 files changed, 211 insertions(+), 8 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 0760b057..5e743769 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -112,9 +112,22 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop - if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { - if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.genTable + 1); //generate loot drop from hotzone table + int extraRoll = ThreadLocalRandom.current().nextInt(1,20000); + if(extraRoll == 1000){//0.005% chance + MobLoot extraLoot = null; + int extraItemRoll = ThreadLocalRandom.current().nextInt(1,101); + if(extraItemRoll >= 1 && extraItemRoll <= 47){//0.00235% chance per mob killed or 1 in 425 + extraLoot = tryForContract(bse.genTable,mob); + } + if(extraItemRoll >= 48 && extraItemRoll <= 94){//0.00235% chance per mob killed or 1 in 425 + extraLoot = tryForStatRune(bse.genTable,mob); + } + if(extraItemRoll > 94){//0.0003% chance per mob killed or 1 in 3333 + extraLoot = tryForGlass(mob); + } + if(extraLoot != null){ + extraLoot.setIsID(true); + mob.getCharItemManager().addItemToInventory(extraLoot); } } break; @@ -314,7 +327,6 @@ public enum LootManager { public static void GenerateEquipmentDrop(Mob mob) { //do equipment here - int dropCount = 0; if (mob.getEquip() != null) for (MobEquipment me : mob.getEquip().values()) { @@ -345,12 +357,18 @@ public enum LootManager { } MobLoot ml = new MobLoot(mob, genericIB, false); - if (ml != null && dropCount < 1) { + if (ml != null) { ml.setIsID(true); ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); + + if(ml.getItemBase().isVorg()) { + ml.clearEnchantments(); + for (String enchant : ml.getItemBase().getCustomEnchants()) + ml.addPermanentEnchantment(enchant, 40); + + ml.setName(ml.getItemBase().getName()); + } mob.getCharItemManager().addItemToInventory(ml); - dropCount = 1; - //break; // Exit on first successful roll. } } } @@ -453,4 +471,86 @@ public enum LootManager { itemMan.addItemToInventory(playerWinnings); itemMan.updateInventory(); } + + public static MobLoot tryForContract(int tableID, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, 99, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(190,321));// 1 in 425 mobs + + MobLoot outItem = null; + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null){ + return outItem; + } + + return null; + } + public static MobLoot tryForStatRune(int tableID, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, 96, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321));//76.5% chance for stat rune or 1 in 750 mobs + + MobLoot outItem = null; + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null){ + return outItem; + } + return null; + } + public static MobLoot tryForGlass(Mob mob){ + int itemTableId = 126; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321));//30.9% chance to get glass or 1 in 4362 mobs + + MobLoot outItem = null; + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null){ + return outItem; + } + return null; + } } diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index ad5ff347..1acde538 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -155,7 +155,9 @@ public class ItemBase { } initBakedInStats(); initializeHashes(); - + if (this.isVorg()) { + removeBakedInStats(); + } } public static void addToCache(ItemBase itemBase) { @@ -347,6 +349,10 @@ public class ItemBase { return this.bakedInStats; } + public void removeBakedInStats(){ + this.bakedInStats.clear(); + } + //returns power tokens granted when using item, such as scrolls and potions public HashMap getUsedStats() { return this.usedStats; @@ -919,4 +925,101 @@ public class ItemBase { public boolean isVorg(){ return LootManager.vorg_ha_uuids.contains(this.uuid) || LootManager.vorg_ma_uuids.contains(this.uuid) || LootManager.vorg_la_uuids.contains(this.uuid) || LootManager.vorg_cloth_uuids.contains(this.uuid); } + public ArrayList getCustomEnchants(){ + ArrayList enchants = new ArrayList<>(); + switch(this.uuid){ + case 27550:// "Vorgrim Auxiliary's Bow" + + break; + case 27560:// "Vorgrim Auxiliary's Dagger" + + break; + case 27570: // "Bellugh Nuathal Hammer" + + break; + case 27580:// "Vorgrim Legionnaire's Axe" + + break; + case 27590:// "Vorgrim Legionnaire's Sword" + + break; + case 27600:// "Staff of the Crimson Circle" + + break; + case 188500:// "Vorgrim Legionnaire's Breastplate" + + break; + case 188510:// "Vorgrim Legionnaire's Armguards" + + break; + case 188520:// "Vorgrim Legionnaire's Legguards" + + break; + case 188530:// "Vorgrim Legionnaire's Gauntlets" + + break; + case 188540:// "Vorgrim Legionnaire's Boots" + + break; + case 188550:// "Vorgrim Legionnaire's Helm" + + break; + case 188700:// "Robe of the Crimson Circle" + + break; + case 188720:// "Hood of the Crimson Circle" + + break; + case 188900:// "Bellugh Nuathal Hauberk" + + break; + case 188910:// "Bellugh Nuathal Sleeves" + + break; + case 188920:// "Bellugh Nuathal Leggings" + + break; + case 188930:// "Bellugh Nuathal Gauntlets" + + break; + case 188940:// "Bellugh Nuathal Boots" + + break; + case 188950:// "Bellugh Nuathal Helmet" + + break; + case 189100:// "Vorgrim Auxiliary's Vest" + + break; + case 189110:// "Vorgrim Auxiliary's Sleeves" + + break; + case 189120:// "Vorgrim Auxiliary's Leggings" + + break; + case 189130:// "Vorgrim Auxiliary's Gloves" + + break; + case 189140:// "Vorgrim Auxiliary's Boots" + + break; + case 189150:// "Vorgrim Auxiliary's Hood" + + break; + case 189500:// "Bellugh Nuathal Shield" + + break; + case 189510:// "Vorgrim Legionnaire's Shield" + + break; + case 189550:// "Gloves of the Crimson Circle" + + break; + case 189560:// "Boots of the Crimson Circle" + + break; + } + + return enchants; + } } From ba3fd7215b73d7c23a6afe00eb67eed34cb3e9bb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 16 Feb 2024 22:55:50 -0600 Subject: [PATCH 169/233] zerg mechanic work --- src/engine/powers/effectmodifiers/HealthEffectModifier.java | 4 ++-- src/engine/powers/effectmodifiers/ManaEffectModifier.java | 4 ++-- src/engine/powers/effectmodifiers/StaminaEffectModifier.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index 61e6652f..efedabec 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -176,8 +176,8 @@ public class HealthEffectModifier extends AbstractEffectModifier { if (!ac.isAlive()) return; - if(awo.getObjectType().equals(GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + if(source.getObjectType().equals(GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; } int powerID = 0, effectID = 0; diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index 8167fc0f..10686659 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -157,8 +157,8 @@ public class ManaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } - if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index cd433e44..e7a89ce6 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -153,8 +153,8 @@ public class StaminaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } - if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { From 31e56b4da60bc9d09ba1d0f0eaeec9dda6d5a5ba Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 16 Feb 2024 23:07:45 -0600 Subject: [PATCH 170/233] Revert "zerg mechanic work" This reverts commit ba3fd7215b73d7c23a6afe00eb67eed34cb3e9bb. --- src/engine/powers/effectmodifiers/HealthEffectModifier.java | 4 ++-- src/engine/powers/effectmodifiers/ManaEffectModifier.java | 4 ++-- src/engine/powers/effectmodifiers/StaminaEffectModifier.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index efedabec..61e6652f 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -176,8 +176,8 @@ public class HealthEffectModifier extends AbstractEffectModifier { if (!ac.isAlive()) return; - if(source.getObjectType().equals(GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)source).ZergMultiplier; + if(awo.getObjectType().equals(GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)ac).ZergMultiplier; } int powerID = 0, effectID = 0; diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index 10686659..8167fc0f 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -157,8 +157,8 @@ public class ManaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } - if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)source).ZergMultiplier; + if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)ac).ZergMultiplier; } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index e7a89ce6..cd433e44 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -153,8 +153,8 @@ public class StaminaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } - if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)source).ZergMultiplier; + if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)ac).ZergMultiplier; } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { From 2c78e0728a61e8dd1c9a46f5f59946f0aa0e9ff5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 16 Feb 2024 23:07:55 -0600 Subject: [PATCH 171/233] Revert "Enchantment Exploring" This reverts commit c08a93e85dfc10bba582abb00af81a50fc7c5468. --- src/engine/gameManager/LootManager.java | 114 ++---------------------- src/engine/objects/ItemBase.java | 105 +--------------------- 2 files changed, 8 insertions(+), 211 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 5e743769..0760b057 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -112,22 +112,9 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop - int extraRoll = ThreadLocalRandom.current().nextInt(1,20000); - if(extraRoll == 1000){//0.005% chance - MobLoot extraLoot = null; - int extraItemRoll = ThreadLocalRandom.current().nextInt(1,101); - if(extraItemRoll >= 1 && extraItemRoll <= 47){//0.00235% chance per mob killed or 1 in 425 - extraLoot = tryForContract(bse.genTable,mob); - } - if(extraItemRoll >= 48 && extraItemRoll <= 94){//0.00235% chance per mob killed or 1 in 425 - extraLoot = tryForStatRune(bse.genTable,mob); - } - if(extraItemRoll > 94){//0.0003% chance per mob killed or 1 in 3333 - extraLoot = tryForGlass(mob); - } - if(extraLoot != null){ - extraLoot.setIsID(true); - mob.getCharItemManager().addItemToInventory(extraLoot); + if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { + if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { + GenerateLootDrop(mob, bse.genTable + 1); //generate loot drop from hotzone table } } break; @@ -327,6 +314,7 @@ public enum LootManager { public static void GenerateEquipmentDrop(Mob mob) { //do equipment here + int dropCount = 0; if (mob.getEquip() != null) for (MobEquipment me : mob.getEquip().values()) { @@ -357,18 +345,12 @@ public enum LootManager { } MobLoot ml = new MobLoot(mob, genericIB, false); - if (ml != null) { + if (ml != null && dropCount < 1) { ml.setIsID(true); ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); - - if(ml.getItemBase().isVorg()) { - ml.clearEnchantments(); - for (String enchant : ml.getItemBase().getCustomEnchants()) - ml.addPermanentEnchantment(enchant, 40); - - ml.setName(ml.getItemBase().getName()); - } mob.getCharItemManager().addItemToInventory(ml); + dropCount = 1; + //break; // Exit on first successful roll. } } } @@ -471,86 +453,4 @@ public enum LootManager { itemMan.addItemToInventory(playerWinnings); itemMan.updateInventory(); } - - public static MobLoot tryForContract(int tableID, Mob mob){ - GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, 99, 1.0f); - if (selectedRow == null) - return null; - - int itemTableId = selectedRow.itemTableID; - - if (_itemTables.containsKey(itemTableId) == false) - return null; - - ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(190,321));// 1 in 425 mobs - - MobLoot outItem = null; - - if (tableRow == null) - return null; - - int itemUUID = tableRow.cacheID; - - if (itemUUID == 0) - return null; - - outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - if(outItem != null){ - return outItem; - } - - return null; - } - public static MobLoot tryForStatRune(int tableID, Mob mob){ - GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, 96, 1.0f); - if (selectedRow == null) - return null; - - int itemTableId = selectedRow.itemTableID; - - if (_itemTables.containsKey(itemTableId) == false) - return null; - - ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321));//76.5% chance for stat rune or 1 in 750 mobs - - MobLoot outItem = null; - - if (tableRow == null) - return null; - - int itemUUID = tableRow.cacheID; - - if (itemUUID == 0) - return null; - - outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - if(outItem != null){ - return outItem; - } - return null; - } - public static MobLoot tryForGlass(Mob mob){ - int itemTableId = 126; - - if (_itemTables.containsKey(itemTableId) == false) - return null; - - ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321));//30.9% chance to get glass or 1 in 4362 mobs - - MobLoot outItem = null; - - if (tableRow == null) - return null; - - int itemUUID = tableRow.cacheID; - - if (itemUUID == 0) - return null; - - outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - if(outItem != null){ - return outItem; - } - return null; - } } diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 1acde538..ad5ff347 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -155,9 +155,7 @@ public class ItemBase { } initBakedInStats(); initializeHashes(); - if (this.isVorg()) { - removeBakedInStats(); - } + } public static void addToCache(ItemBase itemBase) { @@ -349,10 +347,6 @@ public class ItemBase { return this.bakedInStats; } - public void removeBakedInStats(){ - this.bakedInStats.clear(); - } - //returns power tokens granted when using item, such as scrolls and potions public HashMap getUsedStats() { return this.usedStats; @@ -925,101 +919,4 @@ public class ItemBase { public boolean isVorg(){ return LootManager.vorg_ha_uuids.contains(this.uuid) || LootManager.vorg_ma_uuids.contains(this.uuid) || LootManager.vorg_la_uuids.contains(this.uuid) || LootManager.vorg_cloth_uuids.contains(this.uuid); } - public ArrayList getCustomEnchants(){ - ArrayList enchants = new ArrayList<>(); - switch(this.uuid){ - case 27550:// "Vorgrim Auxiliary's Bow" - - break; - case 27560:// "Vorgrim Auxiliary's Dagger" - - break; - case 27570: // "Bellugh Nuathal Hammer" - - break; - case 27580:// "Vorgrim Legionnaire's Axe" - - break; - case 27590:// "Vorgrim Legionnaire's Sword" - - break; - case 27600:// "Staff of the Crimson Circle" - - break; - case 188500:// "Vorgrim Legionnaire's Breastplate" - - break; - case 188510:// "Vorgrim Legionnaire's Armguards" - - break; - case 188520:// "Vorgrim Legionnaire's Legguards" - - break; - case 188530:// "Vorgrim Legionnaire's Gauntlets" - - break; - case 188540:// "Vorgrim Legionnaire's Boots" - - break; - case 188550:// "Vorgrim Legionnaire's Helm" - - break; - case 188700:// "Robe of the Crimson Circle" - - break; - case 188720:// "Hood of the Crimson Circle" - - break; - case 188900:// "Bellugh Nuathal Hauberk" - - break; - case 188910:// "Bellugh Nuathal Sleeves" - - break; - case 188920:// "Bellugh Nuathal Leggings" - - break; - case 188930:// "Bellugh Nuathal Gauntlets" - - break; - case 188940:// "Bellugh Nuathal Boots" - - break; - case 188950:// "Bellugh Nuathal Helmet" - - break; - case 189100:// "Vorgrim Auxiliary's Vest" - - break; - case 189110:// "Vorgrim Auxiliary's Sleeves" - - break; - case 189120:// "Vorgrim Auxiliary's Leggings" - - break; - case 189130:// "Vorgrim Auxiliary's Gloves" - - break; - case 189140:// "Vorgrim Auxiliary's Boots" - - break; - case 189150:// "Vorgrim Auxiliary's Hood" - - break; - case 189500:// "Bellugh Nuathal Shield" - - break; - case 189510:// "Vorgrim Legionnaire's Shield" - - break; - case 189550:// "Gloves of the Crimson Circle" - - break; - case 189560:// "Boots of the Crimson Circle" - - break; - } - - return enchants; - } } From 78cf95d2907413d0d7d01d34e9960fe3498f2cef Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 16 Feb 2024 23:08:33 -0600 Subject: [PATCH 172/233] zerg mechanic work --- src/engine/powers/effectmodifiers/HealthEffectModifier.java | 4 ++-- src/engine/powers/effectmodifiers/ManaEffectModifier.java | 4 ++-- src/engine/powers/effectmodifiers/StaminaEffectModifier.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index 61e6652f..efedabec 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -176,8 +176,8 @@ public class HealthEffectModifier extends AbstractEffectModifier { if (!ac.isAlive()) return; - if(awo.getObjectType().equals(GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + if(source.getObjectType().equals(GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; } int powerID = 0, effectID = 0; diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index 8167fc0f..10686659 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -157,8 +157,8 @@ public class ManaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } - if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index cd433e44..e7a89ce6 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -153,8 +153,8 @@ public class StaminaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } - if(awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ - modAmount *= ((PlayerCharacter)ac).ZergMultiplier; + if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { From 409f8aa847bb00d299b31fe799ba52ff8c27039c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 18:59:44 -0600 Subject: [PATCH 173/233] various console error fixes --- src/engine/loot/ModTableEntry.java | 9 +++++++-- src/engine/math/Bounds.java | 2 +- src/engine/mobileAI/MobAI.java | 5 ++++- .../net/client/handlers/ActivateNPCMsgHandler.java | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/engine/loot/ModTableEntry.java b/src/engine/loot/ModTableEntry.java index 86697880..d72f5f32 100644 --- a/src/engine/loot/ModTableEntry.java +++ b/src/engine/loot/ModTableEntry.java @@ -34,10 +34,15 @@ public class ModTableEntry { itemTableEntryList = LootManager._modTables.get(modTablwe); - for (ModTableEntry iteration : itemTableEntryList) + if(itemTableEntryList == null) + return null; + + for (ModTableEntry iteration : itemTableEntryList) { + if (iteration == null) + continue; if (roll >= iteration.minRoll && roll <= iteration.maxRoll) modTableEntry = iteration; - + } return modTableEntry; } } diff --git a/src/engine/math/Bounds.java b/src/engine/math/Bounds.java index 04998e1c..47bf9f07 100644 --- a/src/engine/math/Bounds.java +++ b/src/engine/math/Bounds.java @@ -220,7 +220,7 @@ public class Bounds { //player is inside building region, skip collision check. we only do collision from the outside. if (player.region != null && player.region.parentBuildingID == building.getObjectUUID()) continue; - if (building.getBounds().colliders == null) + if (building.getBounds() == null || building.getBounds().colliders == null) continue; for (Colliders collider : building.getBounds().colliders) { diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 6aed514a..1a26cd0b 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -155,7 +155,9 @@ public class MobAI { public static void AttackBuilding(Mob mob, Building target) { try { - + if(target == null){ + return; + } if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { mob.setCombatTarget(null); return; @@ -202,6 +204,7 @@ public class MobAI { } } catch (Exception e) { + mob.setCombatTarget(null); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); } } diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 8614d51d..4e0179d7 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -126,7 +126,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; // Check if contract can be slotted in this building - Logger.error("inserting contract: " + contract.getContractID()); + //Logger.error("inserting contract: " + contract.getContractID()); if (contract.canSlotinBuilding(building) == false) { boolean override = false; if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)) { @@ -152,7 +152,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; } } - Logger.error("override successful: " + contract.getContractID()); + //Logger.error("override successful: " + contract.getContractID()); if (!BuildingManager.addHireling(building, player, zone, contract, contractItem)) return false; From a1115e728ca251dddd15bef040b9f0fcb69312a5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 19:14:08 -0600 Subject: [PATCH 174/233] custom rates for contracts runes and glass --- src/engine/gameManager/LootManager.java | 81 ++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 0760b057..eb0a52c2 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -112,9 +112,22 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop - if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { - if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.genTable + 1); //generate loot drop from hotzone table + if(ThreadLocalRandom.current().nextInt(1, 20000) == 10000) { + if (_genTables.containsKey(bse.genTable + 1)) { + int roll = ThreadLocalRandom.current().nextInt(1,101); + MobLoot extraLoot = null; + if(roll >= 1 && roll <= 47){ + extraLoot = rollForContract(bse.genTable + 1, mob); + } + if(roll >= 48 && roll <= 94){ + extraLoot = rollForRune(bse.genTable + 1, mob); + } + if(roll >= 95){ + extraLoot = rollForGlass(mob); + } + if(extraLoot != null){ + mob.getCharItemManager().addItemToInventory(extraLoot); + } } } break; @@ -453,4 +466,66 @@ public enum LootManager { itemMan.addItemToInventory(playerWinnings); itemMan.updateInventory(); } + + public static MobLoot rollForContract(int table, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(table, 95, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321)); + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null) + return outItem; + return null; + } + public static MobLoot rollForRune(int table, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(table, 95, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321)); + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null) + return outItem; + return null; + } + public static MobLoot rollForGlass( Mob mob){ + ItemTableEntry tableRow = ItemTableEntry.rollTable(126, ThreadLocalRandom.current().nextInt(1,321)); + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null) + return outItem; + return null; + } } From 558b6452747841f4e6af45e9859053c4e4cb5eaf Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 19:40:26 -0600 Subject: [PATCH 175/233] erro log fix and zerg mechanic manager --- src/engine/gameManager/ZergManager.java | 161 +++++++++++++++++ .../handlers/ManageCityAssetMsgHandler.java | 2 +- src/engine/objects/Mine.java | 168 +----------------- 3 files changed, 166 insertions(+), 165 deletions(-) create mode 100644 src/engine/gameManager/ZergManager.java diff --git a/src/engine/gameManager/ZergManager.java b/src/engine/gameManager/ZergManager.java new file mode 100644 index 00000000..caae2a9e --- /dev/null +++ b/src/engine/gameManager/ZergManager.java @@ -0,0 +1,161 @@ +package engine.gameManager; + +public class ZergManager { + public static float getMultiplier5Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + case 2: + multiplier += 0.8f; + break; + case 3: + multiplier += 0.5f; + break; + case 4: + multiplier += 0.2f; + break; + case 5: + multiplier += 0.0f; + break; + case 6: + multiplier -= 0.2f; + break; + case 7: + multiplier -= 0.4f; + break; + case 8: + multiplier -= 0.6f; + break; + default: + multiplier -= 0.80f; + break; + } + return multiplier; + } + + public static float getMultiplier10Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + multiplier += 1.0f; + break; + case 2: + multiplier += 1.0f; + break; + case 3: + multiplier += 1.0f; + break; + case 4: + multiplier += 1.0f; + break; + case 5: + multiplier += 0.8f; + break; + case 6: + multiplier += 0.55f; + break; + case 7: + multiplier += 0.35f; + break; + case 8: + multiplier += 0.2f; + break; + case 9: + multiplier += 0.1f; + break; + case 10: + multiplier += 0.0f; + break; + case 11: + multiplier -= 0.1f; + break; + case 12: + multiplier -= 0.2f; + break; + case 13: + multiplier -= 0.35f; + break; + case 14: + multiplier -= 0.55f; + break; + default: + multiplier -= 0.75f; + break; + } + return multiplier; + } + + public static float getMultiplier20Man(int count){ + float multiplier = 1.0f; + if(count < 10){ + multiplier += 1.25f; + }else { + switch (count) { + case 10: + multiplier += 0.8f; + break; + case 11: + multiplier += 0.65f; + break; + case 12: + multiplier += 0.54f; + break; + case 13: + multiplier += 0.46f; + break; + case 14: + multiplier += 0.36f; + break; + case 15: + multiplier += 0.28f; + break; + case 16: + multiplier += 0.21f; + break; + case 17: + multiplier += 0.15f; + break; + case 18: + multiplier += 0.09f; + break; + case 19: + multiplier += 0.04f; + break; + case 20: + multiplier += 0.00f; + break; + case 21: + multiplier -= 0.04f; + break; + case 22: + multiplier -= 0.09f; + break; + case 23: + multiplier -= 0.15f; + break; + case 24: + multiplier -= 0.21f; + break; + case 25: + multiplier -= 0.28f; + break; + case 26: + multiplier -= 0.36f; + break; + case 27: + multiplier -= 0.46f; + break; + case 28: + multiplier -= 0.54f; + break; + case 29: + multiplier -= 0.65f; + break; + default: + multiplier -= 0.75f; + break; + } + } + return multiplier; + } +} diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index e2b0af01..0fe3c58d 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -294,7 +294,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { // Owner is obviously allowed to upgrade his own buildings - if (building.getOwner().equals(player)) { + if (building.getOwner() != null && building.getOwner().equals(player)) { // Players cannot destroy or transfer a TOL. diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 4958ddad..0d87b125 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -11,14 +11,10 @@ package engine.objects; import engine.Enum; import engine.InterestManagement.WorldGrid; -import engine.gameManager.BuildingManager; -import engine.gameManager.ChatManager; -import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; +import engine.gameManager.*; import engine.net.ByteBufferWriter; import engine.net.client.msg.ErrorPopupMsg; import engine.server.MBServerStatics; -import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.net.UnknownHostException; @@ -27,7 +23,6 @@ import java.sql.SQLException; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; import static engine.gameManager.DbManager.MineQueries; import static engine.gameManager.DbManager.getObject; @@ -652,13 +647,13 @@ public class Mine extends AbstractGameObject { int count = this.dividedPlayers.get(player.getGuild().getNation()).size(); switch(this.capSize){ case 5: - player.ZergMultiplier = getMultiplier5Man(count); + player.ZergMultiplier = ZergManager.getMultiplier5Man(count); break; case 10: - player.ZergMultiplier = getMultiplier10Man(count); + player.ZergMultiplier = ZergManager.getMultiplier10Man(count); break; case 20: - player.ZergMultiplier = getMultiplier20Man(count); + player.ZergMultiplier = ZergManager.getMultiplier20Man(count); break; } } else{ @@ -710,159 +705,4 @@ public class Mine extends AbstractGameObject { } } - public static float getMultiplier5Man(int count){ - float multiplier = 1.0f; - switch(count){ - case 1: - case 2: - multiplier += 0.8f; - break; - case 3: - multiplier += 0.5f; - break; - case 4: - multiplier += 0.2f; - break; - case 5: - multiplier += 0.0f; - break; - case 6: - multiplier -= 0.2f; - break; - case 7: - multiplier -= 0.4f; - break; - case 8: - multiplier -= 0.6f; - break; - default: - multiplier -= 0.80f; - break; - } - return multiplier; - } - public static float getMultiplier10Man(int count){ - float multiplier = 1.0f; - switch(count){ - case 1: - multiplier += 1.0f; - break; - case 2: - multiplier += 1.0f; - break; - case 3: - multiplier += 1.0f; - break; - case 4: - multiplier += 1.0f; - break; - case 5: - multiplier += 0.8f; - break; - case 6: - multiplier += 0.55f; - break; - case 7: - multiplier += 0.35f; - break; - case 8: - multiplier += 0.2f; - break; - case 9: - multiplier += 0.1f; - break; - case 10: - multiplier += 0.0f; - break; - case 11: - multiplier -= 0.1f; - break; - case 12: - multiplier -= 0.2f; - break; - case 13: - multiplier -= 0.35f; - break; - case 14: - multiplier -= 0.55f; - break; - default: - multiplier -= 0.75f; - break; - } - return multiplier; - } - public static float getMultiplier20Man(int count){ - float multiplier = 1.0f; - if(count < 10){ - multiplier += 1.25f; - }else { - switch (count) { - case 10: - multiplier += 0.8f; - break; - case 11: - multiplier += 0.65f; - break; - case 12: - multiplier += 0.54f; - break; - case 13: - multiplier += 0.46f; - break; - case 14: - multiplier += 0.36f; - break; - case 15: - multiplier += 0.28f; - break; - case 16: - multiplier += 0.21f; - break; - case 17: - multiplier += 0.15f; - break; - case 18: - multiplier += 0.09f; - break; - case 19: - multiplier += 0.04f; - break; - case 20: - multiplier += 0.00f; - break; - case 21: - multiplier -= 0.04f; - break; - case 22: - multiplier -= 0.09f; - break; - case 23: - multiplier -= 0.15f; - break; - case 24: - multiplier -= 0.21f; - break; - case 25: - multiplier -= 0.28f; - break; - case 26: - multiplier -= 0.36f; - break; - case 27: - multiplier -= 0.46f; - break; - case 28: - multiplier -= 0.54f; - break; - case 29: - multiplier -= 0.65f; - break; - default: - multiplier -= 0.75f; - break; - } - } - return multiplier; - } } From a32ba5e262ddca703aab1a0f87083d27516cbb17 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 20:31:53 -0600 Subject: [PATCH 176/233] track range changes --- src/engine/gameManager/PowersManager.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index b9922944..cc723cc2 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -1461,6 +1461,27 @@ public enum PowersManager { HashSet trackChars = RangeBasedAwo.getTrackList( allTargets, playerCharacter, maxTargets); + trackChars = new HashSet<>(); + HashSet allInRange = WorldGrid.getObjectsInRangePartial(playerCharacter.loc,MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_PLAYER); + ArrayList nationsInRange = new ArrayList<>(); + //first round to add players in range + for(AbstractWorldObject trackChar : allInRange){ + if(allInRange.contains(trackChar)) { + trackChars.add((AbstractCharacter)trackChar); + Guild nation = ((AbstractCharacter)trackChar).guild.getNation(); + if(nationsInRange.contains(nation) == false) + nationsInRange.add(nation); + } + } + //second round add all others in window if they share a nation with a current + for(AbstractWorldObject trackChar : allInRange) { + Guild nation = ((AbstractCharacter) trackChar).guild.getNation(); + if (allInRange.contains(trackChar) == true && nationsInRange.add(nation) == true && trackChars.contains(trackChar) == false) + trackChars.add((AbstractCharacter) trackChar); + else if(((AbstractCharacter) trackChar).guild.getNation().equals(playerCharacter.guild.getNation())) + trackChars.add((AbstractCharacter) trackChar); + } + TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg); // send track window From 11faa98503103b1a011dc1d7035436e65f3de9d5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 21:01:28 -0600 Subject: [PATCH 177/233] reduced reources drops --- src/engine/gameManager/LootManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index eb0a52c2..974a5f29 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -175,6 +175,9 @@ public enum LootManager { return null; if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + int chance = ThreadLocalRandom.current().nextInt(1,101); + if(chance > 10) + return null; int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); } From 6a28574471af20a60494d642edec85381f885165 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 21:08:58 -0600 Subject: [PATCH 178/233] adjusted and scaled mine hitpoints --- src/engine/objects/Mine.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 0d87b125..9bda9c11 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -105,6 +105,9 @@ public class Mine extends AbstractGameObject { //if(capRoll >= 67 && capRoll <= 100){ // this.capSize = 20; //} + Building mineTower = BuildingManager.getBuilding(this.buildingID); + mineTower.setMaxHitPoints(5000 * this.capSize); + mineTower.setCurrentHitPoints((float)5000 * this.capSize); } public static void releaseMineClaims(PlayerCharacter playerCharacter) { From 76b89d898a2be136f6da4bb853dc72872f0aad92 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:21:16 -0600 Subject: [PATCH 179/233] added rune merchant --- src/engine/server/world/WorldServer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index d3add44a..1738853f 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -23,6 +23,7 @@ import engine.gameManager.*; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.LogoutCharacterJob; +import engine.math.Vector3fImmutable; import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.MobRespawnThread; import engine.net.Dispatch; @@ -629,7 +630,14 @@ public class WorldServer { ZoneManager.populateWorldZones(zone); } - + //add extra vendors for lakebane + try { + NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, -44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + runeMerchant.sellPercent = 1000000; + } + catch(Exception e){ + Logger.error("FAILED TO ADD RUNE MERCHANT"); + } Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From 6668c0118599f5b46be0358892aa3ecbc1334cdc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:27:46 -0600 Subject: [PATCH 180/233] boxed characters to have pathfinding effect applied at all times --- src/engine/objects/PlayerCharacter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 02d8682c..befcc710 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4814,9 +4814,12 @@ public class PlayerCharacter extends AbstractCharacter { this.safeZone = this.isInSafeZone(); - if(this.isBoxed && this.containsEffect(1672601862) == false) { + if(this.isBoxed && this.containsEffect(1672601862) == false) {//Deathshroud PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); } + if(this.isBoxed && this.containsEffect(429611355) == false) {//pathfinding + PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 429611355, 40, false); + } } catch (Exception e) { Logger.error(e); From 0eb67c83a396470e6c54ad0c41585bf06aa4a8f1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:33:08 -0600 Subject: [PATCH 181/233] stat runes junk for 500k each --- src/engine/net/client/ClientMessagePump.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 011f0c20..ffd3af7e 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -562,7 +562,10 @@ public class ClientMessagePump implements NetMsgHandler { if (i.isCanDestroy()) { if (itemManager.delete(i) == true) { - sourcePlayer.getCharItemManager().addGoldToInventory(i.getItemBase().getBaseValue(),false); + int value = i.getItemBase().getBaseValue(); + if(i.getItemBase().isStatRune()) + value = 500000; + sourcePlayer.getCharItemManager().addGoldToInventory(value,false); sourcePlayer.getCharItemManager().updateInventory(); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); From 7eba9501a6f7f23e5eb48cd2c6c2447f78310199 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:39:23 -0600 Subject: [PATCH 182/233] adjust "runey" location --- src/engine/server/world/WorldServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 1738853f..a56a3563 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -632,7 +632,7 @@ public class WorldServer { } //add extra vendors for lakebane try { - NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, -44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); runeMerchant.sellPercent = 1000000; } catch(Exception e){ From 1fc9e6251e2c672b72d02557bce27c160d2db5eb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:52:10 -0600 Subject: [PATCH 183/233] adjust "runey" location --- src/engine/server/world/WorldServer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index a56a3563..0b50aec2 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -634,6 +634,10 @@ public class WorldServer { try { NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); runeMerchant.sellPercent = 1000000; + Building SDRhut = BuildingManager.getBuildingFromCache(27979); + runeMerchant.bindLoc = Vector3fImmutable.ZERO; + runeMerchant.building = SDRhut; + NPCManager.slotCharacterInBuilding(runeMerchant); } catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); From 664eb04658e4fe3346336765de294e2cb5ad639a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:56:14 -0600 Subject: [PATCH 184/233] adjust "runey" location --- src/engine/server/world/WorldServer.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 0b50aec2..943dbba9 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -634,10 +634,7 @@ public class WorldServer { try { NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); runeMerchant.sellPercent = 1000000; - Building SDRhut = BuildingManager.getBuildingFromCache(27979); - runeMerchant.bindLoc = Vector3fImmutable.ZERO; - runeMerchant.building = SDRhut; - NPCManager.slotCharacterInBuilding(runeMerchant); + runeMerchant.setLoc(runeMerchant.bindLoc); } catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); From 2d4d0f79f87e9379c04e8a12b374c227e54bf8b6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 15:58:33 -0600 Subject: [PATCH 185/233] add UUID to slottest hireling list --- 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 bc31e7c2..7e663a06 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -71,7 +71,7 @@ public class SlotTestCmd extends AbstractDevCmd { outString += "Hirelings List:"; for (AbstractCharacter hireling : building.getHirelings().keySet()) - outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling); + outString += "\r\n" + hireling.getName() + "(" + hireling.getObjectUUID() + ") slot : " + building.getHirelings().get(hireling); } From ee60f88e624866922b6c1fc1ec9e125ea5c348a9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:00:16 -0600 Subject: [PATCH 186/233] add UUID to slottest hireling list --- src/engine/server/world/WorldServer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 943dbba9..83123259 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -634,6 +634,10 @@ public class WorldServer { try { NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); runeMerchant.sellPercent = 1000000; + Building sdrHut = BuildingManager.getBuilding(27979); + runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + runeMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(runeMerchant); runeMerchant.setLoc(runeMerchant.bindLoc); } catch(Exception e){ From e93f09c184167fa01f4e6208c99b9da532b023fd Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:04:50 -0600 Subject: [PATCH 187/233] runey work > profit slider --- src/engine/server/world/WorldServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 83123259..0f8dec71 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -633,7 +633,7 @@ public class WorldServer { //add extra vendors for lakebane try { NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - runeMerchant.sellPercent = 1000000; + runeMerchant.sellPercent = 10000; Building sdrHut = BuildingManager.getBuilding(27979); runeMerchant.buildingUUID = sdrHut.getObjectUUID(); runeMerchant.building = sdrHut; From 0437f10bf98eb2f30814f885723fa3adb37842e8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:06:09 -0600 Subject: [PATCH 188/233] runey work > profit slider --- src/engine/objects/MobEquipment.java | 2 +- src/engine/server/world/WorldServer.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/MobEquipment.java b/src/engine/objects/MobEquipment.java index d15b6274..b9caec70 100644 --- a/src/engine/objects/MobEquipment.java +++ b/src/engine/objects/MobEquipment.java @@ -34,7 +34,7 @@ public class MobEquipment extends AbstractGameObject { private AbstractPowerAction suffix; private int pValue; private int sValue; - private int magicValue; + public int magicValue; private float dropChance = 0; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 0f8dec71..14d417a4 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -633,12 +633,15 @@ public class WorldServer { //add extra vendors for lakebane try { NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - runeMerchant.sellPercent = 10000; + runeMerchant.sellPercent = 0; Building sdrHut = BuildingManager.getBuilding(27979); runeMerchant.buildingUUID = sdrHut.getObjectUUID(); runeMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(runeMerchant); runeMerchant.setLoc(runeMerchant.bindLoc); + for(MobEquipment item : runeMerchant.contract.getSellInventory()){ + item.magicValue = 10000000; + } } catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); From 88123ad99a2e5a6ef8b4dfcf01d8ea2dc5e86bb9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:07:46 -0600 Subject: [PATCH 189/233] runey work > profit slider --- src/engine/server/world/WorldServer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 14d417a4..981472d4 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -639,6 +639,7 @@ public class WorldServer { runeMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(runeMerchant); runeMerchant.setLoc(runeMerchant.bindLoc); + runeMerchant.equipmentSetID = 396; for(MobEquipment item : runeMerchant.contract.getSellInventory()){ item.magicValue = 10000000; } From 7de9bdbbe4026a666bcc81d50edb469782b3350c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:14:42 -0600 Subject: [PATCH 190/233] runey work > profit slider --- src/engine/net/client/ClientMessagePump.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index ffd3af7e..7d566c34 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1404,6 +1404,8 @@ public class ClientMessagePump implements NetMsgHandler { return; int cost = me.getMagicValue(); + if(me.getItemBase().isStatRune()) + cost = 10000000; float bargain = sourcePlayer.getBargain(); @@ -1415,7 +1417,6 @@ public class ClientMessagePump implements NetMsgHandler { cost *= profit; - if (gold.getNumOfItems() - cost < 0) { //dont' have enough goldItem exit! // chatMan.chatSystemInfo(pc, "" + "You dont have enough gold."); From 7b5de5f3f5275a996213818633f9d90efd4d5fa5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:15:24 -0600 Subject: [PATCH 191/233] runey work > profit slider --- src/engine/server/world/WorldServer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 981472d4..14d417a4 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -639,7 +639,6 @@ public class WorldServer { runeMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(runeMerchant); runeMerchant.setLoc(runeMerchant.bindLoc); - runeMerchant.equipmentSetID = 396; for(MobEquipment item : runeMerchant.contract.getSellInventory()){ item.magicValue = 10000000; } From dc1720b38b4e17c596809db62e9ee41b6c66e90e Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:29:40 -0600 Subject: [PATCH 192/233] resource merchant added --- src/engine/server/world/WorldServer.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 14d417a4..f3adfb62 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -632,7 +632,7 @@ public class WorldServer { } //add extra vendors for lakebane try { - NPC runeMerchant = NPC.createNPC("Runey", 1200, new Vector3fImmutable(88862f, 33f, 44997f), Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); runeMerchant.sellPercent = 0; Building sdrHut = BuildingManager.getBuilding(27979); runeMerchant.buildingUUID = sdrHut.getObjectUUID(); @@ -646,6 +646,22 @@ public class WorldServer { catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); } + try { + NPC resourceMerchant = NPC.createNPC("Resources", 960124, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + resourceMerchant.sellPercent = 0; + Building sdrHut = BuildingManager.getBuilding(27984); + resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); + resourceMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(resourceMerchant); + resourceMerchant.setLoc(resourceMerchant.bindLoc); + //for(MobEquipment item : resourceMerchant.contract.getSellInventory()){ + // item.magicValue = 10000000; + //} + //resourceMerchant.contract.getSellInventory() + } + catch(Exception e){ + Logger.error("FAILED TO ADD RUNE MERCHANT"); + } Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From e5d606fe8ae40cb2b6ff7e1cbcd3451acae5196a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:41:54 -0600 Subject: [PATCH 193/233] resource merchant work --- src/engine/objects/Contract.java | 2 +- src/engine/server/world/WorldServer.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index 076e8525..3132d155 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -30,7 +30,7 @@ public class Contract extends AbstractGameObject { public int inventorySet = 0; private int vendorID; private boolean isTrainer; - private VendorDialog vendorDialog; + public VendorDialog vendorDialog; private ArrayList npcMenuOptions = new ArrayList<>(); private ArrayList npcModTypeTable = new ArrayList<>(); private ArrayList npcModSuffixTable = new ArrayList<>(); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index f3adfb62..7bdfdc39 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -647,17 +647,20 @@ public class WorldServer { Logger.error("FAILED TO ADD RUNE MERCHANT"); } try { - NPC resourceMerchant = NPC.createNPC("Resources", 960124, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + + NPC resourceMerchant = NPC.createNPC("Resource Merchant", 960124, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); resourceMerchant.sellPercent = 0; + resourceMerchant.contract.vendorDialog = VendorDialog.getVendorDialog(623); Building sdrHut = BuildingManager.getBuilding(27984); resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); resourceMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(resourceMerchant); resourceMerchant.setLoc(resourceMerchant.bindLoc); - //for(MobEquipment item : resourceMerchant.contract.getSellInventory()){ - // item.magicValue = 10000000; - //} - //resourceMerchant.contract.getSellInventory() + resourceMerchant.contract.getSellInventory().clear(); + for(int resourceID : Warehouse.getMaxResources().keySet()){ + MobEquipment me = new MobEquipment(ItemBase.getItemBase(resourceID), 0, 0); + resourceMerchant.contract.getSellInventory().add(me); + } } catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); From 6247332f839c13cd89308fcb80453c4a48b79d84 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:46:28 -0600 Subject: [PATCH 194/233] resource merchant work --- src/engine/server/world/WorldServer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 7bdfdc39..a4d25f99 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -658,6 +658,8 @@ public class WorldServer { resourceMerchant.setLoc(resourceMerchant.bindLoc); resourceMerchant.contract.getSellInventory().clear(); for(int resourceID : Warehouse.getMaxResources().keySet()){ + if(resourceID == 7 || resourceID == 1580021) + continue; MobEquipment me = new MobEquipment(ItemBase.getItemBase(resourceID), 0, 0); resourceMerchant.contract.getSellInventory().add(me); } From 257d864132ca7f3579f58f43f3c1845407520cee Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 16:58:45 -0600 Subject: [PATCH 195/233] resource merchant work --- src/engine/server/world/WorldServer.java | 47 +++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index a4d25f99..7b82074e 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -632,36 +632,39 @@ public class WorldServer { } //add extra vendors for lakebane try { - NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - runeMerchant.sellPercent = 0; Building sdrHut = BuildingManager.getBuilding(27979); - runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - runeMerchant.building = sdrHut; - NPCManager.slotCharacterInBuilding(runeMerchant); - runeMerchant.setLoc(runeMerchant.bindLoc); - for(MobEquipment item : runeMerchant.contract.getSellInventory()){ - item.magicValue = 10000000; + if (sdrHut.getHirelings().size() < 1) { + NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + runeMerchant.sellPercent = 0; + runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + runeMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(runeMerchant); + runeMerchant.setLoc(runeMerchant.bindLoc); + for (MobEquipment item : runeMerchant.contract.getSellInventory()) { + item.magicValue = 10000000; + } } } catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); } try { - - NPC resourceMerchant = NPC.createNPC("Resource Merchant", 960124, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - resourceMerchant.sellPercent = 0; - resourceMerchant.contract.vendorDialog = VendorDialog.getVendorDialog(623); Building sdrHut = BuildingManager.getBuilding(27984); - resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); - resourceMerchant.building = sdrHut; - NPCManager.slotCharacterInBuilding(resourceMerchant); - resourceMerchant.setLoc(resourceMerchant.bindLoc); - resourceMerchant.contract.getSellInventory().clear(); - for(int resourceID : Warehouse.getMaxResources().keySet()){ - if(resourceID == 7 || resourceID == 1580021) - continue; - MobEquipment me = new MobEquipment(ItemBase.getItemBase(resourceID), 0, 0); - resourceMerchant.contract.getSellInventory().add(me); + if(sdrHut.getHirelings().size() < 2) { + NPC resourceMerchant = NPC.createNPC("Resource Merchant", 830, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + resourceMerchant.sellPercent = 0; + resourceMerchant.contract.vendorDialog = VendorDialog.getVendorDialog(623); + resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); + resourceMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(resourceMerchant); + resourceMerchant.setLoc(resourceMerchant.bindLoc); + //resourceMerchant.contract.getSellInventory().clear(); + for(int resourceID : Warehouse.getMaxResources().keySet()){ + if(resourceID == 7 || resourceID == 1580021) + continue; + MobLoot resource = new MobLoot(resourceMerchant,ItemBase.getItemBase(resourceID), 1, true); + resourceMerchant.getCharItemManager().addItemToInventory(resource); + } } } catch(Exception e){ From 149630ef5aad014bff1e33901e5d1e0d56c14167 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:20:49 -0600 Subject: [PATCH 196/233] resource merchant work --- src/engine/objects/Item.java | 2 +- src/engine/server/world/WorldServer.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index cc74c165..9bb21a13 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -61,7 +61,7 @@ public class Item extends AbstractWorldObject { private ArrayList enchants = new ArrayList<>(); private long dateToUpgrade; private String customName = ""; - private int magicValue; + public int magicValue; /** * No Id Constructor diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 7b82074e..ea4778ef 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -663,6 +663,7 @@ public class WorldServer { if(resourceID == 7 || resourceID == 1580021) continue; MobLoot resource = new MobLoot(resourceMerchant,ItemBase.getItemBase(resourceID), 1, true); + resource.magicValue = Warehouse.getCostForResource(resourceID); resourceMerchant.getCharItemManager().addItemToInventory(resource); } } From 13513bcf2a883c82988333538a9990f83ba0ee4c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:31:09 -0600 Subject: [PATCH 197/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 6 ++ src/engine/objects/Warehouse.java | 71 ++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 7d566c34..e12876a3 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -9,6 +9,7 @@ package engine.net.client; +import engine.Enum; import engine.Enum.*; import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; @@ -1583,6 +1584,11 @@ public class ClientMessagePump implements NetMsgHandler { // msg.setItemID(buy.getObjectUUID()); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + if(npc.getName().equals("Resource Merchant")){ + MobLoot resource = new MobLoot(npc,ItemBase.getItemBase(buy.getItemBaseID()), 1, true); + resource.magicValue = Warehouse.getCostForResource(buy.getItemBaseID()); + npc.getCharItemManager().addItemToInventory(resource); + } itemMan.updateInventory(); } diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index f96a5fcb..c24513fc 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -1334,4 +1334,75 @@ public class Warehouse extends AbstractWorldObject { return resourceType.elementOf(this.lockedResourceTypes); } + + public static int getCostForResource(int id){ + int newCost = 0; + switch(id){ + case 1580000://stone + newCost = 3000; + break; + case 1580001://truesteel + newCost = 50000; + break; + case 1580002://iron + newCost = 50000; + break; + case 1580003://adamant + newCost = 100000; + break; + case 1580004://lumber + newCost = 3000; + break; + case 1580005://oak + newCost = 30000; + break; + case 1580006://bronzewood + newCost = 30000; + break; + case 1580007://mandrake + newCost = 100000; + break; + case 1580008://coal + newCost = 30000; + break; + case 1580009://agate + newCost = 50000; + break; + case 1580010://diamond + newCost = 50000; + break; + case 1580011://onyx + newCost = 100000; + break; + case 1580012://azoth + newCost = 50000; + break; + case 1580013://orichalk + newCost = 30000; + break; + case 1580014://antimony + newCost = 100000; + break; + case 1580015://sulfur + newCost = 100000; + break; + case 1580016://quicksilver + newCost = 100000; + break; + case 1580017://galvor + newCost = 300000; + break; + case 1580018://wormwood + newCost = 300000; + break; + case 1580019://obsidian + newCost = 200000; + break; + case 1580020://bloodstone + newCost = 200000; + break; + } + + return newCost; + } } From 669db7f021273948223cb53ea5197ed8cb55cf19 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:36:53 -0600 Subject: [PATCH 198/233] resource merchant work --- src/engine/objects/CharacterItemManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 3f8b4907..833b04d5 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1218,8 +1218,10 @@ public class CharacterItemManager { if (this.doesCharOwnThisItem(i.getObjectUUID()) == false) return false; if (this.inventory.contains(i)) { - this.inventory.remove(i); - this.itemIDtoType.remove(i.getObjectUUID()); + if(this.getOwner().getName().equals("Resource Merchant") == false){ + this.inventory.remove(i); + this.itemIDtoType.remove(i.getObjectUUID()); + } return true; } } From 9e7a8bef4a098c0bc8a3b1fb5b5d3fd033fabe54 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:38:57 -0600 Subject: [PATCH 199/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 2 +- src/engine/server/world/WorldServer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index e12876a3..af9ad608 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1586,7 +1586,7 @@ public class ClientMessagePump implements NetMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); if(npc.getName().equals("Resource Merchant")){ MobLoot resource = new MobLoot(npc,ItemBase.getItemBase(buy.getItemBaseID()), 1, true); - resource.magicValue = Warehouse.getCostForResource(buy.getItemBaseID()); + resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); npc.getCharItemManager().addItemToInventory(resource); } itemMan.updateInventory(); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index ea4778ef..c18e4953 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -663,7 +663,7 @@ public class WorldServer { if(resourceID == 7 || resourceID == 1580021) continue; MobLoot resource = new MobLoot(resourceMerchant,ItemBase.getItemBase(resourceID), 1, true); - resource.magicValue = Warehouse.getCostForResource(resourceID); + resource.setValue(Warehouse.getCostForResource(resourceID)); resourceMerchant.getCharItemManager().addItemToInventory(resource); } } From 571ad4b4665fff628e909ed1a09cd4dbe20d574d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:49:13 -0600 Subject: [PATCH 200/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 1 + src/engine/objects/CharacterItemManager.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index af9ad608..9af7ab6e 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1588,6 +1588,7 @@ public class ClientMessagePump implements NetMsgHandler { MobLoot resource = new MobLoot(npc,ItemBase.getItemBase(buy.getItemBaseID()), 1, true); resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); npc.getCharItemManager().addItemToInventory(resource); + npc.getCharItemManager().updateInventory(resource,true); } itemMan.updateInventory(); } diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 833b04d5..575798dc 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1218,10 +1218,9 @@ public class CharacterItemManager { if (this.doesCharOwnThisItem(i.getObjectUUID()) == false) return false; if (this.inventory.contains(i)) { - if(this.getOwner().getName().equals("Resource Merchant") == false){ this.inventory.remove(i); this.itemIDtoType.remove(i.getObjectUUID()); - } + updateInventory(i, false); return true; } } From 0d256c17b55153207da156d2c03cd8142fe09926 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:57:17 -0600 Subject: [PATCH 201/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 9af7ab6e..65aa1c68 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1577,22 +1577,21 @@ public class ClientMessagePump implements NetMsgHandler { return; if (buy != null) { - + if(npc.getName().equals("Resource Merchant")) { + MobLoot resource = new MobLoot(npc, ItemBase.getItemBase(buy.getItemBaseID()), 1, true); + resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); + npc.getCharItemManager().addItemToInventory(resource); + npc.getCharItemManager().updateInventory(resource, true); + } msg.setItem(buy); //send the buy message back to update player // msg.setItemType(buy.getObjectType().ordinal()); // msg.setItemID(buy.getObjectUUID()); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - if(npc.getName().equals("Resource Merchant")){ - MobLoot resource = new MobLoot(npc,ItemBase.getItemBase(buy.getItemBaseID()), 1, true); - resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); - npc.getCharItemManager().addItemToInventory(resource); - npc.getCharItemManager().updateInventory(resource,true); - } - itemMan.updateInventory(); - } + itemMan.updateInventory(); + } } finally { origin.buyLock.unlock(); } From 0e61f0e7b88d449ad5b25572d4a6ee91fb9a9ce7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 17:59:25 -0600 Subject: [PATCH 202/233] resource merchant work --- src/engine/objects/CharacterItemManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 575798dc..3f8b4907 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1218,9 +1218,8 @@ public class CharacterItemManager { if (this.doesCharOwnThisItem(i.getObjectUUID()) == false) return false; if (this.inventory.contains(i)) { - this.inventory.remove(i); - this.itemIDtoType.remove(i.getObjectUUID()); - updateInventory(i, false); + this.inventory.remove(i); + this.itemIDtoType.remove(i.getObjectUUID()); return true; } } From a7bc1d5a6afad4ebc7b953e8277a9380f7846e11 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:04:31 -0600 Subject: [PATCH 203/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 65aa1c68..bcffbd21 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1577,12 +1577,6 @@ public class ClientMessagePump implements NetMsgHandler { return; if (buy != null) { - if(npc.getName().equals("Resource Merchant")) { - MobLoot resource = new MobLoot(npc, ItemBase.getItemBase(buy.getItemBaseID()), 1, true); - resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); - npc.getCharItemManager().addItemToInventory(resource); - npc.getCharItemManager().updateInventory(resource, true); - } msg.setItem(buy); //send the buy message back to update player // msg.setItemType(buy.getObjectType().ordinal()); @@ -1592,13 +1586,18 @@ public class ClientMessagePump implements NetMsgHandler { itemMan.updateInventory(); } + if(npc.getName().equals("Resource Merchant")) { + MobLoot resource = new MobLoot(npc, ItemBase.getItemBase(buy.getItemBaseID()), 1, true); + resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); + npc.getCharItemManager().addItemToInventory(resource); + npc.getCharItemManager().updateInventory(resource, true); + } } finally { origin.buyLock.unlock(); } } else { ErrorPopupMsg.sendErrorPopup(origin.getPlayerCharacter(), 12); // All production slots taken } - } private static void Repair(RepairMsg msg, ClientConnection origin) { From 2222a335a19ea64bd9453f52d6347f7e60b97099 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:12:09 -0600 Subject: [PATCH 204/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index bcffbd21..0cd796cd 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1389,7 +1389,15 @@ public class ClientMessagePump implements NetMsgHandler { return; Item buy = null; - + if(npc.getName().equals("Resource Merchant")) { + MobLoot resource = new MobLoot(npc, ItemBase.getItemBase(msg.getItemID()), 1, true); + resource.setValue(Warehouse.getCostForResource(msg.getItemID())); + npc.getCharItemManager().addItemToInventory(resource); + npc.getCharItemManager().updateInventory(resource, true); + Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + itemMan.updateInventory(); + } if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) { ArrayList sellInventory = npc.getContract().getSellInventory(); if (sellInventory == null) @@ -1583,15 +1591,9 @@ public class ClientMessagePump implements NetMsgHandler { // msg.setItemID(buy.getObjectUUID()); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - - itemMan.updateInventory(); - } - if(npc.getName().equals("Resource Merchant")) { - MobLoot resource = new MobLoot(npc, ItemBase.getItemBase(buy.getItemBaseID()), 1, true); - resource.setValue(Warehouse.getCostForResource(buy.getItemBaseID())); - npc.getCharItemManager().addItemToInventory(resource); - npc.getCharItemManager().updateInventory(resource, true); + itemMan.updateInventory(); } + } finally { origin.buyLock.unlock(); } From 8f0e19a10c7e91a71c1bfc73aece60e6379bdbb3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:17:38 -0600 Subject: [PATCH 205/233] resource merchant work --- src/engine/net/client/ClientMessagePump.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 0cd796cd..bc5b33ef 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1389,15 +1389,7 @@ public class ClientMessagePump implements NetMsgHandler { return; Item buy = null; - if(npc.getName().equals("Resource Merchant")) { - MobLoot resource = new MobLoot(npc, ItemBase.getItemBase(msg.getItemID()), 1, true); - resource.setValue(Warehouse.getCostForResource(msg.getItemID())); - npc.getCharItemManager().addItemToInventory(resource); - npc.getCharItemManager().updateInventory(resource, true); - Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - itemMan.updateInventory(); - } + if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) { ArrayList sellInventory = npc.getContract().getSellInventory(); if (sellInventory == null) @@ -1413,8 +1405,6 @@ public class ClientMessagePump implements NetMsgHandler { return; int cost = me.getMagicValue(); - if(me.getItemBase().isStatRune()) - cost = 10000000; float bargain = sourcePlayer.getBargain(); @@ -1426,6 +1416,7 @@ public class ClientMessagePump implements NetMsgHandler { cost *= profit; + if (gold.getNumOfItems() - cost < 0) { //dont' have enough goldItem exit! // chatMan.chatSystemInfo(pc, "" + "You dont have enough gold."); @@ -1585,6 +1576,7 @@ public class ClientMessagePump implements NetMsgHandler { return; if (buy != null) { + msg.setItem(buy); //send the buy message back to update player // msg.setItemType(buy.getObjectType().ordinal()); @@ -1600,6 +1592,7 @@ public class ClientMessagePump implements NetMsgHandler { } else { ErrorPopupMsg.sendErrorPopup(origin.getPlayerCharacter(), 12); // All production slots taken } + } private static void Repair(RepairMsg msg, ClientConnection origin) { From 8e8876587c5521fb8ca3eef4d560db32e2f03af9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:25:26 -0600 Subject: [PATCH 206/233] resource merchant work --- src/engine/server/world/WorldServer.java | 49 +++++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index c18e4953..ac8c1c3e 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -649,28 +649,57 @@ public class WorldServer { Logger.error("FAILED TO ADD RUNE MERCHANT"); } try { - Building sdrHut = BuildingManager.getBuilding(27984); - if(sdrHut.getHirelings().size() < 2) { - NPC resourceMerchant = NPC.createNPC("Resource Merchant", 830, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + Building sdrHut = BuildingManager.getBuilding(27979); + if (sdrHut.getHirelings().size() < 1) { + NPC resourceMerchant = NPC.createNPC("Resource Merchant", 12287, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); resourceMerchant.sellPercent = 0; - resourceMerchant.contract.vendorDialog = VendorDialog.getVendorDialog(623); resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); resourceMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(resourceMerchant); resourceMerchant.setLoc(resourceMerchant.bindLoc); - //resourceMerchant.contract.getSellInventory().clear(); - for(int resourceID : Warehouse.getMaxResources().keySet()){ - if(resourceID == 7 || resourceID == 1580021) + resourceMerchant.contract.getSellInventory().clear(); + for(int resourceID : Warehouse.getMaxResources().keySet()) { + if (resourceID == 7 || resourceID == 1580021) continue; - MobLoot resource = new MobLoot(resourceMerchant,ItemBase.getItemBase(resourceID), 1, true); - resource.setValue(Warehouse.getCostForResource(resourceID)); - resourceMerchant.getCharItemManager().addItemToInventory(resource); + //MobLoot resource = new MobLoot(resourceMerchant, ItemBase.getItemBase(resourceID), 1, true); + //resource.setValue(Warehouse.getCostForResource(resourceID)); + //resourceMerchant.getCharItemManager().addItemToInventory(resource); + MobEquipment resource = new MobEquipment(ItemBase.getItemBase(resourceID),0,0); + resourceMerchant.contract.getSellInventory().add(resource); + } + for (MobEquipment item : resourceMerchant.contract.getSellInventory()) { + item.magicValue = Warehouse.getCostForResource(item.getItemBase().getUUID()); } } } catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); } + + //try { + // Building sdrHut = BuildingManager.getBuilding(27984); + // if(sdrHut.getHirelings().size() < 2) { + // NPC resourceMerchant = NPC.createNPC("Resource Merchant", 830, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + // resourceMerchant.sellPercent = 0; + // resourceMerchant.contract.vendorDialog = VendorDialog.getVendorDialog(623); + // resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); + // resourceMerchant.building = sdrHut; + // NPCManager.slotCharacterInBuilding(resourceMerchant); + // resourceMerchant.setLoc(resourceMerchant.bindLoc); + // //resourceMerchant.contract.getSellInventory().clear(); + // Contract contract = resourceMerchant.contract. + // for(int resourceID : Warehouse.getMaxResources().keySet()){ + // if(resourceID == 7 || resourceID == 1580021) + // continue; + // MobLoot resource = new MobLoot(resourceMerchant,ItemBase.getItemBase(resourceID), 1, true); + // resource.setValue(Warehouse.getCostForResource(resourceID)); + // resourceMerchant.getCharItemManager().addItemToInventory(resource); + // } + // } + //} + //catch(Exception e){ + // Logger.error("FAILED TO ADD RUNE MERCHANT"); + //} Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From 2de240dd6053dbe090fb4527920b56c923f439a5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:28:36 -0600 Subject: [PATCH 207/233] resource merchant work --- src/engine/server/world/WorldServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index ac8c1c3e..e47569e0 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -651,7 +651,7 @@ public class WorldServer { try { Building sdrHut = BuildingManager.getBuilding(27979); if (sdrHut.getHirelings().size() < 1) { - NPC resourceMerchant = NPC.createNPC("Resource Merchant", 12287, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + NPC resourceMerchant = NPC.createNPC("Resource Merchant", 900, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); resourceMerchant.sellPercent = 0; resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); resourceMerchant.building = sdrHut; From 8c022596a7b321e427967b6ba1c6a1dd94cb98fc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:31:55 -0600 Subject: [PATCH 208/233] resource merchant work --- src/engine/server/world/WorldServer.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e47569e0..c04b2811 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -657,19 +657,19 @@ public class WorldServer { resourceMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(resourceMerchant); resourceMerchant.setLoc(resourceMerchant.bindLoc); - resourceMerchant.contract.getSellInventory().clear(); - for(int resourceID : Warehouse.getMaxResources().keySet()) { - if (resourceID == 7 || resourceID == 1580021) - continue; + //resourceMerchant.contract.getSellInventory().clear(); + //for(int resourceID : Warehouse.getMaxResources().keySet()) { + // if (resourceID == 7 || resourceID == 1580021) + // continue; //MobLoot resource = new MobLoot(resourceMerchant, ItemBase.getItemBase(resourceID), 1, true); //resource.setValue(Warehouse.getCostForResource(resourceID)); //resourceMerchant.getCharItemManager().addItemToInventory(resource); - MobEquipment resource = new MobEquipment(ItemBase.getItemBase(resourceID),0,0); - resourceMerchant.contract.getSellInventory().add(resource); - } - for (MobEquipment item : resourceMerchant.contract.getSellInventory()) { - item.magicValue = Warehouse.getCostForResource(item.getItemBase().getUUID()); - } + // MobEquipment resource = new MobEquipment(ItemBase.getItemBase(resourceID),0,0); + // resourceMerchant.contract.getSellInventory().add(resource); + //} + //for (MobEquipment item : resourceMerchant.contract.getSellInventory()) { + // item.magicValue = Warehouse.getCostForResource(item.getItemBase().getUUID()); + //} } } catch(Exception e){ From c964115c1ec1f922bb715baf5a3d22edf717f9ab Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 18:34:46 -0600 Subject: [PATCH 209/233] resource merchant work --- src/engine/server/world/WorldServer.java | 27 ------------------------ 1 file changed, 27 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index c04b2811..a4f22186 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -648,33 +648,6 @@ public class WorldServer { catch(Exception e){ Logger.error("FAILED TO ADD RUNE MERCHANT"); } - try { - Building sdrHut = BuildingManager.getBuilding(27979); - if (sdrHut.getHirelings().size() < 1) { - NPC resourceMerchant = NPC.createNPC("Resource Merchant", 900, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - resourceMerchant.sellPercent = 0; - resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); - resourceMerchant.building = sdrHut; - NPCManager.slotCharacterInBuilding(resourceMerchant); - resourceMerchant.setLoc(resourceMerchant.bindLoc); - //resourceMerchant.contract.getSellInventory().clear(); - //for(int resourceID : Warehouse.getMaxResources().keySet()) { - // if (resourceID == 7 || resourceID == 1580021) - // continue; - //MobLoot resource = new MobLoot(resourceMerchant, ItemBase.getItemBase(resourceID), 1, true); - //resource.setValue(Warehouse.getCostForResource(resourceID)); - //resourceMerchant.getCharItemManager().addItemToInventory(resource); - // MobEquipment resource = new MobEquipment(ItemBase.getItemBase(resourceID),0,0); - // resourceMerchant.contract.getSellInventory().add(resource); - //} - //for (MobEquipment item : resourceMerchant.contract.getSellInventory()) { - // item.magicValue = Warehouse.getCostForResource(item.getItemBase().getUUID()); - //} - } - } - catch(Exception e){ - Logger.error("FAILED TO ADD RUNE MERCHANT"); - } //try { // Building sdrHut = BuildingManager.getBuilding(27984); From 106dd87216831279197a0558a2bc007db0222e50 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 20:25:11 -0600 Subject: [PATCH 210/233] zerg mechanic tweak --- src/engine/gameManager/ZergManager.java | 51 ++++++++++++++----------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/engine/gameManager/ZergManager.java b/src/engine/gameManager/ZergManager.java index caae2a9e..c1729d93 100644 --- a/src/engine/gameManager/ZergManager.java +++ b/src/engine/gameManager/ZergManager.java @@ -6,10 +6,10 @@ public class ZergManager { switch(count){ case 1: case 2: - multiplier += 0.8f; + multiplier += 0.0f; break; case 3: - multiplier += 0.5f; + multiplier += 0.55f; break; case 4: multiplier += 0.2f; @@ -21,13 +21,16 @@ public class ZergManager { multiplier -= 0.2f; break; case 7: - multiplier -= 0.4f; + multiplier -= 0.35f; break; case 8: - multiplier -= 0.6f; + multiplier -= 0.50f; + break; + case 9: + multiplier -= 0.750f; break; default: - multiplier -= 0.80f; + multiplier -= 1.0f; break; } return multiplier; @@ -35,27 +38,17 @@ public class ZergManager { public static float getMultiplier10Man(int count){ float multiplier = 1.0f; + if(count <=4) + return 0.0f; switch(count){ - case 1: - multiplier += 1.0f; - break; - case 2: - multiplier += 1.0f; - break; - case 3: - multiplier += 1.0f; - break; - case 4: - multiplier += 1.0f; - break; case 5: - multiplier += 0.8f; + multiplier += 0.5f; break; case 6: - multiplier += 0.55f; + multiplier += 0.4f; break; case 7: - multiplier += 0.35f; + multiplier += 0.3f; break; case 8: multiplier += 0.2f; @@ -73,14 +66,26 @@ public class ZergManager { multiplier -= 0.2f; break; case 13: - multiplier -= 0.35f; + multiplier -= 0.3f; break; case 14: - multiplier -= 0.55f; + multiplier -= 0.4f; break; - default: + case 15: + multiplier -= 0.5f; + break; + case 16: + multiplier -= 0.65f; + break; + case 17: multiplier -= 0.75f; break; + case 18: + multiplier -= 0.85f; + break; + default: + multiplier -= 1.0f; + break; } return multiplier; } From e70b52d88c1eb7c60825dd6aef0423cdbe9505fe Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 21:28:39 -0600 Subject: [PATCH 211/233] test mechanics removed --- src/engine/InterestManagement/InterestManager.java | 3 --- src/engine/gameManager/BuildingManager.java | 2 +- src/engine/net/client/handlers/ObjectActionMsgHandler.java | 6 ++++-- src/engine/net/client/handlers/UpgradeAssetMsgHandler.java | 3 +-- src/engine/objects/Mob.java | 3 +-- src/engine/objects/NPC.java | 3 +-- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index bd27652f..d93c2871 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -533,9 +533,6 @@ public enum InterestManager implements Runnable { if(player.level < 10) { player.setLevel((short) 10); - MobLoot ml = new MobLoot(player,ItemBase.getItemBase(980066),false); - ml.promoteToItem(player); - player.getCharItemManager().addGoldToInventory(50000, true); } player.isBoxed = false; for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 354d4f14..2e6e19a8 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -258,7 +258,7 @@ public enum BuildingManager { if (building == null) return; - building.upgradeDateTime = LocalDateTime.now().plusMinutes(5); + if (building.getUpgradeDateTime() == null) { Logger.error("Attempt to submit upgrade job for non-ranking building"); return; diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index d6ef538e..de6a9fbf 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -439,8 +439,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { // } // break; //} - - LootManager.peddleFate(player,item); + int i = 0; + if(i != 0) { + LootManager.peddleFate(player, item); + } break; case 30: //water bucket diff --git a/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java b/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java index 9c1eae12..3638c2ec 100644 --- a/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java +++ b/src/engine/net/client/handlers/UpgradeAssetMsgHandler.java @@ -119,8 +119,7 @@ public class UpgradeAssetMsgHandler extends AbstractClientMsgHandler { return true; } - //dateToUpgrade = LocalDateTime.now().plusHours(buildingToRank.getBlueprint().getRankTime(nextRank)); - dateToUpgrade = LocalDateTime.now().plusMinutes(5); + dateToUpgrade = LocalDateTime.now().plusHours(buildingToRank.getBlueprint().getRankTime(nextRank)); BuildingManager.setUpgradeDateTime(buildingToRank, dateToUpgrade, 0); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 6efc6119..00bdfb28 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1885,8 +1885,7 @@ public class Mob extends AbstractIntelligenceAgent { if (!building.transferGold(-rankCost, false)) return; - //DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); - DateTime dateToUpgrade = DateTime.now().plusMinutes(5); + DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this)); Mob.setUpgradeDateTime(this, dateToUpgrade); // Schedule upgrade job diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index abc99255..b3b3aed5 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1325,8 +1325,7 @@ public class NPC extends AbstractCharacter { if (!building.transferGold(-rankCost, false)) return; - //dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); - dateToUpgrade = DateTime.now().plusMinutes(5); + dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); this.setUpgradeDateTime(dateToUpgrade); // Schedule upgrade job From 46826163be7079b3297e6cff85375d16be1551d7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 21:49:40 -0600 Subject: [PATCH 212/233] test mechanics removed --- src/engine/objects/PlayerCharacter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index befcc710..6b6df9c8 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4817,9 +4817,9 @@ public class PlayerCharacter extends AbstractCharacter { if(this.isBoxed && this.containsEffect(1672601862) == false) {//Deathshroud PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); } - if(this.isBoxed && this.containsEffect(429611355) == false) {//pathfinding - PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 429611355, 40, false); - } + //if(this.isBoxed && this.containsEffect(429611355) == false) {//pathfinding + // PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 429611355, 40, false); + //} } catch (Exception e) { Logger.error(e); From 7efd276d523733d65fbd75b6591b35fd44274e41 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 18 Feb 2024 22:13:41 -0600 Subject: [PATCH 213/233] grant conc pot when level set to 10 --- src/engine/InterestManagement/InterestManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index d93c2871..178e8b33 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -533,6 +533,10 @@ public enum InterestManager implements Runnable { if(player.level < 10) { player.setLevel((short) 10); + MobLoot conc = new MobLoot(player,ItemBase.getItemBase(980066),false); + //player.getCharItemManager().addItemToInventory(conc); + player.getCharItemManager().addItemToInventory(conc.promoteToItem(player),1); + player.getCharItemManager().updateInventory(); } player.isBoxed = false; for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ From 666e3d54790b3706c196aa96abf2a9d05145226a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:02:42 -0600 Subject: [PATCH 214/233] boons become nation friendly --- src/engine/net/client/handlers/MerchantMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/MerchantMsgHandler.java b/src/engine/net/client/handlers/MerchantMsgHandler.java index 94490a72..0adbace4 100644 --- a/src/engine/net/client/handlers/MerchantMsgHandler.java +++ b/src/engine/net/client/handlers/MerchantMsgHandler.java @@ -147,7 +147,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler { Building shrineBuilding; Shrine shrine; - if (npc.getGuild() != player.getGuild()) + if (npc.getGuild().getNation() != player.getGuild().getNation()) return; shrineBuilding = npc.getBuilding(); From d9a03ebf93f8f9feb698054b222c752ea1847a96 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:16:34 -0600 Subject: [PATCH 215/233] resources auto stack when entering inventory --- src/engine/objects/CharacterItemManager.java | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 3f8b4907..74eac61f 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1251,6 +1251,27 @@ public class CharacterItemManager { ItemBase ib = i.getItemBase(); if (ib != null) this.inventoryWeight += ib.getWeight(); + + if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { + int count = i.getNumOfItems(); + ArrayList purge = new ArrayList<>(); + for (Item it : this.getInventory()) { + if (it.getItemBase().equals(i.getItemBase()) && it.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(it.getItemBaseID())) { + purge.add(it); + count += it.getNumOfItems(); + } + } + if (count <= Warehouse.getMaxResources().get(i.getItemBaseID())) { + MobLoot ml = new MobLoot(this.getOwner(), i.getItemBase(), count, false); + for (Item p : purge) { + this.removeItemFromInventory(p); + } + this.addItemToInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()), 1); + this.updateInventory(); + return true; + } + } + return true; } From 1e9f1685da925dc09fb2987eacf5a6c7b3cfdc80 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:19:34 -0600 Subject: [PATCH 216/233] cannot delete gold --- src/engine/objects/Item.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 9bb21a13..245756c8 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -889,6 +889,8 @@ public class Item extends AbstractWorldObject { } public boolean isCanDestroy() { + if(this.getItemBaseID() == 7)//gold + return false; return canDestroy; } From 351437b46b74dc61980d589b056ed938af6d2568 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:25:19 -0600 Subject: [PATCH 217/233] rune and contract rate update --- src/engine/gameManager/LootManager.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 974a5f29..5bec55d8 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -112,24 +112,26 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop - if(ThreadLocalRandom.current().nextInt(1, 20000) == 10000) { + if(ThreadLocalRandom.current().nextInt(1,101) < mob.level && mob.parentZone.getSafeZone() == 0) { + if (ThreadLocalRandom.current().nextInt(1, 20000) == 10000) { if (_genTables.containsKey(bse.genTable + 1)) { - int roll = ThreadLocalRandom.current().nextInt(1,101); + int roll = ThreadLocalRandom.current().nextInt(1, 101); MobLoot extraLoot = null; - if(roll >= 1 && roll <= 47){ + if (roll >= 1 && roll <= 47) { extraLoot = rollForContract(bse.genTable + 1, mob); } - if(roll >= 48 && roll <= 94){ + if (roll >= 48 && roll <= 94) { extraLoot = rollForRune(bse.genTable + 1, mob); } - if(roll >= 95){ + if (roll >= 95) { extraLoot = rollForGlass(mob); } - if(extraLoot != null){ + if (extraLoot != null) { mob.getCharItemManager().addItemToInventory(extraLoot); } } } + } break; case "ITEM": GenerateInventoryDrop(mob, bse); @@ -145,7 +147,7 @@ public enum LootManager { MobLoot outItem; - int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); + int genRoll = ThreadLocalRandom.current().nextInt(1,94 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); From 2c7baaf2ac2c3c55713f5741f73e81c0d3c21320 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:35:19 -0600 Subject: [PATCH 218/233] rune and contract rate update --- src/engine/gameManager/LootManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 5bec55d8..4cb8d083 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -113,7 +113,7 @@ public enum LootManager { if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop if(ThreadLocalRandom.current().nextInt(1,101) < mob.level && mob.parentZone.getSafeZone() == 0) { - if (ThreadLocalRandom.current().nextInt(1, 20000) == 10000) { + if (ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { if (_genTables.containsKey(bse.genTable + 1)) { int roll = ThreadLocalRandom.current().nextInt(1, 101); MobLoot extraLoot = null; From 547de5033baa3bf759a5e7c982ed891a465a6020 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:42:02 -0600 Subject: [PATCH 219/233] rune and contract rate update --- src/engine/gameManager/LootManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 4cb8d083..77657678 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -113,14 +113,14 @@ public enum LootManager { if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop if(ThreadLocalRandom.current().nextInt(1,101) < mob.level && mob.parentZone.getSafeZone() == 0) { - if (ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { + if (ThreadLocalRandom.current().nextInt(1, 10000) < mob.level) { if (_genTables.containsKey(bse.genTable + 1)) { int roll = ThreadLocalRandom.current().nextInt(1, 101); MobLoot extraLoot = null; - if (roll >= 1 && roll <= 47) { + if (roll >= 1 && roll <= 50) { extraLoot = rollForContract(bse.genTable + 1, mob); } - if (roll >= 48 && roll <= 94) { + if (roll >= 51 && roll <= 94) { extraLoot = rollForRune(bse.genTable + 1, mob); } if (roll >= 95) { From 43409d2e4b5916cb8043946cdc2cffcbc1c8da1a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 17:49:32 -0600 Subject: [PATCH 220/233] booty sim 1000 iteration --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index f6ef0bb0..544e6eb4 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -51,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { int failures = 0; int goldAmount = 0; - for (int i = 0; i < 100; ++i) { + for (int i = 0; i < 1000; ++i) { try { mob.loadInventory(); From b5f36b60f72d80b4afbbc3d90abb672c177ddcd2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 18:01:19 -0600 Subject: [PATCH 221/233] loot update --- src/engine/gameManager/LootManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 77657678..a27613f2 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -118,10 +118,10 @@ public enum LootManager { int roll = ThreadLocalRandom.current().nextInt(1, 101); MobLoot extraLoot = null; if (roll >= 1 && roll <= 50) { - extraLoot = rollForContract(bse.genTable + 1, mob); + extraLoot = rollForContract(bse.genTable, mob); } if (roll >= 51 && roll <= 94) { - extraLoot = rollForRune(bse.genTable + 1, mob); + extraLoot = rollForRune(bse.genTable, mob); } if (roll >= 95) { extraLoot = rollForGlass(mob); @@ -473,7 +473,7 @@ public enum LootManager { } public static MobLoot rollForContract(int table, Mob mob){ - GenTableEntry selectedRow = GenTableEntry.rollTable(table, 95, 1.0f); + GenTableEntry selectedRow = GenTableEntry.rollTable(table, 99, 1.0f); if (selectedRow == null) return null; @@ -496,7 +496,7 @@ public enum LootManager { return null; } public static MobLoot rollForRune(int table, Mob mob){ - GenTableEntry selectedRow = GenTableEntry.rollTable(table, 95, 1.0f); + GenTableEntry selectedRow = GenTableEntry.rollTable(table, 97, 1.0f); if (selectedRow == null) return null; From 0289b5087d2d8bbc218d3b445de8c52fad758344 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 18:27:56 -0600 Subject: [PATCH 222/233] loot update --- src/engine/gameManager/LootManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a27613f2..e24f4ca5 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -178,7 +178,7 @@ public enum LootManager { if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { int chance = ThreadLocalRandom.current().nextInt(1,101); - if(chance > 10) + if(chance > 5) return null; int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); From be902cf09c20581279d361ab1f021fc8b5d44ced Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 18:30:09 -0600 Subject: [PATCH 223/233] loot update --- src/engine/objects/CharacterItemManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 74eac61f..fe2cdf92 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1267,7 +1267,7 @@ public class CharacterItemManager { this.removeItemFromInventory(p); } this.addItemToInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()), 1); - this.updateInventory(); + this.updateInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()),true); return true; } } From 84a75f6b835701aa2152106a153f2ec53ffa091a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 18:39:02 -0600 Subject: [PATCH 224/233] resource stacking update --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 2 +- src/engine/objects/CharacterItemManager.java | 37 +++++++------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index 544e6eb4..7249ee3b 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -51,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { int failures = 0; int goldAmount = 0; - for (int i = 0; i < 1000; ++i) { + for (int i = 0; i < 10000; ++i) { try { mob.loadInventory(); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index fe2cdf92..2213007f 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1244,34 +1244,23 @@ public class CharacterItemManager { return false; } - - this.inventory.add(i); - this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - - ItemBase ib = i.getItemBase(); - if (ib != null) - this.inventoryWeight += ib.getWeight(); - if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { - int count = i.getNumOfItems(); - ArrayList purge = new ArrayList<>(); - for (Item it : this.getInventory()) { - if (it.getItemBase().equals(i.getItemBase()) && it.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(it.getItemBaseID())) { - purge.add(it); - count += it.getNumOfItems(); + for(Item item : this.getInventory()){ + if(item.getItemBaseID() == i.getItemBaseID()){ + if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) { + item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems()); + updateInventory(); + } } } - if (count <= Warehouse.getMaxResources().get(i.getItemBaseID())) { - MobLoot ml = new MobLoot(this.getOwner(), i.getItemBase(), count, false); - for (Item p : purge) { - this.removeItemFromInventory(p); - } - this.addItemToInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()), 1); - this.updateInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()),true); - return true; - } - } + }else { + this.inventory.add(i); + this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); + ItemBase ib = i.getItemBase(); + if (ib != null) + this.inventoryWeight += ib.getWeight(); + } return true; } From 44cd8d00132acd11f1352bed886090ea925923f1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 18:41:47 -0600 Subject: [PATCH 225/233] resource stacking update --- src/engine/objects/CharacterItemManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 2213007f..8e80fabd 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1245,14 +1245,24 @@ public class CharacterItemManager { return false; } if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { + boolean added = false; for(Item item : this.getInventory()){ if(item.getItemBaseID() == i.getItemBaseID()){ if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) { item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems()); updateInventory(); + added = true; } } } + if(!added){ + this.inventory.add(i); + this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); + + ItemBase ib = i.getItemBase(); + if (ib != null) + this.inventoryWeight += ib.getWeight(); + } }else { this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); From c4bd7661569eecf8e2d87bb965143efcf43e170d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 19:40:47 -0600 Subject: [PATCH 226/233] test rune vendor --- src/engine/server/world/WorldServer.java | 45 ++++++------------------ 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index a4f22186..45aacb61 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -631,42 +631,17 @@ public class WorldServer { } //add extra vendors for lakebane - try { - Building sdrHut = BuildingManager.getBuilding(27979); - if (sdrHut.getHirelings().size() < 1) { - NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - runeMerchant.sellPercent = 0; - runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - runeMerchant.building = sdrHut; - NPCManager.slotCharacterInBuilding(runeMerchant); - runeMerchant.setLoc(runeMerchant.bindLoc); - for (MobEquipment item : runeMerchant.contract.getSellInventory()) { - item.magicValue = 10000000; - } - } - } - catch(Exception e){ - Logger.error("FAILED TO ADD RUNE MERCHANT"); - } - //try { - // Building sdrHut = BuildingManager.getBuilding(27984); - // if(sdrHut.getHirelings().size() < 2) { - // NPC resourceMerchant = NPC.createNPC("Resource Merchant", 830, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - // resourceMerchant.sellPercent = 0; - // resourceMerchant.contract.vendorDialog = VendorDialog.getVendorDialog(623); - // resourceMerchant.buildingUUID = sdrHut.getObjectUUID(); - // resourceMerchant.building = sdrHut; - // NPCManager.slotCharacterInBuilding(resourceMerchant); - // resourceMerchant.setLoc(resourceMerchant.bindLoc); - // //resourceMerchant.contract.getSellInventory().clear(); - // Contract contract = resourceMerchant.contract. - // for(int resourceID : Warehouse.getMaxResources().keySet()){ - // if(resourceID == 7 || resourceID == 1580021) - // continue; - // MobLoot resource = new MobLoot(resourceMerchant,ItemBase.getItemBase(resourceID), 1, true); - // resource.setValue(Warehouse.getCostForResource(resourceID)); - // resourceMerchant.getCharItemManager().addItemToInventory(resource); + // Building sdrHut = BuildingManager.getBuilding(27979); + // if (sdrHut.getHirelings().size() < 1) { + // NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + // runeMerchant.sellPercent = 0; + // runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + // runeMerchant.building = sdrHut; + // NPCManager.slotCharacterInBuilding(runeMerchant); + // runeMerchant.setLoc(runeMerchant.bindLoc); + // for (MobEquipment item : runeMerchant.contract.getSellInventory()) { + // item.magicValue = 10000000; // } // } //} From c9428d2b568f956776e0908baa9a3b1f06e42c4d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 20:39:38 -0600 Subject: [PATCH 227/233] test rune vendor --- src/engine/server/world/WorldServer.java | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 45aacb61..a190e4d6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -631,23 +631,23 @@ public class WorldServer { } //add extra vendors for lakebane - //try { - // Building sdrHut = BuildingManager.getBuilding(27979); - // if (sdrHut.getHirelings().size() < 1) { - // NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - // runeMerchant.sellPercent = 0; - // runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - // runeMerchant.building = sdrHut; - // NPCManager.slotCharacterInBuilding(runeMerchant); - // runeMerchant.setLoc(runeMerchant.bindLoc); - // for (MobEquipment item : runeMerchant.contract.getSellInventory()) { - // item.magicValue = 10000000; - // } - // } - //} - //catch(Exception e){ - // Logger.error("FAILED TO ADD RUNE MERCHANT"); - //} + try { + Building sdrHut = BuildingManager.getBuilding(27979); + if (sdrHut.getHirelings() == null || sdrHut.getHirelings().size() != 1) { + NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + runeMerchant.sellPercent = 0; + runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + runeMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(runeMerchant); + runeMerchant.setLoc(runeMerchant.bindLoc); + for (MobEquipment item : runeMerchant.contract.getSellInventory()) { + item.magicValue = 10000000; + } + } + } + catch(Exception e){ + Logger.error("FAILED TO ADD RUNE MERCHANT"); + } Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From f82a19f24331ae427195d38557ff524658abe0bc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 20:50:58 -0600 Subject: [PATCH 228/233] test rune vendor --- src/engine/server/world/WorldServer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index a190e4d6..54009162 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -633,7 +633,12 @@ public class WorldServer { //add extra vendors for lakebane try { Building sdrHut = BuildingManager.getBuilding(27979); - if (sdrHut.getHirelings() == null || sdrHut.getHirelings().size() != 1) { + Zone sdr = sdrHut.parentZone; + boolean exists = false; + for(NPC merchant : sdr.zoneNPCSet) + if(merchant.contract.getContractID() == 1200) + exists = true; + if (!exists) { NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); runeMerchant.sellPercent = 0; runeMerchant.buildingUUID = sdrHut.getObjectUUID(); From 0f7410f55fab8902cee100103b981f2dab6ece80 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 20:56:37 -0600 Subject: [PATCH 229/233] test rune vendor --- src/engine/server/world/WorldServer.java | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 54009162..f6f026e6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -631,28 +631,28 @@ public class WorldServer { } //add extra vendors for lakebane - try { - Building sdrHut = BuildingManager.getBuilding(27979); - Zone sdr = sdrHut.parentZone; - boolean exists = false; - for(NPC merchant : sdr.zoneNPCSet) - if(merchant.contract.getContractID() == 1200) - exists = true; - if (!exists) { - NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - runeMerchant.sellPercent = 0; - runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - runeMerchant.building = sdrHut; - NPCManager.slotCharacterInBuilding(runeMerchant); - runeMerchant.setLoc(runeMerchant.bindLoc); - for (MobEquipment item : runeMerchant.contract.getSellInventory()) { - item.magicValue = 10000000; - } - } - } - catch(Exception e){ - Logger.error("FAILED TO ADD RUNE MERCHANT"); - } + //try { + // Building sdrHut = BuildingManager.getBuilding(27979); + // Zone sdr = sdrHut.parentZone; + // boolean exists = false; + // for(NPC merchant : sdr.zoneNPCSet) + // if(merchant.contract.getContractID() == 1200) + // exists = true; + // if (!exists) { + // NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + // runeMerchant.sellPercent = 0; + // runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + // runeMerchant.building = sdrHut; + // NPCManager.slotCharacterInBuilding(runeMerchant); + // runeMerchant.setLoc(runeMerchant.bindLoc); + // for (MobEquipment item : runeMerchant.contract.getSellInventory()) { + // item.magicValue = 10000000; + // } + // } + //} + //catch(Exception e){ + // Logger.error("FAILED TO ADD RUNE MERCHANT"); + //} Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From fbc408f61711590701812867a6ae11ca2e559eaf Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 21:01:57 -0600 Subject: [PATCH 230/233] test rune vendor --- src/engine/server/world/WorldServer.java | 45 ++++++++++++------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index f6f026e6..4a101dae 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -631,28 +631,29 @@ public class WorldServer { } //add extra vendors for lakebane - //try { - // Building sdrHut = BuildingManager.getBuilding(27979); - // Zone sdr = sdrHut.parentZone; - // boolean exists = false; - // for(NPC merchant : sdr.zoneNPCSet) - // if(merchant.contract.getContractID() == 1200) - // exists = true; - // if (!exists) { - // NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - // runeMerchant.sellPercent = 0; - // runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - // runeMerchant.building = sdrHut; - // NPCManager.slotCharacterInBuilding(runeMerchant); - // runeMerchant.setLoc(runeMerchant.bindLoc); - // for (MobEquipment item : runeMerchant.contract.getSellInventory()) { - // item.magicValue = 10000000; - // } - // } - //} - //catch(Exception e){ - // Logger.error("FAILED TO ADD RUNE MERCHANT"); - //} + // + try { + Building sdrHut = BuildingManager.getBuilding(27979); + Zone sdr = sdrHut.parentZone; + boolean exists = false; + for(NPC merchant : sdr.zoneNPCSet) + if(merchant.contract.getContractID() == 1200) + exists = true; + if (!exists) { + NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + runeMerchant.sellPercent = 9999.00f; + runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + runeMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(runeMerchant); + runeMerchant.setLoc(runeMerchant.bindLoc); + for (MobEquipment item : runeMerchant.contract.getSellInventory()) { + item.magicValue = 10000000; + } + } + } + catch(Exception e){ + Logger.error("FAILED TO ADD RUNE MERCHANT"); + } Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From 0440aabd1e5551299b7e4cf4c0ed711002a54b8f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 21:03:05 -0600 Subject: [PATCH 231/233] test rune vendor --- src/engine/server/world/WorldServer.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 4a101dae..b4973443 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -646,9 +646,7 @@ public class WorldServer { runeMerchant.building = sdrHut; NPCManager.slotCharacterInBuilding(runeMerchant); runeMerchant.setLoc(runeMerchant.bindLoc); - for (MobEquipment item : runeMerchant.contract.getSellInventory()) { - item.magicValue = 10000000; - } + runeMerchant.updateDatabase(); } } catch(Exception e){ From a37e30c550eeaf9f3a69646ea7b04582562b97ba Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 21:06:32 -0600 Subject: [PATCH 232/233] test rune vendor --- src/engine/server/world/WorldServer.java | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index b4973443..14f8b9d9 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -632,26 +632,26 @@ public class WorldServer { } //add extra vendors for lakebane // - try { - Building sdrHut = BuildingManager.getBuilding(27979); - Zone sdr = sdrHut.parentZone; - boolean exists = false; - for(NPC merchant : sdr.zoneNPCSet) - if(merchant.contract.getContractID() == 1200) - exists = true; - if (!exists) { - NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - runeMerchant.sellPercent = 9999.00f; - runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - runeMerchant.building = sdrHut; - NPCManager.slotCharacterInBuilding(runeMerchant); - runeMerchant.setLoc(runeMerchant.bindLoc); - runeMerchant.updateDatabase(); - } - } - catch(Exception e){ - Logger.error("FAILED TO ADD RUNE MERCHANT"); - } + //try { + // Building sdrHut = BuildingManager.getBuilding(27979); + // Zone sdr = sdrHut.parentZone; + // boolean exists = false; + // for(NPC merchant : sdr.zoneNPCSet) + // if(merchant.contract.getContractID() == 1200) + // exists = true; + // if (!exists) { + // NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + // runeMerchant.sellPercent = 9999.00f; + // runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + // runeMerchant.building = sdrHut; + // NPCManager.slotCharacterInBuilding(runeMerchant); + // runeMerchant.setLoc(runeMerchant.bindLoc); + // runeMerchant.updateDatabase(); + // } + //} + //catch(Exception e){ + // Logger.error("FAILED TO ADD RUNE MERCHANT"); + //} Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From 40290bdf976902e49de0dd92faf21c5eba8bd0c3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 20 Feb 2024 21:13:12 -0600 Subject: [PATCH 233/233] test rune vendor --- src/engine/server/world/WorldServer.java | 45 +++++++++++++----------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 14f8b9d9..7b25ff09 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -617,6 +617,11 @@ public class WorldServer { for (NPC n : npcs) { n.setObjectTypeMask(MBServerStatics.MASK_NPC); + + if(n.contract.getContractID() == 1200) { + DbManager.NPCQueries.DELETE_NPC(n); + continue; + } n.setLoc(n.getLoc()); } @@ -632,26 +637,26 @@ public class WorldServer { } //add extra vendors for lakebane // - //try { - // Building sdrHut = BuildingManager.getBuilding(27979); - // Zone sdr = sdrHut.parentZone; - // boolean exists = false; - // for(NPC merchant : sdr.zoneNPCSet) - // if(merchant.contract.getContractID() == 1200) - // exists = true; - // if (!exists) { - // NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); - // runeMerchant.sellPercent = 9999.00f; - // runeMerchant.buildingUUID = sdrHut.getObjectUUID(); - // runeMerchant.building = sdrHut; - // NPCManager.slotCharacterInBuilding(runeMerchant); - // runeMerchant.setLoc(runeMerchant.bindLoc); - // runeMerchant.updateDatabase(); - // } - //} - //catch(Exception e){ - // Logger.error("FAILED TO ADD RUNE MERCHANT"); - //} + try { + Building sdrHut = BuildingManager.getBuilding(27979); + Zone sdr = sdrHut.parentZone; + boolean exists = false; + for(NPC merchant : sdr.zoneNPCSet) + if(merchant.contract.getContractID() == 1200) + exists = true; + if (!exists) { + NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + runeMerchant.sellPercent = 9999.00f; + runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + runeMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(runeMerchant); + runeMerchant.setLoc(runeMerchant.bindLoc); + runeMerchant.updateDatabase(); + } + } + catch(Exception e){ + Logger.error("FAILED TO ADD RUNE MERCHANT"); + } Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); }