diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index 6182d29d..cd525d8d 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -285,7 +285,7 @@ public enum InterestManager implements Runnable { uom.addObject(obj); if (obj.getObjectType() == GameObjectType.Mob) - ((Mob) obj).getPlayerAgroMap().remove(player.getObjectUUID()); + ((Mob) obj).playerAgroMap.remove(player.getObjectUUID()); } catch (Exception e) { Logger.error("UnloadCharacter", obj.getObjectUUID() + " " + e.getMessage()); } @@ -338,10 +338,10 @@ public enum InterestManager implements Runnable { if (!awonpc.isAlive() && (awonpc.isPet() || awonpc.isSiege() || awonpc.isNecroPet() || awonpc.isPlayerGuard())) continue; - if (awonpc.getState().equals(STATE.Respawn) || awonpc.getState().equals(STATE.Disabled)) + if (awonpc.state.equals(STATE.Respawn) || awonpc.state.equals(STATE.Disabled)) continue; - awonpc.getPlayerAgroMap().put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), false); MobileFSM.setAwake(awonpc, false); // IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000)); // awonpc.enableIntelligence(); @@ -355,7 +355,7 @@ public enum InterestManager implements Runnable { if (!awonpc.isAlive()) continue; - awonpc.getPlayerAgroMap().put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), false); if (awonpc.isMob()) MobileFSM.setAwake(awonpc, false); diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 274a6276..3d3bde7a 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -34,7 +34,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.sqr; -import static java.lang.Math.sqrt; public class MobileFSM { @@ -58,7 +57,7 @@ public class MobileFSM { if (mob == null) { return; } - STATE state = mob.getState(); + STATE state = mob.state; switch (state) { case Idle: if (mob.isAlive()) @@ -149,21 +148,21 @@ public class MobileFSM { public static boolean setAwake(Mob aiAgent, boolean force) { if (force) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return true; } - if (aiAgent.getState() == STATE.Idle) { - aiAgent.setState(STATE.Awake); + if (aiAgent.state == STATE.Idle) { + aiAgent.state = STATE.Awake; return true; } return false; } public static boolean setAggro(Mob aiAgent, int targetID) { - if (aiAgent.getState() != STATE.Dead) { + if (aiAgent.state != STATE.Dead) { aiAgent.setNoAggro(false); aiAgent.setAggroTargetID(targetID); - aiAgent.setState(STATE.Aggro); + aiAgent.state = STATE.Aggro; return true; } return false; @@ -173,18 +172,18 @@ public class MobileFSM { if (mob.getLoc().distanceSquared2D(mob.getBindLoc()) > sqr(2000)) { mob.setWalkingHome(false); - mob.setState(STATE.Home); + mob.state = STATE.Home; } } private static void awake(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } if (aiAgent.getLoc().distanceSquared2D(aiAgent.getBindLoc()) > sqr(2000)) { aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } //Don't attempt to aggro if No aggro is on and aiAgent is not home yet. @@ -197,8 +196,8 @@ public class MobileFSM { aiAgent.setNoAggro(false); } //no players currently have this mob loaded. return to IDLE. - if (aiAgent.getPlayerAgroMap().isEmpty()) { - aiAgent.setState(STATE.Idle); + if (aiAgent.playerAgroMap.isEmpty()) { + aiAgent.state = STATE.Idle; return; } @@ -210,7 +209,7 @@ public class MobileFSM { //Get the Map for Players that loaded this mob. - ConcurrentHashMap loadedPlayers = aiAgent.getPlayerAgroMap(); + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; if (!Enum.MobFlagType.AGGRESSIVE.elementOf(aiAgent.getMobBase().getFlags()) && aiAgent.getCombatTarget() == null) { @@ -218,7 +217,7 @@ public class MobileFSM { int patrolRandom = ThreadLocalRandom.current().nextInt(1000); if (patrolRandom <= MBServerStatics.AI_PATROL_DIVISOR) { - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; } return; } @@ -251,7 +250,7 @@ public class MobileFSM { if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { aiAgent.setAggroTargetID(playerID); - aiAgent.setState(STATE.Aggro); + aiAgent.state = STATE.Aggro; return; } @@ -260,37 +259,37 @@ public class MobileFSM { int patrolRandom = ThreadLocalRandom.current().nextInt(1000); if (patrolRandom <= MBServerStatics.AI_PATROL_DIVISOR) { - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; } } private static void guardAttackMob(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } AbstractGameObject target = aiAgent.getCombatTarget(); if (target == null) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (target.getObjectType().equals(GameObjectType.Mob) == false) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (target.equals(aiAgent)) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } Mob mob = (Mob) target; - if (!mob.isAlive() || mob.getState() == STATE.Dead) { + if (!mob.isAlive() || mob.state == STATE.Dead) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -350,7 +349,7 @@ public class MobileFSM { } private static void awakeNPCguard(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } @@ -359,7 +358,7 @@ public class MobileFSM { if (aiAgent.getLoc().distanceSquared2D(aiAgent.getBindLoc()) > sqr(2000)) { aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -383,13 +382,13 @@ public class MobileFSM { if (aiAgent.getLoc().distanceSquared2D(mob.getLoc()) > sqr(50)) continue; aiAgent.setCombatTarget(mob); - aiAgent.setState(STATE.Attack); + aiAgent.state = STATE.Attack; } } private static void petAwake(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } @@ -425,13 +424,13 @@ public class MobileFSM { private static void aggro(Mob aiAgent, int targetID) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } if (aiAgent.getLoc().distanceSquared2D(aiAgent.getBindLoc()) > sqr(2000)) { aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -447,22 +446,22 @@ public class MobileFSM { if (aggroTarget == null) { // Logger.error("MobileFSM.aggro", "aggro target with UUID " + targetID + " returned null"); - aiAgent.getPlayerAgroMap().remove(targetID); + aiAgent.playerAgroMap.remove(targetID); aiAgent.setAggroTargetID(0); - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (!aiAgent.canSee(aggroTarget)) { aiAgent.setCombatTarget(null); targetID = 0; - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (!aggroTarget.isActive()) { aiAgent.setCombatTarget(null); targetID = 0; - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } aiAgent.setCombatTarget(aggroTarget); @@ -471,7 +470,7 @@ public class MobileFSM { attack(aiAgent, targetID); } } else if (CombatUtilities.inRange2D(aiAgent, aggroTarget, aiAgent.getRange())) { - aiAgent.setState(STATE.Attack); + aiAgent.state = STATE.Attack; attack(aiAgent, targetID); return; } @@ -480,14 +479,14 @@ public class MobileFSM { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); MovementUtilities.moveToLocation(aiAgent, aiAgent.getTrueBindLoc(), 0); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (!MovementUtilities.inRangeOfBindLocation(aiAgent)) { aiAgent.setCombatTarget(null); aiAgent.setAggroTargetID(0); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -511,14 +510,14 @@ public class MobileFSM { private static void petAttack(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } AbstractGameObject target = aiAgent.getCombatTarget(); if (target == null) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -530,13 +529,13 @@ public class MobileFSM { if (!player.isActive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (player.inSafeZone()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -556,21 +555,21 @@ public class MobileFSM { private static void mobAttack(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } if (aiAgent.getLoc().distanceSquared2D(aiAgent.getBindLoc()) > sqr(2000)) { aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } AbstractGameObject target = aiAgent.getCombatTarget(); if (target == null) { - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } @@ -582,13 +581,13 @@ public class MobileFSM { if (!player.isActive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (aiAgent.isNecroPet() && player.inSafeZone()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Idle); + aiAgent.state = STATE.Idle; return; } if (canCast(aiAgent) == true) { @@ -614,19 +613,19 @@ public class MobileFSM { if (building.getRank() == -1) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (!building.isVulnerable()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (BuildingManager.getBuildingFromCache(building.getObjectUUID()) == null) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -645,7 +644,7 @@ public class MobileFSM { continue; mob.setCombatTarget(aiAgent); - mob.setState(STATE.Attack); + mob.state = STATE.Attack; } } @@ -722,13 +721,13 @@ public class MobileFSM { if (aiAgent.getMobBase().getSeeInvis() < player.getHidden()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (!player.isAlive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -798,13 +797,13 @@ public class MobileFSM { if (aiAgent.getMobBase().getSeeInvis() < player.getHidden()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (!player.isAlive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -815,14 +814,14 @@ public class MobileFSM { aiAgent.setCombatTarget(null); aiAgent.setAggroTargetID(0); aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } if (!MovementUtilities.inRangeDropAggro(aiAgent, player)) { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); MovementUtilities.moveToLocation(aiAgent, aiAgent.getTrueBindLoc(), 0); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (CombatUtilities.inRange2D(aiAgent, player, aiAgent.getRange())) { @@ -891,13 +890,13 @@ public class MobileFSM { if (CombatUtilities.inRangeToAttack2D(aiAgent, player)) return; //set mob to pursue target - aiAgent.setState(MobileFSM.STATE.Chase); + aiAgent.state = STATE.Chase; } private static void handleMobAttackForPet(Mob aiAgent, Mob mob) { if (!mob.isAlive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -969,7 +968,7 @@ public class MobileFSM { if (!mob.isAlive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1040,7 +1039,7 @@ public class MobileFSM { //in range to attack, start attacking now! if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } @@ -1048,23 +1047,23 @@ public class MobileFSM { if (aggroTarget == null) { // Logger.error("MobileFSM.aggro", "aggro target with UUID " + targetID + " returned null"); - aiAgent.getPlayerAgroMap().remove(targetID); + aiAgent.playerAgroMap.remove(targetID); aiAgent.setAggroTargetID(0); - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (aiAgent.getMobBase().getSeeInvis() < aggroTarget.getHidden()) { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (!aggroTarget.isAlive()) { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } @@ -1072,7 +1071,7 @@ public class MobileFSM { aiAgent.setCombatTarget(null); aiAgent.setAggroTargetID(0); aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -1080,7 +1079,7 @@ public class MobileFSM { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); MovementUtilities.moveToLocation(aiAgent, aiAgent.getTrueBindLoc(), 0); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1144,17 +1143,17 @@ public class MobileFSM { MovementManager.translocate(aiAgent, aiAgent.getBindLoc(), null); aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; } private static void recalling(Mob aiAgent) { //recall home. if (aiAgent.getLoc() == aiAgent.getBindLoc()) - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; if (aiAgent.getLoc().distanceSquared2D(aiAgent.getBindLoc()) > sqr(2000)) { aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; } } private static void patrol(Mob aiAgent) { @@ -1162,7 +1161,7 @@ public class MobileFSM { MobBase mobbase = aiAgent.getMobBase(); if (mobbase != null && (Enum.MobFlagType.SENTINEL.elementOf(mobbase.getFlags()) || !Enum.MobFlagType.CANROAM.elementOf(mobbase.getFlags()))) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1178,35 +1177,35 @@ public class MobileFSM { MovementUtilities.aiMove(aiAgent, Vector3fImmutable.getRandomPointInCircle(aiAgent.getBindLoc(), patrolRadius), true); } - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; } private static void dead(Mob aiAgent) { //Despawn Timer with Loot currently in inventory. if (aiAgent.getCharItemManager().getInventoryCount() > 0) { - if (System.currentTimeMillis() > aiAgent.getDeathTime() + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { + if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { aiAgent.despawn(); //update time of death after mob despawns so respawn time happens after mob despawns. aiAgent.setDeathTime(System.currentTimeMillis()); - aiAgent.setState(STATE.Respawn); + aiAgent.state = STATE.Respawn; } //No items in inventory. } else { //Mob's Loot has been looted. if (aiAgent.isHasLoot()) { - if (System.currentTimeMillis() > aiAgent.getDeathTime() + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { + if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { aiAgent.despawn(); //update time of death after mob despawns so respawn time happens after mob despawns. aiAgent.setDeathTime(System.currentTimeMillis()); - aiAgent.setState(STATE.Respawn); + aiAgent.state = STATE.Respawn; } //Mob never had Loot. } else { - if (System.currentTimeMillis() > aiAgent.getDeathTime() + MBServerStatics.DESPAWN_TIMER) { + if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) { aiAgent.despawn(); //update time of death after mob despawns so respawn time happens after mob despawns. aiAgent.setDeathTime(System.currentTimeMillis()); - aiAgent.setState(STATE.Respawn); + aiAgent.state = STATE.Respawn; } } } @@ -1214,14 +1213,14 @@ public class MobileFSM { private static void guardAwake(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } if (aiAgent.getLoc().distanceSquared2D(aiAgent.getBindLoc()) > sqr(2000)) { aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -1232,12 +1231,12 @@ public class MobileFSM { aiAgent.setNoAggro(false); // do nothing if no players are around. - if (aiAgent.getPlayerAgroMap().isEmpty()) + if (aiAgent.playerAgroMap.isEmpty()) return; //Get the Map for Players that loaded this mob. - ConcurrentHashMap loadedPlayers = aiAgent.getPlayerAgroMap(); + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; //no players currently have this mob loaded. return to IDLE. //aiAgent finished moving home, set aggro on. @@ -1342,13 +1341,13 @@ public class MobileFSM { if (aggro) { if (CombatUtilities.inRangeToAttack(aiAgent, loadedPlayer)) { aiAgent.setAggroTargetID(playerID); - aiAgent.setState(STATE.Aggro); + aiAgent.state = STATE.Aggro; return; } if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { aiAgent.setAggroTargetID(playerID); - aiAgent.setState(STATE.Aggro); + aiAgent.state = STATE.Aggro; return; } } @@ -1356,12 +1355,12 @@ public class MobileFSM { //attempt to patrol even if aiAgent isn't aggresive; if (aiAgent.isMoving() == false) - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; } private static void guardAggro(Mob aiAgent, int targetID) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } @@ -1376,26 +1375,26 @@ public class MobileFSM { PlayerCharacter aggroTarget = PlayerCharacter.getFromCache(targetID); if (aggroTarget == null) { - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (!aiAgent.canSee(aggroTarget)) { aiAgent.setCombatTarget(null); targetID = 0; - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (!aggroTarget.isActive()) { aiAgent.setCombatTarget(null); targetID = 0; - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (CombatUtilities.inRangeToAttack(aiAgent, aggroTarget)) { aiAgent.setCombatTarget(aggroTarget); - aiAgent.setState(STATE.Attack); + aiAgent.state = STATE.Attack; guardAttack(aiAgent); return; } @@ -1412,7 +1411,7 @@ public class MobileFSM { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); MovementUtilities.moveToLocation(aiAgent, aiAgent.getTrueBindLoc(), 0); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1420,7 +1419,7 @@ public class MobileFSM { aiAgent.setCombatTarget(null); aiAgent.setAggroTargetID(0); aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -1437,8 +1436,8 @@ public class MobileFSM { } private static void guardPatrol(Mob aiAgent) { - if (aiAgent.getPlayerAgroMap().isEmpty()) { - aiAgent.setState(STATE.Awake); + if (aiAgent.playerAgroMap.isEmpty()) { + aiAgent.state = STATE.Awake; return; } @@ -1449,7 +1448,7 @@ public class MobileFSM { DispatchMessage.sendToAllInRange(aiAgent, rwss); } - if (aiAgent.getNpcOwner() == null) { + if (aiAgent.npcOwner == null) { if (!aiAgent.isWalk() || (aiAgent.isCombat() && aiAgent.getCombatTarget() == null)) { aiAgent.setWalkMode(true); @@ -1460,14 +1459,14 @@ public class MobileFSM { } if (aiAgent.isMoving()) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } - Building barrack = aiAgent.getBuilding(); + Building barrack = aiAgent.building; if (barrack == null) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1480,7 +1479,7 @@ public class MobileFSM { } } - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1494,25 +1493,25 @@ public class MobileFSM { } - Building barrack = ((Mob) aiAgent.getNpcOwner()).getBuilding(); + Building barrack = ((Mob) aiAgent.npcOwner).building; if (barrack == null) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (barrack.getPatrolPoints() == null) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (barrack.getPatrolPoints().isEmpty()) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } if (aiAgent.isMoving()) { - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1528,24 +1527,24 @@ public class MobileFSM { if (patrolLoc != null) { if (MovementUtilities.canMove(aiAgent)) { MovementUtilities.aiMove(aiAgent, patrolLoc, true); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; } } } } - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; } private static void guardAttack(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } AbstractGameObject target = aiAgent.getCombatTarget(); if (target == null) { - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } @@ -1556,13 +1555,13 @@ public class MobileFSM { if (!player.isActive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Patrol); + aiAgent.state = STATE.Patrol; return; } if (aiAgent.isNecroPet() && player.inSafeZone()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Idle); + aiAgent.state = STATE.Idle; return; } if (canCast(aiAgent) == true) { @@ -1575,7 +1574,7 @@ public class MobileFSM { break; case Building: Logger.info("PLAYER GUARD ATTEMPTING TO ATTACK BUILDING IN " + aiAgent.getParentZone().getName()); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; break; case Mob: Mob mob = (Mob) target; @@ -1590,7 +1589,7 @@ public class MobileFSM { aiAgent.setAggroTargetID(0); aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; } private static void respawn(Mob aiAgent) { @@ -1599,26 +1598,26 @@ public class MobileFSM { long spawnTime = aiAgent.getSpawnTime(); - if (aiAgent.isPlayerGuard() && aiAgent.getNpcOwner() != null && !aiAgent.getNpcOwner().isAlive()) + if (aiAgent.isPlayerGuard() && aiAgent.npcOwner != null && !aiAgent.npcOwner.isAlive()) return; - if (System.currentTimeMillis() > aiAgent.getDeathTime() + spawnTime) { + if (System.currentTimeMillis() > aiAgent.deathTime + spawnTime) { aiAgent.respawn(); - aiAgent.setState(STATE.Idle); + aiAgent.state = STATE.Idle; } } private static void retaliate(Mob aiAgent) { if (aiAgent.getCombatTarget() == null) - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; //out of range to attack move if (!MovementUtilities.canMove(aiAgent)) { - aiAgent.setState(STATE.Attack); + aiAgent.state = STATE.Attack; return; } - aiAgent.setState(STATE.Attack); + aiAgent.state = STATE.Attack; //lets make mobs ai less twitchy, Don't call another movement until mob reaches it's destination. if (aiAgent.isMoving()) @@ -1730,7 +1729,7 @@ public class MobileFSM { Zone mobCamp = mob.getParentZone(); for (Mob mob1 : mobCamp.zoneMobSet) { if (mob1.getMobBase().getFlags().contains(Enum.MobFlagType.RESPONDSTOCALLSFORHELP)) { - if (mob1.getState() == STATE.Awake) { + if (mob1.state == STATE.Awake) { if (CombatUtilities.inRange2D(mob, mob1, mob.getAggroRange()) == true) { MovementUtilities.moveToLocation(mob1, mob.getLoc(), 0); } @@ -1745,14 +1744,14 @@ public class MobileFSM { mob.setCombatTarget(null); mob.setAggroTargetID(0); mob.setWalkingHome(false); - mob.setState(STATE.Home); + mob.state = STATE.Home; return; } mob.updateMovementState(); mob.updateLocation(); if(CombatUtilities.inRange2D(mob,mob.getCombatTarget(), mob.getRange()) == true) { MovementUtilities.moveToLocation(mob, mob.getLoc(), 0); - mob.setState(STATE.Attack); + mob.state = STATE.Attack; } else {//if (mob.isMoving() == false){ if(mob.getRange() > 15) { diff --git a/src/engine/ai/utilities/MovementUtilities.java b/src/engine/ai/utilities/MovementUtilities.java index 28a89689..f160d987 100644 --- a/src/engine/ai/utilities/MovementUtilities.java +++ b/src/engine/ai/utilities/MovementUtilities.java @@ -40,10 +40,10 @@ public class MovementUtilities { if (agent.getContract() != null) guardCaptain = agent; else - guardCaptain = (Mob) agent.getNpcOwner(); + guardCaptain = (Mob) agent.npcOwner; if (guardCaptain != null){ - Building barracks = guardCaptain.getBuilding(); + Building barracks = guardCaptain.building; if (barracks != null){ City city = barracks.getCity(); diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index c26312db..e98705c5 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -10,6 +10,7 @@ package engine.db.handlers; import engine.ai.MobileFSM.STATE; +import engine.gameManager.NPCManager; import engine.math.Vector3fImmutable; import engine.objects.Mob; import engine.objects.PlayerCharacter; @@ -118,7 +119,7 @@ public class dbMobHandler extends dbHandlerBase { while (rs.next()) { int mobBaseID = rs.getInt("mobBaseID"); String name = rs.getString("name"); - Mob toCreate = captain.createGuardMob(mobBaseID, captain.getGuild(), captain.getParentZone(), captain.getBuilding().getLoc(), captain.getLevel(),name); + Mob toCreate = NPCManager.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(),name); if (toCreate == null) return; @@ -127,7 +128,7 @@ public class dbMobHandler extends dbHandlerBase { toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + MBServerStatics.FIFTEEN_MINUTES); toCreate.setDeathTime(System.currentTimeMillis()); - toCreate.setState(STATE.Respawn); + toCreate.state = STATE.Respawn; } } @@ -241,7 +242,7 @@ public class dbMobHandler extends dbHandlerBase { worldDelta = worldDelta.subtract(new Vector3fImmutable(sourceZone.getAbsX(), sourceZone.getAbsY(), sourceZone.getAbsZ())); newMobile = Mob.createMob(mobile.getLoadID(), - mobile.getLoc().add(worldDelta), null, true, targetZone, mobile.getBuilding(), 0); + mobile.getLoc().add(worldDelta), null, true, targetZone, mobile.building, 0); if (newMobile != null) { newMobile.updateDatabase(); diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 235f433e..27750c60 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -449,7 +449,7 @@ public class InfoCmd extends AbstractDevCmd { output += StringUtils.addWS("isAlive: " + targetMob.isAlive(), 20); output += newline; - output += "Mob State: " +targetMob.getState().name(); + output += "Mob State: " + targetMob.state.name(); output += newline; output += "Speed : " + targetMob.getSpeed(); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 5a2d7fa6..5e84494e 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -260,7 +260,7 @@ public enum BuildingManager { if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC) ((NPC) slottedNPC).remove(); else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob) - ((Mob) slottedNPC).remove(building); + NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building); } return; } @@ -285,7 +285,7 @@ public enum BuildingManager { else building.getHirelings().remove(npc); } else if (mob != null) { - if (!mob.remove(building)) + if (!NPCManager.removeMobileFromBuilding(mob, building)) Logger.error("Failed to remove npc " + npc.getObjectUUID() + "from Building " + building.getObjectUUID()); else diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index fffe09c8..f654af90 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -183,8 +183,8 @@ public enum CombatManager { //set sources target pet.setCombatTarget(target); - pet.setState(STATE.Attack); - // setFirstHitCombatTarget(player,target); + pet.state = STATE.Attack; + // setFirstHitCombatTarget(player,target); //put in combat if not already if (!pet.isCombat()) @@ -691,8 +691,8 @@ public enum CombatManager { count++; mob.setCombatTarget(ac); - mob.setState(STATE.Attack); - } + mob.state = STATE.Attack; + } } } } @@ -1339,8 +1339,8 @@ public enum CombatManager { Mob pet = ((PlayerCharacter) tarAc).getPet(); if (pet != null && pet.assist() && pet.getCombatTarget() == null) { pet.setCombatTarget(ac); - pet.setState(STATE.Retaliate); - } + pet.state = STATE.Retaliate; + } } //Handle Mob Retaliate. @@ -1351,9 +1351,9 @@ public enum CombatManager { if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege()) return; retaliater.setCombatTarget(ac); - retaliater.setState(STATE.Retaliate); + retaliater.state = STATE.Retaliate; - } + } } public static void handleDamageShields(AbstractCharacter ac, AbstractCharacter target, float damage) { diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index daffd23c..2e4239c8 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -1,7 +1,15 @@ package engine.gameManager; +import engine.Enum; +import engine.InterestManagement.WorldGrid; +import engine.ai.MobileFSM; +import engine.math.Vector3fImmutable; +import engine.net.Dispatch; +import engine.net.DispatchMessage; +import engine.net.client.msg.PetMsg; import engine.objects.*; import engine.powers.EffectsBase; +import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -12,10 +20,8 @@ public enum NPCManager { NPC_MANAGER; public static HashMap> _equipmentSetMap = new HashMap<>(); public static HashMap> _runeSetMap = new HashMap<>(); - public static HashMap> _bootySetMap = new HashMap<>(); - public static void LoadAllEquipmentSets() { _equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); } @@ -33,7 +39,7 @@ public enum NPCManager { // Early exit if (mob.runeSetID == 0) - return;; + return; //Apply all rune effects. @@ -67,7 +73,7 @@ public enum NPCManager { // Race runes are in the runeset but not in runebase for some reason if (sourceRune == null) - return;; + return; for (MobBaseEffects mbe : sourceRune.getEffectsList()) { @@ -106,4 +112,304 @@ public enum NPCManager { } } + + public static void dismissNecroPet(Mob necroPet, boolean updateOwner) { + + necroPet.state = MobileFSM.STATE.Disabled; + + necroPet.combatTarget = null; + necroPet.hasLoot = false; + + if (necroPet.parentZone != null) + necroPet.parentZone.zoneMobSet.remove(necroPet); + + try { + necroPet.clearEffects(); + } catch (Exception e) { + Logger.error(e.getMessage()); + } + necroPet.playerAgroMap.clear(); + WorldGrid.RemoveWorldObject(necroPet); + + DbManager.removeFromCache(necroPet); + + PlayerCharacter petOwner = necroPet.getOwner(); + + if (petOwner != null) { + necroPet.setOwner(null); + petOwner.setPet(null); + + if (updateOwner == false) + return; + + PetMsg petMsg = new PetMsg(5, null); + Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); + } + } + + public static void auditNecroPets(PlayerCharacter player) { + int removeIndex = 0; + while (player.necroPets.size() >= 10) { + + + if (removeIndex == player.necroPets.size()) + break; + + Mob necroPet = player.necroPets.get(removeIndex); + + if (necroPet == null) { + removeIndex++; + continue; + } + dismissNecroPet(necroPet, true); + player.necroPets.remove(necroPet); + removeIndex++; + + + } + } + + public static void resetNecroPets(PlayerCharacter player) { + + for (Mob necroPet : player.necroPets) + if (necroPet.isPet()) + necroPet.setMob(); + } + + public static void spawnNecroPet(PlayerCharacter playerCharacter, Mob mob) { + + if (mob == null) + return; + + if (mob.getMobBaseID() != 12021 && mob.getMobBaseID() != 12022) + return; + + auditNecroPets(playerCharacter); + resetNecroPets(playerCharacter); + + playerCharacter.necroPets.add(mob); + } + + public static void dismissNecroPets(PlayerCharacter playerCharacter) { + + + if (playerCharacter.necroPets.isEmpty()) + return; + + for (Mob necroPet : playerCharacter.necroPets) { + + try { + dismissNecroPet(necroPet, true); + } catch (Exception e) { + necroPet.state = MobileFSM.STATE.Disabled; + Logger.error(e); + } + } + playerCharacter.necroPets.clear(); + } + + public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) { + + MobBase minionMobBase; + Mob mob; + int maxSlots = 1; + + switch (guardCaptain.getRank()) { + case 1: + case 2: + maxSlots = 1; + break; + case 3: + maxSlots = 2; + break; + case 4: + case 5: + maxSlots = 3; + break; + case 6: + maxSlots = 4; + break; + case 7: + maxSlots = 5; + break; + default: + maxSlots = 1; + + } + + if (guardCaptain.siegeMinionMap.size() == maxSlots) + return null; + + minionMobBase = guardCaptain.mobBase; + + if (minionMobBase == null) + return null; + + mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true); + + mob.despawned = true; + + mob.setLevel(level); + //grab equipment and name from minionbase. + if (guardCaptain.contract != null) { + Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); + if (minionType != null) { + mob.equipmentSetID = minionType.getEquipSetID(); + String rank = ""; + + if (guardCaptain.getRank() < 3) + rank = MBServerStatics.JUNIOR; + else if (guardCaptain.getRank() < 6) + rank = ""; + else if (guardCaptain.getRank() == 6) + rank = MBServerStatics.VETERAN; + else + rank = MBServerStatics.ELITE; + + if (rank.isEmpty()) + mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName(); + else + mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName(); + } + } + + if (parent != null) + mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ); + + mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); + + // mob.setMob(); + mob.isPlayerGuard = true; + mob.setParentZone(parent); + DbManager.addToCache(mob); + mob.runAfterLoad(); + + + RuneBase guardRune = RuneBase.getRuneBase(252621); + + for (MobBaseEffects mbe : guardRune.getEffectsList()) { + + EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken()); + + if (eb == null) { + Logger.info("EffectsBase Null for Token " + mbe.getToken()); + continue; + } + + //check to upgrade effects if needed. + if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { + if (mbe.getReqLvl() > (int) mob.level) { + continue; + } + + Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); + + if (eff == null) + continue; + + //Current effect is a higher rank, dont apply. + if (eff.getTrains() > mbe.getRank()) + continue; + + //new effect is of a higher rank. remove old effect and apply new one. + eff.cancelJob(); + mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); + } else { + + if (mbe.getReqLvl() > (int) mob.level) + continue; + + mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); + } + } + + int slot = 0; + slot += guardCaptain.siegeMinionMap.size() + 1; + + guardCaptain.siegeMinionMap.put(mob, slot); + mob.setInBuildingLoc(guardCaptain.building, guardCaptain); + mob.setBindLoc(loc.add(mob.inBuildingLoc)); + mob.deathTime = System.currentTimeMillis(); + mob.spawnTime = 900; + mob.npcOwner = guardCaptain; + mob.state = MobileFSM.STATE.Respawn; + + return mob; + } + + public static void removeSiegeMinions(Mob mobile) { + + for (Mob toRemove : mobile.siegeMinionMap.keySet()) { + + toRemove.state = MobileFSM.STATE.Disabled; + + if (mobile.isMoving()) { + + mobile.stopMovement(mobile.getLoc()); + mobile.state = MobileFSM.STATE.Disabled; + + if (toRemove.parentZone != null) + toRemove.parentZone.zoneMobSet.remove(toRemove); + } + + try { + toRemove.clearEffects(); + } catch (Exception e) { + Logger.error(e.getMessage()); + } + + if (toRemove.parentZone != null) + toRemove.parentZone.zoneMobSet.remove(toRemove); + + WorldGrid.RemoveWorldObject(toRemove); + WorldGrid.removeObject(toRemove); + DbManager.removeFromCache(toRemove); + + PlayerCharacter petOwner = toRemove.getOwner(); + + if (petOwner != null) { + + petOwner.setPet(null); + toRemove.setOwner(null); + + PetMsg petMsg = new PetMsg(5, null); + Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); + } + } + } + + public static boolean removeMobileFromBuilding(Mob mobile, Building building) { + + // Remove npc from it's building + mobile.state = MobileFSM.STATE.Disabled; + + try { + mobile.clearEffects(); + } catch (Exception e) { + Logger.error(e.getMessage()); + } + + if (mobile.parentZone != null) + mobile.parentZone.zoneMobSet.remove(mobile); + + if (building != null) { + building.getHirelings().remove(mobile); + removeSiegeMinions(mobile); + } + + // Delete npc from database + + if (DbManager.MobQueries.DELETE_MOB(mobile) == 0) + return false; + + // Remove npc from the simulation + + mobile.removeFromCache(); + DbManager.removeFromCache(mobile); + WorldGrid.RemoveWorldObject(mobile); + WorldGrid.removeObject(mobile); + return true; + } } diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 51f9e993..4d715c3c 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -28,7 +28,6 @@ import engine.net.client.msg.*; import engine.net.client.msg.chat.AbstractChatMsg; import engine.net.client.msg.commands.ClientAdminCommandMsg; import engine.objects.*; -import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.server.MBServerStatics; import engine.server.world.WorldServer; import engine.session.Session; @@ -37,7 +36,6 @@ import org.pmw.tinylog.Logger; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -2028,7 +2026,7 @@ public class ClientMessagePump implements NetMsgHandler { if (pet.getCombatTarget() == null) return; - pet.setState(STATE.Attack); + pet.state = STATE.Attack; } protected static void petCmd(PetCmdMsg msg, ClientConnection conn) throws MsgSendException { @@ -2046,7 +2044,7 @@ public class ClientMessagePump implements NetMsgHandler { if (!pet.isAlive()) return; - if (pet.getState() == STATE.Disabled) + if (pet.state == STATE.Disabled) return; int type = msg.getType(); @@ -2054,7 +2052,7 @@ public class ClientMessagePump implements NetMsgHandler { if (type == 1) { //stop attack pet.setCombatTarget(null); pc.setCombat(false); - pet.setState(STATE.Awake); + pet.state = STATE.Awake; } else if (type == 2) { //dismiss diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index c0bd4819..558caf1a 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -7,6 +7,7 @@ import engine.ai.MobileFSM; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import engine.gameManager.SessionManager; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -66,8 +67,8 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (!npc.getSiegeMinionMap().containsKey(toRemove)) return true; - toRemove.setState(MobileFSM.STATE.Disabled); - npc.getSiegeMinionMap().remove(toRemove); + toRemove.state = MobileFSM.STATE.Disabled; + npc.getSiegeMinionMap().remove(toRemove); //toRemove.disableIntelligence(); WorldGrid.RemoveWorldObject(toRemove); @@ -159,8 +160,8 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { toCreate.setSpawnTime(60 * 15); toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + (60 * 15 * 1000)); toCreate.setDeathTime(System.currentTimeMillis()); - toCreate.setState(MobileFSM.STATE.Respawn); - } + toCreate.state = MobileFSM.STATE.Respawn; + } } ManageNPCMsg mnm = new ManageNPCMsg(npc); @@ -198,8 +199,8 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.getMobBaseID(), npc.getSiegeMinionMap().get(toRemove))) return true; - toRemove.setState(MobileFSM.STATE.Disabled); - npc.getSiegeMinionMap().remove(toRemove); + toRemove.state = MobileFSM.STATE.Disabled; + npc.getSiegeMinionMap().remove(toRemove); //toRemove.disableIntelligence(); WorldGrid.RemoveWorldObject(toRemove); @@ -283,7 +284,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) return true; - Mob toCreate = npc.createGuardMob(mobBase, npc.getGuild(), zone, b.getLoc(), npc.getLevel(),pirateName); + Mob toCreate = NPCManager.createGuardMob(npc, npc.getGuild(), zone, b.getLoc(), npc.getLevel(),pirateName); if (toCreate == null) return true; @@ -292,8 +293,8 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (toCreate != null) { toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + MBServerStatics.FIFTEEN_MINUTES); toCreate.setDeathTime(System.currentTimeMillis()); - toCreate.setState(MobileFSM.STATE.Respawn); - } + toCreate.state = MobileFSM.STATE.Respawn; + } } ManageNPCMsg mnm = new ManageNPCMsg(npc); diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index 3335727c..d115bdb0 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -6,6 +6,7 @@ import engine.Enum.ProfitType; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import engine.gameManager.SessionManager; import engine.math.FastMath; import engine.math.Vector3fImmutable; @@ -209,7 +210,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (building.getHirelings().containsKey(mob) == false) return true; - if (mob.remove(building) == false) { + if (NPCManager.removeMobileFromBuilding(mob, building) == false) { PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); return true; } @@ -439,9 +440,9 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { case Mob: Mob mob = (Mob) abstractCharacter; - building = mob.getBuilding(); + building = mob.building; - if (mob.getBuilding() == null) + if (mob.building == null) return; City mobCity = building.getCity(); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 40a2f51c..1afc8738 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -84,7 +84,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { protected float manaMax; // Health/Mana/Stamina protected AtomicBoolean isAlive = new AtomicBoolean(true); protected Resists resists = new Resists("Genric"); - protected AbstractWorldObject combatTarget; + public AbstractWorldObject combatTarget; protected ConcurrentHashMap timers; protected ConcurrentHashMap timestamps; protected int atrHandOne; diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index f3f3c601..ce119020 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -204,8 +204,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { WorldGrid.RemoveWorldObject(this); if (this.getObjectType() == GameObjectType.Mob){ - ((Mob)this).setState(STATE.Disabled); - if (((Mob)this).getParentZone() != null) + ((Mob)this).state = STATE.Disabled; + if (((Mob)this).getParentZone() != null) ((Mob)this).getParentZone().zoneMobSet.remove(this); } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 47f87d9b..9b726b8c 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -11,7 +11,6 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.WorldGrid; import engine.ai.MobileFSM; import engine.ai.MobileFSM.STATE; @@ -32,7 +31,6 @@ import engine.net.client.msg.ManageCityAssetsMsg; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; import engine.net.client.msg.chat.ChatSystemMsg; -import engine.powers.EffectsBase; import engine.server.MBServerStatics; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -57,7 +55,7 @@ public class Mob extends AbstractIntelligenceAgent { private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); //mob specific - private final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); + public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); public long nextCastTime = 0; public long nextCallForHelp = 0; public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); @@ -70,42 +68,42 @@ public class Mob extends AbstractIntelligenceAgent { protected boolean isMob; public MobBase mobBase; protected float spawnRadius; - protected int spawnTime; + public int spawnTime; //used by static mobs protected int parentZoneID; - protected Zone parentZone; + public Zone parentZone; protected float statLat; protected float statLon; protected float statAlt; - protected Building building; + public Building building; public Contract contract; private int currentID; private int ownerUID = 0; //only used by pets - private boolean hasLoot = false; + public boolean hasLoot = false; private AbstractWorldObject fearedObject = null; private int buildingID; private boolean isSiege = false; public boolean isPlayerGuard = false; private long timeToSpawnSiege; - private AbstractCharacter npcOwner; - private Vector3fImmutable inBuildingLoc = null; + public AbstractCharacter npcOwner; + public Vector3fImmutable inBuildingLoc = null; private boolean noAggro = false; - private STATE state = STATE.Disabled; + public STATE state = STATE.Disabled; private int aggroTargetID = 0; private boolean walkingHome = true; private long lastAttackTime = 0; - private long deathTime = 0; - private final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + public long deathTime = 0; + public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private int patrolPointIndex = 0; private int lastMobPowerToken = 0; private HashMap equip = null; - private String nameOverride = ""; + public String nameOverride = ""; private Regions lastRegion = null; private long despawnTime = 0; private DeferredPowerJob weaponPower; private DateTime upgradeDateTime = null; private boolean lootSync = false; - private int equipmentSetID = 0; + public int equipmentSetID = 0; public int runeSetID = 0; public int bootySetID = 0; @@ -1950,10 +1948,6 @@ public class Mob extends AbstractIntelligenceAgent { } - public Vector3fImmutable getInBuildingLoc() { - return inBuildingLoc; - } - public ItemBase getWeaponItemBase(boolean mainHand) { if (this.equipmentSetID != 0) { @@ -2070,10 +2064,6 @@ public class Mob extends AbstractIntelligenceAgent { this.timeToSpawnSiege = timeToSpawnSiege; } - public AbstractCharacter getNpcOwner() { - return npcOwner; - } - public void setNpcOwner(AbstractCharacter npcOwner) { this.npcOwner = npcOwner; } @@ -2106,81 +2096,6 @@ public class Mob extends AbstractIntelligenceAgent { } } - public boolean remove(Building building) { - - // Remove npc from it's building - this.state = STATE.Disabled; - - try { - this.clearEffects(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - - if (this.parentZone != null) - this.parentZone.zoneMobSet.remove(this); - - if (building != null) { - building.getHirelings().remove(this); - this.removeMinions(); - } - - // Delete npc from database - - if (DbManager.MobQueries.DELETE_MOB(this) == 0) - return false; - - // Remove npc from the simulation - - this.removeFromCache(); - DbManager.removeFromCache(this); - WorldGrid.RemoveWorldObject(this); - WorldGrid.removeObject(this); - return true; - } - - public void removeMinions() { - - for (Mob toRemove : this.siegeMinionMap.keySet()) { - - toRemove.state = STATE.Disabled; - - if (this.isMoving()) { - - this.stopMovement(this.getLoc()); - this.state = STATE.Disabled; - - if (toRemove.parentZone != null) - toRemove.parentZone.zoneMobSet.remove(toRemove); - } - - try { - toRemove.clearEffects(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - - if (toRemove.parentZone != null) - toRemove.parentZone.zoneMobSet.remove(toRemove); - - WorldGrid.RemoveWorldObject(toRemove); - WorldGrid.removeObject(toRemove); - DbManager.removeFromCache(toRemove); - - PlayerCharacter petOwner = toRemove.getOwner(); - - if (petOwner != null) { - - petOwner.setPet(null); - toRemove.setOwner(null); - - PetMsg petMsg = new PetMsg(5, null); - Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); - } - } - } - public void setRank(int newRank) { DbManager.MobQueries.SET_PROPERTY(this, "mob_level", newRank); @@ -2201,14 +2116,6 @@ public class Mob extends AbstractIntelligenceAgent { this.noAggro = noAggro; } - public STATE getState() { - return state; - } - - public void setState(STATE state) { - this.state = state; - } - public int getAggroTargetID() { return aggroTargetID; } @@ -2233,14 +2140,6 @@ public class Mob extends AbstractIntelligenceAgent { this.lastAttackTime = lastAttackTime; } - public ConcurrentHashMap getPlayerAgroMap() { - return playerAgroMap; - } - - public long getDeathTime() { - return deathTime; - } - public void setDeathTime(long deathTime) { this.deathTime = deathTime; } @@ -2261,10 +2160,6 @@ public class Mob extends AbstractIntelligenceAgent { return siegeMinionMap; } - public Building getBuilding() { - return this.building; - } - public DateTime getUpgradeDateTime() { lock.readLock().lock(); @@ -2276,136 +2171,6 @@ public class Mob extends AbstractIntelligenceAgent { } } - public synchronized Mob createGuardMob(int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) { - - MobBase minionMobBase; - Mob mob; - int maxSlots = 1; - - switch (this.getRank()) { - case 1: - case 2: - maxSlots = 1; - break; - case 3: - maxSlots = 2; - break; - case 4: - case 5: - maxSlots = 3; - break; - case 6: - maxSlots = 4; - break; - case 7: - maxSlots = 5; - break; - default: - maxSlots = 1; - - } - - if (siegeMinionMap.size() == maxSlots) - return null; - - minionMobBase = this.mobBase; - - if (minionMobBase == null) - return null; - - mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true); - - mob.despawned = true; - - mob.setLevel(level); - //grab equipment and name from minionbase. - if (this.contract != null) { - MinionType minionType = MinionType.ContractToMinionMap.get(this.contract.getContractID()); - if (minionType != null) { - mob.equipmentSetID = minionType.getEquipSetID(); - String rank = ""; - - if (this.getRank() < 3) - rank = MBServerStatics.JUNIOR; - else if (this.getRank() < 6) - rank = ""; - else if (this.getRank() == 6) - rank = MBServerStatics.VETERAN; - else - rank = MBServerStatics.ELITE; - - if (rank.isEmpty()) - mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName(); - else - mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName(); - } - } - - - if (parent != null) - mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ); - - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); - - // mob.setMob(); - mob.isPlayerGuard = true; - mob.setParentZone(parent); - DbManager.addToCache(mob); - mob.runAfterLoad(); - - - RuneBase guardRune = RuneBase.getRuneBase(252621); - - for (MobBaseEffects mbe : guardRune.getEffectsList()) { - - EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken()); - - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) mob.level) { - continue; - } - - Effect eff = mob.effects.get(Integer.toString(eb.getUUID())); - - if (eff == null) - continue; - - //Current effect is a higher rank, dont apply. - if (eff.getTrains() > mbe.getRank()) - continue; - - //new effect is of a higher rank. remove old effect and apply new one. - eff.cancelJob(); - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { - - if (mbe.getReqLvl() > (int) mob.level) - continue; - - mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - - int slot = 0; - slot += siegeMinionMap.size() + 1; - - siegeMinionMap.put(mob, slot); - mob.setInBuildingLoc(this.building, this); - mob.setBindLoc(loc.add(mob.inBuildingLoc)); - mob.deathTime = System.currentTimeMillis(); - mob.spawnTime = 900; - mob.npcOwner = this; - mob.state = STATE.Respawn; - - return mob; - } - public Contract getContract() { return contract; } @@ -2472,7 +2237,7 @@ public class Mob extends AbstractIntelligenceAgent { try { - building = this.getBuilding(); + building = this.building; // Cannot upgrade an npc not within a building @@ -2550,7 +2315,7 @@ public class Mob extends AbstractIntelligenceAgent { if (!building.getHirelings().containsKey(this)) return; - if (!this.remove(building)) { + if (!NPCManager.removeMobileFromBuilding(this, building)) { PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); return; } @@ -2607,7 +2372,7 @@ public class Mob extends AbstractIntelligenceAgent { WorldGrid.RemoveWorldObject(this); DbManager.removeFromCache(this); if (this.getObjectType() == GameObjectType.Mob) { - this.setState(STATE.Disabled); + this.state = STATE.Disabled; if (this.getParentZone() != null) this.getParentZone().zoneMobSet.remove(this); } @@ -2639,44 +2404,4 @@ public class Mob extends AbstractIntelligenceAgent { } } - public void dismissNecroPet(boolean updateOwner) { - - this.state = STATE.Disabled; - - this.combatTarget = null; - this.hasLoot = false; - - if (this.parentZone != null) - this.parentZone.zoneMobSet.remove(this); - - try { - this.clearEffects(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - this.playerAgroMap.clear(); - WorldGrid.RemoveWorldObject(this); - - DbManager.removeFromCache(this); - - // YEAH BONUS CODE! THANKS UNNAMED ASSHOLE! - //WorldServer.removeObject(this); - //WorldGrid.INSTANCE.removeWorldObject(this); - //owner.getPet().disableIntelligence(); - - PlayerCharacter petOwner = this.getOwner(); - - if (petOwner != null) { - this.setOwner(null); - petOwner.setPet(null); - - if (updateOwner == false) - return; - PetMsg petMsg = new PetMsg(5, null); - Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); - } - } - - } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1959bbf1..36c90f31 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -797,7 +797,7 @@ public class NPC extends AbstractCharacter { for (Mob toRemove : this.siegeMinionMap.keySet()) { - toRemove.setState(STATE.Disabled); + toRemove.state = STATE.Disabled; try { toRemove.clearEffects(); @@ -1461,14 +1461,14 @@ public class NPC extends AbstractCharacter { siegeMinionMap.put(mob, slot); mob.setInBuildingLoc(this.building, this); - - Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, mob.getInBuildingLoc()); + + Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, mob.inBuildingLoc); mob.setBindLoc(buildingWorldLoc); mob.setLoc(buildingWorldLoc); mob.setSpawnTime(10); mob.setNpcOwner(this); - mob.setState(STATE.Awake); + mob.state = STATE.Awake; return mob; } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index a7ceb19e..bf2ada16 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -626,7 +626,7 @@ public class PlayerCharacter extends AbstractCharacter { if (this.pet != null) this.dismissPet(); - this.dismissNecroPets(); + NPCManager.dismissNecroPets(this); // remove flight job. this.setTakeOffTime(0); @@ -1586,77 +1586,13 @@ public class PlayerCharacter extends AbstractCharacter { return this.pet; } - public Mob getNecroPet(int i) { - return this.necroPets.get(i); - } - - -public static void auditNecroPets(PlayerCharacter player){ - int removeIndex =0; - while(player.necroPets.size() >= 10){ - - - if (removeIndex == player.necroPets.size()) - break; - - Mob toRemove = player.necroPets.get(removeIndex); - - if (toRemove == null){ - removeIndex++; - continue; - } - toRemove.dismissNecroPet(true); - player.necroPets.remove(toRemove); - removeIndex++; - - - } -} - -public static void resetNecroPets(PlayerCharacter player){ - for (Mob necroPet: player.necroPets) - if (necroPet.isPet()) - necroPet.setMob(); -} - - public void spawnNecroPet(Mob mob) { - if (mob == null) - return; - if (mob.getMobBaseID() != 12021 && mob.getMobBaseID() != 12022) - return; - - PlayerCharacter.auditNecroPets(this); - PlayerCharacter.resetNecroPets(this); - - this.necroPets.add(mob); - } - - public void dismissPet() { + if (this.pet != null) { this.pet.dismiss(); this.pet = null; } } - -public void dismissNecroPets() { - - - if (this.necroPets.isEmpty()) - return; - - for (Mob necroPet: this.necroPets){ - - try{ - necroPet.dismissNecroPet(true); - }catch(Exception e){ - necroPet.setState(STATE.Disabled); - Logger.error(e); - } - } - this.necroPets.clear(); - } - //called to verify player has correct item equipped for casting. public boolean validEquip(int slot, String type) { @@ -4644,7 +4580,7 @@ public void dismissNecroPets() { if (!currentPet.isSiege()) { currentPet.setCombatTarget(null); - currentPet.setState(STATE.Disabled); + currentPet.state = STATE.Disabled; if (currentPet.getParentZone() != null) @@ -4655,7 +4591,7 @@ public void dismissNecroPets() { }catch(Exception e){ Logger.error( e.getMessage()); } - currentPet.getPlayerAgroMap().clear(); + currentPet.playerAgroMap.clear(); WorldGrid.RemoveWorldObject(currentPet); DbManager.removeFromCache(currentPet); diff --git a/src/engine/powers/poweractions/ClearAggroPowerAction.java b/src/engine/powers/poweractions/ClearAggroPowerAction.java index 4ac761e6..ce62b610 100644 --- a/src/engine/powers/poweractions/ClearAggroPowerAction.java +++ b/src/engine/powers/poweractions/ClearAggroPowerAction.java @@ -32,8 +32,8 @@ public class ClearAggroPowerAction extends AbstractPowerAction { protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) { if (awo != null && awo.getObjectType() == GameObjectType.Mob){ ((Mob)awo).setNoAggro(true); - ((Mob)awo).setState(STATE.Patrol); - } + ((Mob)awo).state = STATE.Patrol; + } diff --git a/src/engine/powers/poweractions/ClearNearbyAggroPowerAction.java b/src/engine/powers/poweractions/ClearNearbyAggroPowerAction.java index a32dd972..33ee2f04 100644 --- a/src/engine/powers/poweractions/ClearNearbyAggroPowerAction.java +++ b/src/engine/powers/poweractions/ClearNearbyAggroPowerAction.java @@ -31,8 +31,8 @@ public class ClearNearbyAggroPowerAction extends AbstractPowerAction { @Override protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) { if (source.getObjectType() == GameObjectType.Mob){ - ((Mob)source).setState(STATE.Patrol); - } + ((Mob)source).state = STATE.Patrol; + } } diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index de78b27d..0eb499d5 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -13,6 +13,7 @@ import engine.Enum; import engine.InterestManagement.WorldGrid; import engine.ai.MobileFSM.STATE; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.net.Dispatch; @@ -81,13 +82,13 @@ public class CreateMobPowerAction extends AbstractPowerAction { if(currentPet!= null && !currentPet.isNecroPet() && !currentPet.isSiege()) { DbManager.removeFromCache(currentPet); WorldGrid.RemoveWorldObject(currentPet); - currentPet.setState(STATE.Disabled); - currentPet.setCombatTarget(null); + currentPet.state = STATE.Disabled; + currentPet.setCombatTarget(null); if (currentPet.getParentZone() != null) currentPet.getParentZone().zoneMobSet.remove(currentPet); - currentPet.getPlayerAgroMap().clear(); + currentPet.playerAgroMap.clear(); try { currentPet.clearEffects(); @@ -107,7 +108,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { //remove 10th pet - owner.spawnNecroPet(pet); + NPCManager.spawnNecroPet(owner, pet); } else { //is not a necro pet @@ -115,13 +116,13 @@ public class CreateMobPowerAction extends AbstractPowerAction { if(!currentPet.isNecroPet() && !currentPet.isSiege()) { DbManager.removeFromCache(currentPet); currentPet.setCombatTarget(null); - currentPet.setState(STATE.Disabled); + currentPet.state = STATE.Disabled; - currentPet.setOwner(null); + currentPet.setOwner(null); WorldGrid.RemoveWorldObject(currentPet); currentPet.getParentZone().zoneMobSet.remove(currentPet); - currentPet.getPlayerAgroMap().clear(); + currentPet.playerAgroMap.clear(); currentPet.clearEffects(); //currentPet.disableIntelligence(); } @@ -136,8 +137,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { } } - PlayerCharacter.auditNecroPets(owner); - PlayerCharacter.resetNecroPets(owner); + NPCManager.auditNecroPets(owner); + NPCManager.resetNecroPets(owner); } } /* if(owner.getPet() != null) { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 4eec50af..bef15898 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -560,7 +560,7 @@ public class WorldServer { m.setParentZone(zone); //ADD GUARDS HERE. - if (m.getBuilding() != null && m.getBuilding().getBlueprint() != null && m.getBuilding().getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) + if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) DbManager.MobQueries.LOAD_PATROL_POINTS(m); } @@ -683,7 +683,7 @@ public class WorldServer { if (player.getPet() != null) player.getPet().dismiss(); - player.dismissNecroPets(); + NPCManager.dismissNecroPets(player); // Set player inactive so they quit loading for other players