Files
Server/src/engine/gameManager/NPCManager.java
T

102 lines
3.1 KiB
Java
Raw Normal View History

2023-03-28 17:22:57 -04:00
package engine.gameManager;
import engine.objects.*;
import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger;
2023-03-28 17:22:57 -04:00
import java.util.ArrayList;
import java.util.HashMap;
public enum NPCManager {
2023-03-28 17:22:57 -04:00
NPC_MANAGER;
2023-03-28 17:45:58 -04:00
public static HashMap<Integer, ArrayList<EquipmentSetEntry>> _equipmentSetMap = new HashMap<>();
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
2023-03-28 17:22:57 -04:00
public static HashMap<Integer, ArrayList<BootySetEntry>> _bootySetMap = new HashMap<>();
2023-03-28 17:22:57 -04:00
2023-03-28 17:29:16 -04:00
public static void LoadAllEquipmentSets() {
2023-03-28 17:45:58 -04:00
_equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
}
public static void LoadAllRuneSets() {
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
2023-03-28 17:29:16 -04:00
}
public static void LoadAllBootySets() {
_bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS();
}
2023-03-29 15:42:32 -04:00
public static void applyRuneSetEffects(Mob mob) {
2023-03-29 15:42:32 -04:00
EffectsBase effectsBase;
2023-03-29 15:42:32 -04:00
//Apply all rune effects.
2023-03-29 15:42:32 -04:00
if (NPCManager._runeSetMap.get(mob.runeSetID).contains(252623)) {
mob.isPlayerGuard = true;
mob.setNoAggro(true);
}
2023-03-29 15:42:32 -04:00
// Only captains have contracts
2023-03-29 15:42:32 -04:00
if (mob.contract != null || mob.isPlayerGuard)
applyEffectsForRune(mob, 252621);
2023-03-29 15:42:32 -04:00
// Apply effects from RuneSet
2023-03-29 15:42:32 -04:00
if (mob.runeSetID != 0)
for (int runeID : _runeSetMap.get(mob.runeSetID))
applyEffectsForRune(mob, runeID);
2023-03-29 15:42:32 -04:00
// Not sure why but apply Warrior effects for some reason?
2023-03-29 15:42:32 -04:00
applyEffectsForRune(mob, 2518);
}
2023-03-29 15:42:32 -04:00
public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
2023-03-29 15:42:32 -04:00
EffectsBase effectsBase;
RuneBase sourceRune = RuneBase.getRuneBase(runeID);
2023-03-29 15:42:32 -04:00
for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
2023-03-29 15:42:32 -04:00
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
2023-03-29 15:42:32 -04:00
if (effectsBase == null) {
Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
continue;
}
2023-03-29 15:42:32 -04:00
//check to upgrade effects if needed.
if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
2023-03-29 15:42:32 -04:00
if (mbe.getReqLvl() > (int) character.level)
continue;
2023-03-29 15:42:32 -04:00
Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
2023-03-29 15:42:32 -04:00
if (eff == null)
continue;
2023-03-29 15:42:32 -04:00
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
2023-03-29 15:42:32 -04:00
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
} else {
2023-03-29 15:42:32 -04:00
if (mbe.getReqLvl() > (int) character.level)
continue;
2023-03-29 15:42:32 -04:00
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
}
}
2023-03-29 15:42:32 -04:00
}
2023-03-28 17:22:57 -04:00
}