Skip to content

Commit 110e238

Browse files
committed
Item Get Text Tweaks
- Make the item get text for bow/bombs use your actual capacity instead of always saying 30
1 parent 2e8d224 commit 110e238

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

tweaks.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,6 +3642,50 @@ TweakError fix_vanilla_text() {
36423642
return TweakError::NONE;
36433643
}
36443644

3645+
TweakError make_item_get_text_dynamic() {
3646+
for (const auto& language : Text::supported_languages) {
3647+
RandoSession::CacheEntry& entry = g_session.openGameFile("content/Common/Pack/permanent_2d_Us" + language + ".pack@SARC@message_msbt.szs@YAZ0@SARC@message.msbt@MSBT");
3648+
entry.addAction([=](RandoSession* session, FileType* data) -> int {
3649+
CAST_ENTRY_TO_FILETYPE(msbt, FileTypes::MSBTFile, data)
3650+
3651+
// The item get message for arrows normally says you can carry up to 30
3652+
// Change it to use your maximum arrow count
3653+
{
3654+
static const std::unordered_map<std::string, std::u16string> word_to_replace = {
3655+
{"English", u"30 arrows"s},
3656+
{"Spanish", u"30 flechas"s},
3657+
{"French", u"30 flèches"s},
3658+
};
3659+
3660+
std::u16string& message = msbt.messages_by_label["00140"].text.message;
3661+
const std::u16string& replace = word_to_replace.at(language);
3662+
message.replace(message.find(replace), replace.size(), REPLACE(ReplaceTags::ARROW_MAX));
3663+
}
3664+
3665+
// The item get message for bombs normally says you can carry up to 30
3666+
// Change it to use your maximum bomb count
3667+
// IMPROVEMENT: the vanilla text command for bomb capacity always includes " bombs" after the number
3668+
// English and Spanish have a unitless number in the vanilla text, so the text would be more faithful if it left off the unit
3669+
{
3670+
// Replacing just "30" without color commands would leave French with redundant unit text
3671+
static const std::unordered_map<std::string, std::u16string> word_to_replace = {
3672+
{"English", TEXT_COLOR_RED u"30"s TEXT_COLOR_DEFAULT},
3673+
{"Spanish", TEXT_COLOR_RED u"30"s TEXT_COLOR_DEFAULT},
3674+
{"French", TEXT_COLOR_RED u"30 "s TEXT_COLOR_DEFAULT u"bombes"s},
3675+
};
3676+
3677+
std::u16string& message = msbt.messages_by_label["00150"].text.message;
3678+
const std::u16string& replace = word_to_replace.at(language);
3679+
message.replace(message.find(replace), replace.size(), TEXT_COLOR_RED REPLACE(ReplaceTags::BOMB_MAX) TEXT_COLOR_DEFAULT);
3680+
}
3681+
3682+
return true;
3683+
});
3684+
}
3685+
3686+
return TweakError::NONE;
3687+
}
3688+
36453689
TweakError allow_nonlinear_servants_of_the_towers() {
36463690
// Allow the sections of Tower of the Gods where you bring three Servants of the Tower into the hub room to be done nonlinearly, so you can return the servants in any order.
36473691
// We change it so the Command Melody tablet appears when any one of the three servants is returned (originally it would only appear when returning the east servant).
@@ -4292,6 +4336,7 @@ TweakError apply_necessary_tweaks(const Settings& settings) {
42924336
TWEAK_ERR_CHECK(add_ff_warp_button());
42934337
TWEAK_ERR_CHECK(fix_entrance_params());
42944338
TWEAK_ERR_CHECK(fix_vanilla_text());
4339+
TWEAK_ERR_CHECK(make_item_get_text_dynamic());
42954340
TWEAK_ERR_CHECK(make_dungeon_joy_pendants_flexible());
42964341
TWEAK_ERR_CHECK(prevent_fairy_island_softlocks());
42974342
TWEAK_ERR_CHECK(give_fairy_fountains_distinct_colors());

0 commit comments

Comments
 (0)