Skip to content

Commit

Permalink
Merge pull request #1 from fenhl/blue-warp-item-override
Browse files Browse the repository at this point in the history
Allow shuffled items on dungeon reward locations
  • Loading branch information
engineer124 authored Jan 29, 2023
2 parents 8325c5a + cbc5fca commit 4edda81
Show file tree
Hide file tree
Showing 11 changed files with 24,620 additions and 24,593 deletions.
864 changes: 432 additions & 432 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
482 changes: 241 additions & 241 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions ASM/c/blue_warp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <stdbool.h>

#include "blue_warp.h"
#include "save.h"
#include "z64.h"

#define TEXT_STATE_CLOSING 2
Expand All @@ -23,7 +26,7 @@ int32_t DoorWarp1_PlayerInRange_Overwrite(z64_actor_t *actor, z64_game_t *game)
// Check vanilla range
if (DoorWarp1_PlayerInRange(actor, game)) {

if (HAS_COLLECTED_DUNGEON_REWARD) {
if (extended_savectx.collected_dungeon_rewards[game->scene_index - 0x0011]) {
return 1;
}

Expand All @@ -37,10 +40,11 @@ int32_t DoorWarp1_PlayerInRange_Overwrite(z64_actor_t *actor, z64_game_t *game)
// Put a dummy item value on the blue warp, which will be overwritten by the medallions* (TODO)
z64_ActorOfferGetItem(actor, game, 0x65, 60.0f, 20.0f);
return 0;
}
}

// Wait until Link closes the textbox displaying the getItem reward
if (z64_MessageGetState(((uint8_t *)(&z64_game)) + 0x20D8) == TEXT_STATE_CLOSING) {
extended_savectx.collected_dungeon_rewards[game->scene_index - 0x0011] = true;
return 1;
}
}
Expand Down
3 changes: 3 additions & 0 deletions ASM/c/save.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <stdbool.h>

#include "z64.h"

// Struct for storing additional data in SRAM. This has to always be a multiple of 2 bytes long supposedly.
typedef struct {
uint8_t silver_rupee_counts[0x16];
bool collected_dungeon_rewards[8];
} extended_savecontext_static_t __attribute__ ((aligned (8)));


Expand Down
50 changes: 20 additions & 30 deletions ItemPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ def get_pool_core(world):
placed_items = {}
remain_shop_items = []
ruto_bottles = 1
num_extra_dungeon_items = 0

if world.settings.zora_fountain == 'open':
ruto_bottles = 0
Expand Down Expand Up @@ -687,26 +686,26 @@ def get_pool_core(world):
# Dungeon Rewards
elif location.type == 'Boss':
if world.settings.shuffle_dungeon_rewards in ('vanilla', 'reward'):
pass #shuffle_item = world.settings.shuffle_dungeon_rewards != 'vanilla'
pass # handled in World.fill_bosses
elif location.name == 'Links Pocket':
#TODO Blue warps currently each give a copy of the Light Medallion in addition to their shuffled item.
# Once this is fixed, shuffle the Light Medallion normally.
shuffle_item = False
else:
#TODO allow any item to be placed on a dungeon reward location, then shuffle normally
placed_items[location.name] = 'Light Medallion'
if location.vanilla_item != 'Light Medallion':
dungeon_name = {
'Kokiri Emerald': 'Deku Tree',
'Goron Ruby': 'Dodongos Cavern',
'Zora Sapphire': 'Jabu Jabus Belly',
'Forest Medallion': 'Forest Temple',
'Fire Medallion': 'Fire Temple',
'Water Medallion': 'Water Temple',
'Shadow Medallion': 'Shadow Temple',
'Spirit Medallion': 'Spirit Temple',
}[location.vanilla_item]
dungeon = [dungeon for dungeon in world.dungeons if dungeon.name == dungeon_name][0]
dungeon.reward.append(ItemFactory(item))
num_extra_dungeon_items += 1
if world.settings.shuffle_dungeon_rewards in ('any_dungeon', 'overworld', 'regional'):
dungeon.reward[-1].priority = True
dungeon_name = {
'Kokiri Emerald': 'Deku Tree',
'Goron Ruby': 'Dodongos Cavern',
'Zora Sapphire': 'Jabu Jabus Belly',
'Forest Medallion': 'Forest Temple',
'Fire Medallion': 'Fire Temple',
'Water Medallion': 'Water Temple',
'Shadow Medallion': 'Shadow Temple',
'Spirit Medallion': 'Spirit Temple',
}[location.vanilla_item]
dungeon = [dungeon for dungeon in world.dungeons if dungeon.name == dungeon_name][0]
dungeon.reward.append(ItemFactory(item))
if world.settings.shuffle_dungeon_rewards in ('any_dungeon', 'overworld', 'regional'):
dungeon.reward[-1].priority = True

