Compare commits

...

117 Commits

Author SHA1 Message Date
MagicBot 6641651f3c Unused method removed. 1 year ago
MagicBot dbf164bfb2 bonus code removal 1 year ago
MagicBot 8a617c3008 Siege minion spawn time set to 15m. 1 year ago
FatBoy-DOTC a50a2430ba hate value for chants to affect mobs in range 1 year ago
FatBoy-DOTC 5c3c552288 usage of AIAgentType for default patrol points 1 year ago
FatBoy-DOTC 69fdddfc71 hate value fix 1 year ago
FatBoy-DOTC db5b988275 usage of AIAgentType for pet checks in run after load 1 year ago
FatBoy-DOTC 4284757035 pet level set in run after load removed 1 year ago
FatBoy-DOTC b93a47acc0 pet death and dismissal fix 1 year ago
MagicBot d59f9857ce Cleanup in pet minion 1 year ago
FatBoy-DOTC 8ce212b74b Merge remote-tracking branch 'origin/mob-refactor2' into mob-refactor2 1 year ago
FatBoy-DOTC e78aea5735 Assign patrol points added as static method to NPC manager 1 year ago
MagicBot 9a3c5c3f40 Siege minion assigned UUID. 1 year ago
FatBoy-DOTC 60ca3f9c34 remove siege minion 1 year ago
FatBoy-DOTC e7e740dff1 blocked player character specific block in minion training message handler 1 year ago
MagicBot 8343a98d77 Minion added to map after runafterload. 1 year ago
MagicBot 5862039a00 Minion added to map after runafterload. 1 year ago
MagicBot 8af989b75f Fix is patrol logic bloc conditional. 1 year ago
MagicBot 08d0e5ff75 Logic isn't needed here. 1 year ago
MagicBot 5196d10e5c Logic isn't needed here. 1 year ago
MagicBot 3392ec463d Removed unused methods. 1 year ago
MagicBot 33529404cf Logic fix in siege minions. 1 year ago
MagicBot 00e7a36013 Logic fix in siege minions. 1 year ago
FatBoy-DOTC 3060b394ab removed siegeminion map from NPC 1 year ago
MagicBot a43d9022fe Siege engine slot override. 1 year ago
FatBoy-DOTC 6abdc68ca5 removed un-needed cast to player character for pets 1 year ago
FatBoy-DOTC 61c66b0e96 trebs slot in proper locations 1 year ago
FatBoy-DOTC 36cc23457a optimized slot for siege engines 1 year ago
FatBoy-DOTC d573b238de refactored mob get/set owner 1 year ago
FatBoy-DOTC 8afe25fe85 siege minions added to arty captain minion map 1 year ago
MagicBot f80647ff0d Spawn time set to 15s for debug. 1 year ago
MagicBot 7e64cbabf8 Update to slotting logic. 1 year ago
MagicBot 14a06410ae Update to slotting logic. 1 year ago
MagicBot 85c2a4f4f0 Add all as hirelings 1 year ago
FatBoy-DOTC da9e211ec7 SiegeEngine enum and logic added 1 year ago
MagicBot a81070c471 Pet level += 20 to conform to 24.3 1 year ago
MagicBot e3ad7efa4f Method renamed for new convention. 1 year ago
MagicBot a4dafd7155 Unused variable in signature. 1 year ago
MagicBot 645aec853e Bindloc not adjusted for pets. 1 year ago
MagicBot d8d5e4a3c4 Name set to default. 1 year ago
MagicBot 7a48c04057 Mobbase set properly. 1 year ago
MagicBot 64aaaa707e Behaviour type set for pets. 1 year ago
MagicBot 445d40dc5f Bonus code removed. 1 year ago
MagicBot ebdcb531f2 AI methods moved to ai class. 1 year ago
MagicBot c9cdb891d6 Cleanup of ownerNPC mess. 1 year ago
MagicBot f5c6c002a8 Unused method removed. 1 year ago
MagicBot d171c6bb9a Unused method removed. 1 year ago
MagicBot 1c81a4faed Wall archers static reverted. 1 year ago
MagicBot e7d1d5cb71 Constructor removed. 1 year ago
MagicBot 060d831d50 Comment for clarity. 1 year ago
MagicBot 316bd6dd01 Siege engines use slot system. 1 year ago
MagicBot 34081e5903 Ordinal comparison fix. 1 year ago
MagicBot e2d843b65e Signature refactor. 1 year ago
MagicBot a796f5fe4b More siege engine work. 1 year ago
MagicBot 51ee41c773 use of SiegeEngine Behaviour Type 1 year ago
MagicBot 7e5ed3efe5 sqrMagnitude not sqrRoot 1 year ago
MagicBot 8dd25ac315 Minions inherit patrol points form barracks. 1 year ago
MagicBot 1cdaa58e7a Wall archers set to static grid type. 1 year ago
MagicBot fa3aa24a3d Update to minion building/location mechanic. 1 year ago
MagicBot 091431d95b Dynamic set in all constructors. 1 year ago
MagicBot 1ecf0122ab Unused variable removed. 1 year ago
MagicBot 79980a1725 NoID constructor removed. 1 year ago
MagicBot 8badcc3f6e Refactored out redundant stat-xyz variables. 1 year ago
MagicBot 4d6e57257c Unused methods removed. 1 year ago
MagicBot a7a93b8500 Tweak to bindloc for minions. 1 year ago
MagicBot 85cc34fb4c AIinfo updated. 1 year ago
MagicBot 772a996b6e Tweak to behavior type setup. 1 year ago
MagicBot e67eff822d Propagate guardedCity. 1 year ago
MagicBot c39ed6120f Cleanup of bind/loc logic. 1 year ago
MagicBot c38f4e6543 Mask only needs be set once. 1 year ago
MagicBot 098433b697 Needs contract null check 1 year ago
MagicBot c8e20c905b Add to cache before setloc 1 year ago
MagicBot bd2446ba0a Minion uuid set pre configure 1 year ago
MagicBot c179e4aaf3 Don't override level or name for minions. 1 year ago
MagicBot 2f8de2a919 Worthless collection only used in 2 places. 1 year ago
MagicBot 338110973d Mobbase cannot be null. 1 year ago
MagicBot 3c9c4495bc playerGuard = true. 1 year ago
MagicBot 93476f782c Bind loc not overwritten. 1 year ago
MagicBot 3aec6ee578 More minion setup work. 1 year ago
MagicBot 3bca76d4c8 Setloc to spawn minion. 1 year ago
MagicBot b9d6f35aac Unused variable. 1 year ago
MagicBot 9b6959414a More flushing out minion support. 1 year ago
MagicBot 400dd6aa5e More granular error reporting. 1 year ago
MagicBot 14af2f6efd Minion spawning re-enabled for refactoring. 1 year ago
MagicBot 0a2de9e0d5 Contract handling cleanup. 1 year ago
MagicBot 89bfad78a6 Contract handling cleanup. 1 year ago
MagicBot 52486fa278 Contract handling cleanup. 1 year ago
MagicBot dc0e14eb21 AI added earlier in sequence for availability. 1 year ago
MagicBot 70278374e7 manager init moved to the top of method. 1 year ago
MagicBot ac3588c76a manager init moved to the top of method. 1 year ago
MagicBot ab335aef2a Enums are fragile. 1 year ago
MagicBot 719c855bdb Cleanup of inventoryManager usage. 1 year ago
MagicBot f283e50018 Disabled minions for now. 1 year ago
MagicBot 99b952ee28 Refactor towards new constructor. 1 year ago
MagicBot 24639b62c0 Refactor towards new constructor. 1 year ago
MagicBot 573cc531bf Refactor towards new constructor. 1 year ago
MagicBot 29e24bae93 Unused constructor removed. 1 year ago
MagicBot 22e4cc07c0 Separate pet and siege behaviour types. 1 year ago
MagicBot 9264347698 Minions inherit enemy/notenemy from captain. 1 year ago
MagicBot 579c26ac59 InitializeMob removed. 1 year ago
MagicBot ef577dd313 Removed catch to propagate error. 1 year ago
MagicBot 62c7e52487 Starting to whittle away at initmob method. 1 year ago
MagicBot 3534ac6477 Starting to whittle away at initmob method. 1 year ago
MagicBot 1738f7b311 Starting to whittle away at initmob method. 1 year ago
MagicBot eb25caec81 Object creation moved out of rs const. 1 year ago
MagicBot a6c60e2c04 Merge remote-tracking branch 'origin/master' into mobile-cleanup 1 year ago
MagicBot adafbdf6d3 Duplicate building and building ID values. 1 year ago
MagicBot 7eab14938d Exception for siege when slotting. 1 year ago
MagicBot 039e55673b Exception for siege when slotting. 1 year ago
MagicBot ec3a9b6cb4 Minions don't have contracts. 1 year ago
MagicBot 17a6494b2b Unused code. 1 year ago
MagicBot 0b05c7074f Slot all agents but true mobiles. 1 year ago
MagicBot 876ccc7cbf New constructor created. 1 year ago
MagicBot bdf14b8f24 Ordinal comparisons refactored. 1 year ago
MagicBot 43375a6f5b Only mobiles with contracts can be slotted. 1 year ago
MagicBot e00328ae13 Siege pets use slotting mechanic. 1 year ago
MagicBot 07c553294b Mobiles use new slotting mechanic. 1 year ago
  1. 17
      src/engine/Enum.java
  2. 4
      src/engine/InterestManagement/InterestManager.java
  3. 39
      src/engine/db/handlers/dbMobHandler.java
  4. 4
      src/engine/devcmd/cmds/AddMobCmd.java
  5. 4
      src/engine/devcmd/cmds/InfoCmd.java
  6. 4
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  7. 4
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  8. 2
      src/engine/devcmd/cmds/SplatMobCmd.java
  9. 36
      src/engine/devcmd/cmds/aiInfoCmd.java
  10. 6
      src/engine/gameManager/BuildingManager.java
  11. 3
      src/engine/gameManager/CombatManager.java
  12. 80
      src/engine/gameManager/NPCManager.java
  13. 4
      src/engine/gameManager/PowersManager.java
  14. 4
      src/engine/jobs/EndFearJob.java
  15. 106
      src/engine/mobileAI/MobAI.java
  16. 2
      src/engine/mobileAI/utilities/CombatUtilities.java
  17. 4
      src/engine/mobileAI/utilities/MovementUtilities.java
  18. 75
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  19. 10
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  20. 8
      src/engine/net/client/msg/ManageNPCMsg.java
  21. 61
      src/engine/objects/AbstractCharacter.java
  22. 31
      src/engine/objects/AbstractIntelligenceAgent.java
  23. 4
      src/engine/objects/AbstractWorldObject.java
  24. 1071
      src/engine/objects/Mob.java
  25. 18
      src/engine/objects/NPC.java
  26. 19
      src/engine/objects/PlayerCharacter.java
  27. 24
      src/engine/powers/poweractions/ApplyEffectPowerAction.java
  28. 36
      src/engine/powers/poweractions/CreateMobPowerAction.java
  29. 2
      src/engine/powers/poweractions/FearPowerAction.java
  30. 83
      src/engine/server/world/WorldServer.java

