vb richard (#108)

* Lost Dog + Custom Hook Handler

* vb richard

* fix the merge

---------

Co-authored-by: Taw <Tawling@users.noreply.github.com>
This commit is contained in:
briaguya 2024-04-16 20:28:20 -04:00 committed by GitHub
parent 63afaa3cc9
commit 60d74f720a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 36 deletions

View File

@ -303,6 +303,8 @@ typedef enum {
GI_VB_GIVE_ITEM_FROM_HORSEBACK_ARCHERY, GI_VB_GIVE_ITEM_FROM_HORSEBACK_ARCHERY,
// Opt: *EnSth // Opt: *EnSth
GI_VB_GIVE_ITEM_FROM_SKULLTULA_REWARD, GI_VB_GIVE_ITEM_FROM_SKULLTULA_REWARD,
// Opt: *EnHy
GI_VB_GIVE_ITEM_FROM_LOST_DOG,
GI_VB_GIVE_ITEM_FAIRY_OCARINA, GI_VB_GIVE_ITEM_FAIRY_OCARINA,
GI_VB_GIVE_ITEM_WEIRD_EGG, GI_VB_GIVE_ITEM_WEIRD_EGG,

View File

@ -28,6 +28,7 @@ extern "C" {
#include "src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h" #include "src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h"
#include "src/overlays/actors/ovl_En_Box/z_en_box.h" #include "src/overlays/actors/ovl_En_Box/z_en_box.h"
#include "src/overlays/actors/ovl_En_Skj/z_en_skj.h" #include "src/overlays/actors/ovl_En_Skj/z_en_skj.h"
#include "src/overlays/actors/ovl_En_Hy/z_en_hy.h"
#include "adult_trade_shuffle.h" #include "adult_trade_shuffle.h"
extern SaveContext gSaveContext; extern SaveContext gSaveContext;
extern PlayState* gPlayState; extern PlayState* gPlayState;
@ -917,6 +918,15 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void
*should = false; *should = false;
break; break;
} }
case GI_VB_GIVE_ITEM_FROM_LOST_DOG: {
EnHy* enHy = static_cast<EnHy*>(optionalArg);
Flags_SetInfTable(INFTABLE_191);
gSaveContext.dogParams = 0;
gSaveContext.dogIsLost = false;
enHy->actionFunc = func_80A7127C;
*should = false;
break;
}
case GI_VB_TRADE_TIMER_ODD_MUSHROOM: case GI_VB_TRADE_TIMER_ODD_MUSHROOM:
case GI_VB_TRADE_TIMER_EYEDROPS: case GI_VB_TRADE_TIMER_EYEDROPS:
case GI_VB_TRADE_TIMER_FROG: case GI_VB_TRADE_TIMER_FROG:

View File

@ -14,6 +14,7 @@
#include "objects/object_cne/object_cne.h" #include "objects/object_cne/object_cne.h"
#include "objects/object_cob/object_cob.h" #include "objects/object_cob/object_cob.h"
#include "objects/object_os_anime/object_os_anime.h" #include "objects/object_os_anime/object_os_anime.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_WHILE_CULLED) #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_WHILE_CULLED)
@ -659,19 +660,10 @@ s16 func_80A70058(PlayState* play, Actor* thisx) {
gSaveContext.dogParams = 0; gSaveContext.dogParams = 0;
break; break;
case 0x709F: case 0x709F:
if (Flags_GetInfTable(INFTABLE_191)) { // Already brought the lost dog back if (GameInteractor_Should(GI_VB_GIVE_ITEM_FROM_LOST_DOG, true, this)) {
func_80A6F7CC(this, play, GI_RUPEE_BLUE); func_80A6F7CC(this, play, Flags_GetInfTable(INFTABLE_191) ? GI_RUPEE_BLUE : GI_HEART_PIECE);
} else { this->actionFunc = func_80A714C4;
if (!IS_RANDO) {
func_80A6F7CC(this, play, GI_HEART_PIECE);
} else {
this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_LOST_DOG, GI_HEART_PIECE);
// The follownig line and last arguments of GiveItemEntryFromActor are copied from func_80A6F7CC
this->unkGetItemId = this->getItemEntry.getItemId;
GiveItemEntryFromActor(&this->actor, play, this->getItemEntry, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f);
}
} }
this->actionFunc = func_80A714C4;
break; break;
} }
return NPC_TALK_STATE_IDLE; return NPC_TALK_STATE_IDLE;
@ -1068,36 +1060,26 @@ void func_80A714C4(EnHy* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play)) { if (Actor_HasParent(&this->actor, play)) {
this->actionFunc = func_80A71530; this->actionFunc = func_80A71530;
} else { } else {
if (!IS_RANDO || this->getItemEntry.getItemId == GI_NONE) { Actor_OfferGetItem(&this->actor, play, this->unkGetItemId, this->actor.xzDistToPlayer + 1.0f,
Actor_OfferGetItem(&this->actor, play, this->unkGetItemId, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); fabsf(this->actor.yDistToPlayer) + 1.0f);
} else {
GiveItemEntryFromActor(&this->actor, play, this->getItemEntry, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f);
}
} }
} }
void func_80A71530(EnHy* this, PlayState* play) { void func_80A71530(EnHy* this, PlayState* play) {
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) {
if (IS_RANDO) { switch (this->unkGetItemId) {
if (!Flags_GetInfTable(INFTABLE_191)) { case GI_HEART_PIECE:
Flags_SetInfTable(INFTABLE_191); gSaveContext.dogParams = 0;
} gSaveContext.dogIsLost = false;
gSaveContext.dogParams = 0; SET_INFTABLE(INFTABLE_191);
gSaveContext.dogIsLost = false; break;
} else { case GI_RUPEE_BLUE:
switch (this->unkGetItemId) { Rupees_ChangeBy(5);
case GI_HEART_PIECE: gSaveContext.dogParams = 0;
gSaveContext.dogParams = 0; gSaveContext.dogIsLost = false;
gSaveContext.dogIsLost = false; break;
Flags_SetInfTable(INFTABLE_191);
break;
case GI_RUPEE_BLUE:
Rupees_ChangeBy(5);
gSaveContext.dogParams = 0;
gSaveContext.dogIsLost = false;
break;
}
} }
this->actionFunc = func_80A7127C; this->actionFunc = func_80A7127C;
} }
} }

View File

@ -62,4 +62,6 @@ typedef struct EnHy {
/* */ GetItemEntry getItemEntry; /* */ GetItemEntry getItemEntry;
} EnHy; // size = 0x0334 } EnHy; // size = 0x0334
void func_80A7127C(EnHy* enHy, PlayState* play);
#endif #endif