From 213ea742eb7dac6111f63ee43994e1106334cafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Sat, 14 Jun 2025 05:43:25 +0000 Subject: [PATCH] Gerudo Guards: offer to throw you in jail (#5390) * Gerudo Guards: offer to throw you in jail Necessary for logic to use being captured in routing * don't intercept Ge3 * TODO_TRANSLATE * cleanup --- .../custom-message/CustomMessageTypes.h | 1 + .../vanilla-behavior/GIVanillaBehavior.h | 8 ++++++ .../Enhancements/randomizer/hook_handlers.cpp | 11 +++++++- soh/soh/OTRGlobals.cpp | 10 ++++--- soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 27 ++++++++++--------- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/soh/soh/Enhancements/custom-message/CustomMessageTypes.h b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h index 3bcbaf7b0..b5bc0fd6e 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageTypes.h +++ b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h @@ -163,6 +163,7 @@ typedef enum { TEXT_ANJU_ROUND_THEM_UP_OR_YOULL_PAY = 0x503C, TEXT_ANJU_DONT_TEASE_MY_CUCCOS = 0x503D, TEXT_BIG_POE_COLLECTED_RANDO = 0x5090, + TEXT_GERUDO_GUARD_FRIENDLY = 0x6005, TEXT_HBA_NOT_ON_HORSE = 0x603F, TEXT_HBA_INITIAL_EXPLAINATION = 0x6040, TEXT_HBA_WANT_TO_TRY_AGAIN_YES_NO = 0x6041, diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index 5159118b1..e76a806ab 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -575,6 +575,14 @@ typedef enum { // - None VB_GANON_HEAL_BEFORE_FIGHT, + // #### `result` + // ```c + // true + // ``` + // #### `args` + // - `*EnGe2` + VB_GERUDO_GUARD_SET_ACTION_AFTER_TALK, + // #### `result` // See logic in // ```c diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index ea8ce1e12..994e0fba6 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -46,6 +46,7 @@ extern "C" { #include "src/overlays/actors/ovl_En_Hy/z_en_hy.h" #include "src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h" #include "src/overlays/actors/ovl_En_Ge1/z_en_ge1.h" +#include "src/overlays/actors/ovl_En_Ge2/z_en_ge2.h" #include "src/overlays/actors/ovl_En_Ds/z_en_ds.h" #include "src/overlays/actors/ovl_En_Gm/z_en_gm.h" #include "src/overlays/actors/ovl_En_Js/z_en_js.h" @@ -55,7 +56,6 @@ extern "C" { #include "src/overlays/actors/ovl_En_Xc/z_en_xc.h" #include "src/overlays/actors/ovl_Fishing/z_fishing.h" #include "src/overlays/actors/ovl_En_Mk/z_en_mk.h" -#include "src/overlays/actors/ovl_En_Ge1/z_en_ge1.h" #include "draw.h" extern SaveContext gSaveContext; @@ -69,6 +69,8 @@ extern void EnMk_Wait(EnMk* enMk, PlayState* play); extern void func_80ABA778(EnNiwLady* enNiwLady, PlayState* play); extern void EnGe1_Wait_Archery(EnGe1* enGe1, PlayState* play); extern void EnGe1_SetAnimationIdle(EnGe1* enGe1); +extern void EnGe1_SetAnimationIdle(EnGe1* enGe1); +extern void EnGe2_SetupCapturePlayer(EnGe2* enGe2, PlayState* play); } bool LocMatchesQuest(Rando::Location loc) { @@ -1435,6 +1437,13 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l } break; } + case VB_GERUDO_GUARD_SET_ACTION_AFTER_TALK: + if (gPlayState->msgCtx.choiceIndex == 0) { + EnGe2* enGe2 = va_arg(args, EnGe2*); + EnGe2_SetupCapturePlayer(enGe2, gPlayState); + *should = false; + } + break; case VB_GERUDOS_BE_FRIENDLY: { *should = CHECK_QUEST_ITEM(QUEST_GERUDO_CARD); break; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a2135006a..9ac03b48e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2236,7 +2236,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { (Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == RO_GOSSIP_STONES_NEED_STONE && CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)))) { - Actor* stone = GET_PLAYER(play)->talkActor; + Actor* stone = player->talkActor; RandomizerHint stoneHint = RH_NONE; s16 hintParams = stone->params & 0xFF; @@ -2294,7 +2294,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { (RandomizerInf)((textId - TEXT_SHOP_ITEM_RANDOM_CONFIRM) + RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1)); messageEntry = OTRGlobals::Instance->gRandomizer->GetMerchantMessage(rc, TEXT_SHOP_ITEM_RANDOM_CONFIRM); } else if (textId == TEXT_SCRUB_RANDOM) { - EnDns* enDns = (EnDns*)GET_PLAYER(play)->talkActor; + EnDns* enDns = (EnDns*)player->talkActor; RandomizerCheck rc = OTRGlobals::Instance->gRandomizer->GetCheckFromRandomizerInf( (RandomizerInf)enDns->sohScrubIdentity.randomizerInf); messageEntry = OTRGlobals::Instance->gRandomizer->GetMerchantMessage( @@ -2344,7 +2344,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::merchantMessageTableID, textId, MF_AUTO_FORMAT); } else if (textId == TEXT_SKULLTULA_PEOPLE_IM_CURSED) { - actorParams = GET_PLAYER(play)->talkActor->params; + actorParams = player->talkActor->params; if (actorParams == 1 && ctx->GetOption(RSK_KAK_10_SKULLS_HINT)) { messageEntry = ctx->GetHint(RH_KAK_10_SKULLS_HINT)->GetHintMessage(MF_AUTO_FORMAT); } else if (actorParams == 2 && ctx->GetOption(RSK_KAK_20_SKULLS_HINT)) { @@ -2443,6 +2443,10 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { } else if (textId == TEXT_BIG_POE_COLLECTED_RANDO) { messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, textId, MF_AUTO_FORMAT); + } else if (textId == TEXT_GERUDO_GUARD_FRIENDLY && player->talkActor->id == ACTOR_EN_GE2) { + // TODO_TRANSLATE Translate into french and german + messageEntry = CustomMessage("Want me to throw you in jail?&\x1B#Yes please&No thanks#", { QM_GREEN }); + messageEntry.AutoFormat(); } } if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) { diff --git a/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index 89e846a23..776a241b1 100644 --- a/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -439,20 +439,21 @@ void EnGe2_LookAtPlayer(EnGe2* this, PlayState* play) { void EnGe2_SetActionAfterTalk(EnGe2* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - - switch (this->actor.params & 0xFF) { - case GE2_TYPE_PATROLLING: - EnGe2_ChangeAction(this, GE2_ACTION_ABOUTTURN); - break; - case GE2_TYPE_STATIONARY: - EnGe2_ChangeAction(this, GE2_ACTION_STAND); - break; - case GE2_TYPE_GERUDO_CARD_GIVER: - this->actionFunc = EnGe2_WaitLookAtPlayer; - break; + if (GameInteractor_Should(VB_GERUDO_GUARD_SET_ACTION_AFTER_TALK, true, this)) { + switch (this->actor.params & 0xFF) { + case GE2_TYPE_PATROLLING: + EnGe2_ChangeAction(this, GE2_ACTION_ABOUTTURN); + break; + case GE2_TYPE_STATIONARY: + EnGe2_ChangeAction(this, GE2_ACTION_STAND); + break; + case GE2_TYPE_GERUDO_CARD_GIVER: + this->actionFunc = EnGe2_WaitLookAtPlayer; + break; + } + this->actor.update = EnGe2_UpdateFriendly; + this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; } - this->actor.update = EnGe2_UpdateFriendly; - this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; } EnGe2_TurnToFacePlayer(this, play); }