Browse Source

Class cleanup.

combat-2
MagicBot 6 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 { @@ -582,9 +582,9 @@ public class MobAI {
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);
//Player is null, let's remove them from the list.
@ -608,12 +608,12 @@ public class MobAI { @@ -608,12 +608,12 @@ public class MobAI {
// 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;
//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;
if (MovementUtilities.inRangeToAggro(aiAgent, loadedPlayer)) {
@ -805,8 +805,7 @@ public class MobAI { @@ -805,8 +805,7 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
for (Integer playerEntry : mob.playerAgroMap.keySet())
mob.playerAgroMap.put(playerEntry, 0f);
mob.playerAgroMap.replaceAll((e, v) -> 0f);
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
@ -819,7 +818,7 @@ public class MobAI { @@ -819,7 +818,7 @@ public class MobAI {
if (!mob.getTimestamps().containsKey("lastChase"))
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;
mob.getTimestamps().put("lastChase", System.currentTimeMillis());
@ -1021,9 +1020,9 @@ public class MobAI { @@ -1021,9 +1020,9 @@ public class MobAI {
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);
//Player is null, let's remove them from the list.
@ -1198,13 +1197,13 @@ public class MobAI { @@ -1198,13 +1197,13 @@ public class MobAI {
float CurrentHateValue = 0;
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;
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()))
continue;
@ -1214,8 +1213,8 @@ public class MobAI { @@ -1214,8 +1213,8 @@ public class MobAI {
continue;
}
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
if (mob.playerAgroMap.get(potentialTarget.getObjectUUID()) > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID());
mostHatedTarget = potentialTarget;
}

Loading…
Cancel
Save