Browse Source

Class cleanup.

combat-2
MagicBot 8 months ago
parent
commit
6df0e5625c
  1. 27
      src/engine/mobileAI/MobAI.java

27
src/engine/mobileAI/MobAI.java

@ -582,9 +582,9 @@ public class MobAI {
ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry<Integer, Float> playerEntry : loadedPlayers.entrySet()) {
int playerID = (int) playerEntry.getKey(); int playerID = playerEntry.getKey();
PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID); PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID);
//Player is null, let's remove them from the list. //Player is null, let's remove them from the list.
@ -608,12 +608,12 @@ public class MobAI {
// No aggro for this race type // No aggro for this race type
if (aiAgent.notEnemy.size() > 0 && aiAgent.notEnemy.contains(loadedPlayer.race.getRaceType().getMonsterType())) if (!aiAgent.notEnemy.isEmpty() && aiAgent.notEnemy.contains(loadedPlayer.race.getRaceType().getMonsterType()))
continue; continue;
//mob has enemies and this player race is not it //mob has enemies and this player race is not it
if (aiAgent.enemy.size() > 0 && !aiAgent.enemy.contains(loadedPlayer.race.getRaceType().getMonsterType())) if (!aiAgent.enemy.isEmpty() && !aiAgent.enemy.contains(loadedPlayer.race.getRaceType().getMonsterType()))
continue; continue;
if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) { if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
@ -805,8 +805,7 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
for (Integer playerEntry : mob.playerAgroMap.keySet()) mob.playerAgroMap.replaceAll((e, v) -> 0f);
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());
@ -819,7 +818,7 @@ public class MobAI {
if (!mob.getTimestamps().containsKey("lastChase")) if (!mob.getTimestamps().containsKey("lastChase"))
mob.getTimestamps().put("lastChase", System.currentTimeMillis()); mob.getTimestamps().put("lastChase", System.currentTimeMillis());
else if (System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + (750 + ThreadLocalRandom.current().nextInt(0, 500))) else if (System.currentTimeMillis() < mob.getTimestamps().get("lastChase") + (750 + ThreadLocalRandom.current().nextInt(0, 500)))
return; return;
mob.getTimestamps().put("lastChase", System.currentTimeMillis()); mob.getTimestamps().put("lastChase", System.currentTimeMillis());
@ -1021,9 +1020,9 @@ public class MobAI {
ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry<Integer, Float> playerEntry : loadedPlayers.entrySet()) {
int playerID = (int) playerEntry.getKey(); int playerID = playerEntry.getKey();
PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID); PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID);
//Player is null, let's remove them from the list. //Player is null, let's remove them from the list.
@ -1198,13 +1197,13 @@ public class MobAI {
float CurrentHateValue = 0; float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue(); CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID());
AbstractWorldObject mostHatedTarget = null; AbstractWorldObject mostHatedTarget = null;
for (Entry playerEntry : mob.playerAgroMap.entrySet()) { for (Entry<Integer, Float> playerEntry : mob.playerAgroMap.entrySet()) {
PlayerCharacter potentialTarget = PlayerCharacter.getPlayerCharacter((int) playerEntry.getKey()); PlayerCharacter potentialTarget = PlayerCharacter.getPlayerCharacter(playerEntry.getKey());
if (potentialTarget.equals(mob.getCombatTarget())) if (potentialTarget.equals(mob.getCombatTarget()))
continue; continue;
@ -1214,8 +1213,8 @@ public class MobAI {
continue; continue;
} }
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { if (mob.playerAgroMap.get(potentialTarget.getObjectUUID()) > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue(); CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID());
mostHatedTarget = potentialTarget; mostHatedTarget = potentialTarget;
} }

Loading…
Cancel
Save