From f2eb6060380cc66ad091cce71be10fbdc4b65437 Mon Sep 17 00:00:00 2001 From: Marechal-l Date: Sat, 22 Oct 2022 23:51:48 +0200 Subject: [PATCH] DS3: Set required client version to 0.3.6 and added offsets between items and location tables for backward compatibility --- worlds/dark_souls_3/Items.py | 19 +++++++++++++++ worlds/dark_souls_3/Locations.py | 19 +++++++++++++++ worlds/dark_souls_3/__init__.py | 27 +++++++++------------- worlds/dark_souls_3/data/items_data.py | 4 +++- worlds/dark_souls_3/data/locations_data.py | 13 +++++++---- 5 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 worlds/dark_souls_3/Items.py create mode 100644 worlds/dark_souls_3/Locations.py diff --git a/worlds/dark_souls_3/Items.py b/worlds/dark_souls_3/Items.py new file mode 100644 index 0000000000..2ad3199451 --- /dev/null +++ b/worlds/dark_souls_3/Items.py @@ -0,0 +1,19 @@ +from BaseClasses import Item +from worlds.dark_souls_3.data.items_data import item_tables + + +class DarkSouls3Item(Item): + game: str = "Dark Souls III" + + @staticmethod + def get_name_to_id() -> dict: + base_id = 100000 + table_offset = 100 + + output = {} + i = 0 + for table in item_tables: + output |= {name: id for id, name in enumerate(table, base_id + (table_offset * i))} + i += 1 + + return output diff --git a/worlds/dark_souls_3/Locations.py b/worlds/dark_souls_3/Locations.py new file mode 100644 index 0000000000..7eb842c4d2 --- /dev/null +++ b/worlds/dark_souls_3/Locations.py @@ -0,0 +1,19 @@ +from BaseClasses import Location +from worlds.dark_souls_3.data.locations_data import location_tables + + +class DarkSouls3Location(Location): + game: str = "Dark Souls III" + + @staticmethod + def get_name_to_id() -> dict: + base_id = 100000 + table_offset = 100 + + output = {} + i = 0 + for table in location_tables: + output |= {name: id for id, name in enumerate(table, base_id + (table_offset * i))} + i += 1 + + return output diff --git a/worlds/dark_souls_3/__init__.py b/worlds/dark_souls_3/__init__.py index 8d58de1221..c56e6752dc 100644 --- a/worlds/dark_souls_3/__init__.py +++ b/worlds/dark_souls_3/__init__.py @@ -2,9 +2,11 @@ import json import os +from .Items import DarkSouls3Item +from .Locations import DarkSouls3Location from .Options import dark_souls_options -from .data.items_data import weapons_upgrade_5_table, weapons_upgrade_10_table, item_dictionary_table, key_items_list -from .data.locations_data import location_dictionary_table, cemetery_of_ash_table, fire_link_shrine_table, \ +from .data.items_data import weapons_upgrade_5_table, weapons_upgrade_10_table, item_dictionary, key_items_list +from .data.locations_data import location_dictionary, cemetery_of_ash_table, fire_link_shrine_table, \ high_wall_of_lothric, \ undead_settlement_table, road_of_sacrifice_table, consumed_king_garden_table, cathedral_of_the_deep_table, \ farron_keep_table, catacombs_of_carthus_table, smouldering_lake_table, irithyll_of_the_boreal_valley_table, \ @@ -53,8 +55,9 @@ class DarkSouls3World(World): web = DarkSouls3Web() data_version = 3 base_id = 100000 - item_name_to_id = {name: id for id, name in enumerate(item_dictionary_table, base_id)} - location_name_to_id = {name: id for id, name in enumerate(location_dictionary_table, base_id)} + required_client_version = (0, 3, 6) + item_name_to_id = DarkSouls3Item.get_name_to_id() + location_name_to_id = DarkSouls3Location.get_name_to_id() def __init__(self, world: MultiWorld, player: int): super().__init__(world, player) @@ -239,18 +242,18 @@ class DarkSouls3World(World): def generate_output(self, output_directory: str): # Depending on the specified option, modify items hexadecimal value to add an upgrade level - item_dictionary = item_dictionary_table.copy() + item_dictionary_copy = item_dictionary.copy() if self.world.randomize_weapons_level[self.player]: # Randomize some weapons upgrades for name in weapons_upgrade_5_table.keys(): if self.world.random.randint(0, 100) < 33: value = self.world.random.randint(1, 5) - item_dictionary[name] += value + item_dictionary_copy[name] += value for name in weapons_upgrade_10_table.keys(): if self.world.random.randint(0, 100) < 33: value = self.world.random.randint(1, 10) - item_dictionary[name] += value + item_dictionary_copy[name] += value # Create the mandatory lists to generate the player's output file items_id = [] @@ -264,7 +267,7 @@ class DarkSouls3World(World): items_address.append(item_dictionary[location.item.name]) if location.player == self.player: - locations_address.append(location_dictionary_table[location.name]) + locations_address.append(location_dictionary[location.name]) locations_id.append(location.address) if location.item.player == self.player: locations_target.append(item_dictionary[location.item.name]) @@ -291,11 +294,3 @@ class DarkSouls3World(World): filename = f"AP-{self.world.seed_name}-P{self.player}-{self.world.player_name[self.player]}.json" with open(os.path.join(output_directory, filename), 'w') as outfile: json.dump(data, outfile) - - -class DarkSouls3Location(Location): - game: str = "Dark Souls III" - - -class DarkSouls3Item(Item): - game: str = "Dark Souls III" diff --git a/worlds/dark_souls_3/data/items_data.py b/worlds/dark_souls_3/data/items_data.py index f155558c1f..e951b674fe 100644 --- a/worlds/dark_souls_3/data/items_data.py +++ b/worlds/dark_souls_3/data/items_data.py @@ -391,4 +391,6 @@ key_items_list = { "Jailer's Key Ring", } -item_dictionary_table = {**weapons_upgrade_5_table, **weapons_upgrade_10_table, **shields_table, **armor_table, **rings_table, **spells_table, **misc_items_table, **goods_table} +item_tables = [weapons_upgrade_5_table, weapons_upgrade_10_table, shields_table, armor_table, rings_table, spells_table, misc_items_table, goods_table] + +item_dictionary = {**weapons_upgrade_5_table, **weapons_upgrade_10_table, **shields_table, **armor_table, **rings_table, **spells_table, **misc_items_table, **goods_table} diff --git a/worlds/dark_souls_3/data/locations_data.py b/worlds/dark_souls_3/data/locations_data.py index 94a3c4ea81..7230bb795d 100644 --- a/worlds/dark_souls_3/data/locations_data.py +++ b/worlds/dark_souls_3/data/locations_data.py @@ -440,7 +440,12 @@ archdragon_peak_table = { "AP: Havel's Greatshield": 0x013376F0, } -location_dictionary_table = {**cemetery_of_ash_table, **fire_link_shrine_table, **firelink_shrine_bell_tower_table, **high_wall_of_lothric, **undead_settlement_table, **road_of_sacrifice_table, - **cathedral_of_the_deep_table, **farron_keep_table, **catacombs_of_carthus_table, **smouldering_lake_table, **irithyll_of_the_boreal_valley_table, - **irithyll_dungeon_table, **profaned_capital_table, **anor_londo_table, **lothric_castle_table, **consumed_king_garden_table, - **grand_archives_table, **untended_graves_table, **archdragon_peak_table} +location_tables = [cemetery_of_ash_table, fire_link_shrine_table, firelink_shrine_bell_tower_table, high_wall_of_lothric, undead_settlement_table, road_of_sacrifice_table, + cathedral_of_the_deep_table, farron_keep_table, catacombs_of_carthus_table, smouldering_lake_table, irithyll_of_the_boreal_valley_table, + irithyll_dungeon_table, profaned_capital_table, anor_londo_table, lothric_castle_table, consumed_king_garden_table, + grand_archives_table, untended_graves_table, archdragon_peak_table] + +location_dictionary = {**cemetery_of_ash_table, **fire_link_shrine_table, **firelink_shrine_bell_tower_table, **high_wall_of_lothric, **undead_settlement_table, **road_of_sacrifice_table, + **cathedral_of_the_deep_table, **farron_keep_table, **catacombs_of_carthus_table, **smouldering_lake_table, **irithyll_of_the_boreal_valley_table, + **irithyll_dungeon_table, **profaned_capital_table, **anor_londo_table, **lothric_castle_table, **consumed_king_garden_table, + **grand_archives_table, **untended_graves_table, **archdragon_peak_table}