# Dungeon Items
elif location.dungeon is not None:
Expand Down Expand Up @@ -860,7 +859,7 @@ def get_pool_core(world):
world.distribution.alter_pool(world, pool)

# Make sure our pending_junk_pool is empty. If not, remove some random junk here.
if pending_junk_pool or num_extra_dungeon_items:
if pending_junk_pool:
for item in set(pending_junk_pool):
# Ensure pending_junk_pool contents don't exceed values given by distribution file
if item in world.distribution.item_pool:
Expand All @@ -886,15 +885,6 @@ def get_pool_core(world):
pool.remove(junk_item)
pool.append(pending_item)

for i in range(num_extra_dungeon_items):
# make room in the item pool for additional dungeon items, which aren't tracked as part of pending_junk_pool
#TODO remove this hack once normal items can be on dungeon reward locations
if not junk_candidates:
raise RuntimeError(f'Not enough junk exists in item pool for {num_extra_dungeon_items - i} dungeon items to be added.')
junk_item = random.choice(junk_candidates)
junk_candidates.remove(junk_item)
pool.remove(junk_item)

if world.settings.item_pool_value == 'ludicrous':
# Replace all junk items with major items
# Overrides plando'd junk items
Expand Down
16 changes: 8 additions & 8 deletions LocationList.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def shop_address(shop_id, shelf_id):
location_table = OrderedDict([
## Dungeon Rewards
("Links Pocket", ("Boss", None, None, None, 'Light Medallion', None)),
("Queen Gohma", ("Boss", None, 0x6C, (0x0CA315F, 0x2079571), 'Kokiri Emerald', None)),
("King Dodongo", ("Boss", None, 0x6D, (0x0CA30DF, 0x2223309), 'Goron Ruby', None)),
("Barinade", ("Boss", None, 0x6E, (0x0CA36EB, 0x2113C19), 'Zora Sapphire', None)),
("Phantom Ganon", ("Boss", None, 0x66, (0x0CA3D07, 0x0D4ED79), 'Forest Medallion', None)),
("Volvagia", ("Boss", None, 0x67, (0x0CA3D93, 0x0D10135), 'Fire Medallion', None)),
("Morpha", ("Boss", None, 0x68, (0x0CA3E1F, 0x0D5A3A9), 'Water Medallion', None)),
("Bongo Bongo", ("Boss", None, 0x6A, (0x0CA3F43, 0x0D13E19), 'Shadow Medallion', None)),
("Twinrova", ("Boss", None, 0x69, (0x0CA3EB3, 0x0D39FF1), 'Spirit Medallion', None)),
("Queen Gohma", ("Boss", 0x11, 0x65, None, 'Kokiri Emerald', None)),
("King Dodongo", ("Boss", 0x12, 0x65, None, 'Goron Ruby', None)),
("Barinade", ("Boss", 0x13, 0x65, None, 'Zora Sapphire', None)),
("Phantom Ganon", ("Boss", 0x14, 0x65, None, 'Forest Medallion', None)),
("Volvagia", ("Boss", 0x15, 0x65, None, 'Fire Medallion', None)),
("Morpha", ("Boss", 0x16, 0x65, None, 'Water Medallion', None)),
("Bongo Bongo", ("Boss", 0x18, 0x65, None, 'Shadow Medallion', None)),
("Twinrova", ("Boss", 0x17, 0x65, None, 'Spirit Medallion', None)),
("Ganon", ("Event", None, None, None, 'Triforce', None)),
("Gift from Sages", ("Cutscene", 0xFF, 0x03, None, None, None)),

Expand Down
15 changes: 14 additions & 1 deletion Patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from HintList import getHint
from Hints import GossipText, HintArea, writeGossipStoneHints, buildAltarHints, \
buildGanonText, buildMiscItemHints, buildMiscLocationHints, getSimpleHintNoPrefix, getItemGenericName
from Item import ItemFactory
from Location import DisableType
from Utils import data_path
from Messages import read_messages, update_message_by_id, read_shop_items, update_warp_song_text, \
Expand Down Expand Up @@ -1996,6 +1997,18 @@ def set_entrance_updates(entrances):
elif location.name == 'Sheik at Colossus':
rom.write_byte(0x218C589, special['text_id']) #Fix text box
elif location.type == 'Boss' and location.name != 'Links Pocket':
locationaddress, secondaryaddress = {
"Queen Gohma": (0x0CA315F, 0x2079571),
"King Dodongo": (0x0CA30DF, 0x2223309),
"Barinade": (0x0CA36EB, 0x2113C19),
"Phantom Ganon": (0x0CA3D07, 0x0D4ED79),
"Volvagia": (0x0CA3D93, 0x0D10135),
"Morpha": (0x0CA3E1F, 0x0D5A3A9),
"Bongo Bongo": (0x0CA3F43, 0x0D13E19),
"Twinrova": (0x0CA3EB3, 0x0D39FF1),
}[location.name]
if world.settings.shuffle_dungeon_rewards not in ('vanilla', 'reward'):
special = ItemFactory('Light Medallion').special #TODO remove entirely
rom.write_byte(locationaddress, special['item_id'])
rom.write_byte(secondaryaddress, special['addr2_data'])
bit_mask_hi = special['bit_mask'] >> 16
Expand Down Expand Up @@ -2541,7 +2554,7 @@ def get_override_entry(location):
else:
looks_like_item_id = 0

if location.type in ('NPC', 'Scrub', 'BossHeart'):
if location.type in ('NPC', 'Scrub', 'BossHeart', 'Boss'):
type = 0
elif location.type == 'Chest':
type = 1
Expand Down
15 changes: 8 additions & 7 deletions SettingsList.py
Original file line number Diff line number Diff line change
Expand Up @@ -2904,13 +2904,14 @@ def __init__(self, name, gui_text, min, max, default, step=1,
reward. In Multiworld, dungeon rewards will only appear
in their own world.
<b>The following options are in early development, and
come with some limitations:</b> The starting dungeon reward
currently can't be shuffled. Dungeon reward locations will
hold a copy of the starting reward. If you receive the last
required medallion for the Burning Kakariko cutscene while
already in Kakariko, the cutscene doesn't play until you
leave and reenter Kakariko (or enter and exit a building).
<b>The following options are still in development, and
come with some limitations:</b> The Light Medallion
currently can't be shuffled because dungeon reward locations
will give a copy of it in addition to their shuffled item.
If you receive the last required medallion for the Burning
Kakariko cutscene while already in Kakariko, the cutscene
doesn't play until you leave and reenter Kakariko (or enter
and exit a building).
'Own Dungeon': Each dungeon reward appears in its respective
dungeon, but not necessarily on the boss. If boss entrances
Expand Down
Loading

0 comments on commit 4edda81

Please sign in to comment.