Browse Source

hamlet guard aggro

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

Loading…
Cancel
Save