Browse Source

ranged mobs now stop when in proper attacking range

master
FatBoy-DOTC 2 years ago
parent
commit
6fe690d592
  1. 36
      src/engine/ai/MobileFSM.java
  2. 15
      src/engine/objects/AbstractCharacter.java

36
src/engine/ai/MobileFSM.java

@ -17,7 +17,6 @@ import engine.InterestManagement.WorldGrid;
import engine.ai.utilities.CombatUtilities; import engine.ai.utilities.CombatUtilities;
import engine.ai.utilities.MovementUtilities; import engine.ai.utilities.MovementUtilities;
import engine.gameManager.*; import engine.gameManager.*;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.PerformActionMsg; import engine.net.client.msg.PerformActionMsg;
@ -25,8 +24,6 @@ import engine.net.client.msg.PowerProjectileMsg;
import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.ActionsBase; import engine.powers.ActionsBase;
import engine.powers.EffectsBase;
import engine.powers.PowerPrereq;
import engine.powers.PowersBase; import engine.powers.PowersBase;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -469,17 +466,11 @@ public class MobileFSM {
return; return;
} }
aiAgent.setCombatTarget(aggroTarget); aiAgent.setCombatTarget(aggroTarget);
double AttackRange = 3;
if(aiAgent.getEquip().get(0) != null){
AttackRange = aiAgent.getEquip().get(0).getItemBase().getRange();
} else if(aiAgent.getEquip().get(1) != null){
AttackRange = aiAgent.getEquip().get(1).getItemBase().getRange();
}
if (canCast(aiAgent) == true) { if (canCast(aiAgent) == true) {
if (MobCast(aiAgent) == false) { if (MobCast(aiAgent) == false) {
attack(aiAgent, targetID); attack(aiAgent, targetID);
} }
} else if (CombatUtilities.inRange2D(aiAgent, aggroTarget, AttackRange)) { } else if (CombatUtilities.inRange2D(aiAgent, aggroTarget, aiAgent.getRange())) {
aiAgent.setState(STATE.Attack); aiAgent.setState(STATE.Attack);
attack(aiAgent, targetID); attack(aiAgent, targetID);
return; return;
@ -1155,12 +1146,6 @@ public class MobileFSM {
aiAgent.setCombatTarget(null); aiAgent.setCombatTarget(null);
aiAgent.setState(STATE.Awake); aiAgent.setState(STATE.Awake);
} }
private static void recall(Mob aiAgent) {
//recall home.
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(aiAgent, aiAgent, recall, 40);
aiAgent.setState(MobileFSM.STATE.Recalling);
}
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())
@ -1731,15 +1716,28 @@ public class MobileFSM {
mob.nextCallForHelp = System.currentTimeMillis() + 60000; mob.nextCallForHelp = System.currentTimeMillis() + 60000;
} }
public static void handleMobChase(Mob mob){ public static void handleMobChase(Mob mob){
if (!MovementUtilities.inRangeOfBindLocation(mob)) {
mob.setCombatTarget(null);
mob.setAggroTargetID(0);
mob.setWalkingHome(false);
mob.setState(STATE.Home);
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.setState(STATE.Attack);
} }
else if (mob.isMoving() == false){ else {//if (mob.isMoving() == false){
mob.destination = mob.getCombatTarget().getLoc(); if(mob.getRange() > 15) {
MovementUtilities.moveToLocation(mob, mob.destination, 0); mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else{
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange());
}
} }
} }
} }

15
src/engine/objects/AbstractCharacter.java

@ -781,17 +781,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
// Treb range does not appear to be set here // Treb range does not appear to be set here
// what gives? // what gives?
if (this.getObjectType() == GameObjectType.Mob) { if (this.getObjectType() == GameObjectType.Mob) {
Mob mob = (Mob) this; Mob mob = (Mob) this;
if (mob.isSiege()) { if (mob.isSiege()) {
return 300; return 300;
} }
float DefaultRange = 8; float range = 8;
if(((Mob) this).getEquip().get(0) != null){ if(((Mob) this).getEquip().get(1) != null){
return ((Mob) this).getEquip().get(0).getItemBase().getRange(); range = ((Mob) this).getEquip().get(1).getItemBase().getRange();
} else if(((Mob) this).getEquip().get(1) != null){ } else if(((Mob) this).getEquip().get(2) != null){
return ((Mob) this).getEquip().get(1).getItemBase().getRange(); range = ((Mob) this).getEquip().get(2).getItemBase().getRange();
}
if(range > 80){
range = 80;
} }
return range;
} }
if (this.rangeHandOne > this.rangeHandTwo) { if (this.rangeHandOne > this.rangeHandTwo) {
return this.rangeHandOne; return this.rangeHandOne;

Loading…
Cancel
Save