Browse Source

hamlet guard aggro

combat-2
FatBoy-DOTC 6 months ago
parent
commit
3f3fb53675
  1. 62
      src/engine/mobileAI/MobAI.java

62
src/engine/mobileAI/MobAI.java

@ -30,6 +30,7 @@ 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.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -214,6 +215,7 @@ public class MobAI {
} }
} }
assert mob.patrolPoints != null;
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1) if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
mob.lastPatrolPointIndex = 0; mob.lastPatrolPointIndex = 0;
@ -233,6 +235,7 @@ public class MobAI {
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDCAPTAIN)) if (mob.agentType.equals(mbEnums.AIAgentType.GUARDCAPTAIN))
for (Integer minionUUID : mob.minions) { for (Integer minionUUID : mob.minions) {
Mob minion = Mob.getMob(minionUUID); Mob minion = Mob.getMob(minionUUID);
assert minion != null;
if (minion.isAlive() && minion.combatTarget == null) if (minion.isAlive() && minion.combatTarget == null)
MobAI.patrol(minion); MobAI.patrol(minion);
} }
@ -654,10 +657,7 @@ public class MobAI {
mob.updateLocation(); mob.updateLocation();
switch (mob.behaviourType) { if (mob.behaviourType == mbEnums.MobBehaviourType.Pet1) {
case Pet1:
if (mob.guardCaptain == null) if (mob.guardCaptain == null)
return; return;
@ -679,8 +679,7 @@ public class MobAI {
MovementUtilities.moveToLocation(mob, mob.destination, 5, false); MovementUtilities.moveToLocation(mob, mob.destination, 5, false);
} else } else
chaseTarget(mob); chaseTarget(mob);
break; } else {
default:
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
if (!mob.isMoving()) { if (!mob.isMoving()) {
@ -696,7 +695,6 @@ public class MobAI {
} else { } else {
chaseTarget(mob); chaseTarget(mob);
} }
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());
@ -795,6 +793,7 @@ public class MobAI {
Mob minion = Mob.getMob(minionUUID); Mob minion = Mob.getMob(minionUUID);
PowersManager.useMobPower(minion, minion, recall, 40); PowersManager.useMobPower(minion, minion, recall, 40);
assert minion != null;
minion.setCombatTarget(null); minion.setCombatTarget(null);
} }
} }
@ -949,19 +948,57 @@ public class MobAI {
private static void hamletGuardLogic(Mob mob) { private static void hamletGuardLogic(Mob mob) {
try { try {
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
if (mob.getCombatTarget() == null)
hamletGuardAggro(mob);
else if (!mob.getCombatTarget().isAlive())
hamletGuardAggro(mob);
} else {
//safehold guard //safehold guard
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
safeGuardAggro(mob); safeGuardAggro(mob);
else if (!mob.getCombatTarget().isAlive()) else if (!mob.getCombatTarget().isAlive())
safeGuardAggro(mob); safeGuardAggro(mob);
}
checkForAttack(mob); checkForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage());
} }
} }
private static void hamletGuardAggro(Mob mob) {
ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
for (Entry<Integer, Float> playerEntry : loadedPlayers.entrySet()) {
int playerID = playerEntry.getKey();
PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID);
if (loadedPlayer == null)
continue;
if (!loadedPlayer.isAlive())
continue;
//Can't see target, skip aggro.
if (!mob.canSee(loadedPlayer))
continue;
// No aggro for this player
if (!guardCanAggro(mob, loadedPlayer))
continue;
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) {
mob.setCombatTarget(loadedPlayer);
return;
}
}
}
private static void defaultLogic(Mob mob) { private static void defaultLogic(Mob mob) {
try { try {
@ -1085,7 +1122,7 @@ public class MobAI {
return false; return false;
} }
if (mob.guardedCity.cityOutlaws.contains(target.getObjectUUID())) if (mob.guardedCity != null && mob.guardedCity.cityOutlaws.contains(target.getObjectUUID()))
return true; return true;
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
@ -1093,8 +1130,8 @@ public class MobAI {
//first check condemn list for aggro allowed (allies button is checked) //first check condemn list for aggro allowed (allies button is checked)
if (ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().reverseKOS) { if (Objects.requireNonNull(ZoneManager.getCityAtLocation(mob.getLoc())).getTOL().reverseKOS) {
for (Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { for (Entry<Integer, Condemned> entry : Objects.requireNonNull(ZoneManager.getCityAtLocation(mob.getLoc())).getTOL().getCondemned().entrySet()) {
//target is listed individually //target is listed individually
@ -1116,7 +1153,7 @@ public class MobAI {
//allies button is not checked //allies button is not checked
for (Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) { for (Entry<Integer, Condemned> entry : Objects.requireNonNull(ZoneManager.getCityAtLocation(mob.getLoc())).getTOL().getCondemned().entrySet()) {
//target is listed individually //target is listed individually
@ -1175,6 +1212,7 @@ public class MobAI {
//make sure mob is out of combat stance //make sure mob is out of combat stance
assert minion != null;
if (!minion.despawned) { if (!minion.despawned) {
if (MovementUtilities.canMove(minion)) { if (MovementUtilities.canMove(minion)) {
Vector3f minionOffset = mbEnums.FormationType.getOffset(2, mob.minions.indexOf(minionUUID) + 3); Vector3f minionOffset = mbEnums.FormationType.getOffset(2, mob.minions.indexOf(minionUUID) + 3);

Loading…
Cancel
Save