Browse Source

Merge branch 'lakebane-zerg' into lakebane-master

# Conflicts:
#	src/engine/InterestManagement/InterestManager.java
#	src/engine/gameManager/SimulationManager.java
#	src/engine/mobileAI/MobAI.java
#	src/engine/objects/CharacterItemManager.java
#	src/engine/objects/Mine.java
#	src/engine/objects/PlayerCharacter.java
lakebane-master
FatBoy-DOTC 9 months ago
parent
commit
e89e2f51b7
  1. 17
      src/engine/Enum.java
  2. 29
      src/engine/InterestManagement/InterestManager.java
  3. 12
      src/engine/db/handlers/dbItemHandler.java
  4. 39
      src/engine/db/handlers/dbMobHandler.java
  5. 4
      src/engine/devcmd/cmds/AddMobCmd.java
  6. 19
      src/engine/devcmd/cmds/EnchantCmd.java
  7. 4
      src/engine/devcmd/cmds/InfoCmd.java
  8. 4
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  9. 4
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  10. 2
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  11. 2
      src/engine/devcmd/cmds/SlotTestCmd.java
  12. 2
      src/engine/devcmd/cmds/SplatMobCmd.java
  13. 36
      src/engine/devcmd/cmds/aiInfoCmd.java
  14. 11
      src/engine/gameManager/BuildingManager.java
  15. 6
      src/engine/gameManager/CombatManager.java
  16. 2
      src/engine/gameManager/DevCmdManager.java
  17. 187
      src/engine/gameManager/LootManager.java
  18. 21
      src/engine/gameManager/MaintenanceManager.java
  19. 80
      src/engine/gameManager/NPCManager.java
  20. 35
      src/engine/gameManager/PowersManager.java
  21. 58
      src/engine/gameManager/SimulationManager.java
  22. 166
      src/engine/gameManager/ZergManager.java
  23. 4
      src/engine/jobs/EndFearJob.java
  24. 9
      src/engine/loot/ModTableEntry.java
  25. 2
      src/engine/math/Bounds.java
  26. 168
      src/engine/mobileAI/MobAI.java
  27. 2
      src/engine/mobileAI/utilities/CombatUtilities.java
  28. 4
      src/engine/mobileAI/utilities/MovementUtilities.java
  29. 21
      src/engine/net/client/ClientMessagePump.java
  30. 55
      src/engine/net/client/handlers/ActivateNPCMsgHandler.java
  31. 3
      src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java
  32. 9
      src/engine/net/client/handlers/CityDataHandler.java
  33. 2
      src/engine/net/client/handlers/ManageCityAssetMsgHandler.java
  34. 2
      src/engine/net/client/handlers/MerchantMsgHandler.java
  35. 75
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  36. 6
      src/engine/net/client/handlers/ObjectActionMsgHandler.java
  37. 10
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  38. 2
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  39. 8
      src/engine/net/client/msg/ManageNPCMsg.java
  40. 61
      src/engine/objects/AbstractCharacter.java
  41. 31
      src/engine/objects/AbstractIntelligenceAgent.java
  42. 4
      src/engine/objects/AbstractWorldObject.java
  43. 28
      src/engine/objects/Blueprint.java
  44. 38
      src/engine/objects/CharacterItemManager.java
  45. 2
      src/engine/objects/Contract.java
  46. 19
      src/engine/objects/Guild.java
  47. 4
      src/engine/objects/Item.java
  48. 5
      src/engine/objects/ItemBase.java
  49. 4
      src/engine/objects/ItemFactory.java
  50. 105
      src/engine/objects/Mine.java
  51. 1071
      src/engine/objects/Mob.java
  52. 2
      src/engine/objects/MobEquipment.java
  53. 19
      src/engine/objects/NPC.java
  54. 37
      src/engine/objects/PlayerCharacter.java
  55. 71
      src/engine/objects/Warehouse.java
  56. 4
      src/engine/powers/effectmodifiers/HealthEffectModifier.java
  57. 3
      src/engine/powers/effectmodifiers/ManaEffectModifier.java
  58. 3
      src/engine/powers/effectmodifiers/StaminaEffectModifier.java
  59. 24
      src/engine/powers/poweractions/ApplyEffectPowerAction.java
  60. 36
      src/engine/powers/poweractions/CreateMobPowerAction.java
  61. 2
      src/engine/powers/poweractions/FearPowerAction.java
  62. 1
      src/engine/powers/poweractions/TransferStatPowerAction.java
  63. 108
      src/engine/server/world/WorldServer.java
  64. 30
      src/engine/workthreads/HourlyJobThread.java

17
src/engine/Enum.java

