From 685dd948e211294f0f050a3cf878ca2dcf2c0ccf Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 31 Jul 2023 21:55:20 -0500 Subject: [PATCH 01/16] asset placement validation to use city location not players location --- src/engine/net/client/handlers/PlaceAssetMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index a5956ebf..c8e1e777 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -190,7 +190,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; } - Realm serverRealm = RealmMap.getRealmAtLocation(player.getLoc()); + Realm serverRealm = RealmMap.getRealmAtLocation(city.getLoc()); // Cannot place buildings on seafloor or other restricted realms From 7cc5e0cf5c8f97716f2e5e9e63debfef64c3abf7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 17:22:34 -0500 Subject: [PATCH 02/16] timestamp to console after each completed iteration of MobileFSMManager --- src/engine/ai/MobileFSMManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index 6e2accf9..b57ac4fa 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -14,6 +14,7 @@ import engine.gameManager.ZoneManager; import engine.objects.Mob; import engine.objects.Zone; import engine.util.ThreadUtils; +import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.time.Duration; @@ -121,6 +122,7 @@ public class MobileFSMManager { executionMax = executionTime; mobPulse = System.currentTimeMillis() + AI_PULSE_MOB_THRESHOLD; + Logger.error("MobileFSM cycle completed: " + DateTime.now()); } } } From 1b6dcd4da08072226e3e76476af03d827bc17176 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 17:53:45 -0500 Subject: [PATCH 03/16] AuditAI command implemented and functions --- src/engine/ai/MobileFSM.java | 26 ++++++++++++++ src/engine/ai/MobileFSMManager.java | 38 +++++++++++++++++--- src/engine/devcmd/cmds/AuditAI.java | 44 +++++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 1 + 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 src/engine/devcmd/cmds/AuditAI.java diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index f977be90..c087814a 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -35,6 +35,7 @@ public class MobileFSM { private static void AttackTarget(Mob mob, AbstractWorldObject target) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKTARGET; if (mob == null) return; if (target == null || !target.isAlive()) { @@ -67,6 +68,7 @@ public class MobileFSM { } public static void AttackPlayer(Mob mob, PlayerCharacter target) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKPLAYER; if (!mob.canSee(target)) { mob.setCombatTarget(null); return; @@ -115,6 +117,7 @@ public class MobileFSM { } public static void AttackBuilding(Mob mob, Building target) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKBUILDING; if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { mob.setCombatTarget(null); return; @@ -156,6 +159,7 @@ public class MobileFSM { } public static void AttackMob(Mob mob, Mob target) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKMOB; if (mob.getRange() >= 30 && mob.isMoving()) return; //no weapons, default mob attack speed 3 seconds. @@ -186,6 +190,7 @@ public class MobileFSM { } private static void Patrol(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.PATROL; //make sure mob is out of combat stance if (mob.isCombat() && mob.getCombatTarget() == null) { mob.setCombat(false); @@ -235,6 +240,7 @@ public class MobileFSM { } public static boolean canCast(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CANCAST; // Performs validation to determine if a // mobile in the proper state to cast. if (mob == null) @@ -256,6 +262,7 @@ public class MobileFSM { } public static boolean MobCast(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.MOBCAST; // Method picks a random spell from a mobile's list of powers // and casts it on the current target (or itself). Validation // (including empty lists) is done previously within canCast(); @@ -320,6 +327,7 @@ public class MobileFSM { } public static void MobCallForHelp(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.MOBCALLFORHELP; boolean callGotResponse = false; if (mob.nextCallForHelp == 0) { mob.nextCallForHelp = System.currentTimeMillis(); @@ -341,6 +349,7 @@ public class MobileFSM { } public static void DetermineAction(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.DETERMINEACTION; //always check the respawn que, respawn 1 mob max per second to not flood the client if (mob == null) @@ -430,6 +439,7 @@ public class MobileFSM { } private static void CheckForAggro(Mob aiAgent) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORAGRO; //looks for and sets mobs combatTarget if (!aiAgent.isAlive()) return; @@ -477,6 +487,7 @@ public class MobileFSM { } private static void CheckMobMovement(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKMOBMOVEMENT; if (!MovementUtilities.canMove(mob)) return; mob.updateLocation(); @@ -523,6 +534,7 @@ public class MobileFSM { } private static void CheckForRespawn(Mob aiAgent) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORRESPAWN; if (aiAgent.deathTime == 0) { aiAgent.setDeathTime(System.currentTimeMillis()); return; @@ -561,6 +573,7 @@ public class MobileFSM { } public static void CheckForAttack(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORATTACK; //checks if mob can attack based on attack timer and range if (mob.isAlive() == false) return; @@ -588,6 +601,7 @@ public class MobileFSM { } private static void CheckToSendMobHome(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKTOSENDMOBHOME; if (mob.BehaviourType.isAgressive) { if (mob.isPlayerGuard()) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { @@ -626,6 +640,7 @@ public class MobileFSM { } private static void chaseTarget(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHASETARGET; mob.updateMovementState(); mob.updateLocation(); if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { @@ -651,6 +666,7 @@ public class MobileFSM { } private static void SafeGuardAggro(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.SAFEGUARDAGRO; HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); for (AbstractWorldObject awoMob : awoList) { //dont scan self. @@ -667,6 +683,7 @@ public class MobileFSM { } public static void GuardCaptainLogic(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDCAPTAINLOGIC; if (mob.getCombatTarget() == null) CheckForPlayerGuardAggro(mob); CheckMobMovement(mob); @@ -674,6 +691,7 @@ public class MobileFSM { } public static void GuardMinionLogic(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDMINIONLOGIC; if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { CheckForPlayerGuardAggro(mob); } @@ -686,6 +704,7 @@ public class MobileFSM { } public static void GuardWallArcherLogic(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDWALLARCHERLOGIC; if (mob.getCombatTarget() == null) CheckForPlayerGuardAggro(mob); else @@ -693,6 +712,7 @@ public class MobileFSM { } private static void PetLogic(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.PETLOGIC; if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){ if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){ mob.killCharacter("no owner"); @@ -718,6 +738,7 @@ public class MobileFSM { } private static void HamletGuardLogic(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.HAMLETGUARDLOGIC; if (mob.getCombatTarget() == null) { //safehold guard SafeGuardAggro(mob); @@ -730,6 +751,7 @@ public class MobileFSM { } private static void DefaultLogic(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.DEFAULTLOGIC; //check for players that can be aggroed if mob is agressive and has no target if(mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ mob.setCombatTarget(null); @@ -758,6 +780,7 @@ public class MobileFSM { } public static void CheckForPlayerGuardAggro(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORPLAYERGUARDAGRO; //looks for and sets mobs combatTarget if (!mob.isAlive()) return; @@ -789,6 +812,7 @@ public class MobileFSM { } public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDCANAGRO; if (mob.getGuild().getNation().equals(target.getGuild().getNation())) return false; if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { @@ -830,6 +854,7 @@ public class MobileFSM { } public static void randomGuardPatrolPoint(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.RANDOMGUARDPATROLPOINTS; if (mob.isMoving() == true) { //early exit for a mob who is already moving to a patrol point //while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin @@ -868,6 +893,7 @@ public class MobileFSM { } public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { + MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHANGETARGETFROMHATEVALUE; float CurrentHateValue = 0; if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index b57ac4fa..07bc6628 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -29,16 +29,44 @@ public class MobileFSMManager { //AI variables moved form mb_server_statics public static int AI_BASE_AGGRO_RANGE = 60; public static int AI_DROP_AGGRO_RANGE = 60; - public static int AI_RECALL_RANGE = 400; public static int AI_PULSE_MOB_THRESHOLD = 200; - public static int AI_THREAD_SLEEP = 1000; public static int AI_PATROL_DIVISOR = 15; public static int AI_POWER_DIVISOR = 20; - public static float AI_MAX_ANGLE = 10f; private volatile boolean alive; private long timeOfKill = -1; - - + public fsmState currentState; + public Mob currentMob; + public enum fsmState { + ATTACKTARGET, + ATTACKPLAYER, + ATTACKBUILDING, + ATTACKMOB, + PATROL, + CANCAST, + MOBCAST, + MOBCALLFORHELP, + DETERMINEACTION, + CHECKFORAGRO, + CHECKMOBMOVEMENT, + CHECKFORRESPAWN, + CHECKFORATTACK, + CHECKTOSENDMOBHOME, + CHASETARGET, + SAFEGUARDAGRO, + GUARDCAPTAINLOGIC, + GUARDMINIONLOGIC, + GUARDWALLARCHERLOGIC, + PETLOGIC, + HAMLETGUARDLOGIC, + DEFAULTLOGIC, + CHECKFORPLAYERGUARDAGRO, + GUARDCANAGRO, + RANDOMGUARDPATROLPOINTS, + CHANGETARGETFROMHATEVALUE + } + public String getFSMState(){ + return "Executing: " + this.currentState + " on Mobile UUID: " + this.currentMob.getObjectUUID() + " " + this.currentMob.getName(); + } private MobileFSMManager() { Runnable worker = new Runnable() { diff --git a/src/engine/devcmd/cmds/AuditAI.java b/src/engine/devcmd/cmds/AuditAI.java new file mode 100644 index 00000000..39889109 --- /dev/null +++ b/src/engine/devcmd/cmds/AuditAI.java @@ -0,0 +1,44 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.ai.MobileFSMManager; +import engine.devcmd.AbstractDevCmd; +import engine.objects.AbstractGameObject; +import engine.objects.PlayerCharacter; + +/** + * ./auditai <- display the current state of mob AI thread + */ + +public class AuditAI extends AbstractDevCmd { + + public AuditAI() { + super("auditai"); + } + + @Override + protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { + throwbackInfo(playerCharacter, MobileFSMManager.getInstance().getFSMState()); + } + + @Override + protected String _getHelpString() { + return "displays the current state and mob running thought he AI system"; + } + + @Override + protected String _getUsageString() { + return "'./auditai"; + } + + +} + diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 33ba103d..056bb62a 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -58,6 +58,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new InfoCmd()); DevCmdManager.registerDevCmd(new aiInfoCmd()); DevCmdManager.registerDevCmd(new simulateBootyCmd()); + DevCmdManager.registerDevCmd(new AuditAI()); DevCmdManager.registerDevCmd(new GetHeightCmd()); // Tester From bab033be2d9939241b6eeba063338fd5440f758d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 18:52:44 -0500 Subject: [PATCH 04/16] mobAI error tracing --- src/engine/ai/MobileFSM.java | 185 ++++++++++++++++------ src/engine/ai/MobileFSMManager.java | 35 +--- src/engine/devcmd/cmds/AuditAI.java | 44 ----- src/engine/gameManager/DevCmdManager.java | 1 - 4 files changed, 134 insertions(+), 131 deletions(-) delete mode 100644 src/engine/devcmd/cmds/AuditAI.java diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index c087814a..a1529795 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -23,6 +23,8 @@ import engine.objects.*; import engine.powers.ActionsBase; import engine.powers.PowersBase; import engine.server.MBServerStatics; +import org.pmw.tinylog.Logger; + import java.util.ArrayList; import java.util.HashSet; import java.util.Map.Entry; @@ -35,40 +37,43 @@ public class MobileFSM { private static void AttackTarget(Mob mob, AbstractWorldObject target) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKTARGET; - if (mob == null) - return; - if (target == null || !target.isAlive()) { - mob.setCombatTarget(null); - return; - } - if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) { - if (MobCast(mob)) { - mob.updateLocation(); + try { + if (mob == null) + return; + if (target == null || !target.isAlive()) { + mob.setCombatTarget(null); return; } + if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) { + if (MobCast(mob)) { + mob.updateLocation(); + return; + } + } + if (!CombatUtilities.inRangeToAttack(mob, target)) + return; + switch (target.getObjectType()) { + case PlayerCharacter: + PlayerCharacter targetPlayer = (PlayerCharacter) target; + AttackPlayer(mob, targetPlayer); + break; + case Building: + Building targetBuilding = (Building) target; + AttackBuilding(mob, targetBuilding); + break; + case Mob: + Mob targetMob = (Mob) target; + AttackMob(mob, targetMob); + break; + } + mob.updateLocation(); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); } - if (!CombatUtilities.inRangeToAttack(mob, target)) - return; - switch (target.getObjectType()) { - case PlayerCharacter: - PlayerCharacter targetPlayer = (PlayerCharacter) target; - AttackPlayer(mob, targetPlayer); - break; - case Building: - Building targetBuilding = (Building) target; - AttackBuilding(mob, targetBuilding); - break; - case Mob: - Mob targetMob = (Mob) target; - AttackMob(mob, targetMob); - break; - } - mob.updateLocation(); } public static void AttackPlayer(Mob mob, PlayerCharacter target) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKPLAYER; + try{ if (!mob.canSee(target)) { mob.setCombatTarget(null); return; @@ -114,10 +119,13 @@ public class MobileFSM { target.getPet().setCombatTarget(mob); } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage()); + } } public static void AttackBuilding(Mob mob, Building target) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKBUILDING; + try{ if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { mob.setCombatTarget(null); return; @@ -156,10 +164,13 @@ public class MobileFSM { ppm.setRange(50); DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); + } } public static void AttackMob(Mob mob, Mob target) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKMOB; + try{ if (mob.getRange() >= 30 && mob.isMoving()) return; //no weapons, default mob attack speed 3 seconds. @@ -187,10 +198,13 @@ public class MobileFSM { target.combatTarget = mob; } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage()); + } } private static void Patrol(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.PATROL; + try{ //make sure mob is out of combat stance if (mob.isCombat() && mob.getCombatTarget() == null) { mob.setCombat(false); @@ -237,10 +251,13 @@ public class MobileFSM { } } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); + } } public static boolean canCast(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CANCAST; + try{ // Performs validation to determine if a // mobile in the proper state to cast. if (mob == null) @@ -259,10 +276,14 @@ public class MobileFSM { mob.nextCastTime = System.currentTimeMillis(); return mob.nextCastTime <= System.currentTimeMillis(); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast" + " " + e.getMessage()); + } + return false; } public static boolean MobCast(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.MOBCAST; + try{ // Method picks a random spell from a mobile's list of powers // and casts it on the current target (or itself). Validation // (including empty lists) is done previously within canCast(); @@ -323,11 +344,14 @@ public class MobileFSM { mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000)) * randomCooldown); return true; } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage()); + } return false; } public static void MobCallForHelp(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.MOBCALLFORHELP; + try{ boolean callGotResponse = false; if (mob.nextCallForHelp == 0) { mob.nextCallForHelp = System.currentTimeMillis(); @@ -346,10 +370,13 @@ public class MobileFSM { if (callGotResponse) //wait 60 seconds to call for help again mob.nextCallForHelp = System.currentTimeMillis() + 60000; + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp" + " " + e.getMessage()); + } } public static void DetermineAction(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.DETERMINEACTION; + try{ //always check the respawn que, respawn 1 mob max per second to not flood the client if (mob == null) @@ -436,10 +463,13 @@ public class MobileFSM { DefaultLogic(mob); break; } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); + } } private static void CheckForAggro(Mob aiAgent) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORAGRO; + try{ //looks for and sets mobs combatTarget if (!aiAgent.isAlive()) return; @@ -484,10 +514,13 @@ public class MobileFSM { return; } } + } catch(Exception e){ + Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro" + " " + e.getMessage()); + } } private static void CheckMobMovement(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKMOBMOVEMENT; + try{ if (!MovementUtilities.canMove(mob)) return; mob.updateLocation(); @@ -531,10 +564,13 @@ public class MobileFSM { } break; } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); + } } private static void CheckForRespawn(Mob aiAgent) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORRESPAWN; + try{ if (aiAgent.deathTime == 0) { aiAgent.setDeathTime(System.currentTimeMillis()); return; @@ -570,10 +606,13 @@ public class MobileFSM { //aiAgent.respawn(); aiAgent.getParentZone().respawnQue.add(aiAgent); } + } catch(Exception e){ + Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); + } } public static void CheckForAttack(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORATTACK; + try{ //checks if mob can attack based on attack timer and range if (mob.isAlive() == false) return; @@ -598,10 +637,13 @@ public class MobileFSM { } if (System.currentTimeMillis() > mob.getLastAttackTime()) AttackTarget(mob, mob.getCombatTarget()); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage()); + } } private static void CheckToSendMobHome(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKTOSENDMOBHOME; + try{ if (mob.BehaviourType.isAgressive) { if (mob.isPlayerGuard()) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { @@ -637,10 +679,13 @@ public class MobileFSM { PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); + } } private static void chaseTarget(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHASETARGET; + try{ mob.updateMovementState(); mob.updateLocation(); if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { @@ -663,10 +708,13 @@ public class MobileFSM { } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage()); + } } private static void SafeGuardAggro(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.SAFEGUARDAGRO; + try{ HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); for (AbstractWorldObject awoMob : awoList) { //dont scan self. @@ -680,18 +728,24 @@ public class MobileFSM { continue; mob.setCombatTarget(aggroMob); } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro" + " " + e.getMessage()); + } } public static void GuardCaptainLogic(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDCAPTAINLOGIC; + try{ if (mob.getCombatTarget() == null) CheckForPlayerGuardAggro(mob); CheckMobMovement(mob); CheckForAttack(mob); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage()); + } } public static void GuardMinionLogic(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDMINIONLOGIC; + try{ if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { CheckForPlayerGuardAggro(mob); } @@ -701,18 +755,24 @@ public class MobileFSM { mob.setCombatTarget(null); CheckMobMovement(mob); CheckForAttack(mob); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage()); + } } public static void GuardWallArcherLogic(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDWALLARCHERLOGIC; + try{ if (mob.getCombatTarget() == null) CheckForPlayerGuardAggro(mob); else CheckForAttack(mob); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardWallArcherLogic" + " " + e.getMessage()); + } } private static void PetLogic(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.PETLOGIC; + try{ if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){ if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){ mob.killCharacter("no owner"); @@ -734,11 +794,13 @@ public class MobileFSM { mob.setHealth(mob.getHealthMax()); } } + }} catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); } } private static void HamletGuardLogic(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.HAMLETGUARDLOGIC; + try{ if (mob.getCombatTarget() == null) { //safehold guard SafeGuardAggro(mob); @@ -748,10 +810,13 @@ public class MobileFSM { } } CheckForAttack(mob); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage()); + } } private static void DefaultLogic(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.DEFAULTLOGIC; + try{ //check for players that can be aggroed if mob is agressive and has no target if(mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ mob.setCombatTarget(null); @@ -777,10 +842,13 @@ public class MobileFSM { //check if mob can attack if it isn't wimpy if (!mob.BehaviourType.isWimpy && mob.combatTarget != null) CheckForAttack(mob); + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage()); + } } public static void CheckForPlayerGuardAggro(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORPLAYERGUARDAGRO; + try{ //looks for and sets mobs combatTarget if (!mob.isAlive()) return; @@ -809,10 +877,13 @@ public class MobileFSM { return; } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro" + e.getMessage()); + } } public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDCANAGRO; + try{ if (mob.getGuild().getNation().equals(target.getGuild().getNation())) return false; if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { @@ -850,11 +921,14 @@ public class MobileFSM { return true; } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro" + " " + e.getMessage()); + } return false; } public static void randomGuardPatrolPoint(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.RANDOMGUARDPATROLPOINTS; + try{ if (mob.isMoving() == true) { //early exit for a mob who is already moving to a patrol point //while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin @@ -890,10 +964,13 @@ public class MobileFSM { } } } + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e.getMessage()); + } } public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { - MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHANGETARGETFROMHATEVALUE; + try{ float CurrentHateValue = 0; if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); @@ -910,5 +987,9 @@ public class MobileFSM { } } return mostHatedTarget; + } catch(Exception e){ + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage()); + } + return null; } } \ No newline at end of file diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index 07bc6628..98d81110 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -34,39 +34,6 @@ public class MobileFSMManager { public static int AI_POWER_DIVISOR = 20; private volatile boolean alive; private long timeOfKill = -1; - public fsmState currentState; - public Mob currentMob; - public enum fsmState { - ATTACKTARGET, - ATTACKPLAYER, - ATTACKBUILDING, - ATTACKMOB, - PATROL, - CANCAST, - MOBCAST, - MOBCALLFORHELP, - DETERMINEACTION, - CHECKFORAGRO, - CHECKMOBMOVEMENT, - CHECKFORRESPAWN, - CHECKFORATTACK, - CHECKTOSENDMOBHOME, - CHASETARGET, - SAFEGUARDAGRO, - GUARDCAPTAINLOGIC, - GUARDMINIONLOGIC, - GUARDWALLARCHERLOGIC, - PETLOGIC, - HAMLETGUARDLOGIC, - DEFAULTLOGIC, - CHECKFORPLAYERGUARDAGRO, - GUARDCANAGRO, - RANDOMGUARDPATROLPOINTS, - CHANGETARGETFROMHATEVALUE - } - public String getFSMState(){ - return "Executing: " + this.currentState + " on Mobile UUID: " + this.currentMob.getObjectUUID() + " " + this.currentMob.getName(); - } private MobileFSMManager() { Runnable worker = new Runnable() { @@ -150,7 +117,7 @@ public class MobileFSMManager { executionMax = executionTime; mobPulse = System.currentTimeMillis() + AI_PULSE_MOB_THRESHOLD; - Logger.error("MobileFSM cycle completed: " + DateTime.now()); + Logger.info("MobileFSM cycle completed: " + DateTime.now()); } } } diff --git a/src/engine/devcmd/cmds/AuditAI.java b/src/engine/devcmd/cmds/AuditAI.java deleted file mode 100644 index 39889109..00000000 --- a/src/engine/devcmd/cmds/AuditAI.java +++ /dev/null @@ -1,44 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.ai.MobileFSMManager; -import engine.devcmd.AbstractDevCmd; -import engine.objects.AbstractGameObject; -import engine.objects.PlayerCharacter; - -/** - * ./auditai <- display the current state of mob AI thread - */ - -public class AuditAI extends AbstractDevCmd { - - public AuditAI() { - super("auditai"); - } - - @Override - protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { - throwbackInfo(playerCharacter, MobileFSMManager.getInstance().getFSMState()); - } - - @Override - protected String _getHelpString() { - return "displays the current state and mob running thought he AI system"; - } - - @Override - protected String _getUsageString() { - return "'./auditai"; - } - - -} - diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 056bb62a..33ba103d 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -58,7 +58,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new InfoCmd()); DevCmdManager.registerDevCmd(new aiInfoCmd()); DevCmdManager.registerDevCmd(new simulateBootyCmd()); - DevCmdManager.registerDevCmd(new AuditAI()); DevCmdManager.registerDevCmd(new GetHeightCmd()); // Tester From cdd074c0ae7fd8f46e2615b22e18f6427466c874 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 18:56:56 -0500 Subject: [PATCH 05/16] respawn que null check --- src/engine/ai/MobileFSMManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index 98d81110..c4bd7624 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -95,9 +95,11 @@ public class MobileFSMManager { for (Zone zone : ZoneManager.getAllZones()) { if(zone.respawnQue.size() > 0 && zone.lastRespawn + 100 < System.currentTimeMillis()){ - zone.respawnQue.get(0).respawn(); - zone.respawnQue.remove(0); - zone.lastRespawn = System.currentTimeMillis(); + if(zone.respawnQue.get(0) != null) { + zone.respawnQue.get(0).respawn(); + zone.respawnQue.remove(0); + zone.lastRespawn = System.currentTimeMillis(); + } } for (Mob mob : zone.zoneMobSet) { From 7f1e53797580bbb1a905190f10400015cbf9fa3a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 19:19:39 -0500 Subject: [PATCH 06/16] mob respawning handled in its own thread --- src/engine/ai/MobileFSMManager.java | 7 -- src/engine/objects/Zone.java | 3 +- src/engine/server/world/WorldServer.java | 9 ++- src/engine/workthreads/MobRespawnThread.java | 74 ++++++++++++++++++++ 4 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 src/engine/workthreads/MobRespawnThread.java diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index c4bd7624..39d89849 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -94,13 +94,6 @@ public class MobileFSMManager { for (Zone zone : ZoneManager.getAllZones()) { - if(zone.respawnQue.size() > 0 && zone.lastRespawn + 100 < System.currentTimeMillis()){ - if(zone.respawnQue.get(0) != null) { - zone.respawnQue.get(0).respawn(); - zone.respawnQue.remove(0); - zone.lastRespawn = System.currentTimeMillis(); - } - } for (Mob mob : zone.zoneMobSet) { try { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 8fbd4990..45314553 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -58,7 +58,8 @@ public class Zone extends AbstractGameObject { private String hash; private float worldAltitude = 0; private float seaLevel = 0; - public static ArrayList respawnQue = new ArrayList<>(); + //public static ArrayList respawnQue = new ArrayList<>(); + public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; /** * ResultSet Constructor diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 48c2edfd..15acc575 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -18,6 +18,7 @@ import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; import engine.ai.MobileFSMManager; +import engine.workthreads.MobRespawnThread; import engine.db.archive.DataWarehouse; import engine.exception.MsgSendException; import engine.gameManager.*; @@ -57,6 +58,7 @@ import java.net.InetAddress; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; +import java.time.Duration; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -479,7 +481,10 @@ public class WorldServer { Logger.info("Initializing Client Connection Manager"); initClientConnectionManager(); - + + //intiate mob respawn thread + Logger.info("Starting network Dispatcher"); + MobRespawnThread.startRespawnThread(); // Run maintenance MaintenanceManager.dailyMaintenance(); @@ -494,7 +499,7 @@ public class WorldServer { // Calculate bootstrap time and rest boot time to current time. - java.time.Duration bootDuration = java.time.Duration.between(LocalDateTime.now(), bootTime); + Duration bootDuration = Duration.between(LocalDateTime.now(), bootTime); long bootSeconds = Math.abs(bootDuration.getSeconds()); String boottime = String.format("%d hours %02d minutes %02d seconds", bootSeconds / 3600, (bootSeconds % 3600) / 60, (bootSeconds % 60)); Logger.info("Bootstrap time was " + boottime); diff --git a/src/engine/workthreads/MobRespawnThread.java b/src/engine/workthreads/MobRespawnThread.java new file mode 100644 index 00000000..a0a6affa --- /dev/null +++ b/src/engine/workthreads/MobRespawnThread.java @@ -0,0 +1,74 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.workthreads; + +import engine.Enum.DispatchChannel; +import engine.gameManager.ZoneManager; +import engine.net.Dispatch; +import engine.objects.Mob; +import engine.objects.Zone; +import org.pmw.tinylog.Logger; + +import java.util.concurrent.ConcurrentLinkedQueue; + +/** + * Thread blocks until MagicBane dispatch messages are + * enqueued then processes them in FIFO order. The collection + * is thread safe. + *

