From 2df4f658c98d6675a15f9fea692442d520938fd4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 23 Apr 2023 20:16:30 -0500 Subject: [PATCH] Mob.java cleanup --- src/engine/ai/MobileFSM.java | 6 --- src/engine/gameManager/NPCManager.java | 1 - src/engine/objects/Mob.java | 45 ++++--------------- .../poweractions/ClearAggroPowerAction.java | 2 +- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 4a4bf2f3..c1ec2849 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -70,7 +70,6 @@ public class MobileFSM { MobCallForHelp(mob); } if (!MovementUtilities.inRangeDropAggro(mob, target)) { - mob.setAggroTargetID(0); mob.setCombatTarget(null); return; } @@ -421,7 +420,6 @@ public class MobileFSM { if (aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType())) continue; if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { - aiAgent.setAggroTargetID(playerID); aiAgent.setCombatTarget(loadedPlayer); return; } @@ -523,14 +521,12 @@ public class MobileFSM { if(current == null || current.equals(mob.getGuild().getOwnedCity()) == false) { PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersManager.useMobPower(mob, mob, recall, 40); - mob.setAggroTargetID(0); mob.setCombatTarget(null); } } if (mob.getLoc().distanceSquared2D(mob.getBindLoc()) > sqr(2000)) { PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersManager.useMobPower(mob, mob, recall, 40); - mob.setAggroTargetID(0); mob.setCombatTarget(null); } } @@ -665,11 +661,9 @@ public class MobileFSM { if (GuardCanAggro(mob,loadedPlayer) == false) continue; if (MovementUtilities.inRangeToAggro(mob, loadedPlayer)) { - mob.setAggroTargetID(playerID); mob.setCombatTarget(loadedPlayer); if(mob.contract != null) { for (Entry minion : mob.siegeMinionMap.entrySet()) { - minion.getKey().setAggroTargetID(playerID); minion.getKey().setCombatTarget(loadedPlayer); } } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 1ba7ca68..c949ed86 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -39,7 +39,6 @@ public enum NPCManager { if (NPCManager._runeSetMap.get(mob.runeSet).contains(252623)) { mob.isPlayerGuard = true; - mob.setNoAggro(true); } // Only captains have contracts diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 78a96f81..41684c9c 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -36,6 +36,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -93,9 +94,6 @@ public class Mob extends AbstractIntelligenceAgent { private int buildingID; private boolean isSiege = false; private long timeToSpawnSiege; - private boolean noAggro = false; - private int aggroTargetID = 0; - private final boolean walkingHome = true; private long lastAttackTime = 0; private int lastMobPowerToken = 0; private HashMap equip = null; @@ -569,12 +567,6 @@ public class Mob extends AbstractIntelligenceAgent { return mob; } - public static int nextStaticID() { - int id = Mob.staticID; - Mob.staticID++; - return id; - } - public static Mob getMob(int id) { if (id == 0) return null; @@ -667,13 +659,9 @@ public class Mob extends AbstractIntelligenceAgent { MobBase minionMobBase; Mob mob; - int maxSlots = 1; + int maxSlots; switch (guardCaptain.getRank()) { - case 1: - case 2: - maxSlots = 1; - break; case 3: maxSlots = 2; break; @@ -687,6 +675,8 @@ public class Mob extends AbstractIntelligenceAgent { case 7: maxSlots = 5; break; + case 1: + case 2: default: maxSlots = 1; @@ -711,7 +701,7 @@ public class Mob extends AbstractIntelligenceAgent { if (guardCaptain.contract != null) { Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); if (minionType != null) { - String rank = ""; + String rank; if (guardCaptain.getRank() < 3) rank = MBServerStatics.JUNIOR; @@ -954,12 +944,6 @@ public class Mob extends AbstractIntelligenceAgent { return this.spawnRadius; } - public int getSpawnTime() { - - if (this.spawnTime == 0) return MBServerStatics.RESPAWN_TIMER; - else return this.spawnTime * 1000; - } - public void setSpawnTime(int value) { this.spawnTime = value; } @@ -1644,7 +1628,7 @@ public class Mob extends AbstractIntelligenceAgent { } float min, max; - float speed = 20f; + float speed; boolean strBased = false; // get skill percentages and min and max damage for weapons @@ -1810,9 +1794,9 @@ public class Mob extends AbstractIntelligenceAgent { if (npc.getSiegeMinionMap().containsKey(this)) putSlot = npc.getSiegeMinionMap().get(this); } else if (mob != null) { - //if (mob.getSiegeMinionMap().containsKey(this)) putSlot = mob.getSiegeMinionMap().get(this); - int hirelings = mob.building.getHirelings().size(); - putSlot = hirelings; + if (mob.building.getHirelings().containsKey(this)) + putSlot = mob.building.getHirelings().get(this); + //putSlot = mob.building.getHirelings().size(); } int count = 0; @@ -1999,14 +1983,6 @@ public class Mob extends AbstractIntelligenceAgent { return this.upgradeDateTime != null; } - public void setNoAggro(boolean noAggro) { - this.noAggro = noAggro; - } - - public void setAggroTargetID(int aggroTargetID) { - this.aggroTargetID = aggroTargetID; - } - public long getLastAttackTime() { return lastAttackTime; } @@ -2073,9 +2049,6 @@ public class Mob extends AbstractIntelligenceAgent { this.lastMobPowerToken = lastMobPowerToken; } - public Regions getLastRegion() { - return lastRegion; - } public boolean isLootSync() { return lootSync; diff --git a/src/engine/powers/poweractions/ClearAggroPowerAction.java b/src/engine/powers/poweractions/ClearAggroPowerAction.java index a21e15b1..1b02429f 100644 --- a/src/engine/powers/poweractions/ClearAggroPowerAction.java +++ b/src/engine/powers/poweractions/ClearAggroPowerAction.java @@ -30,7 +30,7 @@ public class ClearAggroPowerAction extends AbstractPowerAction { @Override protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) { if (awo != null && awo.getObjectType() == GameObjectType.Mob){ - ((Mob)awo).setNoAggro(true); + ((Mob)awo).setCombatTarget(null); }