Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include key total in item get text box #1841

Merged
Merged
Show file tree
Hide file tree
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
845 changes: 423 additions & 422 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
391 changes: 196 additions & 195 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions ASM/c/get_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ void activate_override(override_t override) {
item_row_t *item_row = get_item_row(resolved_item_id);

active_override = override;
if (resolved_item_id == 0xCA)
if (resolved_item_id == 0xCA) {
active_override_is_outgoing = 2; // Send to everyone
else
} else {
active_override_is_outgoing = override.value.player != PLAYER_ID;
}
active_item_row = item_row;
active_item_action_id = item_row->action_id;
active_item_text_id = item_row->text_id;
active_item_text_id = resolve_item_text_id(resolved_item_id, active_override_is_outgoing);
active_item_object_id = item_row->object_id;
active_item_graphic_id = item_row->graphic_id;
if (override.value.looks_like_item_id) {
Expand Down Expand Up @@ -771,7 +772,7 @@ uint8_t item_give_collectible(uint8_t item, z64_link_t *link, z64_actor_t *from_
// draw message box and play get item sound (like when a skull is picked up)
z64_Audio_PlayFanFare(NA_BGM_SMALL_ITEM_GET);

z64_DisplayTextbox(&z64_game, item_row->text_id, 0);
z64_DisplayTextbox(&z64_game, resolve_item_text_id(resolved_item_id, player != PLAYER_ID), 0);

// Set up
pItem->timeToLive = 15; // unk_15A is a frame timer that is decremented each frame by the main actor code.
Expand Down Expand Up @@ -805,7 +806,7 @@ void get_skulltula_token(z64_actor_t *token_actor) {
token_actor->draw_proc = NULL;

PLAYER_NAME_ID = player;
z64_DisplayTextbox(&z64_game, item_row->text_id, 0);
z64_DisplayTextbox(&z64_game, resolve_item_text_id(resolved_item_id, player != PLAYER_ID), 0);
dispatch_item(resolved_item_id, player, &override, item_row);
}

Expand Down
12 changes: 8 additions & 4 deletions ASM/c/item_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,22 @@ void give_small_key(z64_file_t *save, int16_t dungeon_id, int16_t arg2) {
save->dungeon_keys[dungeon_id] = current_keys + 1;
uint32_t flag = save->scene_flags[dungeon_id].unk_00_;
int8_t total_keys = flag >> 0x10;
save->scene_flags[dungeon_id].unk_00_ = (flag & 0x0000ffff) | ((total_keys + 1) << 0x10);
int8_t max_keys = key_counts[dungeon_id][CFG_DUNGEON_IS_MQ[dungeon_id]];
if (total_keys < max_keys) {
save->scene_flags[dungeon_id].unk_00_ = (flag & 0x0000ffff) | ((total_keys + 1) << 0x10);
}
}

uint8_t KEYRING_BOSSKEY_CONDITION = 0;
void give_small_key_ring(z64_file_t *save, int16_t dungeon_id, int16_t arg2) {
int8_t current_keys = save->dungeon_keys[dungeon_id] > 0 ? save->dungeon_keys[dungeon_id] : 0;
save->dungeon_keys[dungeon_id] = current_keys + key_counts[dungeon_id][CFG_DUNGEON_IS_MQ[dungeon_id]];
if (KEYRING_BOSSKEY_CONDITION && dungeon_id > 2 && dungeon_id < 8)
if (KEYRING_BOSSKEY_CONDITION && dungeon_id > 2 && dungeon_id < 8) {
save->dungeon_items[dungeon_id].boss_key = 1;
}
uint32_t flag = save->scene_flags[dungeon_id].unk_00_;
int8_t total_keys = flag >> 0x10;
save->scene_flags[dungeon_id].unk_00_ = (flag & 0x0000ffff) | ((total_keys + key_counts[dungeon_id][CFG_DUNGEON_IS_MQ[dungeon_id]]) << 0x10);
int8_t max_keys = key_counts[dungeon_id][CFG_DUNGEON_IS_MQ[dungeon_id]];
save->scene_flags[dungeon_id].unk_00_ = (flag & 0x0000ffff) | (max_keys << 0x10);
}

void give_defense(z64_file_t *save, int16_t arg1, int16_t arg2) {
Expand Down
26 changes: 17 additions & 9 deletions ASM/c/item_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ item_row_t item_table[] = {
[0xAD] = ITEM_ROW(0x53, BROWN_CHEST, 0x41, -1, 0x00A5, 0x00C8, 0x1C, no_upgrade, give_dungeon_item, 0x04, BOTW_ID ), // Bottom of the Well Map
[0xAE] = ITEM_ROW(0x53, BROWN_CHEST, 0x41, -1, 0x0092, 0x00C8, 0x1C, no_upgrade, give_dungeon_item, 0x04, ICE_ID ), // Ice Cavern Map

[0xAF] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x0093, 0x00AA, 0x02, no_upgrade, give_small_key, FOREST_ID, -1), // Forest Temple Small Key
[0xB0] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x0094, 0x00AA, 0x02, no_upgrade, give_small_key, FIRE_ID, -1), // Fire Temple Small Key
[0xB1] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x0095, 0x00AA, 0x02, no_upgrade, give_small_key, WATER_ID, -1), // Water Temple Small Key
[0xB2] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00A6, 0x00AA, 0x02, no_upgrade, give_small_key, SPIRIT_ID, -1), // Spirit Temple Small Key
[0xB3] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00A9, 0x00AA, 0x02, no_upgrade, give_small_key, SHADOW_ID, -1), // Shadow Temple Small Key
[0xB4] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x009B, 0x00AA, 0x02, no_upgrade, give_small_key, BOTW_ID, -1), // Bottom of the Well Small Key
[0xB5] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x009F, 0x00AA, 0x02, no_upgrade, give_small_key, GTG_ID, -1), // Gerudo Training Small Key
[0xB6] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00A0, 0x00AA, 0x02, no_upgrade, give_small_key, FORT_ID, -1), // Gerudo Fortress Small Key
[0xB7] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00A1, 0x00AA, 0x02, no_upgrade, give_small_key, CASTLE_ID, -1), // Ganon's Castle Small Key
[0xAF] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9101, 0x00AA, 0x02, no_upgrade, give_small_key, FOREST_ID, -1), // Forest Temple Small Key
[0xB0] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9108, 0x00AA, 0x02, no_upgrade, give_small_key, FIRE_ID, -1), // Fire Temple Small Key
[0xB1] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9111, 0x00AA, 0x02, no_upgrade, give_small_key, WATER_ID, -1), // Water Temple Small Key
[0xB2] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9118, 0x00AA, 0x02, no_upgrade, give_small_key, SPIRIT_ID, -1), // Spirit Temple Small Key
[0xB3] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9120, 0x00AA, 0x02, no_upgrade, give_small_key, SHADOW_ID, -1), // Shadow Temple Small Key
[0xB4] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9127, 0x00AA, 0x02, no_upgrade, give_small_key, BOTW_ID, -1), // Bottom of the Well Small Key
[0xB5] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x912B, 0x00AA, 0x02, no_upgrade, give_small_key, GTG_ID, -1), // Gerudo Training Small Key
[0xB6] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x9135, 0x00AA, 0x02, no_upgrade, give_small_key, FORT_ID, -1), // Gerudo Fortress Small Key
[0xB7] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x913A, 0x00AA, 0x02, no_upgrade, give_small_key, CASTLE_ID, -1), // Ganon's Castle Small Key

