refactored AI variables from MBServerStatics
This commit is contained in:
@@ -174,7 +174,7 @@ public class MobileFSM {
|
||||
rwss.setPlayer(mob);
|
||||
DispatchMessage.sendToAllInRange(mob, rwss);
|
||||
}
|
||||
int patrolDelay = ThreadLocalRandom.current().nextInt((int)(MBServerStatics.AI_PATROL_DIVISOR * 0.5f), MBServerStatics.AI_PATROL_DIVISOR) + MBServerStatics.AI_PATROL_DIVISOR;
|
||||
int patrolDelay = ThreadLocalRandom.current().nextInt((int)(MobileFSMManager.AI_PATROL_DIVISOR * 0.5f), MobileFSMManager.AI_PATROL_DIVISOR) + MobileFSMManager.AI_PATROL_DIVISOR;
|
||||
if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis())
|
||||
//early exit while waiting to patrol again
|
||||
return;
|
||||
@@ -270,7 +270,7 @@ public class MobileFSM {
|
||||
msg.setUnknown04(2);
|
||||
PowersManager.finishUseMobPower(msg, mob, 0, 0);
|
||||
// Default minimum seconds between cast = 10
|
||||
mob.nextCastTime = System.currentTimeMillis() + (MBServerStatics.AI_POWER_DIVISOR * 1000);
|
||||
mob.nextCastTime = System.currentTimeMillis() + mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -500,7 +500,7 @@ public class MobileFSM {
|
||||
CheckForAggro(mob);
|
||||
}
|
||||
}
|
||||
if(mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob,mob.getCombatTarget(),MBServerStatics.AI_BASE_AGGRO_RANGE * 0.5f)){
|
||||
if(mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob,mob.getCombatTarget(), MobileFSMManager.AI_BASE_AGGRO_RANGE * 0.5f)){
|
||||
return;
|
||||
}
|
||||
if (mob.isPlayerGuard() && !mob.despawned) {
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
|
||||
package engine.ai;
|
||||
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.Zone;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.util.ThreadUtils;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -30,6 +28,17 @@ public class MobileFSMManager {
|
||||
private volatile boolean alive;
|
||||
private long timeOfKill = -1;
|
||||
|
||||
//AI variables moved form mb_server_statics
|
||||
public static int AI_BASE_AGGRO_RANGE = 60;
|
||||
public static int AI_DROP_AGGRO_RANGE = 60;
|
||||
public static int AI_RECALL_RANGE = 400;
|
||||
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
||||
public static int AI_THREAD_SLEEP = 1000;
|
||||
public static int AI_PATROL_DIVISOR = 15;
|
||||
public static int AI_POWER_DIVISOR = 20;
|
||||
public static float AI_MAX_ANGLE = 10f;
|
||||
|
||||
|
||||
private MobileFSMManager() {
|
||||
|
||||
Runnable worker = new Runnable() {
|
||||
@@ -40,7 +49,10 @@ public class MobileFSMManager {
|
||||
};
|
||||
|
||||
alive = true;
|
||||
|
||||
//assign the AI varibales base don difficulty scaling from config file:
|
||||
float difficulty = Float.parseFloat(ConfigManager.MB_MOB_DIFFICULTY.getValue());
|
||||
AI_BASE_AGGRO_RANGE = (int)(100 * difficulty); // range at which aggressive mobs will attack you
|
||||
AI_POWER_DIVISOR = (int)(20 * (1.5f-difficulty)); //duration between mob casts
|
||||
Thread t = new Thread(worker, "MobileFSMManager");
|
||||
t.start();
|
||||
}
|
||||
@@ -69,7 +81,7 @@ public class MobileFSMManager {
|
||||
|
||||
//Load zone threshold once.
|
||||
|
||||
long mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
|
||||
long mobPulse = System.currentTimeMillis() + AI_PULSE_MOB_THRESHOLD;
|
||||
Instant startTime;
|
||||
|
||||
while (alive) {
|
||||
@@ -99,7 +111,7 @@ public class MobileFSMManager {
|
||||
if (executionTime.compareTo(executionMax) > 0)
|
||||
executionMax = executionTime;
|
||||
|
||||
mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
|
||||
mobPulse = System.currentTimeMillis() + AI_PULSE_MOB_THRESHOLD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ModType;
|
||||
import engine.Enum.SourceType;
|
||||
import engine.ai.MobileFSMManager;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.MovementManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -79,7 +79,7 @@ public class MovementUtilities {
|
||||
zoneRange = agent.getSpawnRadius();
|
||||
|
||||
|
||||
return distanceSquaredToTarget < sqr(MBServerStatics.AI_DROP_AGGRO_RANGE + zoneRange);
|
||||
return distanceSquaredToTarget < sqr(MobileFSMManager.AI_DROP_AGGRO_RANGE + zoneRange);
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MovementUtilities {
|
||||
Vector3fImmutable tl = target.getLoc();
|
||||
|
||||
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||
float range = MBServerStatics.AI_BASE_AGGRO_RANGE;
|
||||
float range = MobileFSMManager.AI_BASE_AGGRO_RANGE;
|
||||
|
||||
if (agent.isPlayerGuard())
|
||||
range = 150;
|
||||
|
||||
Reference in New Issue
Block a user