From c9907ed5fc823a31394730ae41b3bc5f5ad4086d Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sat, 30 Dec 2023 12:10:50 -0500 Subject: [PATCH] Allows rendering custom models as Ice Traps in GetItem Animations. (#3760) --- soh/soh/Enhancements/randomizer/3drando/item_pool.cpp | 10 +++++----- soh/soh/Enhancements/randomizer/draw.cpp | 2 +- soh/soh/Enhancements/randomizer/item.cpp | 8 ++++---- soh/src/code/z_player_lib.c | 6 +++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index 2248bcd15..c4fad91eb 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -731,11 +731,11 @@ void GenerateItemPool() { AddItemToMainPool(RG_OCARINA_C_RIGHT_BUTTON); //TODO: Re-add when custom models work with ice traps - //ctx->possibleIceTrapModels.push_back(RG_OCARINA_A_BUTTON); - //ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_UP_BUTTON); - //ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_DOWN_BUTTON); - //ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_LEFT_BUTTON); - //ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_RIGHT_BUTTON); + ctx->possibleIceTrapModels.push_back(RG_OCARINA_A_BUTTON); + ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_UP_BUTTON); + ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_DOWN_BUTTON); + ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_LEFT_BUTTON); + ctx->possibleIceTrapModels.push_back(RG_OCARINA_C_RIGHT_BUTTON); } if (ctx->GetOption(RSK_SHUFFLE_COWS)) { diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index 1730c7fc7..a66d6b43d 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -358,7 +358,7 @@ extern "C" void Randomizer_DrawOcarinaButton(PlayState* play, GetItemEntry* getI cRightButtonColor = CVarGetColor24("gCosmetics.Hud_CRightButton.Value", cRightButtonColor); } - s16 slot = getItemEntry->getItemId - RG_OCARINA_A_BUTTON; + s16 slot = getItemEntry->drawItemId - RG_OCARINA_A_BUTTON; Gfx* dLists[] = { (Gfx*)gOcarinaAButtonDL, diff --git a/soh/soh/Enhancements/randomizer/item.cpp b/soh/soh/Enhancements/randomizer/item.cpp index d34929f76..9ad4be326 100644 --- a/soh/soh/Enhancements/randomizer/item.cpp +++ b/soh/soh/Enhancements/randomizer/item.cpp @@ -19,9 +19,9 @@ Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) { - giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_RANDOMIZER, static_cast(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, NULL}); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_RANDOMIZER, static_cast(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, static_cast(randomizerGet_), MOD_RANDOMIZER, NULL}); } else { - giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_VANILLA, getItemId_, gid_, true, ITEM_FROM_NPC, category_, NULL}); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_VANILLA, getItemId_, gid_, true, ITEM_FROM_NPC, category_, itemId_, modIndex_, NULL}); } } @@ -33,9 +33,9 @@ Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_, : randomizerGet(randomizerGet_), name(std::move(name_)), type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_), progressive(progressive_), price(price_) { if (modIndex_ == MOD_RANDOMIZER || getItemId > 0x7D) { - giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_RANDOMIZER, static_cast(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, NULL}); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_RANDOMIZER, static_cast(randomizerGet_), gid_, true, ITEM_FROM_NPC, category_, static_cast(randomizerGet_), modIndex_, NULL}); } else { - giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_VANILLA, getItemId_, gid_, true, ITEM_FROM_NPC, category_, NULL}); + giEntry = std::make_shared(GetItemEntry{itemId_, field_, static_cast((chestAnimation_ != CHEST_ANIM_SHORT ? 1 : -1) * (gid_ + 1)), textId_, objectId_, modIndex_, TABLE_VANILLA, getItemId_, gid_, true, ITEM_FROM_NPC, category_, itemId_, modIndex_, NULL}); } } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index b9a66c90e..9df23f794 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1508,7 +1508,11 @@ void Player_DrawGetItemIceTrap(PlayState* play, Player* this, Vec3f* refPos, s32 Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); // Draw fake item model. - GetItem_Draw(play, drawIdPlusOne - 1); + if (this->getItemEntry.drawFunc != NULL) { + this->getItemEntry.drawFunc(play, &this->getItemEntry); + } else { + GetItem_Draw(play, drawIdPlusOne - 1); + } } CLOSE_DISPS(play->state.gfxCtx);