// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2026 // https://www.magicbane.com package engine.objects; import engine.parsers.objects.RuneTemplate; import engine.parsers.objects.UserPowerAction; import engine.parsers.objects.wpak.PowerActionTemplate; import engine.server.MBServerStatics; import engine.util.Hasher; import java.util.ArrayList; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; public class MobBaseEffects { private static final ConcurrentHashMap> effectsByRune = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private int token; private int rank; private int reqLvl; public MobBaseEffects(int token, int rank, int reqLvl) { this.token = token; this.rank = rank; this.reqLvl = reqLvl; } public static ArrayList getEffectsForRune(int runeID) { return effectsByRune.computeIfAbsent(runeID, MobBaseEffects::loadEffectsForRune); } // item_user_power_action entries are {action id, [rank, reqLvl]}; the action names the effect to apply private static ArrayList loadEffectsForRune(int runeID) { ArrayList runeEffects = new ArrayList<>(); HashSet seenEntries = new HashSet<>(); RuneTemplate rune = RuneTemplate._runes.get(runeID); PowerActionTemplate powerAction; String effectID; int rank; int reqLvl; if (rune == null) return runeEffects; for (UserPowerAction userPowerAction : rune.item_user_power_action) { rank = userPowerAction.arguments.length > 0 ? userPowerAction.arguments[0] : 0; reqLvl = userPowerAction.arguments.length > 1 ? userPowerAction.arguments[1] : 0; // 54 rune files repeat their whole list; the DB kept each entry once if (!seenEntries.add(userPowerAction.power + ":" + rank + ":" + reqLvl)) continue; powerAction = PowerActionTemplate._powerActions.get(userPowerAction.power); if (powerAction != null && !powerAction.effect_ids.isEmpty()) effectID = powerAction.effect_ids.get(0); else effectID = userPowerAction.power; runeEffects.add(new MobBaseEffects(Hasher.SBStringHash(effectID), rank, reqLvl)); } return runeEffects; } public int getToken() { return token; } public int getRank() { return rank; } public int getReqLvl() { return reqLvl; } }