diff --git a/src/engine/Enum.java b/src/engine/Enum.java index e98fcabc..aec9e3c6 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2822,7 +2822,6 @@ public class Enum { public enum MobBehaviourType { None(null, false, false, false, false, false), - //Power Power(null, false, true, true, true, false), PowerHelpee(Power, false, true, true, false, true), PowerHelpeeWimpy(Power, true, false, true, false, false), @@ -2847,6 +2846,7 @@ public class Enum { //Independent Types SimpleStandingGuard(null, false, false, false, false, false), Pet1(null, false, false, true, false, false), + SiegeEngine(null, false, false, false, false, false), Simple(null, false, false, true, false, false), Helpee(null, false, true, true, false, true), HelpeeWimpy(null, true, false, true, false, false), @@ -2857,13 +2857,12 @@ public class Enum { HamletGuard(null, false, true, false, false, false), AggroWanderer(null, false, false, true, false, false); - private static HashMap _behaviourTypes = new HashMap<>(); - public MobBehaviourType BehaviourHelperType; - public boolean isWimpy; - public boolean isAgressive; - public boolean canRoam; - public boolean callsForHelp; - public boolean respondsToCallForHelp; + public final MobBehaviourType BehaviourHelperType; + public final boolean isWimpy; + public final boolean isAgressive; + public final boolean canRoam; + public final boolean callsForHelp; + public final boolean respondsToCallForHelp; MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { this.BehaviourHelperType = helpeebehaviourType; @@ -2880,6 +2879,8 @@ public class Enum { MOBILE, PET, CHARMED, + + SIEGEENGINE, GUARD; } } diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index 1368cc5b..178e8b33 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -8,16 +8,17 @@ package engine.InterestManagement; +import com.sun.corba.se.spi.orbutil.fsm.ActionBase; +import com.sun.corba.se.spi.orbutil.fsm.FSM; +import com.sun.corba.se.spi.orbutil.fsm.Input; import engine.Enum; import engine.Enum.DispatchChannel; import engine.Enum.GameObjectType; -import engine.gameManager.ChatManager; import engine.gameManager.GroupManager; import engine.gameManager.PowersManager; import engine.gameManager.SessionManager; import engine.job.JobScheduler; import engine.jobs.RefreshGroupJob; -import engine.math.Vector3fImmutable; import engine.net.AbstractNetMsg; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -27,12 +28,13 @@ import engine.net.client.msg.LoadStructureMsg; import engine.net.client.msg.MoveToPointMsg; import engine.net.client.msg.UnloadObjectsMsg; import engine.objects.*; -import engine.powers.EffectsBase; +import engine.powers.ActionsBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashSet; +import java.util.Map; import static engine.math.FastMath.sqr; @@ -471,7 +473,7 @@ public enum InterestManager implements Runnable { if (awonpc.despawned == true) continue; - awonpc.playerAgroMap.put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), 0f); ((Mob) awonpc).setCombatTarget(null); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); @@ -484,7 +486,7 @@ public enum InterestManager implements Runnable { if (!awonpc.isAlive()) continue; - awonpc.playerAgroMap.put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), 0f); if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE))) ((Mob) awonpc).setCombatTarget(null); @@ -529,15 +531,19 @@ public enum InterestManager implements Runnable { updateStaticList(player, origin); updateMobileList(player, origin); - // apply the 1 box restriction + if(player.level < 10) { + player.setLevel((short) 10); + MobLoot conc = new MobLoot(player,ItemBase.getItemBase(980066),false); + //player.getCharItemManager().addItemToInventory(conc); + player.getCharItemManager().addItemToInventory(conc.promoteToItem(player),1); + player.getCharItemManager().updateInventory(); + } player.isBoxed = false; for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ if(pc.isActive() == false) continue; - if(pc.isEnteredWorld() == false) continue; - if(origin.machineID.equals(pc.getClientConnection().machineID)){ //add deatshroud effect if(pc.isBoxed == true) @@ -546,12 +552,7 @@ public enum InterestManager implements Runnable { return; } } - if(player.getPromotionClass() == null && player.getLevel() < 10){ - player.setLevel((short)10); - MobLoot ml = new MobLoot(player,ItemBase.getItemBase(980066),false); - ml.promoteToItem(player); - player.getCharItemManager().addGoldToInventory(50000, true); - } + } public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) { diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 8e6ffd95..2fc9b64e 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -135,7 +135,11 @@ public class dbItemHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); if (rs.next()) - worked = rs.getBoolean("result"); + try { + worked = rs.getBoolean("result"); + }catch(Exception e){ + return true; + } } catch (SQLException e) { Logger.error(e); @@ -350,7 +354,11 @@ public class dbItemHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); if (rs.next()) - worked = rs.getBoolean("result"); + try { + worked = rs.getBoolean("result"); + } catch(Exception e){ + worked = true; + } } catch (SQLException e) { Logger.error(e); diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index f4c5b854..766335ff 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -28,31 +28,26 @@ public class dbMobHandler extends dbHandlerBase { this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } - public Mob ADD_MOB(Mob toAdd) { + public Mob PERSIST(Mob toAdd) { Mob mobile = null; try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { - preparedStatement.setLong(1, toAdd.getParentZoneID()); - preparedStatement.setInt(2, toAdd.getMobBaseID()); - preparedStatement.setInt(3, toAdd.getGuildUUID()); - preparedStatement.setFloat(4, toAdd.getSpawnX()); - preparedStatement.setFloat(5, toAdd.getSpawnY()); - preparedStatement.setFloat(6, toAdd.getSpawnZ()); + preparedStatement.setLong(1, toAdd.parentZoneUUID); + preparedStatement.setInt(2, toAdd.loadID); + preparedStatement.setInt(3, toAdd.guildUUID); + preparedStatement.setFloat(4, toAdd.bindLoc.x); + preparedStatement.setFloat(5, toAdd.bindLoc.y); + preparedStatement.setFloat(6, toAdd.bindLoc.z); preparedStatement.setInt(7, 0); - preparedStatement.setFloat(8, toAdd.getSpawnRadius()); - preparedStatement.setInt(9, toAdd.getTrueSpawnTime()); - - if (toAdd.getContract() != null) - preparedStatement.setInt(10, toAdd.getContract().getContractID()); - else - preparedStatement.setInt(10, 0); - - preparedStatement.setInt(11, toAdd.getBuildingID()); - preparedStatement.setInt(12, toAdd.getLevel()); - preparedStatement.setString(13, toAdd.getFirstName()); + preparedStatement.setFloat(8, toAdd.spawnRadius); + preparedStatement.setInt(9, toAdd.spawnTime); + preparedStatement.setInt(10, toAdd.contractUUID); + preparedStatement.setInt(11, toAdd.buildingUUID); + preparedStatement.setInt(12, toAdd.level); + preparedStatement.setString(13, toAdd.firstName); ResultSet rs = preparedStatement.executeQuery(); @@ -106,17 +101,17 @@ public class dbMobHandler extends dbHandlerBase { return row_count; } - public void LOAD_PATROL_POINTS(Mob captain) { + public void LOAD_GUARD_MINIONS(Mob guardCaptain) { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) { - preparedStatement.setInt(1, captain.getObjectUUID()); + preparedStatement.setInt(1, guardCaptain.getObjectUUID()); ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { - String name = rs.getString("name"); - Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name); + String minionName = rs.getString("name"); + Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName); if (toCreate == null) return; diff --git a/src/engine/devcmd/cmds/AddMobCmd.java b/src/engine/devcmd/cmds/AddMobCmd.java index ac2fbfa8..d3401151 100644 --- a/src/engine/devcmd/cmds/AddMobCmd.java +++ b/src/engine/devcmd/cmds/AddMobCmd.java @@ -43,7 +43,7 @@ public class AddMobCmd extends AbstractDevCmd { MobBase mb = (MobBase) mobbaseAGO; int loadID = mb.getObjectUUID(); Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100), - null, true, zone, null, 0, "", 1); + null, zone, null, null, "", 1); if (mob != null) { mob.updateDatabase(); this.setResult(String.valueOf(mob.getDBID())); @@ -84,7 +84,7 @@ public class AddMobCmd extends AbstractDevCmd { Mob mob = Mob.createMob(loadID, pc.getLoc(), - null, true, zone, null, 0, "", 1); + null, zone, null, null, "", 1); if (mob != null) { mob.updateDatabase(); ChatManager.chatSayInfo(pc, diff --git a/src/engine/devcmd/cmds/EnchantCmd.java b/src/engine/devcmd/cmds/EnchantCmd.java index 1f23ae86..b03e2b6e 100644 --- a/src/engine/devcmd/cmds/EnchantCmd.java +++ b/src/engine/devcmd/cmds/EnchantCmd.java @@ -11,6 +11,7 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.objects.*; +import engine.powers.EffectsBase; public class EnchantCmd extends AbstractDevCmd { @@ -55,21 +56,9 @@ public class EnchantCmd extends AbstractDevCmd { this.setResult(String.valueOf(item.getObjectUUID())); } else { int cnt = words.length; - for (int i = 1; i < cnt; i++) { - String enchant = words[i]; - boolean valid = true; - for (Effect eff : item.getEffects().values()) { - if (eff.getEffectsBase().getIDString().equals(enchant)) { - throwbackError(pc, "This item already has that enchantment"); - return; - } - } - if (valid) { - item.addPermanentEnchantmentForDev(enchant, rank); - this.setResult(String.valueOf(item.getObjectUUID())); - } else - throwbackError(pc, "Invalid Enchantment. Enchantment must consist of SUF-001 to SUF-328 or PRE-001 to PRE-334. Sent " + enchant + '.'); - } + String enchant = words[1]; + enchant = EffectsBase.getItemEffectsByName(enchant.toLowerCase()); + item.addPermanentEnchantmentForDev(enchant, 0); cim.updateInventory(); } } diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index b3408255..4a26ad0d 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -440,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd { output += "isSummonedPet: true"; else output += "isSummonedPet: false"; - PlayerCharacter owner = targetMob.getOwner(); + + + PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain; if (owner != null) output += " owner: " + owner.getObjectUUID(); output += newline; diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index 7a022384..c0b318c7 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -59,7 +59,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { if (npc != null) { - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); //Mob.getRespawnMap().remove(mob); @@ -151,7 +151,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { if (npc != null) { - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); //Mob.getRespawnMap().remove(mob); diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index 6d13d2b1..c1ee4f85 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -154,7 +154,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { mobA = (Mob) ac; if (npc != null) { - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); //Mob.getRespawnMap().remove(mob); @@ -209,7 +209,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { if (npc.building != null) npc.building.getHirelings().remove(npc); - for (Mob mob : npc.getSiegeMinionMap().keySet()) { + for (Mob mob : npc.siegeMinionMap.keySet()) { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); if (mob.getParentZone() != null) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index f6ef0bb0..7249ee3b 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -51,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { int failures = 0; int goldAmount = 0; - for (int i = 0; i < 100; ++i) { + for (int i = 0; i < 10000; ++i) { try { mob.loadInventory(); diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index bc31e7c2..7e663a06 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -71,7 +71,7 @@ public class SlotTestCmd extends AbstractDevCmd { outString += "Hirelings List:"; for (AbstractCharacter hireling : building.getHirelings().keySet()) - outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling); + outString += "\r\n" + hireling.getName() + "(" + hireling.getObjectUUID() + ") slot : " + building.getHirelings().get(hireling); } diff --git a/src/engine/devcmd/cmds/SplatMobCmd.java b/src/engine/devcmd/cmds/SplatMobCmd.java index cb429b99..44e8114e 100644 --- a/src/engine/devcmd/cmds/SplatMobCmd.java +++ b/src/engine/devcmd/cmds/SplatMobCmd.java @@ -110,7 +110,7 @@ public class SplatMobCmd extends AbstractDevCmd { mobile = Mob.createMob(_mobileUUID, Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange), - null, true, serverZone, null, 0, "", 1); + null, serverZone, null, null, "", 1); if (mobile != null) { mobile.updateDatabase(); diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index e31060bb..4a524c34 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -11,6 +11,7 @@ package engine.devcmd.cmds; import engine.Enum.GameObjectType; import engine.devcmd.AbstractDevCmd; +import engine.gameManager.PowersManager; import engine.objects.AbstractGameObject; import engine.objects.Mob; import engine.objects.PlayerCharacter; @@ -56,36 +57,41 @@ public class aiInfoCmd extends AbstractDevCmd { Mob mob = (Mob) target; output = "Mob AI Information:" + newline; output += mob.getName() + newline; - if (mob.BehaviourType != null) { - output += "BehaviourType: " + mob.BehaviourType.toString() + newline; - if (mob.BehaviourType.BehaviourHelperType != null) { - output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline; + if (mob.behaviourType != null) { + output += "BehaviourType: " + mob.behaviourType.toString() + newline; + if (mob.behaviourType.BehaviourHelperType != null) { + output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline; } else { output += "Behaviour Helper Type: NULL" + newline; - } - output += "Wimpy: " + mob.BehaviourType.isWimpy + newline; - output += "Agressive: " + mob.BehaviourType.isAgressive + newline; - output += "Can Roam: " + mob.BehaviourType.canRoam + newline; - output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline; - output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline; - } else { - output += "BehaviourType: NULL" + newline; + } + output += "Wimpy: " + mob.behaviourType.isWimpy + newline; + output += "Agressive: " + mob.behaviourType.isAgressive + newline; + output += "Can Roam: " + mob.behaviourType.canRoam + newline; + output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline; + output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline; + } else { + output += "BehaviourType: NULL" + newline; } output += "Aggro Range: " + mob.getAggroRange() + newline; output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline; if (mob.playerAgroMap.size() > 0) { output += "Players Loaded:" + newline; } - for (Map.Entry entry : mob.playerAgroMap.entrySet()) { - output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline; + for (Map.Entry entry : mob.playerAgroMap.entrySet()) { + output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline; } if (mob.getCombatTarget() != null) output += "Current Target: " + mob.getCombatTarget().getName() + newline; else output += "Current Target: NULL" + newline; + if (mob.guardedCity != null) + output += "Patrolling: " + mob.guardedCity.getCityName() + newline; + + output += "Powers:" + newline; + for (int token : mob.mobPowers.keySet()) - output += token + newline; + output += PowersManager.getPowerByToken(token).getName() + newline; throwbackInfo(playerCharacter, output); } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 5633df05..2e6e19a8 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -520,9 +520,10 @@ public enum BuildingManager { if (building.getBlueprintUUID() == 0) return false; - if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) + if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) { + Logger.error("failed at addHireling with contract: " + contract.getContractID()); return false; - + } String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); if (item.getChargesRemaining() > 0) @@ -535,7 +536,7 @@ public enum BuildingManager { if (NPC.ISWallArcher(contract)) { - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); if (mob == null) return false; @@ -547,7 +548,7 @@ public enum BuildingManager { if (NPC.ISGuardCaptain(contract.getContractID())) { - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); if (mob == null) return false; @@ -559,7 +560,7 @@ public enum BuildingManager { if (contract.getContractID() == 910) { //guard dog - mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank); + mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); if (mob == null) return false; diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 0587e384..47c50945 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -814,6 +814,9 @@ public enum CombatManager { else damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists); + if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){ + damage *= ((PlayerCharacter)ac).ZergMultiplier; + } float d = 0f; errorTrack = 12; @@ -826,7 +829,8 @@ public enum CombatManager { damage *= 2.5f; //increase damage if sitting if (tarAc.getObjectType() == GameObjectType.Mob) { - ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER); + if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)) + ((Mob)tarAc).playerAgroMap.put(ac.getObjectUUID(), ((Mob) tarAc).playerAgroMap.get(ac.getObjectUUID()) + damage); ((Mob) tarAc).handleDirectAggro(ac); } diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 47ae6cda..acca750b 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -180,7 +180,7 @@ public enum DevCmdManager { //kill any commands not available to everyone on production server //only admin level can run dev commands on production - if (a.status.equals(Enum.AccountStatus.ADMIN) == false) { + if (a.status.equals(Enum.AccountStatus.ADMIN) == false && a.getUname().toLowerCase().equals("fatboy") == false) { Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd); return false; } diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index e19d2eaa..a24d1872 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -17,6 +17,7 @@ import engine.objects.*; import org.pmw.tinylog.Logger; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.concurrent.ThreadLocalRandom; @@ -34,6 +35,11 @@ public enum LootManager { public static HashMap> _modTables = new HashMap<>(); public static HashMap> _modTypeTables = new HashMap<>(); + public static ArrayList vorg_ha_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27580, 27590, 188500, 188510, 188520, 188530, 188540, 188550, 189510})); + public static ArrayList vorg_ma_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27570,188900,188910,188920,188930,188940,188950,189500})); + public static ArrayList vorg_la_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27550,27560,189100,189110,189120,189130,189140,189150})); + public static ArrayList vorg_cloth_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27600,188700,188720,189550,189560})); + // Drop Rates public static float NORMAL_DROP_RATE; @@ -75,16 +81,13 @@ public enum LootManager { public static void GenerateMobLoot(Mob mob) { - //determine if mob is in hotzone - boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); - //iterate the booty sets if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true) - RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone); + RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob); if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true) - RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); + RunBootySet(_bootySetMap.get(mob.bootySet), mob); //lastly, check mobs inventory for godly or disc runes to send a server announcement for (Item it : mob.getInventory()) { @@ -102,38 +105,40 @@ public enum LootManager { } - private static void RunBootySet(ArrayList entries, Mob mob, boolean inHotzone) { + private static void RunBootySet(ArrayList entries, Mob mob) { - boolean hotzoneWasRan = false; - float dropRate = 1.0f; + float dropRate = NORMAL_DROP_RATE; // Iterate all entries in this bootySet and process accordingly for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": - GenerateGoldDrop(mob, bse, inHotzone); + GenerateGoldDrop(mob, bse); break; case "LOOT": - - if (mob.getSafeZone() == false) - dropRate = LootManager.NORMAL_DROP_RATE; - - if (inHotzone == true) - dropRate = LootManager.HOTZONE_DROP_RATE; - if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) - GenerateLootDrop(mob, bse.genTable, false); //generate normal loot drop - - // Generate hotzone loot if in hotzone - // Only one bite at the hotzone apple per bootyset. - - if (inHotzone == true && hotzoneWasRan == false) - if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table - hotzoneWasRan = true; + GenerateLootDrop(mob, bse.genTable); //generate normal loot drop + if(ThreadLocalRandom.current().nextInt(1,101) < mob.level && mob.parentZone.getSafeZone() == 0) { + if (ThreadLocalRandom.current().nextInt(1, 10000) < mob.level) { + if (_genTables.containsKey(bse.genTable + 1)) { + int roll = ThreadLocalRandom.current().nextInt(1, 101); + MobLoot extraLoot = null; + if (roll >= 1 && roll <= 50) { + extraLoot = rollForContract(bse.genTable, mob); + } + if (roll >= 51 && roll <= 94) { + extraLoot = rollForRune(bse.genTable, mob); + } + if (roll >= 95) { + extraLoot = rollForGlass(mob); + } + if (extraLoot != null) { + mob.getCharItemManager().addItemToInventory(extraLoot); + } + } } - + } break; case "ITEM": GenerateInventoryDrop(mob, bse); @@ -142,14 +147,14 @@ public enum LootManager { } } - public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) { + public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob) { if (mob == null || _genTables.containsKey(genTableID) == false) return null; MobLoot outItem; - int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); + int genRoll = ThreadLocalRandom.current().nextInt(1,94 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); @@ -167,7 +172,7 @@ public enum LootManager { if(mob.getObjectType().ordinal() == 52) { //52 = player character itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); } else{ - itemTableRoll = TableRoll(mob.level, inHotzone); + itemTableRoll = TableRoll(mob.level); } ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); if (tableRow == null) @@ -179,6 +184,9 @@ public enum LootManager { return null; if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + int chance = ThreadLocalRandom.current().nextInt(1,101); + if(chance > 5) + return null; int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); } @@ -189,7 +197,7 @@ public enum LootManager { if(selectedRow.pModTable != 0){ try { - outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); + outItem = GeneratePrefix(mob, outItem, genTableID, genRoll); outItem.setIsID(false); } catch (Exception e) { Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); @@ -197,7 +205,7 @@ public enum LootManager { } if(selectedRow.sModTable != 0){ try { - outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); + outItem = GenerateSuffix(mob, outItem, genTableID, genRoll); outItem.setIsID(false); } catch (Exception e) { Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); @@ -206,7 +214,7 @@ public enum LootManager { return outItem; } - private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { + private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) { GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); @@ -223,7 +231,7 @@ public enum LootManager { if(mob.getObjectType().ordinal() == 52) { prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); } else{ - prefixTableRoll = TableRoll(mob.level, inHotzone); + prefixTableRoll = TableRoll(mob.level); } ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); @@ -238,7 +246,7 @@ public enum LootManager { return inItem; } - private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { + private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) { GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); @@ -255,7 +263,7 @@ public enum LootManager { if(mob.getObjectType().ordinal() == 52) { suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); } else{ - suffixTableRoll = TableRoll(mob.level, inHotzone); + suffixTableRoll = TableRoll(mob.level); } ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); @@ -270,7 +278,7 @@ public enum LootManager { return inItem; } - public static int TableRoll(int mobLevel, Boolean inHotzone) { + public static int TableRoll(int mobLevel) { if (mobLevel > 65) mobLevel = 65; @@ -285,15 +293,12 @@ public enum LootManager { if (min < 70) min = 70; - if (inHotzone) - min += mobLevel; - int roll = ThreadLocalRandom.current().nextInt(min, max + 1); return roll; } - public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { + public static void GenerateGoldDrop(Mob mob, BootySetEntry bse) { int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); @@ -304,14 +309,9 @@ public enum LootManager { //determine and add gold to mob inventory - int high = bse.highGold; - int low = bse.lowGold; - int gold = ThreadLocalRandom.current().nextInt(low, high + 1); - - if (inHotzone == true) - gold = (int) (gold * HOTZONE_GOLD_RATE); - else - gold = (int) (gold * NORMAL_GOLD_RATE); + int high = (int)(bse.highGold * NORMAL_GOLD_RATE); + int low = (int)(bse.lowGold * NORMAL_GOLD_RATE); + int gold = ThreadLocalRandom.current().nextInt(low, high); if (gold > 0) { MobLoot goldAmount = new MobLoot(mob, gold); @@ -320,15 +320,16 @@ public enum LootManager { } - public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) { + public static void GenerateLootDrop(Mob mob, int tableID) { try { - MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); + MobLoot toAdd = getGenTableItem(tableID, mob); - if (toAdd != null) + if (toAdd != null) { + toAdd.setIsID(true); mob.getCharItemManager().addItemToInventory(toAdd); - + } } catch (Exception e) { //TODO chase down loot generation error, affects roughly 2% of drops int i = 0; @@ -350,8 +351,24 @@ public enum LootManager { if (equipmentRoll > dropChance) continue; - - MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + ItemBase genericIB = me.getItemBase(); + if(genericIB.isVorg()){ + if(genericIB.isClothArmor()){ + //get random cloth piece + genericIB = ItemBase.getItemBase(vorg_cloth_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_cloth_uuids.size() - 1))); + } else if(genericIB.isHeavyArmor()){ + //get random heavy armor piece + genericIB = ItemBase.getItemBase(vorg_ha_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_ha_uuids.size() - 1))); + } else if(genericIB.isMediumArmor()){ + //get random medium armor piece + genericIB = ItemBase.getItemBase(vorg_ma_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_ma_uuids.size() - 1))); + } else if(genericIB.isLightArmor()){ + //get random light armor piece + genericIB = ItemBase.getItemBase(vorg_la_uuids.get(ThreadLocalRandom.current().nextInt(0,vorg_la_uuids.size() - 1))); + } + mob.spawnTime = ThreadLocalRandom.current().nextInt(300,2700); + } + MobLoot ml = new MobLoot(mob, genericIB, false); if (ml != null && dropCount < 1) { ml.setIsID(true); @@ -461,4 +478,66 @@ public enum LootManager { itemMan.addItemToInventory(playerWinnings); itemMan.updateInventory(); } + + public static MobLoot rollForContract(int table, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(table, 99, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321)); + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null) + return outItem; + return null; + } + public static MobLoot rollForRune(int table, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(table, 97, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321)); + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null) + return outItem; + return null; + } + public static MobLoot rollForGlass( Mob mob){ + ItemTableEntry tableRow = ItemTableEntry.rollTable(126, ThreadLocalRandom.current().nextInt(1,321)); + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + MobLoot outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null) + return outItem; + return null; + } } diff --git a/src/engine/gameManager/MaintenanceManager.java b/src/engine/gameManager/MaintenanceManager.java index f92d531e..c657b124 100644 --- a/src/engine/gameManager/MaintenanceManager.java +++ b/src/engine/gameManager/MaintenanceManager.java @@ -39,7 +39,7 @@ public enum MaintenanceManager { // Build list of buildings to apply maintenance on. - buildingList = new ArrayList(DbManager.getList(Enum.GameObjectType.Building)); + buildingList = new ArrayList(DbManager.getList(Enum.GameObjectType.City)); maintList = buildMaintList(buildingList); // Deduct upkeep and build list of buildings @@ -53,7 +53,10 @@ public enum MaintenanceManager { // Reset maintenance dates for these buildings for (Building building : maintList) { - setMaintDateTime(building, LocalDateTime.now().plusDays(7)); + if(derankList.contains(building) == false) + setMaintDateTime(building, LocalDateTime.now().plusDays(7)); + else + setMaintDateTime(building, LocalDateTime.now().plusDays(1)); } // Derak or destroy buildings that did not @@ -74,7 +77,10 @@ public enum MaintenanceManager { for (AbstractGameObject gameObject : buildingList) { - Building building = (Building) gameObject; + Building building = ((City)gameObject).getTOL();//(Building) gameObject; + + if(building == null) + continue; // No maintenance on NPC owned buildings (Cache loaded) @@ -154,7 +160,8 @@ public enum MaintenanceManager { // Cache maintenance cost value - maintCost = building.getMaintCost(); + //maintCost = building.getMaintCost(); + maintCost = 3000000; // Something went wrong. Missing buildinggroup from switch? @@ -225,9 +232,9 @@ public enum MaintenanceManager { // Add cash back to strongbox for lost rank if the building isn't being destroyed // and it's not an R8 deranking - if ((building.getRank() > 1) && (building.getRank() < 8)) { - building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7))); - } + //if ((building.getRank() > 1) && (building.getRank() < 8)) { + // building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7))); + //} return false; // Early exit for having failed to meet maintenance } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 11deb263..98549265 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -23,14 +23,6 @@ public enum NPCManager { NPC_MANAGER; public static HashMap> _runeSetMap = new HashMap<>(); - public static void LoadAllRuneSets() { - _runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); - } - - public static void LoadAllBootySets() { - LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); - } - public static void applyRuneSetEffects(Mob mob) { // Early exit @@ -127,10 +119,12 @@ public enum NPCManager { DbManager.removeFromCache(necroPet); - PlayerCharacter petOwner = necroPet.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain; if (petOwner != null) { - necroPet.setOwner(null); + + necroPet.guardCaptain = null; petOwner.setPet(null); if (updateOwner == false) @@ -228,12 +222,14 @@ public enum NPCManager { WorldGrid.removeObject(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); @@ -340,10 +336,19 @@ public enum NPCManager { else buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); + // Override slot for siege engines + + if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) { + Mob siegeMobile = (Mob) abstractCharacter; + buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2; + } + if (buildingSlot == -1) Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + // Pets are regular mobiles not hirelings (Siege engines) + if (abstractCharacter.contract != null) + abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived // from BuildingManager slot location data. @@ -370,4 +375,53 @@ public enum NPCManager { return buildingSlot; } + + public static int getMaxMinions(Mob guardCaptain) { + + int maxSlots; + + switch (guardCaptain.getRank()) { + case 3: + maxSlots = 2; + break; + case 4: + case 5: + maxSlots = 3; + break; + case 6: + maxSlots = 4; + break; + case 7: + maxSlots = 5; + break; + case 1: + case 2: + default: + maxSlots = 1; + + } + return maxSlots; + } + + public static void AssignPatrolPoints(Mob mob) { + mob.patrolPoints = new ArrayList<>(); + + for (int i = 0; i < 5; ++i) { + float patrolRadius = mob.getSpawnRadius(); + + if (patrolRadius > 256) + patrolRadius = 256; + + if (patrolRadius < 60) + patrolRadius = 60; + + Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius); + mob.patrolPoints.add(newPatrolPoint); + + if (i == 1) { + mob.loc = newPatrolPoint; + mob.endLoc = newPatrolPoint; + } + } + } } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 37cf9641..e6b2f1cc 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -300,15 +300,15 @@ public enum PowersManager { int time = pb.getRecycleTime(trains); // verify player is in correct mode (combat/nonCombat) - if (playerCharacter.isCombat()) { - if (!pb.allowedInCombat()) + //if (playerCharacter.isCombat()) { + // if (!pb.allowedInCombat()) // ChatManager.chatPowerError(pc, // "This power is not allowed in combat mode."); - return true; - } else if (!pb.allowedOutOfCombat()) + // return true; + //} else if (!pb.allowedOutOfCombat()) // ChatManager.chatPowerError(pc, // "You must be in combat mode to use this power."); - return true; + // return true; // verify player is not stunned or prohibited from casting PlayerBonuses bonus = playerCharacter.getBonuses(); @@ -842,8 +842,6 @@ public enum PowersManager { return; } - playerCharacter.setHateValue(pb.getHateValue(trains)); - //Send Cast Message. // PerformActionMsg castMsg = new PerformActionMsg(msg); // castMsg.setNumTrains(9999); @@ -894,8 +892,6 @@ public enum PowersManager { //Power is aiding a target, handle aggro if combat target is a Mob. if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pcTarget = (PlayerCharacter) target; - if (!pb.isHarmful()) - Mob.HandleAssistedAggro(playerCharacter, pcTarget); } // update target of used power timer @@ -1468,6 +1464,27 @@ public enum PowersManager { HashSet trackChars = RangeBasedAwo.getTrackList( allTargets, playerCharacter, maxTargets); + trackChars = new HashSet<>(); + HashSet allInRange = WorldGrid.getObjectsInRangePartial(playerCharacter.loc,MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_PLAYER); + ArrayList nationsInRange = new ArrayList<>(); + //first round to add players in range + for(AbstractWorldObject trackChar : allInRange){ + if(allInRange.contains(trackChar)) { + trackChars.add((AbstractCharacter)trackChar); + Guild nation = ((AbstractCharacter)trackChar).guild.getNation(); + if(nationsInRange.contains(nation) == false) + nationsInRange.add(nation); + } + } + //second round add all others in window if they share a nation with a current + for(AbstractWorldObject trackChar : allInRange) { + Guild nation = ((AbstractCharacter) trackChar).guild.getNation(); + if (allInRange.contains(trackChar) == true && nationsInRange.add(nation) == true && trackChars.contains(trackChar) == false) + trackChars.add((AbstractCharacter) trackChar); + else if(((AbstractCharacter) trackChar).guild.getNation().equals(playerCharacter.guild.getNation())) + trackChars.add((AbstractCharacter) trackChar); + } + TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg); // send track window diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index d487b8bf..6a7a6773 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -10,7 +10,6 @@ package engine.gameManager; import engine.Enum; import engine.Enum.GameObjectType; -import engine.math.Vector3fImmutable; import engine.objects.*; import org.pmw.tinylog.Logger; @@ -31,7 +30,6 @@ public enum SimulationManager { SERVERHEARTBEAT; private static final long CITY_PULSE = 2000; - private static final long MINE_PULSE = 2000; private static final long RUNEGATE_PULSE = 3000; private static final long UPDATE_PULSE = 1000; private static final long FlIGHT_PULSE = 100; @@ -39,7 +37,7 @@ public enum SimulationManager { public static Duration executionMax = Duration.ofNanos(1); private static SimulationManager instance = null; private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; - private long _minePulseTime = System.currentTimeMillis() + MINE_PULSE; + private long _minePulseTime = System.currentTimeMillis() + CITY_PULSE; private long _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE; @@ -132,18 +130,7 @@ public enum SimulationManager { pulseMines(); } catch (Exception e) { Logger.error( - "Fatal error in City Pulse: DISABLED. Error Message : " - + e.getMessage()); - e.printStackTrace(); - - } - try { - if ((_minePulseTime != 0) - && (System.currentTimeMillis() > _minePulseTime)) - pulseMines(); - } catch (Exception e) { - Logger.error( - "Fatal error in City Pulse: DISABLED. Error Message : " + "Fatal error in Mine Pulse: DISABLED. Error Message : " + e.getMessage()); e.printStackTrace(); @@ -175,8 +162,6 @@ public enum SimulationManager { if (player == null) continue; - - player.update(); } @@ -226,31 +211,9 @@ public enum SimulationManager { city = (City) cityObject; city.onEnter(); } - _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; } - private void pulseMines() { - - Mine mine; - - // *** Refactor: Need a list cached somewhere as it doesn't change very - // often at all. Have a cityListIsDirty boolean that gets set if it - // needs an update. Will speed up this method a great deal. - - Collection mineList = DbManager.getList(Enum.GameObjectType.Mine); - if (mineList == null) { - Logger.info("City List null"); - return; - } - - for (AbstractGameObject mineObject : mineList) { - mine = (Mine) mineObject; - mine.onEnter(); - } - - _minePulseTime = System.currentTimeMillis() + MINE_PULSE; - } /* * Method runs proximity collision detection for all active portals on the * game's Runegates @@ -264,4 +227,21 @@ public enum SimulationManager { _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; } + private void pulseMines(){ + Mine mine; + Collection mineList = DbManager.getList(Enum.GameObjectType.Mine); + + if (mineList == null) { + Logger.info("Mine List null"); + return; + } + + for (AbstractGameObject mineObject : mineList) { + mine = (Mine) mineObject; + if(mine.isActive) + mine.onEnter(); + } + + _minePulseTime = System.currentTimeMillis() + CITY_PULSE; + } } diff --git a/src/engine/gameManager/ZergManager.java b/src/engine/gameManager/ZergManager.java new file mode 100644 index 00000000..c1729d93 --- /dev/null +++ b/src/engine/gameManager/ZergManager.java @@ -0,0 +1,166 @@ +package engine.gameManager; + +public class ZergManager { + public static float getMultiplier5Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + case 2: + multiplier += 0.0f; + break; + case 3: + multiplier += 0.55f; + break; + case 4: + multiplier += 0.2f; + break; + case 5: + multiplier += 0.0f; + break; + case 6: + multiplier -= 0.2f; + break; + case 7: + multiplier -= 0.35f; + break; + case 8: + multiplier -= 0.50f; + break; + case 9: + multiplier -= 0.750f; + break; + default: + multiplier -= 1.0f; + break; + } + return multiplier; + } + + public static float getMultiplier10Man(int count){ + float multiplier = 1.0f; + if(count <=4) + return 0.0f; + switch(count){ + case 5: + multiplier += 0.5f; + break; + case 6: + multiplier += 0.4f; + break; + case 7: + multiplier += 0.3f; + break; + case 8: + multiplier += 0.2f; + break; + case 9: + multiplier += 0.1f; + break; + case 10: + multiplier += 0.0f; + break; + case 11: + multiplier -= 0.1f; + break; + case 12: + multiplier -= 0.2f; + break; + case 13: + multiplier -= 0.3f; + break; + case 14: + multiplier -= 0.4f; + break; + case 15: + multiplier -= 0.5f; + break; + case 16: + multiplier -= 0.65f; + break; + case 17: + multiplier -= 0.75f; + break; + case 18: + multiplier -= 0.85f; + break; + default: + multiplier -= 1.0f; + break; + } + return multiplier; + } + + public static float getMultiplier20Man(int count){ + float multiplier = 1.0f; + if(count < 10){ + multiplier += 1.25f; + }else { + switch (count) { + case 10: + multiplier += 0.8f; + break; + case 11: + multiplier += 0.65f; + break; + case 12: + multiplier += 0.54f; + break; + case 13: + multiplier += 0.46f; + break; + case 14: + multiplier += 0.36f; + break; + case 15: + multiplier += 0.28f; + break; + case 16: + multiplier += 0.21f; + break; + case 17: + multiplier += 0.15f; + break; + case 18: + multiplier += 0.09f; + break; + case 19: + multiplier += 0.04f; + break; + case 20: + multiplier += 0.00f; + break; + case 21: + multiplier -= 0.04f; + break; + case 22: + multiplier -= 0.09f; + break; + case 23: + multiplier -= 0.15f; + break; + case 24: + multiplier -= 0.21f; + break; + case 25: + multiplier -= 0.28f; + break; + case 26: + multiplier -= 0.36f; + break; + case 27: + multiplier -= 0.46f; + break; + case 28: + multiplier -= 0.54f; + break; + case 29: + multiplier -= 0.65f; + break; + default: + multiplier -= 0.75f; + break; + } + } + return multiplier; + } +} diff --git a/src/engine/jobs/EndFearJob.java b/src/engine/jobs/EndFearJob.java index fef762d5..f88a4850 100644 --- a/src/engine/jobs/EndFearJob.java +++ b/src/engine/jobs/EndFearJob.java @@ -29,7 +29,7 @@ public class EndFearJob extends AbstractEffectJob { if (this.target == null || (!(this.target instanceof Mob))) return; - ((Mob) this.target).setFearedObject(null); + ((Mob) this.target).fearedObject = null; } @Override @@ -40,6 +40,6 @@ public class EndFearJob extends AbstractEffectJob { if (this.target == null || (!(this.target instanceof Mob))) return; - ((Mob) this.target).setFearedObject(null); + ((Mob) this.target).fearedObject = null; } } diff --git a/src/engine/loot/ModTableEntry.java b/src/engine/loot/ModTableEntry.java index 86697880..d72f5f32 100644 --- a/src/engine/loot/ModTableEntry.java +++ b/src/engine/loot/ModTableEntry.java @@ -34,10 +34,15 @@ public class ModTableEntry { itemTableEntryList = LootManager._modTables.get(modTablwe); - for (ModTableEntry iteration : itemTableEntryList) + if(itemTableEntryList == null) + return null; + + for (ModTableEntry iteration : itemTableEntryList) { + if (iteration == null) + continue; if (roll >= iteration.minRoll && roll <= iteration.maxRoll) modTableEntry = iteration; - + } return modTableEntry; } } diff --git a/src/engine/math/Bounds.java b/src/engine/math/Bounds.java index 04998e1c..47bf9f07 100644 --- a/src/engine/math/Bounds.java +++ b/src/engine/math/Bounds.java @@ -220,7 +220,7 @@ public class Bounds { //player is inside building region, skip collision check. we only do collision from the outside. if (player.region != null && player.region.parentBuildingID == building.getObjectUUID()) continue; - if (building.getBounds().colliders == null) + if (building.getBounds() == null || building.getBounds().colliders == null) continue; for (Colliders collider : building.getBounds().colliders) { diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index b4543321..1a26cd0b 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -96,7 +96,7 @@ public class MobAI { return; } - if (mob.BehaviourType.callsForHelp) + if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); if (!MovementUtilities.inRangeDropAggro(mob, target)) { @@ -155,7 +155,9 @@ public class MobAI { public static void AttackBuilding(Mob mob, Building target) { try { - + if(target == null){ + return; + } if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { mob.setCombatTarget(null); return; @@ -165,7 +167,7 @@ public class MobAI { if (playercity != null) for (Mob guard : playercity.getParent().zoneMobSet) - if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) + if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild())) guard.setCombatTarget(mob); @@ -202,6 +204,7 @@ public class MobAI { } } catch (Exception e) { + mob.setCombatTarget(null); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); } } @@ -260,7 +263,7 @@ public class MobAI { //guard captains inherit barracks patrol points dynamically - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { Building barracks = mob.building; @@ -280,7 +283,7 @@ public class MobAI { MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) for (Entry minion : mob.siegeMinionMap.entrySet()) //make sure mob is out of combat stance @@ -312,9 +315,9 @@ public class MobAI { int contractID; - if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) - contractID = mob.npcOwner.contract.getContractID(); - else + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) + contractID = mob.guardCaptain.contract.getContractID(); + else contractID = mob.contract.getContractID(); if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false) @@ -350,7 +353,7 @@ public class MobAI { ArrayList purgeTokens; AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); - if (mob.BehaviourType.callsForHelp) + if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); // Generate a list of tokens from the mob powers for this mobile. @@ -433,7 +436,7 @@ public class MobAI { ArrayList purgeTokens; AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); - if (mob.BehaviourType.callsForHelp) + if (mob.behaviourType.callsForHelp) MobCallForHelp(mob); // Generate a list of tokens from the mob powers for this mobile. @@ -564,7 +567,7 @@ public class MobAI { Zone mobCamp = mob.getParentZone(); for (Mob helper : mobCamp.zoneMobSet) { - if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) { + if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) { helper.setCombatTarget(mob.getCombatTarget()); callGotResponse = true; } @@ -608,8 +611,8 @@ public class MobAI { if (mob.despawned && mob.isPlayerGuard) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { - if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { + if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) { //minions don't respawn while guard captain is dead @@ -625,7 +628,7 @@ public class MobAI { //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting - if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) + if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); return; @@ -646,7 +649,7 @@ public class MobAI { return; } - if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) + if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) CheckToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -673,7 +676,7 @@ public class MobAI { } } - switch (mob.BehaviourType) { + switch (mob.behaviourType) { case GuardCaptain: GuardCaptainLogic(mob); break; @@ -684,6 +687,7 @@ public class MobAI { GuardWallArcherLogic(mob); break; case Pet1: + case SiegeEngine: PetLogic(mob); break; case HamletGuard: @@ -693,8 +697,6 @@ public class MobAI { DefaultLogic(mob); break; } - if(mob.isAlive()) - RecoverHealth(mob); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); } @@ -709,7 +711,7 @@ public class MobAI { if (!aiAgent.isAlive()) return; - ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; for (Entry playerEntry : loadedPlayers.entrySet()) { @@ -784,33 +786,39 @@ public class MobAI { mob.updateLocation(); - switch (mob.BehaviourType) { + switch (mob.behaviourType) { case Pet1: - if (mob.getOwner() == null) + + + if ((PlayerCharacter) mob.guardCaptain == null) return; - if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { + + if (!mob.playerAgroMap.containsKey(((PlayerCharacter) mob.guardCaptain).getObjectUUID())) { //mob no longer has its owner loaded, translocate pet to owner - MovementManager.translocate(mob, mob.getOwner().getLoc(), null); + + MovementManager.translocate(mob, ((PlayerCharacter) mob.guardCaptain).getLoc(), null); return; } if (mob.getCombatTarget() == null) { //move back to owner - if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6)) + + if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6)) return; - mob.destination = mob.getOwner().getLoc(); + + mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc(); MovementUtilities.moveToLocation(mob, mob.destination, 5); } else chaseTarget(mob); break; case GuardMinion: - if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) + if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned) randomGuardPatrolPoint(mob); else { if (mob.getCombatTarget() != null) { @@ -829,7 +837,6 @@ public class MobAI { chaseTarget(mob); } break; - } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); @@ -896,7 +903,8 @@ public class MobAI { if (mob.getCombatTarget() == null) return; - if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { + if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && + mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) { mob.setCombatTarget(null); return; @@ -912,10 +920,10 @@ public class MobAI { private static void CheckToSendMobHome(Mob mob) { try { - if (mob.BehaviourType.isAgressive) { + if (mob.behaviourType.isAgressive) { if (mob.isPlayerGuard()) { - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) CheckForPlayerGuardAggro(mob); } else { CheckForAggro(mob); @@ -935,7 +943,7 @@ public class MobAI { PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) { //guard captain pulls his minions home with him @@ -951,8 +959,8 @@ public class MobAI { PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - for (Entry playerEntry : mob.playerAgroMap.entrySet()) - PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); + for (Integer playerEntry : mob.playerAgroMap.keySet()) + mob.playerAgroMap.put(playerEntry,0f); } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); @@ -1016,7 +1024,7 @@ public class MobAI { if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD))) continue; - if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)) + if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1)) continue; if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) @@ -1046,6 +1054,7 @@ public class MobAI { mob.setCombatTarget(newTarget); } + CheckMobMovement(mob); CheckForAttack(mob); } catch (Exception e) { @@ -1056,15 +1065,29 @@ public class MobAI { public static void GuardMinionLogic(Mob mob) { try { - boolean isComanded = mob.npcOwner.isAlive(); - if (!isComanded) { - GuardCaptainLogic(mob); + if (!mob.guardCaptain.isAlive()) { + + if (mob.getCombatTarget() == null) { + CheckForPlayerGuardAggro(mob); + } else { + + AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); + + if (newTarget != null) { + + if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { + if (GuardCanAggro(mob, (PlayerCharacter) newTarget)) + mob.setCombatTarget(newTarget); + } else + mob.setCombatTarget(newTarget); + + } + } }else { - if (mob.npcOwner.getCombatTarget() != null) - mob.setCombatTarget(mob.npcOwner.getCombatTarget()); - else - if (mob.getCombatTarget() != null) - mob.setCombatTarget(null); + if (mob.guardCaptain.getCombatTarget() != null) + mob.setCombatTarget(mob.guardCaptain.getCombatTarget()); + else if (mob.getCombatTarget() != null) + mob.setCombatTarget(null); } CheckMobMovement(mob); CheckForAttack(mob); @@ -1089,14 +1112,31 @@ public class MobAI { try { - if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false) + + if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false) if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) mob.killCharacter("no owner"); - if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) + if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) CheckMobMovement(mob); CheckForAttack(mob); + + //recover health + + if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false) + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + + if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000) + if (mob.getHealth() < mob.getHealthMax()) { + + float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f); + mob.setHealth(mob.getHealth() + recoveredHealth); + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + + if (mob.getHealth() > mob.getHealthMax()) + mob.setHealth(mob.getHealthMax()); + } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); } @@ -1127,7 +1167,7 @@ public class MobAI { if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) mob.setCombatTarget(null); - if (mob.BehaviourType.isAgressive) { + if (mob.behaviourType.isAgressive) { AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); @@ -1135,7 +1175,7 @@ public class MobAI { mob.setCombatTarget(newTarget); else { if (mob.getCombatTarget() == null) { - if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) + if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) SafeGuardAggro(mob); //safehold guard else CheckForAggro(mob); //normal aggro @@ -1145,12 +1185,12 @@ public class MobAI { //check if mob can move for patrol or moving to target - if (mob.BehaviourType.canRoam) + if (mob.behaviourType.canRoam) CheckMobMovement(mob); //check if mob can attack if it isn't wimpy - if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null) + if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null) CheckForAttack(mob); } catch (Exception e) { @@ -1167,7 +1207,7 @@ public class MobAI { if (!mob.isAlive()) return; - ConcurrentHashMap loadedPlayers = mob.playerAgroMap; + ConcurrentHashMap loadedPlayers = mob.playerAgroMap; for (Entry playerEntry : loadedPlayers.entrySet()) { @@ -1215,8 +1255,8 @@ public class MobAI { if (mob.getGuild().getNation().equals(target.getGuild().getNation())) return false; - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { - if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { + if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { return true; } } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { @@ -1300,7 +1340,7 @@ public class MobAI { MovementUtilities.aiMove(mob, mob.destination, true); - if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { + if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { for (Entry minion : mob.siegeMinionMap.entrySet()) { //make sure mob is out of combat stance @@ -1327,7 +1367,7 @@ public class MobAI { float CurrentHateValue = 0; if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) - CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); + CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue(); AbstractWorldObject mostHatedTarget = null; @@ -1338,8 +1378,8 @@ public class MobAI { if (potentialTarget.equals(mob.getCombatTarget())) continue; - if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { - CurrentHateValue = potentialTarget.getHateValue(); + if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { + CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue(); mostHatedTarget = potentialTarget; } @@ -1350,22 +1390,4 @@ public class MobAI { } return null; } - - public static void RecoverHealth(Mob mob){ - //recover health - - if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false) - mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); - - if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000) - if (mob.getHealth() < mob.getHealthMax()) { - - float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f); - mob.setHealth(mob.getHealth() + recoveredHealth); - mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); - - if (mob.getHealth() > mob.getHealthMax()) - mob.setHealth(mob.getHealthMax()); - } - } } \ No newline at end of file diff --git a/src/engine/mobileAI/utilities/CombatUtilities.java b/src/engine/mobileAI/utilities/CombatUtilities.java index fd52a2e3..3a0c0634 100644 --- a/src/engine/mobileAI/utilities/CombatUtilities.java +++ b/src/engine/mobileAI/utilities/CombatUtilities.java @@ -48,7 +48,7 @@ public class CombatUtilities { } public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) { - return entity1.getLoc().distance2D(entity2.getLoc()) < range; + return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range; } public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) { diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 85affdca..9bda3497 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -13,10 +13,10 @@ import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; -import engine.mobileAI.Threads.MobAIThread; import engine.exception.MsgSendException; import engine.gameManager.MovementManager; import engine.math.Vector3fImmutable; +import engine.mobileAI.Threads.MobAIThread; import engine.net.client.msg.MoveToPointMsg; import engine.objects.*; import org.pmw.tinylog.Logger; @@ -38,7 +38,7 @@ public class MovementUtilities { if (agent.getContract() != null) guardCaptain = agent; else - guardCaptain = (Mob) agent.npcOwner; + guardCaptain = (Mob) agent.guardCaptain; if (guardCaptain != null) { Building barracks = guardCaptain.building; diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index d31a63c3..bc5b33ef 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -9,6 +9,7 @@ package engine.net.client; +import engine.Enum; import engine.Enum.*; import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; @@ -560,12 +561,17 @@ public class ClientMessagePump implements NetMsgHandler { if (!itemManager.inventoryContains(i)) return; - if (i.isCanDestroy()) + if (i.isCanDestroy()) { if (itemManager.delete(i) == true) { + int value = i.getItemBase().getBaseValue(); + if(i.getItemBase().isStatRune()) + value = 500000; + sourcePlayer.getCharItemManager().addGoldToInventory(value,false); + sourcePlayer.getCharItemManager().updateInventory(); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); } - + } } private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) { @@ -1888,6 +1894,17 @@ public class ClientMessagePump implements NetMsgHandler { break; case LEAVEREQUEST: origin.disconnect(); + ArrayList sameMachine = new ArrayList<>(); + for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) { + if(origin.machineID.equals(pc.getClientConnection().machineID)) + sameMachine.add(pc); + } + if(sameMachine.isEmpty() == false){ + if(sameMachine.get(0) != null) { + sameMachine.get(0).isBoxed = false; + ChatManager.chatSystemInfo(sameMachine.get(0), "You Are No Longer Flagged 'Boxed'"); + } + } break; case POWER: PowersManager.usePower((PerformActionMsg) msg, origin, false); diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 0d2897bf..4e0179d7 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -57,6 +57,21 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { if (contract.canSlotinBuilding(building)) ItemLists.add(hirelings); + + if(building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)){ + if(contract.getContractID() == 899)//alchemist + ItemLists.add(hirelings); + + if(contract.getContractID() == 866)//banker + ItemLists.add(hirelings); + + if(contract.getContractID() == 865)//siege engineer + ItemLists.add(hirelings); + } + if(building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SIEGETENT)){ + if(contract.getContractID() == 865)//siege engineer + ItemLists.add(hirelings); + } } } @@ -78,13 +93,20 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; } - if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) + if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size()) return false; Item contractItem = Item.getFromCache(msg.getContractItem()); if (contractItem == null) return false; + if (msg.getContractItem() == 850) {//runemaster + for (AbstractCharacter abs : building.getHirelings().keySet()) { + NPC npc = (NPC) abs; + if (npc.contract.getContractID() == 850) + return false; //can only have 1 runemaster + } + } if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) { Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!"); @@ -104,10 +126,33 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; // Check if contract can be slotted in this building - - if (contract.canSlotinBuilding(building) == false) - return false; - + //Logger.error("inserting contract: " + contract.getContractID()); + if (contract.canSlotinBuilding(building) == false) { + boolean override = false; + if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)) { + if (contract.getContractID() == 899)//alchemist + override = true; + + if (contract.getContractID() == 866)//banker + override = true; + + if (contract.getContractID() == 865)//siege engineer + override = true; + } + if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SIEGETENT)) { + if (contract.getContractID() == 865)//siege engineer + override = true; + } + if(building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.SIEGETENT)){ + if(contract.getContractID() == 865)//siege engineer + override = true; + } + if(override == false) { + Logger.error("failed at override with contract: " + contract.getContractID()); + return false; + } + } + //Logger.error("override successful: " + contract.getContractID()); if (!BuildingManager.addHireling(building, player, zone, contract, contractItem)) return false; diff --git a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java index 02b0518c..eb62ddfb 100644 --- a/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java +++ b/src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java @@ -66,6 +66,9 @@ public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler { // Send Guild, Nation and IC MOTD GuildManager.enterWorldMOTD(player); ChatManager.sendSystemMessage(player, ConfigManager.MB_WORLD_GREETING.getValue()); + ChatManager.sendSystemMessage(player, "Gold Drop Rate: " + ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); + ChatManager.sendSystemMessage(player, "Loot Drop Rate: " + ConfigManager.MB_NORMAL_DROP_RATE.getValue()); + ChatManager.sendSystemMessage(player, "Experience Rate: " + ConfigManager.MB_NORMAL_EXP_RATE.getValue()); // Send branch string if available from ConfigManager. diff --git a/src/engine/net/client/handlers/CityDataHandler.java b/src/engine/net/client/handlers/CityDataHandler.java index 98ca60fb..f2f5d0d3 100644 --- a/src/engine/net/client/handlers/CityDataHandler.java +++ b/src/engine/net/client/handlers/CityDataHandler.java @@ -61,15 +61,6 @@ public class CityDataHandler extends AbstractClientMsgHandler { dispatch = Dispatch.borrow(playerCharacter, cityDataMsg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - // If the hotZone has changed then update the client's map accordingly. - - if (playerCharacter.getTimeStamp("hotzoneupdate") <= ZoneManager.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) { - HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID()); - dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - playerCharacter.setTimeStamp("hotzoneupdate", System.currentTimeMillis() - 100); - } - // Serialize the realms for this map WorldRealmMsg worldRealmMsg = new WorldRealmMsg(); diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index e2b0af01..0fe3c58d 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -294,7 +294,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { // Owner is obviously allowed to upgrade his own buildings - if (building.getOwner().equals(player)) { + if (building.getOwner() != null && building.getOwner().equals(player)) { // Players cannot destroy or transfer a TOL. diff --git a/src/engine/net/client/handlers/MerchantMsgHandler.java b/src/engine/net/client/handlers/MerchantMsgHandler.java index 94490a72..0adbace4 100644 --- a/src/engine/net/client/handlers/MerchantMsgHandler.java +++ b/src/engine/net/client/handlers/MerchantMsgHandler.java @@ -147,7 +147,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler { Building shrineBuilding; Shrine shrine; - if (npc.getGuild() != player.getGuild()) + if (npc.getGuild().getNation() != player.getGuild().getNation()) return; shrineBuilding = npc.getBuilding(); diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index a71a9300..f9007eb9 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -8,7 +8,6 @@ import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; import engine.gameManager.NPCManager; import engine.gameManager.SessionManager; -import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -42,7 +41,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (player == null) return true; - if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) { NPC npc = NPC.getFromCache(minionMsg.getNpcID()); @@ -63,10 +61,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { Mob toRemove = Mob.getFromCache(minionMsg.getUUID()); - if (!npc.getSiegeMinionMap().containsKey(toRemove)) + if (!npc.siegeMinionMap.containsKey(toRemove)) return true; - npc.getSiegeMinionMap().remove(toRemove); + npc.siegeMinionMap.remove(toRemove); WorldGrid.RemoveWorldObject(toRemove); @@ -74,14 +72,18 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { toRemove.getParentZone().zoneMobSet.remove(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, DispatchChannel.SECONDARY); + if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; + + if (petOwner != null) { + petOwner.setPet(null); + + toRemove.guardCaptain = null; + PetMsg petMsg = new PetMsg(5, null); + Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + } } // we Found the move to remove, lets break the for loop so it doesnt look for more. @@ -115,7 +117,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (npc.getContractID() == 842) maxSlots = 1; - if (npc.getSiegeMinionMap().size() == maxSlots) + if (npc.siegeMinionMap.size() == maxSlots) return true; int mobBase; @@ -146,42 +148,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (mobBase == 0) return true; - Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1); + Mob siegeMob = Mob.createSiegeMinion(npc, mobBase); if (siegeMob == null) return true; - - if (siegeMob != null) { - - siegeMob.setSpawnTime(60 * 15); - Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID()); - - siegeMob.building = building; - siegeMob.parentZone = zone; - - // Slot siege minion - // Can be either corner tower or bulwark. - - int slot; - - if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER)) - slot = 2; - else - slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain - - BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot); - siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation()); - - // Rotate slot position by the building rotation - - siegeMob.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), siegeMob.bindLoc, building.getBounds().getQuaternion().angleY); - - siegeMob.loc = new Vector3fImmutable(siegeMob.bindLoc); - siegeMob.endLoc = new Vector3fImmutable(siegeMob.bindLoc); - - zone.zoneMobSet.add(siegeMob); - siegeMob.setLoc(siegeMob.bindLoc); - } } ManageNPCMsg mnm = new ManageNPCMsg(npc); @@ -228,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { toRemove.getParentZone().zoneMobSet.remove(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); @@ -298,14 +271,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { String pirateName = NPCManager.getPirateName(mobBase); - if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) - return true; - - Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName); + Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName); if (toCreate == null) return true; + if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) + return true; + if (toCreate != null) { toCreate.setDeathTime(System.currentTimeMillis()); toCreate.parentZone.zoneMobSet.add(toCreate); diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index d6ef538e..de6a9fbf 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -439,8 +439,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { // } // break; //} - - LootManager.peddleFate(player,item); + int i = 0; + if(i != 0) { + LootManager.peddleFate(player, item); + } break; case 30: //water bucket diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index d0a9793a..ec62bd25 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -212,10 +212,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { return; } - for (AbstractCharacter guard : building.getHirelings().keySet()) { - if (guard.getObjectType() == GameObjectType.Mob) - ((Mob) guard).setPatrolPointIndex(0); - } } else if (building.getPatrolPoints() != null) ClearPatrolPoints(building.getObjectUUID()); @@ -223,10 +219,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { AddSentryPoints(building.getObjectUUID(), orderNpcMsg.getSentryPoints()); } else if (building.getSentryPoints() != null) ClearSentryPoints(building.getObjectUUID()); - - // Dispatch dispatch = Dispatch.borrow(pc, msg); - // DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - } private static void processUpgradeNPC(PlayerCharacter player, AbstractCharacter abstractCharacter) { @@ -541,7 +533,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { } else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) { - mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID()); + mob = Mob.getMob(orderNPCMsg.getNpcUUID()); if (mob == null) return true; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 382b6547..c5f59add 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -800,7 +800,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING); treeObject.setParentZone(zoneObject); - MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7)); + MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(14)); // Update guild binds and tags //load the new city on the clients diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 8772b7c0..d68ecb04 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -343,7 +343,7 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(0); //runemaster list //artillery captain list - ConcurrentHashMap siegeMinions = npc.getSiegeMinionMap(); + ConcurrentHashMap siegeMinions = npc.siegeMinionMap; writer.putInt(1 + siegeMinions.size()); serializeBulwarkList(writer, 1); //Trebuchet //serializeBulwarkList(writer, 2); //Ballista @@ -366,7 +366,7 @@ public class ManageNPCMsg extends ClientNetMsg { long timeLife = upgradeTime - curTime; if (upgradeTime * 1000 > System.currentTimeMillis()) { - if (mob.npcOwner.isAlive()) { + if (mob.guardCaptain.isAlive()) { writer.put((byte) 0);//shows respawning timer writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime); @@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg { } else if (this.targetType == GameObjectType.Mob.ordinal()) { - mobA = Mob.getFromCacheDBID(this.targetID); + mobA = Mob.getMob(this.targetID); if (mobA == null) { Logger.error("Missing Mob of ID " + this.targetID); @@ -689,7 +689,7 @@ public class ManageNPCMsg extends ClientNetMsg { long timeLife = upgradeTime - curTime; if (upgradeTime * 1000 > System.currentTimeMillis()) { - if (mob.npcOwner.isAlive()) { + if (mob.guardCaptain.isAlive()) { writer.put((byte) 0);//shows respawning timer writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index e43da320..3d788dbe 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public int contractUUID; public Contract contract; - protected String firstName; - protected String lastName; + public String firstName; + public String lastName; protected short statStrCurrent; protected short statDexCurrent; protected short statConCurrent; @@ -117,16 +117,33 @@ public abstract class AbstractCharacter extends AbstractWorldObject { protected boolean movingUp = false; private float desiredAltitude = 0; private long takeOffTime = 0; - private float hateValue = 0; private long lastHateUpdate = 0; - private boolean collided = false; private byte aoecntr = 0; + public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public AbstractCharacter() { super(); + this.firstName = ""; + this.lastName = ""; - this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + this.statStrCurrent = (short) 0; + this.statDexCurrent = (short) 0; + this.statConCurrent = (short) 0; + this.statIntCurrent = (short) 0; + this.statSpiCurrent = (short) 0; + + this.unusedStatPoints = (short) 0; + + this.level = (short) 0; // TODO get this from MobsBase later + this.exp = 1; + this.walkMode = true; + this.bindLoc = Vector3fImmutable.ZERO; + this.faceDir = Vector3fImmutable.ZERO; + + this.runningTrains = (byte) 0; + + this.skills = new ConcurrentHashMap<>(); + this.powers = new ConcurrentHashMap<>(); this.initializeCharacter(); } @@ -214,8 +231,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); this.initializeCharacter(); - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } /** @@ -258,8 +273,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.powers = new ConcurrentHashMap<>(); this.initializeCharacter(); - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } /** @@ -291,8 +304,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.powers = new ConcurrentHashMap<>(); initializeCharacter(); - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } /** @@ -342,9 +353,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.powers = new ConcurrentHashMap<>(); this.initializeCharacter(); - - // Dangerous to use THIS in a constructor!!! - this.charItemManager = new CharacterItemManager(this); } public static int getBankCapacity() { @@ -1758,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.inBuildingID = inBuildingID; } - public float getHateValue() { - if (this.hateValue <= 0) { - this.hateValue = 0; - return hateValue; - } - - if (this.lastHateUpdate == 0) { - this.lastHateUpdate = System.currentTimeMillis(); - return this.hateValue; - } - long duration = System.currentTimeMillis() - this.lastHateUpdate; - //convert duration to seconds and multiply Hate Delimiter. - float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER; - this.hateValue -= modAmount; - this.lastHateUpdate = System.currentTimeMillis(); - return this.hateValue; - } - - public void setHateValue(float hateValue) { - this.lastHateUpdate = System.currentTimeMillis(); - this.hateValue = hateValue; - } - public int getInFloorID() { return inFloorID; } diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index 580a3094..f18d4acb 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -9,6 +9,7 @@ package engine.objects; +import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.ModType; @@ -31,7 +32,20 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { protected Vector3fImmutable lastBindLoc; public boolean assist = false; public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; - + public boolean isPlayerGuard = false; + public AbstractCharacter guardCaptain; + public EnumBitSet notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class); + public EnumBitSet enemy = EnumBitSet.noneOf(Enum.MonsterType.class); + ; + public Enum.MobBehaviourType behaviourType; + public ArrayList patrolPoints; + public int lastPatrolPointIndex = 0; + public long stopPatrolTime = 0; + public City guardedCity; + + public AbstractIntelligenceAgent() { + super(); + } public AbstractIntelligenceAgent(ResultSet rs) throws SQLException { super(rs); @@ -87,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { this.agentType = Enum.AIAgentType.CHARMED; if (this.getObjectType().equals(GameObjectType.Mob)) { - ((Mob) this).setOwner(owner); + + ((Mob) this).guardCaptain = owner; } } @@ -110,14 +125,6 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { return 0; } - public PlayerCharacter getOwner() { - - if (this.getObjectType().equals(GameObjectType.Mob)) - return this.getOwner(); - - return null; - } - public boolean getSafeZone() { ArrayList allIn = ZoneManager.getAllZonesIn(this.getLoc()); @@ -158,7 +165,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { //clear owner - PlayerCharacter owner = this.getOwner(); + PlayerCharacter owner = (PlayerCharacter) this.guardCaptain; //close pet window @@ -174,7 +181,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { owner.setPet(null); if (this.getObjectType().equals(GameObjectType.Mob)) - ((Mob) this).setOwner(null); + ((Mob) this).guardCaptain = null; } diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 97d8a5d1..5f087a55 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject { Mob mob = (Mob) this; if (mob.isSiege()) { if (mob.isPet()) { - PlayerCharacter petOwner = mob.getOwner(); + + + PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain; if (petOwner != null && source.equals(EffectSourceType.Effect)) { petOwner.dismissPet(); return; diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index 15777c27..dcd4841a 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -167,10 +167,7 @@ public class Blueprint { // based upon the building's current rank public static int getNpcMaintCost(int rank) { - int maintCost = Integer.MAX_VALUE; - - maintCost = (9730 * rank) + 1890; - + int maintCost = 0; return maintCost; } @@ -313,10 +310,10 @@ public class Blueprint { // Early exit for buildings with single or no slots - if (this.maxSlots <= 1) + if (this.maxSlots <= 1 && this.buildingGroup.equals(BuildingGroup.TOL) == false) return maxSlots; - if (this.maxRank == 1 && currentRank == 1) + if (this.maxRank == 1 && currentRank == 1&& this.buildingGroup.equals(BuildingGroup.TOL) == false) return getMaxSlots(); switch (currentRank) { @@ -328,20 +325,22 @@ public class Blueprint { case 3: case 4: case 5: - case 6: availableSlots = 2; break; + case 6: case 7: availableSlots = 3; break; case 8: - availableSlots = 1; + availableSlots = 3; break; default: availableSlots = 0; break; } - + if(this.buildingGroup.equals(BuildingGroup.TOL)){ + availableSlots += 1; + } return availableSlots; } @@ -609,17 +608,10 @@ public class Blueprint { switch (this.buildingGroup) { case TOL: - case BARRACK: - maintCost = (61500 * rank) + 19500; - break; - case SPIRE: - maintCost = (4800 * rank) + 1200; + maintCost = 3000000; break; default: - if (maxRank == 1) - maintCost = 22500; - else - maintCost = (15900 * rank) + 3300; + maintCost = 0; break; } diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index f70a3034..8e80fabd 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1244,13 +1244,33 @@ public class CharacterItemManager { return false; } + if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { + boolean added = false; + for(Item item : this.getInventory()){ + if(item.getItemBaseID() == i.getItemBaseID()){ + if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) { + item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems()); + updateInventory(); + added = true; + } + } + } + if(!added){ + this.inventory.add(i); + this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - this.inventory.add(i); - this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); + ItemBase ib = i.getItemBase(); + if (ib != null) + this.inventoryWeight += ib.getWeight(); + } + }else { + this.inventory.add(i); + this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - ItemBase ib = i.getItemBase(); - if (ib != null) - this.inventoryWeight += ib.getWeight(); + ItemBase ib = i.getItemBase(); + if (ib != null) + this.inventoryWeight += ib.getWeight(); + } return true; } @@ -2095,7 +2115,7 @@ public class CharacterItemManager { if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pc = (PlayerCharacter) this.absCharacter; int newWeight = this.getCarriedWeight() + weight; - return newWeight <= pc.getInventoryCapacity(); + return newWeight <= (int) pc.statStrBase * 3; } else if (this.absCharacter.getObjectType() == GameObjectType.NPC) { int newWeight = this.getCarriedWeight() + weight; return newWeight <= 1900 + (this.absCharacter.getLevel() * 3); @@ -2128,7 +2148,7 @@ public class CharacterItemManager { tradeWeight = tradeWeight + tradeCharacter.getCharItemManager().getTradingWeight(); tradeWeight = tradeWeight - this.getTradingWeight(); - return tradeWeight <= playerCharacter.getInventoryCapacity(); + return tradeWeight <= (int) playerCharacter.statStrBase * 3; } public boolean hasRoomBank(short weight) { @@ -2432,9 +2452,9 @@ public class CharacterItemManager { if (item == null || amount < 1 || amount > 5) return; - //dont damage items when dieing in safezone - if(ZoneManager.findSmallestZone(this.absCharacter.getLoc()).getSafeZone() == 0) + if(ZoneManager.findSmallestZone(this.getOwner().loc).getSafeZone() == 1){ return; + } //verify the item is equipped by this player int slot = item.getEquipSlot(); diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index 076e8525..3132d155 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -30,7 +30,7 @@ public class Contract extends AbstractGameObject { public int inventorySet = 0; private int vendorID; private boolean isTrainer; - private VendorDialog vendorDialog; + public VendorDialog vendorDialog; private ArrayList npcMenuOptions = new ArrayList<>(); private ArrayList npcModTypeTable = new ArrayList<>(); private ArrayList npcModSuffixTable = new ArrayList<>(); diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 154e286a..cfcfe83d 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -730,32 +730,29 @@ public class Guild extends AbstractWorldObject { public boolean canSubAGuild(Guild toSub) { - boolean canSub; - + boolean canSubToNation; + boolean canAcceptSub; if (this.equals(toSub)) return false; switch (this.guildState) { case Nation: case Sovereign: - canSub = true; + canAcceptSub = true; break; default: - canSub = false; + canAcceptSub = false; } switch (toSub.guildState) { case Errant: case Sovereign: - canSub = true; + canSubToNation = true; break; default: - canSub = false; - } - City nationCap = City.getCity(nation.cityUUID); - if (nation.getSubGuildList().size() >= nationCap.getRank()) { - canSub = false; + canSubToNation = false; } - return canSub; + + return canAcceptSub && canSubToNation; } public int getRealmsOwnedFlag() { diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index cc74c165..245756c8 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -61,7 +61,7 @@ public class Item extends AbstractWorldObject { private ArrayList enchants = new ArrayList<>(); private long dateToUpgrade; private String customName = ""; - private int magicValue; + public int magicValue; /** * No Id Constructor @@ -889,6 +889,8 @@ public class Item extends AbstractWorldObject { } public boolean isCanDestroy() { + if(this.getItemBaseID() == 7)//gold + return false; return canDestroy; } diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 17c5a00c..ad5ff347 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -13,6 +13,7 @@ import engine.Enum.DamageType; import engine.Enum.GameObjectType; import engine.Enum.ItemType; import engine.gameManager.DbManager; +import engine.gameManager.LootManager; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -914,4 +915,8 @@ public class ItemBase { public void setAutoID(boolean autoID) { this.autoID = autoID; } + + public boolean isVorg(){ + return LootManager.vorg_ha_uuids.contains(this.uuid) || LootManager.vorg_ma_uuids.contains(this.uuid) || LootManager.vorg_la_uuids.contains(this.uuid) || LootManager.vorg_cloth_uuids.contains(this.uuid); + } } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 34b06cb0..442608db 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -707,7 +707,7 @@ public class ItemFactory { if (rollPrefix < 80) { - int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); + int randomPrefix = LootManager.TableRoll(vendor.getLevel()); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); if (prefixEntry != null) @@ -722,7 +722,7 @@ public class ItemFactory { if (rollSuffix < 80 || prefixEntry == null) { - int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); + int randomSuffix = LootManager.TableRoll(vendor.getLevel()); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); if (suffixEntry != null) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index a19bc892..9bda9c11 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -21,9 +21,7 @@ import java.net.UnknownHostException; import java.sql.ResultSet; import java.sql.SQLException; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import static engine.gameManager.DbManager.MineQueries; @@ -32,7 +30,6 @@ import static engine.math.FastMath.sqr; public class Mine extends AbstractGameObject { - public final HashSet _playerMemory = new HashSet<>(); public static ConcurrentHashMap mineMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public static ConcurrentHashMap towerMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final String zoneName; @@ -51,6 +48,13 @@ public class Mine extends AbstractGameObject { private int buildingID; private MineProduction mineType; + public int capSize; + + public final HashSet _playerMemory = new HashSet<>(); + public final HashMap _recentMemory = new HashMap<>(); + HashMap> dividedPlayers; + public Integer totalPlayers; + /** * ResultSet Constructor */ @@ -91,6 +95,19 @@ public class Mine extends AbstractGameObject { this.production = Resource.valueOf(rs.getString("mine_resource")); this.lastClaimer = null; + //int capRoll = ThreadLocalRandom.current().nextInt(0,100); + //if(capRoll >= 0 && capRoll <= 33){ + this.capSize = 5; + //} + //if(capRoll >= 34 && capRoll <= 66){ + // this.capSize = 10; + //} + //if(capRoll >= 67 && capRoll <= 100){ + // this.capSize = 20; + //} + Building mineTower = BuildingManager.getBuilding(this.buildingID); + mineTower.setMaxHitPoints(5000 * this.capSize); + mineTower.setCurrentHitPoints((float)5000 * this.capSize); } public static void releaseMineClaims(PlayerCharacter playerCharacter) { @@ -165,7 +182,7 @@ public class Mine extends AbstractGameObject { writer.putInt(mine.getObjectUUID()); writer.putInt(mine.getObjectUUID()); //actually a hash of mine writer.putString(mine.mineType.name); - writer.putString(mine.zoneName); + writer.putString(mine.zoneName + " {" + mine.capSize + " Man}"); writer.putInt(mine.production.hash); writer.putInt(mine.production.baseProduction); writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here @@ -577,13 +594,12 @@ public class Mine extends AbstractGameObject { public void onEnter() { HashSet currentPlayers; - HashSet currentMemory; PlayerCharacter player; // Gather current list of players within the zone bounds - - currentPlayers = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); - currentMemory = new HashSet<>(); + Building tower = BuildingManager.getBuildingFromCache(this.buildingID); + currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents, MBServerStatics.MASK_PLAYER); + boolean updated = false; for (AbstractWorldObject playerObject : currentPlayers) { @@ -591,9 +607,10 @@ public class Mine extends AbstractGameObject { continue; player = (PlayerCharacter) playerObject; - currentMemory.add(player.getObjectUUID()); // Player is already in our memory + if (_recentMemory.containsKey(player.getObjectUUID())) + _recentMemory.remove(player.getObjectUUID()); if (_playerMemory.contains(player.getObjectUUID())) continue; @@ -601,24 +618,60 @@ public class Mine extends AbstractGameObject { // Add player to our city's memory _playerMemory.add(player.getObjectUUID()); + updated = true; // ***For debugging // Logger.info("PlayerMemory for ", this.getCityName() + ": " + _playerMemory.size()); } + this.totalPlayers = this._playerMemory.size(); try { - onExit(currentMemory); + if(onExit(currentPlayers)){ + updated = true; + } } catch (Exception e) { Logger.error(e.getMessage()); } - PowersManager.applyZergBuff(this); + this.dividedPlayers = new HashMap<>(); + for(Integer playerID : this._playerMemory){ + player = PlayerCharacter.getFromCache(playerID); + Guild nation = player.getGuild().getNation(); Guild entry; + if(this.dividedPlayers.containsKey(nation)){ + this.dividedPlayers.get(nation).add(playerID); + }else{ + ArrayList newEntry = new ArrayList<>(); + newEntry.add(playerID); + this.dividedPlayers.put(nation,newEntry); + } + } + if(updated == true){ + for(Integer playerID : this._playerMemory){ + player = PlayerCharacter.getFromCache(playerID); + if(this.dividedPlayers.containsKey(player.getGuild().getNation())){ + int count = this.dividedPlayers.get(player.getGuild().getNation()).size(); + switch(this.capSize){ + case 5: + player.ZergMultiplier = ZergManager.getMultiplier5Man(count); + break; + case 10: + player.ZergMultiplier = ZergManager.getMultiplier10Man(count); + break; + case 20: + player.ZergMultiplier = ZergManager.getMultiplier20Man(count); + break; + } + } else{ + player.ZergMultiplier = 1.0f; //something went wrong reset to default until next cycle + } + } + } } - private void onExit(HashSet currentMemory) { + + private Boolean onExit(HashSet currentPlayers) { PlayerCharacter player; int playerUUID = 0; HashSet toRemove = new HashSet<>(); Iterator iter = _playerMemory.iterator(); - HashSet inRange = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc,Enum.CityBoundsType.ZONE.extents * 0.5f,MBServerStatics.MASK_PLAYER); while (iter.hasNext()) { playerUUID = iter.next(); @@ -626,15 +679,33 @@ public class Mine extends AbstractGameObject { player = PlayerCharacter.getFromCache(playerUUID); - if (inRange.contains(player)) + if (currentPlayers.contains(player)) continue; toRemove.add(playerUUID); + if(_recentMemory.containsKey(playerUUID) == false) { + _recentMemory.put(playerUUID, System.currentTimeMillis()); + } + player.ZergMultiplier = 1.0f; // reset damage modifier to 1.0 } // Remove players from mine memory - _playerMemory.removeAll(toRemove); - PowersManager.removeZergBuff(toRemove); + //_playerMemory.removeAll(toRemove); + HashSet purge = new HashSet<>(); + for(Integer id : _recentMemory.keySet()){ + if(System.currentTimeMillis() > _recentMemory.get(playerUUID) + 60000){ + purge.add(id); + } + } + for(Integer id : purge){ + _recentMemory.remove(id); + } + if(toRemove.isEmpty()){ + return false; + }else{ + return true; + } } + } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 70602b02..00bdfb28 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -19,16 +19,12 @@ import engine.job.JobScheduler; import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; import engine.math.Bounds; -import engine.math.Quaternion; -import engine.math.Vector3f; import engine.math.Vector3fImmutable; -import engine.mobileAI.Threads.MobAIThread; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; -import engine.powers.EffectsBase; import engine.powers.MobPowerEntry; import engine.server.MBServerStatics; import org.joda.time.DateTime; @@ -36,64 +32,45 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; -import static engine.math.FastMath.acos; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; public class Mob extends AbstractIntelligenceAgent { - private static final ReentrantReadWriteLock createLock = new ReentrantReadWriteLock(); - private static final ConcurrentHashMap mobMapByDBID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - // Variables NOT to be stored in db private static int staticID = 0; //mob specific - public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); - public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); //key = Player value = hate value + public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); public long nextCastTime = 0; public long nextCallForHelp = 0; public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public boolean despawned = false; public Vector3fImmutable destination = Vector3fImmutable.ZERO; - public Vector3fImmutable localLoc = Vector3fImmutable.ZERO; public LinkedHashMap mobPowers = new LinkedHashMap<>(); public MobBase mobBase; public int spawnTime; public Zone parentZone; - public Building building; public boolean hasLoot = false; - public boolean isPlayerGuard = false; - public AbstractCharacter npcOwner; public long deathTime = 0; public int equipmentSetID = 0; public int runeSet = 0; public int bootySet = 0; - public EnumBitSet notEnemy; - public EnumBitSet enemy; - public MobBehaviourType BehaviourType; - public ArrayList patrolPoints; - public int lastPatrolPointIndex = 0; - public long stopPatrolTime = 0; - public City guardedCity; - protected int dbID; //the database ID - protected int loadID; - protected float spawnRadius; + + public int loadID; + public float spawnRadius; //used by static mobs - protected int parentZoneID; - protected float statLat; - protected float statLon; - protected float statAlt; + public int parentZoneUUID; + protected int dbID; //the database ID + private int currentID; - private int ownerUID = 0; //only used by pets - private AbstractWorldObject fearedObject = null; - private int buildingID; - private boolean isSiege = false; + + //TODO implement feared object system + public AbstractWorldObject fearedObject = null; private long lastAttackTime = 0; private int lastMobPowerToken = 0; private HashMap equip = null; @@ -101,86 +78,17 @@ public class Mob extends AbstractIntelligenceAgent { private DateTime upgradeDateTime = null; private boolean lootSync = false; - - /** - * No Id Constructor - */ - public Mob(String firstName, String lastName, short statStrCurrent, short statDexCurrent, short statConCurrent, short statIntCurrent, short statSpiCurrent, short level, int exp, boolean sit, boolean walk, boolean combat, Vector3fImmutable bindLoc, Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild, byte runningTrains, int npcType, boolean isMob, Zone parent, Building building, int contractID) { - super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, sit, walk, combat, bindLoc, currentLoc, faceDir, healthCurrent, manaCurrent, stamCurrent, guild, runningTrains); - + // New Mobile constructor. Fill in the blanks and then call + // PERSIST. + public Mob() { + super(); this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; - this.loadID = npcType; - this.mobBase = MobBase.getMobBase(loadID); this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; - this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; - this.building = building; - - if (building != null) - this.buildingID = building.getObjectUUID(); - else - this.buildingID = 0; - - if (contractID == 0) - this.contract = null; - else - this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); - if (building != null && building.getOwner() != null) { - this.lastName = "the " + contract.getName(); - } - clearStatic(); + this.bindLoc = Vector3fImmutable.ZERO; + this.gridObjectType = GridObjectType.DYNAMIC; + this.agentType = AIAgentType.MOBILE; } - /** - * Normal Constructor - */ - public Mob(String firstName, String lastName, short statStrCurrent, short statDexCurrent, short statConCurrent, short statIntCurrent, short statSpiCurrent, short level, int exp, boolean sit, boolean walk, boolean combat, Vector3fImmutable bindLoc, Vector3fImmutable currentLoc, Vector3fImmutable faceDir, short healthCurrent, short manaCurrent, short stamCurrent, Guild guild, byte runningTrains, int npcType, boolean isMob, Zone parent, int newUUID, Building building, int contractID) { - super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, sit, walk, combat, bindLoc, currentLoc, faceDir, healthCurrent, manaCurrent, stamCurrent, guild, runningTrains, newUUID); - this.dbID = newUUID; - this.loadID = npcType; - - if (contractID == 0) - this.contract = null; - else - this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); - - this.mobBase = MobBase.getMobBase(loadID); - this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; - this.building = building; - initializeMob(false, false, false); - clearStatic(); - } - - /** - * Pet Constructor - */ - public Mob(MobBase mobBase, Guild guild, Zone parent, short level, PlayerCharacter owner, int tableID) { - super(mobBase.getFirstName(), "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, level, 0, false, true, false, owner.getLoc(), owner.getLoc(), owner.getFaceDir(), (short) mobBase.getHealthMax(), (short) 0, (short) 0, guild, (byte) 0, tableID); - this.dbID = tableID; - this.loadID = mobBase.getObjectUUID(); - this.mobBase = mobBase; - this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; - this.ownerUID = owner.getObjectUUID(); - this.BehaviourType = Enum.MobBehaviourType.Pet1; - initializeMob(true, false, false); - clearStatic(); - } - - //SIEGE CONSTRUCTOR - public Mob(MobBase mobBase, Guild guild, Zone parent, short level, Vector3fImmutable loc, int tableID, boolean isPlayerGuard) { - super(mobBase.getFirstName(), "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, level, 0, false, true, false, loc, loc, Vector3fImmutable.ZERO, (short) mobBase.getHealthMax(), (short) 0, (short) 0, guild, (byte) 0, tableID); - this.dbID = tableID; - this.loadID = mobBase.getObjectUUID(); - this.mobBase = mobBase; - this.parentZone = parent; - this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; - this.ownerUID = 0; - this.equip = new HashMap<>(); - initializeMob(false, true, isPlayerGuard); - clearStatic(); - } /** * ResultSet Constructor @@ -189,52 +97,33 @@ public class Mob extends AbstractIntelligenceAgent { super(rs); + float statLat; + float statAlt; + float statLon; + try { this.dbID = rs.getInt(1); - //this.state = STATE.Idle; this.loadID = rs.getInt("mob_mobbaseID"); this.gridObjectType = GridObjectType.DYNAMIC; + this.spawnRadius = rs.getFloat("mob_spawnRadius"); this.spawnTime = rs.getInt("mob_spawnTime"); - this.parentZone = null; - this.statLat = rs.getFloat("mob_spawnX"); - this.statAlt = rs.getFloat("mob_spawnY"); - this.statLon = rs.getFloat("mob_spawnZ"); - this.localLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); + statLat = rs.getFloat("mob_spawnX"); + statAlt = rs.getFloat("mob_spawnY"); + statLon = rs.getFloat("mob_spawnZ"); + this.bindLoc = new Vector3fImmutable(statLat, statAlt, statLon); - this.parentZoneID = rs.getInt("parent"); + this.parentZoneUUID = rs.getInt("parent"); this.level = (short) rs.getInt("mob_level"); - int buildingID = rs.getInt("mob_buildingID"); - try { - this.building = BuildingManager.getBuilding(buildingID); - } catch (Exception e) { - this.building = null; - Logger.error(e.getMessage()); - } + this.buildingUUID = rs.getInt("mob_buildingID"); - int contractID = rs.getInt("mob_contractID"); + this.contractUUID = rs.getInt("mob_contractID"); - if (contractID == 0) - this.contract = null; - else - this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); + this.guildUUID = rs.getInt("mob_guildUID"); - if (this.contract != null && NPC.ISGuardCaptain(contract.getContractID())) { - this.spawnTime = 60 * 15; - this.isPlayerGuard = true; - } - - int guildID = rs.getInt("mob_guildUID"); - - if (this.building != null) - this.guild = this.building.getGuild(); - else - this.guild = Guild.getGuild(guildID); - - if (this.guild == null) - this.guild = Guild.getErrantGuild(); + this.equipmentSetID = rs.getInt("equipmentSet"); java.util.Date sqlDateTime; sqlDateTime = rs.getTimestamp("upgradeDate"); @@ -249,15 +138,9 @@ public class Mob extends AbstractIntelligenceAgent { if (this.upgradeDateTime != null) Mob.submitUpgradeJob(this); - this.mobBase = MobBase.getMobBase(loadID); - - this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); - if (this.mobBase != null && this.spawnTime == 0) this.spawnTime = this.mobBase.getSpawnTime(); - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.runeSet = rs.getInt("runeSet"); this.bootySet = rs.getInt("bootySet"); @@ -265,27 +148,14 @@ public class Mob extends AbstractIntelligenceAgent { this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class); this.firstName = rs.getString("mob_name"); - if (this.firstName.isEmpty()) - this.firstName = this.mobBase.getFirstName(); - - if (this.contract != null) { - this.equipmentSetID = this.contract.getEquipmentSet(); - this.lastName = this.getContract().getName(); - } else - this.equipmentSetID = rs.getInt("equipmentSet"); - - if (rs.getString("fsm").length() > 1) - this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); + this.behaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); - } catch (Exception e) { - Logger.error(e + " " + this.dbID); - } + this.currentID = this.dbID; - try { - initializeMob(false, false, this.isPlayerGuard); + this.agentType = AIAgentType.MOBILE; } catch (Exception e) { - Logger.error("Mobile:" + this.dbID + ": " + e); + Logger.error(e + " " + this.dbID); } } @@ -418,7 +288,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(0); // NPC menu options - if (mob.contract != null && mob.npcOwner == null) { + if (mob.contract != null && mob.guardCaptain == null) { writer.put((byte) 1); writer.putLong(0); writer.putLong(0); @@ -431,12 +301,12 @@ public class Mob extends AbstractIntelligenceAgent { } else writer.put((byte) 0); - if (mob.npcOwner != null) { + if (mob.guardCaptain != null) { writer.put((byte) 1); writer.putInt(GameObjectType.PlayerCharacter.ordinal()); writer.putInt(131117009); - writer.putInt(mob.npcOwner.getObjectType().ordinal()); - writer.putInt(mob.npcOwner.getObjectUUID()); + writer.putInt(mob.guardCaptain.getObjectType().ordinal()); + writer.putInt(mob.guardCaptain.getObjectUUID()); writer.putInt(8); } else writer.put((byte) 0); @@ -445,9 +315,14 @@ public class Mob extends AbstractIntelligenceAgent { writer.put((byte) 1); - if (mob.getOwner() != null) { - writer.putInt(mob.getOwner().getObjectType().ordinal()); - writer.putInt(mob.getOwner().getObjectUUID()); + + if ((PlayerCharacter) mob.guardCaptain != null) { + + + writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectType().ordinal()); + + + writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectUUID()); } else { writer.putInt(0); //ownerType writer.putInt(0); //ownerID @@ -465,7 +340,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(0); writer.putInt(0); - if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.isSiege && !mob.isPlayerGuard) { + if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.behaviourType.equals(MobBehaviourType.SiegeEngine) && !mob.isPlayerGuard) { writer.putInt(0); writer.putInt(0); } @@ -476,7 +351,7 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(2); writer.putInt(0x00008A2E); writer.putInt(0x1AB84003); - } else if (mob.isSiege) { + } else if (mob.behaviourType.equals(MobBehaviourType.SiegeEngine)) { writer.putInt(1); writer.putInt(74620179); } else @@ -526,31 +401,38 @@ public class Mob extends AbstractIntelligenceAgent { writer.putInt(mob.currentID); } - public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, boolean isMob, Zone parent, Building building, int contractID, String pirateName, int level) { - - Mob mobWithoutID = new Mob(pirateName, "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 1, 0, false, false, false, spawn, spawn, Vector3fImmutable.ZERO, (short) 1, (short) 1, (short) 1, guild, (byte) 0, loadID, isMob, parent, building, contractID); + public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, Zone parent, Building building, Contract contract, String pirateName, int level) { - if (mobWithoutID.mobBase == null) - return null; + Mob mobile = new Mob(); + mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; + mobile.loadID = loadID; + mobile.level = (short) level; - mobWithoutID.level = (short) level; + if (guild == null || guild.isEmptyGuild()) + mobile.guildUUID = 0; + else + mobile.guildUUID = guild.getObjectUUID(); - // Parent zone is required by dbhandler. Can likely - // refactor that out and just use the id. + mobile.parentZoneUUID = parent.getObjectUUID(); + mobile.buildingUUID = building.getObjectUUID(); - mobWithoutID.parentZone = parent; - mobWithoutID.parentZoneID = parent.getObjectUUID(); + if (mobile.buildingUUID != 0) + mobile.bindLoc = Vector3fImmutable.ZERO; + else + mobile.bindLoc = spawn; - // NPC in a Building derives position from slot + mobile.firstName = pirateName; - if (mobWithoutID.building != null) - mobWithoutID.bindLoc = Vector3fImmutable.ZERO; + if (contract == null) + mobile.contractUUID = 0; + else + mobile.contractUUID = contract.getContractID(); Mob mob; + mobile.agentType = AIAgentType.GUARD; try { - mob = DbManager.MobQueries.ADD_MOB(mobWithoutID); - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); + mob = DbManager.MobQueries.PERSIST(mobile); } catch (Exception e) { Logger.error("SQLException:" + e.getMessage()); @@ -560,38 +442,130 @@ public class Mob extends AbstractIntelligenceAgent { return mob; } - public static Mob createPet(int loadID, Guild guild, Zone parent, PlayerCharacter owner, short level) { - MobBase mobBase = MobBase.getMobBase(loadID); - Mob mob = null; + public static synchronized Mob createGuardMinion(Mob guardCaptain, short level, String minionName) { - if (mobBase == null || owner == null) - return null; + Mob minionMobile; - createLock.writeLock().lock(); - level += 20; + minionMobile = new Mob(); + minionMobile.currentID = (--Mob.staticID); - try { - mob = new Mob(mobBase, guild, parent, level, owner, 0); - if (mob.mobBase == null) - return null; - mob.runAfterLoad(); - Vector3fImmutable loc = owner.getLoc(); - DbManager.addToCache(mob); - mob.setPet(owner, true); - mob.setWalkMode(false); + minionMobile.level = level; + minionMobile.loadID = guardCaptain.loadID; + minionMobile.firstName = minionName; + minionMobile.equipmentSetID = guardCaptain.equipmentSetID; + minionMobile.buildingUUID = guardCaptain.building.getObjectUUID(); + minionMobile.guildUUID = guardCaptain.guildUUID; + minionMobile.runeSet = guardCaptain.runeSet; + minionMobile.enemy = guardCaptain.enemy; + minionMobile.notEnemy = guardCaptain.notEnemy; + + minionMobile.deathTime = System.currentTimeMillis(); + minionMobile.guardCaptain = guardCaptain; + minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; + minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion; + minionMobile.agentType = AIAgentType.GUARD; + minionMobile.isPlayerGuard = true; + minionMobile.guardedCity = guardCaptain.guardedCity; + minionMobile.patrolPoints = guardCaptain.building.patrolPoints; + + minionMobile.parentZoneUUID = guardCaptain.parentZoneUUID; + minionMobile.bindLoc = Vector3fImmutable.ZERO; + + //grab name from minionbase. + + Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); + + if (minionType != null) { + 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; + + minionMobile.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); - } catch (Exception e) { - Logger.error(e); - } finally { - createLock.writeLock().unlock(); } - parent.zoneMobSet.add(mob); - mob.level = level; - mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f); - mob.health.set(mob.healthMax); - return mob; + + // Configure and spawn minion + + minionMobile.runAfterLoad(); + DbManager.addToCache(minionMobile); + + minionMobile.setLoc(minionMobile.bindLoc); + minionMobile.despawn(); + + int slot = guardCaptain.siegeMinionMap.size() + 1; + guardCaptain.siegeMinionMap.put(minionMobile, slot); + + return minionMobile; } + public static synchronized Mob createSiegeMinion(NPC artyCaptain, int loadID) { + + Mob siegeMinion; + + siegeMinion = new Mob(); + siegeMinion.currentID = (--Mob.staticID); + + siegeMinion.level = 1; + siegeMinion.loadID = loadID; + siegeMinion.guildUUID = artyCaptain.guildUUID; + siegeMinion.equipmentSetID = 0; + siegeMinion.buildingUUID = artyCaptain.buildingUUID; + siegeMinion.guardCaptain = artyCaptain; + siegeMinion.parentZoneUUID = artyCaptain.parentZoneUUID; + siegeMinion.behaviourType = MobBehaviourType.SiegeEngine; + siegeMinion.agentType = AIAgentType.SIEGEENGINE; + siegeMinion.bindLoc = Vector3fImmutable.ZERO; + siegeMinion.spawnTime = (60 * 15); + + siegeMinion.runAfterLoad(); + + DbManager.addToCache(siegeMinion); + siegeMinion.setLoc(siegeMinion.bindLoc); + siegeMinion.despawn(); + + int slot = artyCaptain.siegeMinionMap.size() + 1; + artyCaptain.siegeMinionMap.put(siegeMinion, slot); + + return siegeMinion; + } + + public static synchronized Mob createPetMinion(int loadID, Zone parent, PlayerCharacter petOwner, short level) { + + if (petOwner == null) + return null; + + Mob petMinion = new Mob(); + + petMinion.currentID = (--Mob.staticID); + + petMinion.level = (short) (level + 20); + petMinion.loadID = loadID; + petMinion.bindLoc = petOwner.getLoc(); + petMinion.loc = petOwner.getLoc(); + petMinion.guardCaptain = petOwner; + petMinion.parentZoneUUID = parent.getObjectUUID(); + petMinion.walkMode = false; + petMinion.healthMax = MobBase.getMobBase(loadID).getHealthMax() * (petMinion.level * 0.5f); + petMinion.health.set(petMinion.healthMax); + petMinion.behaviourType = MobBehaviourType.Pet1; + petMinion.agentType = AIAgentType.PET; + petMinion.firstName = ""; + petMinion.lastName = ""; + + petMinion.despawned = false; + petMinion.runAfterLoad(); + DbManager.addToCache(petMinion); + petMinion.setLoc(petMinion.bindLoc); + + return petMinion; + } public static Mob getMob(int id) { if (id == 0) @@ -609,12 +583,6 @@ public class Mob extends AbstractIntelligenceAgent { return (Mob) DbManager.getFromCache(GameObjectType.Mob, id); } - public static Mob getFromCacheDBID(int id) { - if (Mob.mobMapByDBID.containsKey(id)) - return Mob.mobMapByDBID.get(id); - return null; - } - private static float getModifiedAmount(CharacterSkill skill) { if (skill == null) @@ -623,28 +591,6 @@ public class Mob extends AbstractIntelligenceAgent { return skill.getModifiedAmount(); } - public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { - - HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobAIThread.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); - - for (AbstractWorldObject awo : mobsInRange) { - Mob mob = (Mob) awo; - - //Mob is not attacking anyone, skip. - if (mob.getCombatTarget() == null) - continue; - - //Mob not attacking target's target, let's not be failmu and skip this target. - if (mob.getCombatTarget() != target) - continue; - - //target is mob's combat target, LETS GO. - - if (source.getHateValue() > target.getHateValue()) - mob.setCombatTarget(source); - } - } - public static void submitUpgradeJob(Mob mob) { if (mob.getUpgradeDateTime() == null) { @@ -690,302 +636,6 @@ public class Mob extends AbstractIntelligenceAgent { mob.upgradeDateTime = upgradeDateTime; } - public static synchronized Mob createGuardMob(Mob guardCaptain, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) { - - MobBase minionMobBase; - Mob mob; - int maxSlots; - - switch (guardCaptain.getRank()) { - case 3: - maxSlots = 2; - break; - case 4: - case 5: - maxSlots = 3; - break; - case 6: - maxSlots = 4; - break; - case 7: - maxSlots = 5; - break; - case 1: - case 2: - 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.setLevel(level); - if (guardCaptain.equipmentSetID != 0) - mob.equipmentSetID = guardCaptain.equipmentSetID; - - mob.runAfterLoad(); - mob.despawned = true; - mob.despawn(); - - //grab equipment and name from minionbase. - - if (guardCaptain.contract != null) { - Enum.MinionType minionType = Enum.MinionType.ContractToMinionMap.get(guardCaptain.contract.getContractID()); - if (minionType != null) { - 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; - - mob.firstName = NPCManager.getPirateName(mob.getMobBaseID()); - mob.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); - } - } - - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); - - mob.isPlayerGuard = true; - - DbManager.addToCache(mob); - - 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.deathTime = System.currentTimeMillis(); - mob.npcOwner = guardCaptain; - mob.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60; - mob.BehaviourType = Enum.MobBehaviourType.GuardMinion; - mob.guardedCity = guardCaptain.guardedCity; - mob.parentZone = parent; - parent.zoneMobSet.add(mob); - MovementManager.translocate(mob, guardCaptain.bindLoc, guardCaptain.region); - mob.bindLoc = guardCaptain.bindLoc; - return mob; - } - - public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) { - - MobBase minionMobBase; - Mob mob; - - if (owner.getSiegeMinionMap().size() == 3) - return null; - - minionMobBase = MobBase.getMobBase(loadID); - - if (minionMobBase == null) - return null; - - mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, false); - //mob.runAfterLoad(); - mob.despawned = true; - DbManager.addToCache(mob); - - mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks()); - - //mob.setMob(); - mob.setSiege(true); - - int slot = 0; - - if (!owner.getSiegeMinionMap().containsValue(1)) - slot = 1; - else if (!owner.getSiegeMinionMap().containsValue(2)) - slot = 2; - - owner.getSiegeMinionMap().put(mob, slot); - - mob.setNpcOwner(owner); - mob.BehaviourType = MobBehaviourType.Pet1; - mob.BehaviourType.canRoam = false; - return mob; - } - - private void clearStatic() { - - if (this.parentZone != null) - this.parentZone.zoneMobSet.remove(this); - - this.parentZone = null; - this.statLat = 0f; - this.statLon = 0f; - this.statAlt = 0f; - } - - private void initializeMob(boolean isPet, boolean isSiege, boolean isGuard) { - - int slot; - Vector3fImmutable slotLocation; - Quaternion slotRotation; - - if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) - return; - - // Configure parent zone adding this NPC to the - // zone collection - - this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneID); - this.parentZone.zoneMobSet.remove(this); - this.parentZone.zoneMobSet.add(this); - - // Setup location for this Mobile - - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); - - // Handle Mobiles within buildings - - if (this.building != null) { - - if (this.contract == null) { - - // Mobiles inside buildings are offset from it not the zone - - this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); - this.bindLoc = this.building.getLoc().add(this.bindLoc); - - } else { - - // Get next available slot for this Mobile and then - // add it to the building's hireling list - - slot = BuildingManager.getAvailableSlot(building); - - if (slot == -1) - Logger.error("No available slot for Mobile: " + this.getObjectUUID()); - - building.getHirelings().put(this, slot); - - // Override bind and location for this contracted Mobile - // derived from BuildingManager slot location data. - - slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation(); - - this.bindLoc = building.getLoc().add(slotLocation); - - } - - // Rotate slot position by the building rotation - - this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, building.getBounds().getQuaternion().angleY); - - this.loc = new Vector3fImmutable(bindLoc); - this.endLoc = new Vector3fImmutable(bindLoc); - - // Rotate mobile rotation by the building's rotation - - slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0); - slotRotation = slotRotation.mult(building.getBounds().getQuaternion()); - this.setRot(new Vector3f(0, slotRotation.y, 0)); - - // Configure building region and floor/level for this Mobile - - this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); - } - - if (this.mobBase != null) { - this.gridObjectType = GridObjectType.DYNAMIC; - this.healthMax = this.mobBase.getHealthMax(); - this.manaMax = 0; - this.staminaMax = 0; - this.setHealth(this.healthMax); - this.mana.set(this.manaMax); - this.stamina.set(this.staminaMax); - - if (isPet) - this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks()); - - if (this.contract == null) - this.level = (short) this.mobBase.getLevel(); - } - - //set bonuses - this.bonuses = new PlayerBonuses(this); - - //TODO set these correctly later - this.rangeHandOne = 8; - this.rangeHandTwo = -1; - this.minDamageHandOne = 0; - this.maxDamageHandOne = 0; - this.minDamageHandTwo = 1; - this.maxDamageHandTwo = 4; - this.atrHandOne = 300; - this.defenseRating = (short) this.mobBase.getDefenseRating(); - this.isActive = true; - - this.charItemManager.load(); - - //load AI for general mobs. - if (this.contract != null && NPC.ISWallArcher(this.contract)) { - this.BehaviourType = MobBehaviourType.GuardWallArcher; - this.isPlayerGuard = true; - this.spawnTime = 450; - } - if (isPet || isSiege || (isGuard && this.contract == null)) - this.currentID = (--Mob.staticID); - else - this.currentID = this.dbID; - - //store mobs by Database ID - - if (!isPet && !isSiege) - Mob.mobMapByDBID.put(this.dbID, this); - - } /* * Getters @@ -1008,18 +658,6 @@ public class Mob extends AbstractIntelligenceAgent { return currentID; } - public float getSpawnX() { - return this.statLat; - } - - public float getSpawnY() { - return this.statAlt; - } - - public float getSpawnZ() { - return this.statLon; - } - public float getSpawnRadius() { return this.spawnRadius; } @@ -1028,11 +666,6 @@ public class Mob extends AbstractIntelligenceAgent { this.spawnTime = value; } - //use getSpawnTime instead. This is just for init tables - public int getTrueSpawnTime() { - return this.spawnTime; - } - public String getSpawnTimeAsString() { if (this.spawnTime == 0) return MBServerStatics.DEFAULT_SPAWN_TIME_MS / 1000 + " seconds (Default)"; @@ -1062,14 +695,6 @@ public class Mob extends AbstractIntelligenceAgent { return this.parentZone; } - public int getParentZoneID() { - - if (this.parentZone != null) - return this.parentZone.getObjectUUID(); - - return 0; - } - @Override public int getGuildUUID() { @@ -1079,36 +704,13 @@ public class Mob extends AbstractIntelligenceAgent { return this.guild.getObjectUUID(); } - @Override - public PlayerCharacter getOwner() { - - if (!this.isPet()) - return null; - - if (this.ownerUID == 0) - return null; - - return PlayerCharacter.getFromCache(this.ownerUID); - } - - public void setOwner(PlayerCharacter value) { - - if (value == null) - this.ownerUID = 0; - else - this.ownerUID = value.getObjectUUID(); - } - - public void setFearedObject(AbstractWorldObject awo) { - this.fearedObject = awo; - } - @Override public Vector3fImmutable getBindLoc() { - if (this.isPet() && !this.isSiege) - return this.getOwner() != null ? this.getOwner().getLoc() : this.getLoc(); - return this.bindLoc; + if (this.isPet() && !this.behaviourType.equals(MobBehaviourType.SiegeEngine)) + return (PlayerCharacter) this.guardCaptain != null ? ((PlayerCharacter) this.guardCaptain).getLoc() : this.getLoc(); + else + return this.bindLoc; } public void calculateModifiedStats() { @@ -1230,7 +832,8 @@ public class Mob extends AbstractIntelligenceAgent { if (mobAttacker.isPet()) { - PlayerCharacter owner = mobAttacker.getOwner(); + + PlayerCharacter owner = (PlayerCharacter) mobAttacker.guardCaptain; if (owner != null) if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard) { @@ -1282,57 +885,60 @@ public class Mob extends AbstractIntelligenceAgent { try { //resync corpses - //this.setLoc(this.getMovementLoc()); - if (this.isSiege) { + + if (this.behaviourType.equals(MobBehaviourType.SiegeEngine)) { this.deathTime = System.currentTimeMillis(); - //this.state = STATE.Dead; + try { this.clearEffects(); } catch (Exception e) { Logger.error(e.getMessage()); } + this.setCombatTarget(null); this.hasLoot = false; this.playerAgroMap.clear(); - if (this.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) - this.spawnTime = (int) (-2.500 * ((Mob) this.npcOwner).building.getRank() + 22.5) * 60; + if (this.behaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) + this.spawnTime = (int) (-2.500 * this.guardCaptain.building.getRank() + 22.5) * 60; if (this.isPet()) { - PlayerCharacter petOwner = this.getOwner(); + PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain; if (petOwner != null) { - this.setOwner(null); + + this.guardCaptain = null; petOwner.setPet(null); PetMsg petMsg = new PetMsg(5, null); - dispatch = Dispatch.borrow(this.getOwner(), petMsg); + + + dispatch = Dispatch.borrow((PlayerCharacter) this.guardCaptain, petMsg); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); } } } else if (this.isPet() || this.isNecroPet()) { - //this.state = STATE.Disabled; this.setCombatTarget(null); this.hasLoot = false; - - //if (this.parentZone != null) - //this.parentZone.zoneMobSet.remove(this); ZoneManager.getSeaFloor().zoneMobSet.remove(this); + try { this.clearEffects(); } catch (Exception e) { Logger.error(e.getMessage()); } + this.playerAgroMap.clear(); WorldGrid.RemoveWorldObject(this); DbManager.removeFromCache(this); - PlayerCharacter petOwner = this.getOwner(); + PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain; if (petOwner != null) { - this.setOwner(null); + + this.guardCaptain = null; petOwner.setPet(null); PetMsg petMsg = new PetMsg(5, null); dispatch = Dispatch.borrow(petOwner, petMsg); @@ -1341,6 +947,7 @@ public class Mob extends AbstractIntelligenceAgent { } else { //cleanup effects + playerAgroMap.clear(); if (!this.isPlayerGuard && this.equip != null) @@ -1385,14 +992,12 @@ public class Mob extends AbstractIntelligenceAgent { this.recalculateStats(); this.setHealth(this.healthMax); - if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).BehaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal()) - this.building = ((Mob) this.npcOwner).building; + if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.equals(MobBehaviourType.GuardCaptain)) + this.building = this.guardCaptain.building; else if (this.building != null) this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); - //MovementManager.translocate(this, this.bindLoc, this.region); - - if (!this.isSiege && !this.isPlayerGuard && contract == null) + if (!this.behaviourType.equals(MobBehaviourType.SiegeEngine) && !this.isPlayerGuard && contract == null) loadInventory(); this.updateLocation(); @@ -1439,7 +1044,6 @@ public class Mob extends AbstractIntelligenceAgent { @Override public void updateDatabase() { - // DbManager.MobQueries.updateDatabase(this); } public void refresh() { @@ -1925,19 +1529,140 @@ public class Mob extends AbstractIntelligenceAgent { @Override public void runAfterLoad() { + this.charItemManager = new CharacterItemManager(this); + + if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) + return; + + this.mobBase = MobBase.getMobBase(loadID); + + this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); + + this.building = BuildingManager.getBuilding(this.buildingUUID); + + if (this.contractUUID == 0) + this.contract = null; + else + this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID); + + // Setup mobile AI and equipset for contract + + if (this.contract != null) { + + this.equipmentSetID = this.contract.getEquipmentSet(); + + // Load AI for guard captains + + if (NPC.ISGuardCaptain(contract.getContractID()) || this.contract.getContractID() == 910) { // Guard Dog + this.behaviourType = MobBehaviourType.GuardCaptain; + this.spawnTime = 60 * 15; + this.isPlayerGuard = true; + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); + } + + // Load AI for wall archers + + if (NPC.ISWallArcher(this.contract)) { + this.gridObjectType = GridObjectType.DYNAMIC; + this.behaviourType = MobBehaviourType.GuardWallArcher; + this.isPlayerGuard = true; + this.spawnTime = 450; + this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc()); + } + } + + // Default to the mobbase for AI if nothing is hte mob field to override. + + if (this.behaviourType == null || this.behaviourType.equals(MobBehaviourType.None)) + this.behaviourType = this.getMobBase().fsm; + + if (this.behaviourType == null) + this.behaviourType = MobBehaviourType.None; + + if (this.building != null) + this.guild = this.building.getGuild(); + else + this.guild = Guild.getGuild(guildUUID); + + if (this.guild == null) + this.guild = Guild.getErrantGuild(); + + if (this.firstName.isEmpty()) + this.firstName = this.mobBase.getFirstName(); + + if (this.contract != null) + if (this.lastName.isEmpty()) + this.lastName = this.getContract().getName(); + + this.healthMax = this.mobBase.getHealthMax(); + this.manaMax = 0; + this.staminaMax = 0; + this.setHealth(this.healthMax); + this.mana.set(this.manaMax); + this.stamina.set(this.staminaMax); + + // Don't override level for guard minions or pets + + if (this.contract == null) + if (!this.agentType.equals(AIAgentType.GUARD) && !this.agentType.equals(AIAgentType.PET)) + this.level = (short) this.mobBase.getLevel(); + + //set bonuses + + this.bonuses = new PlayerBonuses(this); + + //TODO set these correctly later + this.rangeHandOne = this.mobBase.getAttackRange(); + this.rangeHandTwo = -1; + this.minDamageHandOne = (int)this.mobBase.getMinDmg(); + this.maxDamageHandOne = (int)this.mobBase.getMaxDmg(); + this.minDamageHandTwo = 0; + this.maxDamageHandTwo = 0; + this.atrHandOne = this.mobBase.getAtr(); + this.defenseRating = (short) this.mobBase.getDefenseRating(); + this.isActive = true; + + // Configure parent zone adding this NPC to the + // zone collection + + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); + this.parentZone.zoneMobSet.remove(this); + this.parentZone.zoneMobSet.add(this); + + // Handle Mobiles within buildings + + if (this.building == null) { + + // Do not adjust a pet's bindloc. + + if (!this.agentType.equals(AIAgentType.PET)) + this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); + } else { + + // Mobiles inside buildings are offset from it not the zone + // with the exceptions being mobiles + // with a contract. + + if (this.contract != null || this.behaviourType.equals(MobBehaviourType.SiegeEngine)) + NPCManager.slotCharacterInBuilding(this); + else + this.bindLoc = building.getLoc().add(bindLoc); + } + + // Setup location for this Mobile + + this.loc = new Vector3fImmutable(bindLoc); + this.endLoc = new Vector3fImmutable(bindLoc); + // Initialize inventory - this.charItemManager = new CharacterItemManager(this); + this.charItemManager.load(); this.loadInventory(); - try { - if (this.equipmentSetID != 0) - this.equip = MobBase.loadEquipmentSet(this.equipmentSetID); - else - this.equip = new HashMap<>(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } + if (this.equipmentSetID != 0) + this.equip = MobBase.loadEquipmentSet(this.equipmentSetID); + else + this.equip = new HashMap<>(); // Powers from mobbase @@ -1959,7 +1684,7 @@ public class Mob extends AbstractIntelligenceAgent { // Combine mobbase and mob aggro arrays into one bitvector //skip for pets - if (this.isPet() == false && (this.agentType.equals(AIAgentType.PET)) == false && this.isNecroPet() == false) { + if (this.isPet() == false && this.isNecroPet() == false) { if (this.getMobBase().notEnemy.size() > 0) this.notEnemy.addAll(this.getMobBase().notEnemy); @@ -1978,47 +1703,13 @@ public class Mob extends AbstractIntelligenceAgent { mobBounds.setBounds(this.getLoc()); this.setBounds(mobBounds); - if (this.contract != null && this.contract.getContractID() == 910) { - this.isPlayerGuard = true; - this.BehaviourType = MobBehaviourType.GuardCaptain; - this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); - } //assign 5 random patrol points for regular mobs - if (!(this.agentType.equals(AIAgentType.GUARD)) && !this.isPlayerGuard() && !this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !(this.agentType.equals(AIAgentType.CHARMED))) { - this.patrolPoints = new ArrayList<>(); + if (this.agentType.equals(AIAgentType.MOBILE)) { - for (int i = 0; i < 5; ++i) { - float patrolRadius = this.getSpawnRadius(); - - if (patrolRadius > 256) - patrolRadius = 256; - - if (patrolRadius < 60) - patrolRadius = 60; - - Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(this.getBindLoc(), patrolRadius); - this.patrolPoints.add(newPatrolPoint); - - if (i == 1) - MovementManager.translocate(this, newPatrolPoint, null); - } + NPCManager.AssignPatrolPoints(this); } - if (this.BehaviourType == null) - this.BehaviourType = this.getMobBase().fsm; - - if (this.isPlayerGuard() && this.contract != null) - if (NPC.ISWallArcher(this.getContract())) { - this.BehaviourType = MobBehaviourType.GuardWallArcher; - this.spawnTime = 450; - } else { - this.BehaviourType = MobBehaviourType.GuardCaptain; - this.spawnTime = 900; - this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc); - } - this.deathTime = 0; } catch (Exception e) { Logger.error(e.getMessage()); @@ -2035,23 +1726,19 @@ public class Mob extends AbstractIntelligenceAgent { } public int getBuildingID() { - return buildingID; + return buildingUUID; } public void setBuildingID(int buildingID) { - this.buildingID = buildingID; + this.buildingUUID = buildingID; } public boolean isSiege() { - return isSiege; - } - - public void setSiege(boolean isSiege) { - this.isSiege = isSiege; + return this.behaviourType.equals(MobBehaviourType.SiegeEngine); } - public void setNpcOwner(AbstractCharacter npcOwner) { - this.npcOwner = npcOwner; + public void setGuardCaptain(AbstractCharacter guardCaptain) { + this.guardCaptain = guardCaptain; } public boolean isNecroPet() { @@ -2073,9 +1760,6 @@ public class Mob extends AbstractIntelligenceAgent { if (player.getObjectUUID() == this.getCombatTarget().getObjectUUID()) return; - if (this.getCombatTarget().getObjectType() == GameObjectType.PlayerCharacter) - if (ac.getHateValue() > ((PlayerCharacter) this.getCombatTarget()).getHateValue()) - this.setCombatTarget(player); } public void setRank(int newRank) { @@ -2141,13 +1825,6 @@ public class Mob extends AbstractIntelligenceAgent { return isPlayerGuard; } - public void setPlayerGuard(boolean isPlayerGuard) { - this.isPlayerGuard = isPlayerGuard; - } - - public void setPatrolPointIndex(int patrolPointIndex) { - } - public int getLastMobPowerToken() { return lastMobPowerToken; } @@ -2226,42 +1903,4 @@ public class Mob extends AbstractIntelligenceAgent { } } - public void dismiss() { - - if (this.isPet()) { - - if ((this.agentType.equals(AIAgentType.PET))) { //delete summoned pet - this.despawn(); - WorldGrid.RemoveWorldObject(this); - DbManager.removeFromCache(this); - - if (this.getObjectType() == GameObjectType.Mob) - if (this.getParentZone() != null) - this.getParentZone().zoneMobSet.remove(this); - - } else { //revert charmed pet - this.agentType = AIAgentType.MOBILE; - this.setCombatTarget(null); - } - //clear owner - - PlayerCharacter owner = this.getOwner(); - - //close pet window - - if (owner != null) { - Mob pet = owner.getPet(); - PetMsg pm = new PetMsg(5, null); - Dispatch dispatch = Dispatch.borrow(owner, pm); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - if (pet != null && pet.getObjectUUID() == this.getObjectUUID()) - owner.setPet(null); - - if (this.getObjectType().equals(GameObjectType.Mob)) - this.setOwner(null); - } - } - } - -} \ No newline at end of file +} diff --git a/src/engine/objects/MobEquipment.java b/src/engine/objects/MobEquipment.java index d15b6274..b9caec70 100644 --- a/src/engine/objects/MobEquipment.java +++ b/src/engine/objects/MobEquipment.java @@ -34,7 +34,7 @@ public class MobEquipment extends AbstractGameObject { private AbstractPowerAction suffix; private int pValue; private int sValue; - private int magicValue; + public int magicValue; private float dropChance = 0; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1e6d2f83..b3b3aed5 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -50,7 +50,6 @@ public class NPC extends AbstractCharacter { // Used for thread safety public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private final ArrayList rolling = new ArrayList<>(); - private final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public ArrayList forgedItems = new ArrayList<>(); public HashMap equip = null; @@ -86,6 +85,7 @@ public class NPC extends AbstractCharacter { public NPC() { + super(); this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; } @@ -654,12 +654,14 @@ public class NPC extends AbstractCharacter { WorldGrid.RemoveWorldObject(toRemove); DbManager.removeFromCache(toRemove); - PlayerCharacter petOwner = toRemove.getOwner(); + + PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { petOwner.setPet(null); - toRemove.setOwner(null); + + toRemove.guardCaptain = null; PetMsg petMsg = new PetMsg(5, null); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); @@ -805,6 +807,8 @@ public class NPC extends AbstractCharacter { @Override public void runAfterLoad() { + this.charItemManager = new CharacterItemManager(this); + if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) return; @@ -846,10 +850,6 @@ public class NPC extends AbstractCharacter { if (wordCount(this.name) < 2 && this.contract != null) this.name += " the " + this.contract.getName(); - // Initialize inventory - - this.charItemManager = new CharacterItemManager(this); - // Configure parent zone adding this NPC to the // zone collection @@ -1103,10 +1103,6 @@ public class NPC extends AbstractCharacter { return (int) time; } - public ConcurrentHashMap getSiegeMinionMap() { - return siegeMinionMap; - } - public boolean remove() { Building building; @@ -1330,7 +1326,6 @@ public class NPC extends AbstractCharacter { return; dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); - this.setUpgradeDateTime(dateToUpgrade); // Schedule upgrade job diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 83dedf44..6b6df9c8 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -144,7 +144,6 @@ public class PlayerCharacter extends AbstractCharacter { private long lastUpdateTime = System.currentTimeMillis(); private long lastStamUpdateTime = System.currentTimeMillis(); private boolean safeZone = false; - private int bindBuildingID; /* DataWarehouse based kill/death tracking. @@ -177,8 +176,7 @@ public class PlayerCharacter extends AbstractCharacter { public boolean isBoxed = false; - public boolean receivedConc = false; - + public float ZergMultiplier = 1.0f; /** * No Id Constructor */ @@ -209,15 +207,18 @@ public class PlayerCharacter extends AbstractCharacter { this.spiMod.set(spiMod); this.guildStatus = new AtomicInteger(0); - this.bindBuildingID = -1; + this.buildingUUID = -1; } /** * ResultSet Constructor */ public PlayerCharacter(ResultSet rs) throws SQLException { + super(rs, true); + this.charItemManager = new CharacterItemManager(this); + this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID()); int accountID = rs.getInt("parent"); this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID); @@ -269,7 +270,7 @@ public class PlayerCharacter extends AbstractCharacter { this.intMod.set(rs.getShort("char_intMod")); this.spiMod.set(rs.getShort("char_spiMod")); - this.bindBuildingID = rs.getInt("char_bindBuilding"); + this.buildingUUID = rs.getInt("char_bindBuilding"); this.hash = rs.getString("hash"); @@ -2191,11 +2192,8 @@ public class PlayerCharacter extends AbstractCharacter { } - //public int getInventoryCapacity() { - // return statStrBase * 3; - //} public int getInventoryCapacity() { - return 1000; + return statStrBase * 3; } public int getInventoryCapacityRemaining() { @@ -2230,7 +2228,6 @@ public class PlayerCharacter extends AbstractCharacter { // Warehouse this event CharacterRecord.updatePromotionClass(this); - return true; } @@ -2729,12 +2726,12 @@ public class PlayerCharacter extends AbstractCharacter { */ public synchronized int getBindBuildingID() { - return this.bindBuildingID; + return this.buildingUUID; } public synchronized void setBindBuildingID(int value) { DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value); - this.bindBuildingID = value; + this.buildingUUID = value; } public AbstractGameObject getLastTarget() { @@ -4569,10 +4566,6 @@ public class PlayerCharacter extends AbstractCharacter { @Override public void runAfterLoad() { - // Init inventory - - this.charItemManager = new CharacterItemManager(this); - Bounds playerBounds = Bounds.borrow(); playerBounds.setBounds(this.getLoc()); this.setBounds(playerBounds); @@ -4700,7 +4693,8 @@ public class PlayerCharacter extends AbstractCharacter { } else if (currentPet.isSiege()) { currentPet.agentType = AIAgentType.MOBILE; - currentPet.setOwner(null); + + currentPet.guardCaptain = null; currentPet.setCombatTarget(null); if (currentPet.isAlive()) WorldGrid.updateObject(currentPet); @@ -4819,9 +4813,14 @@ public class PlayerCharacter extends AbstractCharacter { updateBlessingMessage(); this.safeZone = this.isInSafeZone(); - if(this.isBoxed == true && this.containsEffect(1672601862) == false) - PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); + if(this.isBoxed && this.containsEffect(1672601862) == false) {//Deathshroud + PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); + } + //if(this.isBoxed && this.containsEffect(429611355) == false) {//pathfinding + // PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 429611355, 40, false); + //} + } catch (Exception e) { Logger.error(e); } finally { diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index f96a5fcb..c24513fc 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -1334,4 +1334,75 @@ public class Warehouse extends AbstractWorldObject { return resourceType.elementOf(this.lockedResourceTypes); } + + public static int getCostForResource(int id){ + int newCost = 0; + switch(id){ + case 1580000://stone + newCost = 3000; + break; + case 1580001://truesteel + newCost = 50000; + break; + case 1580002://iron + newCost = 50000; + break; + case 1580003://adamant + newCost = 100000; + break; + case 1580004://lumber + newCost = 3000; + break; + case 1580005://oak + newCost = 30000; + break; + case 1580006://bronzewood + newCost = 30000; + break; + case 1580007://mandrake + newCost = 100000; + break; + case 1580008://coal + newCost = 30000; + break; + case 1580009://agate + newCost = 50000; + break; + case 1580010://diamond + newCost = 50000; + break; + case 1580011://onyx + newCost = 100000; + break; + case 1580012://azoth + newCost = 50000; + break; + case 1580013://orichalk + newCost = 30000; + break; + case 1580014://antimony + newCost = 100000; + break; + case 1580015://sulfur + newCost = 100000; + break; + case 1580016://quicksilver + newCost = 100000; + break; + case 1580017://galvor + newCost = 300000; + break; + case 1580018://wormwood + newCost = 300000; + break; + case 1580019://obsidian + newCost = 200000; + break; + case 1580020://bloodstone + newCost = 200000; + break; + } + + return newCost; + } } diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index 3ddaf96b..efedabec 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -176,6 +176,10 @@ public class HealthEffectModifier extends AbstractEffectModifier { if (!ac.isAlive()) return; + if(source.getObjectType().equals(GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; + } + int powerID = 0, effectID = 0; String powerName = ""; if (effect.getPower() != null) { diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index d70b9a2c..10686659 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -157,6 +157,9 @@ public class ManaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } + if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; + } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID); diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index 59145f16..e7a89ce6 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -153,6 +153,9 @@ public class StaminaEffectModifier extends AbstractEffectModifier { skipImmune = true; } } + if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){ + modAmount *= ((PlayerCharacter)source).ZergMultiplier; + } PlayerBonuses bonus = ac.getBonuses(); if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID); diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index d96d3a54..a9eb6c89 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -11,6 +11,7 @@ package engine.powers.poweractions; import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; +import engine.InterestManagement.WorldGrid; import engine.gameManager.ChatManager; import engine.jobs.ChantJob; import engine.jobs.DeferredPowerJob; @@ -22,6 +23,7 @@ import engine.objects.*; import engine.powers.ActionsBase; import engine.powers.EffectsBase; import engine.powers.PowersBase; +import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.sql.ResultSet; @@ -117,20 +119,12 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { awo.addEffect(stackType, duration, eff, effect, trains); } else awo.applyAllBonuses(); - // //TODO if chant, start cycle - // if (pb.isChant() && source.equals(awo)) { - // ChantJob cj = new ChantJob(source, awo, stackType, trains, ab, pb, effect, eff); - // source.setLastChant((int)(pb.getChantDuration()-2) * 1000, cj); - // eff.setChant(true); - // } if (this.effectID.equals("TAUNT")) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) { - ((Mob) awo).setCombatTarget(source); ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); DispatchMessage.sendToAllInRange(source, msg); - ((Mob)awo).refresh(); } } if (awo != null && awo.getObjectType() == GameObjectType.Mob) { @@ -140,7 +134,21 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { } this.effect.startEffect(source, awo, trains, eff); } + //apply effects to mobs within range for chants + if(pb.isChant){ + for(AbstractGameObject ago : WorldGrid.getObjectsInRangePartial(awo.loc,pb.range, MBServerStatics.MASK_MOB)){ + Mob mob = (Mob)ago; + if(mob.playerAgroMap.containsKey(source.getObjectUUID())) + mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue); + } + }else { + if (awo != null && awo.getObjectType() == GameObjectType.Mob) { + Mob mob = (Mob) awo; + if (mob.playerAgroMap.containsKey(source.getObjectUUID())) + mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue); + } + } } protected void _applyEffectForItem(Item item, int trains) { diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index 90b64055..41c7e810 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -12,7 +12,6 @@ package engine.powers.poweractions; import engine.Enum; import engine.InterestManagement.WorldGrid; import engine.gameManager.DbManager; -import engine.gameManager.MovementManager; import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; @@ -75,7 +74,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { return; //create Pet - Mob pet = Mob.createPet(mobID, guild, seaFloor, owner, (short) mobLevel); + Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel); if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet @@ -84,8 +83,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { WorldGrid.RemoveWorldObject(currentPet); currentPet.setCombatTarget(null); - //if (currentPet.getParentZone() != null) - //currentPet.getParentZone().zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet); currentPet.playerAgroMap.clear(); @@ -95,10 +92,10 @@ public class CreateMobPowerAction extends AbstractPowerAction { Logger.error(e.getMessage()); } - //currentPet.disableIntelligence(); } else if (currentPet != null && currentPet.isSiege()) { currentPet.agentType = Enum.AIAgentType.MOBILE; - currentPet.setOwner(null); + + currentPet.guardCaptain = null; currentPet.setCombatTarget(null); if (currentPet.isAlive()) @@ -106,7 +103,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { } //remove 10th pet - NPCManager.spawnNecroPet(owner, pet); } else { //is not a necro pet @@ -115,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { DbManager.removeFromCache(currentPet); currentPet.setCombatTarget(null); - currentPet.setOwner(null); + currentPet.guardCaptain = null; WorldGrid.RemoveWorldObject(currentPet); //currentPet.getParentZone().zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet); @@ -125,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { } else { if (currentPet.isSiege()) { currentPet.agentType = Enum.AIAgentType.MOBILE; - currentPet.setOwner(null); + + currentPet.guardCaptain = null; currentPet.setCombatTarget(null); if (currentPet.isAlive()) @@ -137,26 +134,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { NPCManager.resetNecroPets(owner); } } - /* if(owner.getPet() != null) { - if(owner.getPet().getMobBaseID() != 12021 && owner.getPet().getMobBaseID() != 12022) { - //if not a necro pet, remove pet - WorldGrid.removeWorldObject(owner.getPet()); - owner.getPet().disableIntelligence(); - Mob.removePet(owner.getPet().getUUID()); - owner.setPet(null); - } - else { - //if it is a necro pet, add it to the line and set as mob - owner.getPet().setMob(); - } - }*/ - - // if (mobID == 12021 || mobID == 12022) //Necro Pets - // pet.setPet(owner, true); + owner.setPet(pet); - if(pet.isSiege() == false) { - MovementManager.translocate(pet, owner.getLoc(), owner.region); - } + pet.recalculateStats(); pet.healthMax = pet.level * 0.5f * 120; pet.setHealth(pet.healthMax); diff --git a/src/engine/powers/poweractions/FearPowerAction.java b/src/engine/powers/poweractions/FearPowerAction.java index c1bae2ed..da352aa5 100644 --- a/src/engine/powers/poweractions/FearPowerAction.java +++ b/src/engine/powers/poweractions/FearPowerAction.java @@ -59,7 +59,7 @@ public class FearPowerAction extends AbstractPowerAction { int duration = 10 + ((int) (trains * 0.5)); String stackType = ab.getStackType(); EndFearJob efj = new EndFearJob(source, awo, stackType, trains, ab, pb, null); - ((Mob) awo).setFearedObject(source); + ((Mob) awo).fearedObject = source; JobScheduler.getInstance().scheduleJob(efj, duration * 1000); } diff --git a/src/engine/powers/poweractions/TransferStatPowerAction.java b/src/engine/powers/poweractions/TransferStatPowerAction.java index 4deea480..f2673706 100644 --- a/src/engine/powers/poweractions/TransferStatPowerAction.java +++ b/src/engine/powers/poweractions/TransferStatPowerAction.java @@ -213,6 +213,7 @@ public class TransferStatPowerAction extends AbstractPowerAction { // put it back between min and max damage += min; + damage *= ((PlayerCharacter) source).ZergMultiplier; } // Apply any power effect modifiers (such as stances) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index eafae89b..7b25ff09 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -10,7 +10,6 @@ package engine.server.world; import engine.Enum; -import engine.Enum.BuildingGroup; import engine.Enum.DispatchChannel; import engine.Enum.MinionType; import engine.Enum.SupportMsgType; @@ -18,11 +17,13 @@ import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; +import engine.db.handlers.dbPowerHandler; import engine.exception.MsgSendException; import engine.gameManager.*; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.LogoutCharacterJob; +import engine.math.Vector3fImmutable; import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.MobRespawnThread; import engine.net.Dispatch; @@ -334,7 +335,7 @@ public class WorldServer { DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); Logger.info("Loading NPC and Mob Rune Sets"); - NPCManager.LoadAllRuneSets(); + NPCManager._runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); Logger.info("Loading Booty Sets"); LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); @@ -352,7 +353,7 @@ public class WorldServer { DbManager.MobBaseQueries.GET_ALL_MOBBASES(); Logger.info("Loading Mob Powers"); - PowersManager.AllMobPowers = DbManager.PowerQueries.LOAD_MOB_POWERS(); + PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS(); Logger.info("Loading item enchants"); DbManager.LootQueries.LOAD_ENCHANT_VALUES(); @@ -436,7 +437,7 @@ public class WorldServer { DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT(); //pick a startup Hotzone - ZoneManager.generateAndSetRandomHotzone(); + //ZoneManager.generateAndSetRandomHotzone(); Logger.info("Loading All Players from database to Server Cache"); long start = System.currentTimeMillis(); @@ -482,7 +483,7 @@ public class WorldServer { Logger.info("Initializing Client Connection Manager"); initClientConnectionManager(); - + //intiate mob respawn thread Logger.info("Starting Mob Respawn Thread"); MobRespawnThread.startRespawnThread(); @@ -551,44 +552,40 @@ public class WorldServer { } //Set sea floor object for server + Zone seaFloor = rootParent.get(0); seaFloor.setParent(null); ZoneManager.setSeaFloor(seaFloor); - // zoneManager.addZone(seaFloor.getLoadNum(), seaFloor); <- DIE IN A FUCKING CAR FIRE BONUS CODE LIKE THIS SUCKS FUCKING DICK - rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor)); long start = System.currentTimeMillis(); for (Zone zone : rootParent) { - try { - ZoneManager.addZone(zone.getLoadNum(), zone); + ZoneManager.addZone(zone.getLoadNum(), zone); + zone.generateWorldAltitude(); - try { - zone.generateWorldAltitude(); - } catch (Exception e) { - Logger.error(e.getMessage()); - e.printStackTrace(); - } - //Handle Buildings + //Handle Buildings + try { ArrayList bList; bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); for (Building b : bList) { - try { - b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); - b.setLoc(b.getLoc()); - } catch (Exception e) { - Logger.error(b.getObjectUUID() + " returned an Error Message :" + e.getMessage()); - } + b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); + b.setLoc(b.getLoc()); } + } catch (Exception e) { + Logger.error(e); + e.printStackTrace(); + } - //Handle Mobs + //Handle Mobs + + try { ArrayList mobs; mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone); @@ -596,15 +593,22 @@ public class WorldServer { m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks()); m.setLoc(m.getLoc()); - //ADD GUARDS HERE. - if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) - DbManager.MobQueries.LOAD_PATROL_POINTS(m); + // Load Minions for Guard Captains here. + + if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK) + DbManager.MobQueries.LOAD_GUARD_MINIONS(m); } + } catch (Exception e) { + Logger.error(e); + e.printStackTrace(); + } + + //Handle NPCs - //Handle npc's + try { ArrayList npcs; - // Ignore npc's on the seafloor (npc guild leaders, etc) + // Ignore NPCs on the seafloor (npc guild leaders, etc) if (zone.equals(seaFloor)) continue; @@ -612,26 +616,48 @@ public class WorldServer { npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone); for (NPC n : npcs) { + n.setObjectTypeMask(MBServerStatics.MASK_NPC); - try { - n.setObjectTypeMask(MBServerStatics.MASK_NPC); - n.setLoc(n.getLoc()); - } catch (Exception e) { - Logger.error(n.getObjectUUID() + " returned an Error Message :" + e.getMessage()); + if(n.contract.getContractID() == 1200) { + DbManager.NPCQueries.DELETE_NPC(n); + continue; } + n.setLoc(n.getLoc()); } - //Handle cities + } catch (Exception e) { + Logger.error(e); + e.printStackTrace(); + } + //Handle cities - ZoneManager.loadCities(zone); - ZoneManager.populateWorldZones(zone); + ZoneManager.loadCities(zone); + ZoneManager.populateWorldZones(zone); - } catch (Exception e) { - Logger.info(e.getMessage() + zone.getName() + ' ' + zone.getObjectUUID()); + } + //add extra vendors for lakebane + // + try { + Building sdrHut = BuildingManager.getBuilding(27979); + Zone sdr = sdrHut.parentZone; + boolean exists = false; + for(NPC merchant : sdr.zoneNPCSet) + if(merchant.contract.getContractID() == 1200) + exists = true; + if (!exists) { + NPC runeMerchant = NPC.createNPC("Runey", 1200, Vector3fImmutable.ZERO, Guild.getGuild(6), ZoneManager.getZoneByUUID(656), (short) 70, null); + runeMerchant.sellPercent = 9999.00f; + runeMerchant.buildingUUID = sdrHut.getObjectUUID(); + runeMerchant.building = sdrHut; + NPCManager.slotCharacterInBuilding(runeMerchant); + runeMerchant.setLoc(runeMerchant.bindLoc); + runeMerchant.updateDatabase(); } } - - Logger.info("time to load: " + (System.currentTimeMillis() - start) + " ms"); + catch(Exception e){ + Logger.error("FAILED TO ADD RUNE MERCHANT"); + } + Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } /** @@ -704,7 +730,7 @@ public class WorldServer { return; } //remove player from loaded mobs agro maps - for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) { + for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) { Mob loadedMob = (Mob) awo; loadedMob.playerAgroMap.remove(player.getObjectUUID()); } diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index dbf17e0c..eabd71f1 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -189,28 +189,28 @@ public class HourlyJobThread implements Runnable { Logger.info("Hourly job is now running."); - try { + //try { // Use the same hotZone this hour up and until // the HotZone_Duration from the ConfigManager - if (ZoneManager.hotZone == null) - ZoneManager.generateAndSetRandomHotzone(); - else - ZoneManager.hotZoneCycle = ZoneManager.hotZoneCycle + 1; + //if (ZoneManager.hotZone == null) + // ZoneManager.generateAndSetRandomHotzone(); + //else + // ZoneManager.hotZoneCycle = ZoneManager.hotZoneCycle + 1; - if (ZoneManager.hotZoneCycle > Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue())) - ZoneManager.generateAndSetRandomHotzone(); + //if (ZoneManager.hotZoneCycle > Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue())) + // ZoneManager.generateAndSetRandomHotzone(); - if (ZoneManager.hotZone == null) { - Logger.error("Null HotZone returned from ZoneManager"); - } else { - Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName()); - } + //if (ZoneManager.hotZone == null) { + // Logger.error("Null HotZone returned from ZoneManager"); + //} else { + // Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName()); + //} - } catch (Exception e) { - Logger.error(e.toString()); - } + //} catch (Exception e) { + // Logger.error(e.toString()); + //} // Open or Close mines for the current mine window.