@ -34,7 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom ;
import java.util.concurrent.ThreadLocalRandom ;
import static engine.math.FastMath.sqr ;
import static engine.math.FastMath.sqr ;
import static java.lang.Math.sqrt ;
public class MobileFSM {
public class MobileFSM {
@ -58,7 +57,7 @@ public class MobileFSM {
if ( mob = = null ) {
if ( mob = = null ) {
return ;
return ;
}
}
STATE state = mob . getState ( ) ;
STATE state = mob . state ;
switch ( state ) {
switch ( state ) {
case Idle :
case Idle :
if ( mob . isAlive ( ) )
if ( mob . isAlive ( ) )
@ -149,21 +148,21 @@ public class MobileFSM {
public static boolean setAwake ( Mob aiAgent , boolean force ) {
public static boolean setAwake ( Mob aiAgent , boolean force ) {
if ( force ) {
if ( force ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return true ;
return true ;
}
}
if ( aiAgent . getState ( ) = = STATE . Idle ) {
if ( aiAgent . state = = STATE . Idle ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return true ;
return true ;
}
}
return false ;
return false ;
}
}
public static boolean setAggro ( Mob aiAgent , int targetID ) {
public static boolean setAggro ( Mob aiAgent , int targetID ) {
if ( aiAgent . getState ( ) ! = STATE . Dead ) {
if ( aiAgent . state ! = STATE . Dead ) {
aiAgent . setNoAggro ( false ) ;
aiAgent . setNoAggro ( false ) ;
aiAgent . setAggroTargetID ( targetID ) ;
aiAgent . setAggroTargetID ( targetID ) ;
aiAgent . setState ( STATE . Aggro ) ;
aiAgent . state = STATE . Aggro ;
return true ;
return true ;
}
}
return false ;
return false ;
@ -173,18 +172,18 @@ public class MobileFSM {
if ( mob . getLoc ( ) . distanceSquared2D ( mob . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( mob . getLoc ( ) . distanceSquared2D ( mob . getBindLoc ( ) ) > sqr ( 2000 ) ) {
mob . setWalkingHome ( false ) ;
mob . setWalkingHome ( false ) ;
mob . setState ( STATE . Home ) ;
mob . state = STATE . Home ;
}
}
}
}
private static void awake ( Mob aiAgent ) {
private static void awake ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
//Don't attempt to aggro if No aggro is on and aiAgent is not home yet.
//Don't attempt to aggro if No aggro is on and aiAgent is not home yet.
@ -197,8 +196,8 @@ public class MobileFSM {
aiAgent . setNoAggro ( false ) ;
aiAgent . setNoAggro ( false ) ;
}
}
//no players currently have this mob loaded. return to IDLE.
//no players currently have this mob loaded. return to IDLE.
if ( aiAgent . getPlayerAgroMap ( ) . isEmpty ( ) ) {
if ( aiAgent . playerAgroMap . isEmpty ( ) ) {
aiAgent . setState ( STATE . Idle ) ;
aiAgent . state = STATE . Idle ;
return ;
return ;
}
}
@ -210,7 +209,7 @@ public class MobileFSM {
//Get the Map for Players that loaded this mob.
//Get the Map for Players that loaded this mob.
ConcurrentHashMap < Integer , Boolean > loadedPlayers = aiAgent . getPlayerAgroMap ( ) ;
ConcurrentHashMap < Integer , Boolean > loadedPlayers = aiAgent . playerAgroMap ;
if ( ! Enum . MobFlagType . AGGRESSIVE . elementOf ( aiAgent . getMobBase ( ) . getFlags ( ) ) & & aiAgent . getCombatTarget ( ) = = null ) {
if ( ! Enum . MobFlagType . AGGRESSIVE . elementOf ( aiAgent . getMobBase ( ) . getFlags ( ) ) & & aiAgent . getCombatTarget ( ) = = null ) {
@ -218,7 +217,7 @@ public class MobileFSM {
int patrolRandom = ThreadLocalRandom . current ( ) . nextInt ( 1000 ) ;
int patrolRandom = ThreadLocalRandom . current ( ) . nextInt ( 1000 ) ;
if ( patrolRandom < = MBServerStatics . AI_PATROL_DIVISOR ) {
if ( patrolRandom < = MBServerStatics . AI_PATROL_DIVISOR ) {
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
}
}
return ;
return ;
}
}
@ -251,7 +250,7 @@ public class MobileFSM {
if ( MovementUtilities . inRangeToAggro ( aiAgent , loadedPlayer ) ) {
if ( MovementUtilities . inRangeToAggro ( aiAgent , loadedPlayer ) ) {
aiAgent . setAggroTargetID ( playerID ) ;
aiAgent . setAggroTargetID ( playerID ) ;
aiAgent . setState ( STATE . Aggro ) ;
aiAgent . state = STATE . Aggro ;
return ;
return ;
}
}
@ -260,37 +259,37 @@ public class MobileFSM {
int patrolRandom = ThreadLocalRandom . current ( ) . nextInt ( 1000 ) ;
int patrolRandom = ThreadLocalRandom . current ( ) . nextInt ( 1000 ) ;
if ( patrolRandom < = MBServerStatics . AI_PATROL_DIVISOR ) {
if ( patrolRandom < = MBServerStatics . AI_PATROL_DIVISOR ) {
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
}
}
}
}
private static void guardAttackMob ( Mob aiAgent ) {
private static void guardAttackMob ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
if ( target = = null ) {
if ( target = = null ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( target . getObjectType ( ) . equals ( GameObjectType . Mob ) = = false ) {
if ( target . getObjectType ( ) . equals ( GameObjectType . Mob ) = = false ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( target . equals ( aiAgent ) ) {
if ( target . equals ( aiAgent ) ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
Mob mob = ( Mob ) target ;
Mob mob = ( Mob ) target ;
if ( ! mob . isAlive ( ) | | mob . getState ( ) = = STATE . Dead ) {
if ( ! mob . isAlive ( ) | | mob . state = = STATE . Dead ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -350,7 +349,7 @@ public class MobileFSM {
}
}
private static void awakeNPCguard ( Mob aiAgent ) {
private static void awakeNPCguard ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
@ -359,7 +358,7 @@ public class MobileFSM {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
@ -383,13 +382,13 @@ public class MobileFSM {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( mob . getLoc ( ) ) > sqr ( 50 ) )
if ( aiAgent . getLoc ( ) . distanceSquared2D ( mob . getLoc ( ) ) > sqr ( 50 ) )
continue ;
continue ;
aiAgent . setCombatTarget ( mob ) ;
aiAgent . setCombatTarget ( mob ) ;
aiAgent . setState ( STATE . Attack ) ;
aiAgent . state = STATE . Attack ;
}
}
}
}
private static void petAwake ( Mob aiAgent ) {
private static void petAwake ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
@ -425,13 +424,13 @@ public class MobileFSM {
private static void aggro ( Mob aiAgent , int targetID ) {
private static void aggro ( Mob aiAgent , int targetID ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
@ -447,22 +446,22 @@ public class MobileFSM {
if ( aggroTarget = = null ) {
if ( aggroTarget = = null ) {
// Logger.error("MobileFSM.aggro", "aggro target with UUID " + targetID + " returned null");
// Logger.error("MobileFSM.aggro", "aggro target with UUID " + targetID + " returned null");
aiAgent . getPlayerAgroMap ( ) . remove ( targetID ) ;
aiAgent . playerAgroMap . remove ( targetID ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( ! aiAgent . canSee ( aggroTarget ) ) {
if ( ! aiAgent . canSee ( aggroTarget ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
targetID = 0 ;
targetID = 0 ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( ! aggroTarget . isActive ( ) ) {
if ( ! aggroTarget . isActive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
targetID = 0 ;
targetID = 0 ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
aiAgent . setCombatTarget ( aggroTarget ) ;
aiAgent . setCombatTarget ( aggroTarget ) ;
@ -471,7 +470,7 @@ public class MobileFSM {
attack ( aiAgent , targetID ) ;
attack ( aiAgent , targetID ) ;
}
}
} else if ( CombatUtilities . inRange2D ( aiAgent , aggroTarget , aiAgent . getRange ( ) ) ) {
} else if ( CombatUtilities . inRange2D ( aiAgent , aggroTarget , aiAgent . getRange ( ) ) ) {
aiAgent . setState ( STATE . Attack ) ;
aiAgent . state = STATE . Attack ;
attack ( aiAgent , targetID ) ;
attack ( aiAgent , targetID ) ;
return ;
return ;
}
}
@ -480,14 +479,14 @@ public class MobileFSM {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( ! MovementUtilities . inRangeOfBindLocation ( aiAgent ) ) {
if ( ! MovementUtilities . inRangeOfBindLocation ( aiAgent ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
@ -511,14 +510,14 @@ public class MobileFSM {
private static void petAttack ( Mob aiAgent ) {
private static void petAttack ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
if ( target = = null ) {
if ( target = = null ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -530,13 +529,13 @@ public class MobileFSM {
if ( ! player . isActive ( ) ) {
if ( ! player . isActive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( player . inSafeZone ( ) ) {
if ( player . inSafeZone ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -556,21 +555,21 @@ public class MobileFSM {
private static void mobAttack ( Mob aiAgent ) {
private static void mobAttack ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
if ( target = = null ) {
if ( target = = null ) {
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
@ -582,13 +581,13 @@ public class MobileFSM {
if ( ! player . isActive ( ) ) {
if ( ! player . isActive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( aiAgent . isNecroPet ( ) & & player . inSafeZone ( ) ) {
if ( aiAgent . isNecroPet ( ) & & player . inSafeZone ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Idle ) ;
aiAgent . state = STATE . Idle ;
return ;
return ;
}
}
if ( canCast ( aiAgent ) = = true ) {
if ( canCast ( aiAgent ) = = true ) {
@ -614,19 +613,19 @@ public class MobileFSM {
if ( building . getRank ( ) = = - 1 ) {
if ( building . getRank ( ) = = - 1 ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( ! building . isVulnerable ( ) ) {
if ( ! building . isVulnerable ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( BuildingManager . getBuildingFromCache ( building . getObjectUUID ( ) ) = = null ) {
if ( BuildingManager . getBuildingFromCache ( building . getObjectUUID ( ) ) = = null ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -645,7 +644,7 @@ public class MobileFSM {
continue ;
continue ;
mob . setCombatTarget ( aiAgent ) ;
mob . setCombatTarget ( aiAgent ) ;
mob . setState ( STATE . Attack ) ;
mob . state = STATE . Attack ;
}
}
}
}
@ -722,13 +721,13 @@ public class MobileFSM {
if ( aiAgent . getMobBase ( ) . getSeeInvis ( ) < player . getHidden ( ) ) {
if ( aiAgent . getMobBase ( ) . getSeeInvis ( ) < player . getHidden ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( ! player . isAlive ( ) ) {
if ( ! player . isAlive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -798,13 +797,13 @@ public class MobileFSM {
if ( aiAgent . getMobBase ( ) . getSeeInvis ( ) < player . getHidden ( ) ) {
if ( aiAgent . getMobBase ( ) . getSeeInvis ( ) < player . getHidden ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( ! player . isAlive ( ) ) {
if ( ! player . isAlive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -815,14 +814,14 @@ public class MobileFSM {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
if ( ! MovementUtilities . inRangeDropAggro ( aiAgent , player ) ) {
if ( ! MovementUtilities . inRangeDropAggro ( aiAgent , player ) ) {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( CombatUtilities . inRange2D ( aiAgent , player , aiAgent . getRange ( ) ) ) {
if ( CombatUtilities . inRange2D ( aiAgent , player , aiAgent . getRange ( ) ) ) {
@ -891,13 +890,13 @@ public class MobileFSM {
if ( CombatUtilities . inRangeToAttack2D ( aiAgent , player ) )
if ( CombatUtilities . inRangeToAttack2D ( aiAgent , player ) )
return ;
return ;
//set mob to pursue target
//set mob to pursue target
aiAgent . setS tate ( MobileFSM . STATE . Chase ) ;
aiAgent . state = STATE . Chase ;
}
}
private static void handleMobAttackForPet ( Mob aiAgent , Mob mob ) {
private static void handleMobAttackForPet ( Mob aiAgent , Mob mob ) {
if ( ! mob . isAlive ( ) ) {
if ( ! mob . isAlive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -969,7 +968,7 @@ public class MobileFSM {
if ( ! mob . isAlive ( ) ) {
if ( ! mob . isAlive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1040,7 +1039,7 @@ public class MobileFSM {
//in range to attack, start attacking now!
//in range to attack, start attacking now!
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
@ -1048,23 +1047,23 @@ public class MobileFSM {
if ( aggroTarget = = null ) {
if ( aggroTarget = = null ) {
// Logger.error("MobileFSM.aggro", "aggro target with UUID " + targetID + " returned null");
// Logger.error("MobileFSM.aggro", "aggro target with UUID " + targetID + " returned null");
aiAgent . getPlayerAgroMap ( ) . remove ( targetID ) ;
aiAgent . playerAgroMap . remove ( targetID ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( aiAgent . getMobBase ( ) . getSeeInvis ( ) < aggroTarget . getHidden ( ) ) {
if ( aiAgent . getMobBase ( ) . getSeeInvis ( ) < aggroTarget . getHidden ( ) ) {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( ! aggroTarget . isAlive ( ) ) {
if ( ! aggroTarget . isAlive ( ) ) {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
@ -1072,7 +1071,7 @@ public class MobileFSM {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
@ -1080,7 +1079,7 @@ public class MobileFSM {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1144,17 +1143,17 @@ public class MobileFSM {
MovementManager . translocate ( aiAgent , aiAgent . getBindLoc ( ) , null ) ;
MovementManager . translocate ( aiAgent , aiAgent . getBindLoc ( ) , null ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
}
}
private static void recalling ( Mob aiAgent ) {
private static void recalling ( Mob aiAgent ) {
//recall home.
//recall home.
if ( aiAgent . getLoc ( ) = = aiAgent . getBindLoc ( ) )
if ( aiAgent . getLoc ( ) = = aiAgent . getBindLoc ( ) )
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
}
}
}
}
private static void patrol ( Mob aiAgent ) {
private static void patrol ( Mob aiAgent ) {
@ -1162,7 +1161,7 @@ public class MobileFSM {
MobBase mobbase = aiAgent . getMobBase ( ) ;
MobBase mobbase = aiAgent . getMobBase ( ) ;
if ( mobbase ! = null & & ( Enum . MobFlagType . SENTINEL . elementOf ( mobbase . getFlags ( ) ) | | ! Enum . MobFlagType . CANROAM . elementOf ( mobbase . getFlags ( ) ) ) ) {
if ( mobbase ! = null & & ( Enum . MobFlagType . SENTINEL . elementOf ( mobbase . getFlags ( ) ) | | ! Enum . MobFlagType . CANROAM . elementOf ( mobbase . getFlags ( ) ) ) ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1178,35 +1177,35 @@ public class MobileFSM {
MovementUtilities . aiMove ( aiAgent , Vector3fImmutable . getRandomPointInCircle ( aiAgent . getBindLoc ( ) , patrolRadius ) , true ) ;
MovementUtilities . aiMove ( aiAgent , Vector3fImmutable . getRandomPointInCircle ( aiAgent . getBindLoc ( ) , patrolRadius ) , true ) ;
}
}
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
}
}
private static void dead ( Mob aiAgent ) {
private static void dead ( Mob aiAgent ) {
//Despawn Timer with Loot currently in inventory.
//Despawn Timer with Loot currently in inventory.
if ( aiAgent . getCharItemManager ( ) . getInventoryCount ( ) > 0 ) {
if ( aiAgent . getCharItemManager ( ) . getInventoryCount ( ) > 0 ) {
if ( System . currentTimeMillis ( ) > aiAgent . getDeathTime ( ) + MBServerStatics . DESPAWN_TIMER_WITH_LOOT ) {
if ( System . currentTimeMillis ( ) > aiAgent . deathTime + MBServerStatics . DESPAWN_TIMER_WITH_LOOT ) {
aiAgent . despawn ( ) ;
aiAgent . despawn ( ) ;
//update time of death after mob despawns so respawn time happens after mob despawns.
//update time of death after mob despawns so respawn time happens after mob despawns.
aiAgent . setDeathTime ( System . currentTimeMillis ( ) ) ;
aiAgent . setDeathTime ( System . currentTimeMillis ( ) ) ;
aiAgent . setState ( STATE . Respawn ) ;
aiAgent . state = STATE . Respawn ;
}
}
//No items in inventory.
//No items in inventory.
} else {
} else {
//Mob's Loot has been looted.
//Mob's Loot has been looted.
if ( aiAgent . isHasLoot ( ) ) {
if ( aiAgent . isHasLoot ( ) ) {
if ( System . currentTimeMillis ( ) > aiAgent . getDeathTime ( ) + MBServerStatics . DESPAWN_TIMER_ONCE_LOOTED ) {
if ( System . currentTimeMillis ( ) > aiAgent . deathTime + MBServerStatics . DESPAWN_TIMER_ONCE_LOOTED ) {
aiAgent . despawn ( ) ;
aiAgent . despawn ( ) ;
//update time of death after mob despawns so respawn time happens after mob despawns.
//update time of death after mob despawns so respawn time happens after mob despawns.
aiAgent . setDeathTime ( System . currentTimeMillis ( ) ) ;
aiAgent . setDeathTime ( System . currentTimeMillis ( ) ) ;
aiAgent . setState ( STATE . Respawn ) ;
aiAgent . state = STATE . Respawn ;
}
}
//Mob never had Loot.
//Mob never had Loot.
} else {
} else {
if ( System . currentTimeMillis ( ) > aiAgent . getDeathTime ( ) + MBServerStatics . DESPAWN_TIMER ) {
if ( System . currentTimeMillis ( ) > aiAgent . deathTime + MBServerStatics . DESPAWN_TIMER ) {
aiAgent . despawn ( ) ;
aiAgent . despawn ( ) ;
//update time of death after mob despawns so respawn time happens after mob despawns.
//update time of death after mob despawns so respawn time happens after mob despawns.
aiAgent . setDeathTime ( System . currentTimeMillis ( ) ) ;
aiAgent . setDeathTime ( System . currentTimeMillis ( ) ) ;
aiAgent . setState ( STATE . Respawn ) ;
aiAgent . state = STATE . Respawn ;
}
}
}
}
}
}
@ -1214,14 +1213,14 @@ public class MobileFSM {
private static void guardAwake ( Mob aiAgent ) {
private static void guardAwake ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
if ( aiAgent . getLoc ( ) . distanceSquared2D ( aiAgent . getBindLoc ( ) ) > sqr ( 2000 ) ) {
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
@ -1232,12 +1231,12 @@ public class MobileFSM {
aiAgent . setNoAggro ( false ) ;
aiAgent . setNoAggro ( false ) ;
// do nothing if no players are around.
// do nothing if no players are around.
if ( aiAgent . getPlayerAgroMap ( ) . isEmpty ( ) )
if ( aiAgent . playerAgroMap . isEmpty ( ) )
return ;
return ;
//Get the Map for Players that loaded this mob.
//Get the Map for Players that loaded this mob.
ConcurrentHashMap < Integer , Boolean > loadedPlayers = aiAgent . getPlayerAgroMap ( ) ;
ConcurrentHashMap < Integer , Boolean > loadedPlayers = aiAgent . playerAgroMap ;
//no players currently have this mob loaded. return to IDLE.
//no players currently have this mob loaded. return to IDLE.
//aiAgent finished moving home, set aggro on.
//aiAgent finished moving home, set aggro on.
@ -1342,13 +1341,13 @@ public class MobileFSM {
if ( aggro ) {
if ( aggro ) {
if ( CombatUtilities . inRangeToAttack ( aiAgent , loadedPlayer ) ) {
if ( CombatUtilities . inRangeToAttack ( aiAgent , loadedPlayer ) ) {
aiAgent . setAggroTargetID ( playerID ) ;
aiAgent . setAggroTargetID ( playerID ) ;
aiAgent . setState ( STATE . Aggro ) ;
aiAgent . state = STATE . Aggro ;
return ;
return ;
}
}
if ( MovementUtilities . inRangeToAggro ( aiAgent , loadedPlayer ) ) {
if ( MovementUtilities . inRangeToAggro ( aiAgent , loadedPlayer ) ) {
aiAgent . setAggroTargetID ( playerID ) ;
aiAgent . setAggroTargetID ( playerID ) ;
aiAgent . setState ( STATE . Aggro ) ;
aiAgent . state = STATE . Aggro ;
return ;
return ;
}
}
}
}
@ -1356,12 +1355,12 @@ public class MobileFSM {
//attempt to patrol even if aiAgent isn't aggresive;
//attempt to patrol even if aiAgent isn't aggresive;
if ( aiAgent . isMoving ( ) = = false )
if ( aiAgent . isMoving ( ) = = false )
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
}
}
private static void guardAggro ( Mob aiAgent , int targetID ) {
private static void guardAggro ( Mob aiAgent , int targetID ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
@ -1376,26 +1375,26 @@ public class MobileFSM {
PlayerCharacter aggroTarget = PlayerCharacter . getFromCache ( targetID ) ;
PlayerCharacter aggroTarget = PlayerCharacter . getFromCache ( targetID ) ;
if ( aggroTarget = = null ) {
if ( aggroTarget = = null ) {
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( ! aiAgent . canSee ( aggroTarget ) ) {
if ( ! aiAgent . canSee ( aggroTarget ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
targetID = 0 ;
targetID = 0 ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( ! aggroTarget . isActive ( ) ) {
if ( ! aggroTarget . isActive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
targetID = 0 ;
targetID = 0 ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( CombatUtilities . inRangeToAttack ( aiAgent , aggroTarget ) ) {
if ( CombatUtilities . inRangeToAttack ( aiAgent , aggroTarget ) ) {
aiAgent . setCombatTarget ( aggroTarget ) ;
aiAgent . setCombatTarget ( aggroTarget ) ;
aiAgent . setState ( STATE . Attack ) ;
aiAgent . state = STATE . Attack ;
guardAttack ( aiAgent ) ;
guardAttack ( aiAgent ) ;
return ;
return ;
}
}
@ -1412,7 +1411,7 @@ public class MobileFSM {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
MovementUtilities . moveToLocation ( aiAgent , aiAgent . getTrueBindLoc ( ) , 0 ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1420,7 +1419,7 @@ public class MobileFSM {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setWalkingHome ( false ) ;
aiAgent . setState ( STATE . Home ) ;
aiAgent . state = STATE . Home ;
return ;
return ;
}
}
@ -1437,8 +1436,8 @@ public class MobileFSM {
}
}
private static void guardPatrol ( Mob aiAgent ) {
private static void guardPatrol ( Mob aiAgent ) {
if ( aiAgent . getPlayerAgroMap ( ) . isEmpty ( ) ) {
if ( aiAgent . playerAgroMap . isEmpty ( ) ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1449,7 +1448,7 @@ public class MobileFSM {
DispatchMessage . sendToAllInRange ( aiAgent , rwss ) ;
DispatchMessage . sendToAllInRange ( aiAgent , rwss ) ;
}
}
if ( aiAgent . getNpcOwner ( ) = = null ) {
if ( aiAgent . npcOwner = = null ) {
if ( ! aiAgent . isWalk ( ) | | ( aiAgent . isCombat ( ) & & aiAgent . getCombatTarget ( ) = = null ) ) {
if ( ! aiAgent . isWalk ( ) | | ( aiAgent . isCombat ( ) & & aiAgent . getCombatTarget ( ) = = null ) ) {
aiAgent . setWalkMode ( true ) ;
aiAgent . setWalkMode ( true ) ;
@ -1460,14 +1459,14 @@ public class MobileFSM {
}
}
if ( aiAgent . isMoving ( ) ) {
if ( aiAgent . isMoving ( ) ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
Building barrack = aiAgent . getBuilding ( ) ;
Building barrack = aiAgent . building ;
if ( barrack = = null ) {
if ( barrack = = null ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1480,7 +1479,7 @@ public class MobileFSM {
}
}
}
}
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1494,25 +1493,25 @@ public class MobileFSM {
}
}
Building barrack = ( ( Mob ) aiAgent . getNpcOwner ( ) ) . getBuilding ( ) ;
Building barrack = ( ( Mob ) aiAgent . npcOwner ) . building ;
if ( barrack = = null ) {
if ( barrack = = null ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( barrack . getPatrolPoints ( ) = = null ) {
if ( barrack . getPatrolPoints ( ) = = null ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( barrack . getPatrolPoints ( ) . isEmpty ( ) ) {
if ( barrack . getPatrolPoints ( ) . isEmpty ( ) ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
if ( aiAgent . isMoving ( ) ) {
if ( aiAgent . isMoving ( ) ) {
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
return ;
return ;
}
}
@ -1528,24 +1527,24 @@ public class MobileFSM {
if ( patrolLoc ! = null ) {
if ( patrolLoc ! = null ) {
if ( MovementUtilities . canMove ( aiAgent ) ) {
if ( MovementUtilities . canMove ( aiAgent ) ) {
MovementUtilities . aiMove ( aiAgent , patrolLoc , true ) ;
MovementUtilities . aiMove ( aiAgent , patrolLoc , true ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
}
}
}
}
}
}
}
}
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
}
}
private static void guardAttack ( Mob aiAgent ) {
private static void guardAttack ( Mob aiAgent ) {
if ( ! aiAgent . isAlive ( ) ) {
if ( ! aiAgent . isAlive ( ) ) {
aiAgent . setState ( STATE . Dead ) ;
aiAgent . state = STATE . Dead ;
return ;
return ;
}
}
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
AbstractGameObject target = aiAgent . getCombatTarget ( ) ;
if ( target = = null ) {
if ( target = = null ) {
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
@ -1556,13 +1555,13 @@ public class MobileFSM {
if ( ! player . isActive ( ) ) {
if ( ! player . isActive ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Patrol ) ;
aiAgent . state = STATE . Patrol ;
return ;
return ;
}
}
if ( aiAgent . isNecroPet ( ) & & player . inSafeZone ( ) ) {
if ( aiAgent . isNecroPet ( ) & & player . inSafeZone ( ) ) {
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Idle ) ;
aiAgent . state = STATE . Idle ;
return ;
return ;
}
}
if ( canCast ( aiAgent ) = = true ) {
if ( canCast ( aiAgent ) = = true ) {
@ -1575,7 +1574,7 @@ public class MobileFSM {
break ;
break ;
case Building :
case Building :
Logger . info ( "PLAYER GUARD ATTEMPTING TO ATTACK BUILDING IN " + aiAgent . getParentZone ( ) . getName ( ) ) ;
Logger . info ( "PLAYER GUARD ATTEMPTING TO ATTACK BUILDING IN " + aiAgent . getParentZone ( ) . getName ( ) ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
break ;
break ;
case Mob :
case Mob :
Mob mob = ( Mob ) target ;
Mob mob = ( Mob ) target ;
@ -1590,7 +1589,7 @@ public class MobileFSM {
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setAggroTargetID ( 0 ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setCombatTarget ( null ) ;
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
}
}
private static void respawn ( Mob aiAgent ) {
private static void respawn ( Mob aiAgent ) {
@ -1599,26 +1598,26 @@ public class MobileFSM {
long spawnTime = aiAgent . getSpawnTime ( ) ;
long spawnTime = aiAgent . getSpawnTime ( ) ;
if ( aiAgent . isPlayerGuard ( ) & & aiAgent . getNpcOwner ( ) ! = null & & ! aiAgent . getNpcOwner ( ) . isAlive ( ) )
if ( aiAgent . isPlayerGuard ( ) & & aiAgent . npcOwner ! = null & & ! aiAgent . npcOwner . isAlive ( ) )
return ;
return ;
if ( System . currentTimeMillis ( ) > aiAgent . getDeathTime ( ) + spawnTime ) {
if ( System . currentTimeMillis ( ) > aiAgent . deathTime + spawnTime ) {
aiAgent . respawn ( ) ;
aiAgent . respawn ( ) ;
aiAgent . setState ( STATE . Idle ) ;
aiAgent . state = STATE . Idle ;
}
}
}
}
private static void retaliate ( Mob aiAgent ) {
private static void retaliate ( Mob aiAgent ) {
if ( aiAgent . getCombatTarget ( ) = = null )
if ( aiAgent . getCombatTarget ( ) = = null )
aiAgent . setState ( STATE . Awake ) ;
aiAgent . state = STATE . Awake ;
//out of range to attack move
//out of range to attack move
if ( ! MovementUtilities . canMove ( aiAgent ) ) {
if ( ! MovementUtilities . canMove ( aiAgent ) ) {
aiAgent . setState ( STATE . Attack ) ;
aiAgent . state = STATE . Attack ;
return ;
return ;
}
}
aiAgent . setState ( STATE . Attack ) ;
aiAgent . state = STATE . Attack ;
//lets make mobs ai less twitchy, Don't call another movement until mob reaches it's destination.
//lets make mobs ai less twitchy, Don't call another movement until mob reaches it's destination.
if ( aiAgent . isMoving ( ) )
if ( aiAgent . isMoving ( ) )
@ -1730,7 +1729,7 @@ public class MobileFSM {
Zone mobCamp = mob . getParentZone ( ) ;
Zone mobCamp = mob . getParentZone ( ) ;
for ( Mob mob1 : mobCamp . zoneMobSet ) {
for ( Mob mob1 : mobCamp . zoneMobSet ) {
if ( mob1 . getMobBase ( ) . getFlags ( ) . contains ( Enum . MobFlagType . RESPONDSTOCALLSFORHELP ) ) {
if ( mob1 . getMobBase ( ) . getFlags ( ) . contains ( Enum . MobFlagType . RESPONDSTOCALLSFORHELP ) ) {
if ( mob1 . getState ( ) = = STATE . Awake ) {
if ( mob1 . state = = STATE . Awake ) {
if ( CombatUtilities . inRange2D ( mob , mob1 , mob . getAggroRange ( ) ) = = true ) {
if ( CombatUtilities . inRange2D ( mob , mob1 , mob . getAggroRange ( ) ) = = true ) {
MovementUtilities . moveToLocation ( mob1 , mob . getLoc ( ) , 0 ) ;
MovementUtilities . moveToLocation ( mob1 , mob . getLoc ( ) , 0 ) ;
}
}
@ -1745,14 +1744,14 @@ public class MobileFSM {
mob . setCombatTarget ( null ) ;
mob . setCombatTarget ( null ) ;
mob . setAggroTargetID ( 0 ) ;
mob . setAggroTargetID ( 0 ) ;
mob . setWalkingHome ( false ) ;
mob . setWalkingHome ( false ) ;
mob . setState ( STATE . Home ) ;
mob . state = STATE . Home ;
return ;
return ;
}
}
mob . updateMovementState ( ) ;
mob . updateMovementState ( ) ;
mob . updateLocation ( ) ;
mob . updateLocation ( ) ;
if ( CombatUtilities . inRange2D ( mob , mob . getCombatTarget ( ) , mob . getRange ( ) ) = = true ) {
if ( CombatUtilities . inRange2D ( mob , mob . getCombatTarget ( ) , mob . getRange ( ) ) = = true ) {
MovementUtilities . moveToLocation ( mob , mob . getLoc ( ) , 0 ) ;
MovementUtilities . moveToLocation ( mob , mob . getLoc ( ) , 0 ) ;
mob . setState ( STATE . Attack ) ;
mob . state = STATE . Attack ;
}
}
else { //if (mob.isMoving() == false){
else { //if (mob.isMoving() == false){
if ( mob . getRange ( ) > 15 ) {
if ( mob . getRange ( ) > 15 ) {