diff --git a/src/discord/MagicBot.java b/src/discord/MagicBot.java index 0ada6f9e..fe5a6150 100644 --- a/src/discord/MagicBot.java +++ b/src/discord/MagicBot.java @@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import static discord.ChatChannel.ADMINLOG; -import static discord.ChatChannel.SEPTIC; /* * MagicBot is many things to Magicbane... diff --git a/src/discord/handlers/ChatChannelHandler.java b/src/discord/handlers/ChatChannelHandler.java index 6c59dd28..4f86b184 100644 --- a/src/discord/handlers/ChatChannelHandler.java +++ b/src/discord/handlers/ChatChannelHandler.java @@ -14,8 +14,6 @@ import discord.RobotSpeak; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import org.pmw.tinylog.Logger; -import static discord.ChatChannel.GENERAL; - public class ChatChannelHandler { public static void handleRequest(ChatChannel chatChannel, MessageReceivedEvent event, String[] args) { diff --git a/src/discord/handlers/DevRequestHandler.java b/src/discord/handlers/DevRequestHandler.java index a9b741d1..c73ea898 100644 --- a/src/discord/handlers/DevRequestHandler.java +++ b/src/discord/handlers/DevRequestHandler.java @@ -12,10 +12,7 @@ import discord.MagicBot; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import org.pmw.tinylog.Logger; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Collectors; diff --git a/src/engine/Enum.java b/src/engine/Enum.java index d2718ab9..0a73b743 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -9,12 +9,14 @@ package engine; import ch.claude_martin.enumbitset.EnumBitSetHelper; -import engine.gameManager.ConfigManager; import engine.gameManager.PowersManager; import engine.gameManager.ZoneManager; import engine.math.Vector2f; import engine.math.Vector3fImmutable; -import engine.objects.*; +import engine.objects.AbstractCharacter; +import engine.objects.ItemBase; +import engine.objects.Shrine; +import engine.objects.Zone; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -34,65 +36,6 @@ import java.util.concurrent.ThreadLocalRandom; public class Enum { - public enum MobRaceType { - - Aelfborn(436353765), - All(80289), - Animal(-1674072607), - Aracoix(-1764716937), - Celestial(-317458791), - Centaur(775630999), - Construct(-513218610), - CSR(52803), - Dragon(-1731031452), - Dwarf(71831236), - Elf(70053), - Giant(90574087), - Goblin(-1732836921), - Grave(75107943), - HalfGiant(251196434), - Human(79806088), - Infernal(-654077031), - Insect(-1407990295), - Irekei(-1770742167), - Minotaur(-949570680), - Monster(258519513), - NecroPet(618137151), - NPC(35374), - Pet(88208), - Plant(90574256), - Rat(88082), - Reptile(-591705981), - Shade(74648883), - Siege(74620179), - SiegeEngineer(-839969219), - Summoned(-656950110), - Troll(82261620), - Undead(-1942775307), - Nephilim(-592098572), - Vampire(-524731385); - - int token; - - private static HashMap _mobRaceTypeByToken = new HashMap<>(); - - MobRaceType(int token) { - this.token = token; - } - - public static MobRaceType getRaceTypebyToken(int token) { - return _mobRaceTypeByToken.get(token); - } - - public static void initRaceTypeTables() { - - for (MobRaceType raceType : MobRaceType.values()) { - _mobRaceTypeByToken.put(raceType.token, raceType); - } - } - - } - public enum MobFlagType implements EnumBitSetHelper { AGGRESSIVE, CANROAM, @@ -1832,7 +1775,7 @@ public class Enum { SkillReq, SkillsBase, SkillsBaseAttribute, - SpecialLoot, + MobileBooty, StrongBox, Trigger, ValidRaceBeardStyle, 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..f3456e62 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -16,7 +16,10 @@ import engine.Enum.GameObjectType; import engine.InterestManagement.WorldGrid; import engine.ai.utilities.CombatUtilities; import engine.ai.utilities.MovementUtilities; -import engine.gameManager.*; +import engine.gameManager.BuildingManager; +import engine.gameManager.CombatManager; +import engine.gameManager.MovementManager; +import engine.gameManager.PowersManager; import engine.math.Vector3fImmutable; import engine.net.DispatchMessage; import engine.net.client.msg.PerformActionMsg; @@ -28,13 +31,13 @@ import engine.powers.PowersBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; import java.util.Map.Entry; 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 +61,7 @@ public class MobileFSM { if (mob == null) { return; } - STATE state = mob.getState(); + STATE state = mob.state; switch (state) { case Idle: if (mob.isAlive()) @@ -90,8 +93,11 @@ public class MobileFSM { if (mob.isPlayerGuard()) guardAggro(mob, mob.getAggroTargetID()); - else + else if (mob.isGuard()) { + awakeNPCguard(mob); + } else { aggro(mob, mob.getAggroTargetID()); + } break; case Patrol: @@ -149,21 +155,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 +179,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 +203,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 +216,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 +224,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 +257,7 @@ public class MobileFSM { if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { aiAgent.setAggroTargetID(playerID); - aiAgent.setState(STATE.Aggro); + aiAgent.state = STATE.Aggro; return; } @@ -260,37 +266,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 +356,7 @@ public class MobileFSM { } private static void awakeNPCguard(Mob aiAgent) { if (!aiAgent.isAlive()) { - aiAgent.setState(STATE.Dead); + aiAgent.state = STATE.Dead; return; } @@ -359,7 +365,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 +389,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 +431,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 +453,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 +477,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 +486,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 +517,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 +536,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 +562,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 +588,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 +620,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 +651,7 @@ public class MobileFSM { continue; mob.setCombatTarget(aiAgent); - mob.setState(STATE.Attack); + mob.state = STATE.Attack; } } @@ -722,13 +728,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 +804,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 +821,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 +897,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 +975,7 @@ public class MobileFSM { if (!mob.isAlive()) { aiAgent.setCombatTarget(null); - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1040,7 +1046,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 +1054,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 +1078,7 @@ public class MobileFSM { aiAgent.setCombatTarget(null); aiAgent.setAggroTargetID(0); aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -1080,7 +1086,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 +1150,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 +1168,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 +1184,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 +1220,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 +1238,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 +1348,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 +1362,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 +1382,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 +1418,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 +1426,7 @@ public class MobileFSM { aiAgent.setCombatTarget(null); aiAgent.setAggroTargetID(0); aiAgent.setWalkingHome(false); - aiAgent.setState(STATE.Home); + aiAgent.state = STATE.Home; return; } @@ -1437,8 +1443,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 +1455,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 +1466,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 +1486,7 @@ public class MobileFSM { } } - aiAgent.setState(STATE.Awake); + aiAgent.state = STATE.Awake; return; } @@ -1494,25 +1500,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 +1534,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 +1562,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 +1581,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 +1596,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 +1605,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 +1736,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 +1751,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/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index 28c8d5b9..9e6ea1f9 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -10,31 +10,20 @@ package engine.ai.utilities; -import engine.Enum; import engine.Enum.*; -import engine.ai.MobileFSM.STATE; import engine.gameManager.ChatManager; import engine.gameManager.CombatManager; -import engine.gameManager.PowersManager; -import engine.math.Vector3f; import engine.math.Vector3fImmutable; import engine.net.DispatchMessage; -import engine.net.client.msg.PerformActionMsg; import engine.net.client.msg.TargetedActionMsg; import engine.objects.*; -import engine.powers.ActionsBase; -import engine.powers.PowersBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.util.Map; -import java.util.Random; -import java.util.Set; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.sqr; import static java.lang.Math.pow; -import static java.lang.Math.sqrt; public class CombatUtilities { 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/dbGuildHandler.java b/src/engine/db/handlers/dbGuildHandler.java index f60f80f4..49dc05f5 100644 --- a/src/engine/db/handlers/dbGuildHandler.java +++ b/src/engine/db/handlers/dbGuildHandler.java @@ -19,7 +19,6 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.time.LocalDateTime; import java.util.ArrayList; public class dbGuildHandler extends dbHandlerBase { diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 6217f7d3..a54c8185 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -9,6 +9,7 @@ package engine.db.handlers; +import engine.objects.BootySetEntry; import engine.objects.EquipmentSetEntry; import engine.objects.ItemBase; import org.pmw.tinylog.Logger; @@ -149,4 +150,87 @@ public class dbItemBaseHandler extends dbHandlerBase { } return equipmentSets; } + + public HashMap> LOAD_RUNES_FOR_NPC_AND_MOBS() { + + HashMap> runeSets = new HashMap<>(); + int runeSetID; + int runeBaseID; + int recordsRead = 0; + + prepareCallable("SELECT * FROM static_npc_runeSet"); + + try { + ResultSet rs = executeQuery(); + + while (rs.next()) { + + recordsRead++; + + runeSetID = rs.getInt("runeSet"); + runeBaseID = rs.getInt("runeBase"); + + if (runeSets.get(runeSetID) == null){ + ArrayList runeList = new ArrayList<>(); + runeList.add(runeBaseID); + runeSets.put(runeSetID, runeList); + } + else{ + ArrayListruneList = runeSets.get(runeSetID); + runeList.add(runeSetID); + runeSets.put(runeSetID, runeList); + } + } + + Logger.info("read: " + recordsRead + " cached: " + runeSets.size()); + + } catch (SQLException e) { + Logger.error( e.toString()); + } finally { + closeCallable(); + } + return runeSets; + } + + public HashMap> LOAD_BOOTY_FOR_MOBS() { + + HashMap> bootySets = new HashMap<>(); + BootySetEntry bootySetEntry; + int bootySetID; + + int recordsRead = 0; + + prepareCallable("SELECT * FROM static_npc_bootySet"); + + try { + ResultSet rs = executeQuery(); + + while (rs.next()) { + + recordsRead++; + + bootySetID = rs.getInt("bootySet"); + bootySetEntry = new BootySetEntry(rs); + + if (bootySets.get(bootySetID) == null){ + ArrayList bootyList = new ArrayList<>(); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } + else{ + ArrayListbootyList = bootySets.get(bootySetID); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } + } + + Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); + + } catch (SQLException e) { + Logger.error( e.toString()); + } finally { + closeCallable(); + } + return bootySets; + } } diff --git a/src/engine/db/handlers/dbMineHandler.java b/src/engine/db/handlers/dbMineHandler.java index eb66c44b..eeca535b 100644 --- a/src/engine/db/handlers/dbMineHandler.java +++ b/src/engine/db/handlers/dbMineHandler.java @@ -14,7 +14,6 @@ import engine.objects.Mine; import engine.objects.MineProduction; import engine.objects.Resource; -import java.time.LocalDateTime; import java.util.ArrayList; public class dbMineHandler extends dbHandlerBase { diff --git a/src/engine/db/handlers/dbMobBaseHandler.java b/src/engine/db/handlers/dbMobBaseHandler.java index 33f98990..9914c782 100644 --- a/src/engine/db/handlers/dbMobBaseHandler.java +++ b/src/engine/db/handlers/dbMobBaseHandler.java @@ -174,37 +174,6 @@ public class dbMobBaseHandler extends dbHandlerBase { } - public ArrayList LOAD_RUNES_FOR_MOBBASE(int mobBaseUUID) { - - ArrayList runes = new ArrayList<>(); - prepareCallable("SELECT * FROM `static_npc_mobbase_runes` WHERE `mobbaseUUID` = ?"); - setInt(1, mobBaseUUID); - try { - ResultSet rs = executeQuery(); - while (rs.next()) { - int runeID = rs.getInt("runeID"); - RuneBase rune = RuneBase.getRuneBase(runeID); - runes.add(rune); - } - - } catch (SQLException e) { - Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e); - } finally { - closeCallable(); - } - return runes; - - } - - public boolean ADD_MOBBASE_EFFECT(int mobBaseUUID, int token, int rank, int reqLvl) { - prepareCallable("INSERT INTO `static_npc_mobbase_effects` (`mobbaseUUID`, `token`, `rank`, `reqLvl`) VALUES (?, ?, ?, ?);"); - setInt(1, mobBaseUUID); - setInt(2, token); - setInt(3, rank); - setInt(4, reqLvl); - return (executeUpdate() > 0); - } - public boolean ADD_MOBBASE_POWER(int mobBaseUUID, int token, int rank) { prepareCallable("INSERT INTO `static_npc_mobbase_powers` (`mobbaseUUID`, `token`, `rank`) VALUES (?, ?, ?);"); setInt(1, mobBaseUUID); @@ -213,13 +182,6 @@ public class dbMobBaseHandler extends dbHandlerBase { return (executeUpdate() > 0); } - public boolean UPDATE_SKILLS(int ID, int skillsID) { - prepareCallable("UPDATE `static_npc_mobbase` SET `baseSkills`=? WHERE `ID`=?;"); - setInt(1, skillsID); - setInt(2, ID); - return (executeUpdate() > 0); - } - public boolean ADD_MOBBASE_RUNE(int mobBaseUUID, int runeID) { prepareCallable("INSERT INTO `static_npc_mobbase_runes` (`mobbaseUUID`, `runeID`) VALUES (?, ?);"); setInt(1, mobBaseUUID); diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index c26312db..fb8bccd1 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -10,19 +10,16 @@ package engine.db.handlers; import engine.ai.MobileFSM.STATE; -import engine.math.Vector3fImmutable; +import engine.gameManager.NPCManager; import engine.objects.Mob; -import engine.objects.PlayerCharacter; import engine.objects.Zone; import engine.server.MBServerStatics; -import engine.server.world.WorldServer; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; public class dbMobHandler extends dbHandlerBase { @@ -118,7 +115,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 +124,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; } } @@ -218,99 +215,4 @@ public class dbMobHandler extends dbHandlerBase { return getResult(); } - - public static boolean COPY_ZONE_MOBILES(PlayerCharacter pc, Zone sourceZone, Zone targetZone) { - - ArrayList sourceMobList; - Vector3fImmutable worldDelta; - Mob newMobile; - - // Sanity check. Can't copy a non existent zone - - if ((sourceZone == null) || (targetZone == null)) - return false; - - // Generate collections for all buildings in each zone - - - for (Mob mobile : sourceZone.zoneMobSet) { - - // Calculate world coordinate offset between zones - - worldDelta = new Vector3fImmutable(targetZone.getAbsX(), targetZone.getAbsY(), targetZone.getAbsZ()); - 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); - - if (newMobile != null) { - newMobile.updateDatabase(); - } - - } - - return true; - } - - - public void LOAD_RUNES_FOR_FIDELITY_MOBS() { - - - - - - prepareCallable("SELECT static_zone_npc.npcID,static_zone_npc.loadNum, static_zone_npc.classID, static_zone_npc.professionID, static_zone_npc.extraRune, static_zone_npc.extraRune2 FROM static_zone_npc ; "); - - try { - ResultSet rs = executeQuery(); - - while (rs.next()) { - - - int loadNum = rs.getInt("loadNum"); - int fidelityID = rs.getInt("npcID"); - int classID = rs.getInt("classID"); - int professionID = rs.getInt("professionID"); - int extraRune = rs.getInt("extraRune"); - int extraRune2 = rs.getInt("extraRune2"); - - if (WorldServer.ZoneFidelityMobRunes.get(loadNum) == null) - WorldServer.ZoneFidelityMobRunes.put(loadNum, new HashMap<>()); - ArrayList runeList; - if (WorldServer.ZoneFidelityMobRunes.get(loadNum).get(fidelityID) == null){ - runeList = new ArrayList<>(4); - }else - runeList = WorldServer.ZoneFidelityMobRunes.get(loadNum).get(fidelityID); - - - - if (classID != 0) - runeList.add(classID); - if (professionID != 0) - runeList.add(professionID); - if(extraRune != 0) - runeList.add(extraRune); - - if (extraRune2 != 0) - runeList.add(extraRune2); - - WorldServer.ZoneFidelityMobRunes.get(loadNum).put(fidelityID, runeList); - - - } - - rs.close(); - - - - } catch (SQLException e) { - Logger.error( e.toString()); - } finally { - closeCallable(); - - } - - } - - } diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index cc4623e9..bd3b539e 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -243,48 +243,7 @@ public class dbNPCHandler extends dbHandlerBase { closeCallable(); } } - - public void LOAD_RUNES_FOR_FIDELITY_NPC(NPC npc) { - - - - - - prepareCallable("SELECT static_zone_npc.npcID,static_zone_npc.loadNum, static_zone_npc.classID, static_zone_npc.professionID, static_zone_npc.extraRune, static_zone_npc.extraRune2 FROM static_zone_npc WHERE static_zone_npc.loadNum = ? AND static_zone_npc.npcID = ?"); - setInt(1,npc.getParentZoneID()); - setInt(2, npc.getFidalityID()); - try { - ResultSet rs = executeQuery(); - - while (rs.next()) { - - - - int classID = rs.getInt("classID"); - int professionID = rs.getInt("professionID"); - int extraRune = rs.getInt("extraRune"); - int extraRune2 = rs.getInt("extraRune2"); - - npc.classID = classID; - npc.professionID = professionID; - npc.extraRune = extraRune; - npc.extraRune2 = extraRune2; - - - - } - - rs.close(); - - - } catch (SQLException e) { - Logger.error( e.toString()); - } finally { - closeCallable(); - - } - } public boolean ADD_TO_PRODUCTION_LIST(final long ID,final long npcUID, final long itemBaseID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) { prepareCallable("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `itemBaseID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)"); diff --git a/src/engine/db/handlers/dbRunegateHandler.java b/src/engine/db/handlers/dbRunegateHandler.java index 32ec6324..86d1c575 100644 --- a/src/engine/db/handlers/dbRunegateHandler.java +++ b/src/engine/db/handlers/dbRunegateHandler.java @@ -13,13 +13,10 @@ import engine.Enum; import engine.gameManager.DbManager; import engine.objects.Building; import engine.objects.Portal; -import engine.objects.Resists; -import java.sql.Array; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.List; public class dbRunegateHandler extends dbHandlerBase { diff --git a/src/engine/db/handlers/dbSpecialLootHandler.java b/src/engine/db/handlers/dbSpecialLootHandler.java deleted file mode 100644 index 76aa68dd..00000000 --- a/src/engine/db/handlers/dbSpecialLootHandler.java +++ /dev/null @@ -1,75 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.db.handlers; - -import engine.objects.SpecialLoot; -import org.pmw.tinylog.Logger; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; - -public class dbSpecialLootHandler extends dbHandlerBase { - - public dbSpecialLootHandler() { - this.localClass = SpecialLoot.class; - this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); - } - - public ArrayList GET_SPECIALLOOT(int mobbaseID) { - - prepareCallable("SELECT * FROM `static_npc_mob_specialloot` WHERE `mobbaseID`=?"); - setInt(1, mobbaseID); - return getObjectList(); - } - - public void GenerateSpecialLoot(){ - HashMap> lootSets; - SpecialLoot lootSetEntry; - int lootSetID; - - lootSets = new HashMap<>(); - int recordsRead = 0; - - prepareCallable("SELECT * FROM static_zone_npc_specialloot"); - - try { - ResultSet rs = executeQuery(); - - while (rs.next()) { - - recordsRead++; - - lootSetID = rs.getInt("lootSet"); - lootSetEntry = new SpecialLoot(rs,true); - - if (lootSets.get(lootSetID) == null){ - ArrayList lootList = new ArrayList<>(); - lootList.add(lootSetEntry); - lootSets.put(lootSetID, lootList); - } - else{ - ArrayListlootList = lootSets.get(lootSetID); - lootList.add(lootSetEntry); - lootSets.put(lootSetID, lootList); - } - } - - Logger.info( "read: " + recordsRead + " cached: " + lootSets.size()); - - } catch (SQLException e) { - Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e); - } finally { - closeCallable(); - } - SpecialLoot.LootMap = lootSets; - } -} diff --git a/src/engine/devcmd/cmds/AddMobRuneCmd.java b/src/engine/devcmd/cmds/AddMobRuneCmd.java deleted file mode 100644 index 54a4ceef..00000000 --- a/src/engine/devcmd/cmds/AddMobRuneCmd.java +++ /dev/null @@ -1,98 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - - - - -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.Enum.GameObjectType; -import engine.devcmd.AbstractDevCmd; -import engine.gameManager.DbManager; -import engine.objects.AbstractGameObject; -import engine.objects.Mob; -import engine.objects.PlayerCharacter; -import engine.objects.RuneBase; - -/** - * - * @author Eighty - * - */ -public class AddMobRuneCmd extends AbstractDevCmd { - - public AddMobRuneCmd() { - super("addmobrune"); - } - - @Override - protected void _doCmd(PlayerCharacter pcSender, String[] args, - AbstractGameObject target) { - - - if(args.length != 1){ - this.sendUsage(pcSender); - return; - } - - if (target.getObjectType() != GameObjectType.Mob){ - this.throwbackError(pcSender, "Target is not a valid Mob."); - return; - } - Mob mobTarget = (Mob)target; - - - int runeID = 0; - try{ - runeID = Integer.valueOf(args[0]); - }catch(Exception e){ - this.throwbackInfo(pcSender, "Failed to Parse an Integer."); - return; - } - - RuneBase rune = RuneBase.getRuneBase(runeID); - if (rune == null){ - this.throwbackError(pcSender, "Invalid Rune ID"); - return; - } - - - if (!DbManager.MobBaseQueries.ADD_MOBBASE_RUNE(mobTarget.getMobBaseID(), runeID)){ - this.throwbackError(pcSender, "Failed to update Database"); - return; - } - - mobTarget.getMobBase().updateRunes(); - - this.throwbackInfo(pcSender, "Successfuly added rune " + rune.getName() + " to Mobbase with UID " + mobTarget.getMobBaseID()); - - - - } - - @Override - protected String _getUsageString() { - return "' /visualeffect visualeffectID"; - } - - @Override - protected String _getHelpString() { - return "Temporarily add visual effects to Character"; - } - -} diff --git a/src/engine/devcmd/cmds/GetDisciplineLocCmd.java b/src/engine/devcmd/cmds/GetDisciplineLocCmd.java deleted file mode 100644 index c8d428c1..00000000 --- a/src/engine/devcmd/cmds/GetDisciplineLocCmd.java +++ /dev/null @@ -1,64 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.devcmd.AbstractDevCmd; -import engine.gameManager.ZoneManager; -import engine.objects.*; - -import java.util.ArrayList; - -/** - * @author - * - */ -public class GetDisciplineLocCmd extends AbstractDevCmd { - - public GetDisciplineLocCmd() { - super("getdiscloc"); - } - - @Override - protected void _doCmd(PlayerCharacter pc, String[] words, - AbstractGameObject target) { - - System.out.println("MOB UUID , MOB NAME , MACRO ZONE NAME , MOB LOCATION, DROPPED ITEM, DROP CHANCE"); - - for (Zone zone: ZoneManager.getAllZones()){ - for (Mob mob: zone.zoneMobSet){ - - if (mob.getLevel() >= 80) - continue; - - ArrayList specialLootList = SpecialLoot.LootMap.get(mob.getLootSet()); - - - if (specialLootList != null) - for (SpecialLoot specialLoot: specialLootList){ - - - ItemBase itemBase = ItemBase.getItemBase(specialLoot.getItemID()); - System.out.println(mob.getObjectUUID() + " : " + mob.getName() + " : " + (mob.getParentZone().isMacroZone() ? mob.getParentZone().getName() : mob.getParentZone().getParent().getName()) + " , " + mob.getLoc().toString2D() + " , " + itemBase.getName() + " , " + specialLoot.getDropChance() + '%'); - } - } - } - } - - @Override - protected String _getHelpString() { - return "Enchants an item with a prefix and suffix"; - } - - @Override - protected String _getUsageString() { - return "' /enchant clear/Enchant1 Enchant2 Enchant3 ...'"; - } - -} diff --git a/src/engine/devcmd/cmds/HotzoneCmd.java b/src/engine/devcmd/cmds/HotzoneCmd.java index d3389750..5a8bb7b5 100644 --- a/src/engine/devcmd/cmds/HotzoneCmd.java +++ b/src/engine/devcmd/cmds/HotzoneCmd.java @@ -12,12 +12,8 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ZoneManager; -import engine.math.FastMath; -import engine.net.client.msg.HotzoneChangeMsg; import engine.objects.AbstractGameObject; import engine.objects.PlayerCharacter; -import engine.objects.Zone; -import engine.server.world.WorldServer; /** * ./hotzone <- display the current hotzone & time remaining diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 656e7520..27750c60 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -382,8 +382,6 @@ public class InfoCmd extends AbstractDevCmd { output += newline; output += "Slottable: " + targetNPC.getContract().getAllowedBuildings().toString(); output += newline; - output += "Fidelity ID: " + targetNPC.getFidalityID(); - output += newline; output += "EquipSet: " + targetNPC.getEquipmentSetID(); output += newline; output += "Parent Zone LoadNum : " + targetNPC.getParentZone().getLoadNum(); @@ -451,13 +449,11 @@ 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(); output += newline; - output += "Fidelity ID: " + targetMob.getFidalityID(); - output += newline; output += "EquipSet: " + targetMob.getEquipmentSetID(); output += newline; output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); 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/DbManager.java b/src/engine/gameManager/DbManager.java index e172f333..c89099e2 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -303,7 +303,6 @@ public enum DbManager { public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler(); public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler(); public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler(); - public static final dbSpecialLootHandler SpecialLootQueries = new dbSpecialLootHandler(); public static final dbVendorDialogHandler VendorDialogQueries = new dbVendorDialogHandler(); public static final dbZoneHandler ZoneQueries = new dbZoneHandler(); public static final dbRealmHandler RealmQueries = new dbRealmHandler(); diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index f51157d2..66521d62 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -126,7 +126,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new RealmInfoCmd()); DevCmdManager.registerDevCmd(new RebootCmd()); DevCmdManager.registerDevCmd(new AddMobPowerCmd()); - DevCmdManager.registerDevCmd(new AddMobRuneCmd()); DevCmdManager.registerDevCmd(new SetMineTypeCmd()); DevCmdManager.registerDevCmd(new SetMineExpansion()); DevCmdManager.registerDevCmd(new SetForceRenameCityCmd()); @@ -134,7 +133,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new convertLoc()); DevCmdManager.registerDevCmd(new GetMobBaseLoot()); DevCmdManager.registerDevCmd(new MBDropCmd()); - DevCmdManager.registerDevCmd(new GetDisciplineLocCmd()); DevCmdManager.registerDevCmd(new AuditHeightMapCmd()); DevCmdManager.registerDevCmd(new UnloadFurnitureCmd()); DevCmdManager.registerDevCmd(new SetNPCSlotCmd()); diff --git a/src/engine/gameManager/MaintenanceManager.java b/src/engine/gameManager/MaintenanceManager.java index f54a904b..2cc15cf7 100644 --- a/src/engine/gameManager/MaintenanceManager.java +++ b/src/engine/gameManager/MaintenanceManager.java @@ -13,12 +13,9 @@ package engine.gameManager; import engine.Enum; import engine.objects.*; -import org.joda.time.DateTime; import org.pmw.tinylog.Logger; -import java.time.DayOfWeek; import java.time.LocalDateTime; -import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; public enum MaintenanceManager { @@ -79,7 +76,7 @@ public enum MaintenanceManager { Building building = (Building) gameObject; - // No Maintenance on fidelity structures + // No maintenance on NPC owned buildings (Cache loaded) if (building.getProtectionState() == Enum.ProtectionState.NPC) continue; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java new file mode 100644 index 00000000..2e4239c8 --- /dev/null +++ b/src/engine/gameManager/NPCManager.java @@ -0,0 +1,415 @@ +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; +import java.util.HashMap; + +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(); + } + + public static void LoadAllRuneSets() { + _runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); + } + + public static void LoadAllBootySets() { + _bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS(); + } + + public static void applyRuneSetEffects(Mob mob) { + + // Early exit + + if (mob.runeSetID == 0) + return; + + //Apply all rune effects. + + if (NPCManager._runeSetMap.get(mob.runeSetID).contains(252623)) { + mob.isPlayerGuard = true; + mob.setNoAggro(true); + } + + // Only captains have contracts + + if (mob.contract != null || mob.isPlayerGuard) + applyEffectsForRune(mob, 252621); + + + // Apply effects from RuneSet + + if (mob.runeSetID != 0) + for (int runeID : _runeSetMap.get(mob.runeSetID)) + applyEffectsForRune(mob, runeID); + + // Not sure why but apply Warrior effects for some reason? + + applyEffectsForRune(mob, 2518); + } + + public static void applyEffectsForRune(AbstractCharacter character, int runeID) { + + EffectsBase effectsBase; + RuneBase sourceRune = RuneBase.getRuneBase(runeID); + + // Race runes are in the runeset but not in runebase for some reason + + if (sourceRune == null) + return; + + for (MobBaseEffects mbe : sourceRune.getEffectsList()) { + + effectsBase = PowersManager.getEffectByToken(mbe.getToken()); + + if (effectsBase == null) { + Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken()); + continue; + } + + //check to upgrade effects if needed. + if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) { + + if (mbe.getReqLvl() > (int) character.level) + continue; + + Effect eff = character.effects.get(Integer.toString(effectsBase.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(); + character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); + } else { + + if (mbe.getReqLvl() > (int) character.level) + continue; + + character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true); + } + + } + } + + 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 adbe76ee..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; @@ -1130,15 +1128,12 @@ public class ClientMessagePump implements NetMsgHandler { //Take equipment off mob if (tar.getObjectType() == GameObjectType.Mob && itemRet != null){ Mob mobTarget = (Mob)tar; - if (mobTarget.getFidalityID() != 0){ + if (item != null && item.getObjectType() == GameObjectType.MobLoot){ - int fidelityEquipID = ((MobLoot)item).getFidelityEquipID(); - if (fidelityEquipID != 0){ for (MobEquipment equip: mobTarget.getEquip().values()){ - if (equip.getObjectUUID() == fidelityEquipID){ - TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.getSlot()); + TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.getSlot()); DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); LootMsg lootMsg = new LootMsg(0,0,tar.getObjectType().ordinal(), tar.getObjectUUID(), equip); @@ -1146,23 +1141,13 @@ public class ClientMessagePump implements NetMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); break; } - } } - - } } - } - } - } - else { - } - - } else if (targetType == GameObjectType.Corpse.ordinal()) { corpse = Corpse.getCorpse(targetID); if (corpse == null) @@ -2041,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 { @@ -2059,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(); @@ -2067,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/ArcLoginNotifyMsgHandler.java b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java index c72b5cb8..a7cf9de7 100644 --- a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java +++ b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java @@ -12,7 +12,10 @@ import engine.net.client.msg.ArcLoginNotifyMsg; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.HotzoneChangeMsg; import engine.net.client.msg.PetMsg; -import engine.objects.*; +import engine.objects.Account; +import engine.objects.Guild; +import engine.objects.PlayerCharacter; +import engine.objects.PlayerFriends; import engine.server.MBServerStatics; import engine.session.Session; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java b/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java index a201d90b..d02e53d8 100644 --- a/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java +++ b/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java @@ -9,7 +9,6 @@ import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ArcMineWindowAvailableTimeMsg; import engine.net.client.msg.ClientNetMsg; -import engine.net.client.msg.KeepAliveServerClientMsg; import engine.objects.Building; import engine.objects.Guild; import engine.objects.GuildStatusController; diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index 29b4e055..1a45f229 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -38,7 +38,10 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.guild.GuildCreationFinalizeMsg; import engine.net.client.msg.guild.GuildInfoMsg; -import engine.objects.*; +import engine.objects.Guild; +import engine.objects.Item; +import engine.objects.ItemBase; +import engine.objects.PlayerCharacter; import engine.util.StringUtils; public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { 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/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index f9d8ccc4..0b4ee378 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -23,6 +23,7 @@ import engine.objects.*; import engine.server.MBServerStatics; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; + import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/engine/net/client/msg/RefineMsg.java b/src/engine/net/client/msg/RefineMsg.java index c630ae99..cd0a2a47 100644 --- a/src/engine/net/client/msg/RefineMsg.java +++ b/src/engine/net/client/msg/RefineMsg.java @@ -10,17 +10,14 @@ package engine.net.client.msg; -import engine.gameManager.PowersManager; import engine.gameManager.SessionManager; import engine.net.*; import engine.net.client.ClientConnection; import engine.net.client.Protocol; import engine.objects.*; -import engine.powers.PowersBase; import engine.server.MBServerStatics; import java.util.ArrayList; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class RefineMsg extends ClientNetMsg { diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index b2f3e5f2..5b1322bc 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -14,7 +14,10 @@ import engine.Enum.*; import engine.InterestManagement.InterestManager; import engine.InterestManagement.WorldGrid; import engine.exception.SerializationException; -import engine.gameManager.*; +import engine.gameManager.CombatManager; +import engine.gameManager.ConfigManager; +import engine.gameManager.MovementManager; +import engine.gameManager.PowersManager; import engine.job.AbstractJob; import engine.job.JobContainer; import engine.job.JobScheduler; @@ -25,9 +28,6 @@ import engine.math.AtomicFloat; import engine.math.Bounds; import engine.math.Vector3fImmutable; import engine.net.ByteBufferWriter; -import engine.net.Dispatch; -import engine.net.DispatchMessage; -import engine.net.client.msg.MoveToPointMsg; import engine.powers.EffectsBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -51,7 +51,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { protected short statIntCurrent; protected short statSpiCurrent; protected short unusedStatPoints; - protected short level; + public short level; protected int exp; protected Vector3fImmutable bindLoc; protected Vector3fImmutable faceDir; @@ -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; @@ -496,26 +496,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { return this.statSpiCurrent; } - public final void setStatStrCurrent(final short value) { - this.statStrCurrent = (value < 1) ? (short) 1 : value; - } - - public final void setStatDexCurrent(final short value) { - this.statDexCurrent = (value < 1) ? (short) 1 : value; - } - - public final void setStatConCurrent(final short value) { - this.statConCurrent = (value < 1) ? (short) 1 : value; - } - - public final void setStatIntCurrent(final short value) { - this.statIntCurrent = (value < 1) ? (short) 1 : value; - } - - public final void setStatSpiCurrent(final short value) { - this.statSpiCurrent = (value < 1) ? (short) 1 : value; - } - public short getLevel() { return this.level; } @@ -1917,16 +1897,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.itemCasting = itemCasting; } - public static void MoveInsideBuilding(PlayerCharacter source, AbstractCharacter ac){ - MoveToPointMsg moveMsg = new MoveToPointMsg(); - moveMsg.setPlayer(ac); - moveMsg.setTarget(ac, BuildingManager.getBuildingFromCache(ac.inBuildingID)); - - Dispatch dispatch = Dispatch.borrow(source, moveMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); - - } - //updates public void update(){ } 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/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 61e69d31..11305d41 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -50,7 +50,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { protected AtomicFloat health = new AtomicFloat(); public float healthMax; protected boolean load = true; - protected ConcurrentHashMap effects = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + public ConcurrentHashMap effects = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private int objectTypeMask = 0; private Bounds bounds; diff --git a/src/engine/objects/BootySetEntry.java b/src/engine/objects/BootySetEntry.java new file mode 100644 index 00000000..c34edeba --- /dev/null +++ b/src/engine/objects/BootySetEntry.java @@ -0,0 +1,29 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.objects; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class BootySetEntry { + + + public int itemBase; + public float dropChance; + /** + * ResultSet Constructor + */ + + public BootySetEntry(ResultSet rs) throws SQLException { + this.itemBase = (rs.getInt("itemBase")); + this.dropChance = (rs.getFloat("dropChance")); + } + +} diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index d9fca2d5..80a625c4 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -99,7 +99,6 @@ public class Building extends AbstractWorldObject { public int floor; public int level; - public HashMap fidelityNpcs = new HashMap<>(); public AtomicBoolean isDeranking = new AtomicBoolean(false); private ArrayList children = null; public LocalDateTime maintDateTime; diff --git a/src/engine/objects/EquipmentSetEntry.java b/src/engine/objects/EquipmentSetEntry.java index b3bdf8a6..aae0ed3d 100644 --- a/src/engine/objects/EquipmentSetEntry.java +++ b/src/engine/objects/EquipmentSetEntry.java @@ -9,39 +9,21 @@ package engine.objects; -import engine.gameManager.DbManager; - import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; public class EquipmentSetEntry { - private float dropChance; - private int itemID; - - static HashMap> EquipmentSetMap = new HashMap<>(); + public int itemID; + public float dropChance; /** * ResultSet Constructor */ public EquipmentSetEntry(ResultSet rs) throws SQLException { - this.dropChance = (rs.getFloat("dropChance")); this.itemID = (rs.getInt("itemID")); - } - - public static void LoadAllEquipmentSets() { - EquipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); - } - - float getDropChance() { - return dropChance; - } - - public int getItemID() { - return itemID; + this.dropChance = (rs.getFloat("dropChance")); } } diff --git a/src/engine/objects/Experience.java b/src/engine/objects/Experience.java index 32653186..b153679b 100644 --- a/src/engine/objects/Experience.java +++ b/src/engine/objects/Experience.java @@ -9,13 +9,11 @@ package engine.objects; -import engine.Enum; import engine.Enum.TargetColor; import engine.gameManager.ConfigManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.server.MBServerStatics; -import engine.server.world.WorldServer; import java.util.ArrayList; import java.util.TreeMap; diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index c9c5fb9d..047b2b25 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -9,15 +9,14 @@ package engine.objects; -import engine.Enum; import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; import engine.server.MBServerStatics; -import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -182,32 +181,31 @@ public class LootTable { } //Returns a list of random loot for a mob based on level, lootTable and hotzone - public static ArrayList getMobLoot(Mob mob, int mobLevel, int lootTable, boolean hotzone) { + public static ArrayList getMobLoot(Mob mobile, int mobLevel, int lootTable, boolean hotzone) { - // Member variable declaration - ArrayList loot; + ArrayList mobLoot; int calculatedLootTable; - int roll; + int randomRoll; - // Member variable assignment - loot = new ArrayList<>(); + mobLoot = new ArrayList<>(); // Setup default loot table if none exists + calculatedLootTable = lootTable; LootTable.rollCount++; - if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){ + if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()){ - roll = ThreadLocalRandom.current().nextInt(100); - if (roll > 90) - if (roll > LootTable.oneDropHotZone) - addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, true); + randomRoll = ThreadLocalRandom.current().nextInt(100); + + if (randomRoll > 90) + if (randomRoll > LootTable.oneDropHotZone) + addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true); else - addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, true); + addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true); }else{ - for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){ - + for (MobLootBase mlb:MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())){ float chance = mlb.getChance() *.01f; @@ -215,12 +213,10 @@ public class LootTable { calculatedLootTable = mlb.getLootTableID(); - if (ThreadLocalRandom.current().nextFloat() > chance) continue; - addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, false); - + addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, false); } } @@ -230,62 +226,48 @@ public class LootTable { if (calculatedLootTable <= 1) calculatedLootTable = 1300; // GENERIC WORLD - - - //handle hotzone random loot if (hotzone) { LootTable.rollCount++; - if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){ - - - roll = ThreadLocalRandom.current().nextInt(100); - if (roll > 90) - if (roll > LootTable.oneDropHotZone) - addMobLoot(mob, loot, mobLevel, calculatedLootTable + 1, 1, true); - else - addMobLoot(mob, loot, mobLevel, calculatedLootTable + 1, 1, true); - }else{ - for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){ + if (!MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()) + for (MobLootBase mlb : MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())) { if (!LootTable.lootGroups.containsKey(mlb.getLootTableID() + 1)) continue; calculatedLootTable = mlb.getLootTableID(); break; } - roll = ThreadLocalRandom.current().nextInt(100); - if (roll > 90) - if (roll > LootTable.oneDropHotZone) - addMobLoot(mob, loot, mobLevel, (calculatedLootTable + 1), 1, true); - else - addMobLoot(mob, loot, mobLevel, (calculatedLootTable + 1), 1, true); - } + randomRoll = ThreadLocalRandom.current().nextInt(100); + if (randomRoll > 90) + if (randomRoll > LootTable.oneDropHotZone) + addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true); + else + addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true); } - - - //handle mob specific special loot - handleSpecialLoot(loot, mob, false); - return loot; + ArrayList bootyLoot = getBootyLoot(mobile); + mobLoot.addAll(bootyLoot); + + return mobLoot; } - public static ArrayList getMobLootDeath(Mob mob, int mobLevel, int lootTable) { - ArrayList loot = new ArrayList<>(); + public static ArrayList getMobLootDeath(Mob mobile, int mobLevel, int lootTable) { + ArrayList mobLoot = new ArrayList<>(); - if (mob == null) - return loot; + if (mobile == null) + return mobLoot; //handle hotzone random loot - boolean hotzone = ZoneManager.inHotZone(mob.getLoc()); + boolean hotzone = ZoneManager.inHotZone(mobile.getLoc()); if (hotzone) { - if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){ + if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()){ lootTable += 1; if (lootTable <= 1) @@ -293,11 +275,11 @@ public class LootTable { int roll = ThreadLocalRandom.current().nextInt(100); if (roll > 90) if (roll > LootTable.oneDropHotZone) - addMobLoot(mob, loot, mobLevel, lootTable, 1, true); + addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true); else - addMobLoot(mob, loot, mobLevel, lootTable, 1, true); + addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true); }else{ - for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){ + for (MobLootBase mlb:MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())){ lootTable = mlb.getLootTableID() + 1; if (!LootTable.lootGroups.containsKey(lootTable)) continue; @@ -305,67 +287,54 @@ public class LootTable { int roll = ThreadLocalRandom.current().nextInt(100); if (roll > 90) if (roll > LootTable.oneDropHotZone) - addMobLoot(mob, loot, mobLevel, (lootTable), 1, true); + addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true); else - addMobLoot(mob, loot, mobLevel, (lootTable), 1, true); + addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true); break; } } - if (loot.isEmpty()){ + if (mobLoot.isEmpty()){ LootTable.rollCount++; //add another rollCount here. int resourceRoll = ThreadLocalRandom.current().nextInt(100); if (resourceRoll <=5) - addMobLootResources(mob, loot, mobLevel, (lootTable), 1, true); + addMobLootResources(mobile, mobLoot, mobLevel, (lootTable), 1, true); } } - //handle mob specific special loot on death - handleSpecialLoot(loot, mob, true); + //handle mob specific booty on death - return loot; + ArrayList bootyLoot = getBootyLoot(mobile); + mobLoot.addAll(bootyLoot); + + return mobLoot; } - private static void handleSpecialLoot(ArrayList loot, Mob mob, boolean onDeath) { - - if (SpecialLoot.LootMap.containsKey(mob.getLootSet())) { - ArrayList specialLoot = SpecialLoot.LootMap.get(mob.getLootSet()); - for (SpecialLoot sl : specialLoot) { - if ((onDeath && sl.dropOnDeath()) || (!onDeath && !sl.dropOnDeath())) - if (ThreadLocalRandom.current().nextInt(100) < sl.getDropChance()) { - ItemBase ib = ItemBase.getItemBase(sl.getItemID()); - if (ib != null) { - - switch (ib.getUUID()){ - case 19290: - continue; - case 19291: - continue; - case 19292: - continue; - case 27530: - continue; - case 973000: - continue; - case 973200: - continue; - case 26360: - continue; - } - MobLoot ml = new MobLoot(mob, ib, sl.noSteal()); - loot.add(ml); + private static ArrayList getBootyLoot(Mob mob) { - + ArrayList bootySetList; + ArrayList mobLootList = new ArrayList<>(); - } + if (mob.bootySetID == 0) + return mobLootList; + + bootySetList = NPCManager._bootySetMap.get(mob.bootySetID); + + for (BootySetEntry bootyEntry : bootySetList) + if (ThreadLocalRandom.current().nextInt(100) < bootyEntry.dropChance) { + ItemBase itemBase = ItemBase.getItemBase(bootyEntry.itemBase); + + if (itemBase != null) { + MobLoot mobLoot = new MobLoot(mob, itemBase, true); + mobLootList.add(mobLoot); } } - } + return mobLootList; } @@ -394,40 +363,29 @@ public class LootTable { LootRow modRow = null; // Used for actual generation of items + int itemBaseUUID; ItemBase itemBase = null; MobLoot mobLoot; - Zone zone = mob.getParentZone(); - // Member variable assignment if (!LootTable.lootGroups.containsKey(lootTableID)) return; lootGroup = LootTable.lootGroups.get(lootTableID); - - - - calculatedMobLevel = mobLevel; if (calculatedMobLevel > 49) calculatedMobLevel = 49; - int roll = 0; + int randomRoll = 0; for (int i = 0; i < cnt; i++) { - Random random = new Random(); - - roll = random.nextInt(100) + 1; //random roll between 1 and 100 - groupRow = lootGroup.getLootRow(roll); - - - - + randomRoll = random.nextInt(100) + 1; //random roll between 1 and 100 + groupRow = lootGroup.getLootRow(randomRoll); if (groupRow == null) return; @@ -436,21 +394,13 @@ public class LootTable { if (!LootTable.lootTables.containsKey(groupRow.getValueOne())) return; - lootTable = LootTable.lootTables.get(groupRow.getValueOne()); - //get item ID //FUCK THIS RETARDED SHIT - // roll = gaussianLevel(calculatedMobLevel); - - - - int minRoll = (int) ((calculatedMobLevel - 5) * 5); int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - if (minRoll < (int)lootTable.minRoll){ + if (minRoll < (int)lootTable.minRoll) minRoll = (int)lootTable.minRoll; - } if (maxRoll < minRoll) maxRoll = minRoll; @@ -458,36 +408,30 @@ public class LootTable { if (maxRoll > lootTable.maxRoll) maxRoll = (int) lootTable.maxRoll; - - if (maxRoll > 320) maxRoll = 320; - roll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? + randomRoll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? - - lootRow = lootTable.getLootRow(roll); //get the item row from the bell's curve of level +-15 + lootRow = lootTable.getLootRow(randomRoll); //get the item row from the bell's curve of level +-15 if (lootRow == null) continue; //no item found for roll itemBaseUUID = lootRow.getValueOne(); - - if (lootRow.getValueOne() == 0) continue; //handle quantities > 1 for resource drops + minSpawn = lootRow.getValueTwo(); maxSpawn = lootRow.getValueThree(); - // spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) + // spawnQuantity between min spawn (inclusive) and max spawn (inclusive) if (maxSpawn > 1) spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; - - //get modifierPrefix calculatedMobLevel = mobLevel; @@ -500,20 +444,18 @@ public class LootTable { int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1; - if (chanceMod < 25){ + if (chanceMod < 25) { modGroup = LootTable.modGroups.get(groupRow.getValueTwo()); if (modGroup != null) { - for (int a = 0;a<10;a++){ - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); + randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; + modRow = modGroup.getLootRow(randomRoll); if (modRow != null) break; } - if (modRow != null) { subTableID = modRow.getValueOne(); @@ -521,17 +463,15 @@ public class LootTable { modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int)calculatedMobLevel); - - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; + randomRoll = gaussianLevel((int)calculatedMobLevel); - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; + if (randomRoll < modTable.minRoll) + randomRoll = (int) modTable.minRoll; + if (randomRoll > modTable.maxRoll) + randomRoll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(roll); + modRow = modTable.getLootRow(randomRoll); if (modRow != null) { prefixValue = modRow.getValueOne(); @@ -540,14 +480,14 @@ public class LootTable { } } } - }else if(chanceMod < 50){ + }else if(chanceMod < 50) { modGroup = LootTable.modGroups.get(groupRow.getValueThree()); if (modGroup != null) { for (int a = 0;a<10;a++){ - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); + randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; + modRow = modGroup.getLootRow(randomRoll); if (modRow != null) break; } @@ -559,19 +499,19 @@ public class LootTable { if (LootTable.modTables.containsKey(subTableID)) { modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int)calculatedMobLevel); + randomRoll = gaussianLevel((int)calculatedMobLevel); - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; + if (randomRoll < modTable.minRoll) + randomRoll = (int) modTable.minRoll; - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; + if (randomRoll > modTable.maxRoll) + randomRoll = (int) modTable.maxRoll; - modRow = modTable.getLootRow(roll); + modRow = modTable.getLootRow(randomRoll); - if (modRow == null){ + if (modRow == null) modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f)); - } + if (modRow != null) { suffixValue = modRow.getValueOne(); @@ -586,9 +526,9 @@ public class LootTable { if (modGroup != null) { - for (int a = 0;a<10;a++){ - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); + for (int a = 0;a<10;a++) { + randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; + modRow = modGroup.getLootRow(randomRoll); if (modRow != null) break; } @@ -601,21 +541,18 @@ public class LootTable { modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int)calculatedMobLevel); + randomRoll = gaussianLevel((int)calculatedMobLevel); - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; + if (randomRoll < modTable.minRoll) + randomRoll = (int) modTable.minRoll; - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; + if (randomRoll > modTable.maxRoll) + randomRoll = (int) modTable.maxRoll; + modRow = modTable.getLootRow(randomRoll); - - modRow = modTable.getLootRow(roll); - - if (modRow == null){ + if (modRow == null) modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f)); - } if (modRow != null) { prefixValue = modRow.getValueOne(); @@ -631,8 +568,8 @@ public class LootTable { if (modGroup != null) { for (int a = 0;a<10;a++){ - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); + randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; + modRow = modGroup.getLootRow(randomRoll); if (modRow != null) break; } @@ -644,19 +581,18 @@ public class LootTable { if (LootTable.modTables.containsKey(subTableID)) { modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int)calculatedMobLevel); + randomRoll = gaussianLevel((int)calculatedMobLevel); - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; + if (randomRoll < modTable.minRoll) + randomRoll = (int) modTable.minRoll; - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; + if (randomRoll > modTable.maxRoll) + randomRoll = (int) modTable.maxRoll; - modRow = modTable.getLootRow(roll); + modRow = modTable.getLootRow(randomRoll); - if (modRow == null){ + if (modRow == null) modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f)); - } if (modRow != null) { suffixValue = modRow.getValueOne(); @@ -667,7 +603,6 @@ public class LootTable { } } - itemBase = ItemBase.getItemBase(itemBaseUUID); if (itemBase == null) @@ -676,19 +611,6 @@ public class LootTable { //Handle logging of drops LootTable.HandleDropLogs(itemBase); - - - - // Handle drop rates of resources/runes/contracts. - // We intentionally drop them in half - // if ((itemBase.getMessageType() == ItemType.CONTRACT) || - // (itemBase.getMessageType() == ItemType.RUNE) ){ - // if (ThreadLocalRandom.current().nextBoolean() == false) - // continue; - // } - - - if (itemBase.getType() == ItemType.OFFERING) spawnQuanity = 1; @@ -702,12 +624,11 @@ public class LootTable { if (!modifierSuffix.isEmpty()) mobLoot.addPermanentEnchantment(modifierSuffix, 0, suffixValue, false); + mobLoot.loadEnchantments(); loot.add(mobLoot); - - } } @@ -718,28 +639,18 @@ public class LootTable { int minSpawn; int maxSpawn; int spawnQuanity = 0; - int prefixValue = 0; - int suffixValue = 0; - int subTableID; - String modifierPrefix = ""; - String modifierSuffix = ""; // Lookup Table Variables LootTable lootTable; LootRow lootRow; LootTable lootGroup; LootRow groupRow = null; - LootTable modTable; - LootTable modGroup; - LootRow modRow = null; // Used for actual generation of items int itemBaseUUID; ItemBase itemBase; MobLoot mobLoot; - Zone zone = mob.getParentZone(); - // Member variable assignment if (!LootTable.lootGroups.containsKey(lootTableID)) return; @@ -753,8 +664,6 @@ public class LootTable { int roll = 0; for (int i = 0; i < cnt; i++) { - - if (lootTableID == 1901) groupRow = lootGroup.getLootRow(66); else if (lootTableID == 1501) @@ -762,38 +671,25 @@ public class LootTable { else groupRow = lootGroup.getLootRow(80); - - - - if (groupRow == null) return; //get loot table for this group + if (!LootTable.lootTables.containsKey(groupRow.getValueOne())) return; - lootTable = LootTable.lootTables.get(groupRow.getValueOne()); - //get item ID //FUCK THIS RETARDED SHIT - // roll = gaussianLevel(calculatedMobLevel); - - - - int minRoll = (int) ((calculatedMobLevel-5) * 5); int maxRoll = (int) ((calculatedMobLevel + 15) *5); - if (minRoll < (int)lootTable.minRoll){ + if (minRoll < (int)lootTable.minRoll) minRoll = (int)lootTable.minRoll; - } if (maxRoll < minRoll) maxRoll = minRoll; - - if (maxRoll > 320) maxRoll = 320; @@ -809,19 +705,21 @@ public class LootTable { continue; //handle quantities > 1 for resource drops + minSpawn = lootRow.getValueTwo(); maxSpawn = lootRow.getValueThree(); // spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) + if (maxSpawn > 1) spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; - itemBase = ItemBase.getItemBase(itemBaseUUID); + if (itemBase == null) return; - LootTable.HandleDropLogs(itemBase); + LootTable.HandleDropLogs(itemBase); switch (itemBase.getUUID()){ case 19290: @@ -844,8 +742,6 @@ public class LootTable { // Handle drop rates of resources/runes/contracts. // We intentionally drop them in half - - if (itemBase.getType() == ItemType.OFFERING) spawnQuanity = 1; @@ -867,18 +763,8 @@ public class LootTable { } return (level * 5) + ret; - // float useLevel = (float)(level + (ThreadLocalRandom.current().nextGaussian() * 5)); - // - // if (useLevel < (level - 15)) - // useLevel = level - 15; - // else if (useLevel > (level + 15)) - // useLevel = level + 15; - // return (int)(useLevel * 5); - } - - - + } //This set's the drop chances for stat runes. public static void populateStatRuneChances() { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 65d2dd59..020420c7 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,9 +31,7 @@ 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 engine.server.world.WorldServer; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -58,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(); @@ -69,48 +66,46 @@ public class Mob extends AbstractIntelligenceAgent { protected int dbID; //the database ID protected int loadID; protected boolean isMob; - protected MobBase mobBase; + 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; - protected Contract contract; + 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; - private boolean isPlayerGuard = 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 fidalityID = 0; - private int equipmentSetID = 0; - private int lootSet = 0; - private boolean isGuard; - private ArrayList fidelityRunes = null; + public int equipmentSetID = 0; + public int runeSetID = 0; + public int bootySetID = 0; /** * No Id Constructor @@ -257,12 +252,7 @@ public class Mob extends AbstractIntelligenceAgent { int guildID = rs.getInt("mob_guildUID"); - if (this.fidalityID != 0) { - if (this.building != null) - this.guild = this.building.getGuild(); - else - this.guild = Guild.getGuild(guildID); - } else if (this.building != null) + if (this.building != null) this.guild = this.building.getGuild(); else this.guild = Guild.getGuild(guildID); @@ -294,34 +284,15 @@ public class Mob extends AbstractIntelligenceAgent { this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID)); - - this.fidalityID = rs.getInt("fidalityID"); - this.equipmentSetID = rs.getInt("equipmentSet"); + this.runeSetID = rs.getInt("runeSet"); + this.bootySetID = rs.getInt("bootySet"); if (this.contract != null) this.equipmentSetID = this.contract.getEquipmentSet(); - this.lootSet = (rs.getInt("lootSet")); - - if (this.fidalityID != 0) - this.nameOverride = rs.getString("mob_name"); - - if (this.fidalityID != 0) { + this.nameOverride = rs.getString("mob_name"); - Zone parentZone = ZoneManager.getZoneByUUID(this.parentZoneID); - if (parentZone != null) { - this.fidelityRunes = WorldServer.ZoneFidelityMobRunes.get(parentZone.getLoadNum()).get(this.fidalityID); - - if (this.fidelityRunes != null) - for (Integer runeID : this.fidelityRunes) { - if (runeID == 252623) { - this.isGuard = true; - this.noAggro = true; - } - } - } - } } catch (Exception e) { Logger.error(currentID + ""); } @@ -596,8 +567,8 @@ public class Mob extends AbstractIntelligenceAgent { int level = mob.getLevel(); - level = (level < 0) ? 0 : level; - level = (level > 50) ? 50 : level; + level = Math.max(level, 0); + level = Math.min(level, 50); double minGold; double maxGold; @@ -722,30 +693,6 @@ public class Mob extends AbstractIntelligenceAgent { return skill.getModifiedAmount(); } - public static int getBuildingSlot(Mob mob) { - int slot = -1; - - if (mob.building == null) - return -1; - - - BuildingModelBase buildingModel = BuildingModelBase.getModelBase(mob.building.getMeshUUID()); - - if (buildingModel == null) - return -1; - - - if (mob.building.getHirelings().containsKey(mob)) - slot = (mob.building.getHirelings().get(mob)); - - - if (buildingModel.getNPCLocation(slot) == null) - return -1; - - - return slot; - } - public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MBServerStatics.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); @@ -817,58 +764,6 @@ public class Mob extends AbstractIntelligenceAgent { mob.upgradeDateTime = upgradeDateTime; } - public static Vector3fImmutable GetSpawnRadiusLocation(Mob mob) { - - Vector3fImmutable returnLoc = Vector3fImmutable.ZERO; - - if (mob.fidalityID != 0 && mob.building != null) { - - - Vector3fImmutable spawnRadiusLoc = Vector3fImmutable.getRandomPointInCircle(mob.localLoc, mob.spawnRadius); - - Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(mob.building, spawnRadiusLoc); - - return buildingWorldLoc; - - - } else { - - boolean run = true; - - while (run) { - Vector3fImmutable localLoc = new Vector3fImmutable(mob.statLat + mob.parentZone.absX, mob.statAlt + mob.parentZone.absY, mob.statLon + mob.parentZone.absZ); - Vector3fImmutable spawnRadiusLoc = Vector3fImmutable.getRandomPointInCircle(localLoc, mob.spawnRadius); - - //not a roaming mob, just return the random loc. - if (mob.spawnRadius < 12000) - return spawnRadiusLoc; - - Zone spawnZone = ZoneManager.findSmallestZone(spawnRadiusLoc); - //dont spawn roaming mobs in npc cities - if (spawnZone.isNPCCity()) - continue; - - //dont spawn roaming mobs in player cities. - if (spawnZone.isPlayerCity()) - continue; - - //don't spawn mobs in water. - if (HeightMap.isLocUnderwater(spawnRadiusLoc)) - continue; - - run = false; - - return spawnRadiusLoc; - - } - - } - - //shouldn't ever get here. - - return returnLoc; - } - private void clearStatic() { if (this.parentZone != null) @@ -909,7 +804,7 @@ public class Mob extends AbstractIntelligenceAgent { this.level = 1; //add this npc to building - if (this.building != null && this.loadID != 0 && this.fidalityID == 0) { + if (this.building != null && this.loadID != 0 && building.getBlueprintUUID() != 0) { int maxSlots; maxSlots = building.getBlueprint().getSlotsForRank(this.building.getRank()); @@ -955,225 +850,6 @@ public class Mob extends AbstractIntelligenceAgent { Mob.mobMapByDBID.put(this.dbID, this); } - private void initializeSkills() { - - if (this.mobBase.getMobBaseStats() == null) - return; - - long skillVector = this.mobBase.getMobBaseStats().getSkillSet(); - int skillValue = this.mobBase.getMobBaseStats().getSkillValue(); - - if (this.mobBase.getObjectUUID() >= 17233) { - for (CharacterSkills cs : CharacterSkills.values()) { - SkillsBase sb = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(cs.getToken()); - CharacterSkill css = new CharacterSkill(sb, this, 50); - this.skills.put(sb.getName(), css); - } - } else { - for (CharacterSkills cs : CharacterSkills.values()) { - if ((skillVector & cs.getFlag()) != 0) { - SkillsBase sb = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(cs.getToken()); - CharacterSkill css = new CharacterSkill(sb, this, skillValue); - this.skills.put(sb.getName(), css); - } - } - } - } - - private void initializeStaticEffects() { - - EffectsBase eb = null; - for (MobBaseEffects mbe : this.mobBase.getRaceEffectsList()) { - - eb = PowersManager.getEffectByToken(mbe.getToken()); - - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (this.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) this.level) - continue; - - Effect eff = this.effects.get(Integer.toString(eb.getUUID())); - - if (eff == null) - continue; - - if (eff.getTrains() > mbe.getRank()) - continue; - - //new effect is of a higher rank. remove old effect and apply new one. - eff.cancelJob(); - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { - if (mbe.getReqLvl() > (int) this.level) - continue; - - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - - //Apply all rune effects. - // Only Captains have contracts - if (contract != null || this.isPlayerGuard) { - RuneBase guardRune = RuneBase.getRuneBase(252621); - for (MobBaseEffects mbe : guardRune.getEffectsList()) { - - eb = PowersManager.getEffectByToken(mbe.getToken()); - - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (this.effects.containsKey(Integer.toString(eb.getUUID()))) { - - if (mbe.getReqLvl() > (int) this.level) - continue; - - Effect eff = this.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(); - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { - - if (mbe.getReqLvl() > (int) this.level) - continue; - - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - - RuneBase WarriorRune = RuneBase.getRuneBase(2518); - for (MobBaseEffects mbe : WarriorRune.getEffectsList()) { - - eb = PowersManager.getEffectByToken(mbe.getToken()); - - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (this.effects.containsKey(Integer.toString(eb.getUUID()))) { - - if (mbe.getReqLvl() > (int) this.level) - continue; - - Effect eff = this.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(); - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { - - if (mbe.getReqLvl() > (int) this.level) - continue; - - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - } - - if (this.fidelityRunes != null) { - - for (int fidelityRune : this.fidelityRunes) { - - RuneBase rune = RuneBase.getRuneBase(fidelityRune); - - if (rune != null) - for (MobBaseEffects mbe : rune.getEffectsList()) { - - eb = PowersManager.getEffectByToken(mbe.getToken()); - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (this.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) this.level) - continue; - - Effect eff = this.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(); - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - - } else { - - if (mbe.getReqLvl() > (int) this.level) - continue; - - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - } - } else - for (RuneBase rune : this.mobBase.getRunes()) { - for (MobBaseEffects mbe : rune.getEffectsList()) { - - eb = PowersManager.getEffectByToken(mbe.getToken()); - if (eb == null) { - Logger.info("EffectsBase Null for Token " + mbe.getToken()); - continue; - } - - //check to upgrade effects if needed. - if (this.effects.containsKey(Integer.toString(eb.getUUID()))) { - if (mbe.getReqLvl() > (int) this.level) - continue; - - Effect eff = this.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(); - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } else { - - if (mbe.getReqLvl() > (int) this.level) - continue; - - this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true); - } - } - } - } - /* * Getters */ @@ -1259,16 +935,29 @@ public class Mob extends AbstractIntelligenceAgent { public void setParentZone(Zone zone) { - if (this.parentZone == null) { + if (this.parentZone == null){ zone.zoneMobSet.add(this); this.parentZone = zone; } - this.bindLoc = Mob.GetSpawnRadiusLocation(this); - this.lastBindLoc = bindLoc; - this.setLoc(bindLoc); - this.stopMovement(bindLoc); - } + + if ( this.building != null) { + + Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat,this.statAlt,this.statLon); + Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, localLoc); + this.setBindLoc(buildingWorldLoc); + this.setLoc(buildingWorldLoc); + this.endLoc = buildingWorldLoc; + this.stopMovement(endLoc); + return; + } + + Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat + zone.absX, this.statAlt + zone.absY, this.statLon + zone.absZ); + this.setBindLoc(localLoc); + this.setLoc(localLoc); + this.endLoc = localLoc; + this.stopMovement(endLoc); + } public int getParentZoneID() { @@ -1588,7 +1277,6 @@ public class Mob extends AbstractIntelligenceAgent { if (chance <= me.getDropChance()) { MobLoot ml = new MobLoot(this, me.getItemBase(), false); - ml.setFidelityEquipID(me.getObjectUUID()); this.charItemManager.addItemToInventory(ml); } } @@ -1627,14 +1315,11 @@ public class Mob extends AbstractIntelligenceAgent { this.combatTarget = null; this.isAlive.set(true); - if (!this.isSiege) - this.lastBindLoc = Mob.GetSpawnRadiusLocation(this); - else - this.lastBindLoc = this.bindLoc; + this.lastBindLoc = this.bindLoc; this.bindLoc = this.lastBindLoc; this.setLoc(this.lastBindLoc); this.stopMovement(this.lastBindLoc); - this.initializeStaticEffects(); + NPCManager.applyRuneSetEffects(this); this.recalculateStats(); this.setHealth(this.healthMax); @@ -1642,8 +1327,6 @@ public class Mob extends AbstractIntelligenceAgent { if (!this.isSiege && !this.isPlayerGuard && contract == null) loadInventory(); - // LoadJob.getInstance(); - // LoadJob.forceLoad(this); } public void despawn() { @@ -2265,10 +1948,6 @@ public class Mob extends AbstractIntelligenceAgent { } - public Vector3fImmutable getInBuildingLoc() { - return inBuildingLoc; - } - public ItemBase getWeaponItemBase(boolean mainHand) { if (this.equipmentSetID != 0) { @@ -2338,14 +2017,7 @@ public class Mob extends AbstractIntelligenceAgent { } try { - this.initializeStaticEffects(); - - try { - this.initializeSkills(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - + NPCManager.applyRuneSetEffects(this); recalculateStats(); this.setHealth(this.healthMax); @@ -2392,10 +2064,6 @@ public class Mob extends AbstractIntelligenceAgent { this.timeToSpawnSiege = timeToSpawnSiege; } - public AbstractCharacter getNpcOwner() { - return npcOwner; - } - public void setNpcOwner(AbstractCharacter npcOwner) { this.npcOwner = npcOwner; } @@ -2428,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); @@ -2523,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; } @@ -2555,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; } @@ -2583,10 +2160,6 @@ public class Mob extends AbstractIntelligenceAgent { return siegeMinionMap; } - public Building getBuilding() { - return this.building; - } - public DateTime getUpgradeDateTime() { lock.readLock().lock(); @@ -2598,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; } @@ -2776,10 +2219,6 @@ public class Mob extends AbstractIntelligenceAgent { this.lootSync = lootSync; } - public int getFidalityID() { - return fidalityID; - } - public HashMap getEquip() { return equip; } @@ -2788,14 +2227,6 @@ public class Mob extends AbstractIntelligenceAgent { return equipmentSetID; } - public int getLootSet() { - return lootSet; - } - - public boolean isGuard() { - return this.isGuard; - } - public String getNameOverride() { return nameOverride; } @@ -2806,7 +2237,7 @@ public class Mob extends AbstractIntelligenceAgent { try { - building = this.getBuilding(); + building = this.building; // Cannot upgrade an npc not within a building @@ -2884,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; } @@ -2941,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); } @@ -2973,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/MobBase.java b/src/engine/objects/MobBase.java index 2c4bf960..32ecdef4 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -12,6 +12,7 @@ package engine.objects; import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import engine.server.MBServerStatics; import java.sql.ResultSet; @@ -128,7 +129,6 @@ public class MobBase extends AbstractGameObject { if (Enum.MobFlagType.RAT.elementOf(this.flags)) this.mask += MBServerStatics.MASK_RAT; - this.runes = DbManager.MobBaseQueries.LOAD_RUNES_FOR_MOBBASE(this.loadID); this.raceEffectsList = DbManager.MobBaseQueries.LOAD_STATIC_EFFECTS(this.loadID); this.mobBaseStats = DbManager.MobBaseQueries.LOAD_STATS(this.loadID); DbManager.MobBaseQueries.LOAD_ALL_MOBBASE_LOOT(this.loadID); @@ -144,14 +144,14 @@ public class MobBase extends AbstractGameObject { if (equipmentSetID == 0) return equip; - equipList = EquipmentSetEntry.EquipmentSetMap.get(equipmentSetID); + equipList = NPCManager._equipmentSetMap.get(equipmentSetID); if (equipList == null) return equip; for (EquipmentSetEntry equipmentSetEntry : equipList) { - MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.getItemID(), equipmentSetEntry.getDropChance()); + MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemID, equipmentSetEntry.dropChance); ItemBase itemBase = mobEquipment.getItemBase(); if (itemBase != null) { @@ -174,10 +174,6 @@ public class MobBase extends AbstractGameObject { this.raceEffectsList = DbManager.MobBaseQueries.LOAD_STATIC_EFFECTS(this.getObjectUUID()); } - public void updateRunes() { - this.runes = DbManager.MobBaseQueries.LOAD_RUNES_FOR_MOBBASE(this.getObjectUUID()); - } - public void updatePowers() { this.staticPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getObjectUUID()); } diff --git a/src/engine/objects/MobBaseStats.java b/src/engine/objects/MobBaseStats.java index 60a4681a..95ba2f7c 100644 --- a/src/engine/objects/MobBaseStats.java +++ b/src/engine/objects/MobBaseStats.java @@ -12,8 +12,6 @@ package engine.objects; import java.sql.ResultSet; import java.sql.SQLException; - - public class MobBaseStats { private final int baseStr; @@ -21,8 +19,6 @@ public class MobBaseStats { private final int baseCon; private final int baseSpi; private final int baseDex; - private final long skillSet; - private final int skillValue; public static MobBaseStats mbs = null; @@ -35,8 +31,6 @@ public class MobBaseStats { this.baseCon = rs.getInt("Constitution"); this.baseSpi = rs.getInt("Spirit"); this.baseDex = rs.getInt("Dexterity"); - this.skillSet = rs.getLong("baseSkills"); - this.skillValue = rs.getInt("skillAmount"); } /** @@ -49,8 +43,6 @@ public class MobBaseStats { this.baseCon = 0; this.baseSpi = 0; this.baseDex = 0; - this.skillSet = 0; - this.skillValue = 0; } public int getBaseStr() { return baseStr; @@ -75,14 +67,6 @@ public class MobBaseStats { public int getBaseDex() { return baseDex; } - - public long getSkillSet() { - return skillSet; - } - - public int getSkillValue() { - return skillValue; - } public static MobBaseStats GetGenericStats(){ if (mbs != null) diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index 2a9c18ba..4f192888 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -34,9 +34,6 @@ public final class MobLoot extends Item { private String prefix = ""; private String suffix = ""; - private int fidelityEquipID = 0; - - /** * Create a new MobLoot. * Do not use this to create Gold. @@ -395,14 +392,4 @@ public final class MobLoot extends Item { this.suffix = suffix; } - public int getFidelityEquipID() { - return fidelityEquipID; - } - - public void setFidelityEquipID(int fidelityEquipID) { - this.fidelityEquipID = fidelityEquipID; - } - - - } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 2d2698fc..36c90f31 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -89,12 +89,12 @@ public class NPC extends AbstractCharacter { private int parentZoneID; public ArrayList forgedItems = new ArrayList<>(); - private int fidalityID; private int buildingLevel; private int buildingFloor; public HashMap equip = null; private String nameOverride = ""; private int equipmentSetID = 0; + public int runeSetID = 0; private int slot; private Regions region = null; @@ -187,8 +187,8 @@ public class NPC extends AbstractCharacter { this.gridObjectType = GridObjectType.STATIC; this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); - this.fidalityID = (rs.getInt("fidalityID")); this.equipmentSetID = rs.getInt("equipmentSet"); + this.runeSetID = rs.getInt("runeSet"); if (this.equipmentSetID == 0 && this.contract != null) this.equipmentSetID = this.contract.equipmentSet; @@ -200,8 +200,7 @@ public class NPC extends AbstractCharacter { int mobBaseOverride = rs.getInt("npc_raceID"); - if ((this.fidalityID != 0) || (mobBaseOverride != 0)) - this.loadID = mobBaseOverride; + this.loadID = mobBaseOverride; this.mobBase = MobBase.getMobBase(this.loadID); this.level = rs.getByte("npc_level"); @@ -211,9 +210,6 @@ public class NPC extends AbstractCharacter { try{ this.building = BuildingManager.getBuilding(buildingID); - if (this.building != null) - this.building.fidelityNpcs.put(currentID, this.building.fidelityNpcs.size() + 1); - }catch(Exception e){ this.building = null; Logger.error( e.getMessage()); @@ -251,12 +247,6 @@ public class NPC extends AbstractCharacter { int guildID = rs.getInt("npc_guildID"); - if (this.fidalityID != 0){ - if (this.building != null) - this.guild = this.building.getGuild(); - else - this.guild = Guild.getGuild(guildID); - }else if (this.building != null) this.guild = this.building.getGuild(); else @@ -264,9 +254,8 @@ public class NPC extends AbstractCharacter { if (guildID != 0 && (this.guild == null || this.guild.isEmptyGuild())) NPC.Oprhans.add(currentID); - else if(this.building == null && buildingID > 0) { + else if(this.building == null && buildingID > 0) NPC.Oprhans.add(currentID); - } if (this.guild == null) this.guild = Guild.getErrantGuild(); @@ -290,8 +279,8 @@ public class NPC extends AbstractCharacter { this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID)); - if (this.fidalityID != 0) - this.nameOverride = rs.getString("npc_name"); + + this.nameOverride = rs.getString("npc_name"); }catch(Exception e){ Logger.error(e); @@ -365,7 +354,7 @@ public class NPC extends AbstractCharacter { } //add this npc to building - if (this.building != null && this.loadID != 0 && this.fidalityID == 0) { + if (this.building != null && this.loadID != 0) { if (building.getBlueprint() != null){ @@ -808,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(); @@ -1173,9 +1162,6 @@ public class NPC extends AbstractCharacter { if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; - if (this.fidalityID != 0) - DbManager.NPCQueries.LOAD_RUNES_FOR_FIDELITY_NPC(this); - try{ this.equip = loadEquipmentSet(this.equipmentSetID); @@ -1475,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; } @@ -1619,10 +1605,6 @@ public class NPC extends AbstractCharacter { return true; } - public int getFidalityID() { - return fidalityID; - } - public int getBuildingLevel() { return buildingLevel; } @@ -1648,21 +1630,12 @@ public class NPC extends AbstractCharacter { if (buildingModel == null) return -1; - if (npc.fidalityID != 0){ - - if (npc.building.fidelityNpcs.get(npc.currentID) != null){ - slot = npc.building.fidelityNpcs.get(npc.currentID); - } - - } else{ - if (npc.building.getHirelings().containsKey(npc)) - slot = (npc.building.getHirelings().get(npc)); - } + if (npc.building.getHirelings().containsKey(npc)) + slot = (npc.building.getHirelings().get(npc)); if (buildingModel.getNPCLocation(slot) == null) return -1; - return slot; } @@ -1681,7 +1654,7 @@ public class NPC extends AbstractCharacter { public static boolean UpdateEquipSetID(NPC npc, int equipSetID){ - if (!EquipmentSetEntry.EquipmentSetMap.containsKey(equipSetID)) + if (!NPCManager._equipmentSetMap.containsKey(equipSetID)) return false; if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID)) 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/objects/Resists.java b/src/engine/objects/Resists.java index c084f5c6..5e5fae0b 100644 --- a/src/engine/objects/Resists.java +++ b/src/engine/objects/Resists.java @@ -16,13 +16,11 @@ import engine.Enum.SourceType; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; import engine.powers.EffectsBase; -import engine.powers.effectmodifiers.ArmorPiercingEffectModifier; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; diff --git a/src/engine/objects/Runegate.java b/src/engine/objects/Runegate.java index 59da6d10..d3434b70 100644 --- a/src/engine/objects/Runegate.java +++ b/src/engine/objects/Runegate.java @@ -1,7 +1,6 @@ package engine.objects; import engine.Enum; -import engine.Enum.PortalType; import engine.gameManager.DbManager; import engine.net.ByteBufferWriter; diff --git a/src/engine/objects/SpecialLoot.java b/src/engine/objects/SpecialLoot.java deleted file mode 100644 index 8afa6657..00000000 --- a/src/engine/objects/SpecialLoot.java +++ /dev/null @@ -1,77 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.gameManager.DbManager; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; - -public class SpecialLoot extends AbstractGameObject { - - private int itemID; - private int dropChance; - private boolean dropOnDeath; - private boolean noSteal; - private int lootSetID; - - public static HashMap> LootMap = new HashMap<>(); - /** - * ResultSet Constructor - */ - public SpecialLoot(ResultSet rs) throws SQLException { - super(rs); - this.itemID = rs.getInt("itemID"); - this.dropChance = rs.getInt("dropChance"); - this.dropOnDeath = rs.getBoolean("dropOnDeath"); - this.noSteal = rs.getBoolean("noSteal"); - } - - public SpecialLoot(ResultSet rs,boolean specialLoot) throws SQLException { - super(rs); - - this.lootSetID = rs.getInt("lootSet"); - this.itemID = rs.getInt("itemID"); - this.dropChance = rs.getInt("dropChance"); - this.dropOnDeath = false; - this.noSteal = true; - } - - /* - * Getters - */ - - public int getItemID() { - return this.itemID; - } - - public int getDropChance() { - return this.dropChance; - } - - public boolean dropOnDeath() { - return this.dropOnDeath; - } - - public boolean noSteal() { - return this.noSteal; - } - - public static ArrayList getSpecialLoot(int mobbaseID) { - return DbManager.SpecialLootQueries.GET_SPECIALLOOT(mobbaseID); - } - - @Override - public void updateDatabase() { - - } -} \ No newline at end of file diff --git a/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java b/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java index cc50dc66..3baf4e6f 100644 --- a/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java +++ b/src/engine/powers/effectmodifiers/DurabilityEffectModifier.java @@ -9,13 +9,14 @@ package engine.powers.effectmodifiers; -import engine.Enum; import engine.jobs.AbstractEffectJob; -import engine.objects.*; +import engine.objects.AbstractCharacter; +import engine.objects.AbstractWorldObject; +import engine.objects.Building; +import engine.objects.Item; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.concurrent.ConcurrentHashMap; public class DurabilityEffectModifier extends AbstractEffectModifier { 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/powers/poweractions/RunegateTeleportPowerAction.java b/src/engine/powers/poweractions/RunegateTeleportPowerAction.java index c41db745..ef728452 100644 --- a/src/engine/powers/poweractions/RunegateTeleportPowerAction.java +++ b/src/engine/powers/poweractions/RunegateTeleportPowerAction.java @@ -10,7 +10,6 @@ package engine.powers.poweractions; import engine.Enum; -import engine.Enum.PortalType; import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e5e99e67..256b14eb 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -60,7 +60,6 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Timer; @@ -74,7 +73,6 @@ public class WorldServer { // Member variable declaration - public static HashMap>> ZoneFidelityMobRunes = new HashMap<>(); public WorldServer() { super(); } @@ -285,14 +283,17 @@ public class WorldServer { DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); Logger.info("Loading NPC and Mob Equipment Sets"); - EquipmentSetEntry.LoadAllEquipmentSets(); + NPCManager.LoadAllEquipmentSets(); + + Logger.info("Loading NPC and Mob Rune Sets"); + NPCManager.LoadAllRuneSets(); + + Logger.info("Loading Mobile Booty Sets"); + NPCManager.LoadAllBootySets(); Logger.info("Loading Gold Loot for Mobbases"); MobbaseGoldEntry.LoadMobbaseGold(); - Logger.info("Loading fidelity mob runes."); - DbManager.MobQueries.LOAD_RUNES_FOR_FIDELITY_MOBS(); - //load lootTable Logger.info("Loading Loot Tables"); LootTable.populateLootTables(); @@ -338,9 +339,6 @@ public class WorldServer { Blueprint.loadAllDoorNumbers(); Blueprint.loadAllBlueprints(); - Logger.info("Loading Special Loot For Mobs"); - DbManager.SpecialLootQueries.GenerateSpecialLoot(); - Logger.info("Initializing Heightmap data"); HeightMap.loadAlHeightMaps(); @@ -557,7 +555,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); } @@ -680,7 +678,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 diff --git a/src/engine/util/MapLoader.java b/src/engine/util/MapLoader.java index cdc1b503..e13eb553 100644 --- a/src/engine/util/MapLoader.java +++ b/src/engine/util/MapLoader.java @@ -6,7 +6,6 @@ package engine.util; import engine.InterestManagement.RealmMap; import engine.server.MBServerStatics; -import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; import javax.imageio.ImageIO;