Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions worlds/ff6wc/item_rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def build_ir_from_placements(wc_event_locations: list[Location]) -> list[str]:
if loc.item and loc.item.player == loc.player:
ap_item_id = loc.item.code
if ap_item_id in inventory_item_ap_id_to_name:
wc_item_id = Rom.item_name_id[inventory_item_ap_id_to_name[ap_item_id]]
item_name = inventory_item_ap_id_to_name[ap_item_id]
wc_item_id = Rom.item_name_id[item_name]
items_in_wc_event_locations[loc.name] = wc_item_id

items_in_wc_event_locations_list = sorted(set(items_in_wc_event_locations.values()))
Expand Down Expand Up @@ -109,6 +110,15 @@ def item_qualities() -> Mapping[int, int]:
for item_tier, key in zip(tiers, sort_keys, strict=True):
for wc_id in item_tier:
qualities[wc_id] = key

# Add items not present in chest_item_tiers
if "Cursed Shld" in Rom.item_name_id:
qualities[Rom.item_name_id["Cursed Shld"]] = 1
if "ArchplgoItem" in Rom.item_name_id:
qualities[Rom.item_name_id["ArchplgoItem"]] = 1
if "Empty" in Rom.item_name_id:
qualities[Rom.item_name_id["Empty"]] = 10

return qualities


Expand All @@ -126,14 +136,17 @@ def limit_event_items(wc_event_locations: list[Location], random: Random) -> Non
if loc.item and loc.item.player == loc.player:
ap_item_id = loc.item.code
if ap_item_id in inventory_item_ap_id_to_name:
wc_item_id = Rom.item_name_id[inventory_item_ap_id_to_name[ap_item_id]]
item_name = inventory_item_ap_id_to_name[ap_item_id]
if item_name == "Empty":
continue
Comment on lines +140 to +141

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "Empty" is in an event location, doesn't that still need a dialog?
The game displays a dialog when you do the event, doesn't it?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like we still want to process the "Empty"s.
The only problem was "Empty" not being in the qualities

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed - fixed in next commit

wc_item_id = Rom.item_name_id[item_name]
items_in_wc_event_locations[loc.name] = wc_item_id
locations_by_name[loc.name] = loc

qualities = item_qualities()

def sort_key(wc_item_id: int) -> int:
return qualities[wc_item_id]
return qualities.get(wc_item_id, 10)

items_by_quality = sorted(set(items_in_wc_event_locations.values()), key=sort_key)

Expand All @@ -144,14 +157,15 @@ def sort_key(wc_item_id: int) -> int:

# print(f"{[Rom.item_id_name_weight[i_id][0] for i_id in smaller_set]=}")

for loc_name, loc in locations_by_name.items():
wc_item_id = items_in_wc_event_locations[loc_name]
if wc_item_id not in smaller_set:
replacement = random.choice(smaller_set)
replacement_name = Rom.item_id_name_weight[replacement][0]
replacement_code = item_name_to_id[replacement_name]
assert loc.item, f"{loc=}"
loc.item.name = replacement_name
loc.item.code = replacement_code
loc.item.classification = ItemClassification.useful
loc.locked = True
if smaller_set:
for loc_name, loc in locations_by_name.items():
wc_item_id = items_in_wc_event_locations[loc_name]
if wc_item_id not in smaller_set:
replacement = random.choice(smaller_set)
replacement_name = Rom.item_id_name_weight[replacement][0]
replacement_code = item_name_to_id[replacement_name]
assert loc.item, f"{loc=}"
loc.item.name = replacement_name
loc.item.code = replacement_code
loc.item.classification = ItemClassification.useful
loc.locked = True
Loading