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; @@ -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 { @@ -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()));
}
}
}

2
src/engine/objects/AbstractCharacter.java

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

2
src/engine/objects/CharacterSkill.java

@ -258,7 +258,7 @@ public class CharacterSkill extends AbstractGameObject { @@ -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);

16
src/engine/objects/Mob.java

@ -1680,6 +1680,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -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 { @@ -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

Loading…
Cancel
Save