Browse Source

disable mob changing target based on hate value

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
b81f088a3a
  1. 44
      src/engine/mobileAI/MobAI.java

44
src/engine/mobileAI/MobAI.java

@ -1391,35 +1391,37 @@ public class MobAI {
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) {
try { if(mob.combatTarget != null)
return mob.combatTarget;
//try {
float CurrentHateValue = 0; // float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.Mob)){ // if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.Mob)){
return mob.getCombatTarget(); // return mob.getCombatTarget();
} // }
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) // if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue(); // CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue();
AbstractWorldObject mostHatedTarget = null; // AbstractWorldObject mostHatedTarget = null;
for (Entry playerEntry : mob.playerAgroMap.entrySet()) { // for (Entry playerEntry : mob.playerAgroMap.entrySet()) {
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey()); // PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey());
if (potentialTarget.equals(mob.getCombatTarget())) // if (potentialTarget.equals(mob.getCombatTarget()))
continue; // continue;
if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { // if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue(); // CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
mostHatedTarget = potentialTarget; // mostHatedTarget = potentialTarget;
} // }
} // }
return mostHatedTarget; // return mostHatedTarget;
} catch (Exception e) { //} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage()); // Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage());
} //}
return null; return null;
} }
} }
Loading…
Cancel
Save