From ee6efc30a34505657bc84771770171da7a7c334f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 3 Sep 2023 19:52:16 -0500 Subject: [PATCH] rune skill loading broken into static method in NPCManager --- src/engine/gameManager/NPCManager.java | 18 ++++++++++++++++++ src/engine/objects/AbstractCharacter.java | 2 +- src/engine/objects/CharacterSkill.java | 2 +- src/engine/objects/Mob.java | 16 +--------------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 4ece92d9..a6d473b8 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -10,6 +10,7 @@ import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.objects.*; import engine.powers.EffectsBase; +import engine.powers.RuneSkillAdjustEntry; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -405,4 +406,21 @@ public enum NPCManager { if(baseSkill != null) mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount())); } + + public static void applyRuneSkills(AbstractCharacter character,int runeID){ + //load mob skill adjustments from mobbase rune + if(PowersManager._allRuneSkillAdjusts.containsKey(runeID)) + for(RuneSkillAdjustEntry entry : PowersManager._allRuneSkillAdjusts.get(runeID)) { + if(SkillsBase.getFromCache(entry.skill_type) == null) + SkillsBase.putInCache(DbManager.SkillsBaseQueries.GET_BASE_BY_NAME(entry.skill_type)); + SkillsBase skillBase = SkillsBase.getFromCache(entry.skill_type); + if(skillBase == null) + continue; + if (entry.level <= character.level) + if (character.skills.containsKey(entry.name) == false) + character.skills.put(entry.skill_type, new CharacterSkill(skillBase, character, entry.rank)); + else + character.skills.put(entry.skill_type, new CharacterSkill(skillBase, character, entry.rank + character.skills.get(entry.skill_type).getNumTrains())); + } + } } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 7b35aa31..c14dcd58 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -71,7 +71,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public Guild guild; protected byte runningTrains; protected ConcurrentHashMap powers; - protected ConcurrentHashMap skills; + public ConcurrentHashMap skills; // Variables NOT to be stored in db protected boolean sit = false; protected boolean walkMode; diff --git a/src/engine/objects/CharacterSkill.java b/src/engine/objects/CharacterSkill.java index a4cb9588..aacebba7 100644 --- a/src/engine/objects/CharacterSkill.java +++ b/src/engine/objects/CharacterSkill.java @@ -258,7 +258,7 @@ public class CharacterSkill extends AbstractGameObject { this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken()); } - public CharacterSkill(SkillsBase sb, Mob mob, int trains) { + public CharacterSkill(SkillsBase sb, AbstractCharacter mob, int trains) { super(); this.skillsBase = sb; this.numTrains.set(trains); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 749b4568..8fc7ee28 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1680,6 +1680,7 @@ public class Mob extends AbstractIntelligenceAgent { NPCManager.applyMobbaseEffects(this); NPCManager.applyEquipmentResists(this); NPCManager.applyMobbaseSkill(this); + NPCManager.applyRuneSkills(this,this.getMobBaseID()); this.recalculateStats(); this.setHealth(this.healthMax); @@ -1705,21 +1706,6 @@ public class Mob extends AbstractIntelligenceAgent { } this.deathTime = 0; - - //load mob skill adjustments form mobbase rune - if(PowersManager._allRuneSkillAdjusts.containsKey(this.getMobBaseID())) - for(RuneSkillAdjustEntry entry : PowersManager._allRuneSkillAdjusts.get(this.getMobBaseID())) { - if(SkillsBase.getFromCache(entry.skill_type) == null) - SkillsBase.putInCache(DbManager.SkillsBaseQueries.GET_BASE_BY_NAME(entry.skill_type)); - SkillsBase skillBase = SkillsBase.getFromCache(entry.skill_type); - if(skillBase == null) - continue; - if (entry.level <= this.level) - if (this.skills.containsKey(entry.name) == false) - this.skills.put(entry.skill_type, new CharacterSkill(skillBase, this, entry.rank)); - else - this.skills.put(entry.skill_type, new CharacterSkill(skillBase, this, entry.rank + this.skills.get(entry.skill_type).getNumTrains())); - } } @Override