From 9f0fb26e1f29bd94b736b4a9d2f9fe47a36ecfe4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 8 Aug 2023 12:24:27 -0400 Subject: [PATCH] Need to preserver order of hashmap insertion. --- src/engine/mobileAI/MobAI.java | 4 ++++ src/engine/objects/Mob.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 0944536d..a1b5168c 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -474,6 +474,7 @@ public class MobAI { if (powerTokens.isEmpty()) return false; + int powerToken = 0; int nukeRoll = ThreadLocalRandom.current().nextInt(1,100); @@ -488,6 +489,7 @@ public class MobAI { } int powerRank = 1; + switch(mob.getRank()){ case 1: powerRank = 10; @@ -511,6 +513,7 @@ public class MobAI { powerRank = 40; break; } + PowersBase mobPower = PowersManager.getPowerByToken(powerToken); //check for hit-roll @@ -542,6 +545,7 @@ public class MobAI { msg.setUnknown04(2); PowersManager.finishUseMobPower(msg, mob, 0, 0); + long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY); mob.nextCastTime = System.currentTimeMillis() + randomCooldown; return true; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 16a1cce9..e2f8d728 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -39,6 +39,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -61,7 +62,7 @@ public class Mob extends AbstractIntelligenceAgent { public boolean despawned = false; public Vector3fImmutable destination = Vector3fImmutable.ZERO; public Vector3fImmutable localLoc = Vector3fImmutable.ZERO; - public HashMap mobPowers = new HashMap<>(); + public LinkedHashMap mobPowers = new LinkedHashMap<>(); public MobBase mobBase; public int spawnTime; public Zone parentZone;