Build SkillsBase from Skills.cfg
SkillsBase name, description, token (SBStringHash of the name) and attribute weights now come from SkillTemplate._skills. The skill ids stay in static_skill_skillsbase (ID, name), which dyn_character_skill and SkillReq use; the loader joins each row's name to the cfg skill and logs an error for a name with no cfg entry. Both servers load all 63 at boot after Skills.cfg; GET_BASE/GET_BASE_BY_NAME/GET_BASE_BY_TOKEN read the boot caches only. The other 31 cfg skills stay in SkillTemplate. Parity (scripts/p43.py, dev DB): 63/63 names, 63/63 tokens, 63/63 weights. Only value change: description was empty for all 63 in the DB and is now the cfg text (no server reader). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9af6dd30ea
commit
ff52d1d7e5
4 files changed
+58
-48
No files matched your search
@@ -10,8 +10,10 @@
|
||||
package engine.objects;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.mbEnums.AttributeType;
|
||||
import engine.mbEnums.SourceType;
|
||||
import engine.parsers.objects.RuneTemplate;
|
||||
import engine.parsers.objects.wpak.SkillTemplate;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.util.Hasher;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -75,6 +77,20 @@ public class SkillsBase extends AbstractGameObject {
|
||||
this.spiMod = spiMod;
|
||||
}
|
||||
|
||||
public SkillsBase(int skillsBaseID, SkillTemplate template) {
|
||||
super(skillsBaseID);
|
||||
this.name = template.skill_name;
|
||||
this.nameNoSpace = name.replace(" ", "");
|
||||
this.description = template.description;
|
||||
this.sourceType = SourceType.GetSourceType(this.nameNoSpace.replace("-", "").replace("\"", "").replace(",", ""));
|
||||
this.token = Hasher.SBStringHash(this.name);
|
||||
this.strMod = template.attr_weights.getOrDefault(AttributeType.Strength, 0).shortValue();
|
||||
this.dexMod = template.attr_weights.getOrDefault(AttributeType.Dexterity, 0).shortValue();
|
||||
this.conMod = template.attr_weights.getOrDefault(AttributeType.Constitution, 0).shortValue();
|
||||
this.intMod = template.attr_weights.getOrDefault(AttributeType.Intelligence, 0).shortValue();
|
||||
this.spiMod = template.attr_weights.getOrDefault(AttributeType.Spirit, 0).shortValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -107,6 +123,31 @@ public class SkillsBase extends AbstractGameObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Skill ids stay in static_skill_skillsbase (dyn_character_skill and SkillReq use them); everything else is Skills.cfg
|
||||
public static void LoadAllSkillsBase() {
|
||||
|
||||
HashMap<String, SkillTemplate> skillsByName = new HashMap<>();
|
||||
HashMap<Integer, String> skillNames = DbManager.SkillsBaseQueries.GET_ALL_SKILL_NAMES();
|
||||
SkillTemplate template;
|
||||
|
||||
for (SkillTemplate skill : SkillTemplate._skills.values())
|
||||
skillsByName.put(skill.skill_name, skill);
|
||||
|
||||
for (Map.Entry<Integer, String> skillName : skillNames.entrySet()) {
|
||||
|
||||
template = skillsByName.get(skillName.getValue());
|
||||
|
||||
if (template == null) {
|
||||
Logger.error("static_skill_skillsbase " + skillName.getKey() + " '" + skillName.getValue() + "' has no Skills.cfg entry");
|
||||
continue;
|
||||
}
|
||||
|
||||
putInCache(new SkillsBase(skillName.getKey(), template));
|
||||
}
|
||||
|
||||
Logger.info("Loaded " + skillsCache.size() + " skills of " + SkillTemplate._skills.size() + " in Skills.cfg");
|
||||
}
|
||||
|
||||
// Level 0 adjusts are the skills a rune grants outright; higher levels are trainer caps
|
||||
public static void LoadAllRuneSkills() {
|
||||
|
||||
|
||||
Reference in new issue
Block a user