+ * Any large messages not time sensitive such as load object + * sent to more than a single individual should be spawned + * individually on a DispatchMessageThread. + */ + +public class MobRespawnThread implements Runnable { + + // Instance variables + + + // Thread constructor + + public MobRespawnThread() { + + Logger.info(" MobRespawnThread thread has started!"); + + } + + @Override + public void run() { + for (Zone zone : ZoneManager.getAllZones()) { + if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { + if (zone.respawnQue.iterator().next() != null) { + Mob respawner = zone.respawnQue.iterator().next(); + respawner.respawn(); + zone.respawnQue.remove(respawner); + zone.lastRespawn = System.currentTimeMillis(); + } + } + } + } + public static void startRespawnThread() { + + Thread respawnThread; + respawnThread = new Thread(new PurgeOprhans()); + + respawnThread.setName("respawnThread"); + respawnThread.start(); + } +} From 50cd9b32dbaede1b5b4de568baae296f1361ec7a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 19:21:11 -0500 Subject: [PATCH 07/16] rename comment in WorldServer for mob respawn thread --- 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 15acc575..e96389ba 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -483,7 +483,7 @@ public class WorldServer { initClientConnectionManager(); //intiate mob respawn thread - Logger.info("Starting network Dispatcher"); + Logger.info("Starting Mob Respawn Thread"); MobRespawnThread.startRespawnThread(); // Run maintenance From 370efe1092f20820e6277200b8f844384e5d881f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 19:27:46 -0500 Subject: [PATCH 08/16] forget about that --- src/engine/workthreads/MobRespawnThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/workthreads/MobRespawnThread.java b/src/engine/workthreads/MobRespawnThread.java index a0a6affa..1d2bb4f5 100644 --- a/src/engine/workthreads/MobRespawnThread.java +++ b/src/engine/workthreads/MobRespawnThread.java @@ -66,7 +66,7 @@ public class MobRespawnThread implements Runnable { public static void startRespawnThread() { Thread respawnThread; - respawnThread = new Thread(new PurgeOprhans()); + respawnThread = new Thread(new MobRespawnThread()); respawnThread.setName("respawnThread"); respawnThread.start(); From 5e0b4ad763f5f264f054ac2ff3d1a73ad43ecd22 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 19:50:52 -0500 Subject: [PATCH 09/16] respawn while loop addition --- src/engine/ai/MobileFSM.java | 4 +++- src/engine/workthreads/MobRespawnThread.java | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index a1529795..9649a730 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -604,7 +604,9 @@ public class MobileFSM { } } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { //aiAgent.respawn(); - aiAgent.getParentZone().respawnQue.add(aiAgent); + if(aiAgent.getParentZone().respawnQue.contains(aiAgent) == false) { + aiAgent.getParentZone().respawnQue.add(aiAgent); + } } } catch(Exception e){ Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); diff --git a/src/engine/workthreads/MobRespawnThread.java b/src/engine/workthreads/MobRespawnThread.java index 1d2bb4f5..61f009c1 100644 --- a/src/engine/workthreads/MobRespawnThread.java +++ b/src/engine/workthreads/MobRespawnThread.java @@ -26,6 +26,7 @@ import engine.objects.Zone; import org.pmw.tinylog.Logger; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.LongAdder; /** * Thread blocks until MagicBane dispatch messages are @@ -41,24 +42,25 @@ public class MobRespawnThread implements Runnable { // Instance variables - // Thread constructor public MobRespawnThread() { - + Boolean isAlive = false; Logger.info(" MobRespawnThread thread has started!"); } @Override public void run() { - for (Zone zone : ZoneManager.getAllZones()) { - if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { - if (zone.respawnQue.iterator().next() != null) { - Mob respawner = zone.respawnQue.iterator().next(); - respawner.respawn(); - zone.respawnQue.remove(respawner); - zone.lastRespawn = System.currentTimeMillis(); + while(true) { + for (Zone zone : ZoneManager.getAllZones()) { + if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { + if (zone.respawnQue.iterator().next() != null) { + Mob respawner = zone.respawnQue.iterator().next(); + respawner.respawn(); + zone.respawnQue.remove(respawner); + zone.lastRespawn = System.currentTimeMillis(); + } } } } From 140a9bd0845be060d16e967fe87f6d030d1849f8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 20:13:23 -0500 Subject: [PATCH 10/16] mob AI new thread --- .../InterestManagement/InterestManager.java | 4 +- src/engine/ai/MobileFSMManager.java | 120 ------------------ src/engine/ai/utilities/PowerUtilities.java | 14 -- src/engine/db/handlers/dbMobBaseHandler.java | 1 - src/engine/devcmd/cmds/HeartbeatCmd.java | 46 ------- src/engine/gameManager/DevCmdManager.java | 1 - .../MobileFSM.java => mobileAI/MobAI.java} | 19 +-- src/engine/mobileAI/Threads/MobAIThread.java | 46 +++++++ .../Threads}/MobRespawnThread.java | 11 +- .../utilities/CombatUtilities.java | 2 +- .../utilities/MovementUtilities.java | 8 +- .../objects/AbstractIntelligenceAgent.java | 4 +- src/engine/objects/Mob.java | 4 +- .../poweractions/CreateMobPowerAction.java | 1 - .../poweractions/MobRecallPowerAction.java | 2 +- src/engine/server/world/WorldServer.java | 10 +- 16 files changed, 75 insertions(+), 218 deletions(-) delete mode 100644 src/engine/ai/MobileFSMManager.java delete mode 100644 src/engine/ai/utilities/PowerUtilities.java delete mode 100644 src/engine/devcmd/cmds/HeartbeatCmd.java rename src/engine/{ai/MobileFSM.java => mobileAI/MobAI.java} (98%) create mode 100644 src/engine/mobileAI/Threads/MobAIThread.java rename src/engine/{workthreads => mobileAI/Threads}/MobRespawnThread.java (92%) rename src/engine/{ai => mobileAI}/utilities/CombatUtilities.java (99%) rename src/engine/{ai => mobileAI}/utilities/MovementUtilities.java (97%) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index 9ab31019..0580d421 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -458,7 +458,7 @@ public enum InterestManager implements Runnable { continue; awonpc.playerAgroMap.put(player.getObjectUUID(), false); - //MobileFSM.setAwake(awonpc, false); + //MobAI.setAwake(awonpc, false); ((Mob) awonpc).setCombatTarget(null); // IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000)); // awonpc.enableIntelligence(); @@ -475,7 +475,7 @@ public enum InterestManager implements Runnable { awonpc.playerAgroMap.put(player.getObjectUUID(), false); if (awonpc.isMob()) - //MobileFSM.setAwake(awonpc, false); + //MobAI.setAwake(awonpc, false); ((Mob) awonpc).setCombatTarget(null); // IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000)); // awonpc.enableIntelligence(); diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java deleted file mode 100644 index 39d89849..00000000 --- a/src/engine/ai/MobileFSMManager.java +++ /dev/null @@ -1,120 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.ai; - -import engine.gameManager.ConfigManager; -import engine.gameManager.ZoneManager; -import engine.objects.Mob; -import engine.objects.Zone; -import engine.util.ThreadUtils; -import org.joda.time.DateTime; -import org.pmw.tinylog.Logger; - -import java.time.Duration; -import java.time.Instant; - - -public class MobileFSMManager { - - private static final MobileFSMManager INSTANCE = new MobileFSMManager(); - public static Duration executionTime = Duration.ofNanos(1); - public static Duration executionMax = Duration.ofNanos(1); - //AI variables moved form mb_server_statics - public static int AI_BASE_AGGRO_RANGE = 60; - public static int AI_DROP_AGGRO_RANGE = 60; - public static int AI_PULSE_MOB_THRESHOLD = 200; - public static int AI_PATROL_DIVISOR = 15; - public static int AI_POWER_DIVISOR = 20; - private volatile boolean alive; - private long timeOfKill = -1; - private MobileFSMManager() { - - Runnable worker = new Runnable() { - @Override - public void run() { - execution(); - } - }; - - alive = true; - - //assign the AI varibales base don difficulty scaling from config file: - - float difficulty = Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()); - AI_BASE_AGGRO_RANGE = (int) (100 * difficulty); // range at which aggressive mobs will attack you - - difficulty = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue()); - AI_POWER_DIVISOR = (int) (20 * (1.5f - difficulty)); //duration between mob casts - - Thread t = new Thread(worker, "MobileFSMManager"); - t.start(); - } - - public static MobileFSMManager getInstance() { - return INSTANCE; - } - - /** - * Stops the MobileFSMManager - */ - public void shutdown() { - if (alive) { - alive = false; - timeOfKill = System.currentTimeMillis(); - } - } - - - public boolean isAlive() { - return this.alive; - } - - - private void execution() { - - //Load zone threshold once. - - long mobPulse = System.currentTimeMillis() + AI_PULSE_MOB_THRESHOLD; - Instant startTime; - - while (alive) { - - ThreadUtils.sleep(1); - - if (System.currentTimeMillis() > mobPulse) { - - startTime = Instant.now(); - - for (Zone zone : ZoneManager.getAllZones()) { - - for (Mob mob : zone.zoneMobSet) { - - try { - if (mob != null) - MobileFSM.DetermineAction(mob); - } catch (Exception e) { - Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e); - e.printStackTrace(); - } - } - } - - executionTime = Duration.between(startTime, Instant.now()); - - if (executionTime.compareTo(executionMax) > 0) - executionMax = executionTime; - - mobPulse = System.currentTimeMillis() + AI_PULSE_MOB_THRESHOLD; - Logger.info("MobileFSM cycle completed: " + DateTime.now()); - } - } - } - -} diff --git a/src/engine/ai/utilities/PowerUtilities.java b/src/engine/ai/utilities/PowerUtilities.java deleted file mode 100644 index 66039f96..00000000 --- a/src/engine/ai/utilities/PowerUtilities.java +++ /dev/null @@ -1,14 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.ai.utilities; - -public class PowerUtilities { - -} diff --git a/src/engine/db/handlers/dbMobBaseHandler.java b/src/engine/db/handlers/dbMobBaseHandler.java index f59ab84f..fce26d02 100644 --- a/src/engine/db/handlers/dbMobBaseHandler.java +++ b/src/engine/db/handlers/dbMobBaseHandler.java @@ -10,7 +10,6 @@ package engine.db.handlers; import engine.Enum.GameObjectType; -import engine.ai.MobileFSMManager; import engine.gameManager.DbManager; import engine.objects.MobBase; import engine.objects.MobBaseEffects; diff --git a/src/engine/devcmd/cmds/HeartbeatCmd.java b/src/engine/devcmd/cmds/HeartbeatCmd.java deleted file mode 100644 index 84afaba6..00000000 --- a/src/engine/devcmd/cmds/HeartbeatCmd.java +++ /dev/null @@ -1,46 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.ai.MobileFSMManager; -import engine.devcmd.AbstractDevCmd; -import engine.gameManager.SimulationManager; -import engine.objects.AbstractGameObject; -import engine.objects.PlayerCharacter; - -public class HeartbeatCmd extends AbstractDevCmd { - - public HeartbeatCmd() { - super("heartbeat"); - } - - @Override - protected void _doCmd(PlayerCharacter pc, String[] words, - AbstractGameObject target) { - - this.throwbackInfo(pc, "Heartbeat : " + SimulationManager.executionTime.toMillis() + "ms"); - this.throwbackInfo(pc, "Heartbeat Max: " + SimulationManager.executionMax.toMillis() + "ms"); - - this.throwbackInfo(pc, "FSM: " + MobileFSMManager.executionTime.toMillis() + "ms"); - this.throwbackInfo(pc, "FSM max: " + MobileFSMManager.executionMax.toMillis() + "ms"); - - } - - @Override - protected String _getHelpString() { - return "Displays simulation metrics"; - } - - @Override - protected String _getUsageString() { - return "' ./heartbeat"; - } - -} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 33ba103d..d9a37b29 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -135,7 +135,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd()); DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd()); DevCmdManager.registerDevCmd(new ResetLevelCmd()); - DevCmdManager.registerDevCmd(new HeartbeatCmd()); DevCmdManager.registerDevCmd(new SetNpcNameCmd()); DevCmdManager.registerDevCmd(new SetNpcMobbaseCmd()); DevCmdManager.registerDevCmd(new DespawnCmd()); diff --git a/src/engine/ai/MobileFSM.java b/src/engine/mobileAI/MobAI.java similarity index 98% rename from src/engine/ai/MobileFSM.java rename to src/engine/mobileAI/MobAI.java index 9649a730..4fc1024e 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/mobileAI/MobAI.java @@ -5,13 +5,14 @@ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com -package engine.ai; +package engine.mobileAI; import engine.Enum; import engine.Enum.DispatchChannel; import engine.InterestManagement.WorldGrid; -import engine.ai.utilities.CombatUtilities; -import engine.ai.utilities.MovementUtilities; +import engine.mobileAI.Threads.MobAIThread; +import engine.mobileAI.utilities.CombatUtilities; +import engine.mobileAI.utilities.MovementUtilities; import engine.gameManager.*; import engine.math.Vector3f; import engine.math.Vector3fImmutable; @@ -33,7 +34,7 @@ import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.sqr; -public class MobileFSM { +public class MobAI { private static void AttackTarget(Mob mob, AbstractWorldObject target) { @@ -212,7 +213,7 @@ public class MobileFSM { rwss.setPlayer(mob); DispatchMessage.sendToAllInRange(mob, rwss); } - int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobileFSMManager.AI_PATROL_DIVISOR * 0.5f), MobileFSMManager.AI_PATROL_DIVISOR) + MobileFSMManager.AI_PATROL_DIVISOR; + int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR; if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis()) //early exit while waiting to patrol again return; @@ -269,7 +270,7 @@ public class MobileFSM { return false; } int castRoll = ThreadLocalRandom.current().nextInt(101); - if(castRoll <= MobileFSMManager.AI_POWER_DIVISOR){ + if(castRoll <= MobAIThread.AI_POWER_DIVISOR){ return false; } if (mob.nextCastTime == 0) @@ -341,7 +342,7 @@ public class MobileFSM { PowersManager.finishUseMobPower(msg, mob, 0, 0); // Default minimum seconds between cast = 10 float randomCooldown = (ThreadLocalRandom.current().nextInt(150) + 100) * 0.01f; - mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000)) * randomCooldown); + mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobAIThread.AI_POWER_DIVISOR * 1000)) * randomCooldown); return true; } } catch(Exception e){ @@ -504,7 +505,7 @@ public class MobileFSM { } if(aiAgent.combatTarget == null) { //look for pets to aggro if no players found to aggro - HashSet awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobileFSMManager.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET); + HashSet awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET); for (AbstractWorldObject awoMob : awoList) { //dont scan self. if (aiAgent.equals(awoMob)) @@ -655,7 +656,7 @@ public class MobileFSM { CheckForAggro(mob); } } - if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobileFSMManager.AI_BASE_AGGRO_RANGE * 0.5f)) { + if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f)) { return; } if (mob.isPlayerGuard() && !mob.despawned) { diff --git a/src/engine/mobileAI/Threads/MobAIThread.java b/src/engine/mobileAI/Threads/MobAIThread.java new file mode 100644 index 00000000..3e92a1f9 --- /dev/null +++ b/src/engine/mobileAI/Threads/MobAIThread.java @@ -0,0 +1,46 @@ +package engine.mobileAI.Threads; + +import engine.mobileAI.MobAI; +import engine.gameManager.ZoneManager; +import engine.objects.Mob; +import engine.objects.Zone; +import org.pmw.tinylog.Logger; + +public class MobAIThread implements Runnable{ + public static int AI_BASE_AGGRO_RANGE = 60; + public static int AI_DROP_AGGRO_RANGE = 60; + public static int AI_PULSE_MOB_THRESHOLD = 200; + public static int AI_PATROL_DIVISOR = 15; + public static int AI_POWER_DIVISOR = 20; + // Thread constructor + + public MobAIThread() { + Logger.info(" MobAIThread thread has started!"); + + } + + @Override + public void run() { + while (true) { + for (Zone zone : ZoneManager.getAllZones()) { + + for (Mob mob : zone.zoneMobSet) { + + try { + if (mob != null) + MobAI.DetermineAction(mob); + } catch (Exception e) { + Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e); + e.printStackTrace(); + } + } + } + } + } + public static void startAIThread() { + Thread aiThread; + aiThread = new Thread(new MobAIThread()); + aiThread.setName("aiThread"); + aiThread.start(); + } +} diff --git a/src/engine/workthreads/MobRespawnThread.java b/src/engine/mobileAI/Threads/MobRespawnThread.java similarity index 92% rename from src/engine/workthreads/MobRespawnThread.java rename to src/engine/mobileAI/Threads/MobRespawnThread.java index 61f009c1..2e9beb49 100644 --- a/src/engine/workthreads/MobRespawnThread.java +++ b/src/engine/mobileAI/Threads/MobRespawnThread.java @@ -16,18 +16,12 @@ // www.magicbane.com -package engine.workthreads; - -import engine.Enum.DispatchChannel; +package engine.mobileAI.Threads; import engine.gameManager.ZoneManager; -import engine.net.Dispatch; import engine.objects.Mob; import engine.objects.Zone; import org.pmw.tinylog.Logger; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.LongAdder; - /** * Thread blocks until MagicBane dispatch messages are * enqueued then processes them in FIFO order. The collection @@ -45,7 +39,6 @@ public class MobRespawnThread implements Runnable { // Thread constructor public MobRespawnThread() { - Boolean isAlive = false; Logger.info(" MobRespawnThread thread has started!"); } @@ -66,10 +59,8 @@ public class MobRespawnThread implements Runnable { } } public static void startRespawnThread() { - Thread respawnThread; respawnThread = new Thread(new MobRespawnThread()); - respawnThread.setName("respawnThread"); respawnThread.start(); } diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/mobileAI/utilities/CombatUtilities.java similarity index 99% rename from src/engine/ai/utilities/CombatUtilities.java rename to src/engine/mobileAI/utilities/CombatUtilities.java index 3fb076a1..5ad79656 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/mobileAI/utilities/CombatUtilities.java @@ -7,7 +7,7 @@ // www.magicbane.com -package engine.ai.utilities; +package engine.mobileAI.utilities; import engine.Enum.*; import engine.gameManager.ChatManager; diff --git a/src/engine/ai/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java similarity index 97% rename from src/engine/ai/utilities/MovementUtilities.java rename to src/engine/mobileAI/utilities/MovementUtilities.java index b07d9a9a..85affdca 100644 --- a/src/engine/ai/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -7,13 +7,13 @@ // www.magicbane.com -package engine.ai.utilities; +package engine.mobileAI.utilities; import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.ai.MobileFSMManager; +import engine.mobileAI.Threads.MobAIThread; import engine.exception.MsgSendException; import engine.gameManager.MovementManager; import engine.math.Vector3fImmutable; @@ -79,7 +79,7 @@ public class MovementUtilities { zoneRange = agent.getSpawnRadius(); - return distanceSquaredToTarget < sqr(MobileFSMManager.AI_DROP_AGGRO_RANGE + zoneRange); + return distanceSquaredToTarget < sqr(MobAIThread.AI_DROP_AGGRO_RANGE + zoneRange); } @@ -89,7 +89,7 @@ public class MovementUtilities { Vector3fImmutable tl = target.getLoc(); float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target - float range = MobileFSMManager.AI_BASE_AGGRO_RANGE; + float range = MobAIThread.AI_BASE_AGGRO_RANGE; if (agent.isPlayerGuard()) range = 150; diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index e9b42ff5..525090fe 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -14,7 +14,7 @@ import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; import engine.InterestManagement.WorldGrid; -import engine.ai.MobileFSMManager; +import engine.mobileAI.Threads.MobAIThread; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.net.Dispatch; @@ -190,7 +190,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { public abstract AbstractWorldObject getFearedObject(); public float getAggroRange() { - float ret = MobileFSMManager.AI_BASE_AGGRO_RANGE; + float ret = MobAIThread.AI_BASE_AGGRO_RANGE; if (this.bonuses != null) ret *= (1 + this.bonuses.getFloatPercentAll(ModType.ScanRange, SourceType.None)); return ret; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index cacf16b8..109bad24 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -13,7 +13,7 @@ import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.Enum.*; import engine.InterestManagement.WorldGrid; -import engine.ai.MobileFSMManager; +import engine.mobileAI.Threads.MobAIThread; import engine.exception.SerializationException; import engine.gameManager.*; import engine.job.JobScheduler; @@ -630,7 +630,7 @@ public class Mob extends AbstractIntelligenceAgent { public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { - HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobileFSMManager.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); + HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobAIThread.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); for (AbstractWorldObject awo : mobsInRange) { Mob mob = (Mob) awo; diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index 82150a97..5c9ec7fa 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -11,7 +11,6 @@ package engine.powers.poweractions; import engine.Enum; import engine.InterestManagement.WorldGrid; -import engine.ai.utilities.MovementUtilities; import engine.gameManager.DbManager; import engine.gameManager.MovementManager; import engine.gameManager.NPCManager; diff --git a/src/engine/powers/poweractions/MobRecallPowerAction.java b/src/engine/powers/poweractions/MobRecallPowerAction.java index 8b25c029..d5318fcf 100644 --- a/src/engine/powers/poweractions/MobRecallPowerAction.java +++ b/src/engine/powers/poweractions/MobRecallPowerAction.java @@ -40,7 +40,7 @@ public class MobRecallPowerAction extends AbstractPowerAction { MovementManager.translocate(awoac, awoac.getBindLoc(), null); if (awoac.getObjectType() == GameObjectType.Mob) { - //MobileFSM.setAwake((Mob)awoac,true); + //MobAI.setAwake((Mob)awoac,true); ((Mob) awoac).setCombatTarget(null); } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e96389ba..91d16acc 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -17,8 +17,8 @@ import engine.Enum.SupportMsgType; import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; -import engine.ai.MobileFSMManager; -import engine.workthreads.MobRespawnThread; +import engine.mobileAI.Threads.MobAIThread; +import engine.mobileAI.Threads.MobRespawnThread; import engine.db.archive.DataWarehouse; import engine.exception.MsgSendException; import engine.gameManager.*; @@ -459,8 +459,9 @@ public class WorldServer { Logger.info("Running Heraldry Audit for Deleted Players"); Heraldry.AuditHeraldry(); - Logger.info("Starting Mobile AI FSM"); - MobileFSMManager.getInstance(); + //intiate mob ai thread + Logger.info("Starting Mob AI Thread"); + MobAIThread.startAIThread(); for (Zone zone : ZoneManager.getAllZones()) { if (zone.getHeightMap() != null) { @@ -485,6 +486,7 @@ public class WorldServer { //intiate mob respawn thread Logger.info("Starting Mob Respawn Thread"); MobRespawnThread.startRespawnThread(); + // Run maintenance MaintenanceManager.dailyMaintenance(); From b47848d63d1d25e6fea80e504c81b55f4e2eed02 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 20:32:02 -0500 Subject: [PATCH 11/16] mob drop combat targets no longer in game --- src/engine/mobileAI/MobAI.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 4fc1024e..0b788f1e 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -429,9 +429,9 @@ public class MobAI { mob.setCombatTarget(null); return; } - if(mob.getCombatTarget().getObjectTypeMask() == MBServerStatics.MASK_PLAYER){ - if(mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ + PlayerCharacter target = (PlayerCharacter)mob.combatTarget; + if(mob.playerAgroMap.containsKey(target.getObjectUUID()) == false){ mob.setCombatTarget(null); return; } @@ -439,6 +439,10 @@ public class MobAI { mob.setCombatTarget(null); return; } + if(target.getClientConnection() == null){ + mob.setCombatTarget(null); + return; + } } } //if(mob.getTimestamps().containsKey("LOCATIONSYNC") == false){ From b8cb90cdd038ad20d144d9031f7809df45249360 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 1 Aug 2023 21:26:14 -0500 Subject: [PATCH 12/16] mob pulse delay added to mobAI --- src/engine/mobileAI/MobAI.java | 17 +++++++++++------ src/engine/server/world/WorldServer.java | 6 +++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 0b788f1e..689e8a38 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -382,6 +382,13 @@ public class MobAI { if (mob == null) return; + if(mob.getTimestamps().containsKey("lastExecution") == false){ + mob.getTimestamps().put("lastExecution",System.currentTimeMillis()); + } + if(System.currentTimeMillis() < mob.getTimeStamp("lastExecution")){ + return; + } + mob.getTimestamps().put("lastExecution",System.currentTimeMillis() + MobAIThread.AI_PULSE_MOB_THRESHOLD); if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { //trebuchet spawn handler CheckForRespawn(mob); @@ -439,10 +446,6 @@ public class MobAI { mob.setCombatTarget(null); return; } - if(target.getClientConnection() == null){ - mob.setCombatTarget(null); - return; - } } } //if(mob.getTimestamps().containsKey("LOCATIONSYNC") == false){ @@ -705,14 +708,16 @@ public class MobAI { case PlayerCharacter: case Mob: mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); - MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange()); + MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange() + 1); break; case Building: mob.destination = mob.getCombatTarget().getLoc(); MovementUtilities.moveToLocation(mob,mob.getCombatTarget().getLoc(),0); break; } - + if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == true){ + mob.stopMovement(mob.getLoc()); + } } } } catch(Exception e){ diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 91d16acc..b7b520e6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -704,7 +704,11 @@ public class WorldServer { Logger.error("Unable to find PlayerCharacter to logout"); return; } - + //remove player from loaded mobs agro maps + for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) { + Mob loadedMob = (Mob) awo; + loadedMob.playerAgroMap.remove(player.getObjectUUID()); + } player.getTimestamps().put("logout", System.currentTimeMillis()); player.setEnteredWorld(false); From 350a1208f561736ffed0aae633d891cbe4f9d644 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 2 Aug 2023 08:07:41 -0400 Subject: [PATCH 13/16] Try-catch surrounding respawn code. --- .../mobileAI/Threads/MobRespawnThread.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/engine/mobileAI/Threads/MobRespawnThread.java b/src/engine/mobileAI/Threads/MobRespawnThread.java index 2e9beb49..10b62364 100644 --- a/src/engine/mobileAI/Threads/MobRespawnThread.java +++ b/src/engine/mobileAI/Threads/MobRespawnThread.java @@ -45,17 +45,28 @@ public class MobRespawnThread implements Runnable { @Override public void run() { - while(true) { - for (Zone zone : ZoneManager.getAllZones()) { - if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { - if (zone.respawnQue.iterator().next() != null) { + + while (true) { + + try { + for (Zone zone : ZoneManager.getAllZones()) { + + if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { + Mob respawner = zone.respawnQue.iterator().next(); + + if (respawner == null) + continue; + respawner.respawn(); zone.respawnQue.remove(respawner); zone.lastRespawn = System.currentTimeMillis(); } } + } catch (Exception e) { + Logger.error(e); } + } } public static void startRespawnThread() { From a299493bd7b047fe1478ef4f2bad519ec03bafa5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 2 Aug 2023 08:18:50 -0400 Subject: [PATCH 14/16] Cleanup of file project headers. --- src/engine/devcmd/cmds/CombatMessageCmd.java | 9 --------- src/engine/jobs/DoorCloseJob.java | 9 --------- .../mobileAI/Threads/MobRespawnThread.java | 9 --------- src/engine/net/Dispatch.java | 9 --------- src/engine/net/ItemProductionManager.java | 9 --------- src/engine/net/ItemQueue.java | 9 --------- src/engine/net/MessageDispatcher.java | 9 --------- .../handlers/AcceptInviteToGuildHandler.java | 9 --------- .../net/client/handlers/ChangeRankHandler.java | 9 --------- .../handlers/GuildCreationFinalizeHandler.java | 9 --------- .../handlers/HirelingServiceMsgHandler.java | 9 --------- src/engine/net/client/msg/DoorTryOpenMsg.java | 18 ------------------ src/engine/net/client/msg/ObjectActionMsg.java | 9 --------- .../net/client/msg/TargetedActionMsg.java | 9 --------- src/engine/net/client/msg/UpdateStateMsg.java | 9 --------- src/engine/net/client/msg/WorldRealmMsg.java | 9 --------- .../client/msg/guild/AcceptSubInviteMsg.java | 18 ------------------ .../net/client/msg/guild/ChangeRankMsg.java | 18 ------------------ .../net/client/msg/guild/GuildInfoMsg.java | 9 --------- .../msg/login/CommitNewCharacterMsg.java | 9 --------- src/engine/objects/Corpse.java | 9 --------- src/engine/objects/Guild.java | 9 --------- src/engine/objects/ItemBase.java | 9 --------- src/engine/objects/Mine.java | 9 --------- src/engine/powers/EffectsBase.java | 9 --------- .../effectmodifiers/ManaEffectModifier.java | 9 --------- .../effectmodifiers/StaminaEffectModifier.java | 9 --------- .../poweractions/ApplyEffectPowerAction.java | 9 --------- 28 files changed, 279 deletions(-) diff --git a/src/engine/devcmd/cmds/CombatMessageCmd.java b/src/engine/devcmd/cmds/CombatMessageCmd.java index a3615e89..6f1254d5 100644 --- a/src/engine/devcmd/cmds/CombatMessageCmd.java +++ b/src/engine/devcmd/cmds/CombatMessageCmd.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; diff --git a/src/engine/jobs/DoorCloseJob.java b/src/engine/jobs/DoorCloseJob.java index 44e50b21..8606d6f3 100644 --- a/src/engine/jobs/DoorCloseJob.java +++ b/src/engine/jobs/DoorCloseJob.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.jobs; import engine.Enum.DoorState; diff --git a/src/engine/mobileAI/Threads/MobRespawnThread.java b/src/engine/mobileAI/Threads/MobRespawnThread.java index 10b62364..eee68bb3 100644 --- a/src/engine/mobileAI/Threads/MobRespawnThread.java +++ b/src/engine/mobileAI/Threads/MobRespawnThread.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.mobileAI.Threads; import engine.gameManager.ZoneManager; import engine.objects.Mob; diff --git a/src/engine/net/Dispatch.java b/src/engine/net/Dispatch.java index ebbdb4de..d10e0068 100644 --- a/src/engine/net/Dispatch.java +++ b/src/engine/net/Dispatch.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/ItemProductionManager.java b/src/engine/net/ItemProductionManager.java index 0d2cb0c8..78577668 100644 --- a/src/engine/net/ItemProductionManager.java +++ b/src/engine/net/ItemProductionManager.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net; import engine.Enum.DispatchChannel; diff --git a/src/engine/net/ItemQueue.java b/src/engine/net/ItemQueue.java index c95dea2e..e5373324 100644 --- a/src/engine/net/ItemQueue.java +++ b/src/engine/net/ItemQueue.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net; import engine.objects.ProducedItem; diff --git a/src/engine/net/MessageDispatcher.java b/src/engine/net/MessageDispatcher.java index c804a4ea..862be7b7 100644 --- a/src/engine/net/MessageDispatcher.java +++ b/src/engine/net/MessageDispatcher.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net; import engine.Enum.DispatchChannel; diff --git a/src/engine/net/client/handlers/AcceptInviteToGuildHandler.java b/src/engine/net/client/handlers/AcceptInviteToGuildHandler.java index a14cba57..a0269277 100644 --- a/src/engine/net/client/handlers/AcceptInviteToGuildHandler.java +++ b/src/engine/net/client/handlers/AcceptInviteToGuildHandler.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.handlers; import engine.Enum; diff --git a/src/engine/net/client/handlers/ChangeRankHandler.java b/src/engine/net/client/handlers/ChangeRankHandler.java index db4ee68c..8197fbff 100644 --- a/src/engine/net/client/handlers/ChangeRankHandler.java +++ b/src/engine/net/client/handlers/ChangeRankHandler.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.handlers; import engine.Enum; diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index d3d30b08..aed341f4 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.handlers; import engine.Enum; diff --git a/src/engine/net/client/handlers/HirelingServiceMsgHandler.java b/src/engine/net/client/handlers/HirelingServiceMsgHandler.java index 44d9a6d2..68ee899c 100644 --- a/src/engine/net/client/handlers/HirelingServiceMsgHandler.java +++ b/src/engine/net/client/handlers/HirelingServiceMsgHandler.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.handlers; diff --git a/src/engine/net/client/msg/DoorTryOpenMsg.java b/src/engine/net/client/msg/DoorTryOpenMsg.java index 8e9ef720..17c6116a 100644 --- a/src/engine/net/client/msg/DoorTryOpenMsg.java +++ b/src/engine/net/client/msg/DoorTryOpenMsg.java @@ -16,24 +16,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg; import engine.Enum.GameObjectType; diff --git a/src/engine/net/client/msg/ObjectActionMsg.java b/src/engine/net/client/msg/ObjectActionMsg.java index 44429666..c3922440 100644 --- a/src/engine/net/client/msg/ObjectActionMsg.java +++ b/src/engine/net/client/msg/ObjectActionMsg.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg; diff --git a/src/engine/net/client/msg/TargetedActionMsg.java b/src/engine/net/client/msg/TargetedActionMsg.java index 7016e4e2..c60d7056 100644 --- a/src/engine/net/client/msg/TargetedActionMsg.java +++ b/src/engine/net/client/msg/TargetedActionMsg.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg; diff --git a/src/engine/net/client/msg/UpdateStateMsg.java b/src/engine/net/client/msg/UpdateStateMsg.java index eaa7e9ed..7ac64a2c 100644 --- a/src/engine/net/client/msg/UpdateStateMsg.java +++ b/src/engine/net/client/msg/UpdateStateMsg.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg; import engine.Enum.GameObjectType; diff --git a/src/engine/net/client/msg/WorldRealmMsg.java b/src/engine/net/client/msg/WorldRealmMsg.java index 82ca2cf4..fde56eb5 100644 --- a/src/engine/net/client/msg/WorldRealmMsg.java +++ b/src/engine/net/client/msg/WorldRealmMsg.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg; import engine.net.AbstractConnection; diff --git a/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java b/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java index 53b0ed87..4ff7c8f8 100644 --- a/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java +++ b/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java @@ -16,24 +16,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg.guild; import engine.Enum.GameObjectType; diff --git a/src/engine/net/client/msg/guild/ChangeRankMsg.java b/src/engine/net/client/msg/guild/ChangeRankMsg.java index 5a9885f2..e6be2350 100644 --- a/src/engine/net/client/msg/guild/ChangeRankMsg.java +++ b/src/engine/net/client/msg/guild/ChangeRankMsg.java @@ -16,24 +16,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg.guild; import engine.Enum.GameObjectType; diff --git a/src/engine/net/client/msg/guild/GuildInfoMsg.java b/src/engine/net/client/msg/guild/GuildInfoMsg.java index c99bd893..aea3c464 100644 --- a/src/engine/net/client/msg/guild/GuildInfoMsg.java +++ b/src/engine/net/client/msg/guild/GuildInfoMsg.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg.guild; diff --git a/src/engine/net/client/msg/login/CommitNewCharacterMsg.java b/src/engine/net/client/msg/login/CommitNewCharacterMsg.java index 968829d7..673656cf 100644 --- a/src/engine/net/client/msg/login/CommitNewCharacterMsg.java +++ b/src/engine/net/client/msg/login/CommitNewCharacterMsg.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.net.client.msg.login; diff --git a/src/engine/objects/Corpse.java b/src/engine/objects/Corpse.java index 9958a72b..fa7970ad 100644 --- a/src/engine/objects/Corpse.java +++ b/src/engine/objects/Corpse.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.objects; import engine.Enum.GameObjectType; diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 300c7850..154e286a 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.objects; import engine.Enum; diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 0b767663..17c5a00c 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.objects; import engine.Enum.DamageType; diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index b0dc6653..7a2a4b56 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.objects; import engine.Enum; diff --git a/src/engine/powers/EffectsBase.java b/src/engine/powers/EffectsBase.java index 511adf7c..a1e7b9e6 100644 --- a/src/engine/powers/EffectsBase.java +++ b/src/engine/powers/EffectsBase.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.powers; import engine.Enum; diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index c0db91c0..d70b9a2c 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.powers.effectmodifiers; import engine.Enum; diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index 81de332f..59145f16 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.powers.effectmodifiers; import engine.Enum; diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index 9dc09960..d96d3a54 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -7,15 +7,6 @@ // www.magicbane.com -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.powers.poweractions; import engine.Enum.GameObjectType; import engine.Enum.ModType; From dea9d93e5b44989e0251bee9773a104caa1c394b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 2 Aug 2023 09:10:51 -0400 Subject: [PATCH 15/16] Class formatting cleanup. --- src/engine/mobileAI/MobAI.java | 1680 ++++++++++++++++++-------------- 1 file changed, 970 insertions(+), 710 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 689e8a38..07e815aa 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -5,17 +5,18 @@ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com + package engine.mobileAI; import engine.Enum; import engine.Enum.DispatchChannel; import engine.InterestManagement.WorldGrid; -import engine.mobileAI.Threads.MobAIThread; -import engine.mobileAI.utilities.CombatUtilities; -import engine.mobileAI.utilities.MovementUtilities; import engine.gameManager.*; import engine.math.Vector3f; import engine.math.Vector3fImmutable; +import engine.mobileAI.Threads.MobAIThread; +import engine.mobileAI.utilities.CombatUtilities; +import engine.mobileAI.utilities.MovementUtilities; import engine.net.DispatchMessage; import engine.net.client.msg.PerformActionMsg; import engine.net.client.msg.PowerProjectileMsg; @@ -38,21 +39,26 @@ public class MobAI { private static void AttackTarget(Mob mob, AbstractWorldObject target) { + try { + if (mob == null) return; + if (target == null || !target.isAlive()) { mob.setCombatTarget(null); return; } - if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) { + + if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) if (MobCast(mob)) { mob.updateLocation(); return; } - } + if (!CombatUtilities.inRangeToAttack(mob, target)) return; + switch (target.getObjectType()) { case PlayerCharacter: PlayerCharacter targetPlayer = (PlayerCharacter) target; @@ -67,939 +73,1193 @@ public class MobAI { AttackMob(mob, targetMob); break; } + mob.updateLocation(); - } catch(Exception e){ + + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); } } public static void AttackPlayer(Mob mob, PlayerCharacter target) { - try{ - if (!mob.canSee(target)) { - mob.setCombatTarget(null); - return; - } - if (mob.BehaviourType.callsForHelp) - MobCallForHelp(mob); - if (!MovementUtilities.inRangeDropAggro(mob, target)) { - mob.setCombatTarget(null); - return; - } - if (CombatUtilities.inRange2D(mob, target, mob.getRange())) { - //no weapons, default mob attack speed 3 seconds. - if (System.currentTimeMillis() < mob.getLastAttackTime()) + + try { + + if (!mob.canSee(target)) { + mob.setCombatTarget(null); + return; + } + + if (mob.BehaviourType.callsForHelp) + MobCallForHelp(mob); + + if (!MovementUtilities.inRangeDropAggro(mob, target)) { + mob.setCombatTarget(null); return; - // ranged mobs cant attack while running. skip until they finally stop. - if (mob.isMoving() && mob.getRange() > 20) + } + + if (CombatUtilities.inRange2D(mob, target, mob.getRange())) { + + //no weapons, default mob attack speed 3 seconds. + + if (System.currentTimeMillis() < mob.getLastAttackTime()) + return; + + // ranged mobs cant attack while running. skip until they finally stop. + + if (mob.isMoving() && mob.getRange() > 20) + return; + + // add timer for last attack. + + ItemBase mainHand = mob.getWeaponItemBase(true); + ItemBase offHand = mob.getWeaponItemBase(false); + + if (mainHand == null && offHand == null) { + CombatUtilities.combatCycle(mob, target, true, null); + int delay = 3000; + if (mob.isSiege()) + delay = 11000; + mob.setLastAttackTime(System.currentTimeMillis() + delay); + } else if (mob.getWeaponItemBase(true) != null) { + int delay = 3000; + if (mob.isSiege()) + delay = 11000; + CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); + mob.setLastAttackTime(System.currentTimeMillis() + delay); + } else if (mob.getWeaponItemBase(false) != null) { + int attackDelay = 3000; + if (mob.isSiege()) + attackDelay = 11000; + CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); + mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); + } + } + + if (target.getPet() != null) + if (target.getPet().getCombatTarget() == null && target.getPet().assist() == true) + target.getPet().setCombatTarget(mob); + + } catch (Exception e) { + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage()); + } + + } + + public static void AttackBuilding(Mob mob, Building target) { + + try { + + if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { + mob.setCombatTarget(null); return; - // add timer for last attack. + } + + City playercity = ZoneManager.getCityAtLocation(mob.getLoc()); + + if (playercity != null) + for (Mob guard : playercity.getParent().zoneMobSet) + if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) + if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild())) + guard.setCombatTarget(mob); + + if (mob.isSiege()) + MovementManager.sendRWSSMsg(mob); + ItemBase mainHand = mob.getWeaponItemBase(true); ItemBase offHand = mob.getWeaponItemBase(false); + if (mainHand == null && offHand == null) { CombatUtilities.combatCycle(mob, target, true, null); int delay = 3000; if (mob.isSiege()) - delay = 11000; + delay = 15000; mob.setLastAttackTime(System.currentTimeMillis() + delay); } else if (mob.getWeaponItemBase(true) != null) { - int delay = 3000; + int attackDelay = 3000; if (mob.isSiege()) - delay = 11000; + attackDelay = 15000; CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); - mob.setLastAttackTime(System.currentTimeMillis() + delay); + mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } else if (mob.getWeaponItemBase(false) != null) { int attackDelay = 3000; if (mob.isSiege()) - attackDelay = 11000; + attackDelay = 15000; CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } - } - if(target.getPet() != null){ - if(target.getPet().getCombatTarget() == null && target.getPet().assist() == true){ - target.getPet().setCombatTarget(mob); + + if (mob.isSiege()) { + PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target); + ppm.setRange(50); + DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); } - } - } catch(Exception e){ - Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage()); - } - } - public static void AttackBuilding(Mob mob, Building target) { - try{ - if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { - mob.setCombatTarget(null); - return; - } - City playercity = ZoneManager.getCityAtLocation(mob.getLoc()); - if (playercity != null) - for (Mob guard : playercity.getParent().zoneMobSet) - if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) - if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild())) - guard.setCombatTarget(mob); - if (mob.isSiege()) - MovementManager.sendRWSSMsg(mob); - ItemBase mainHand = mob.getWeaponItemBase(true); - ItemBase offHand = mob.getWeaponItemBase(false); - if (mainHand == null && offHand == null) { - CombatUtilities.combatCycle(mob, target, true, null); - int delay = 3000; - if (mob.isSiege()) - delay = 15000; - mob.setLastAttackTime(System.currentTimeMillis() + delay); - } else if (mob.getWeaponItemBase(true) != null) { - int attackDelay = 3000; - if (mob.isSiege()) - attackDelay = 15000; - CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); - mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); - } else if (mob.getWeaponItemBase(false) != null) { - int attackDelay = 3000; - if (mob.isSiege()) - attackDelay = 15000; - CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); - mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); - } - if (mob.isSiege()) { - PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target); - ppm.setRange(50); - DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); } } public static void AttackMob(Mob mob, Mob target) { - try{ - if (mob.getRange() >= 30 && mob.isMoving()) - return; - //no weapons, default mob attack speed 3 seconds. - ItemBase mainHand = mob.getWeaponItemBase(true); - ItemBase offHand = mob.getWeaponItemBase(false); - if (mainHand == null && offHand == null) { - CombatUtilities.combatCycle(mob, target, true, null); - int delay = 3000; - if (mob.isSiege()) - delay = 11000; - mob.setLastAttackTime(System.currentTimeMillis() + delay); - } else if (mob.getWeaponItemBase(true) != null) { - int attackDelay = 3000; - if (mob.isSiege()) - attackDelay = 11000; - CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); - mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); - } else if (mob.getWeaponItemBase(false) != null) { - int attackDelay = 3000; - if (mob.isSiege()) - attackDelay = 11000; - CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); - mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); - if(target.combatTarget == null){ - target.combatTarget = mob; + + try { + + if (mob.getRange() >= 30 && mob.isMoving()) + return; + + //no weapons, default mob attack speed 3 seconds. + + ItemBase mainHand = mob.getWeaponItemBase(true); + ItemBase offHand = mob.getWeaponItemBase(false); + + if (mainHand == null && offHand == null) { + CombatUtilities.combatCycle(mob, target, true, null); + int delay = 3000; + if (mob.isSiege()) + delay = 11000; + mob.setLastAttackTime(System.currentTimeMillis() + delay); + } else if (mob.getWeaponItemBase(true) != null) { + int attackDelay = 3000; + if (mob.isSiege()) + attackDelay = 11000; + CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); + mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); + } else if (mob.getWeaponItemBase(false) != null) { + int attackDelay = 3000; + if (mob.isSiege()) + attackDelay = 11000; + CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); + mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); + if (target.combatTarget == null) { + target.combatTarget = mob; + } } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage()); } } private static void Patrol(Mob mob) { - try{ - //make sure mob is out of combat stance - if (mob.isCombat() && mob.getCombatTarget() == null) { - mob.setCombat(false); - UpdateStateMsg rwss = new UpdateStateMsg(); - rwss.setPlayer(mob); - DispatchMessage.sendToAllInRange(mob, rwss); - } - int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR; - if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis()) + + try { + + //make sure mob is out of combat stance + + if (mob.isCombat() && mob.getCombatTarget() == null) { + mob.setCombat(false); + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(mob); + DispatchMessage.sendToAllInRange(mob, rwss); + } + + int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR; + //early exit while waiting to patrol again - return; - //guard captains inherit barracks patrol points dynamically - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { - Building barracks = mob.building; - if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) { - mob.patrolPoints = barracks.patrolPoints; - } else { - randomGuardPatrolPoint(mob); + + if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis()) return; + + //guard captains inherit barracks patrol points dynamically + + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + Building barracks = mob.building; + if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) { + mob.patrolPoints = barracks.patrolPoints; + } else { + randomGuardPatrolPoint(mob); + return; + } } - } - if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1) { - mob.lastPatrolPointIndex = 0; - } - mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); - mob.lastPatrolPointIndex += 1; - MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { - for (Entry minion : mob.siegeMinionMap.entrySet()) { - //make sure mob is out of combat stance - if (minion.getKey().despawned == false) { - if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) { - minion.getKey().setCombat(false); - UpdateStateMsg rwss = new UpdateStateMsg(); - rwss.setPlayer(minion.getKey()); - DispatchMessage.sendToAllInRange(minion.getKey(), rwss); - } - if (MovementUtilities.canMove(minion.getKey())) { - Vector3f minionOffset = Formation.getOffset(2, minion.getValue() + 3); - minion.getKey().updateLocation(); - Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z); - MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true); + + if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1) + mob.lastPatrolPointIndex = 0; + + mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); + mob.lastPatrolPointIndex += 1; + + MovementUtilities.aiMove(mob, mob.destination, true); + + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + for (Entry minion : mob.siegeMinionMap.entrySet()) { + + //make sure mob is out of combat stance + + if (minion.getKey().despawned == false) { + if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) { + minion.getKey().setCombat(false); + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(minion.getKey()); + DispatchMessage.sendToAllInRange(minion.getKey(), rwss); + } + + if (MovementUtilities.canMove(minion.getKey())) { + Vector3f minionOffset = Formation.getOffset(2, minion.getValue() + 3); + minion.getKey().updateLocation(); + Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z); + MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true); + } } } } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); } } public static boolean canCast(Mob mob) { - try{ - // Performs validation to determine if a - // mobile in the proper state to cast. - if (mob == null) - return false; - if (mob.mobPowers.isEmpty()) - return false; - if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) { - mob.setCombatTarget(null); - return false; - } - int castRoll = ThreadLocalRandom.current().nextInt(101); - if(castRoll <= MobAIThread.AI_POWER_DIVISOR){ - return false; - } - if (mob.nextCastTime == 0) - mob.nextCastTime = System.currentTimeMillis(); - return mob.nextCastTime <= System.currentTimeMillis(); - } catch(Exception e){ + try { + + // Performs validation to determine if a + // mobile in the proper state to cast. + + if (mob == null) + return false; + + if (mob.mobPowers.isEmpty()) + return false; + + if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) { + mob.setCombatTarget(null); + return false; + } + + int castRoll = ThreadLocalRandom.current().nextInt(101); + + if (castRoll <= MobAIThread.AI_POWER_DIVISOR) + return false; + + if (mob.nextCastTime == 0) + mob.nextCastTime = System.currentTimeMillis(); + + return mob.nextCastTime <= System.currentTimeMillis(); + + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast" + " " + e.getMessage()); } return false; } public static boolean MobCast(Mob mob) { - try{ - // Method picks a random spell from a mobile's list of powers - // and casts it on the current target (or itself). Validation - // (including empty lists) is done previously within canCast(); - - ArrayList powerTokens; - ArrayList purgeTokens; - PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget(); - if (mob.BehaviourType.callsForHelp) - MobCallForHelp(mob); - // Generate a list of tokens from the mob powers for this mobile. - powerTokens = new ArrayList<>(mob.mobPowers.keySet()); - purgeTokens = new ArrayList<>(); - // If player has this effect on them currently then remove - // this token from our list. - for (int powerToken : powerTokens) { - PowersBase powerBase = PowersManager.getPowerByToken(powerToken); - for (ActionsBase actionBase : powerBase.getActions()) { - String stackType = actionBase.stackType; - if (target.getEffects() != null && target.getEffects().containsKey(stackType)) - purgeTokens.add(powerToken); - } - } - powerTokens.removeAll(purgeTokens); - // Sanity check - if (powerTokens.isEmpty()) - return false; - // Pick random spell from our list of powers - int powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size())); - int powerRank = mob.mobPowers.get(powerToken); - PowersBase mobPower = PowersManager.getPowerByToken(powerToken); - //check for hit-roll - if (mobPower.requiresHitRoll) { - if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget())) { - return false; - } - if (CombatUtilities.triggerDodge(mob, mob.getCombatTarget())) { - return false; + + try { + // Method picks a random spell from a mobile's list of powers + // and casts it on the current target (or itself). Validation + // (including empty lists) is done previously within canCast(); + + ArrayList powerTokens; + ArrayList purgeTokens; + PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget(); + + if (mob.BehaviourType.callsForHelp) + MobCallForHelp(mob); + + // Generate a list of tokens from the mob powers for this mobile. + + powerTokens = new ArrayList<>(mob.mobPowers.keySet()); + purgeTokens = new ArrayList<>(); + + // If player has this effect on them currently then remove + // this token from our list. + + for (int powerToken : powerTokens) { + + PowersBase powerBase = PowersManager.getPowerByToken(powerToken); + + for (ActionsBase actionBase : powerBase.getActions()) { + + String stackType = actionBase.stackType; + + if (target.getEffects() != null && target.getEffects().containsKey(stackType)) + purgeTokens.add(powerToken); + } } - if (CombatUtilities.triggerBlock(mob, mob.getCombatTarget())) { + + powerTokens.removeAll(purgeTokens); + + // Sanity check + + if (powerTokens.isEmpty()) return false; + + // Pick random spell from our list of powers + + int powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size())); + int powerRank = mob.mobPowers.get(powerToken); + + PowersBase mobPower = PowersManager.getPowerByToken(powerToken); + + //check for hit-roll + + if (mobPower.requiresHitRoll) { + + if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget())) + return false; + + if (CombatUtilities.triggerDodge(mob, mob.getCombatTarget())) + return false; + + if (CombatUtilities.triggerBlock(mob, mob.getCombatTarget())) + return false; + + if (CombatUtilities.triggerParry(mob, mob.getCombatTarget())) + return false; } - if (CombatUtilities.triggerParry(mob, mob.getCombatTarget())) { - return false; + + // Cast the spell + + if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) { + + PowersManager.useMobPower(mob, (AbstractCharacter) mob.getCombatTarget(), mobPower, powerRank); + PerformActionMsg msg; + + if (!mobPower.isHarmful() || mobPower.targetSelf) + msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob); + else + msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target); + + msg.setUnknown04(2); + + PowersManager.finishUseMobPower(msg, mob, 0, 0); + + // Default minimum seconds between cast = 10 + + float randomCooldown = (ThreadLocalRandom.current().nextInt(150) + 100) * 0.01f; + mob.nextCastTime = System.currentTimeMillis() + (long) ((mobPower.getCooldown() + (MobAIThread.AI_POWER_DIVISOR * 1000)) * randomCooldown); + return true; } - } - // Cast the spell - if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) { - PowersManager.useMobPower(mob, (AbstractCharacter) mob.getCombatTarget(), mobPower, powerRank); - PerformActionMsg msg; - if (!mobPower.isHarmful() || mobPower.targetSelf) - msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob); - else - msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target); - msg.setUnknown04(2); - PowersManager.finishUseMobPower(msg, mob, 0, 0); - // Default minimum seconds between cast = 10 - float randomCooldown = (ThreadLocalRandom.current().nextInt(150) + 100) * 0.01f; - mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobAIThread.AI_POWER_DIVISOR * 1000)) * randomCooldown); - return true; - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage()); } return false; } public static void MobCallForHelp(Mob mob) { - try{ - boolean callGotResponse = false; - if (mob.nextCallForHelp == 0) { - mob.nextCallForHelp = System.currentTimeMillis(); - } - if (mob.nextCallForHelp < System.currentTimeMillis()) - return; - //mob sends call for help message - ChatManager.chatSayInfo(null, mob.getName() + " calls for help!"); - Zone mobCamp = mob.getParentZone(); - for (Mob helper : mobCamp.zoneMobSet) { - if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) { - helper.setCombatTarget(mob.getCombatTarget()); - callGotResponse = true; + + try { + + boolean callGotResponse = false; + + if (mob.nextCallForHelp == 0) + mob.nextCallForHelp = System.currentTimeMillis(); + + if (mob.nextCallForHelp < System.currentTimeMillis()) + return; + + //mob sends call for help message + + ChatManager.chatSayInfo(null, mob.getName() + " calls for help!"); + + Zone mobCamp = mob.getParentZone(); + + for (Mob helper : mobCamp.zoneMobSet) { + if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) { + helper.setCombatTarget(mob.getCombatTarget()); + callGotResponse = true; + } } - } - if (callGotResponse) + //wait 60 seconds to call for help again - mob.nextCallForHelp = System.currentTimeMillis() + 60000; - } catch(Exception e){ + + if (callGotResponse) + mob.nextCallForHelp = System.currentTimeMillis() + 60000; + + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp" + " " + e.getMessage()); } } public static void DetermineAction(Mob mob) { - try{ - //always check the respawn que, respawn 1 mob max per second to not flood the client - if (mob == null) - return; - if(mob.getTimestamps().containsKey("lastExecution") == false){ - mob.getTimestamps().put("lastExecution",System.currentTimeMillis()); - } - if(System.currentTimeMillis() < mob.getTimeStamp("lastExecution")){ - return; - } - mob.getTimestamps().put("lastExecution",System.currentTimeMillis() + MobAIThread.AI_PULSE_MOB_THRESHOLD); - if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { + try { + + //always check the respawn que, respawn 1 mob max per second to not flood the client + + if (mob == null) + return; + + if (mob.getTimestamps().containsKey("lastExecution") == false) + mob.getTimestamps().put("lastExecution", System.currentTimeMillis()); + + if (System.currentTimeMillis() < mob.getTimeStamp("lastExecution")) + return; + + mob.getTimestamps().put("lastExecution", System.currentTimeMillis() + MobAIThread.AI_PULSE_MOB_THRESHOLD); + //trebuchet spawn handler - CheckForRespawn(mob); - return; - } - if (mob.despawned && mob.isPlayerGuard) { + + if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { + CheckForRespawn(mob); + return; + } + //override for guards - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { - if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { - //minions don't respawn while guard captain is dead - if (mob.isAlive() == false) { - mob.deathTime = System.currentTimeMillis(); - return; + + if (mob.despawned && mob.isPlayerGuard) { + + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { + if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { + + //minions don't respawn while guard captain is dead + + if (mob.isAlive() == false) { + mob.deathTime = System.currentTimeMillis(); + return; + } + } } + + CheckForRespawn(mob); + + //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()) + CheckToSendMobHome(mob); + + return; } - CheckForRespawn(mob); - //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()){ - CheckToSendMobHome(mob); - } - return; - } - if (!mob.isAlive()) { + //no need to continue if mob is dead, check for respawn and move on - CheckForRespawn(mob); - return; - } - if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { + + if (!mob.isAlive()) { + CheckForRespawn(mob); + return; + } + //no players loaded, no need to proceed - mob.setCombatTarget(null); - return; - } - if (mob.isCombat() && mob.getCombatTarget() == null) { - mob.setCombat(false); - UpdateStateMsg rwss = new UpdateStateMsg(); - rwss.setPlayer(mob); - DispatchMessage.sendToAllInRange(mob, rwss); - } - if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { - CheckToSendMobHome(mob); - } - if (mob.combatTarget != null) { - if(mob.getCombatTarget().isAlive() == false){ + + if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { mob.setCombatTarget(null); return; } - if(mob.getCombatTarget().getObjectTypeMask() == MBServerStatics.MASK_PLAYER){ - PlayerCharacter target = (PlayerCharacter)mob.combatTarget; - if(mob.playerAgroMap.containsKey(target.getObjectUUID()) == false){ + + if (mob.isCombat() && mob.getCombatTarget() == null) { + mob.setCombat(false); + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(mob); + DispatchMessage.sendToAllInRange(mob, rwss); + } + + if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) + CheckToSendMobHome(mob); + + if (mob.combatTarget != null) { + if (mob.getCombatTarget().isAlive() == false) { mob.setCombatTarget(null); return; } - if(mob.canSee((PlayerCharacter)mob.getCombatTarget()) == false) { - mob.setCombatTarget(null); - return; + + if (mob.getCombatTarget().getObjectTypeMask() == MBServerStatics.MASK_PLAYER) { + + PlayerCharacter target = (PlayerCharacter) mob.combatTarget; + + if (mob.playerAgroMap.containsKey(target.getObjectUUID()) == false) { + mob.setCombatTarget(null); + return; + } + + if (mob.canSee((PlayerCharacter) mob.getCombatTarget()) == false) { + mob.setCombatTarget(null); + return; + } + } } - } - //if(mob.getTimestamps().containsKey("LOCATIONSYNC") == false){ - // mob.getTimestamps().put("LOCATIONSYNC",System.currentTimeMillis()); - //} - switch (mob.BehaviourType) { - case GuardCaptain: - GuardCaptainLogic(mob); - break; - case GuardMinion: - GuardMinionLogic(mob); - break; - case GuardWallArcher: - GuardWallArcherLogic(mob); - break; - case Pet1: - PetLogic(mob); - break; - case HamletGuard: - HamletGuardLogic(mob); - break; - default: - DefaultLogic(mob); - break; - } - } catch(Exception e){ + + switch (mob.BehaviourType) { + case GuardCaptain: + GuardCaptainLogic(mob); + break; + case GuardMinion: + GuardMinionLogic(mob); + break; + case GuardWallArcher: + GuardWallArcherLogic(mob); + break; + case Pet1: + PetLogic(mob); + break; + case HamletGuard: + HamletGuardLogic(mob); + break; + default: + DefaultLogic(mob); + break; + } + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); } } private static void CheckForAggro(Mob aiAgent) { - try{ - //looks for and sets mobs combatTarget - if (!aiAgent.isAlive()) - return; - ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; - for (Entry playerEntry : loadedPlayers.entrySet()) { - int playerID = (int) playerEntry.getKey(); - PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); - //Player is null, let's remove them from the list. - if (loadedPlayer == null) { - loadedPlayers.remove(playerID); - continue; - } - //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map. - if (!loadedPlayer.isAlive()) { - loadedPlayers.remove(playerID); - continue; - } - //Can't see target, skip aggro. - if (!aiAgent.canSee(loadedPlayer)) - continue; - // No aggro for this race type - if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true) - continue; - //mob has enemies and this player race is not it - if(aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false){ - continue; - } - if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { - aiAgent.setCombatTarget(loadedPlayer); + + try { + + //looks for and sets mobs combatTarget + + if (!aiAgent.isAlive()) return; - } - } - if(aiAgent.combatTarget == null) { - //look for pets to aggro if no players found to aggro - HashSet awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET); - for (AbstractWorldObject awoMob : awoList) { - //dont scan self. - if (aiAgent.equals(awoMob)) + + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; + + for (Entry playerEntry : loadedPlayers.entrySet()) { + + int playerID = (int) playerEntry.getKey(); + PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); + + //Player is null, let's remove them from the list. + + if (loadedPlayer == null) { + loadedPlayers.remove(playerID); continue; - Mob aggroMob = (Mob) awoMob; - aiAgent.setCombatTarget(aggroMob); - return; + } + + //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map. + + if (!loadedPlayer.isAlive()) { + loadedPlayers.remove(playerID); + continue; + } + + //Can't see target, skip aggro. + + if (!aiAgent.canSee(loadedPlayer)) + continue; + + // No aggro for this race type + + if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == true) + continue; + + //mob has enemies and this player race is not it + + if (aiAgent.enemy.size() > 0 && aiAgent.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()) == false) + continue; + + if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { + aiAgent.setCombatTarget(loadedPlayer); + return; + } + } - } - } catch(Exception e){ + + if (aiAgent.combatTarget == null) { + + //look for pets to aggro if no players found to aggro + + HashSet awoList = WorldGrid.getObjectsInRangePartial(aiAgent, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_PET); + + for (AbstractWorldObject awoMob : awoList) { + + //dont scan self. + + if (aiAgent.equals(awoMob)) + continue; + + Mob aggroMob = (Mob) awoMob; + aiAgent.setCombatTarget(aggroMob); + return; + } + } + } catch (Exception e) { Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro" + " " + e.getMessage()); } } private static void CheckMobMovement(Mob mob) { - try{ - if (!MovementUtilities.canMove(mob)) - return; - mob.updateLocation(); - switch (mob.BehaviourType) { - case Pet1: - if(mob.getOwner() == null){ - return; - } - if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { - //mob no longer has its owner loaded, translocate pet to owner - MovementManager.translocate(mob, mob.getOwner().getLoc(), null); - return; - } - if (mob.getCombatTarget() == null) { - //move back to owner - if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6)) + + try { + + if (!MovementUtilities.canMove(mob)) + return; + + mob.updateLocation(); + + switch (mob.BehaviourType) { + + case Pet1: + if (mob.getOwner() == null) return; - mob.destination = mob.getOwner().getLoc(); - MovementUtilities.moveToLocation(mob, mob.destination, 5); - } else - chaseTarget(mob); - break; - case GuardMinion: - if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned) - randomGuardPatrolPoint(mob); - else { - if (mob.getCombatTarget() != null) { + + if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { + + //mob no longer has its owner loaded, translocate pet to owner + + MovementManager.translocate(mob, mob.getOwner().getLoc(), null); + return; + } + if (mob.getCombatTarget() == null) { + + //move back to owner + + if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6)) + return; + + mob.destination = mob.getOwner().getLoc(); + MovementUtilities.moveToLocation(mob, mob.destination, 5); + } else chaseTarget(mob); + break; + case GuardMinion: + if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned) + randomGuardPatrolPoint(mob); + else { + if (mob.getCombatTarget() != null) { + chaseTarget(mob); + } } - } - break; - default: - if (mob.getCombatTarget() == null) { - if (!mob.isMoving()) { - Patrol(mob); + break; + default: + if (mob.getCombatTarget() == null) { + if (!mob.isMoving()) + Patrol(mob); + else { + mob.stopPatrolTime = System.currentTimeMillis(); + } } else { - mob.stopPatrolTime = System.currentTimeMillis(); + chaseTarget(mob); } - } else { - chaseTarget(mob); - } - break; - } - } catch(Exception e){ + break; + } + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); } } private static void CheckForRespawn(Mob aiAgent) { - try{ - if (aiAgent.deathTime == 0) { - aiAgent.setDeathTime(System.currentTimeMillis()); - return; - } - //handles checking for respawn of dead mobs even when no players have mob loaded - //Despawn Timer with Loot currently in inventory. - if (!aiAgent.despawned) { - if (aiAgent.getCharItemManager().getInventoryCount() > 0) { - if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { - aiAgent.despawn(); - aiAgent.deathTime = System.currentTimeMillis(); - return; - } - //No items in inventory. - } else { - //Mob's Loot has been looted. - if (aiAgent.isHasLoot()) { - if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { + + try { + + if (aiAgent.deathTime == 0) { + aiAgent.setDeathTime(System.currentTimeMillis()); + return; + } + + //handles checking for respawn of dead mobs even when no players have mob loaded + //Despawn Timer with Loot currently in inventory. + + if (!aiAgent.despawned) { + + if (aiAgent.getCharItemManager().getInventoryCount() > 0) { + if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { aiAgent.despawn(); aiAgent.deathTime = System.currentTimeMillis(); return; } - //Mob never had Loot. + //No items in inventory. } else { - if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) { - aiAgent.despawn(); - aiAgent.deathTime = System.currentTimeMillis(); - return; + //Mob's Loot has been looted. + if (aiAgent.isHasLoot()) { + if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { + aiAgent.despawn(); + aiAgent.deathTime = System.currentTimeMillis(); + return; + } + //Mob never had Loot. + } else { + if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) { + aiAgent.despawn(); + aiAgent.deathTime = System.currentTimeMillis(); + return; + } } } + } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { + //aiAgent.respawn(); + if (Zone.respawnQue.contains(aiAgent) == false) { + Zone.respawnQue.add(aiAgent); + } } - } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { - //aiAgent.respawn(); - if(aiAgent.getParentZone().respawnQue.contains(aiAgent) == false) { - aiAgent.getParentZone().respawnQue.add(aiAgent); - } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); } } public static void CheckForAttack(Mob mob) { - try{ - //checks if mob can attack based on attack timer and range - if (mob.isAlive() == false) - return; - 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()) { - mob.setCombatTarget(null); - if (mob.isCombat()) { - mob.setCombat(false); + try { + + //checks if mob can attack based on attack timer and range + + if (mob.isAlive() == false) + return; + + 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()) { + + mob.setCombatTarget(null); + + if (mob.isCombat()) { + mob.setCombat(false); + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(mob); + DispatchMessage.sendToAllInRange(mob, rwss); + } + return; + } + + if (!mob.isCombat()) { + mob.setCombat(true); UpdateStateMsg rwss = new UpdateStateMsg(); rwss.setPlayer(mob); DispatchMessage.sendToAllInRange(mob, rwss); } - return; - } - if (!mob.isCombat()) { - mob.setCombat(true); - UpdateStateMsg rwss = new UpdateStateMsg(); - rwss.setPlayer(mob); - DispatchMessage.sendToAllInRange(mob, rwss); - } - if (System.currentTimeMillis() > mob.getLastAttackTime()) - AttackTarget(mob, mob.getCombatTarget()); - } catch(Exception e){ + + if (System.currentTimeMillis() > mob.getLastAttackTime()) + AttackTarget(mob, mob.getCombatTarget()); + + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage()); } } private static void CheckToSendMobHome(Mob mob) { - try{ - if (mob.BehaviourType.isAgressive) { - if (mob.isPlayerGuard()) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { - CheckForPlayerGuardAggro(mob); + + try { + if (mob.BehaviourType.isAgressive) { + + if (mob.isPlayerGuard()) { + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) + CheckForPlayerGuardAggro(mob); + } else { + CheckForAggro(mob); } - } else { - CheckForAggro(mob); } - } - if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f)) { - return; - } - if (mob.isPlayerGuard() && !mob.despawned) { - City current = ZoneManager.getCityAtLocation(mob.getLoc()); - if (current == null || current.equals(mob.getGuild().getOwnedCity()) == false) { + + if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f)) + return; + + if (mob.isPlayerGuard() && !mob.despawned) { + + City current = ZoneManager.getCityAtLocation(mob.getLoc()); + + if (current == null || current.equals(mob.getGuild().getOwnedCity()) == false) { + + PowersBase recall = PowersManager.getPowerByToken(-1994153779); + PowersManager.useMobPower(mob, mob, recall, 40); + mob.setCombatTarget(null); + + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) { + + //guard captain pulls his minions home with him + + for (Entry minion : mob.siegeMinionMap.entrySet()) { + PowersManager.useMobPower(minion.getKey(), minion.getKey(), recall, 40); + minion.getKey().setCombatTarget(null); + } + } + } + } else if (MovementUtilities.inRangeOfBindLocation(mob) == false) { + PowersBase recall = PowersManager.getPowerByToken(-1994153779); PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) { - //guard captain pulls his minions home with him - for (Entry minion : mob.siegeMinionMap.entrySet()) { - PowersManager.useMobPower(minion.getKey(), minion.getKey(), recall, 40); - minion.getKey().setCombatTarget(null); - } - } - } - } else if (MovementUtilities.inRangeOfBindLocation(mob) == false) { - PowersBase recall = PowersManager.getPowerByToken(-1994153779); - PowersManager.useMobPower(mob, mob, recall, 40); - mob.setCombatTarget(null); - for (Entry playerEntry : mob.playerAgroMap.entrySet()) { - PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); + for (Entry playerEntry : mob.playerAgroMap.entrySet()) + PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); } } private static void chaseTarget(Mob mob) { - try{ - mob.updateMovementState(); - mob.updateLocation(); - if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { - if (mob.getRange() > 15) { - mob.destination = mob.getCombatTarget().getLoc(); - MovementUtilities.moveToLocation(mob, mob.destination, 0); - } else { - //check if building - switch (mob.getCombatTarget().getObjectType()) { - case PlayerCharacter: - case Mob: - mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); - MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange() + 1); - break; - case Building: - mob.destination = mob.getCombatTarget().getLoc(); - MovementUtilities.moveToLocation(mob,mob.getCombatTarget().getLoc(),0); - break; - } - if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == true){ - mob.stopMovement(mob.getLoc()); + + try { + + mob.updateMovementState(); + mob.updateLocation(); + + if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { + if (mob.getRange() > 15) { + mob.destination = mob.getCombatTarget().getLoc(); + MovementUtilities.moveToLocation(mob, mob.destination, 0); + } else { + + //check if building + + switch (mob.getCombatTarget().getObjectType()) { + case PlayerCharacter: + case Mob: + mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); + MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange() + 1); + break; + case Building: + mob.destination = mob.getCombatTarget().getLoc(); + MovementUtilities.moveToLocation(mob, mob.getCombatTarget().getLoc(), 0); + break; + } + if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == true) { + mob.stopMovement(mob.getLoc()); + } } } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage()); } } private static void SafeGuardAggro(Mob mob) { - try{ - HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); - for (AbstractWorldObject awoMob : awoList) { - //dont scan self. - if (mob.equals(awoMob) || mob.isGuard() == true) - continue; - Mob aggroMob = (Mob) awoMob; - //dont attack other guards - if (aggroMob.isGuard()) - continue; - if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) - continue; - mob.setCombatTarget(aggroMob); - } - } catch(Exception e){ + try { + + HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); + + for (AbstractWorldObject awoMob : awoList) { + + //dont scan self. + + if (mob.equals(awoMob) || mob.isGuard() == true) + continue; + + Mob aggroMob = (Mob) awoMob; + + //dont attack other guards + + if (aggroMob.isGuard()) + continue; + + if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) + continue; + + mob.setCombatTarget(aggroMob); + } + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro" + " " + e.getMessage()); } } public static void GuardCaptainLogic(Mob mob) { - try{ - if (mob.getCombatTarget() == null) - CheckForPlayerGuardAggro(mob); - CheckMobMovement(mob); - CheckForAttack(mob); - } catch(Exception e){ + + try { + if (mob.getCombatTarget() == null) + CheckForPlayerGuardAggro(mob); + + CheckMobMovement(mob); + CheckForAttack(mob); + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage()); } } public static void GuardMinionLogic(Mob mob) { - try{ - if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { - CheckForPlayerGuardAggro(mob); - } - if (mob.npcOwner.getCombatTarget() != null) - mob.setCombatTarget(mob.npcOwner.getCombatTarget()); - else - mob.setCombatTarget(null); - CheckMobMovement(mob); - CheckForAttack(mob); - } catch(Exception e){ + + try { + if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) + CheckForPlayerGuardAggro(mob); + + if (mob.npcOwner.getCombatTarget() != null) + mob.setCombatTarget(mob.npcOwner.getCombatTarget()); + else + mob.setCombatTarget(null); + + CheckMobMovement(mob); + CheckForAttack(mob); + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage()); } } public static void GuardWallArcherLogic(Mob mob) { - try{ - if (mob.getCombatTarget() == null) - CheckForPlayerGuardAggro(mob); - else - CheckForAttack(mob); - } catch(Exception e){ + + try { + if (mob.getCombatTarget() == null) + CheckForPlayerGuardAggro(mob); + else + CheckForAttack(mob); + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardWallArcherLogic" + " " + e.getMessage()); } } private static void PetLogic(Mob mob) { - try{ - if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){ - if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){ - mob.killCharacter("no owner"); + + try { + if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false) { + if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) + mob.killCharacter("no owner"); } - } - if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) - CheckMobMovement(mob); - CheckForAttack(mob); - //recover health - if(mob.getTimestamps().containsKey("HEALTHRECOVERED") == false){ - mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); - } - if(mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000){ - if(mob.getHealth() < mob.getHealthMax()) { - float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None))* 0.01f); - mob.setHealth(mob.getHealth() + recoveredHealth); - mob.getTimestamps().put("HEALTHRECOVERED",System.currentTimeMillis()); - if(mob.getHealth() > mob.getHealthMax()){ - mob.setHealth(mob.getHealthMax()); + + if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) + CheckMobMovement(mob); + + CheckForAttack(mob); + + //recover health + + if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false) + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + + if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000) { + if (mob.getHealth() < mob.getHealthMax()) { + float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f); + mob.setHealth(mob.getHealth() + recoveredHealth); + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + + if (mob.getHealth() > mob.getHealthMax()) { + mob.setHealth(mob.getHealthMax()); + } } } - }} catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); } } private static void HamletGuardLogic(Mob mob) { - try{ - if (mob.getCombatTarget() == null) { + + try { //safehold guard - SafeGuardAggro(mob); - } else { - if (mob.combatTarget.isAlive() == false) { + + if (mob.getCombatTarget() == null) SafeGuardAggro(mob); - } - } - CheckForAttack(mob); - } catch(Exception e){ + else if (mob.combatTarget.isAlive() == false) + SafeGuardAggro(mob); + + CheckForAttack(mob); + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage()); } } private static void DefaultLogic(Mob mob) { - try{ - //check for players that can be aggroed if mob is agressive and has no target - if(mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ - mob.setCombatTarget(null); - } - if (mob.BehaviourType.isAgressive) { - AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); - if (newTarget != null) { - mob.setCombatTarget(newTarget); - } else { - if (mob.getCombatTarget() == null) { - if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) - //safehold guard - SafeGuardAggro(mob); - else - //normal aggro - CheckForAggro(mob); + + try { + + //check for players that can be aggroed if mob is agressive and has no target + + if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) + mob.setCombatTarget(null); + + if (mob.BehaviourType.isAgressive) { + + AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); + + if (newTarget != null) + mob.setCombatTarget(newTarget); + else { + if (mob.getCombatTarget() == null) { + if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) + //safehold guard + SafeGuardAggro(mob); + else + //normal aggro + CheckForAggro(mob); + } } } - } - //check if mob can move for patrol or moving to target - if (mob.BehaviourType.canRoam) - CheckMobMovement(mob); - //check if mob can attack if it isn't wimpy - if (!mob.BehaviourType.isWimpy && mob.combatTarget != null) - CheckForAttack(mob); - } catch(Exception e){ + + //check if mob can move for patrol or moving to target + + if (mob.BehaviourType.canRoam) + CheckMobMovement(mob); + + //check if mob can attack if it isn't wimpy + + if (!mob.BehaviourType.isWimpy && mob.combatTarget != null) + CheckForAttack(mob); + + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage()); } } public static void CheckForPlayerGuardAggro(Mob mob) { - try{ - //looks for and sets mobs combatTarget - if (!mob.isAlive()) - return; - ConcurrentHashMap loadedPlayers = mob.playerAgroMap; - for (Entry playerEntry : loadedPlayers.entrySet()) { - int playerID = (int) playerEntry.getKey(); - PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); - //Player is null, let's remove them from the list. - if (loadedPlayer == null) { - loadedPlayers.remove(playerID); - continue; - } - //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map. - if (!loadedPlayer.isAlive()) { - loadedPlayers.remove(playerID); - continue; - } - //Can't see target, skip aggro. - if (!mob.canSee(loadedPlayer)) - continue; - // No aggro for this player - if (GuardCanAggro(mob, loadedPlayer) == false) - continue; - if (MovementUtilities.inRangeToAggro(mob, loadedPlayer)) { - mob.setCombatTarget(loadedPlayer); + + try { + + //looks for and sets mobs combatTarget + + if (!mob.isAlive()) return; + + ConcurrentHashMap loadedPlayers = mob.playerAgroMap; + + for (Entry playerEntry : loadedPlayers.entrySet()) { + + int playerID = (int) playerEntry.getKey(); + PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); + + //Player is null, let's remove them from the list. + + if (loadedPlayer == null) { + loadedPlayers.remove(playerID); + continue; + } + + //Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map. + + if (!loadedPlayer.isAlive()) { + loadedPlayers.remove(playerID); + continue; + } + + //Can't see target, skip aggro. + + if (!mob.canSee(loadedPlayer)) + continue; + + // No aggro for this player + + if (GuardCanAggro(mob, loadedPlayer) == false) + continue; + + if (MovementUtilities.inRangeToAggro(mob, loadedPlayer)) { + mob.setCombatTarget(loadedPlayer); + return; + } } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro" + e.getMessage()); } } public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) { - try{ - if (mob.getGuild().getNation().equals(target.getGuild().getNation())) - return false; - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { - if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { + + try { + + if (mob.getGuild().getNation().equals(target.getGuild().getNation())) + return false; + + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { + if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { + return true; + } + } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { return true; } - } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { - return true; - } - //first check condemn list for aggro allowed (allies button is checked) - if (ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().reverseKOS) { - for (Entry entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { - if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) + + //first check condemn list for aggro allowed (allies button is checked) + + if (ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().reverseKOS) { + for (Entry entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { + //target is listed individually - return false; - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild()) + + if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) + return false; + //target's guild is listed - return false; - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation()) + + if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild()) + return false; + //target's nation is listed - return false; - } - return true; - } else { - //allies button is not checked - for (Entry entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { - if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) + + if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation()) + return false; + } + return true; + } else { + + //allies button is not checked + + for (Entry entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { + //target is listed individually - return true; - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild()) + + if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) + return true; + //target's guild is listed - return true; - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation()) + + if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild()) + return true; + //target's nation is listed - return true; + + if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation()) + return true; + } } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro" + " " + e.getMessage()); } return false; } public static void randomGuardPatrolPoint(Mob mob) { - try{ - if (mob.isMoving() == true) { + + try { + //early exit for a mob who is already moving to a patrol point //while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin - mob.stopPatrolTime = System.currentTimeMillis(); - return; - } - //wait between 10 and 15 seconds after reaching patrol point before moving - int patrolDelay = ThreadLocalRandom.current().nextInt(10000) + 5000; - if (mob.stopPatrolTime + patrolDelay > System.currentTimeMillis()) + + if (mob.isMoving() == true) { + mob.stopPatrolTime = System.currentTimeMillis(); + return; + } + + //wait between 10 and 15 seconds after reaching patrol point before moving + + int patrolDelay = ThreadLocalRandom.current().nextInt(10000) + 5000; + //early exit while waiting to patrol again - return; - float xPoint = ThreadLocalRandom.current().nextInt(400) - 200; - float zPoint = ThreadLocalRandom.current().nextInt(400) - 200; - Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc(); - mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint); - MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { - for (Entry minion : mob.siegeMinionMap.entrySet()) { - //make sure mob is out of combat stance - if (minion.getKey().despawned == false) { - if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) { - minion.getKey().setCombat(false); - UpdateStateMsg rwss = new UpdateStateMsg(); - rwss.setPlayer(minion.getKey()); - DispatchMessage.sendToAllInRange(minion.getKey(), rwss); - } - if (MovementUtilities.canMove(minion.getKey())) { - Vector3f minionOffset = Formation.getOffset(2, minion.getValue() + 3); - minion.getKey().updateLocation(); - Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z); - MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true); + + if (mob.stopPatrolTime + patrolDelay > System.currentTimeMillis()) + return; + + float xPoint = ThreadLocalRandom.current().nextInt(400) - 200; + float zPoint = ThreadLocalRandom.current().nextInt(400) - 200; + Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc(); + mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint); + + MovementUtilities.aiMove(mob, mob.destination, true); + + if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + for (Entry minion : mob.siegeMinionMap.entrySet()) { + + //make sure mob is out of combat stance + + if (minion.getKey().despawned == false) { + if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) { + minion.getKey().setCombat(false); + UpdateStateMsg rwss = new UpdateStateMsg(); + rwss.setPlayer(minion.getKey()); + DispatchMessage.sendToAllInRange(minion.getKey(), rwss); + } + + if (MovementUtilities.canMove(minion.getKey())) { + Vector3f minionOffset = Formation.getOffset(2, minion.getValue() + 3); + minion.getKey().updateLocation(); + Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z); + MovementUtilities.aiMove(minion.getKey(), formationPatrolPoint, true); + } } } } - } - } catch(Exception e){ + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e.getMessage()); } } public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { - try{ - float CurrentHateValue = 0; - if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { - CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); - } - AbstractWorldObject mostHatedTarget = null; - for (Entry playerEntry : mob.playerAgroMap.entrySet()) { - PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey()); - if (potentialTarget.equals(mob.getCombatTarget())) { - continue; - } - if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { - CurrentHateValue = potentialTarget.getHateValue(); - mostHatedTarget = potentialTarget; + + try { + + float CurrentHateValue = 0; + + if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) + CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); + + AbstractWorldObject mostHatedTarget = null; + + for (Entry playerEntry : mob.playerAgroMap.entrySet()) { + + PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey()); + + if (potentialTarget.equals(mob.getCombatTarget())) + continue; + + if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { + CurrentHateValue = potentialTarget.getHateValue(); + mostHatedTarget = potentialTarget; + } + } - } - return mostHatedTarget; - } catch(Exception e){ + return mostHatedTarget; + } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage()); } return null; From c3bcdd544e9bde65dfd8b8ef6cef55de97767aaf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 2 Aug 2023 09:12:13 -0400 Subject: [PATCH 16/16] Class formatting cleanup. --- src/engine/mobileAI/MobAI.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 07e815aa..e533c9e2 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -1041,11 +1041,9 @@ public class MobAI { else { if (mob.getCombatTarget() == null) { if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) - //safehold guard - SafeGuardAggro(mob); + SafeGuardAggro(mob); //safehold guard else - //normal aggro - CheckForAggro(mob); + CheckForAggro(mob); //normal aggro } } }