From d0795e9e1ca0a1087b6e37c0cafb743a7bed2766 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 1 Sep 2023 13:57:58 -0400 Subject: [PATCH] Rework of agent type init in runafterload. Only used for 2 instances from disk. --- src/engine/objects/Mob.java | 67 ++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e8efd569..4e6e33c5 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -452,6 +452,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.GUARDMINION; minionMobile.guardedCity = guardCaptain.guardedCity; minionMobile.patrolPoints = guardCaptain.building.patrolPoints; @@ -507,6 +508,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); @@ -541,6 +543,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 = ""; @@ -1524,43 +1527,19 @@ public class Mob extends AbstractIntelligenceAgent { this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); - this.building = BuildingManager.getBuilding(this.buildingUUID); - - if (this.contractUUID == 0) - this.contract = null; - else - this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); - - - if (this.contract != null) { - - // Setup equipset for contract - - this.equipmentSetID = this.contract.getEquipmentSet(); - - // Configure AI related values - - switch (this.behaviourType) { - case GuardCaptain: - this.agentType = AIAgentType.GUARDCAPTAIN; - this.spawnTime = 600; - this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); - break; - case GuardMinion: - this.agentType = AIAgentType.GUARDMINION; - break; - case GuardWallArcher: - this.agentType = AIAgentType.GUARDWALLARCHER; - this.spawnTime = 450; - this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); - case Pet1: - this.agentType = AIAgentType.PET; - break; - case SiegeEngine: - this.agentType = AIAgentType.SIEGEENGINE; - break; - } - + // Configure AI related values + + switch (this.behaviourType) { + case GuardCaptain: + this.agentType = AIAgentType.GUARDCAPTAIN; + this.spawnTime = 600; + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); + break; + case GuardWallArcher: + this.agentType = AIAgentType.GUARDWALLARCHER; + this.spawnTime = 450; + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); + break; } // Default to the mobbase for AI if nothing is in mob field to override. @@ -1571,6 +1550,18 @@ public class Mob extends AbstractIntelligenceAgent { if (this.behaviourType == null) this.behaviourType = MobBehaviourType.None; + this.building = BuildingManager.getBuilding(this.buildingUUID); + + if (this.contractUUID == 0) + this.contract = null; + else + this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); + + // Setup equipset for contract + + if (this.contract != null) + this.equipmentSetID = this.contract.getEquipmentSet(); + if (this.building != null) this.guild = this.building.getGuild(); else @@ -1596,7 +1587,7 @@ public class Mob extends AbstractIntelligenceAgent { // Don't override level for guard minions or pets if (this.contract == null) - if (!this.agentType.equals(AIAgentType.GUARDCAPTAIN) && !this.agentType.equals(AIAgentType.PET)) + if (!this.agentType.equals(AIAgentType.GUARDMINION) && !this.agentType.equals(AIAgentType.PET)) this.level = (short) this.mobBase.getLevel(); //set bonuses