@ -2822,7 +2822,6 @@ public class Enum {
public enum MobBehaviourType { public enum MobBehaviourType {
None(null, false, false, false, false, false), None(null, false, false, false, false, false),
//Power
Power(null, false, true, true, true, false), Power(null, false, true, true, true, false),
PowerHelpee(Power, false, true, true, false, true), PowerHelpee(Power, false, true, true, false, true),
PowerHelpeeWimpy(Power, true, false, true, false, false), PowerHelpeeWimpy(Power, true, false, true, false, false),
@ -2847,6 +2846,7 @@ public class Enum {
//Independent Types //Independent Types
SimpleStandingGuard(null, false, false, false, false, false), SimpleStandingGuard(null, false, false, false, false, false),
Pet1(null, false, false, true, false, false), Pet1(null, false, false, true, false, false),
SiegeEngine(null, false, false, false, false, false),
Simple(null, false, false, true, false, false), Simple(null, false, false, true, false, false),
Helpee(null, false, true, true, false, true), Helpee(null, false, true, true, false, true),
HelpeeWimpy(null, true, false, true, false, false), HelpeeWimpy(null, true, false, true, false, false),
@ -2857,13 +2857,12 @@ public class Enum {
HamletGuard(null, false, true, false, false, false), HamletGuard(null, false, true, false, false, false),
AggroWanderer(null, false, false, true, false, false); AggroWanderer(null, false, false, true, false, false);
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>(); public final MobBehaviourType BehaviourHelperType;
public MobBehaviourType BehaviourHelperType; public final boolean isWimpy;
public boolean isWimpy; public final boolean isAgressive;
public boolean isAgressive; public final boolean canRoam;
public boolean canRoam; public final boolean callsForHelp;
public boolean callsForHelp; public final boolean respondsToCallForHelp;
public boolean respondsToCallForHelp;
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
this.BehaviourHelperType = helpeebehaviourType; this.BehaviourHelperType = helpeebehaviourType;
@ -2880,6 +2879,8 @@ public class Enum {
MOBILE, MOBILE,
PET, PET,
CHARMED, CHARMED,
SIEGEENGINE,
GUARD; GUARD;
} }
} }

29
src/engine/InterestManagement/InterestManager.java

@ -8,16 +8,17 @@
package engine.InterestManagement; 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;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.gameManager.ChatManager;
import engine.gameManager.GroupManager; import engine.gameManager.GroupManager;
import engine.gameManager.PowersManager; import engine.gameManager.PowersManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.RefreshGroupJob; import engine.jobs.RefreshGroupJob;
import engine.math.Vector3fImmutable;
import engine.net.AbstractNetMsg; import engine.net.AbstractNetMsg;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; 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.MoveToPointMsg;
import engine.net.client.msg.UnloadObjectsMsg; import engine.net.client.msg.UnloadObjectsMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase; import engine.powers.ActionsBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import static engine.math.FastMath.sqr; import static engine.math.FastMath.sqr;
@ -471,7 +473,7 @@ public enum InterestManager implements Runnable {
if (awonpc.despawned == true) if (awonpc.despawned == true)
continue; continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
((Mob) awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -484,7 +486,7 @@ public enum InterestManager implements Runnable {
if (!awonpc.isAlive()) if (!awonpc.isAlive())
continue; continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE))) if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE)))
((Mob) awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
@ -529,15 +531,19 @@ public enum InterestManager implements Runnable {
updateStaticList(player, origin); updateStaticList(player, origin);
updateMobileList(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; player.isBoxed = false;
for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){
if(pc.isActive() == false) if(pc.isActive() == false)
continue; continue;
if(pc.isEnteredWorld() == false) if(pc.isEnteredWorld() == false)
continue; continue;
if(origin.machineID.equals(pc.getClientConnection().machineID)){ if(origin.machineID.equals(pc.getClientConnection().machineID)){
//add deatshroud effect //add deatshroud effect
if(pc.isBoxed == true) if(pc.isBoxed == true)
@ -546,12 +552,7 @@ public enum InterestManager implements Runnable {
return; 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) { public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) {

12
src/engine/db/handlers/dbItemHandler.java

@ -135,7 +135,11 @@ public class dbItemHandler extends dbHandlerBase {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) if (rs.next())
worked = rs.getBoolean("result"); try {
worked = rs.getBoolean("result");
}catch(Exception e){
return true;
}
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
@ -350,7 +354,11 @@ public class dbItemHandler extends dbHandlerBase {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) if (rs.next())
worked = rs.getBoolean("result"); try {
worked = rs.getBoolean("result");
} catch(Exception e){
worked = true;
}
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);

39
src/engine/db/handlers/dbMobHandler.java

@ -28,31 +28,26 @@ public class dbMobHandler extends dbHandlerBase {
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
} }
public Mob ADD_MOB(Mob toAdd) { public Mob PERSIST(Mob toAdd) {
Mob mobile = null; Mob mobile = null;
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) { PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
preparedStatement.setLong(1, toAdd.getParentZoneID()); preparedStatement.setLong(1, toAdd.parentZoneUUID);
preparedStatement.setInt(2, toAdd.getMobBaseID()); preparedStatement.setInt(2, toAdd.loadID);
preparedStatement.setInt(3, toAdd.getGuildUUID()); preparedStatement.setInt(3, toAdd.guildUUID);
preparedStatement.setFloat(4, toAdd.getSpawnX()); preparedStatement.setFloat(4, toAdd.bindLoc.x);
preparedStatement.setFloat(5, toAdd.getSpawnY()); preparedStatement.setFloat(5, toAdd.bindLoc.y);
preparedStatement.setFloat(6, toAdd.getSpawnZ()); preparedStatement.setFloat(6, toAdd.bindLoc.z);
preparedStatement.setInt(7, 0); preparedStatement.setInt(7, 0);
preparedStatement.setFloat(8, toAdd.getSpawnRadius()); preparedStatement.setFloat(8, toAdd.spawnRadius);
preparedStatement.setInt(9, toAdd.getTrueSpawnTime()); preparedStatement.setInt(9, toAdd.spawnTime);
preparedStatement.setInt(10, toAdd.contractUUID);
if (toAdd.getContract() != null) preparedStatement.setInt(11, toAdd.buildingUUID);
preparedStatement.setInt(10, toAdd.getContract().getContractID()); preparedStatement.setInt(12, toAdd.level);
else preparedStatement.setString(13, toAdd.firstName);
preparedStatement.setInt(10, 0);
preparedStatement.setInt(11, toAdd.getBuildingID());
preparedStatement.setInt(12, toAdd.getLevel());
preparedStatement.setString(13, toAdd.getFirstName());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
@ -106,17 +101,17 @@ public class dbMobHandler extends dbHandlerBase {
return row_count; return row_count;
} }
public void LOAD_PATROL_POINTS(Mob captain) { public void LOAD_GUARD_MINIONS(Mob guardCaptain) {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) { PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) {
preparedStatement.setInt(1, captain.getObjectUUID()); preparedStatement.setInt(1, guardCaptain.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) { while (rs.next()) {
String name = rs.getString("name"); String minionName = rs.getString("name");
Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name); Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName);
if (toCreate == null) if (toCreate == null)
return; return;

4
src/engine/devcmd/cmds/AddMobCmd.java

@ -43,7 +43,7 @@ public class AddMobCmd extends AbstractDevCmd {
MobBase mb = (MobBase) mobbaseAGO; MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID(); int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100), Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, true, zone, null, 0, "", 1); null, zone, null, null, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID())); this.setResult(String.valueOf(mob.getDBID()));
@ -84,7 +84,7 @@ public class AddMobCmd extends AbstractDevCmd {
Mob mob = Mob.createMob(loadID, pc.getLoc(), Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, true, zone, null, 0, "", 1); null, zone, null, null, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
ChatManager.chatSayInfo(pc, ChatManager.chatSayInfo(pc,

19
src/engine/devcmd/cmds/EnchantCmd.java

@ -11,6 +11,7 @@ package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase;
public class EnchantCmd extends AbstractDevCmd { public class EnchantCmd extends AbstractDevCmd {
@ -55,21 +56,9 @@ public class EnchantCmd extends AbstractDevCmd {
this.setResult(String.valueOf(item.getObjectUUID())); this.setResult(String.valueOf(item.getObjectUUID()));
} else { } else {
int cnt = words.length; int cnt = words.length;
for (int i = 1; i < cnt; i++) { String enchant = words[1];
String enchant = words[i]; enchant = EffectsBase.getItemEffectsByName(enchant.toLowerCase());
boolean valid = true; item.addPermanentEnchantmentForDev(enchant, 0);
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 + '.');
}
cim.updateInventory(); cim.updateInventory();
} }
} }

4
src/engine/devcmd/cmds/InfoCmd.java

@ -440,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd {
output += "isSummonedPet: true"; output += "isSummonedPet: true";
else else
output += "isSummonedPet: false"; output += "isSummonedPet: false";
PlayerCharacter owner = targetMob.getOwner();
PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain;
if (owner != null) if (owner != null)
output += " owner: " + owner.getObjectUUID(); output += " owner: " + owner.getObjectUUID();
output += newline; output += newline;

4
src/engine/devcmd/cmds/PurgeObjectsCmd.java

@ -59,7 +59,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if (npc != null) { if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
@ -151,7 +151,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
if (npc != null) { if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);

4
src/engine/devcmd/cmds/RemoveObjectCmd.java

@ -154,7 +154,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
mobA = (Mob) ac; mobA = (Mob) ac;
if (npc != null) { if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob); //Mob.getRespawnMap().remove(mob);
@ -209,7 +209,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
if (npc.building != null) if (npc.building != null)
npc.building.getHirelings().remove(npc); npc.building.getHirelings().remove(npc);
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.siegeMinionMap.keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.getParentZone() != null)

2
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -51,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
int failures = 0; int failures = 0;
int goldAmount = 0; int goldAmount = 0;
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 10000; ++i) {
try { try {
mob.loadInventory(); mob.loadInventory();

2
src/engine/devcmd/cmds/SlotTestCmd.java

@ -71,7 +71,7 @@ public class SlotTestCmd extends AbstractDevCmd {
outString += "Hirelings List:"; outString += "Hirelings List:";
for (AbstractCharacter hireling : building.getHirelings().keySet()) 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);
} }

2
src/engine/devcmd/cmds/SplatMobCmd.java

@ -110,7 +110,7 @@ public class SplatMobCmd extends AbstractDevCmd {
mobile = Mob.createMob(_mobileUUID, mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange), Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, true, serverZone, null, 0, "", 1); null, serverZone, null, null, "", 1);
if (mobile != null) { if (mobile != null) {
mobile.updateDatabase(); mobile.updateDatabase();

36
src/engine/devcmd/cmds/aiInfoCmd.java

@ -11,6 +11,7 @@ package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.PowersManager;
import engine.objects.AbstractGameObject; import engine.objects.AbstractGameObject;
import engine.objects.Mob; import engine.objects.Mob;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
@ -56,36 +57,41 @@ public class aiInfoCmd extends AbstractDevCmd {
Mob mob = (Mob) target; Mob mob = (Mob) target;
output = "Mob AI Information:" + newline; output = "Mob AI Information:" + newline;
output += mob.getName() + newline; output += mob.getName() + newline;
if (mob.BehaviourType != null) { if (mob.behaviourType != null) {
output += "BehaviourType: " + mob.BehaviourType.toString() + newline; output += "BehaviourType: " + mob.behaviourType.toString() + newline;
if (mob.BehaviourType.BehaviourHelperType != null) { if (mob.behaviourType.BehaviourHelperType != null) {
output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline; output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline;
} else { } else {
output += "Behaviour Helper Type: NULL" + newline; output += "Behaviour Helper Type: NULL" + newline;
} }
output += "Wimpy: " + mob.BehaviourType.isWimpy + newline; output += "Wimpy: " + mob.behaviourType.isWimpy + newline;
output += "Agressive: " + mob.BehaviourType.isAgressive + newline; output += "Agressive: " + mob.behaviourType.isAgressive + newline;
output += "Can Roam: " + mob.BehaviourType.canRoam + newline; output += "Can Roam: " + mob.behaviourType.canRoam + newline;
output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline; output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline;
output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline; output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline;
} else { } else {
output += "BehaviourType: NULL" + newline; output += "BehaviourType: NULL" + newline;
} }
output += "Aggro Range: " + mob.getAggroRange() + newline; output += "Aggro Range: " + mob.getAggroRange() + newline;
output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline; output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline;
if (mob.playerAgroMap.size() > 0) { if (mob.playerAgroMap.size() > 0) {
output += "Players Loaded:" + newline; output += "Players Loaded:" + newline;
} }
for (Map.Entry<Integer, Boolean> entry : mob.playerAgroMap.entrySet()) { for (Map.Entry<Integer, Float> entry : mob.playerAgroMap.entrySet()) {
output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline; output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline;
} }
if (mob.getCombatTarget() != null) if (mob.getCombatTarget() != null)
output += "Current Target: " + mob.getCombatTarget().getName() + newline; output += "Current Target: " + mob.getCombatTarget().getName() + newline;
else else
output += "Current Target: NULL" + newline; output += "Current Target: NULL" + newline;
if (mob.guardedCity != null)
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
output += "Powers:" + newline;
for (int token : mob.mobPowers.keySet()) for (int token : mob.mobPowers.keySet())
output += token + newline; output += PowersManager.getPowerByToken(token).getName() + newline;
throwbackInfo(playerCharacter, output); throwbackInfo(playerCharacter, output);
} }

11
src/engine/gameManager/BuildingManager.java

@ -520,9 +520,10 @@ public enum BuildingManager {
if (building.getBlueprintUUID() == 0) if (building.getBlueprintUUID() == 0)
return false; 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; return false;
}
String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
if (item.getChargesRemaining() > 0) if (item.getChargesRemaining() > 0)
@ -535,7 +536,7 @@ public enum BuildingManager {
if (NPC.ISWallArcher(contract)) { 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) if (mob == null)
return false; return false;
@ -547,7 +548,7 @@ public enum BuildingManager {
if (NPC.ISGuardCaptain(contract.getContractID())) { 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) if (mob == null)
return false; return false;
@ -559,7 +560,7 @@ public enum BuildingManager {
if (contract.getContractID() == 910) { if (contract.getContractID() == 910) {
//guard dog //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) if (mob == null)
return false; return false;

6
src/engine/gameManager/CombatManager.java

@ -814,6 +814,9 @@ public enum CombatManager {
else else
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists); damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
damage *= ((PlayerCharacter)ac).ZergMultiplier;
}
float d = 0f; float d = 0f;
errorTrack = 12; errorTrack = 12;
@ -826,7 +829,8 @@ public enum CombatManager {
damage *= 2.5f; //increase damage if sitting damage *= 2.5f; //increase damage if sitting
if (tarAc.getObjectType() == GameObjectType.Mob) { 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); ((Mob) tarAc).handleDirectAggro(ac);
} }

2
src/engine/gameManager/DevCmdManager.java

@ -180,7 +180,7 @@ public enum DevCmdManager {
//kill any commands not available to everyone on production server //kill any commands not available to everyone on production server
//only admin level can run dev commands on production //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); Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd);
return false; return false;
} }

187
src/engine/gameManager/LootManager.java

@ -17,6 +17,7 @@ import engine.objects.*;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -34,6 +35,11 @@ public enum LootManager {
public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>(); public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>();
public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>(); public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>();
public static ArrayList<Integer> vorg_ha_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27580, 27590, 188500, 188510, 188520, 188530, 188540, 188550, 189510}));
public static ArrayList<Integer> vorg_ma_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27570,188900,188910,188920,188930,188940,188950,189500}));
public static ArrayList<Integer> vorg_la_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27550,27560,189100,189110,189120,189130,189140,189150}));
public static ArrayList<Integer> vorg_cloth_uuids = new ArrayList<>(Arrays.asList(new Integer[]{27600,188700,188720,189550,189560}));
// Drop Rates // Drop Rates
public static float NORMAL_DROP_RATE; public static float NORMAL_DROP_RATE;
@ -75,16 +81,13 @@ public enum LootManager {
public static void GenerateMobLoot(Mob mob) { public static void GenerateMobLoot(Mob mob) {
//determine if mob is in hotzone
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//iterate the booty sets //iterate the booty sets
if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true) 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) 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 //lastly, check mobs inventory for godly or disc runes to send a server announcement
for (Item it : mob.getInventory()) { for (Item it : mob.getInventory()) {
@ -102,38 +105,40 @@ public enum LootManager {
} }
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone) { private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob) {
boolean hotzoneWasRan = false; float dropRate = NORMAL_DROP_RATE;
float dropRate = 1.0f;
// Iterate all entries in this bootySet and process accordingly // Iterate all entries in this bootySet and process accordingly
for (BootySetEntry bse : entries) { for (BootySetEntry bse : entries) {
switch (bse.bootyType) { switch (bse.bootyType) {
case "GOLD": case "GOLD":
GenerateGoldDrop(mob, bse, inHotzone); GenerateGoldDrop(mob, bse);
break; break;
case "LOOT": 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)) if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate))
GenerateLootDrop(mob, bse.genTable, false); //generate normal loot drop GenerateLootDrop(mob, bse.genTable); //generate normal loot drop
if(ThreadLocalRandom.current().nextInt(1,101) < mob.level && mob.parentZone.getSafeZone() == 0) {
// Generate hotzone loot if in hotzone if (ThreadLocalRandom.current().nextInt(1, 10000) < mob.level) {
// Only one bite at the hotzone apple per bootyset. if (_genTables.containsKey(bse.genTable + 1)) {
int roll = ThreadLocalRandom.current().nextInt(1, 101);
if (inHotzone == true && hotzoneWasRan == false) MobLoot extraLoot = null;
if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { if (roll >= 1 && roll <= 50) {
GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table extraLoot = rollForContract(bse.genTable, mob);
hotzoneWasRan = true; }
if (roll >= 51 && roll <= 94) {
extraLoot = rollForRune(bse.genTable, mob);
}
if (roll >= 95) {
extraLoot = rollForGlass(mob);
}
if (extraLoot != null) {
mob.getCharItemManager().addItemToInventory(extraLoot);
}
}
} }
}
break; break;
case "ITEM": case "ITEM":
GenerateInventoryDrop(mob, bse); 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) if (mob == null || _genTables.containsKey(genTableID) == false)
return null; return null;
MobLoot outItem; 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); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
@ -167,7 +172,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { //52 = player character if(mob.getObjectType().ordinal() == 52) { //52 = player character
itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
itemTableRoll = TableRoll(mob.level, inHotzone); itemTableRoll = TableRoll(mob.level);
} }
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll);
if (tableRow == null) if (tableRow == null)
@ -179,6 +184,9 @@ public enum LootManager {
return null; return null;
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { 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); int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
} }
@ -189,7 +197,7 @@ public enum LootManager {
if(selectedRow.pModTable != 0){ if(selectedRow.pModTable != 0){
try { try {
outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); outItem = GeneratePrefix(mob, outItem, genTableID, genRoll);
outItem.setIsID(false); outItem.setIsID(false);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); Logger.error("Failed to GeneratePrefix for item: " + outItem.getName());
@ -197,7 +205,7 @@ public enum LootManager {
} }
if(selectedRow.sModTable != 0){ if(selectedRow.sModTable != 0){
try { try {
outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); outItem = GenerateSuffix(mob, outItem, genTableID, genRoll);
outItem.setIsID(false); outItem.setIsID(false);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); Logger.error("Failed to GenerateSuffix for item: " + outItem.getName());
@ -206,7 +214,7 @@ public enum LootManager {
return outItem; 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); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
@ -223,7 +231,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { if(mob.getObjectType().ordinal() == 52) {
prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
prefixTableRoll = TableRoll(mob.level, inHotzone); prefixTableRoll = TableRoll(mob.level);
} }
ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll);
@ -238,7 +246,7 @@ public enum LootManager {
return inItem; 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); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
@ -255,7 +263,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { if(mob.getObjectType().ordinal() == 52) {
suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
suffixTableRoll = TableRoll(mob.level, inHotzone); suffixTableRoll = TableRoll(mob.level);
} }
ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll);
@ -270,7 +278,7 @@ public enum LootManager {
return inItem; return inItem;
} }
public static int TableRoll(int mobLevel, Boolean inHotzone) { public static int TableRoll(int mobLevel) {
if (mobLevel > 65) if (mobLevel > 65)
mobLevel = 65; mobLevel = 65;
@ -285,15 +293,12 @@ public enum LootManager {
if (min < 70) if (min < 70)
min = 70; min = 70;
if (inHotzone)
min += mobLevel;
int roll = ThreadLocalRandom.current().nextInt(min, max + 1); int roll = ThreadLocalRandom.current().nextInt(min, max + 1);
return roll; 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); int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
@ -304,14 +309,9 @@ public enum LootManager {
//determine and add gold to mob inventory //determine and add gold to mob inventory
int high = bse.highGold; int high = (int)(bse.highGold * NORMAL_GOLD_RATE);
int low = bse.lowGold; int low = (int)(bse.lowGold * NORMAL_GOLD_RATE);
int gold = ThreadLocalRandom.current().nextInt(low, high + 1); int gold = ThreadLocalRandom.current().nextInt(low, high);
if (inHotzone == true)
gold = (int) (gold * HOTZONE_GOLD_RATE);
else
gold = (int) (gold * NORMAL_GOLD_RATE);
if (gold > 0) { if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, gold); 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 { 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); mob.getCharItemManager().addItemToInventory(toAdd);
}
} catch (Exception e) { } catch (Exception e) {
//TODO chase down loot generation error, affects roughly 2% of drops //TODO chase down loot generation error, affects roughly 2% of drops
int i = 0; int i = 0;
@ -350,8 +351,24 @@ public enum LootManager {
if (equipmentRoll > dropChance) if (equipmentRoll > dropChance)
continue; continue;
ItemBase genericIB = me.getItemBase();
MobLoot ml = new MobLoot(mob, me.getItemBase(), false); 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) { if (ml != null && dropCount < 1) {
ml.setIsID(true); ml.setIsID(true);
@ -461,4 +478,66 @@ public enum LootManager {
itemMan.addItemToInventory(playerWinnings); itemMan.addItemToInventory(playerWinnings);
itemMan.updateInventory(); 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;
}
} }

21
src/engine/gameManager/MaintenanceManager.java

@ -39,7 +39,7 @@ public enum MaintenanceManager {
// Build list of buildings to apply maintenance on. // 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); maintList = buildMaintList(buildingList);
// Deduct upkeep and build list of buildings // Deduct upkeep and build list of buildings
@ -53,7 +53,10 @@ public enum MaintenanceManager {
// Reset maintenance dates for these buildings // Reset maintenance dates for these buildings
for (Building building : maintList) { 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 // Derak or destroy buildings that did not
@ -74,7 +77,10 @@ public enum MaintenanceManager {
for (AbstractGameObject gameObject : buildingList) { 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) // No maintenance on NPC owned buildings (Cache loaded)
@ -154,7 +160,8 @@ public enum MaintenanceManager {
// Cache maintenance cost value // Cache maintenance cost value
maintCost = building.getMaintCost(); //maintCost = building.getMaintCost();
maintCost = 3000000;
// Something went wrong. Missing buildinggroup from switch? // 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 // Add cash back to strongbox for lost rank if the building isn't being destroyed
// and it's not an R8 deranking // and it's not an R8 deranking
if ((building.getRank() > 1) && (building.getRank() < 8)) { //if ((building.getRank() > 1) && (building.getRank() < 8)) {
building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7))); // building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7)));
} //}
return false; // Early exit for having failed to meet maintenance return false; // Early exit for having failed to meet maintenance
} }

80
src/engine/gameManager/NPCManager.java

@ -23,14 +23,6 @@ public enum NPCManager {
NPC_MANAGER; NPC_MANAGER;
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>(); public static HashMap<Integer, ArrayList<Integer>> _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) { public static void applyRuneSetEffects(Mob mob) {
// Early exit // Early exit
@ -127,10 +119,12 @@ public enum NPCManager {
DbManager.removeFromCache(necroPet); DbManager.removeFromCache(necroPet);
PlayerCharacter petOwner = necroPet.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain;
if (petOwner != null) { if (petOwner != null) {
necroPet.setOwner(null);
necroPet.guardCaptain = null;
petOwner.setPet(null); petOwner.setPet(null);
if (updateOwner == false) if (updateOwner == false)
@ -228,12 +222,14 @@ public enum NPCManager {
WorldGrid.removeObject(toRemove); WorldGrid.removeObject(toRemove);
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) { if (petOwner != null) {
petOwner.setPet(null); petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null); PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
@ -340,10 +336,19 @@ public enum NPCManager {
else else
buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building); 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) if (buildingSlot == -1)
Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); 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 // Override bind and location for this npc derived
// from BuildingManager slot location data. // from BuildingManager slot location data.
@ -370,4 +375,53 @@ public enum NPCManager {
return buildingSlot; 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;
}
}
}
} }

35
src/engine/gameManager/PowersManager.java

@ -300,15 +300,15 @@ public enum PowersManager {
int time = pb.getRecycleTime(trains); int time = pb.getRecycleTime(trains);
// verify player is in correct mode (combat/nonCombat) // verify player is in correct mode (combat/nonCombat)
if (playerCharacter.isCombat()) { //if (playerCharacter.isCombat()) {
if (!pb.allowedInCombat()) // if (!pb.allowedInCombat())
// ChatManager.chatPowerError(pc, // ChatManager.chatPowerError(pc,
// "This power is not allowed in combat mode."); // "This power is not allowed in combat mode.");
return true; // return true;
} else if (!pb.allowedOutOfCombat()) //} else if (!pb.allowedOutOfCombat())
// ChatManager.chatPowerError(pc, // ChatManager.chatPowerError(pc,
// "You must be in combat mode to use this power."); // "You must be in combat mode to use this power.");
return true; // return true;
// verify player is not stunned or prohibited from casting // verify player is not stunned or prohibited from casting
PlayerBonuses bonus = playerCharacter.getBonuses(); PlayerBonuses bonus = playerCharacter.getBonuses();
@ -842,8 +842,6 @@ public enum PowersManager {
return; return;
} }
playerCharacter.setHateValue(pb.getHateValue(trains));
//Send Cast Message. //Send Cast Message.
// PerformActionMsg castMsg = new PerformActionMsg(msg); // PerformActionMsg castMsg = new PerformActionMsg(msg);
// castMsg.setNumTrains(9999); // castMsg.setNumTrains(9999);
@ -894,8 +892,6 @@ public enum PowersManager {
//Power is aiding a target, handle aggro if combat target is a Mob. //Power is aiding a target, handle aggro if combat target is a Mob.
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) { if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target; PlayerCharacter pcTarget = (PlayerCharacter) target;
if (!pb.isHarmful())
Mob.HandleAssistedAggro(playerCharacter, pcTarget);
} }
// update target of used power timer // update target of used power timer
@ -1468,6 +1464,27 @@ public enum PowersManager {
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList( HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
allTargets, playerCharacter, maxTargets); allTargets, playerCharacter, maxTargets);
trackChars = new HashSet<>();
HashSet<AbstractWorldObject> allInRange = WorldGrid.getObjectsInRangePartial(playerCharacter.loc,MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_PLAYER);
ArrayList<Guild> 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); TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
// send track window // send track window

58
src/engine/gameManager/SimulationManager.java

@ -10,7 +10,6 @@ package engine.gameManager;
import engine.Enum; import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -31,7 +30,6 @@ public enum SimulationManager {
SERVERHEARTBEAT; SERVERHEARTBEAT;
private static final long CITY_PULSE = 2000; 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 RUNEGATE_PULSE = 3000;
private static final long UPDATE_PULSE = 1000; private static final long UPDATE_PULSE = 1000;
private static final long FlIGHT_PULSE = 100; private static final long FlIGHT_PULSE = 100;
@ -39,7 +37,7 @@ public enum SimulationManager {
public static Duration executionMax = Duration.ofNanos(1); public static Duration executionMax = Duration.ofNanos(1);
private static SimulationManager instance = null; private static SimulationManager instance = null;
private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; 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() private long _runegatePulseTime = System.currentTimeMillis()
+ RUNEGATE_PULSE; + RUNEGATE_PULSE;
private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE; private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE;
@ -132,18 +130,7 @@ public enum SimulationManager {
pulseMines(); pulseMines();
} catch (Exception e) { } catch (Exception e) {
Logger.error( Logger.error(
"Fatal error in City Pulse: DISABLED. Error Message : " "Fatal error in Mine 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 : "
+ e.getMessage()); + e.getMessage());
e.printStackTrace(); e.printStackTrace();
@ -175,8 +162,6 @@ public enum SimulationManager {
if (player == null) if (player == null)
continue; continue;
player.update(); player.update();
} }
@ -226,31 +211,9 @@ public enum SimulationManager {
city = (City) cityObject; city = (City) cityObject;
city.onEnter(); city.onEnter();
} }
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE; _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<AbstractGameObject> 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 * Method runs proximity collision detection for all active portals on the
* game's Runegates * game's Runegates
@ -264,4 +227,21 @@ public enum SimulationManager {
_runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE;
} }
private void pulseMines(){
Mine mine;
Collection<AbstractGameObject> 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;
}
} }

