Skip to content

Commit

Permalink
Use simple text box for unshuffled dungeon rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
fenhl committed Jun 25, 2024
1 parent 08d32da commit 61bfb08
Show file tree
Hide file tree
Showing 10 changed files with 34,887 additions and 34,815 deletions.
2,074 changes: 1,038 additions & 1,036 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
1,273 changes: 637 additions & 636 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion ASM/c/blue_warp.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include <stdbool.h>

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

#define TEXT_STATE_CLOSING 2

extern uint8_t PLAYER_ID;
extern uint8_t PLAYER_NAME_ID;
extern bool REWARDS_AS_ITEMS;

// Original function copied over
int32_t DoorWarp1_PlayerInRange(z64_actor_t* actor, z64_game_t* game) {
if (actor->xzdist_from_link < 60.0f) {
Expand All @@ -24,7 +29,17 @@ int32_t DoorWarp1_PlayerInRange_Overwrite(z64_actor_t* actor, z64_game_t* game)
uint8_t boss_idx = game->scene_index - 0x0011;
// queue the item if not already collected
if (!extended_savectx.collected_dungeon_rewards[boss_idx]) {
push_delayed_item(0x05 + boss_idx);
if (REWARDS_AS_ITEMS) {
push_delayed_item(0x05 + boss_idx);
} else {
override_key_t override_key = { .scene = 0xFF, .type = OVR_DELAYED, .flag = 0x05 + boss_idx };
override_t override = lookup_override_by_key(override_key);
uint16_t resolved_item_id = resolve_upgrades(override);
item_row_t* item_row = get_item_row(resolved_item_id);
call_effect_function(item_row);
PLAYER_NAME_ID = override.value.base.player;
z64_DisplayTextbox(&z64_game, resolve_item_text_id(item_row, PLAYER_NAME_ID != PLAYER_ID), 0);
}
extended_savectx.collected_dungeon_rewards[boss_idx] = true;
}
// immediately activate the blue warp. Queued item will be given after the warp
Expand Down
2 changes: 2 additions & 0 deletions ASM/src/config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ CFG_DUNGEON_REWARD_WORLDS:
.align 4
CFG_BIGOCTO_OVERRIDE_KEY:
.word 0
REWARDS_AS_ITEMS:
.byte 0x00
.align 4

; These configuration values are given fixed addresses to aid auto-trackers.
Expand Down
21 changes: 13 additions & 8 deletions Patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
build_ganon_text, build_misc_item_hints, build_misc_location_hints, get_simple_hint_no_prefix, get_item_generic_name
from Item import Item
from ItemList import REWARD_COLORS
from ItemPool import song_list, trade_items, child_trade_items
from ItemPool import reward_list, song_list, trade_items, child_trade_items
from Location import Location, DisableType
from LocationList import business_scrubs
from Messages import read_messages, update_message_by_id, read_shop_items, update_warp_song_text, \
Expand Down Expand Up @@ -425,23 +425,28 @@ def make_bytes(txt: str, size: int) -> list[int]:
rom.write_bytes(0xCD5E76, [0x0E, 0xDC])
rom.write_bytes(0xCD5E12, [0x0E, 0xDC])

# songs as items flag
# Some types of locations (boss rewards, songs, and the fairy ocarina) have special behavior,
# but need to use the normal Get Item mechanism if shuffled into the main item pool.
rewards_as_items = (
world.settings.shuffle_dungeon_rewards not in ('vanilla', 'reward')
or world.distribution.rewards_as_items
or any(name in reward_list and record.count for name, record in world.settings.starting_items.items())
)
if rewards_as_items:
rom.write_byte(rom.sym('REWARDS_AS_ITEMS'), 1)
songs_as_items = (
world.settings.shuffle_song_items != 'song'
or world.distribution.song_as_items
or world.distribution.songs_as_items
or any(name in song_list and record.count for name, record in world.settings.starting_items.items())
or world.settings.shuffle_individual_ocarina_notes
)

if songs_as_items:
rom.write_byte(rom.sym('SONGS_AS_ITEMS'), 1)
if world.settings.shuffle_ocarinas:
rom.write_byte(rom.sym('OCARINAS_SHUFFLED'), 0x01)

patch_cutscenes(rom, songs_as_items)

if world.settings.shuffle_ocarinas:
symbol = rom.sym('OCARINAS_SHUFFLED')
rom.write_byte(symbol, 0x01)

# Speed Pushing of All Pushable Objects (other than armos statues, which are handled in ASM)
rom.write_bytes(0xDD2B86, [0x40, 0x80]) # block speed
rom.write_bytes(0xDD2D26, [0x00, 0x01]) # block delay
Expand Down
11 changes: 8 additions & 3 deletions Plandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ def __init__(self, distribution: Distribution, id: int, src_dict: Optional[dict[
self.id: int = id
self.base_pool: list[str] = []
self.major_group: list[str] = []
self.song_as_items: bool = False
self.rewards_as_items: bool = False
self.songs_as_items: bool = False
self.skipped_locations: list[Location] = []
self.effective_starting_items: dict[str, StarterRecord] = {}

Expand Down Expand Up @@ -607,8 +608,10 @@ def alter_pool(self, world: World, pool: list[str]) -> list[str]:
self.pool_remove_item([pool], item_name, record.count)
except KeyError:
pass
if item_name in item_groups["DungeonReward"]:
self.rewards_as_items = True
if item_name in item_groups["Song"]:
self.song_as_items = True
self.songs_as_items = True

junk_to_add = pool_size - len(pool)
if junk_to_add > 0:
Expand Down Expand Up @@ -907,8 +910,10 @@ def fill(self, worlds: list[World], location_pools: list[list[Location]], item_p

item = self.get_item(ignore_pools, item_pools, location, player_id, record, worlds)

if location.type == 'Boss' and location.name != 'ToT Reward from Rauru' and item.type != 'DungeonReward':
self.rewards_as_items = True
if location.type == 'Song' and item.type != 'Song':
self.song_as_items = True
self.songs_as_items = True
location.world.push_item(location, item, True)

if item.advancement:
Expand Down
2 changes: 1 addition & 1 deletion Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def set_rules(world: World) -> None:
if location.type == 'Song':
# allow junk items, but songs must still have matching world
add_item_rule(location, lambda location, item:
((location.world.distribution.song_as_items or any(name in song_list and record.count for name, record in world.settings.starting_items.items()))
((location.world.distribution.songs_as_items or any(name in song_list and record.count for name, record in world.settings.starting_items.items()))
and item.type != 'Song')
or (item.type == 'Song' and item.world.id == location.world.id))
else:
Expand Down
Loading

0 comments on commit 61bfb08

Please sign in to comment.