Deletes the uncalled static_rune_skill_adjusts, static_rune_maxskills, static_skill_skillsgranted, static_skill_skillreq and static_power_powergrant loaders and their ResultSet constructors. LOAD_RUNE_POWERS stays for the 14 Magister Captain guard contract ids. No value changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
126 lines
4.5 KiB
Java
126 lines
4.5 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
|
|
package engine.objects;
|
|
|
|
import engine.mbEnums;
|
|
import engine.parsers.objects.RuneTemplate;
|
|
import engine.server.MBServerStatics;
|
|
import engine.util.Hasher;
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
public class PowerGrantedTrains {
|
|
|
|
private static ConcurrentHashMap<Integer, PowerGrantedTrains> grantedPowers = null;
|
|
private int token;
|
|
private ConcurrentHashMap<Integer, Short> runeGrants = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
|
|
|
public PowerGrantedTrains(int token) {
|
|
this.token = token;
|
|
}
|
|
|
|
/*
|
|
* Getters
|
|
*/
|
|
|
|
public static Short getGrantedTrains(int token, PlayerCharacter pc) {
|
|
if (pc == null)
|
|
return (short) 0;
|
|
|
|
if (PowerGrantedTrains.grantedPowers == null)
|
|
loadGrantedPowers();
|
|
|
|
if (PowerGrantedTrains.grantedPowers.containsKey(token)) {
|
|
PowerGrantedTrains pg = PowerGrantedTrains.grantedPowers.get(token);
|
|
ConcurrentHashMap<Integer, Short> runeGrants = pg.runeGrants;
|
|
ArrayList<Integer> toks = new ArrayList<>();
|
|
|
|
//get race ID
|
|
Race race = pc.race;
|
|
if (race != null)
|
|
toks.add(race.getRaceRuneID());
|
|
|
|
//get baseClass ID
|
|
BaseClass bc = pc.baseClass;
|
|
if (bc != null)
|
|
toks.add(bc.getObjectUUID());
|
|
|
|
//get promoClass ID
|
|
PromotionClass pcc = pc.getPromotionClass();
|
|
if (pcc != null)
|
|
toks.add(pcc.getObjectUUID());
|
|
|
|
//get promotion and base class combined ID
|
|
if (bc != null && pcc != null)
|
|
toks.add(((pcc.getObjectUUID() * 10) + bc.getObjectUUID()));
|
|
|
|
//get any other rune IDs
|
|
ArrayList<CharacterRune> runes = pc.getRunes();
|
|
for (CharacterRune rune : runes)
|
|
toks.add(rune.getRuneBaseID());
|
|
|
|
//Add any power bonuses granted from runes up
|
|
short amount = (short) 0;
|
|
for (Integer tok : toks) {
|
|
if (runeGrants.containsKey(tok))
|
|
amount += runeGrants.get(tok);
|
|
}
|
|
|
|
return amount;
|
|
} else
|
|
return (short) 0;
|
|
}
|
|
|
|
// Trains are power_arguments[0] of the first action. Mob race runes are skipped:
|
|
// their power actions are mob power ranks by level, not trains.
|
|
public static void loadGrantedPowers() {
|
|
|
|
ConcurrentHashMap<Integer, PowerGrantedTrains> powerGrants = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
|
int token;
|
|
int grantCount = 0;
|
|
|
|
for (RuneTemplate rune : RuneTemplate._runes.values()) {
|
|
|
|
if (rune.rune_type == mbEnums.RuneType.RACE && Race.getRace(rune.template_id) == null)
|
|
continue;
|
|
|
|
for (Map.Entry<String, ArrayList<int[]>> powerAction : rune.item_power_action.entrySet()) {
|
|
|
|
if (powerAction.getValue().isEmpty())
|
|
continue;
|
|
|
|
token = Hasher.SBStringHash(powerAction.getKey());
|
|
powerGrants.computeIfAbsent(token, PowerGrantedTrains::new)
|
|
.addRuneGrant(rune.template_id, (short) powerAction.getValue().get(0)[0]);
|
|
grantCount++;
|
|
}
|
|
}
|
|
|
|
PowerGrantedTrains.grantedPowers = powerGrants;
|
|
Logger.info("Loaded " + grantCount + " power train grants for " + powerGrants.size() + " powers");
|
|
}
|
|
|
|
/*
|
|
* Database
|
|
*/
|
|
|
|
public int getToken() {
|
|
return this.token;
|
|
}
|
|
|
|
private void addRuneGrant(int runeID, short amount) {
|
|
this.runeGrants.put(runeID, amount);
|
|
}
|
|
}
|