Mob effects come from the race rune (2.10b builder) and necro pets get NECROPETSTATS in code, so GET_RUNEBASE_EFFECTS, the MobBaseEffects ResultSet constructor, its unused mobBaseID and the equals/hashCode used for the merge are gone. The table is now unread; drop it with sql/3.4-mobbase-effects-drop.sql. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lines
3.3 KiB
Java
94 lines
3.3 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// 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<Integer, ArrayList<MobBaseEffects>> 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<MobBaseEffects> 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<MobBaseEffects> loadEffectsForRune(int runeID) {
|
|
|
|
ArrayList<MobBaseEffects> runeEffects = new ArrayList<>();
|
|
HashSet<String> 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;
|
|
}
|
|
|
|
|
|
}
|