def _convert_alias_stats(alias_stats_key_1, alias_stats_key_2): r = {} if alias_stats_key_1 is not None: r['when_in_main_hand'] = alias_stats_key_1['Id'] if alias_stats_key_2 is not None: r['when_in_off_hand'] = alias_stats_key_2['Id'] return r def write_stats(data_path, relational_reader, **kwargs): root = {} previous = set() for stat in relational_reader['Stats.dat']: if stat['Id'] in previous: print("Duplicate stat id %s" % stat['Id']) continue root[stat['Id']] = { 'is_local': stat['IsLocal'], 'is_aliased': stat['IsWeaponLocal'], 'alias': _convert_alias_stats(stat['MainHandAlias_StatsKey'], stat['OffHandAlias_StatsKey']), # 'is_on_character_panel': stat['Flag6'], # not sure # 'is_on_tooltip': stat['Flag7'], # not sure } write_json(root, data_path, 'stats') if __name__ == '__main__': call_with_default_args(write_stats)
from RePoE.util import write_json, call_with_default_args def write_crafting_bench_options(data_path, relational_reader, **kwargs): root = [] for row in relational_reader['CraftingBenchOptions.dat']: if row['ModsKey'] is None: continue root.append({ 'mod_id': row['ModsKey']['Id'], 'master_id': row['NPCMasterKey']['Id'], 'master_level': row['MasterLevel'], 'item_classes': [item_class['Id'] for item_class in row['ItemClassesKeys']] }) write_json(root, data_path, 'crafting_bench_options') if __name__ == '__main__': call_with_default_args(write_crafting_bench_options)
# Therefore, each stat_descriptions file is written into a different file (except active_skill_gem_stat_descriptions # because I don't think it is required) WRITTEN_FILES = { ('stat_descriptions.txt', ''), ('chest_stat_descriptions.txt', '/strongbox'), ('gem_stat_descriptions.txt', '/support_gem'), ('skill_stat_descriptions.txt', '/skill'), ('aura_skill_stat_descriptions.txt', '/aura_skill'), ('banner_aura_skill_stat_descriptions.txt', '/banner_aura_skill'), ('beam_skill_stat_descriptions.txt', '/beam_skill'), ('brand_skill_stat_descriptions.txt', '/brand_skill'), ('buff_skill_stat_descriptions.txt', '/buff_skill'), ('curse_skill_stat_descriptions.txt', '/curse_skill'), ('debuff_skill_stat_descriptions.txt', '/debuff_skill'), ('minion_skill_stat_descriptions.txt', '/minion_skill'), ('minion_attack_skill_stat_descriptions.txt', '/minion_attack_skill'), ('minion_spell_skill_stat_descriptions.txt', '/minion_spell_skill'), ('offering_skill_stat_descriptions.txt', '/offering_skill'), ('variable_duration_skill_stat_descriptions.txt', '/variable_duration_skill'), ('map_stat_descriptions.txt', '/areas'), ('atlas_stat_descriptions.txt', '/atlas'), ('passive_skill_stat_descriptions.txt', '/passive_skill'), ('passive_skill_aura_stat_descriptions.txt', '/passive_skill_aura'), ('monster_stat_descriptions.txt', '/monster'), } STAT_TRANSLATION_DICT = {game_file: 'stat_translations' + repoe_file for game_file, repoe_file in WRITTEN_FILES} if __name__ == '__main__': call_with_default_args(write_stat_translations)
'int': gem['Int'] } gems[ge_id], tooltips[ge_id] = converter.convert(gem['BaseItemTypesKey'], granted_effect, gem['GrantedEffectsKey2'], gem['GemTagsKeys'], multipliers) for mod in relational_reader['Mods.dat']: if mod['GrantedEffectsPerLevelKey'] is None: continue if ignore_mod_domain(mod['Domain']): continue granted_effect = mod['GrantedEffectsPerLevelKey']['GrantedEffectsKey'] ge_id = granted_effect['Id'] if ge_id in gems: # mod effects may exist as gems, those are handled above continue gems[ge_id], tooltips[ge_id] = converter.convert(None, granted_effect, None, None, None) for granted_effect in relational_reader['GrantedEffects.dat']: ge_id = granted_effect['Id'] if ge_id != 'PlayerMelee': continue # Default Attack is neither gem nor mod effect gems[ge_id], tooltips[ge_id] = converter.convert(None, granted_effect, None, None, None) write_json(gems, data_path, 'gems') write_json(tooltips, data_path, 'gem_tooltips') if __name__ == '__main__': call_with_default_args(write_gems)
'Belt': 'Belt_ModsKey', 'Body Armour': 'BodyArmour_ModsKey', 'Boots': 'Boots_ModsKey', 'Bow': 'Bow_ModsKey', 'Claw': 'Claw_ModsKey', 'Dagger': 'Dagger_ModsKey', 'Gloves': 'Gloves_ModsKey', 'Helmet': 'Helmet_ModsKey', 'One Hand Axe': 'OneHandAxe_ModsKey', 'One Hand Mace': 'OneHandMace_ModsKey', 'One Hand Sword': 'OneHandSword_ModsKey', 'Quiver': 'Display_Quiver_ModsKey', 'Ring': 'Ring_ModsKey', 'Sceptre': 'Sceptre_ModsKey', 'Shield': 'Shield_ModsKey', 'Staff': 'Staff_ModsKey', 'Thrusting One Hand Sword': 'OneHandThrustingSword_ModsKey', 'Two Hand Axe': 'TwoHandAxe_ModsKey', 'Two Hand Mace': 'TwoHandMace_ModsKey', 'Two Hand Sword': 'TwoHandSword_ModsKey', 'Wand': 'Wand_ModsKey', } return { item_class: row[key]['Id'] for item_class, key in class_to_key.items() if row[key] is not None } if __name__ == '__main__': call_with_default_args(write_essences)
item['ItemClassesKey']['Id'], 'inventory_width': item['Width'], 'inventory_height': item['Height'], 'drop_level': item['DropLevel'], 'implicits': [mod['Id'] for mod in item['Implicit_ModsKeys']], 'tags': [tag['Id'] for tag in item['TagsKeys']] + inherited_tags, 'visual_identity': { 'id': item['ItemVisualIdentityKey']['Id'], 'dds_file': item['ItemVisualIdentityKey']['DDSFile'], }, 'requirements': _convert_requirements(attribute_requirements[item_id], item['DropLevel']), 'properties': properties, 'release_state': get_release_state(item_id).name, 'domain': item['ModDomainsKey'].name.lower(), } _convert_flask_buff(flask_types[item_id], root[item_id]) write_json(root, data_path, 'base_items') if __name__ == '__main__': call_with_default_args(write_base_items)
from RePoE.util import write_json, call_with_default_args def write_characters(data_path, relational_reader, **kwargs): root = [] for row in relational_reader['Characters.dat']: root.append({ 'metadata_id': row['Id'], 'integer_id': row['IntegerId'], 'name': row['Name'], 'base_stats': { 'life': row['BaseMaxLife'], 'mana': row['BaseMaxMana'], 'strength': row['BaseStrength'], 'dexterity': row['BaseDexterity'], 'intelligence': row['BaseIntelligence'], 'unarmed': { 'attack_time': row['WeaponSpeed'], 'min_physical_damage': row['MinDamage'], 'max_physical_damage': row['MaxDamage'], 'range': row['MaxAttackDistance'], }, }, }) write_json(root, data_path, 'characters') if __name__ == '__main__': call_with_default_args(write_characters)
from RePoE.util import write_json, call_with_default_args def write_default_monster_stats(data_path, relational_reader, **kwargs): root = {} for row in relational_reader['DefaultMonsterStats.dat']: root[row['DisplayLevel']] = { 'physical_damage': row['Damage'], 'evasion': row['Evasion'], 'accuracy': row['Accuracy'], 'life': row['Life'], 'ally_life': row['AllyLife'] } write_json(root, data_path, 'default_monster_stats') if __name__ == '__main__': call_with_default_args(write_default_monster_stats)
'domain': domain.name.lower(), 'name': mod['Name'], 'generation_type': mod['GenerationType'].name.lower(), 'group': mod['CorrectGroup'], 'spawn_weights': _convert_spawn_weights(mod['SpawnWeight']), 'generation_weights': _convert_generation_weights(mod['GenerationWeight']), 'grants_buff': _convert_buff(mod['BuffDefinitionsKey'], mod['BuffValue']), 'grants_effect': _convert_granted_effects(mod['GrantedEffectsPerLevelKey']), 'is_essence_only': mod['IsEssenceOnlyModifier'] > 0, 'adds_tags': _convert_tags_keys(mod['TagsKeys']) } if mod['Id'] in root: print("Duplicate mod id:", mod['Id']) else: root[mod['Id']] = obj write_json(root, data_path, 'mods') # a few unique item mods have the wrong mod domain so they wouldn't be added to the file without this MOD_DOMAIN_FIX = { "AreaDamageUniqueBodyDexInt1": MOD_DOMAIN.ITEM, "ElementalResistancePerEnduranceChargeDescentShield1": MOD_DOMAIN.ITEM, "LifeGainOnEndurangeChargeConsumptionUniqueBodyStrInt6": MOD_DOMAIN.ITEM, "ReturningProjectilesUniqueDescentBow1": MOD_DOMAIN.ITEM, } if __name__ == '__main__': call_with_default_args(write_mods)
], "corrupted_essence_chance": row["CorruptedEssenceChance"], "mirrors": row["CanMirrorItem"], "changes_quality": row["CanImproveQuality"], "rolls_lucky": row["HasLuckyRolls"], "enchants": row["CanRollEnchant"], "rolls_white_sockets": row["CanRollWhiteSockets"], "sell_price_mods": [mod['Id'] for mod in row["SellPrice_ModsKeys"]], "descriptions": [ description["Description"] for description in row["DelveCraftingModifierDescriptionsKeys"] ], "blocked_descriptions": [ description["Id"] for description in row["BlockedDelveCraftingModifierDescriptionsKeys"] ] } write_json(root, data_path, 'fossils') if __name__ == '__main__': call_with_default_args(write_fossils)
from RePoE.util import call_with_default_args, write_json def write_tags(data_path, relational_reader, **kwargs): tags = [row['Id'] for row in relational_reader['Tags.dat']] write_json(tags, data_path, 'tags') if __name__ == '__main__': call_with_default_args(write_tags)
from RePoE.util import call_with_default_args, write_json def write_synthesis_implicits(data_path, relational_reader, **kwargs): data = [{ 'stat': { 'id': row['StatsKey']['Id'], 'value': row['StatValue'], }, 'item_classes': [item_class['Id'] for item_class in row['ItemClassesKeys']], 'mods': [mod['Id'] for mod in row['ModsKeys']], } for row in relational_reader['ItemSynthesisMods.dat']] write_json(data, data_path, 'synthesis_implicits') if __name__ == '__main__': call_with_default_args(write_synthesis_implicits)
from RePoE.util import write_json, call_with_default_args def _convert_spawn_weights(tags, weights): r = [] for tag, weight in zip(tags, weights): r.append({ 'tag': tag['Id'], 'weight': weight }) return r def write_npc_master(data_path, relational_reader, **kwargs): root = {} for row in relational_reader['NPCMaster.dat']: root[row['Id']] = { 'signature_mod': { 'id': row['SignatureMod_ModsKey']['Id'], 'spawn_weights': _convert_spawn_weights(row['SignatureModSpawnWeight_TagsKeys'], row['SignatureModSpawnWeight_Values']), }, } write_json(root, data_path, 'npc_master') if __name__ == '__main__': call_with_default_args(write_npc_master)