[0xB8] = ITEM_ROW(0x53, GILDED_CHEST, 0x41, -1, 0x00E9, 0x0194, 0x13, no_upgrade, give_defense, -1, -1), // Double Defense
[0xB9] = ITEM_ROW(0x53, GILDED_CHEST, 0x41, -1, 0x00E4, 0x00CD, 0x1E, no_upgrade, give_magic, -1, -1), // Magic Meter
Expand Down Expand Up @@ -259,6 +259,14 @@ item_row_t *get_item_row(uint16_t item_id) {
return item_row;
}

uint16_t resolve_item_text_id(uint16_t item_id, bool is_outgoing) {
item_row_t *item_row = get_item_row(item_id);
if (item_id >= 0xAF && item_id < 0xB8 && !is_outgoing) {
return item_row->text_id + (z64_file.scene_flags[item_row->effect_arg1].unk_00_ >> 0x10); // Dynamically select the text box based on key count
}
return item_row->text_id;
}

uint16_t resolve_upgrades(uint16_t item_id) {
for (;;) {
item_row_t *item_row = get_item_row(item_id);
Expand Down
3 changes: 3 additions & 0 deletions ASM/c/item_table.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef ITEM_TABLE_H
#define ITEM_TABLE_H

#include <stdbool.h>

#include "z64.h"

typedef enum {
Expand Down Expand Up @@ -39,6 +41,7 @@ typedef struct {
int8_t collectible;
} item_row_t;

uint16_t resolve_item_text_id(uint16_t item_id, bool is_outgoing);
uint16_t resolve_upgrades(uint16_t item_id);
item_row_t *get_item_row(uint16_t item_id);
void call_effect_function(item_row_t *item_row);
Expand Down
28 changes: 19 additions & 9 deletions Messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,9 @@
0x008E: "\x13\x76\x08You found the \x05\x41Dungeon Map\x05\x40\x01for the \x05\x43Water Temple\x05\x40!\x09",
0x008F: "\x13\x76\x08You found the \x05\x41Dungeon Map\x05\x40\x01for the \x05\x46Spirit Temple\x05\x40!\x09",
0x0092: "\x13\x76\x08You found the \x05\x41Dungeon Map\x05\x40\x01for the \x05\x44Ice Cavern\x05\x40!\x09",
0x0093: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x42Forest Temple\x05\x40!\x09",
0x0094: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x41Fire Temple\x05\x40!\x09",
0x0095: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x43Water Temple\x05\x40!\x09",
0x009B: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x45Bottom of the Well\x05\x40!\x09",
0x009F: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x46Gerudo Training\x01Ground\x05\x40!\x09",
0x00A0: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x46Thieves' Hideout\x05\x40!\x09",
0x00A1: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for \x05\x41Ganon's Castle\x05\x40!\x09",
0x00A2: "\x13\x75\x08You found the \x05\x41Compass\x05\x40\x01for the \x05\x45Bottom of the Well\x05\x40!\x09",
0x00A3: "\x13\x76\x08You found the \x05\x41Dungeon Map\x05\x40\x01for the \x05\x45Shadow Temple\x05\x40!\x09",
0x00A5: "\x13\x76\x08You found the \x05\x41Dungeon Map\x05\x40\x01for the \x05\x45Bottom of the Well\x05\x40!\x09",
0x00A6: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x46Spirit Temple\x05\x40!\x09",
0x00A9: "\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for the \x05\x45Shadow Temple\x05\x40!\x09",
0x9010: "\x13\x77\x08You found a \x05\x41Small Key Ring\x05\x40\x01for the \x05\x42Forest Temple\x05\x40!\x09",
0x9011: "\x13\x77\x08You found a \x05\x41Small Key Ring\x05\x40\x01for the \x05\x41Fire Temple\x05\x40!\x09",
0x9012: "\x13\x77\x08You found a \x05\x41Small Key Ring\x05\x40\x01for the \x05\x43Water Temple\x05\x40!\x09",
Expand All @@ -308,6 +299,25 @@
0x9017: "\x13\x77\x08You found a \x05\x41Small Key Ring\x05\x40\x01for the \x05\x46Thieves' Hideout\x05\x40!\x09",
0x9018: "\x13\x77\x08You found a \x05\x41Small Key Ring\x05\x40\x01for \x05\x41Ganon's Castle\x05\x40!\x09",
}
i = 0x9101
for dungeon_name, max_keys in (
("the \x05\x42Forest Temple\x05\x40", 6),
("the \x05\x41Fire Temple\x05\x40", 8),
("the \x05\x43Water Temple\x05\x40", 6),
("the \x05\x46Spirit Temple\x05\x40", 7),
("the \x05\x45Shadow Temple\x05\x40", 6),
("the \x05\x45Bottom of the Well\x05\x40", 3),
("the \x05\x46Gerudo Training\x01Ground\x05\x40", 9),
("the \x05\x46Thieves' Hideout\x05\x40", 4),
("\x05\x41Ganon's Castle\x05\x40", 3),
):
KEYSANITY_MESSAGES[i] = f"\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for {dungeon_name}!\x09"
i += 1
for num_keys in range(2, max_keys + 1):
KEYSANITY_MESSAGES[i] = f"\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for {dungeon_name}!\x01You've collected \x05\x41{num_keys}\x05\x40 of them.\x09"
i += 1
KEYSANITY_MESSAGES[i] = f"\x13\x77\x08You found a \x05\x41Small Key\x05\x40\x01for {dungeon_name}!\x01You already have enough keys.\x09"
i += 1

COLOR_MAP = {
'White': '\x40',
Expand Down
Loading