166
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;
}
}

4
src/engine/jobs/EndFearJob.java

@ -29,7 +29,7 @@ public class EndFearJob extends AbstractEffectJob {
if (this.target == null || (!(this.target instanceof Mob))) if (this.target == null || (!(this.target instanceof Mob)))
return; return;
((Mob) this.target).setFearedObject(null); ((Mob) this.target).fearedObject = null;
} }
@Override @Override
@ -40,6 +40,6 @@ public class EndFearJob extends AbstractEffectJob {
if (this.target == null || (!(this.target instanceof Mob))) if (this.target == null || (!(this.target instanceof Mob)))
return; return;
((Mob) this.target).setFearedObject(null); ((Mob) this.target).fearedObject = null;
} }
} }

9
src/engine/loot/ModTableEntry.java

@ -34,10 +34,15 @@ public class ModTableEntry {
itemTableEntryList = LootManager._modTables.get(modTablwe); 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) if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
modTableEntry = iteration; modTableEntry = iteration;
}
return modTableEntry; return modTableEntry;
} }
} }

2
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. //player is inside building region, skip collision check. we only do collision from the outside.
if (player.region != null && player.region.parentBuildingID == building.getObjectUUID()) if (player.region != null && player.region.parentBuildingID == building.getObjectUUID())
continue; continue;
if (building.getBounds().colliders == null) if (building.getBounds() == null || building.getBounds().colliders == null)
continue; continue;
for (Colliders collider : building.getBounds().colliders) { for (Colliders collider : building.getBounds().colliders) {

168
src/engine/mobileAI/MobAI.java

@ -96,7 +96,7 @@ public class MobAI {
return; return;
} }
if (mob.BehaviourType.callsForHelp) if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
if (!MovementUtilities.inRangeDropAggro(mob, target)) { if (!MovementUtilities.inRangeDropAggro(mob, target)) {
@ -155,7 +155,9 @@ public class MobAI {
public static void AttackBuilding(Mob mob, Building target) { public static void AttackBuilding(Mob mob, Building target) {
try { try {
if(target == null){
return;
}
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
@ -165,7 +167,7 @@ public class MobAI {
if (playercity != null) if (playercity != null)
for (Mob guard : playercity.getParent().zoneMobSet) 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())) if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob); guard.setCombatTarget(mob);
@ -202,6 +204,7 @@ public class MobAI {
} }
} catch (Exception e) { } catch (Exception e) {
mob.setCombatTarget(null);
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); 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 //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; Building barracks = mob.building;
@ -280,7 +283,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
//make sure mob is out of combat stance //make sure mob is out of combat stance
@ -312,9 +315,9 @@ public class MobAI {
int contractID; int contractID;
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.npcOwner.contract.getContractID(); contractID = mob.guardCaptain.contract.getContractID();
else else
contractID = mob.contract.getContractID(); contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false) if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
@ -350,7 +353,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens; ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.BehaviourType.callsForHelp) if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile. // Generate a list of tokens from the mob powers for this mobile.
@ -433,7 +436,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens; ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.BehaviourType.callsForHelp) if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile. // Generate a list of tokens from the mob powers for this mobile.
@ -564,7 +567,7 @@ public class MobAI {
Zone mobCamp = mob.getParentZone(); Zone mobCamp = mob.getParentZone();
for (Mob helper : mobCamp.zoneMobSet) { 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()); helper.setCombatTarget(mob.getCombatTarget());
callGotResponse = true; callGotResponse = true;
} }
@ -608,8 +611,8 @@ public class MobAI {
if (mob.despawned && mob.isPlayerGuard) { if (mob.despawned && mob.isPlayerGuard) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) { if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {
//minions don't respawn while guard captain is dead //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 //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); CheckToSendMobHome(mob);
return; return;
@ -646,7 +649,7 @@ public class MobAI {
return; return;
} }
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@ -673,7 +676,7 @@ public class MobAI {
} }
} }
switch (mob.BehaviourType) { switch (mob.behaviourType) {
case GuardCaptain: case GuardCaptain:
GuardCaptainLogic(mob); GuardCaptainLogic(mob);
break; break;
@ -684,6 +687,7 @@ public class MobAI {
GuardWallArcherLogic(mob); GuardWallArcherLogic(mob);
break; break;
case Pet1: case Pet1:
case SiegeEngine:
PetLogic(mob); PetLogic(mob);
break; break;
case HamletGuard: case HamletGuard:
@ -693,8 +697,6 @@ public class MobAI {
DefaultLogic(mob); DefaultLogic(mob);
break; break;
} }
if(mob.isAlive())
RecoverHealth(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
} }
@ -709,7 +711,7 @@ public class MobAI {
if (!aiAgent.isAlive()) if (!aiAgent.isAlive())
return; return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = aiAgent.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry playerEntry : loadedPlayers.entrySet()) {
@ -784,33 +786,39 @@ public class MobAI {
mob.updateLocation(); mob.updateLocation();
switch (mob.BehaviourType) { switch (mob.behaviourType) {
case Pet1: case Pet1:
if (mob.getOwner() == null)
if ((PlayerCharacter) mob.guardCaptain == null)
return; 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 //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; return;
} }
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
//move back to owner //move back to owner
if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6))
if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6))
return; return;
mob.destination = mob.getOwner().getLoc();
mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 5); MovementUtilities.moveToLocation(mob, mob.destination, 5);
} else } else
chaseTarget(mob); chaseTarget(mob);
break; break;
case GuardMinion: case GuardMinion:
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned)
randomGuardPatrolPoint(mob); randomGuardPatrolPoint(mob);
else { else {
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@ -829,7 +837,6 @@ public class MobAI {
chaseTarget(mob); chaseTarget(mob);
} }
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
@ -896,7 +903,8 @@ public class MobAI {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
return; 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); mob.setCombatTarget(null);
return; return;
@ -912,10 +920,10 @@ public class MobAI {
private static void CheckToSendMobHome(Mob mob) { private static void CheckToSendMobHome(Mob mob) {
try { try {
if (mob.BehaviourType.isAgressive) { if (mob.behaviourType.isAgressive) {
if (mob.isPlayerGuard()) { if (mob.isPlayerGuard()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
} else { } else {
CheckForAggro(mob); CheckForAggro(mob);
@ -935,7 +943,7 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); 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 //guard captain pulls his minions home with him
@ -951,8 +959,8 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
for (Entry playerEntry : mob.playerAgroMap.entrySet()) for (Integer playerEntry : mob.playerAgroMap.keySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); mob.playerAgroMap.put(playerEntry,0f);
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); 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))) if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD)))
continue; continue;
if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)) if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1))
continue; continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
@ -1046,6 +1054,7 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
@ -1056,15 +1065,29 @@ public class MobAI {
public static void GuardMinionLogic(Mob mob) { public static void GuardMinionLogic(Mob mob) {
try { try {
boolean isComanded = mob.npcOwner.isAlive(); if (!mob.guardCaptain.isAlive()) {
if (!isComanded) {
GuardCaptainLogic(mob); 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 { }else {
if (mob.npcOwner.getCombatTarget() != null) if (mob.guardCaptain.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget()); mob.setCombatTarget(mob.guardCaptain.getCombatTarget());
else else if (mob.getCombatTarget() != null)
if (mob.getCombatTarget() != null) mob.setCombatTarget(null);
mob.setCombatTarget(null);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
@ -1089,14 +1112,31 @@ public class MobAI {
try { 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)) if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner"); mob.killCharacter("no owner");
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); 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) if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (mob.BehaviourType.isAgressive) { if (mob.behaviourType.isAgressive) {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
@ -1135,7 +1175,7 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
else { else {
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard) if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard)
SafeGuardAggro(mob); //safehold guard SafeGuardAggro(mob); //safehold guard
else else
CheckForAggro(mob); //normal aggro CheckForAggro(mob); //normal aggro
@ -1145,12 +1185,12 @@ public class MobAI {
//check if mob can move for patrol or moving to target //check if mob can move for patrol or moving to target
if (mob.BehaviourType.canRoam) if (mob.behaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy //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); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
@ -1167,7 +1207,7 @@ public class MobAI {
if (!mob.isAlive()) if (!mob.isAlive())
return; return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = mob.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry playerEntry : loadedPlayers.entrySet()) {
@ -1215,8 +1255,8 @@ public class MobAI {
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false; return false;
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true; return true;
} }
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
@ -1300,7 +1340,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
@ -1327,7 +1367,7 @@ public class MobAI {
float CurrentHateValue = 0; float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) 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; AbstractWorldObject mostHatedTarget = null;
@ -1338,8 +1378,8 @@ public class MobAI {
if (potentialTarget.equals(mob.getCombatTarget())) if (potentialTarget.equals(mob.getCombatTarget()))
continue; continue;
if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue(); CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
mostHatedTarget = potentialTarget; mostHatedTarget = potentialTarget;
} }
@ -1350,22 +1390,4 @@ public class MobAI {
} }
return null; 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());
}
}
} }

2
src/engine/mobileAI/utilities/CombatUtilities.java

@ -48,7 +48,7 @@ public class CombatUtilities {
} }
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) { 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) { public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {

4
src/engine/mobileAI/utilities/MovementUtilities.java

@ -13,10 +13,10 @@ import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.ModType; import engine.Enum.ModType;
import engine.Enum.SourceType; import engine.Enum.SourceType;
import engine.mobileAI.Threads.MobAIThread;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
import engine.gameManager.MovementManager; import engine.gameManager.MovementManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.net.client.msg.MoveToPointMsg; import engine.net.client.msg.MoveToPointMsg;
import engine.objects.*; import engine.objects.*;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -38,7 +38,7 @@ public class MovementUtilities {
if (agent.getContract() != null) if (agent.getContract() != null)
guardCaptain = agent; guardCaptain = agent;
else else
guardCaptain = (Mob) agent.npcOwner; guardCaptain = (Mob) agent.guardCaptain;
if (guardCaptain != null) { if (guardCaptain != null) {
Building barracks = guardCaptain.building; Building barracks = guardCaptain.building;

21
src/engine/net/client/ClientMessagePump.java

@ -9,6 +9,7 @@
package engine.net.client; package engine.net.client;
import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
@ -560,12 +561,17 @@ public class ClientMessagePump implements NetMsgHandler {
if (!itemManager.inventoryContains(i)) if (!itemManager.inventoryContains(i))
return; return;
if (i.isCanDestroy()) if (i.isCanDestroy()) {
if (itemManager.delete(i) == true) { 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); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
} }
}
} }
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) { private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
@ -1888,6 +1894,17 @@ public class ClientMessagePump implements NetMsgHandler {
break; break;
case LEAVEREQUEST: case LEAVEREQUEST:
origin.disconnect(); origin.disconnect();
ArrayList<PlayerCharacter> 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; break;
case POWER: case POWER:
PowersManager.usePower((PerformActionMsg) msg, origin, false); PowersManager.usePower((PerformActionMsg) msg, origin, false);

55
src/engine/net/client/handlers/ActivateNPCMsgHandler.java

@ -57,6 +57,21 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
if (contract.canSlotinBuilding(building)) if (contract.canSlotinBuilding(building))
ItemLists.add(hirelings); 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; return false;
} }
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) if (building.getBlueprint().getSlotsForRank(building.getRank()) == building.getHirelings().size())
return false; return false;
Item contractItem = Item.getFromCache(msg.getContractItem()); Item contractItem = Item.getFromCache(msg.getContractItem());
if (contractItem == null) if (contractItem == null)
return false; 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())) { if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) {
Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!"); 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; return false;
// Check if contract can be slotted in this building // Check if contract can be slotted in this building
//Logger.error("inserting contract: " + contract.getContractID());
if (contract.canSlotinBuilding(building) == false) if (contract.canSlotinBuilding(building) == false) {
return 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)) if (!BuildingManager.addHireling(building, player, zone, contract, contractItem))
return false; return false;

