|
|
@ -23,6 +23,8 @@ import engine.objects.*; |
|
|
|
import engine.powers.ActionsBase; |
|
|
|
import engine.powers.ActionsBase; |
|
|
|
import engine.powers.PowersBase; |
|
|
|
import engine.powers.PowersBase; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
|
|
|
|
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; |
|
|
@ -35,7 +37,7 @@ public class MobileFSM { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void AttackTarget(Mob mob, AbstractWorldObject target) { |
|
|
|
private static void AttackTarget(Mob mob, AbstractWorldObject target) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKTARGET; |
|
|
|
try { |
|
|
|
if (mob == null) |
|
|
|
if (mob == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if (target == null || !target.isAlive()) { |
|
|
|
if (target == null || !target.isAlive()) { |
|
|
@ -65,10 +67,13 @@ public class MobileFSM { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
mob.updateLocation(); |
|
|
|
mob.updateLocation(); |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void AttackPlayer(Mob mob, PlayerCharacter target) { |
|
|
|
public static void AttackPlayer(Mob mob, PlayerCharacter target) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKPLAYER; |
|
|
|
try{ |
|
|
|
if (!mob.canSee(target)) { |
|
|
|
if (!mob.canSee(target)) { |
|
|
|
mob.setCombatTarget(null); |
|
|
|
mob.setCombatTarget(null); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -114,10 +119,13 @@ public class MobileFSM { |
|
|
|
target.getPet().setCombatTarget(mob); |
|
|
|
target.getPet().setCombatTarget(mob); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void AttackBuilding(Mob mob, Building target) { |
|
|
|
public static void AttackBuilding(Mob mob, Building target) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKBUILDING; |
|
|
|
try{ |
|
|
|
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { |
|
|
|
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) { |
|
|
|
mob.setCombatTarget(null); |
|
|
|
mob.setCombatTarget(null); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -156,10 +164,13 @@ public class MobileFSM { |
|
|
|
ppm.setRange(50); |
|
|
|
ppm.setRange(50); |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
|
|
|
DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void AttackMob(Mob mob, Mob target) { |
|
|
|
public static void AttackMob(Mob mob, Mob target) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.ATTACKMOB; |
|
|
|
try{ |
|
|
|
if (mob.getRange() >= 30 && mob.isMoving()) |
|
|
|
if (mob.getRange() >= 30 && mob.isMoving()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
//no weapons, default mob attack speed 3 seconds.
|
|
|
|
//no weapons, default mob attack speed 3 seconds.
|
|
|
@ -187,10 +198,13 @@ public class MobileFSM { |
|
|
|
target.combatTarget = mob; |
|
|
|
target.combatTarget = mob; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void Patrol(Mob mob) { |
|
|
|
private static void Patrol(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.PATROL; |
|
|
|
try{ |
|
|
|
//make sure mob is out of combat stance
|
|
|
|
//make sure mob is out of combat stance
|
|
|
|
if (mob.isCombat() && mob.getCombatTarget() == null) { |
|
|
|
if (mob.isCombat() && mob.getCombatTarget() == null) { |
|
|
|
mob.setCombat(false); |
|
|
|
mob.setCombat(false); |
|
|
@ -237,10 +251,13 @@ public class MobileFSM { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean canCast(Mob mob) { |
|
|
|
public static boolean canCast(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CANCAST; |
|
|
|
try{ |
|
|
|
// Performs validation to determine if a
|
|
|
|
// Performs validation to determine if a
|
|
|
|
// mobile in the proper state to cast.
|
|
|
|
// mobile in the proper state to cast.
|
|
|
|
if (mob == null) |
|
|
|
if (mob == null) |
|
|
@ -259,10 +276,14 @@ public class MobileFSM { |
|
|
|
mob.nextCastTime = System.currentTimeMillis(); |
|
|
|
mob.nextCastTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
return mob.nextCastTime <= System.currentTimeMillis(); |
|
|
|
return mob.nextCastTime <= System.currentTimeMillis(); |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean MobCast(Mob mob) { |
|
|
|
public static boolean MobCast(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.MOBCAST; |
|
|
|
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
|
|
|
|
// and casts it on the current target (or itself). Validation
|
|
|
|
// and casts it on the current target (or itself). Validation
|
|
|
|
// (including empty lists) is done previously within canCast();
|
|
|
|
// (including empty lists) is done previously within canCast();
|
|
|
@ -323,11 +344,14 @@ public class MobileFSM { |
|
|
|
mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000)) * randomCooldown); |
|
|
|
mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000)) * randomCooldown); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void MobCallForHelp(Mob mob) { |
|
|
|
public static void MobCallForHelp(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.MOBCALLFORHELP; |
|
|
|
try{ |
|
|
|
boolean callGotResponse = false; |
|
|
|
boolean callGotResponse = false; |
|
|
|
if (mob.nextCallForHelp == 0) { |
|
|
|
if (mob.nextCallForHelp == 0) { |
|
|
|
mob.nextCallForHelp = System.currentTimeMillis(); |
|
|
|
mob.nextCallForHelp = System.currentTimeMillis(); |
|
|
@ -346,10 +370,13 @@ public class MobileFSM { |
|
|
|
if (callGotResponse) |
|
|
|
if (callGotResponse) |
|
|
|
//wait 60 seconds to call for help again
|
|
|
|
//wait 60 seconds to call for help again
|
|
|
|
mob.nextCallForHelp = System.currentTimeMillis() + 60000; |
|
|
|
mob.nextCallForHelp = System.currentTimeMillis() + 60000; |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void DetermineAction(Mob mob) { |
|
|
|
public static void DetermineAction(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.DETERMINEACTION; |
|
|
|
try{ |
|
|
|
//always check the respawn que, respawn 1 mob max per second to not flood the client
|
|
|
|
//always check the respawn que, respawn 1 mob max per second to not flood the client
|
|
|
|
|
|
|
|
|
|
|
|
if (mob == null) |
|
|
|
if (mob == null) |
|
|
@ -436,10 +463,13 @@ public class MobileFSM { |
|
|
|
DefaultLogic(mob); |
|
|
|
DefaultLogic(mob); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void CheckForAggro(Mob aiAgent) { |
|
|
|
private static void CheckForAggro(Mob aiAgent) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORAGRO; |
|
|
|
try{ |
|
|
|
//looks for and sets mobs combatTarget
|
|
|
|
//looks for and sets mobs combatTarget
|
|
|
|
if (!aiAgent.isAlive()) |
|
|
|
if (!aiAgent.isAlive()) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -484,10 +514,13 @@ public class MobileFSM { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void CheckMobMovement(Mob mob) { |
|
|
|
private static void CheckMobMovement(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKMOBMOVEMENT; |
|
|
|
try{ |
|
|
|
if (!MovementUtilities.canMove(mob)) |
|
|
|
if (!MovementUtilities.canMove(mob)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
mob.updateLocation(); |
|
|
|
mob.updateLocation(); |
|
|
@ -531,10 +564,13 @@ public class MobileFSM { |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void CheckForRespawn(Mob aiAgent) { |
|
|
|
private static void CheckForRespawn(Mob aiAgent) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORRESPAWN; |
|
|
|
try{ |
|
|
|
if (aiAgent.deathTime == 0) { |
|
|
|
if (aiAgent.deathTime == 0) { |
|
|
|
aiAgent.setDeathTime(System.currentTimeMillis()); |
|
|
|
aiAgent.setDeathTime(System.currentTimeMillis()); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -570,10 +606,13 @@ public class MobileFSM { |
|
|
|
//aiAgent.respawn();
|
|
|
|
//aiAgent.respawn();
|
|
|
|
aiAgent.getParentZone().respawnQue.add(aiAgent); |
|
|
|
aiAgent.getParentZone().respawnQue.add(aiAgent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void CheckForAttack(Mob mob) { |
|
|
|
public static void CheckForAttack(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORATTACK; |
|
|
|
try{ |
|
|
|
//checks if mob can attack based on attack timer and range
|
|
|
|
//checks if mob can attack based on attack timer and range
|
|
|
|
if (mob.isAlive() == false) |
|
|
|
if (mob.isAlive() == false) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -598,10 +637,13 @@ public class MobileFSM { |
|
|
|
} |
|
|
|
} |
|
|
|
if (System.currentTimeMillis() > mob.getLastAttackTime()) |
|
|
|
if (System.currentTimeMillis() > mob.getLastAttackTime()) |
|
|
|
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) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKTOSENDMOBHOME; |
|
|
|
try{ |
|
|
|
if (mob.BehaviourType.isAgressive) { |
|
|
|
if (mob.BehaviourType.isAgressive) { |
|
|
|
if (mob.isPlayerGuard()) { |
|
|
|
if (mob.isPlayerGuard()) { |
|
|
|
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { |
|
|
|
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) { |
|
|
@ -637,10 +679,13 @@ public class MobileFSM { |
|
|
|
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); |
|
|
|
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void chaseTarget(Mob mob) { |
|
|
|
private static void chaseTarget(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHASETARGET; |
|
|
|
try{ |
|
|
|
mob.updateMovementState(); |
|
|
|
mob.updateMovementState(); |
|
|
|
mob.updateLocation(); |
|
|
|
mob.updateLocation(); |
|
|
|
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { |
|
|
|
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { |
|
|
@ -663,10 +708,13 @@ public class MobileFSM { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void SafeGuardAggro(Mob mob) { |
|
|
|
private static void SafeGuardAggro(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.SAFEGUARDAGRO; |
|
|
|
try{ |
|
|
|
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); |
|
|
|
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); |
|
|
|
for (AbstractWorldObject awoMob : awoList) { |
|
|
|
for (AbstractWorldObject awoMob : awoList) { |
|
|
|
//dont scan self.
|
|
|
|
//dont scan self.
|
|
|
@ -680,18 +728,24 @@ public class MobileFSM { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
mob.setCombatTarget(aggroMob); |
|
|
|
mob.setCombatTarget(aggroMob); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void GuardCaptainLogic(Mob mob) { |
|
|
|
public static void GuardCaptainLogic(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDCAPTAINLOGIC; |
|
|
|
try{ |
|
|
|
if (mob.getCombatTarget() == null) |
|
|
|
if (mob.getCombatTarget() == null) |
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
CheckMobMovement(mob); |
|
|
|
CheckMobMovement(mob); |
|
|
|
CheckForAttack(mob); |
|
|
|
CheckForAttack(mob); |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void GuardMinionLogic(Mob mob) { |
|
|
|
public static void GuardMinionLogic(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDMINIONLOGIC; |
|
|
|
try{ |
|
|
|
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { |
|
|
|
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { |
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
} |
|
|
|
} |
|
|
@ -701,18 +755,24 @@ public class MobileFSM { |
|
|
|
mob.setCombatTarget(null); |
|
|
|
mob.setCombatTarget(null); |
|
|
|
CheckMobMovement(mob); |
|
|
|
CheckMobMovement(mob); |
|
|
|
CheckForAttack(mob); |
|
|
|
CheckForAttack(mob); |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void GuardWallArcherLogic(Mob mob) { |
|
|
|
public static void GuardWallArcherLogic(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDWALLARCHERLOGIC; |
|
|
|
try{ |
|
|
|
if (mob.getCombatTarget() == null) |
|
|
|
if (mob.getCombatTarget() == null) |
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
CheckForPlayerGuardAggro(mob); |
|
|
|
else |
|
|
|
else |
|
|
|
CheckForAttack(mob); |
|
|
|
CheckForAttack(mob); |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardWallArcherLogic" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void PetLogic(Mob mob) { |
|
|
|
private static void PetLogic(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.PETLOGIC; |
|
|
|
try{ |
|
|
|
if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){ |
|
|
|
if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){ |
|
|
|
if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){ |
|
|
|
if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){ |
|
|
|
mob.killCharacter("no owner"); |
|
|
|
mob.killCharacter("no owner"); |
|
|
@ -734,11 +794,13 @@ public class MobileFSM { |
|
|
|
mob.setHealth(mob.getHealthMax()); |
|
|
|
mob.setHealth(mob.getHealthMax()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void HamletGuardLogic(Mob mob) { |
|
|
|
private static void HamletGuardLogic(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.HAMLETGUARDLOGIC; |
|
|
|
try{ |
|
|
|
if (mob.getCombatTarget() == null) { |
|
|
|
if (mob.getCombatTarget() == null) { |
|
|
|
//safehold guard
|
|
|
|
//safehold guard
|
|
|
|
SafeGuardAggro(mob); |
|
|
|
SafeGuardAggro(mob); |
|
|
@ -748,10 +810,13 @@ public class MobileFSM { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.DEFAULTLOGIC; |
|
|
|
try{ |
|
|
|
//check for players that can be aggroed if mob is agressive and has no target
|
|
|
|
//check for players that can be aggroed if mob is agressive and has no target
|
|
|
|
if(mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ |
|
|
|
if(mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){ |
|
|
|
mob.setCombatTarget(null); |
|
|
|
mob.setCombatTarget(null); |
|
|
@ -777,10 +842,13 @@ public class MobileFSM { |
|
|
|
//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.combatTarget != null) |
|
|
|
if (!mob.BehaviourType.isWimpy && mob.combatTarget != 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) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHECKFORPLAYERGUARDAGRO; |
|
|
|
try{ |
|
|
|
//looks for and sets mobs combatTarget
|
|
|
|
//looks for and sets mobs combatTarget
|
|
|
|
if (!mob.isAlive()) |
|
|
|
if (!mob.isAlive()) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -809,10 +877,13 @@ public class MobileFSM { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro" + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) { |
|
|
|
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.GUARDCANAGRO; |
|
|
|
try{ |
|
|
|
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) |
|
|
|
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { |
|
|
|
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) { |
|
|
@ -850,11 +921,14 @@ public class MobileFSM { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void randomGuardPatrolPoint(Mob mob) { |
|
|
|
public static void randomGuardPatrolPoint(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.RANDOMGUARDPATROLPOINTS; |
|
|
|
try{ |
|
|
|
if (mob.isMoving() == true) { |
|
|
|
if (mob.isMoving() == true) { |
|
|
|
//early exit for a mob who is already moving to a patrol point
|
|
|
|
//early exit for a mob who is already moving to a patrol point
|
|
|
|
//while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin
|
|
|
|
//while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin
|
|
|
@ -890,10 +964,13 @@ public class MobileFSM { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { |
|
|
|
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { |
|
|
|
MobileFSMManager.getInstance().currentState = MobileFSMManager.fsmState.CHANGETARGETFROMHATEVALUE; |
|
|
|
try{ |
|
|
|
float CurrentHateValue = 0; |
|
|
|
float CurrentHateValue = 0; |
|
|
|
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { |
|
|
|
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { |
|
|
|
CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); |
|
|
|
CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); |
|
|
@ -910,5 +987,9 @@ public class MobileFSM { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return mostHatedTarget; |
|
|
|
return mostHatedTarget; |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |