Browse Source

mob ai work

lakebane-mobai2
FatBoy-DOTC 2 weeks ago
parent
commit
2815bc74ad
  1. 20
      src/engine/mobileAI/MobAi2.java

20
src/engine/mobileAI/MobAi2.java

@ -37,6 +37,8 @@ public class MobAi2 {
} }
public static void runAI(Mob mob){ public static void runAI(Mob mob){
//these will be handled in special conditions later
switch(mob.BehaviourType){ switch(mob.BehaviourType){
case GuardCaptain: case GuardCaptain:
case GuardMinion: case GuardMinion:
@ -121,7 +123,7 @@ public class MobAi2 {
int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR; int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR;
if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis()) if (mob.stopPatrolTime + (patrolDelay * 1000L) > System.currentTimeMillis())
return; return;
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1) if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
@ -191,7 +193,7 @@ public class MobAi2 {
if (System.currentTimeMillis() < mob.getLastAttackTime()) if (System.currentTimeMillis() < mob.getLastAttackTime())
return; return;
// ranged mobs cant attack while running. skip until they finally stop. // ranged mobs can't attack while running. skip until they finally stop.
if (mob.isMoving() && mob.getRange() > 20) if (mob.isMoving() && mob.getRange() > 20)
return; return;
@ -223,7 +225,7 @@ public class MobAi2 {
} }
if (target.getPet() != null) if (target.getPet() != null)
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true) if (target.getPet().getCombatTarget() == null && target.getPet().assist)
target.getPet().setCombatTarget(mob); target.getPet().setCombatTarget(mob);
} catch (Exception e) { } catch (Exception e) {
@ -244,10 +246,10 @@ public class MobAi2 {
return; return;
} }
City playercity = ZoneManager.getCityAtLocation(mob.getLoc()); City playerCity = ZoneManager.getCityAtLocation(mob.getLoc());
if (playercity != null) if (playerCity != null)
for (Mob guard : playercity.getParent().zoneMobSet) for (Mob guard : playerCity.getParent().zoneMobSet)
if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
if (guard.getCombatTarget() == null && guard.getGuild() != null && mob.getGuild() != null && !guard.getGuild().equals(mob.getGuild())) if (guard.getCombatTarget() == null && guard.getGuild() != null && mob.getGuild() != null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob); guard.setCombatTarget(mob);
@ -278,12 +280,6 @@ public class MobAi2 {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
} }
//if (mob.isSiege()) {
// PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
// ppm.setRange(50);
// DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
//}
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage());
} }

Loading…
Cancel
Save