delay between mob actions to reduce synchronized appearance

This commit is contained in:
2023-03-15 13:46:58 -05:00
parent 177175cc1d
commit db71635f16
+5 -2
View File
@@ -16,6 +16,8 @@ import engine.server.MBServerStatics;
import engine.util.ThreadUtils;
import org.pmw.tinylog.Logger;
import java.util.Random;
public class MobileFSMManager {
@@ -70,8 +72,9 @@ public class MobileFSMManager {
long mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
while (alive) {
ThreadUtils.sleep(1);
//assign random range of delay between 1ms and 2000ms so mob actions don't appear synchronized
Random r = new Random();
ThreadUtils.sleep(r.nextInt(2000-1) + 1);
if (System.currentTimeMillis() > mobPulse) {