Browse Source

mob cast delay cached

master
FatBoy-DOTC 1 year ago
parent
commit
ec43c54aff
  1. 9
      src/engine/mobileAI/MobAI.java
  2. 6
      src/engine/mobileAI/Threads/MobAIThread.java

9
src/engine/mobileAI/MobAI.java

@ -423,8 +423,8 @@ public class MobAI {
msg.setUnknown04(2); msg.setUnknown04(2);
PowersManager.finishUseMobPower(msg, mob, 0, 0); PowersManager.finishUseMobPower(msg, mob, 0, 0);
int randomCooldown = ThreadLocalRandom.current().nextInt(1,10); long randomCooldown = (long)(ThreadLocalRandom.current().nextInt(10,15) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + (long) ((mobPower.getCooldown() + (MobAIThread.AI_POWER_DIVISOR * 1000))) + (randomCooldown * 1000); mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -519,9 +519,8 @@ public class MobAI {
msg.setUnknown04(2); msg.setUnknown04(2);
PowersManager.finishUseMobPower(msg, mob, 0, 0); PowersManager.finishUseMobPower(msg, mob, 0, 0);
int randomCooldown = ThreadLocalRandom.current().nextInt(1,10); long randomCooldown = (long)(ThreadLocalRandom.current().nextInt(10,15) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
mob.nextCastTime = System.currentTimeMillis() + (long) ((mobPower.getCooldown() + (MobAIThread.AI_POWER_DIVISOR * 1000))) + (randomCooldown * 1000);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {

6
src/engine/mobileAI/Threads/MobAIThread.java

@ -1,9 +1,11 @@
package engine.mobileAI.Threads; package engine.mobileAI.Threads;
import engine.gameManager.ConfigManager;
import engine.mobileAI.MobAI; import engine.mobileAI.MobAI;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.objects.Mob; import engine.objects.Mob;
import engine.objects.Zone; import engine.objects.Zone;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
public class MobAIThread implements Runnable{ public class MobAIThread implements Runnable{
@ -11,7 +13,7 @@ public class MobAIThread implements Runnable{
public static int AI_DROP_AGGRO_RANGE = 60; public static int AI_DROP_AGGRO_RANGE = 60;
public static int AI_PULSE_MOB_THRESHOLD = 200; public static int AI_PULSE_MOB_THRESHOLD = 200;
public static int AI_PATROL_DIVISOR = 15; public static int AI_PATROL_DIVISOR = 15;
public static int AI_POWER_DIVISOR = 20; public static float AI_CAST_FREQUENCY;
// Thread constructor // Thread constructor
public MobAIThread() { public MobAIThread() {
@ -21,6 +23,8 @@ public class MobAIThread implements Runnable{
@Override @Override
public void run() { public void run() {
//cache config value for mobile casting delay
AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue());
while (true) { while (true) {
for (Zone zone : ZoneManager.getAllZones()) { for (Zone zone : ZoneManager.getAllZones()) {

Loading…
Cancel
Save