hamlet guard aggro
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
assert mob.patrolPoints != null;
|
||||
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
|
||||
mob.lastPatrolPointIndex = 0;
|
||||
|
||||
@@ -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,49 +657,44 @@ public class MobAI {
|
||||
|
||||
mob.updateLocation();
|
||||
|
||||
switch (mob.behaviourType) {
|
||||
if (mob.behaviourType == mbEnums.MobBehaviourType.Pet1) {
|
||||
if (mob.guardCaptain == null)
|
||||
return;
|
||||
|
||||
case Pet1:
|
||||
//mob no longer has its owner loaded, translate pet to owner
|
||||
|
||||
if (mob.guardCaptain == null)
|
||||
if (!mob.playerAgroMap.containsKey(mob.guardCaptain.getObjectUUID())) {
|
||||
MovementManager.translocate(mob, mob.guardCaptain.getLoc());
|
||||
return;
|
||||
}
|
||||
|
||||
if (mob.getCombatTarget() == null) {
|
||||
|
||||
//move back to owner
|
||||
|
||||
if (mob.getRange() * mob.getRange() >= mob.loc.distanceSquared(mob.guardCaptain.loc))
|
||||
return;
|
||||
|
||||
//mob no longer has its owner loaded, translate pet to owner
|
||||
mob.destination = mob.guardCaptain.getLoc();
|
||||
MovementUtilities.moveToLocation(mob, mob.destination, 5, false);
|
||||
} else
|
||||
chaseTarget(mob);
|
||||
} else {
|
||||
if (mob.getCombatTarget() == null) {
|
||||
|
||||
if (!mob.playerAgroMap.containsKey(mob.guardCaptain.getObjectUUID())) {
|
||||
MovementManager.translocate(mob, mob.guardCaptain.getLoc());
|
||||
return;
|
||||
}
|
||||
if (!mob.isMoving()) {
|
||||
|
||||
if (mob.getCombatTarget() == null) {
|
||||
// Minions only patrol on their own if captain is dead.
|
||||
|
||||
//move back to owner
|
||||
|
||||
if (mob.getRange() * mob.getRange() >= mob.loc.distanceSquared(mob.guardCaptain.loc))
|
||||
return;
|
||||
|
||||
mob.destination = mob.guardCaptain.getLoc();
|
||||
MovementUtilities.moveToLocation(mob, mob.destination, 5, false);
|
||||
if (!mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION))
|
||||
patrol(mob);
|
||||
else if (!mob.guardCaptain.isAlive())
|
||||
patrol(mob);
|
||||
} else
|
||||
chaseTarget(mob);
|
||||
break;
|
||||
default:
|
||||
if (mob.getCombatTarget() == null) {
|
||||
|
||||
if (!mob.isMoving()) {
|
||||
|
||||
// Minions only patrol on their own if captain is dead.
|
||||
|
||||
if (!mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION))
|
||||
patrol(mob);
|
||||
else if (!mob.guardCaptain.isAlive())
|
||||
patrol(mob);
|
||||
} else
|
||||
mob.stopPatrolTime = System.currentTimeMillis();
|
||||
} else {
|
||||
chaseTarget(mob);
|
||||
}
|
||||
break;
|
||||
mob.stopPatrolTime = System.currentTimeMillis();
|
||||
} else {
|
||||
chaseTarget(mob);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
|
||||
@@ -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 {
|
||||
private static void hamletGuardLogic(Mob mob) {
|
||||
|
||||
try {
|
||||
//safehold guard
|
||||
|
||||
if (mob.getCombatTarget() == null)
|
||||
safeGuardAggro(mob);
|
||||
else if (!mob.getCombatTarget().isAlive())
|
||||
safeGuardAggro(mob);
|
||||
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 {
|
||||
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 {
|
||||
|
||||
//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 {
|
||||
|
||||
//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 {
|
||||
|
||||
//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);
|
||||
|
||||
Reference in New Issue
Block a user