|
|
|
@ -38,7 +38,7 @@ import static engine.math.FastMath.sqr;
@@ -38,7 +38,7 @@ import static engine.math.FastMath.sqr;
|
|
|
|
|
public class MobAI { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void AttackTarget(Mob mob, AbstractWorldObject target) { |
|
|
|
|
private static void attackTarget(Mob mob, AbstractWorldObject target) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -58,7 +58,7 @@ public class MobAI {
@@ -58,7 +58,7 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter && canCast(mob)) { |
|
|
|
|
|
|
|
|
|
if (MobCast(mob)) { |
|
|
|
|
if (mobCast(mob)) { |
|
|
|
|
mob.updateLocation(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -71,15 +71,15 @@ public class MobAI {
@@ -71,15 +71,15 @@ public class MobAI {
|
|
|
|
|
switch (target.getObjectType()) { |
|
|
|
|
case PlayerCharacter: |
|
|
|
|
PlayerCharacter targetPlayer = (PlayerCharacter) target; |
|
|
|
|
AttackPlayer(mob, targetPlayer); |
|
|
|
|
attackPlayer(mob, targetPlayer); |
|
|
|
|
break; |
|
|
|
|
case Building: |
|
|
|
|
Building targetBuilding = (Building) target; |
|
|
|
|
AttackBuilding(mob, targetBuilding); |
|
|
|
|
attackBuilding(mob, targetBuilding); |
|
|
|
|
break; |
|
|
|
|
case Mob: |
|
|
|
|
Mob targetMob = (Mob) target; |
|
|
|
|
AttackMob(mob, targetMob); |
|
|
|
|
attackMob(mob, targetMob); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ public class MobAI {
@@ -90,7 +90,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void AttackPlayer(Mob mob, PlayerCharacter target) { |
|
|
|
|
public static void attackPlayer(Mob mob, PlayerCharacter target) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -100,7 +100,7 @@ public class MobAI {
@@ -100,7 +100,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.callsForHelp) |
|
|
|
|
MobCallForHelp(mob); |
|
|
|
|
mobCallForHelp(mob); |
|
|
|
|
|
|
|
|
|
if (!MovementUtilities.inRangeDropAggro(mob, target)) { |
|
|
|
|
mob.setCombatTarget(null); |
|
|
|
@ -128,7 +128,7 @@ public class MobAI {
@@ -128,7 +128,7 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void AttackBuilding(Mob mob, Building target) { |
|
|
|
|
public static void attackBuilding(Mob mob, Building target) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -162,7 +162,7 @@ public class MobAI {
@@ -162,7 +162,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void AttackMob(Mob mob, Mob target) { |
|
|
|
|
public static void attackMob(Mob mob, Mob target) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -179,7 +179,7 @@ public class MobAI {
@@ -179,7 +179,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void Patrol(Mob mob) { |
|
|
|
|
private static void patrol(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -230,7 +230,7 @@ public class MobAI {
@@ -230,7 +230,7 @@ public class MobAI {
|
|
|
|
|
for (Integer minionUUID : mob.minions) { |
|
|
|
|
Mob minion = Mob.getMob(minionUUID); |
|
|
|
|
if (minion.isAlive() && minion.combatTarget == null) |
|
|
|
|
MobAI.Patrol(minion); |
|
|
|
|
MobAI.patrol(minion); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MovementUtilities.aiMove(mob, mob.destination, true); |
|
|
|
@ -284,7 +284,7 @@ public class MobAI {
@@ -284,7 +284,7 @@ public class MobAI {
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean MobCast(Mob mob) { |
|
|
|
|
public static boolean mobCast(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// Method picks a random spell from a mobile's list of powers
|
|
|
|
@ -296,7 +296,7 @@ public class MobAI {
@@ -296,7 +296,7 @@ public class MobAI {
|
|
|
|
|
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); |
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.callsForHelp) |
|
|
|
|
MobCallForHelp(mob); |
|
|
|
|
mobCallForHelp(mob); |
|
|
|
|
|
|
|
|
|
// Generate a list of tokens from the mob powers for this mobile.
|
|
|
|
|
|
|
|
|
@ -410,7 +410,7 @@ public class MobAI {
@@ -410,7 +410,7 @@ public class MobAI {
|
|
|
|
|
return powerRank; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void MobCallForHelp(Mob mob) { |
|
|
|
|
public static void mobCallForHelp(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -445,7 +445,7 @@ public class MobAI {
@@ -445,7 +445,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void DetermineAction(Mob mob) { |
|
|
|
|
public static void determineAction(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -465,7 +465,7 @@ public class MobAI {
@@ -465,7 +465,7 @@ public class MobAI {
|
|
|
|
|
//trebuchet spawn handler
|
|
|
|
|
|
|
|
|
|
if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { |
|
|
|
|
CheckForRespawn(mob); |
|
|
|
|
checkForRespawn(mob); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -486,12 +486,12 @@ public class MobAI {
@@ -486,12 +486,12 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CheckForRespawn(mob); |
|
|
|
|
checkForRespawn(mob); |
|
|
|
|
|
|
|
|
|
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting
|
|
|
|
|
|
|
|
|
|
if (!mob.agentType.equals(mbEnums.AIAgentType.PET)) |
|
|
|
|
CheckToSendMobHome(mob); |
|
|
|
|
checkToSendMobHome(mob); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -499,7 +499,7 @@ public class MobAI {
@@ -499,7 +499,7 @@ public class MobAI {
|
|
|
|
|
//no need to continue if mob is dead, check for respawn and move on
|
|
|
|
|
|
|
|
|
|
if (!mob.isAlive()) { |
|
|
|
|
CheckForRespawn(mob); |
|
|
|
|
checkForRespawn(mob); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -520,7 +520,7 @@ public class MobAI {
@@ -520,7 +520,7 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mob.agentType.equals(mbEnums.AIAgentType.PET) == false) |
|
|
|
|
CheckToSendMobHome(mob); |
|
|
|
|
checkToSendMobHome(mob); |
|
|
|
|
|
|
|
|
|
if (mob.getCombatTarget() != null) { |
|
|
|
|
|
|
|
|
@ -550,17 +550,17 @@ public class MobAI {
@@ -550,17 +550,17 @@ public class MobAI {
|
|
|
|
|
case GuardCaptain: |
|
|
|
|
case GuardMinion: |
|
|
|
|
case GuardWallArcher: |
|
|
|
|
GuardLogic(mob); |
|
|
|
|
guardLogic(mob); |
|
|
|
|
break; |
|
|
|
|
case Pet1: |
|
|
|
|
case SiegeEngine: |
|
|
|
|
PetLogic(mob); |
|
|
|
|
petLogic(mob); |
|
|
|
|
break; |
|
|
|
|
case HamletGuard: |
|
|
|
|
HamletGuardLogic(mob); |
|
|
|
|
hamletGuardLogic(mob); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
DefaultLogic(mob); |
|
|
|
|
defaultLogic(mob); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
@ -568,7 +568,7 @@ public class MobAI {
@@ -568,7 +568,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void CheckForAggro(Mob aiAgent) { |
|
|
|
|
private static void checkForAggro(Mob aiAgent) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -642,7 +642,7 @@ public class MobAI {
@@ -642,7 +642,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void CheckMobMovement(Mob mob) { |
|
|
|
|
private static void checkMobMovement(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -685,9 +685,9 @@ public class MobAI {
@@ -685,9 +685,9 @@ public class MobAI {
|
|
|
|
|
// Minions only patrol on their own if captain is dead.
|
|
|
|
|
|
|
|
|
|
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION) == false) |
|
|
|
|
Patrol(mob); |
|
|
|
|
patrol(mob); |
|
|
|
|
else if (mob.guardCaptain.isAlive() == false) |
|
|
|
|
Patrol(mob); |
|
|
|
|
patrol(mob); |
|
|
|
|
} else |
|
|
|
|
mob.stopPatrolTime = System.currentTimeMillis(); |
|
|
|
|
} else { |
|
|
|
@ -700,7 +700,7 @@ public class MobAI {
@@ -700,7 +700,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void CheckForRespawn(Mob aiAgent) { |
|
|
|
|
private static void checkForRespawn(Mob aiAgent) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -747,7 +747,7 @@ public class MobAI {
@@ -747,7 +747,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void CheckForAttack(Mob mob) { |
|
|
|
|
public static void checkForAttack(Mob mob) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
//checks if mob can attack based on attack timer and range
|
|
|
|
@ -764,14 +764,14 @@ public class MobAI {
@@ -764,14 +764,14 @@ public class MobAI {
|
|
|
|
|
mob.setCombatTarget(null); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
AttackTarget(mob, mob.getCombatTarget()); |
|
|
|
|
attackTarget(mob, mob.getCombatTarget()); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void CheckToSendMobHome(Mob mob) { |
|
|
|
|
private static void checkToSendMobHome(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -853,7 +853,7 @@ public class MobAI {
@@ -853,7 +853,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void SafeGuardAggro(Mob mob) { |
|
|
|
|
private static void safeGuardAggro(Mob mob) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); |
|
|
|
@ -885,19 +885,19 @@ public class MobAI {
@@ -885,19 +885,19 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void GuardLogic(Mob mob) { |
|
|
|
|
public static void guardLogic(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (mob.getCombatTarget() == null) { |
|
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
|
checkForPlayerGuardAggro(mob); |
|
|
|
|
} else { |
|
|
|
|
//do not need to look to change target if target is already null
|
|
|
|
|
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); |
|
|
|
|
AbstractWorldObject newTarget = changeTargetFromHateValue(mob); |
|
|
|
|
|
|
|
|
|
if (newTarget != null) { |
|
|
|
|
|
|
|
|
|
if (newTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { |
|
|
|
|
if (GuardCanAggro(mob, (PlayerCharacter) newTarget)) |
|
|
|
|
if (guardCanAggro(mob, (PlayerCharacter) newTarget)) |
|
|
|
|
mob.setCombatTarget(newTarget); |
|
|
|
|
} else |
|
|
|
|
mob.setCombatTarget(newTarget); |
|
|
|
@ -905,17 +905,17 @@ public class MobAI {
@@ -905,17 +905,17 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.canRoam) |
|
|
|
|
CheckMobMovement(mob);//all guards that can move check to move
|
|
|
|
|
checkMobMovement(mob);//all guards that can move check to move
|
|
|
|
|
|
|
|
|
|
if (mob.combatTarget != null) |
|
|
|
|
CheckForAttack(mob); //only check to attack if combat target is not null
|
|
|
|
|
checkForAttack(mob); //only check to attack if combat target is not null
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void PetLogic(Mob mob) { |
|
|
|
|
private static void petLogic(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -924,9 +924,9 @@ public class MobAI {
@@ -924,9 +924,9 @@ public class MobAI {
|
|
|
|
|
mob.killCharacter("no owner"); |
|
|
|
|
|
|
|
|
|
if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) |
|
|
|
|
CheckMobMovement(mob); |
|
|
|
|
checkMobMovement(mob); |
|
|
|
|
|
|
|
|
|
CheckForAttack(mob); |
|
|
|
|
checkForAttack(mob); |
|
|
|
|
|
|
|
|
|
//recover health
|
|
|
|
|
|
|
|
|
@ -948,23 +948,23 @@ public class MobAI {
@@ -948,23 +948,23 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void HamletGuardLogic(Mob mob) { |
|
|
|
|
private static void hamletGuardLogic(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//safehold guard
|
|
|
|
|
|
|
|
|
|
if (mob.getCombatTarget() == null) |
|
|
|
|
SafeGuardAggro(mob); |
|
|
|
|
safeGuardAggro(mob); |
|
|
|
|
else if (mob.getCombatTarget().isAlive() == false) |
|
|
|
|
SafeGuardAggro(mob); |
|
|
|
|
safeGuardAggro(mob); |
|
|
|
|
|
|
|
|
|
CheckForAttack(mob); |
|
|
|
|
checkForAttack(mob); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void DefaultLogic(Mob mob) { |
|
|
|
|
private static void defaultLogic(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -975,16 +975,16 @@ public class MobAI {
@@ -975,16 +975,16 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.isAgressive) { |
|
|
|
|
|
|
|
|
|
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); |
|
|
|
|
AbstractWorldObject newTarget = changeTargetFromHateValue(mob); |
|
|
|
|
|
|
|
|
|
if (newTarget != null) |
|
|
|
|
mob.setCombatTarget(newTarget); |
|
|
|
|
else { |
|
|
|
|
if (mob.getCombatTarget() == null) { |
|
|
|
|
if (mob.behaviourType == mbEnums.MobBehaviourType.HamletGuard) |
|
|
|
|
SafeGuardAggro(mob); //safehold guard
|
|
|
|
|
safeGuardAggro(mob); //safehold guard
|
|
|
|
|
else |
|
|
|
|
CheckForAggro(mob); //normal aggro
|
|
|
|
|
checkForAggro(mob); //normal aggro
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -992,19 +992,19 @@ public class MobAI {
@@ -992,19 +992,19 @@ public class MobAI {
|
|
|
|
|
//check if mob can move for patrol or moving to target
|
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.canRoam) |
|
|
|
|
CheckMobMovement(mob); |
|
|
|
|
checkMobMovement(mob); |
|
|
|
|
|
|
|
|
|
//check if mob can attack if it isn't wimpy
|
|
|
|
|
|
|
|
|
|
if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null) |
|
|
|
|
CheckForAttack(mob); |
|
|
|
|
checkForAttack(mob); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void CheckForPlayerGuardAggro(Mob mob) { |
|
|
|
|
public static void checkForPlayerGuardAggro(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -1050,7 +1050,7 @@ public class MobAI {
@@ -1050,7 +1050,7 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
// No aggro for this player
|
|
|
|
|
|
|
|
|
|
if (GuardCanAggro(mob, loadedPlayer) == false) |
|
|
|
|
if (guardCanAggro(mob, loadedPlayer) == false) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) { |
|
|
|
@ -1068,7 +1068,7 @@ public class MobAI {
@@ -1068,7 +1068,7 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mob aggroMob = (Mob) awoMob; |
|
|
|
|
if (GuardCanAggro(mob, aggroMob)) { |
|
|
|
|
if (guardCanAggro(mob, aggroMob)) { |
|
|
|
|
mob.setCombatTarget(aggroMob); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -1080,7 +1080,7 @@ public class MobAI {
@@ -1080,7 +1080,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Boolean GuardCanAggro(Mob mob, AbstractCharacter target) { |
|
|
|
|
public static Boolean guardCanAggro(Mob mob, AbstractCharacter target) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -1189,7 +1189,7 @@ public class MobAI {
@@ -1189,7 +1189,7 @@ public class MobAI {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { |
|
|
|
|
public static AbstractWorldObject changeTargetFromHateValue(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|