Browse Source

camelCase

combat-2
MagicBot 7 months ago
parent
commit
2a9463be4e
  1. 114
      src/engine/mobileAI/MobAI.java
  2. 2
      src/engine/mobileAI/Threads/MobAIThread.java

114
src/engine/mobileAI/MobAI.java

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

2
src/engine/mobileAI/Threads/MobAIThread.java

@ -32,7 +32,7 @@ public class MobAIThread implements Runnable {
try { try {
if (mob != null) if (mob != null)
MobAI.DetermineAction(mob); MobAI.determineAction(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e); Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
e.printStackTrace(); e.printStackTrace();

Loading…
Cancel
Save