vb bombchu bowling (#110)

* vb bombchu bowling

* don't need it

* it's drawing the right thing but it's tiny

* scale

* no need to should, don't rescale every draw

* slightly safer
This commit is contained in:
briaguya 2024-04-17 20:49:29 -04:00 committed by GitHub
parent 84db4c8ab8
commit f6a583446b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 75 additions and 75 deletions

View File

@ -305,6 +305,8 @@ typedef enum {
GI_VB_GIVE_ITEM_FROM_SKULLTULA_REWARD, GI_VB_GIVE_ITEM_FROM_SKULLTULA_REWARD,
// Opt: *EnHy // Opt: *EnHy
GI_VB_GIVE_ITEM_FROM_LOST_DOG, GI_VB_GIVE_ITEM_FROM_LOST_DOG,
// Opt: *EnBomBowlPit
GI_VB_GIVE_ITEM_FROM_BOMBCHU_BOWLING,
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

@ -30,6 +30,7 @@ extern "C" {
#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 "src/overlays/actors/ovl_En_Hy/z_en_hy.h"
#include "src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h" #include "src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h"
#include "src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h"
#include "adult_trade_shuffle.h" #include "adult_trade_shuffle.h"
extern SaveContext gSaveContext; extern SaveContext gSaveContext;
extern PlayState* gPlayState; extern PlayState* gPlayState;
@ -256,6 +257,30 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) {
} }
} }
void EnExItem_DrawRandomizedItem(EnExItem* enExItem, PlayState* play) {
func_8002ED80(&enExItem->actor, play, 0);
EnItem00_CustomItemsParticles(&enExItem->actor, play, enExItem->sohItemEntry);
GetItemEntry_Draw(play, enExItem->sohItemEntry);
}
void EnExItem_WaitForObjectRandomized(EnExItem* enExItem, PlayState* play) {
EnExItem_WaitForObject(enExItem, play);
if (Object_IsLoaded(&play->objectCtx, enExItem->objectIdx)) {
enExItem->actor.draw = (ActorFunc)EnExItem_DrawRandomizedItem;
Actor_SetScale(&enExItem->actor, enExItem->scale);
// for now we're just using this to not have items float
// below the bowling counter, but it would be nice to use
// this to not draw gigantic skull tokens etc.
switch (enExItem->type) {
case EXITEM_BOMB_BAG_COUNTER: {
enExItem->actor.shape.yOffset = -10.0f;
break;
}
}
}
}
void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play) { void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play) {
f32 mtxScale = CVarGetFloat("gTimeSavers.SkipGetItemAnimationScale", 10.0f); f32 mtxScale = CVarGetFloat("gTimeSavers.SkipGetItemAnimationScale", 10.0f);
Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY);
@ -932,6 +957,13 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void
*should = false; *should = false;
break; break;
} }
case GI_VB_GIVE_ITEM_FROM_BOMBCHU_BOWLING: {
EnBomBowlPit* enBomBowlPit = static_cast<EnBomBowlPit*>(optionalArg);
if (enBomBowlPit->prizeIndex == EXITEM_BOMB_BAG_BOWLING || enBomBowlPit->prizeIndex == EXITEM_HEART_PIECE_BOWLING) {
*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:
@ -1216,6 +1248,33 @@ void RandomizerOnActorInitHandler(void* actorRef) {
objComb->beehiveIdentity = OTRGlobals::Instance->gRandomizer->IdentifyBeehive(gPlayState->sceneNum, (s16)actor->world.pos.x, respawnData); objComb->beehiveIdentity = OTRGlobals::Instance->gRandomizer->IdentifyBeehive(gPlayState->sceneNum, (s16)actor->world.pos.x, respawnData);
objComb->actionFunc = (ObjCombActionFunc)ObjComb_RandomizerWait; objComb->actionFunc = (ObjCombActionFunc)ObjComb_RandomizerWait;
} }
if (actor->id == ACTOR_EN_EX_ITEM) {
EnExItem* enExItem = static_cast<EnExItem*>(actorRef);
RandomizerCheck rc = RC_UNKNOWN_CHECK;
switch (enExItem->type) {
case EXITEM_BOMB_BAG_COUNTER:
case EXITEM_BOMB_BAG_BOWLING:
rc = RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE;
break;
case EXITEM_HEART_PIECE_COUNTER:
case EXITEM_HEART_PIECE_BOWLING:
rc = RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE;
break;
case EXITEM_BOMBCHUS_COUNTER:
case EXITEM_BOMBCHUS_BOWLING:
rc = RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS;
break;
case EXITEM_BULLET_BAG:
rc = RC_LW_TARGET_IN_WOODS;
break;
}
if (rc != RC_UNKNOWN_CHECK) {
enExItem->sohItemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rc, true, (GetItemID)Rando::StaticData::GetLocation(rc)->GetVanillaItem());
enExItem->actionFunc = (EnExItemActionFunc)EnExItem_WaitForObjectRandomized;
}
}
} }
void RandomizerRegisterHooks() { void RandomizerRegisterHooks() {

View File

@ -2,6 +2,7 @@
#include "vt.h" #include "vt.h"
#include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" #include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h"
#include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h" #include "overlays/actors/ovl_En_Ex_Item/z_en_ex_item.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED
@ -177,56 +178,30 @@ void EnBomBowlPit_GivePrize(EnBomBowlPit* this, PlayState* play) {
Player_SetCsActionWithHaltedActors(play, NULL, 7); Player_SetCsActionWithHaltedActors(play, NULL, 7);
this->getItemId = sGetItemIds[this->prizeIndex]; this->getItemId = sGetItemIds[this->prizeIndex];
this->getItemEntry = (GetItemEntry)GET_ITEM_NONE;
if ((this->getItemId == GI_BOMB_BAG_30) && (CUR_CAPACITY(UPG_BOMB_BAG) == 30)) { if ((this->getItemId == GI_BOMB_BAG_30) && (CUR_CAPACITY(UPG_BOMB_BAG) == 30)) {
this->getItemId = GI_BOMB_BAG_40; this->getItemId = GI_BOMB_BAG_40;
} }
if (IS_RANDO) {
switch (this->prizeIndex) {
case EXITEM_BOMB_BAG_BOWLING:
this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20);
this->getItemId = this->getItemEntry.getItemId;
break;
case EXITEM_HEART_PIECE_BOWLING:
this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE);
this->getItemId = this->getItemEntry.getItemId;
break;
case EXITEM_BOMBCHUS_BOWLING:
this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS, GI_BOMBCHUS_10);
this->getItemId = this->getItemEntry.getItemId;
break;
}
}
player->stateFlags1 &= ~PLAYER_STATE1_IN_CUTSCENE; player->stateFlags1 &= ~PLAYER_STATE1_IN_CUTSCENE;
this->actor.parent = NULL; this->actor.parent = NULL;
if (!IS_RANDO || this->getItemEntry.getItemId == GI_NONE) { if (GameInteractor_Should(GI_VB_GIVE_ITEM_FROM_BOMBCHU_BOWLING, true, this)) {
Actor_OfferGetItem(&this->actor, play, this->getItemId, 2000.0f, 1000.0f); Actor_OfferGetItem(&this->actor, play, this->getItemId, 2000.0f, 1000.0f);
} else {
GiveItemEntryFromActor(&this->actor, play, this->getItemEntry, 2000.0f, 1000.0f);
} }
player->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; player->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE;
this->actionFunc = EnBomBowlPit_WaitTillPrizeGiven; this->actionFunc = EnBomBowlPit_WaitTillPrizeGiven;
} }
void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* this, PlayState* play) { void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play)) { if (Actor_HasParent(&this->actor, play) || !GameInteractor_Should(GI_VB_GIVE_ITEM_FROM_BOMBCHU_BOWLING, true, this)) {
this->actionFunc = EnBomBowlPit_Reset; this->actionFunc = EnBomBowlPit_Reset;
} else { } else {
if (!IS_RANDO || this->getItemEntry.getItemId == GI_NONE) { Actor_OfferGetItem(&this->actor, play, this->getItemId, 2000.0f, 1000.0f);
Actor_OfferGetItem(&this->actor, play, this->getItemId, 2000.0f, 1000.0f);
} else {
GiveItemEntryFromActor(&this->actor, play, this->getItemEntry, 2000.0f, 1000.0f);
}
} }
} }
void EnBomBowlPit_Reset(EnBomBowlPit* this, PlayState* play) { void EnBomBowlPit_Reset(EnBomBowlPit* this, PlayState* play) {
if (((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) {
Message_ShouldAdvance(play)) ||
(IS_RANDO && this->getItemId == GI_ICE_TRAP)) {
// "Normal termination"/"completion" // "Normal termination"/"completion"
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST);
if (this->getItemId == GI_HEART_PIECE) { if (this->getItemId == GI_HEART_PIECE) {

View File

@ -33,7 +33,6 @@ typedef struct EnBomBowlPit {
/* 0x01D4 */ Vec3f unk_1D4; // camera eye (maxsteps) /* 0x01D4 */ Vec3f unk_1D4; // camera eye (maxsteps)
/* 0x01E0 */ EnExItem* exItem; /* 0x01E0 */ EnExItem* exItem;
/* 0x01E4 */ char unk_1E4[0x3520]; /* 0x01E4 */ char unk_1E4[0x3520];
/* */ GetItemEntry getItemEntry;
} EnBomBowlPit; // size = 0x3704 } EnBomBowlPit; // size = 0x3704
#endif #endif

View File

@ -138,12 +138,7 @@ void EnExItem_WaitForObject(EnExItem* this, PlayState* play) {
onCounter = true; onCounter = true;
case EXITEM_BOMB_BAG_BOWLING: case EXITEM_BOMB_BAG_BOWLING:
this->unk_17C = func_8002EBCC; this->unk_17C = func_8002EBCC;
if (IS_RANDO) { this->giDrawId = GID_BOMB_BAG_30;
this->giDrawId =
Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20).gid;
} else {
this->giDrawId = GID_BOMB_BAG_30;
}
this->timer = 65; this->timer = 65;
this->prizeRotateTimer = 35; this->prizeRotateTimer = 35;
this->scale = 0.5f; this->scale = 0.5f;
@ -151,7 +146,7 @@ void EnExItem_WaitForObject(EnExItem* this, PlayState* play) {
this->actionFunc = EnExItem_BowlPrize; this->actionFunc = EnExItem_BowlPrize;
} else { } else {
this->actionFunc = EnExItem_SetupBowlCounter; this->actionFunc = EnExItem_SetupBowlCounter;
this->actor.shape.yOffset = IS_RANDO ? -10.0f : -18.0f; this->actor.shape.yOffset = -18.0f;
} }
break; break;
case EXITEM_HEART_PIECE_COUNTER: case EXITEM_HEART_PIECE_COUNTER:
@ -173,11 +168,7 @@ void EnExItem_WaitForObject(EnExItem* this, PlayState* play) {
onCounter = true; onCounter = true;
case EXITEM_BOMBCHUS_BOWLING: case EXITEM_BOMBCHUS_BOWLING:
this->unk_17C = func_8002EBCC; this->unk_17C = func_8002EBCC;
if (IS_RANDO) { this->giDrawId = GID_BOMBCHU;
this->giDrawId = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS, GI_BOMBCHUS_10).gid;
} else {
this->giDrawId = GID_BOMBCHU;
}
this->timer = 65; this->timer = 65;
this->prizeRotateTimer = 35; this->prizeRotateTimer = 35;
this->scale = 0.5f; this->scale = 0.5f;
@ -496,43 +487,12 @@ void EnExItem_DrawItems(EnExItem* this, PlayState* play) {
} }
if (this) {} if (this) {}
func_8002ED80(&this->actor, play, 0); func_8002ED80(&this->actor, play, 0);
if (IS_RANDO) {
GetItemEntry randoGetItem = (GetItemEntry)GET_ITEM_NONE;
switch (this->type) {
case EXITEM_BOMB_BAG_BOWLING:
case EXITEM_BOMB_BAG_COUNTER:
randoGetItem = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20);
break;
case EXITEM_BOMBCHUS_BOWLING:
case EXITEM_BOMBCHUS_COUNTER:
randoGetItem = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS, GI_BOMBCHUS_10);
break;
case EXITEM_BULLET_BAG:
randoGetItem = Randomizer_GetItemFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50);
break;
}
if (randoGetItem.getItemId != GI_NONE) {
EnItem00_CustomItemsParticles(&this->actor, play, randoGetItem);
GetItemEntry_Draw(play, randoGetItem);
return;
}
}
GetItem_Draw(play, this->giDrawId); GetItem_Draw(play, this->giDrawId);
} }
void EnExItem_DrawHeartPiece(EnExItem* this, PlayState* play) { void EnExItem_DrawHeartPiece(EnExItem* this, PlayState* play) {
func_8002ED80(&this->actor, play, 0); func_8002ED80(&this->actor, play, 0);
GetItem_Draw(play, GID_HEART_PIECE);
if (IS_RANDO) {
GetItemEntry randoGetItem =
Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE);
EnItem00_CustomItemsParticles(&this->actor, play, randoGetItem);
GetItemEntry_Draw(play, randoGetItem);
} else {
GetItem_Draw(play, GID_HEART_PIECE);
}
} }
void EnExItem_DrawMagic(EnExItem* this, PlayState* play, s16 magicIndex) { void EnExItem_DrawMagic(EnExItem* this, PlayState* play, s16 magicIndex) {

View File

@ -27,6 +27,9 @@ typedef struct EnExItem {
/* 0x0170 */ Vec3f initPos; // unused /* 0x0170 */ Vec3f initPos; // unused
/* 0x017C */ EnExItemLightFunc unk_17C; /* 0x017C */ EnExItemLightFunc unk_17C;
/* 0x0180 */ EnExItemLightFunc unk_180; /* 0x0180 */ EnExItemLightFunc unk_180;
// #region SOH [Randomizer] Caching the get item entry for the draw function for performance
/* */ GetItemEntry sohItemEntry;
// #endregion
} EnExItem; // size = 0x0184 } EnExItem; // size = 0x0184
typedef enum { typedef enum {
@ -52,6 +55,8 @@ typedef enum {
/* 19 */ EXITEM_BULLET_BAG /* 19 */ EXITEM_BULLET_BAG
} EnExItemType; } EnExItemType;
void EnExItem_WaitForObject(EnExItem* enExItem, PlayState* play);
#define EXITEM_COUNTER 5 #define EXITEM_COUNTER 5
#define EXITEM_CHEST 10 #define EXITEM_CHEST 10
#define EXITEM_MAGIC 16 #define EXITEM_MAGIC 16