-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Labels
Description
Currently, in the proficiency system, the spell cooldown reduction perk doesn't work. I tried fixing it using the current server-side format (.json) and couldn't.
But honestly, I'm not good with code; I only do it as a hobby KEKW
The only way I managed to get the cooldown reduction perk working was by converting the system from .json to .xml, so I'm opening this issue to see if anyone has any ideas on how to fix the problem while keeping the current .json system. I confess I tried a few things and couldn't get it to work.
Here's the PR I closed previously:
PR#537
Note: the conversion from proficiencies.json to proficiencies.xml is done by a Python script
Script
import json
import xml.etree.ElementTree as ET
from xml.dom import minidom
# Type Mapping (Numbers -> Readable Strings)
PERK_TYPES = {
0: "attackDamage",
1: "defense",
2: "shieldMod",
3: "skillBonus",
4: "specialMagicLevel",
5: "augment",
6: "bestiaryDamage",
7: "damageBoss",
8: "critChance",
9: "critChanceSpell",
10: "critChanceRune",
11: "critChanceAuto",
12: "critExtraDamage",
13: "critExtraDamageSpell",
14: "critExtraDamageRune",
15: "critExtraDamageAuto",
16: "manaLeech",
17: "lifeLeech",
18: "manaOnHit",
19: "lifeOnHit",
20: "manaOnKill",
21: "lifeOnKill",
22: "damageAtRange",
23: "rangedHitChance",
24: "attackRange",
25: "skillDamageAuto",
26: "skillDamageSpell",
27: "skillHealingSpell"
}
# Skills Mapping
SKILLS = {
1: "magic",
6: "shield",
7: "distance",
8: "sword",
9: "club",
10: "axe",
11: "fist",
13: "fishing"
}
# Elements and Damage Types Mapping
DAMAGE_TYPES = {
8: "fire",
16: "earth",
32: "energy",
64: "ice",
128: "holy",
256: "death",
1048576: "healing"
}
# Augments Mapping
AUGMENT_TYPES = {
2: "baseDamage",
3: "healing",
6: "cooldown",
9: "increasedDamage",
14: "lifeLeech",
15: "manaLeech",
16: "critExtraDamage",
17: "critChance"
}
def load_json(filename):
try:
with open(filename, 'r', encoding='utf-8') as f:
return json.load(f)
except FileNotFoundError:
print(f"Error: File '{filename}' not found.")
return []
except json.JSONDecodeError as e:
print(f"Error reading JSON: {e}")
return []
def create_xml(data):
root = ET.Element("proficiencies")
for entry in data:
# Create <proficiency> tag
prof_id = str(entry.get("ProficiencyId", 0))
name = entry.get("Name", "Unknown")
prof_node = ET.SubElement(root, "proficiency")
prof_node.set("id", prof_id)
prof_node.set("name", name)
levels = entry.get("Levels", [])
# Loop through Levels (index + 1 to generate level ID)
for idx, level_data in enumerate(levels):
level_id = str(idx + 1)
level_node = ET.SubElement(prof_node, "level")
level_node.set("id", level_id)
perks = level_data.get("Perks", [])
# Loop through Perks within Level
for perk in perks:
perk_node = ET.SubElement(level_node, "perk")
# Perk Type
raw_type = perk.get("Type")
type_str = PERK_TYPES.get(raw_type, str(raw_type))
perk_node.set("type", type_str)
# Perk Value - COOLDOWN FIX
value = perk.get("Value", 0)
# If augment is cooldown and value is negative, convert to positive
if "AugmentType" in perk and perk["AugmentType"] == 6 and value < 0:
value = abs(value)
perk_node.set("value", str(value))
# Conditional Attributes (Skill, Element, Augment, etc)
# Skill
if "SkillId" in perk:
skill_id = perk["SkillId"]
perk_node.set("skill", SKILLS.get(skill_id, str(skill_id)))
# ElementId -> convert to 'element' attribute
if "ElementId" in perk:
elem_id = perk["ElementId"]
perk_node.set("element", DAMAGE_TYPES.get(elem_id, str(elem_id)))
# DamageType -> convert to 'damageType' attribute
if "DamageType" in perk:
dmg_id = perk["DamageType"]
perk_node.set("damageType", DAMAGE_TYPES.get(dmg_id, str(dmg_id)))
# AugmentType
if "AugmentType" in perk:
aug_id = perk["AugmentType"]
perk_node.set("augment", AUGMENT_TYPES.get(aug_id, str(aug_id)))
# Direct fields (no enum conversion)
if "SpellId" in perk:
perk_node.set("spellId", str(perk["SpellId"]))
if "Range" in perk:
perk_node.set("range", str(perk["Range"]))
if "BestiaryId" in perk:
perk_node.set("bestiaryId", str(perk["BestiaryId"]))
return root
def save_xml(root, filename):
# Pretty Print formatting
xml_str = ET.tostring(root, encoding='utf-8')
parsed = minidom.parseString(xml_str)
pretty_xml = parsed.toprettyxml(indent=" ")
with open(filename, "w", encoding='utf-8') as f:
f.write(pretty_xml)
print(f"Success! File '{filename}' generated.")
if __name__ == "__main__":
input_file = "proficiencies.json"
output_file = "proficiencies.xml"
print("Reading JSON...")
json_data = load_json(input_file)
if json_data:
print(f"Processing {len(json_data)} items...")
xml_root = create_xml(json_data)
print("Saving XML...")
save_xml(xml_root, output_file)
Reactions are currently unavailable