3
src/engine/net/client/handlers/ArcLoginNotifyMsgHandler.java

@ -66,6 +66,9 @@ public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler {
// Send Guild, Nation and IC MOTD // Send Guild, Nation and IC MOTD
GuildManager.enterWorldMOTD(player); GuildManager.enterWorldMOTD(player);
ChatManager.sendSystemMessage(player, ConfigManager.MB_WORLD_GREETING.getValue()); 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. // Send branch string if available from ConfigManager.

9
src/engine/net/client/handlers/CityDataHandler.java

@ -61,15 +61,6 @@ public class CityDataHandler extends AbstractClientMsgHandler {
dispatch = Dispatch.borrow(playerCharacter, cityDataMsg); dispatch = Dispatch.borrow(playerCharacter, cityDataMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); 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 // Serialize the realms for this map
WorldRealmMsg worldRealmMsg = new WorldRealmMsg(); WorldRealmMsg worldRealmMsg = new WorldRealmMsg();

2
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 // 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. // Players cannot destroy or transfer a TOL.

2
src/engine/net/client/handlers/MerchantMsgHandler.java

@ -147,7 +147,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
Building shrineBuilding; Building shrineBuilding;
Shrine shrine; Shrine shrine;
if (npc.getGuild() != player.getGuild()) if (npc.getGuild().getNation() != player.getGuild().getNation())
return; return;
shrineBuilding = npc.getBuilding(); shrineBuilding = npc.getBuilding();

75
src/engine/net/client/handlers/MinionTrainingMsgHandler.java

@ -8,7 +8,6 @@ import engine.gameManager.BuildingManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.NPCManager; import engine.gameManager.NPCManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
@ -42,7 +41,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (player == null) if (player == null)
return true; return true;
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) { if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
NPC npc = NPC.getFromCache(minionMsg.getNpcID()); NPC npc = NPC.getFromCache(minionMsg.getNpcID());
@ -63,10 +61,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
Mob toRemove = Mob.getFromCache(minionMsg.getUUID()); Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
if (!npc.getSiegeMinionMap().containsKey(toRemove)) if (!npc.siegeMinionMap.containsKey(toRemove))
return true; return true;
npc.getSiegeMinionMap().remove(toRemove); npc.siegeMinionMap.remove(toRemove);
WorldGrid.RemoveWorldObject(toRemove); WorldGrid.RemoveWorldObject(toRemove);
@ -74,14 +72,18 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove); toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
if (petOwner != null) { if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
petOwner.setPet(null); PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null); if (petOwner != null) {
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); petOwner.setPet(null);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
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. // 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) if (npc.getContractID() == 842)
maxSlots = 1; maxSlots = 1;
if (npc.getSiegeMinionMap().size() == maxSlots) if (npc.siegeMinionMap.size() == maxSlots)
return true; return true;
int mobBase; int mobBase;
@ -146,42 +148,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (mobBase == 0) if (mobBase == 0)
return true; return true;
Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1); Mob siegeMob = Mob.createSiegeMinion(npc, mobBase);
if (siegeMob == null) if (siegeMob == null)
return true; 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); ManageNPCMsg mnm = new ManageNPCMsg(npc);
@ -228,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove); toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) { if (petOwner != null) {
petOwner.setPet(null); petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null); PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
@ -298,14 +271,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
String pirateName = NPCManager.getPirateName(mobBase); String pirateName = NPCManager.getPirateName(mobBase);
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName);
return true;
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
if (toCreate == null) if (toCreate == null)
return true; return true;
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
return true;
if (toCreate != null) { if (toCreate != null) {
toCreate.setDeathTime(System.currentTimeMillis()); toCreate.setDeathTime(System.currentTimeMillis());
toCreate.parentZone.zoneMobSet.add(toCreate); toCreate.parentZone.zoneMobSet.add(toCreate);

6
src/engine/net/client/handlers/ObjectActionMsgHandler.java

@ -439,8 +439,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
// } // }
// break; // break;
//} //}
int i = 0;
LootManager.peddleFate(player,item); if(i != 0) {
LootManager.peddleFate(player, item);
}
break; break;
case 30: //water bucket case 30: //water bucket

10
src/engine/net/client/handlers/OrderNPCMsgHandler.java

@ -212,10 +212,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
return; return;
} }
for (AbstractCharacter guard : building.getHirelings().keySet()) {
if (guard.getObjectType() == GameObjectType.Mob)
((Mob) guard).setPatrolPointIndex(0);
}
} else if (building.getPatrolPoints() != null) } else if (building.getPatrolPoints() != null)
ClearPatrolPoints(building.getObjectUUID()); ClearPatrolPoints(building.getObjectUUID());
@ -223,10 +219,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
AddSentryPoints(building.getObjectUUID(), orderNpcMsg.getSentryPoints()); AddSentryPoints(building.getObjectUUID(), orderNpcMsg.getSentryPoints());
} else if (building.getSentryPoints() != null) } else if (building.getSentryPoints() != null)
ClearSentryPoints(building.getObjectUUID()); ClearSentryPoints(building.getObjectUUID());
// Dispatch dispatch = Dispatch.borrow(pc, msg);
// DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
} }
private static void processUpgradeNPC(PlayerCharacter player, AbstractCharacter abstractCharacter) { private static void processUpgradeNPC(PlayerCharacter player, AbstractCharacter abstractCharacter) {
@ -541,7 +533,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) { } else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID()); mob = Mob.getMob(orderNPCMsg.getNpcUUID());
if (mob == null) if (mob == null)
return true; return true;

