Skip to content

Commit

Permalink
VBify poe collector giving for rando. (HarbourMasters#4458)
Browse files Browse the repository at this point in the history
* VBify poe collector giving for rando.

* Forgot an include.

* Further refinement so all the action happens in the handler. Virtual full restoration of vanilla code flow.

* Restored 1000 point messages before rando item give.

* Cleanup redundant GI Should call.
  • Loading branch information
Malkierian authored Oct 21, 2024
1 parent b2e99b8 commit 4663bd1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 2 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ typedef enum {
VB_GIVE_ITEM_FROM_THAWING_KING_ZORA,
// Opt: *EnGo2
VB_GIVE_ITEM_FROM_GORON,
// Opt: *EnGb
VB_GIVE_ITEM_FROM_POE_COLLECTOR,
// Opt: *EnJs
VB_CHECK_RANDO_PRICE_OF_CARPET_SALESMAN,
VB_GIVE_ITEM_FROM_CARPET_SALESMAN,
Expand Down
11 changes: 11 additions & 0 deletions soh/soh/Enhancements/randomizer/hook_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C" {
#include "src/overlays/actors/ovl_En_Cow/z_en_cow.h"
#include "src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.h"
#include "src/overlays/actors/ovl_En_Dns/z_en_dns.h"
#include "src/overlays/actors/ovl_En_Gb/z_en_gb.h"
#include "src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h"
#include "src/overlays/actors/ovl_En_Ko/z_en_ko.h"
#include "src/overlays/actors/ovl_En_Mk/z_en_mk.h"
Expand Down Expand Up @@ -904,6 +905,16 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l
*should = false;
break;
}
case VB_GIVE_ITEM_FROM_POE_COLLECTOR: {
EnGb* enGb = va_arg(args, EnGb*);
if (!Flags_GetRandomizerInf(RAND_INF_10_BIG_POES)) {
Flags_SetRandomizerInf(RAND_INF_10_BIG_POES);
enGb->dyna.actor.parent = NULL;
enGb->actionFunc = func_80A2FC0C;
*should = false;
}
break;
}
case VB_CHECK_RANDO_PRICE_OF_CARPET_SALESMAN: {
if (EnJs_RandoCanGetCarpetMerchantItem()){
*should = gSaveContext.rupees < OTRGlobals::Instance->gRandoContext->GetItemLocation(RC_WASTELAND_BOMBCHU_SALESMAN)->GetPrice();
Expand Down
24 changes: 7 additions & 17 deletions soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "z_en_gb.h"
#include "objects/object_ps/object_ps.h"
#include "soh/frame_interpolation.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"

#define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY)

Expand Down Expand Up @@ -337,18 +338,14 @@ void func_80A2FA50(EnGb* this, PlayState* play) {
Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE);
Rupees_ChangeBy(50);
HIGH_SCORE(HS_POE_POINTS) += 100;
if (
(!IS_RANDO && HIGH_SCORE(HS_POE_POINTS) != 1000) ||
(IS_RANDO && (HIGH_SCORE(HS_POE_POINTS) != 1000 || Flags_GetRandomizerInf(RAND_INF_10_BIG_POES)))
) {
if (HIGH_SCORE(HS_POE_POINTS) != 1000) {
if (HIGH_SCORE(HS_POE_POINTS) > 1100) {
HIGH_SCORE(HS_POE_POINTS) = 1100;
}
this->actionFunc = func_80A2F83C;
} else {
Player* player = GET_PLAYER(play);

Flags_SetRandomizerInf(RAND_INF_10_BIG_POES);
player->exchangeItemId = EXCH_ITEM_NONE;
this->textId = 0x70F8;
Message_ContinueTextbox(play, this->textId);
Expand All @@ -359,27 +356,20 @@ void func_80A2FA50(EnGb* this, PlayState* play) {

void func_80A2FB40(EnGb* this, PlayState* play) {
if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(play)) {
if (!IS_RANDO) {
if (GameInteractor_Should(VB_GIVE_ITEM_FROM_POE_COLLECTOR, true, this)) {
Actor_OfferGetItem(&this->dyna.actor, play, GI_BOTTLE, 100.0f, 10.0f);
} else {
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE);
GiveItemEntryFromActor(&this->dyna.actor, play, getItemEntry, 100.0f, 10.0f);
this->actionFunc = func_80A2FBB0;
}
this->actionFunc = func_80A2FBB0;
}
}

void func_80A2FBB0(EnGb* this, PlayState* play) {
if (Actor_HasParent(&this->dyna.actor, play)) {
this->dyna.actor.parent = NULL;
this->actionFunc = func_80A2FC0C;
} else {
if (!IS_RANDO) {
Actor_OfferGetItem(&this->dyna.actor, play, GI_BOTTLE, 100.0f, 10.0f);
} else {
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE);
GiveItemEntryFromActor(&this->dyna.actor, play, getItemEntry, 100.0f, 10.0f);
}
}
else {
Actor_OfferGetItem(&this->dyna.actor, play, GI_BOTTLE, 100.0f, 10.0f);
}
}

Expand Down
2 changes: 2 additions & 0 deletions soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ typedef struct EnGb {
/* 0x0388 */ EnGbCagedSoul cagedSouls[4];
} EnGb; // size = 0x0438

void func_80A2FC0C(EnGb* actor, PlayState* play);

#endif

0 comments on commit 4663bd1

Please sign in to comment.