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; @@ -17,7 +17,6 @@ import engine.InterestManagement.WorldGrid;
import engine.ai.utilities.CombatUtilities;
import engine.ai.utilities.MovementUtilities;
import engine.gameManager.*;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage;
import engine.net.client.msg.PerformActionMsg;
@ -25,8 +24,6 @@ import engine.net.client.msg.PowerProjectileMsg; @@ -25,8 +24,6 @@ import engine.net.client.msg.PowerProjectileMsg;
import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.EffectsBase;
import engine.powers.PowerPrereq;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
@ -469,17 +466,11 @@ public class MobileFSM { @@ -469,17 +466,11 @@ public class MobileFSM {
return;
}
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 (MobCast(aiAgent) == false) {
attack(aiAgent, targetID);
}
} else if (CombatUtilities.inRange2D(aiAgent, aggroTarget, AttackRange)) {
} else if (CombatUtilities.inRange2D(aiAgent, aggroTarget, aiAgent.getRange())) {
aiAgent.setState(STATE.Attack);
attack(aiAgent, targetID);
return;
@ -1155,12 +1146,6 @@ public class MobileFSM { @@ -1155,12 +1146,6 @@ public class MobileFSM {
aiAgent.setCombatTarget(null);
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) {
//recall home.
if (aiAgent.getLoc() == aiAgent.getBindLoc())
@ -1731,15 +1716,28 @@ public class MobileFSM { @@ -1731,15 +1716,28 @@ public class MobileFSM {
mob.nextCallForHelp = System.currentTimeMillis() + 60000;
}
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.updateLocation();
if(CombatUtilities.inRange2D(mob,mob.getCombatTarget(), mob.getRange()) == true) {
MovementUtilities.moveToLocation(mob, mob.getLoc(), 0);
mob.setState(STATE.Attack);
}
else if (mob.isMoving() == false){
mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
else {//if (mob.isMoving() == false){
if(mob.getRange() > 15) {
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 { @@ -781,17 +781,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
// Treb range does not appear to be set here
// what gives?
if (this.getObjectType() == GameObjectType.Mob) {
Mob mob = (Mob) this;
if (mob.isSiege()) {
return 300;
}
float DefaultRange = 8;
if(((Mob) this).getEquip().get(0) != null){
return ((Mob) this).getEquip().get(0).getItemBase().getRange();
} else if(((Mob) this).getEquip().get(1) != null){
return ((Mob) this).getEquip().get(1).getItemBase().getRange();
float range = 8;
if(((Mob) this).getEquip().get(1) != null){
range = ((Mob) this).getEquip().get(1).getItemBase().getRange();
} else if(((Mob) this).getEquip().get(2) != null){
range = ((Mob) this).getEquip().get(2).getItemBase().getRange();
}
if(range > 80){
range = 80;
}
return range;
}
if (this.rangeHandOne > this.rangeHandTwo) {
return this.rangeHandOne;

Loading…
Cancel
Save