17
src/engine/Enum.java

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

4
src/engine/InterestManagement/InterestManager.java

@ -467,7 +467,7 @@ public enum InterestManager implements Runnable { @@ -467,7 +467,7 @@ public enum InterestManager implements Runnable {
if (awonpc.despawned == true)
continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
((Mob) awonpc).setCombatTarget(null);
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -480,7 +480,7 @@ public enum InterestManager implements Runnable { @@ -480,7 +480,7 @@ public enum InterestManager implements Runnable {
if (!awonpc.isAlive())
continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE)))
((Mob) awonpc).setCombatTarget(null);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

6
src/engine/gameManager/BuildingManager.java

@ -535,7 +535,7 @@ public enum BuildingManager { @@ -535,7 +535,7 @@ public enum BuildingManager {
if (NPC.ISWallArcher(contract)) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
if (mob == null)
return false;
@ -547,7 +547,7 @@ public enum BuildingManager { @@ -547,7 +547,7 @@ public enum BuildingManager {
if (NPC.ISGuardCaptain(contract.getContractID())) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
if (mob == null)
return false;
@ -559,7 +559,7 @@ public enum BuildingManager { @@ -559,7 +559,7 @@ public enum BuildingManager {
if (contract.getContractID() == 910) {
//guard dog
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
if (mob == null)
return false;

3
src/engine/gameManager/CombatManager.java

@ -826,7 +826,8 @@ public enum CombatManager { @@ -826,7 +826,8 @@ public enum CombatManager {
damage *= 2.5f; //increase damage if sitting
if (tarAc.getObjectType() == GameObjectType.Mob) {
ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER);
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter))
((Mob)tarAc).playerAgroMap.put(ac.getObjectUUID(), ((Mob) tarAc).playerAgroMap.get(ac.getObjectUUID()) + damage);
((Mob) tarAc).handleDirectAggro(ac);
}

80
src/engine/gameManager/NPCManager.java

@ -23,14 +23,6 @@ public enum NPCManager { @@ -23,14 +23,6 @@ public enum NPCManager {
NPC_MANAGER;
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) {
// Early exit
@ -127,10 +119,12 @@ public enum NPCManager { @@ -127,10 +119,12 @@ public enum NPCManager {
DbManager.removeFromCache(necroPet);
PlayerCharacter petOwner = necroPet.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain;
if (petOwner != null) {
necroPet.setOwner(null);
necroPet.guardCaptain = null;
petOwner.setPet(null);
if (updateOwner == false)
@ -228,12 +222,14 @@ public enum NPCManager { @@ -228,12 +222,14 @@ public enum NPCManager {
WorldGrid.removeObject(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
@ -340,10 +336,19 @@ public enum NPCManager { @@ -340,10 +336,19 @@ public enum NPCManager {
else
buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building);
// Override slot for siege engines
if (abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob) && ((Mob) abstractCharacter).behaviourType.equals(Enum.MobBehaviourType.SiegeEngine)) {
Mob siegeMobile = (Mob) abstractCharacter;
buildingSlot = siegeMobile.guardCaptain.siegeMinionMap.size() + 2;
}
if (buildingSlot == -1)
Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
// Pets are regular mobiles not hirelings (Siege engines)
if (abstractCharacter.contract != null)
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
// Override bind and location for this npc derived
// from BuildingManager slot location data.
@ -370,4 +375,53 @@ public enum NPCManager { @@ -370,4 +375,53 @@ public enum NPCManager {
return buildingSlot;
}
public static int getMaxMinions(Mob guardCaptain) {
int maxSlots;
switch (guardCaptain.getRank()) {
case 3:
maxSlots = 2;
break;
case 4:
case 5:
maxSlots = 3;
break;
case 6:
maxSlots = 4;
break;
case 7:
maxSlots = 5;
break;
case 1:
case 2:
default:
maxSlots = 1;
}
return maxSlots;
}
public static void AssignPatrolPoints(Mob mob) {
mob.patrolPoints = new ArrayList<>();
for (int i = 0; i < 5; ++i) {
float patrolRadius = mob.getSpawnRadius();
if (patrolRadius > 256)
patrolRadius = 256;
if (patrolRadius < 60)
patrolRadius = 60;
Vector3fImmutable newPatrolPoint = Vector3fImmutable.getRandomPointInCircle(mob.getBindLoc(), patrolRadius);
mob.patrolPoints.add(newPatrolPoint);
if (i == 1) {
mob.loc = newPatrolPoint;
mob.endLoc = newPatrolPoint;
}
}
}
}

4
src/engine/gameManager/PowersManager.java

@ -839,8 +839,6 @@ public enum PowersManager { @@ -839,8 +839,6 @@ public enum PowersManager {
return;
}
playerCharacter.setHateValue(pb.getHateValue(trains));
//Send Cast Message.
// PerformActionMsg castMsg = new PerformActionMsg(msg);
// castMsg.setNumTrains(9999);
@ -891,8 +889,6 @@ public enum PowersManager { @@ -891,8 +889,6 @@ public enum PowersManager {
//Power is aiding a target, handle aggro if combat target is a Mob.
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target;
if (!pb.isHarmful())
Mob.HandleAssistedAggro(playerCharacter, pcTarget);
}
// update target of used power timer

4
src/engine/jobs/EndFearJob.java

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

106
src/engine/mobileAI/MobAI.java

@ -96,7 +96,7 @@ public class MobAI { @@ -96,7 +96,7 @@ public class MobAI {
return;
}
if (mob.BehaviourType.callsForHelp)
if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob);
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
@ -165,7 +165,7 @@ public class MobAI { @@ -165,7 +165,7 @@ public class MobAI {
if (playercity != null)
for (Mob guard : playercity.getParent().zoneMobSet)
if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob);
@ -260,7 +260,7 @@ public class MobAI { @@ -260,7 +260,7 @@ public class MobAI {
//guard captains inherit barracks patrol points dynamically
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
Building barracks = mob.building;
@ -280,7 +280,7 @@ public class MobAI { @@ -280,7 +280,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
//make sure mob is out of combat stance
@ -312,9 +312,9 @@ public class MobAI { @@ -312,9 +312,9 @@ public class MobAI {
int contractID;
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.npcOwner.contract.getContractID();
else
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.guardCaptain.contract.getContractID();
else
contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
@ -350,7 +350,7 @@ public class MobAI { @@ -350,7 +350,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.BehaviourType.callsForHelp)
if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile.
@ -433,7 +433,7 @@ public class MobAI { @@ -433,7 +433,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.BehaviourType.callsForHelp)
if (mob.behaviourType.callsForHelp)
MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile.
@ -564,7 +564,7 @@ public class MobAI { @@ -564,7 +564,7 @@ public class MobAI {
Zone mobCamp = mob.getParentZone();
for (Mob helper : mobCamp.zoneMobSet) {
if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) {
if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) {
helper.setCombatTarget(mob.getCombatTarget());
callGotResponse = true;
}
@ -608,8 +608,8 @@ public class MobAI { @@ -608,8 +608,8 @@ public class MobAI {
if (mob.despawned && mob.isPlayerGuard) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {
//minions don't respawn while guard captain is dead
@ -625,7 +625,7 @@ public class MobAI { @@ -625,7 +625,7 @@ public class MobAI {
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
CheckToSendMobHome(mob);
return;
@ -646,7 +646,7 @@ public class MobAI { @@ -646,7 +646,7 @@ public class MobAI {
return;
}
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
CheckToSendMobHome(mob);
if (mob.getCombatTarget() != null) {
@ -673,7 +673,7 @@ public class MobAI { @@ -673,7 +673,7 @@ public class MobAI {
}
}
switch (mob.BehaviourType) {
switch (mob.behaviourType) {
case GuardCaptain:
GuardCaptainLogic(mob);
break;
@ -684,6 +684,7 @@ public class MobAI { @@ -684,6 +684,7 @@ public class MobAI {
GuardWallArcherLogic(mob);
break;
case Pet1:
case SiegeEngine:
PetLogic(mob);
break;
case HamletGuard:
@ -707,7 +708,7 @@ public class MobAI { @@ -707,7 +708,7 @@ public class MobAI {
if (!aiAgent.isAlive())
return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = aiAgent.playerAgroMap;
ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) {
@ -782,33 +783,39 @@ public class MobAI { @@ -782,33 +783,39 @@ public class MobAI {
mob.updateLocation();
switch (mob.BehaviourType) {
switch (mob.behaviourType) {
case Pet1:
if (mob.getOwner() == null)
if ((PlayerCharacter) mob.guardCaptain == null)
return;
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
if (!mob.playerAgroMap.containsKey(((PlayerCharacter) mob.guardCaptain).getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner
MovementManager.translocate(mob, mob.getOwner().getLoc(), null);
MovementManager.translocate(mob, ((PlayerCharacter) mob.guardCaptain).getLoc(), null);
return;
}
if (mob.getCombatTarget() == null) {
//move back to owner
if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6))
if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6))
return;
mob.destination = mob.getOwner().getLoc();
mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 5);
} else
chaseTarget(mob);
break;
case GuardMinion:
if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned)
if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned)
randomGuardPatrolPoint(mob);
else {
if (mob.getCombatTarget() != null) {
@ -893,7 +900,8 @@ public class MobAI { @@ -893,7 +900,8 @@ public class MobAI {
if (mob.getCombatTarget() == null)
return;
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false &&
mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) {
mob.setCombatTarget(null);
return;
@ -909,10 +917,10 @@ public class MobAI { @@ -909,10 +917,10 @@ public class MobAI {
private static void CheckToSendMobHome(Mob mob) {
try {
if (mob.BehaviourType.isAgressive) {
if (mob.behaviourType.isAgressive) {
if (mob.isPlayerGuard()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
CheckForPlayerGuardAggro(mob);
} else {
CheckForAggro(mob);
@ -932,7 +940,7 @@ public class MobAI { @@ -932,7 +940,7 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) {
//guard captain pulls his minions home with him
@ -948,8 +956,8 @@ public class MobAI { @@ -948,8 +956,8 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
for (Entry playerEntry : mob.playerAgroMap.entrySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
for (Integer playerEntry : mob.playerAgroMap.keySet())
mob.playerAgroMap.put(playerEntry,0f);
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
@ -1013,7 +1021,7 @@ public class MobAI { @@ -1013,7 +1021,7 @@ public class MobAI {
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD)))
continue;
if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1))
if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1))
continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
@ -1054,7 +1062,7 @@ public class MobAI { @@ -1054,7 +1062,7 @@ public class MobAI {
public static void GuardMinionLogic(Mob mob) {
try {
if (!mob.npcOwner.isAlive()) {
if (!mob.guardCaptain.isAlive()) {
if (mob.getCombatTarget() == null) {
CheckForPlayerGuardAggro(mob);
@ -1073,11 +1081,10 @@ public class MobAI { @@ -1073,11 +1081,10 @@ public class MobAI {
}
}
}else {
if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else
if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
if (mob.guardCaptain.getCombatTarget() != null)
mob.setCombatTarget(mob.guardCaptain.getCombatTarget());
else if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
}
CheckMobMovement(mob);
CheckForAttack(mob);
@ -1102,11 +1109,12 @@ public class MobAI { @@ -1102,11 +1109,12 @@ public class MobAI {
try {
if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner");
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam)
CheckMobMovement(mob);
CheckForAttack(mob);
@ -1156,7 +1164,7 @@ public class MobAI { @@ -1156,7 +1164,7 @@ public class MobAI {
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
mob.setCombatTarget(null);
if (mob.BehaviourType.isAgressive) {
if (mob.behaviourType.isAgressive) {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
@ -1164,7 +1172,7 @@ public class MobAI { @@ -1164,7 +1172,7 @@ public class MobAI {
mob.setCombatTarget(newTarget);
else {
if (mob.getCombatTarget() == null) {
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard)
SafeGuardAggro(mob); //safehold guard
else
CheckForAggro(mob); //normal aggro
@ -1174,12 +1182,12 @@ public class MobAI { @@ -1174,12 +1182,12 @@ public class MobAI {
//check if mob can move for patrol or moving to target
if (mob.BehaviourType.canRoam)
if (mob.behaviourType.canRoam)
CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null)
CheckForAttack(mob);
} catch (Exception e) {
@ -1196,7 +1204,7 @@ public class MobAI { @@ -1196,7 +1204,7 @@ public class MobAI {
if (!mob.isAlive())
return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = mob.playerAgroMap;
ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) {
@ -1244,8 +1252,8 @@ public class MobAI { @@ -1244,8 +1252,8 @@ public class MobAI {
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false;
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true;
}
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
@ -1329,7 +1337,7 @@ public class MobAI { @@ -1329,7 +1337,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance
@ -1356,7 +1364,7 @@ public class MobAI { @@ -1356,7 +1364,7 @@ public class MobAI {
float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue();
CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue();
AbstractWorldObject mostHatedTarget = null;
@ -1367,8 +1375,8 @@ public class MobAI { @@ -1367,8 +1375,8 @@ public class MobAI {
if (potentialTarget.equals(mob.getCombatTarget()))
continue;
if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue();
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
mostHatedTarget = potentialTarget;
}

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

@ -48,7 +48,7 @@ public class CombatUtilities { @@ -48,7 +48,7 @@ public class CombatUtilities {
}
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) {
return entity1.getLoc().distance2D(entity2.getLoc()) < range;
return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range;
}
public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {

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

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

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

@ -8,7 +8,6 @@ import engine.gameManager.BuildingManager; @@ -8,7 +8,6 @@ import engine.gameManager.BuildingManager;
import engine.gameManager.DbManager;
import engine.gameManager.NPCManager;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
@ -42,7 +41,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -42,7 +41,6 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (player == null)
return true;
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
NPC npc = NPC.getFromCache(minionMsg.getNpcID());
@ -63,10 +61,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -63,10 +61,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
if (!npc.getSiegeMinionMap().containsKey(toRemove))
if (!npc.siegeMinionMap.containsKey(toRemove))
return true;
npc.getSiegeMinionMap().remove(toRemove);
npc.siegeMinionMap.remove(toRemove);
WorldGrid.RemoveWorldObject(toRemove);
@ -74,14 +72,18 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -74,14 +72,18 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
}
// we Found the move to remove, lets break the for loop so it doesnt look for more.
@ -115,7 +117,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -115,7 +117,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (npc.getContractID() == 842)
maxSlots = 1;
if (npc.getSiegeMinionMap().size() == maxSlots)
if (npc.siegeMinionMap.size() == maxSlots)
return true;
int mobBase;
@ -146,42 +148,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -146,42 +148,10 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (mobBase == 0)
return true;
Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
Mob siegeMob = Mob.createSiegeMinion(npc, mobBase);
if (siegeMob == null)
return true;
if (siegeMob != null) {
siegeMob.setSpawnTime(60 * 15);
Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID());
siegeMob.building = building;
siegeMob.parentZone = zone;
// Slot siege minion
// Can be either corner tower or bulwark.
int slot;
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER))
slot = 2;
else
slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain
BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation());
// Rotate slot position by the building rotation
siegeMob.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), siegeMob.bindLoc, building.getBounds().getQuaternion().angleY);
siegeMob.loc = new Vector3fImmutable(siegeMob.bindLoc);
siegeMob.endLoc = new Vector3fImmutable(siegeMob.bindLoc);
zone.zoneMobSet.add(siegeMob);
siegeMob.setLoc(siegeMob.bindLoc);
}
}
ManageNPCMsg mnm = new ManageNPCMsg(npc);
@ -228,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -228,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
@ -298,14 +271,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -298,14 +271,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
String pirateName = NPCManager.getPirateName(mobBase);
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
return true;
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName);
if (toCreate == null)
return true;
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
return true;
if (toCreate != null) {
toCreate.setDeathTime(System.currentTimeMillis());
toCreate.parentZone.zoneMobSet.add(toCreate);

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

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

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

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

61
src/engine/objects/AbstractCharacter.java

@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public int contractUUID;
public Contract contract;
protected String firstName;
protected String lastName;
public String firstName;
public String lastName;
protected short statStrCurrent;
protected short statDexCurrent;
protected short statConCurrent;
@ -117,16 +117,33 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -117,16 +117,33 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected boolean movingUp = false;
private float desiredAltitude = 0;
private long takeOffTime = 0;
private float hateValue = 0;
private long lastHateUpdate = 0;
private boolean collided = false;
private byte aoecntr = 0;
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public AbstractCharacter() {
super();
this.firstName = "";
this.lastName = "";
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.statStrCurrent = (short) 0;
this.statDexCurrent = (short) 0;
this.statConCurrent = (short) 0;
this.statIntCurrent = (short) 0;
this.statSpiCurrent = (short) 0;
this.unusedStatPoints = (short) 0;
this.level = (short) 0; // TODO get this from MobsBase later
this.exp = 1;
this.walkMode = true;
this.bindLoc = Vector3fImmutable.ZERO;
this.faceDir = Vector3fImmutable.ZERO;
this.runningTrains = (byte) 0;
this.skills = new ConcurrentHashMap<>();
this.powers = new ConcurrentHashMap<>();
this.initializeCharacter();
}
@ -214,8 +231,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -214,8 +231,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**
@ -258,8 +273,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -258,8 +273,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>();
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**
@ -291,8 +304,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -291,8 +304,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>();
initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
/**
@ -342,9 +353,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -342,9 +353,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>();
this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
}
public static int getBankCapacity() {
@ -1758,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1758,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.inBuildingID = inBuildingID;
}
public float getHateValue() {
if (this.hateValue <= 0) {
this.hateValue = 0;
return hateValue;
}
if (this.lastHateUpdate == 0) {
this.lastHateUpdate = System.currentTimeMillis();
return this.hateValue;
}
long duration = System.currentTimeMillis() - this.lastHateUpdate;
//convert duration to seconds and multiply Hate Delimiter.
float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER;
this.hateValue -= modAmount;
this.lastHateUpdate = System.currentTimeMillis();
return this.hateValue;
}
public void setHateValue(float hateValue) {
this.lastHateUpdate = System.currentTimeMillis();
this.hateValue = hateValue;
}
public int getInFloorID() {
return inFloorID;
}

31
src/engine/objects/AbstractIntelligenceAgent.java

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

4
src/engine/objects/AbstractWorldObject.java

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

1071
src/engine/objects/Mob.java

File diff suppressed because it is too large Load Diff

18
src/engine/objects/NPC.java

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

19
src/engine/objects/PlayerCharacter.java

@ -144,7 +144,6 @@ public class PlayerCharacter extends AbstractCharacter { @@ -144,7 +144,6 @@ public class PlayerCharacter extends AbstractCharacter {
private long lastUpdateTime = System.currentTimeMillis();
private long lastStamUpdateTime = System.currentTimeMillis();
private boolean safeZone = false;
private int bindBuildingID;
/*
DataWarehouse based kill/death tracking.
@ -205,15 +204,18 @@ public class PlayerCharacter extends AbstractCharacter { @@ -205,15 +204,18 @@ public class PlayerCharacter extends AbstractCharacter {
this.spiMod.set(spiMod);
this.guildStatus = new AtomicInteger(0);
this.bindBuildingID = -1;
this.buildingUUID = -1;
}
/**
* ResultSet Constructor
*/
public PlayerCharacter(ResultSet rs) throws SQLException {
super(rs, true);
this.charItemManager = new CharacterItemManager(this);
this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID());
int accountID = rs.getInt("parent");
this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID);
@ -265,7 +267,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -265,7 +267,7 @@ public class PlayerCharacter extends AbstractCharacter {
this.intMod.set(rs.getShort("char_intMod"));
this.spiMod.set(rs.getShort("char_spiMod"));
this.bindBuildingID = rs.getInt("char_bindBuilding");
this.buildingUUID = rs.getInt("char_bindBuilding");
this.hash = rs.getString("hash");
@ -2721,12 +2723,12 @@ public class PlayerCharacter extends AbstractCharacter { @@ -2721,12 +2723,12 @@ public class PlayerCharacter extends AbstractCharacter {
*/
public synchronized int getBindBuildingID() {
return this.bindBuildingID;
return this.buildingUUID;
}
public synchronized void setBindBuildingID(int value) {
DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value);
this.bindBuildingID = value;
this.buildingUUID = value;
}
public AbstractGameObject getLastTarget() {
@ -4561,10 +4563,6 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4561,10 +4563,6 @@ public class PlayerCharacter extends AbstractCharacter {
@Override
public void runAfterLoad() {
// Init inventory
this.charItemManager = new CharacterItemManager(this);
Bounds playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc());
this.setBounds(playerBounds);
@ -4692,7 +4690,8 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4692,7 +4690,8 @@ public class PlayerCharacter extends AbstractCharacter {
} else if (currentPet.isSiege()) {
currentPet.agentType = AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
WorldGrid.updateObject(currentPet);

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

@ -11,6 +11,7 @@ package engine.powers.poweractions; @@ -11,6 +11,7 @@ package engine.powers.poweractions;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.ChatManager;
import engine.jobs.ChantJob;
import engine.jobs.DeferredPowerJob;
@ -22,6 +23,7 @@ import engine.objects.*; @@ -22,6 +23,7 @@ import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@ -117,20 +119,12 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { @@ -117,20 +119,12 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
awo.addEffect(stackType, duration, eff, effect, trains);
} else
awo.applyAllBonuses();
// //TODO if chant, start cycle
// if (pb.isChant() && source.equals(awo)) {
// ChantJob cj = new ChantJob(source, awo, stackType, trains, ab, pb, effect, eff);
// source.setLastChant((int)(pb.getChantDuration()-2) * 1000, cj);
// eff.setChant(true);
// }
if (this.effectID.equals("TAUNT")) {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
((Mob) awo).setCombatTarget(source);
ChatSystemMsg msg = ChatManager.CombatInfo(source, awo);
DispatchMessage.sendToAllInRange(source, msg);
((Mob)awo).refresh();
}
}
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
@ -140,7 +134,21 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { @@ -140,7 +134,21 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
}
this.effect.startEffect(source, awo, trains, eff);
}
//apply effects to mobs within range for chants
if(pb.isChant){
for(AbstractGameObject ago : WorldGrid.getObjectsInRangePartial(awo.loc,pb.range, MBServerStatics.MASK_MOB)){
Mob mob = (Mob)ago;
if(mob.playerAgroMap.containsKey(source.getObjectUUID()))
mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue);
}
}else {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
Mob mob = (Mob) awo;
if (mob.playerAgroMap.containsKey(source.getObjectUUID()))
mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue);
}
}
}
protected void _applyEffectForItem(Item item, int trains) {

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

@ -12,7 +12,6 @@ package engine.powers.poweractions; @@ -12,7 +12,6 @@ package engine.powers.poweractions;
import engine.Enum;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.DbManager;
import engine.gameManager.MovementManager;
import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable;
@ -75,7 +74,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -75,7 +74,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
return;
//create Pet
Mob pet = Mob.createPet(mobID, guild, seaFloor, owner, (short) mobLevel);
Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel);
if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet
@ -84,8 +83,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -84,8 +83,6 @@ public class CreateMobPowerAction extends AbstractPowerAction {
WorldGrid.RemoveWorldObject(currentPet);
currentPet.setCombatTarget(null);
//if (currentPet.getParentZone() != null)
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear();
@ -95,10 +92,10 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -95,10 +92,10 @@ public class CreateMobPowerAction extends AbstractPowerAction {
Logger.error(e.getMessage());
}
//currentPet.disableIntelligence();
} else if (currentPet != null && currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
@ -106,7 +103,6 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -106,7 +103,6 @@ public class CreateMobPowerAction extends AbstractPowerAction {
}
//remove 10th pet
NPCManager.spawnNecroPet(owner, pet);
} else { //is not a necro pet
@ -115,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -115,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
DbManager.removeFromCache(currentPet);
currentPet.setCombatTarget(null);
currentPet.setOwner(null);
currentPet.guardCaptain = null;
WorldGrid.RemoveWorldObject(currentPet);
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
@ -125,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -125,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} else {
if (currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
@ -137,26 +134,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -137,26 +134,9 @@ public class CreateMobPowerAction extends AbstractPowerAction {
NPCManager.resetNecroPets(owner);
}
}
/* if(owner.getPet() != null) {
if(owner.getPet().getMobBaseID() != 12021 && owner.getPet().getMobBaseID() != 12022) {
//if not a necro pet, remove pet
WorldGrid.removeWorldObject(owner.getPet());
owner.getPet().disableIntelligence();
Mob.removePet(owner.getPet().getUUID());
owner.setPet(null);
}
else {
//if it is a necro pet, add it to the line and set as mob
owner.getPet().setMob();
}
}*/
// if (mobID == 12021 || mobID == 12022) //Necro Pets
// pet.setPet(owner, true);
owner.setPet(pet);
if(pet.isSiege() == false) {
MovementManager.translocate(pet, owner.getLoc(), owner.region);
}
pet.recalculateStats();
pet.healthMax = pet.level * 0.5f * 120;
pet.setHealth(pet.healthMax);

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

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

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

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.server.world;
import engine.Enum;
import engine.Enum.BuildingGroup;
import engine.Enum.DispatchChannel;
import engine.Enum.MinionType;
import engine.Enum.SupportMsgType;
@ -18,6 +17,7 @@ import engine.InterestManagement.HeightMap; @@ -18,6 +17,7 @@ import engine.InterestManagement.HeightMap;
import engine.InterestManagement.RealmMap;
import engine.InterestManagement.WorldGrid;
import engine.db.archive.DataWarehouse;
import engine.db.handlers.dbPowerHandler;
import engine.exception.MsgSendException;
import engine.gameManager.*;
import engine.job.JobContainer;
@ -334,7 +334,7 @@ public class WorldServer { @@ -334,7 +334,7 @@ public class WorldServer {
DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
Logger.info("Loading NPC and Mob Rune Sets");
NPCManager.LoadAllRuneSets();
NPCManager._runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
Logger.info("Loading Booty Sets");
LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES();
@ -352,7 +352,7 @@ public class WorldServer { @@ -352,7 +352,7 @@ public class WorldServer {
DbManager.MobBaseQueries.GET_ALL_MOBBASES();
Logger.info("Loading Mob Powers");
PowersManager.AllMobPowers = DbManager.PowerQueries.LOAD_MOB_POWERS();
PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS();
Logger.info("Loading item enchants");
DbManager.LootQueries.LOAD_ENCHANT_VALUES();
@ -482,7 +482,7 @@ public class WorldServer { @@ -482,7 +482,7 @@ public class WorldServer {
Logger.info("Initializing Client Connection Manager");
initClientConnectionManager();
//intiate mob respawn thread
Logger.info("Starting Mob Respawn Thread");
MobRespawnThread.startRespawnThread();
@ -551,44 +551,40 @@ public class WorldServer { @@ -551,44 +551,40 @@ public class WorldServer {
}
//Set sea floor object for server
Zone seaFloor = rootParent.get(0);
seaFloor.setParent(null);
ZoneManager.setSeaFloor(seaFloor);
// zoneManager.addZone(seaFloor.getLoadNum(), seaFloor); <- DIE IN A FUCKING CAR FIRE BONUS CODE LIKE THIS SUCKS FUCKING DICK
rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor));
long start = System.currentTimeMillis();
for (Zone zone : rootParent) {
try {
ZoneManager.addZone(zone.getLoadNum(), zone);
ZoneManager.addZone(zone.getLoadNum(), zone);
zone.generateWorldAltitude();
try {
zone.generateWorldAltitude();
} catch (Exception e) {
Logger.error(e.getMessage());
e.printStackTrace();
}
//Handle Buildings
//Handle Buildings
try {
ArrayList<Building> bList;
bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
for (Building b : bList) {
try {
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
b.setLoc(b.getLoc());
} catch (Exception e) {
Logger.error(b.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
b.setLoc(b.getLoc());
}
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle Mobs
//Handle Mobs
try {
ArrayList<Mob> mobs;
mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone);
@ -596,15 +592,22 @@ public class WorldServer { @@ -596,15 +592,22 @@ public class WorldServer {
m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks());
m.setLoc(m.getLoc());
//ADD GUARDS HERE.
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
DbManager.MobQueries.LOAD_PATROL_POINTS(m);
// Load Minions for Guard Captains here.
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK)
DbManager.MobQueries.LOAD_GUARD_MINIONS(m);
}
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle npc's
//Handle NPCs
try {
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))
continue;
@ -612,26 +615,22 @@ public class WorldServer { @@ -612,26 +615,22 @@ public class WorldServer {
npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone);
for (NPC n : npcs) {
try {
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
n.setLoc(n.getLoc());
} catch (Exception e) {
Logger.error(n.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
n.setLoc(n.getLoc());
}
//Handle cities
ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(zone);
} catch (Exception e) {
Logger.info(e.getMessage() + zone.getName() + ' ' + zone.getObjectUUID());
Logger.error(e);
e.printStackTrace();
}
//Handle cities
ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(zone);
}
Logger.info("time to load: " + (System.currentTimeMillis() - start) + " ms");
Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms");
}
/**
@ -704,7 +703,7 @@ public class WorldServer { @@ -704,7 +703,7 @@ public class WorldServer {
return;
}
//remove player from loaded mobs agro maps
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) {
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) {
Mob loadedMob = (Mob) awo;
loadedMob.playerAgroMap.remove(player.getObjectUUID());
}

Loading…
Cancel
Save