2
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -800,7 +800,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING); treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
treeObject.setParentZone(zoneObject); treeObject.setParentZone(zoneObject);
MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7)); MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(14));
// Update guild binds and tags // Update guild binds and tags
//load the new city on the clients //load the new city on the clients

8
src/engine/net/client/msg/ManageNPCMsg.java

@ -343,7 +343,7 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(0); //runemaster list writer.putInt(0); //runemaster list
//artillery captain list //artillery captain list
ConcurrentHashMap<Mob, Integer> siegeMinions = npc.getSiegeMinionMap(); ConcurrentHashMap<Mob, Integer> siegeMinions = npc.siegeMinionMap;
writer.putInt(1 + siegeMinions.size()); writer.putInt(1 + siegeMinions.size());
serializeBulwarkList(writer, 1); //Trebuchet serializeBulwarkList(writer, 1); //Trebuchet
//serializeBulwarkList(writer, 2); //Ballista //serializeBulwarkList(writer, 2); //Ballista
@ -366,7 +366,7 @@ public class ManageNPCMsg extends ClientNetMsg {
long timeLife = upgradeTime - curTime; long timeLife = upgradeTime - curTime;
if (upgradeTime * 1000 > System.currentTimeMillis()) { if (upgradeTime * 1000 > System.currentTimeMillis()) {
if (mob.npcOwner.isAlive()) { if (mob.guardCaptain.isAlive()) {
writer.put((byte) 0);//shows respawning timer writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg {
} else if (this.targetType == GameObjectType.Mob.ordinal()) { } else if (this.targetType == GameObjectType.Mob.ordinal()) {
mobA = Mob.getFromCacheDBID(this.targetID); mobA = Mob.getMob(this.targetID);
if (mobA == null) { if (mobA == null) {
Logger.error("Missing Mob of ID " + this.targetID); Logger.error("Missing Mob of ID " + this.targetID);
@ -689,7 +689,7 @@ public class ManageNPCMsg extends ClientNetMsg {
long timeLife = upgradeTime - curTime; long timeLife = upgradeTime - curTime;
if (upgradeTime * 1000 > System.currentTimeMillis()) { if (upgradeTime * 1000 > System.currentTimeMillis()) {
if (mob.npcOwner.isAlive()) { if (mob.guardCaptain.isAlive()) {
writer.put((byte) 0);//shows respawning timer writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);

61
src/engine/objects/AbstractCharacter.java

@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public int contractUUID; public int contractUUID;
public Contract contract; public Contract contract;
protected String firstName; public String firstName;
protected String lastName; public String lastName;
protected short statStrCurrent; protected short statStrCurrent;
protected short statDexCurrent; protected short statDexCurrent;
protected short statConCurrent; protected short statConCurrent;
@ -117,16 +117,33 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected boolean movingUp = false; protected boolean movingUp = false;
private float desiredAltitude = 0; private float desiredAltitude = 0;
private long takeOffTime = 0; private long takeOffTime = 0;
private float hateValue = 0;
private long lastHateUpdate = 0; private long lastHateUpdate = 0;
private boolean collided = false;
private byte aoecntr = 0; private byte aoecntr = 0;
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public AbstractCharacter() { public AbstractCharacter() {
super(); super();
this.firstName = "";
this.lastName = "";
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); this.statStrCurrent = (short) 0;
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); 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(); 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.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter(); 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.powers = new ConcurrentHashMap<>();
this.initializeCharacter(); 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<>(); this.powers = new ConcurrentHashMap<>();
initializeCharacter(); 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.powers = new ConcurrentHashMap<>();
this.initializeCharacter(); this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
} }
public static int getBankCapacity() { public static int getBankCapacity() {
@ -1758,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.inBuildingID = inBuildingID; 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() { public int getInFloorID() {
return inFloorID; return inFloorID;
} }

31
src/engine/objects/AbstractIntelligenceAgent.java

@ -9,6 +9,7 @@
package engine.objects; package engine.objects;
import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum; import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.ModType; import engine.Enum.ModType;
@ -31,7 +32,20 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
protected Vector3fImmutable lastBindLoc; protected Vector3fImmutable lastBindLoc;
public boolean assist = false; public boolean assist = false;
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
public boolean isPlayerGuard = false;
public AbstractCharacter guardCaptain;
public EnumBitSet<Enum.MonsterType> notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class);
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(Enum.MonsterType.class);
;
public Enum.MobBehaviourType behaviourType;
public ArrayList<Vector3fImmutable> patrolPoints;
public int lastPatrolPointIndex = 0;
public long stopPatrolTime = 0;
public City guardedCity;
public AbstractIntelligenceAgent() {
super();
}
public AbstractIntelligenceAgent(ResultSet rs) throws SQLException { public AbstractIntelligenceAgent(ResultSet rs) throws SQLException {
super(rs); super(rs);
@ -87,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
this.agentType = Enum.AIAgentType.CHARMED; this.agentType = Enum.AIAgentType.CHARMED;
if (this.getObjectType().equals(GameObjectType.Mob)) { 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; return 0;
} }
public PlayerCharacter getOwner() {
if (this.getObjectType().equals(GameObjectType.Mob))
return this.getOwner();
return null;
}
public boolean getSafeZone() { public boolean getSafeZone() {
ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc()); ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc());
@ -158,7 +165,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
//clear owner //clear owner
PlayerCharacter owner = this.getOwner(); PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
//close pet window //close pet window
@ -174,7 +181,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
owner.setPet(null); owner.setPet(null);
if (this.getObjectType().equals(GameObjectType.Mob)) if (this.getObjectType().equals(GameObjectType.Mob))
((Mob) this).setOwner(null); ((Mob) this).guardCaptain = null;
} }

4
src/engine/objects/AbstractWorldObject.java

@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
Mob mob = (Mob) this; Mob mob = (Mob) this;
if (mob.isSiege()) { if (mob.isSiege()) {
if (mob.isPet()) { if (mob.isPet()) {
PlayerCharacter petOwner = mob.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain;
if (petOwner != null && source.equals(EffectSourceType.Effect)) { if (petOwner != null && source.equals(EffectSourceType.Effect)) {
petOwner.dismissPet(); petOwner.dismissPet();
return; return;

28
src/engine/objects/Blueprint.java

@ -167,10 +167,7 @@ public class Blueprint {
// based upon the building's current rank // based upon the building's current rank
public static int getNpcMaintCost(int rank) { public static int getNpcMaintCost(int rank) {
int maintCost = Integer.MAX_VALUE; int maintCost = 0;
maintCost = (9730 * rank) + 1890;
return maintCost; return maintCost;
} }
@ -313,10 +310,10 @@ public class Blueprint {
// Early exit for buildings with single or no slots // 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; return maxSlots;
if (this.maxRank == 1 && currentRank == 1) if (this.maxRank == 1 && currentRank == 1&& this.buildingGroup.equals(BuildingGroup.TOL) == false)
return getMaxSlots(); return getMaxSlots();
switch (currentRank) { switch (currentRank) {
@ -328,20 +325,22 @@ public class Blueprint {
case 3: case 3:
case 4: case 4:
case 5: case 5:
case 6:
availableSlots = 2; availableSlots = 2;
break; break;
case 6:
case 7: case 7:
availableSlots = 3; availableSlots = 3;
break; break;
case 8: case 8:
availableSlots = 1; availableSlots = 3;
break; break;
default: default:
availableSlots = 0; availableSlots = 0;
break; break;
} }
if(this.buildingGroup.equals(BuildingGroup.TOL)){
availableSlots += 1;
}
return availableSlots; return availableSlots;
} }
@ -609,17 +608,10 @@ public class Blueprint {
switch (this.buildingGroup) { switch (this.buildingGroup) {
case TOL: case TOL:
case BARRACK: maintCost = 3000000;
maintCost = (61500 * rank) + 19500;
break;
case SPIRE:
maintCost = (4800 * rank) + 1200;
break; break;
default: default:
if (maxRank == 1) maintCost = 0;
maintCost = 22500;
else
maintCost = (15900 * rank) + 3300;
break; break;
} }

38
src/engine/objects/CharacterItemManager.java

@ -1244,13 +1244,33 @@ public class CharacterItemManager {
return false; 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); ItemBase ib = i.getItemBase();
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); if (ib != null)
this.inventoryWeight += ib.getWeight();
}
}else {
this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
ItemBase ib = i.getItemBase(); ItemBase ib = i.getItemBase();
if (ib != null) if (ib != null)
this.inventoryWeight += ib.getWeight(); this.inventoryWeight += ib.getWeight();
}
return true; return true;
} }
@ -2095,7 +2115,7 @@ public class CharacterItemManager {
if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) { if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pc = (PlayerCharacter) this.absCharacter; PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
int newWeight = this.getCarriedWeight() + weight; int newWeight = this.getCarriedWeight() + weight;
return newWeight <= pc.getInventoryCapacity(); return newWeight <= (int) pc.statStrBase * 3;
} else if (this.absCharacter.getObjectType() == GameObjectType.NPC) { } else if (this.absCharacter.getObjectType() == GameObjectType.NPC) {
int newWeight = this.getCarriedWeight() + weight; int newWeight = this.getCarriedWeight() + weight;
return newWeight <= 1900 + (this.absCharacter.getLevel() * 3); return newWeight <= 1900 + (this.absCharacter.getLevel() * 3);
@ -2128,7 +2148,7 @@ public class CharacterItemManager {
tradeWeight = tradeWeight + tradeCharacter.getCharItemManager().getTradingWeight(); tradeWeight = tradeWeight + tradeCharacter.getCharItemManager().getTradingWeight();
tradeWeight = tradeWeight - this.getTradingWeight(); tradeWeight = tradeWeight - this.getTradingWeight();
return tradeWeight <= playerCharacter.getInventoryCapacity(); return tradeWeight <= (int) playerCharacter.statStrBase * 3;
} }
public boolean hasRoomBank(short weight) { public boolean hasRoomBank(short weight) {
@ -2432,9 +2452,9 @@ public class CharacterItemManager {
if (item == null || amount < 1 || amount > 5) if (item == null || amount < 1 || amount > 5)
return; return;
//dont damage items when dieing in safezone if(ZoneManager.findSmallestZone(this.getOwner().loc).getSafeZone() == 1){
if(ZoneManager.findSmallestZone(this.absCharacter.getLoc()).getSafeZone() == 0)
return; return;
}
//verify the item is equipped by this player //verify the item is equipped by this player
int slot = item.getEquipSlot(); int slot = item.getEquipSlot();

2
src/engine/objects/Contract.java

@ -30,7 +30,7 @@ public class Contract extends AbstractGameObject {
public int inventorySet = 0; public int inventorySet = 0;
private int vendorID; private int vendorID;
private boolean isTrainer; private boolean isTrainer;
private VendorDialog vendorDialog; public VendorDialog vendorDialog;
private ArrayList<Integer> npcMenuOptions = new ArrayList<>(); private ArrayList<Integer> npcMenuOptions = new ArrayList<>();
private ArrayList<Integer> npcModTypeTable = new ArrayList<>(); private ArrayList<Integer> npcModTypeTable = new ArrayList<>();
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>(); private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();

19
src/engine/objects/Guild.java

@ -730,32 +730,29 @@ public class Guild extends AbstractWorldObject {
public boolean canSubAGuild(Guild toSub) { public boolean canSubAGuild(Guild toSub) {
boolean canSub; boolean canSubToNation;
boolean canAcceptSub;
if (this.equals(toSub)) if (this.equals(toSub))
return false; return false;
switch (this.guildState) { switch (this.guildState) {
case Nation: case Nation:
case Sovereign: case Sovereign:
canSub = true; canAcceptSub = true;
break; break;
default: default:
canSub = false; canAcceptSub = false;
} }
switch (toSub.guildState) { switch (toSub.guildState) {
case Errant: case Errant:
case Sovereign: case Sovereign:
canSub = true; canSubToNation = true;
break; break;
default: default:
canSub = false; canSubToNation = false;
}
City nationCap = City.getCity(nation.cityUUID);
if (nation.getSubGuildList().size() >= nationCap.getRank()) {
canSub = false;
} }
return canSub;
return canAcceptSub && canSubToNation;
} }
public int getRealmsOwnedFlag() { public int getRealmsOwnedFlag() {

4
src/engine/objects/Item.java

@ -61,7 +61,7 @@ public class Item extends AbstractWorldObject {
private ArrayList<EnchantmentBase> enchants = new ArrayList<>(); private ArrayList<EnchantmentBase> enchants = new ArrayList<>();
private long dateToUpgrade; private long dateToUpgrade;
private String customName = ""; private String customName = "";
private int magicValue; public int magicValue;
/** /**
* No Id Constructor * No Id Constructor
@ -889,6 +889,8 @@ public class Item extends AbstractWorldObject {
} }
public boolean isCanDestroy() { public boolean isCanDestroy() {
if(this.getItemBaseID() == 7)//gold
return false;
return canDestroy; return canDestroy;
} }

5
src/engine/objects/ItemBase.java

@ -13,6 +13,7 @@ import engine.Enum.DamageType;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.ItemType; import engine.Enum.ItemType;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.LootManager;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -914,4 +915,8 @@ public class ItemBase {
public void setAutoID(boolean autoID) { public void setAutoID(boolean autoID) {
this.autoID = 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);
}
} }

4
src/engine/objects/ItemFactory.java

@ -707,7 +707,7 @@ public class ItemFactory {
if (rollPrefix < 80) { if (rollPrefix < 80) {
int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); int randomPrefix = LootManager.TableRoll(vendor.getLevel());
prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix);
if (prefixEntry != null) if (prefixEntry != null)
@ -722,7 +722,7 @@ public class ItemFactory {
if (rollSuffix < 80 || prefixEntry == null) { if (rollSuffix < 80 || prefixEntry == null) {
int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); int randomSuffix = LootManager.TableRoll(vendor.getLevel());
suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix);
if (suffixEntry != null) if (suffixEntry != null)

105
src/engine/objects/Mine.java

@ -21,9 +21,7 @@ import java.net.UnknownHostException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static engine.gameManager.DbManager.MineQueries; import static engine.gameManager.DbManager.MineQueries;
@ -32,7 +30,6 @@ import static engine.math.FastMath.sqr;
public class Mine extends AbstractGameObject { public class Mine extends AbstractGameObject {
public final HashSet<Integer> _playerMemory = new HashSet<>();
public static ConcurrentHashMap<Mine, Integer> mineMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public static ConcurrentHashMap<Mine, Integer> mineMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public static ConcurrentHashMap<Integer, Mine> towerMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public static ConcurrentHashMap<Integer, Mine> towerMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final String zoneName; private final String zoneName;
@ -51,6 +48,13 @@ public class Mine extends AbstractGameObject {
private int buildingID; private int buildingID;
private MineProduction mineType; private MineProduction mineType;
public int capSize;
public final HashSet<Integer> _playerMemory = new HashSet<>();
public final HashMap<Integer,Long> _recentMemory = new HashMap<>();
HashMap<Guild,ArrayList<Integer>> dividedPlayers;
public Integer totalPlayers;
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */
@ -91,6 +95,19 @@ public class Mine extends AbstractGameObject {
this.production = Resource.valueOf(rs.getString("mine_resource")); this.production = Resource.valueOf(rs.getString("mine_resource"));
this.lastClaimer = null; 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) { public static void releaseMineClaims(PlayerCharacter playerCharacter) {
@ -165,7 +182,7 @@ public class Mine extends AbstractGameObject {
writer.putInt(mine.getObjectUUID()); writer.putInt(mine.getObjectUUID());
writer.putInt(mine.getObjectUUID()); //actually a hash of mine writer.putInt(mine.getObjectUUID()); //actually a hash of mine
writer.putString(mine.mineType.name); 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.hash);
writer.putInt(mine.production.baseProduction); writer.putInt(mine.production.baseProduction);
writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here
@ -577,13 +594,12 @@ public class Mine extends AbstractGameObject {
public void onEnter() { public void onEnter() {
HashSet<AbstractWorldObject> currentPlayers; HashSet<AbstractWorldObject> currentPlayers;
HashSet<Integer> currentMemory;
PlayerCharacter player; PlayerCharacter player;
// Gather current list of players within the zone bounds // Gather current list of players within the zone bounds
Building tower = BuildingManager.getBuildingFromCache(this.buildingID);
currentPlayers = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents, MBServerStatics.MASK_PLAYER);
currentMemory = new HashSet<>(); boolean updated = false;
for (AbstractWorldObject playerObject : currentPlayers) { for (AbstractWorldObject playerObject : currentPlayers) {
@ -591,9 +607,10 @@ public class Mine extends AbstractGameObject {
continue; continue;
player = (PlayerCharacter) playerObject; player = (PlayerCharacter) playerObject;
currentMemory.add(player.getObjectUUID());
// Player is already in our memory // Player is already in our memory
if (_recentMemory.containsKey(player.getObjectUUID()))
_recentMemory.remove(player.getObjectUUID());
if (_playerMemory.contains(player.getObjectUUID())) if (_playerMemory.contains(player.getObjectUUID()))
continue; continue;
@ -601,24 +618,60 @@ public class Mine extends AbstractGameObject {
// Add player to our city's memory // Add player to our city's memory
_playerMemory.add(player.getObjectUUID()); _playerMemory.add(player.getObjectUUID());
updated = true;
// ***For debugging // ***For debugging
// Logger.info("PlayerMemory for ", this.getCityName() + ": " + _playerMemory.size()); // Logger.info("PlayerMemory for ", this.getCityName() + ": " + _playerMemory.size());
} }
this.totalPlayers = this._playerMemory.size();
try { try {
onExit(currentMemory); if(onExit(currentPlayers)){
updated = true;
}
} catch (Exception e) { } catch (Exception e) {
Logger.error(e.getMessage()); 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<Integer> 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<Integer> currentMemory) {
private Boolean onExit(HashSet<AbstractWorldObject> currentPlayers) {
PlayerCharacter player; PlayerCharacter player;
int playerUUID = 0; int playerUUID = 0;
HashSet<Integer> toRemove = new HashSet<>(); HashSet<Integer> toRemove = new HashSet<>();
Iterator<Integer> iter = _playerMemory.iterator(); Iterator<Integer> iter = _playerMemory.iterator();
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc,Enum.CityBoundsType.ZONE.extents * 0.5f,MBServerStatics.MASK_PLAYER);
while (iter.hasNext()) { while (iter.hasNext()) {
playerUUID = iter.next(); playerUUID = iter.next();
@ -626,15 +679,33 @@ public class Mine extends AbstractGameObject {
player = PlayerCharacter.getFromCache(playerUUID); player = PlayerCharacter.getFromCache(playerUUID);
if (inRange.contains(player)) if (currentPlayers.contains(player))
continue; continue;
toRemove.add(playerUUID); 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 // Remove players from mine memory
_playerMemory.removeAll(toRemove); //_playerMemory.removeAll(toRemove);
PowersManager.removeZergBuff(toRemove); HashSet<Integer> 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;
}
} }
} }

1071
src/engine/objects/Mob.java

File diff suppressed because it is too large Load Diff

2
src/engine/objects/MobEquipment.java

@ -34,7 +34,7 @@ public class MobEquipment extends AbstractGameObject {
private AbstractPowerAction suffix; private AbstractPowerAction suffix;
private int pValue; private int pValue;
private int sValue; private int sValue;
private int magicValue; public int magicValue;
private float dropChance = 0; private float dropChance = 0;

19
src/engine/objects/NPC.java

@ -50,7 +50,6 @@ public class NPC extends AbstractCharacter {
// Used for thread safety // Used for thread safety
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private final ArrayList<MobLoot> rolling = new ArrayList<>(); private final ArrayList<MobLoot> rolling = new ArrayList<>();
private final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
public ArrayList<ProducedItem> forgedItems = new ArrayList<>(); public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
public HashMap<Integer, MobEquipment> equip = null; public HashMap<Integer, MobEquipment> equip = null;
@ -86,6 +85,7 @@ public class NPC extends AbstractCharacter {
public NPC() { public NPC() {
super();
this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
this.currentID = 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); WorldGrid.RemoveWorldObject(toRemove);
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) { if (petOwner != null) {
petOwner.setPet(null); petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null); PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
@ -805,6 +807,8 @@ public class NPC extends AbstractCharacter {
@Override @Override
public void runAfterLoad() { public void runAfterLoad() {
this.charItemManager = new CharacterItemManager(this);
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return; return;
@ -846,10 +850,6 @@ public class NPC extends AbstractCharacter {
if (wordCount(this.name) < 2 && this.contract != null) if (wordCount(this.name) < 2 && this.contract != null)
this.name += " the " + this.contract.getName(); this.name += " the " + this.contract.getName();
// Initialize inventory
this.charItemManager = new CharacterItemManager(this);
// Configure parent zone adding this NPC to the // Configure parent zone adding this NPC to the
// zone collection // zone collection
@ -1103,10 +1103,6 @@ public class NPC extends AbstractCharacter {
return (int) time; return (int) time;
} }
public ConcurrentHashMap<Mob, Integer> getSiegeMinionMap() {
return siegeMinionMap;
}
public boolean remove() { public boolean remove() {
Building building; Building building;
@ -1330,7 +1326,6 @@ public class NPC extends AbstractCharacter {
return; return;
dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime()); dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime());
this.setUpgradeDateTime(dateToUpgrade); this.setUpgradeDateTime(dateToUpgrade);
// Schedule upgrade job // Schedule upgrade job

37
src/engine/objects/PlayerCharacter.java

@ -144,7 +144,6 @@ public class PlayerCharacter extends AbstractCharacter {
private long lastUpdateTime = System.currentTimeMillis(); private long lastUpdateTime = System.currentTimeMillis();
private long lastStamUpdateTime = System.currentTimeMillis(); private long lastStamUpdateTime = System.currentTimeMillis();
private boolean safeZone = false; private boolean safeZone = false;
private int bindBuildingID;
/* /*
DataWarehouse based kill/death tracking. DataWarehouse based kill/death tracking.
@ -177,8 +176,7 @@ public class PlayerCharacter extends AbstractCharacter {
public boolean isBoxed = false; public boolean isBoxed = false;
public boolean receivedConc = false; public float ZergMultiplier = 1.0f;
/** /**
* No Id Constructor * No Id Constructor
*/ */
@ -209,15 +207,18 @@ public class PlayerCharacter extends AbstractCharacter {
this.spiMod.set(spiMod); this.spiMod.set(spiMod);
this.guildStatus = new AtomicInteger(0); this.guildStatus = new AtomicInteger(0);
this.bindBuildingID = -1; this.buildingUUID = -1;
} }
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */
public PlayerCharacter(ResultSet rs) throws SQLException { public PlayerCharacter(ResultSet rs) throws SQLException {
super(rs, true); super(rs, true);
this.charItemManager = new CharacterItemManager(this);
this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID()); this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID());
int accountID = rs.getInt("parent"); int accountID = rs.getInt("parent");
this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID); this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID);
@ -269,7 +270,7 @@ public class PlayerCharacter extends AbstractCharacter {
this.intMod.set(rs.getShort("char_intMod")); this.intMod.set(rs.getShort("char_intMod"));
this.spiMod.set(rs.getShort("char_spiMod")); this.spiMod.set(rs.getShort("char_spiMod"));
this.bindBuildingID = rs.getInt("char_bindBuilding"); this.buildingUUID = rs.getInt("char_bindBuilding");
this.hash = rs.getString("hash"); this.hash = rs.getString("hash");
@ -2191,11 +2192,8 @@ public class PlayerCharacter extends AbstractCharacter {
} }
//public int getInventoryCapacity() {
// return statStrBase * 3;
//}
public int getInventoryCapacity() { public int getInventoryCapacity() {
return 1000; return statStrBase * 3;
} }
public int getInventoryCapacityRemaining() { public int getInventoryCapacityRemaining() {
@ -2230,7 +2228,6 @@ public class PlayerCharacter extends AbstractCharacter {
// Warehouse this event // Warehouse this event
CharacterRecord.updatePromotionClass(this); CharacterRecord.updatePromotionClass(this);
return true; return true;
} }
@ -2729,12 +2726,12 @@ public class PlayerCharacter extends AbstractCharacter {
*/ */
public synchronized int getBindBuildingID() { public synchronized int getBindBuildingID() {
return this.bindBuildingID; return this.buildingUUID;
} }
public synchronized void setBindBuildingID(int value) { public synchronized void setBindBuildingID(int value) {
DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value); DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value);
this.bindBuildingID = value; this.buildingUUID = value;
} }
public AbstractGameObject getLastTarget() { public AbstractGameObject getLastTarget() {
@ -4569,10 +4566,6 @@ public class PlayerCharacter extends AbstractCharacter {
@Override @Override
public void runAfterLoad() { public void runAfterLoad() {
// Init inventory
this.charItemManager = new CharacterItemManager(this);
Bounds playerBounds = Bounds.borrow(); Bounds playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc()); playerBounds.setBounds(this.getLoc());
this.setBounds(playerBounds); this.setBounds(playerBounds);
@ -4700,7 +4693,8 @@ public class PlayerCharacter extends AbstractCharacter {
} else if (currentPet.isSiege()) { } else if (currentPet.isSiege()) {
currentPet.agentType = AIAgentType.MOBILE; currentPet.agentType = AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
if (currentPet.isAlive()) if (currentPet.isAlive())
WorldGrid.updateObject(currentPet); WorldGrid.updateObject(currentPet);
@ -4819,9 +4813,14 @@ public class PlayerCharacter extends AbstractCharacter {
updateBlessingMessage(); updateBlessingMessage();
this.safeZone = this.isInSafeZone(); 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) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} finally { } finally {

71
src/engine/objects/Warehouse.java

@ -1334,4 +1334,75 @@ public class Warehouse extends AbstractWorldObject {
return resourceType.elementOf(this.lockedResourceTypes); 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;
}
} }

4
src/engine/powers/effectmodifiers/HealthEffectModifier.java

@ -176,6 +176,10 @@ public class HealthEffectModifier extends AbstractEffectModifier {
if (!ac.isAlive()) if (!ac.isAlive())
return; return;
if(source.getObjectType().equals(GameObjectType.PlayerCharacter)){
modAmount *= ((PlayerCharacter)source).ZergMultiplier;
}
int powerID = 0, effectID = 0; int powerID = 0, effectID = 0;
String powerName = ""; String powerName = "";
if (effect.getPower() != null) { if (effect.getPower() != null) {

3
src/engine/powers/effectmodifiers/ManaEffectModifier.java

@ -157,6 +157,9 @@ public class ManaEffectModifier extends AbstractEffectModifier {
skipImmune = true; skipImmune = true;
} }
} }
if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
modAmount *= ((PlayerCharacter)source).ZergMultiplier;
}
PlayerBonuses bonus = ac.getBonuses(); PlayerBonuses bonus = ac.getBonuses();
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) {
ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID); ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID);

3
src/engine/powers/effectmodifiers/StaminaEffectModifier.java

@ -153,6 +153,9 @@ public class StaminaEffectModifier extends AbstractEffectModifier {
skipImmune = true; skipImmune = true;
} }
} }
if(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
modAmount *= ((PlayerCharacter)source).ZergMultiplier;
}
PlayerBonuses bonus = ac.getBonuses(); PlayerBonuses bonus = ac.getBonuses();
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) { if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) {
ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID); ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID);

24
src/engine/powers/poweractions/ApplyEffectPowerAction.java

@ -11,6 +11,7 @@ package engine.powers.poweractions;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.ModType; import engine.Enum.ModType;
import engine.Enum.SourceType; import engine.Enum.SourceType;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.ChatManager; import engine.gameManager.ChatManager;
import engine.jobs.ChantJob; import engine.jobs.ChantJob;
import engine.jobs.DeferredPowerJob; import engine.jobs.DeferredPowerJob;
@ -22,6 +23,7 @@ import engine.objects.*;
import engine.powers.ActionsBase; import engine.powers.ActionsBase;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.PowersBase; import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -117,20 +119,12 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
awo.addEffect(stackType, duration, eff, effect, trains); awo.addEffect(stackType, duration, eff, effect, trains);
} else } else
awo.applyAllBonuses(); 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 (this.effectID.equals("TAUNT")) {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
((Mob) awo).setCombatTarget(source);
ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); ChatSystemMsg msg = ChatManager.CombatInfo(source, awo);
DispatchMessage.sendToAllInRange(source, msg); DispatchMessage.sendToAllInRange(source, msg);
((Mob)awo).refresh();
} }
} }
if (awo != null && awo.getObjectType() == GameObjectType.Mob) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
@ -140,7 +134,21 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
} }
this.effect.startEffect(source, awo, trains, eff); 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) { protected void _applyEffectForItem(Item item, int trains) {

36
src/engine/powers/poweractions/CreateMobPowerAction.java

@ -12,7 +12,6 @@ package engine.powers.poweractions;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.MovementManager;
import engine.gameManager.NPCManager; import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
@ -75,7 +74,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
return; return;
//create Pet //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 if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet
@ -84,8 +83,6 @@ public class CreateMobPowerAction extends AbstractPowerAction {
WorldGrid.RemoveWorldObject(currentPet); WorldGrid.RemoveWorldObject(currentPet);
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
//if (currentPet.getParentZone() != null)
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear(); currentPet.playerAgroMap.clear();
@ -95,10 +92,10 @@ public class CreateMobPowerAction extends AbstractPowerAction {
Logger.error(e.getMessage()); Logger.error(e.getMessage());
} }
//currentPet.disableIntelligence();
} else if (currentPet != null && currentPet.isSiege()) { } else if (currentPet != null && currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE; currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
if (currentPet.isAlive()) if (currentPet.isAlive())
@ -106,7 +103,6 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} }
//remove 10th pet //remove 10th pet
NPCManager.spawnNecroPet(owner, pet); NPCManager.spawnNecroPet(owner, pet);
} else { //is not a necro pet } else { //is not a necro pet
@ -115,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
DbManager.removeFromCache(currentPet); DbManager.removeFromCache(currentPet);
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
currentPet.setOwner(null); currentPet.guardCaptain = null;
WorldGrid.RemoveWorldObject(currentPet); WorldGrid.RemoveWorldObject(currentPet);
//currentPet.getParentZone().zoneMobSet.remove(currentPet); //currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet);
@ -125,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} else { } else {
if (currentPet.isSiege()) { if (currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE; currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
if (currentPet.isAlive()) if (currentPet.isAlive())
@ -137,26 +134,9 @@ public class CreateMobPowerAction extends AbstractPowerAction {
NPCManager.resetNecroPets(owner); 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); owner.setPet(pet);
if(pet.isSiege() == false) {
MovementManager.translocate(pet, owner.getLoc(), owner.region);
}
pet.recalculateStats(); pet.recalculateStats();
pet.healthMax = pet.level * 0.5f * 120; pet.healthMax = pet.level * 0.5f * 120;
pet.setHealth(pet.healthMax); pet.setHealth(pet.healthMax);

2
src/engine/powers/poweractions/FearPowerAction.java

@ -59,7 +59,7 @@ public class FearPowerAction extends AbstractPowerAction {
int duration = 10 + ((int) (trains * 0.5)); int duration = 10 + ((int) (trains * 0.5));
String stackType = ab.getStackType(); String stackType = ab.getStackType();
EndFearJob efj = new EndFearJob(source, awo, stackType, trains, ab, pb, null); 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); JobScheduler.getInstance().scheduleJob(efj, duration * 1000);
} }

1
src/engine/powers/poweractions/TransferStatPowerAction.java

@ -213,6 +213,7 @@ public class TransferStatPowerAction extends AbstractPowerAction {
// put it back between min and max // put it back between min and max
damage += min; damage += min;
damage *= ((PlayerCharacter) source).ZergMultiplier;
} }
// Apply any power effect modifiers (such as stances) // Apply any power effect modifiers (such as stances)

108
src/engine/server/world/WorldServer.java

@ -10,7 +10,6 @@
package engine.server.world; package engine.server.world;
import engine.Enum; import engine.Enum;
import engine.Enum.BuildingGroup;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;
import engine.Enum.MinionType; import engine.Enum.MinionType;
import engine.Enum.SupportMsgType; import engine.Enum.SupportMsgType;
@ -18,11 +17,13 @@ import engine.InterestManagement.HeightMap;
import engine.InterestManagement.RealmMap; import engine.InterestManagement.RealmMap;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.db.archive.DataWarehouse; import engine.db.archive.DataWarehouse;
import engine.db.handlers.dbPowerHandler;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
import engine.gameManager.*; import engine.gameManager.*;
import engine.job.JobContainer; import engine.job.JobContainer;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.LogoutCharacterJob; import engine.jobs.LogoutCharacterJob;
import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.MobAIThread;
import engine.mobileAI.Threads.MobRespawnThread; import engine.mobileAI.Threads.MobRespawnThread;
import engine.net.Dispatch; import engine.net.Dispatch;
@ -334,7 +335,7 @@ public class WorldServer {
DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
Logger.info("Loading NPC and Mob Rune Sets"); 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"); Logger.info("Loading Booty Sets");
LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES();
@ -352,7 +353,7 @@ public class WorldServer {
DbManager.MobBaseQueries.GET_ALL_MOBBASES(); DbManager.MobBaseQueries.GET_ALL_MOBBASES();
Logger.info("Loading Mob Powers"); Logger.info("Loading Mob Powers");
PowersManager.AllMobPowers = DbManager.PowerQueries.LOAD_MOB_POWERS(); PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS();
Logger.info("Loading item enchants"); Logger.info("Loading item enchants");
DbManager.LootQueries.LOAD_ENCHANT_VALUES(); DbManager.LootQueries.LOAD_ENCHANT_VALUES();
@ -436,7 +437,7 @@ public class WorldServer {
DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT(); DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT();
//pick a startup Hotzone //pick a startup Hotzone
ZoneManager.generateAndSetRandomHotzone(); //ZoneManager.generateAndSetRandomHotzone();
Logger.info("Loading All Players from database to Server Cache"); Logger.info("Loading All Players from database to Server Cache");
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
@ -482,7 +483,7 @@ public class WorldServer {
Logger.info("Initializing Client Connection Manager"); Logger.info("Initializing Client Connection Manager");
initClientConnectionManager(); initClientConnectionManager();
//intiate mob respawn thread //intiate mob respawn thread
Logger.info("Starting Mob Respawn Thread"); Logger.info("Starting Mob Respawn Thread");
MobRespawnThread.startRespawnThread(); MobRespawnThread.startRespawnThread();
@ -551,44 +552,40 @@ public class WorldServer {
} }
//Set sea floor object for server //Set sea floor object for server
Zone seaFloor = rootParent.get(0); Zone seaFloor = rootParent.get(0);
seaFloor.setParent(null); seaFloor.setParent(null);
ZoneManager.setSeaFloor(seaFloor); 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)); rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
for (Zone zone : rootParent) { 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<Building> bList; ArrayList<Building> bList;
bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
for (Building b : bList) { for (Building b : bList) {
try { b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); b.setLoc(b.getLoc());
b.setLoc(b.getLoc());
} catch (Exception e) {
Logger.error(b.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
} }
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle Mobs //Handle Mobs
try {
ArrayList<Mob> mobs; ArrayList<Mob> mobs;
mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone); mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone);
@ -596,15 +593,22 @@ public class WorldServer {
m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks()); m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks());
m.setLoc(m.getLoc()); m.setLoc(m.getLoc());
//ADD GUARDS HERE. // Load Minions for Guard Captains here.
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
DbManager.MobQueries.LOAD_PATROL_POINTS(m); 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<NPC> npcs; ArrayList<NPC> npcs;
// Ignore npc's on the seafloor (npc guild leaders, etc) // Ignore NPCs on the seafloor (npc guild leaders, etc)
if (zone.equals(seaFloor)) if (zone.equals(seaFloor))
continue; continue;
@ -612,26 +616,48 @@ public class WorldServer {
npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone); npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone);
for (NPC n : npcs) { for (NPC n : npcs) {
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
try { if(n.contract.getContractID() == 1200) {
n.setObjectTypeMask(MBServerStatics.MASK_NPC); DbManager.NPCQueries.DELETE_NPC(n);
n.setLoc(n.getLoc()); continue;
} catch (Exception e) {
Logger.error(n.getObjectUUID() + " returned an Error Message :" + e.getMessage());
} }
n.setLoc(n.getLoc());
} }
//Handle cities } catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle cities
ZoneManager.loadCities(zone); ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(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();
} }
} }
catch(Exception e){
Logger.info("time to load: " + (System.currentTimeMillis() - start) + " ms"); 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; return;
} }
//remove player from loaded mobs agro maps //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; Mob loadedMob = (Mob) awo;
loadedMob.playerAgroMap.remove(player.getObjectUUID()); loadedMob.playerAgroMap.remove(player.getObjectUUID());
} }

30
src/engine/workthreads/HourlyJobThread.java

@ -189,28 +189,28 @@ public class HourlyJobThread implements Runnable {
Logger.info("Hourly job is now running."); Logger.info("Hourly job is now running.");
try { //try {
// Use the same hotZone this hour up and until // Use the same hotZone this hour up and until
// the HotZone_Duration from the ConfigManager // the HotZone_Duration from the ConfigManager
if (ZoneManager.hotZone == null) //if (ZoneManager.hotZone == null)
ZoneManager.generateAndSetRandomHotzone(); // ZoneManager.generateAndSetRandomHotzone();
else //else
ZoneManager.hotZoneCycle = ZoneManager.hotZoneCycle + 1; // ZoneManager.hotZoneCycle = ZoneManager.hotZoneCycle + 1;
if (ZoneManager.hotZoneCycle > Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue())) //if (ZoneManager.hotZoneCycle > Integer.parseInt(ConfigManager.MB_HOTZONE_DURATION.getValue()))
ZoneManager.generateAndSetRandomHotzone(); // ZoneManager.generateAndSetRandomHotzone();
if (ZoneManager.hotZone == null) { //if (ZoneManager.hotZone == null) {
Logger.error("Null HotZone returned from ZoneManager"); // Logger.error("Null HotZone returned from ZoneManager");
} else { //} else {
Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName()); // Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName());
} //}
} catch (Exception e) { //} catch (Exception e) {
Logger.error(e.toString()); // Logger.error(e.toString());
} //}
// Open or Close mines for the current mine window. // Open or Close mines for the current mine window.

Loading…
Cancel
Save