summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authoraMannus <mannusmenting@gmail.com>2022-12-21 05:32:01 +0100
committerGitHub <noreply@github.com>2022-12-20 23:32:01 -0500
commita1a6c07549b232fb8c98c86e7f65b2bcdf86a121 (patch)
tree85da045d8b2bc3ef52e83e18f463367c13204d39 /soh/src/code
parent6f7361e1a49a61fc9ddda0b3297d2e31c0aafbc7 (diff)
Rando - Fix ice traps & get item logic (#2210)
* Fix ice traps & get item logic * Fix shop keepers & more draw logic cleanup
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/z_actor.c4
-rw-r--r--soh/src/code/z_draw.c4
-rw-r--r--soh/src/code/z_player_lib.c50
3 files changed, 52 insertions, 6 deletions
diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c
index 74dd031b2..c4e89adf7 100644
--- a/soh/src/code/z_actor.c
+++ b/soh/src/code/z_actor.c
@@ -78,6 +78,9 @@
static CollisionPoly* sCurCeilingPoly;
static s32 sCurCeilingBgId;
+// Used for animating the ice trap on the "Get Item" model.
+f32 iceTrapScale;
+
void ActorShape_Init(ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale) {
shape->yOffset = yOffset;
shape->shadowDraw = shadowDraw;
@@ -2030,6 +2033,7 @@ s32 GiveItemEntryFromActor(Actor* actor, PlayState* play, GetItemEntry getItemEn
s32 absYawDiff = ABS(yawDiff);
if ((getItemEntry.getItemId != GI_NONE) || (player->getItemDirection < absYawDiff)) {
+ iceTrapScale = 0.0f;
player->getItemEntry = getItemEntry;
player->getItemId = getItemEntry.getItemId;
player->interactRangeActor = actor;
diff --git a/soh/src/code/z_draw.c b/soh/src/code/z_draw.c
index 17deffad2..140ee399a 100644
--- a/soh/src/code/z_draw.c
+++ b/soh/src/code/z_draw.c
@@ -400,9 +400,7 @@ void GetItem_Draw(PlayState* play, s16 drawId) {
* Uses the Custom Draw Function if it exists, or just calls `GetItem_Draw`
*/
void GetItemEntry_Draw(PlayState* play, GetItemEntry getItemEntry) {
- // RANDOTODO: Make this more flexible for easier toggling of individual item recolors in the future.
- if (getItemEntry.drawFunc != NULL &&
- (CVar_GetS32("gRandoMatchKeyColors", 0) || getItemEntry.getItemId == RG_DOUBLE_DEFENSE)) {
+ if (getItemEntry.drawFunc != NULL) {
getItemEntry.drawFunc(play, &getItemEntry);
} else {
GetItem_Draw(play, getItemEntry.gid);
diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c
index 625a53bee..617cf274e 100644
--- a/soh/src/code/z_player_lib.c
+++ b/soh/src/code/z_player_lib.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "objects/gameplay_keep/gameplay_keep.h"
+#include "objects/gameplay_field_keep/gameplay_field_keep.h"
#include "objects/object_link_boy/object_link_boy.h"
#include "objects/object_link_child/object_link_child.h"
#include "objects/object_triforce_spot/object_triforce_spot.h"
@@ -1172,6 +1173,49 @@ void func_800906D4(PlayState* play, Player* this, Vec3f* newTipPos) {
}
}
+void Player_DrawGetItemIceTrap(PlayState* play, Player* this, Vec3f* refPos, s32 drawIdPlusOne, f32 height) {
+ OPEN_DISPS(play->state.gfxCtx);
+
+ if (CVar_GetS32("gLetItSnow", 0)) {
+ Gfx_SetupDL_25Opa(play->state.gfxCtx);
+
+ Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY);
+ gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+
+ gDPSetGrayscaleColor(POLY_OPA_DISP++, 75, 75, 75, 255);
+ gSPGrayscale(POLY_OPA_DISP++, true);
+
+ gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gSilverRockDL);
+
+ gSPGrayscale(POLY_OPA_DISP++, false);
+ } else {
+ if (iceTrapScale < 0.01) {
+ iceTrapScale += 0.001f;
+ } else if (iceTrapScale < 0.8f) {
+ iceTrapScale += 0.2f;
+ }
+ gSPSegment(POLY_XLU_DISP++, 0x08,
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (0 - play->gameplayFrames) % 128, 32, 32, 1, 0,
+ (play->gameplayFrames * -2) % 128, 32, 32));
+
+ Matrix_Translate(0.0f, -40.0f, 0.0f, MTXMODE_APPLY);
+ Matrix_Scale(iceTrapScale, iceTrapScale, iceTrapScale, MTXMODE_APPLY);
+ gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, 255);
+ gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL);
+
+ // Reset matrix for the fake item model because we're animating the size of the ice block around it before this.
+ Matrix_Translate(refPos->x + (3.3f * Math_SinS(this->actor.shape.rot.y)), refPos->y + height,
+ refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_CosS(this->actor.shape.rot.y)), MTXMODE_NEW);
+ 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);
+ }
+
+ CLOSE_DISPS(play->state.gfxCtx);
+}
+
void Player_DrawGetItemImpl(PlayState* play, Player* this, Vec3f* refPos, s32 drawIdPlusOne) {
f32 height = (this->exchangeItemId != EXCH_ITEM_NONE) ? 6.0f : 14.0f;
@@ -1187,9 +1231,9 @@ void Player_DrawGetItemImpl(PlayState* play, Player* this, Vec3f* refPos, s32 dr
Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY);
Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY);
- // RANDOTODO: Make this more flexible for easier toggling of individual item recolors in the future.
- if (this->getItemEntry.drawFunc != NULL &&
- (CVar_GetS32("gRandoMatchKeyColors", 0) || this->getItemEntry.getItemId == RG_DOUBLE_DEFENSE || this->getItemEntry.getItemId == RG_ICE_TRAP)) {
+ if (this->getItemEntry.modIndex == MOD_RANDOMIZER && this->getItemEntry.getItemId == RG_ICE_TRAP) {
+ Player_DrawGetItemIceTrap(play, this, refPos, drawIdPlusOne, height);
+ } else if (this->getItemEntry.drawFunc != NULL) {
this->getItemEntry.drawFunc(play, &this->getItemEntry);
} else {
GetItem_Draw(play, drawIdPlusOne - 1);