diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 46a0e02c..68af5572 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2792,4 +2792,66 @@ public class Enum { ADMIN; } + public enum MobBehaviourType { + //Power + Power(null, false, true, true, true, false), + PowerHelpee(Power, false, true, true, false, true), + PowerHelpeeWimpy(Power, true, false, true, false, false), + PowerGrouperWimpy(Power, true, false, true, false, false), + PowerAggro(Power, false, true, true, false, true), + PowerAggroHelpee(Power, false, true, true, false, true), + //Aggro + Aggro(null, false, true, true, true, false), + AggroHelpee(Aggro, false, true, true, false, true), + AggroHelpeeWimpy(Aggro, true, false, true, false, false), + AggroGrouperWimpy(Aggro, true, false, true, false, false), + //Spell + Spell(null, false, true, true, true, false), + SpellHelpee(Spell, false, true, true, false, true), + SpellHelpeeWimpy(Spell, true, false, true, false, false), + SpellGrouperWimpy(Spell, true, false, true, false, false), + SpellAggro(Spell, false, true, true, false, true), + SpellAggroHelpee(Spell, false, true, true, false, true), + SpellAggroHelpeeWimpy(Spell, true, false, true, false, false), + SpellAggroHelpeeEpic(Spell, false, true, true, false, true), + SpellAggroGrouperWimpy(Spell, true, false, true, false, false), + //Independent Types + SimpleStandingGuard(null, false, false, false, false, false), + Pet1(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), + None(null, false, false, false, false, false), + GuardCaptain(null, false, true, true, true, false), + GuardMinion(GuardCaptain, false, true, true, false, true), + Wanderer(null, false, false, false, false, false), + HamletGuard(null, false, false, false, false, false), + AggroWanderer(null, false, false, false, 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; + + MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { + this.BehaviourHelperType = helpeebehaviourType; + this.isWimpy = wimpy; + this.isAgressive = agressive; + this.canRoam = canroam; + this.callsForHelp = callsforhelp; + this.respondsToCallForHelp = respondstocallforhelp; + } + + public static MobBehaviourType getByName(String name) { + for (MobBehaviourType behaviourType : values()) { + if (behaviourType.name().equalsIgnoreCase(name)) { + return behaviourType; + } + } + return MobBehaviourType.None; + } + } } diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 843f2df7..29e83ea1 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -6,6 +6,7 @@ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com package engine.ai; +import engine.Enum; import engine.Enum.DispatchChannel; import engine.InterestManagement.WorldGrid; import engine.ai.utilities.CombatUtilities; @@ -20,64 +21,12 @@ import engine.powers.ActionsBase; import engine.powers.PowersBase; import engine.server.MBServerStatics; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.sqr; public class MobileFSM { - public enum MobBehaviourType { - //Power - Power(null, false, true, true, true, false), - PowerHelpee(Power, false, true, true, false, true), - PowerHelpeeWimpy(Power, true, false, true, false, false), - PowerGrouperWimpy(Power, true, false, true, false, false), - PowerAggro(Power, false, true, true, false, true), - PowerAggroHelpee(Power, false, true, true, false, true), - //Aggro - Aggro(null, false, true, true, true, false), - AggroHelpee(Aggro, false, true, true, false, true), - AggroHelpeeWimpy(Aggro, true, false, true, false, false), - AggroGrouperWimpy(Aggro, true, false, true, false, false), - //Spell - Spell(null, false, true, true, true, false), - SpellHelpee(Spell, false, true, true, false, true), - SpellHelpeeWimpy(Spell, true, false, true, false, false), - SpellGrouperWimpy(Spell, true, false, true, false, false), - SpellAggro(Spell, false, true, true, false, true), - SpellAggroHelpee(Spell, false, true, true, false, true), - SpellAggroHelpeeWimpy(Spell, true, false, true, false, false), - SpellAggroHelpeeEpic(Spell, false, true, true, false, true), - SpellAggroGrouperWimpy(Spell, true, false, true, false, false), - //Independent Types - SimpleStandingGuard(null, false, false, false, false, false), - Pet1(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), - None(null, false, false, false, false, false), - GuardCaptain(null, false, true, true, true, false), - GuardMinion(GuardCaptain, false, true, true, false, true); - - private static HashMap _behaviourTypes = new HashMap<>(); - public MobBehaviourType BehaviourHelperType; - public boolean isWimpy; - public boolean isAgressive; - public boolean canRoam; - public boolean callsForHelp; - public boolean respondsToCallForHelp; - - MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { - this.BehaviourHelperType = helpeebehaviourType; - this.isWimpy = wimpy; - this.isAgressive = agressive; - this.canRoam = canroam; - this.callsForHelp = callsforhelp; - this.respondsToCallForHelp = respondstocallforhelp; - } - } private static void mobAttack(Mob aiAgent) { @@ -534,7 +483,7 @@ public class MobileFSM { if (mob == null) { return; } - if(mob.BehaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()){ + if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){ //this is a player slotted guard captain GuardCaptainLogic(mob); return; @@ -553,10 +502,10 @@ public class MobileFSM { return; } //check for players that can be aggroed if mob is agressive and has no target - if (mob.BehaviourType.isAgressive && mob.getCombatTarget() == null && mob.BehaviourType != MobBehaviourType.SimpleStandingGuard) { + if (mob.BehaviourType.isAgressive && mob.getCombatTarget() == null && mob.BehaviourType != Enum.MobBehaviourType.SimpleStandingGuard) { //normal aggro CheckForAggro(mob); - } else if (mob.BehaviourType == MobBehaviourType.SimpleStandingGuard) { + } else if (mob.BehaviourType == Enum.MobBehaviourType.SimpleStandingGuard) { //safehold guard SafeGuardAggro(mob); } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index c21212b5..5810417b 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -2,7 +2,6 @@ package engine.gameManager; import engine.Enum; import engine.InterestManagement.WorldGrid; -import engine.ai.MobileFSM; import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -325,7 +324,7 @@ public enum NPCManager { mob.deathTime = System.currentTimeMillis(); mob.spawnTime = 900; mob.npcOwner = guardCaptain; - mob.BehaviourType = MobileFSM.MobBehaviourType.GuardMinion; + mob.BehaviourType = Enum.MobBehaviourType.GuardMinion; return mob; } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 8c1f3b62..e32d550f 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -105,7 +105,7 @@ public class Mob extends AbstractIntelligenceAgent { public EnumBitSet notEnemy; public EnumBitSet enemy; - public MobileFSM.MobBehaviourType BehaviourType; + public MobBehaviourType BehaviourType; public ArrayList patrolPoints; public int lastPatrolPointIndex = 0; public long stopPatrolTime = 0; @@ -184,7 +184,7 @@ public class Mob extends AbstractIntelligenceAgent { this.parentZone = parent; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.ownerUID = owner.getObjectUUID(); - this.BehaviourType = MobileFSM.MobBehaviourType.Pet1; + this.BehaviourType = Enum.MobBehaviourType.Pet1; initializeMob(true, false, false); clearStatic(); } @@ -1996,7 +1996,7 @@ public class Mob extends AbstractIntelligenceAgent { } this.BehaviourType = this.getMobBase().fsm; if(this.isPlayerGuard() && this.contract != null){ - this.BehaviourType = MobileFSM.MobBehaviourType.GuardCaptain; + this.BehaviourType = Enum.MobBehaviourType.GuardCaptain; } } catch (Exception e) { Logger.error(e.getMessage()); diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index d016a145..9182cb78 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -11,7 +11,6 @@ package engine.objects; import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; -import engine.ai.MobileFSM; import engine.gameManager.DbManager; import engine.gameManager.NPCManager; import engine.server.MBServerStatics; @@ -61,7 +60,7 @@ public class MobBase extends AbstractGameObject { private float walkCombat = 0; private float runCombat = 0; public int bootySet; - public MobileFSM.MobBehaviourType fsm; + public Enum.MobBehaviourType fsm; public EnumBitSet notEnemy; public EnumBitSet enemy; @@ -90,7 +89,7 @@ public class MobBase extends AbstractGameObject { this.defenseRating = rs.getInt("defense"); this.attackRange = rs.getFloat("attackRange"); this.bootySet = rs.getInt("bootySet"); - this.fsm = MobileFSM.MobBehaviourType.valueOf(rs.getString("fsm")); + this.fsm = Enum.MobBehaviourType.getByName(rs.getString("fsm")); if (MobbaseGoldEntry.MobbaseGoldMap.containsKey(this.loadID)){ MobbaseGoldEntry goldEntry = MobbaseGoldEntry.MobbaseGoldMap.get(this.loadID);