Browse Source

rune skill loading broken into static method in NPCManager

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
ee6efc30a3
  1. 18
      src/engine/gameManager/NPCManager.java
  2. 2
      src/engine/objects/AbstractCharacter.java
  3. 2
      src/engine/objects/CharacterSkill.java
  4. 16
      src/engine/objects/Mob.java

18
src/engine/gameManager/NPCManager.java

@ -10,6 +10,7 @@ import engine.net.DispatchMessage;
import engine.net.client.msg.PetMsg; import engine.net.client.msg.PetMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.RuneSkillAdjustEntry;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
@ -405,4 +406,21 @@ public enum NPCManager {
if(baseSkill != null) if(baseSkill != null)
mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount())); 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()));
}
}
} }

2
src/engine/objects/AbstractCharacter.java

@ -71,7 +71,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public Guild guild; public Guild guild;
protected byte runningTrains; protected byte runningTrains;
protected ConcurrentHashMap<Integer, CharacterPower> powers; protected ConcurrentHashMap<Integer, CharacterPower> powers;
protected ConcurrentHashMap<String, CharacterSkill> skills; public ConcurrentHashMap<String, CharacterSkill> skills;
// Variables NOT to be stored in db // Variables NOT to be stored in db
protected boolean sit = false; protected boolean sit = false;
protected boolean walkMode; protected boolean walkMode;

2
src/engine/objects/CharacterSkill.java

@ -258,7 +258,7 @@ public class CharacterSkill extends AbstractGameObject {
this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken()); this.skillType = CharacterSkills.GetCharacterSkillByToken(this.skillsBase.getToken());
} }
public CharacterSkill(SkillsBase sb, Mob mob, int trains) { public CharacterSkill(SkillsBase sb, AbstractCharacter mob, int trains) {
super(); super();
this.skillsBase = sb; this.skillsBase = sb;
this.numTrains.set(trains); this.numTrains.set(trains);

16
src/engine/objects/Mob.java

@ -1680,6 +1680,7 @@ public class Mob extends AbstractIntelligenceAgent {
NPCManager.applyMobbaseEffects(this); NPCManager.applyMobbaseEffects(this);
NPCManager.applyEquipmentResists(this); NPCManager.applyEquipmentResists(this);
NPCManager.applyMobbaseSkill(this); NPCManager.applyMobbaseSkill(this);
NPCManager.applyRuneSkills(this,this.getMobBaseID());
this.recalculateStats(); this.recalculateStats();
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
@ -1705,21 +1706,6 @@ public class Mob extends AbstractIntelligenceAgent {
} }
this.deathTime = 0; 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 @Override

Loading…
Cancel
Save