summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2026-10-13 21:51:42 +0200
committerGitHub <noreply@github.com>2026-10-13 21:51:42 +0200
commit61eae1994cc67f5066525b41a785826b3eaac07f (patch)
treefeb4292ecde00148f8baff1f1301ab1c3e007153 /src
parent3cd9b9682e1a858879149049d53d99ec5a8293ad (diff)
[cc0 oot] BgHakaTrap (#2815)
* [cc0 oot] BgHakaTrap * BgHakaTrap review
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c277
-rw-r--r--src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.h34
2 files changed, 130 insertions, 181 deletions
diff --git a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c
index 89339a6e3..3132fc4fa 100644
--- a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c
+++ b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c
@@ -3,23 +3,23 @@
* Overlay: ovl_Bg_Haka_Trap
* Description: Shadow Temple traps
*
- * HAKA_TRAP_GUILLOTINE:
+ * BG_HAKA_TRAP_GUILLOTINE:
* A guillotine blade attached to a chain, drops from the ceiling.
*
- * HAKA_TRAP_GUILLOTINE_FAST: (spawn only param)
+ * BG_HAKA_TRAP_GUILLOTINE_FAST: (spawn only param)
* Enables a flag making the guillotine move faster.
*
- * HAKA_TRAP_SPIKED_CRUSHER:
+ * BG_HAKA_TRAP_SPIKED_CRUSHER:
* A square shaped platform suspended by a chain with spikes underneath, intended to crush the player. A pushblock can
* be used to prevent it from decending completely. Rotating this actor may prevent correct hit detection of the block.
*
- * HAKA_TRAP_SPIKED_WALL_EAST:
- * HAKA_TRAP_SPIKED_WALL_WEST:
+ * BG_HAKA_TRAP_SPIKED_WALL_EAST:
+ * BG_HAKA_TRAP_SPIKED_WALL_WEST:
*
* Two wooden spike walls that come together to crush the player. The one to the east has extra holes to reveal the
* chest behind it.
*
- * HAKA_TRAP_FAN_BLADE:
+ * BG_HAKA_TRAP_FAN_BLADE:
* A small fan blade that pushes the player away when turned on. `world.rot.z` is used to store the angular
* velocity of the fan
*/
@@ -47,7 +47,6 @@ void BgHakaTrap_Destroy(Actor* thisx, PlayState* play);
void BgHakaTrap_Update(Actor* thisx, PlayState* play);
void BgHakaTrap_Draw(Actor* thisx, PlayState* play);
-void BgHakaTrap_UpdateBodyColliderPos(BgHakaTrap* this, PlayState* play);
void BgHakaTrap_SpikedWall_CloseIn(BgHakaTrap* this, PlayState* play);
void BgHakaTrap_SpikedWall_Burn(BgHakaTrap* this, PlayState* play);
void BgHakaTrap_Guillotine_Fall(BgHakaTrap* this, PlayState* play);
@@ -58,9 +57,8 @@ void BgHakaTrap_FanBlade_Idle(BgHakaTrap* this, PlayState* play);
void BgHakaTrap_PushPlayer(BgHakaTrap* this, PlayState* play, s16 angularVelocity);
void BgHakaTrap_FanBlade_ToggleFanGust(BgHakaTrap* this, PlayState* play);
void BgHakaTrap_FanBlade_FullGust(BgHakaTrap* this, PlayState* play);
-void BgHakaTrap_SpikedWall_UpdateCollider(BgHakaTrap* this);
-static s32 sIsSpikeWallBurning = false;
+s32 sIsSpikeWallBurning = false;
ActorProfile Bg_Haka_Trap_Profile = {
/**/ ACTOR_BG_HAKA_TRAP,
@@ -94,7 +92,7 @@ static ColliderCylinderInit sCylinderInit = {
{ 30, 90, 0, { 0, 0, 0 } },
};
-static ColliderTrisElementInit sSpikedWallTrisElementsInit[] = {
+static ColliderTrisElementInit sSpikedWallTrisElementsInit[2] = {
{
{
ELEM_MATERIAL_UNK0,
@@ -104,7 +102,13 @@ static ColliderTrisElementInit sSpikedWallTrisElementsInit[] = {
ACELEM_ON,
OCELEM_NONE,
},
- { { { 1800.0f, 1200.0f, 0.0f }, { -1800.0f, 1200.0f, 0.0f }, { -1800.0f, 0.0f, 0.0f } } },
+ {
+ {
+ { 1800.0f, 1200.0f, 0.0f },
+ { -1800.0f, 1200.0f, 0.0f },
+ { -1800.0f, 0.0f, 0.0f },
+ },
+ },
},
{
{
@@ -115,7 +119,11 @@ static ColliderTrisElementInit sSpikedWallTrisElementsInit[] = {
ACELEM_ON,
OCELEM_NONE,
},
- { { { 1800.0f, 1200.0f, 0.0f }, { -1800.0f, 0.0f, 0.0f }, { 1800.0f, 0.0f, 0.0f } } },
+ { {
+ { 1800.0f, 1200.0f, 0.0f },
+ { -1800.0f, 0.0f, 0.0f },
+ { 1800.0f, 0.0f, 0.0f },
+ } },
},
};
@@ -140,137 +148,118 @@ static InitChainEntry sInitChain[] = {
void BgHakaTrap_Init(Actor* thisx, PlayState* play) {
static s32 sSpikedCrusherFlip = false;
+
+ s32* spikedCrusherFlipPtr;
BgHakaTrap* this = (BgHakaTrap*)thisx;
- STACK_PAD(s32);
CollisionHeader* colHeader = NULL;
- Actor_ProcessInitChain(thisx, sInitChain);
- thisx->params &= 0xFF;
-
- if (thisx->params != HAKA_TRAP_FAN_BLADE) {
+ Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
+ this->dyna.actor.params &= 0xFF;
+ spikedCrusherFlipPtr = &sSpikedCrusherFlip;
+ if (this->dyna.actor.params != BG_HAKA_TRAP_FAN_BLADE) {
Collider_InitCylinder(play, &this->colliderCylinder);
- Collider_SetCylinder(play, &this->colliderCylinder, thisx, &sCylinderInit);
-
- if ((thisx->params == HAKA_TRAP_GUILLOTINE) || (thisx->params == HAKA_TRAP_GUILLOTINE_FAST)) {
+ Collider_SetCylinder(play, &this->colliderCylinder, &this->dyna.actor, &sCylinderInit);
+ if ((this->dyna.actor.params == BG_HAKA_TRAP_GUILLOTINE) ||
+ (this->dyna.actor.params == BG_HAKA_TRAP_GUILLOTINE_FAST)) {
this->timer = 20;
+ do {
+ } while (0);
this->colliderCylinder.dim.yShift = 10;
- thisx->velocity.y = 0.1f;
-
- if (thisx->params == HAKA_TRAP_GUILLOTINE_FAST) {
- thisx->params = HAKA_TRAP_GUILLOTINE;
+ this->dyna.actor.velocity.y = 0.1f;
+ if (this->dyna.actor.params == BG_HAKA_TRAP_GUILLOTINE_FAST) {
+ this->dyna.actor.params = BG_HAKA_TRAP_GUILLOTINE;
this->isGuillotineFast = true;
}
-
this->actionFunc = BgHakaTrap_Guillotine_Fall;
} else {
- DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS);
- thisx->flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED;
-
- if (thisx->params == HAKA_TRAP_SPIKED_CRUSHER) {
+ DynaPolyActor_Init((DynaPolyActor*)this, DYNA_TRANSFORM_POS);
+ this->dyna.actor.flags |= ACTOR_FLAG_UPDATE_CULLING_DISABLED;
+ if (this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_CRUSHER) {
CollisionHeader_GetVirtual(&gShadowTempleSpikedCrusherCol, &colHeader);
this->timer = 30;
-
- // Instances alternate between starting off in the up or down position.
- if (sSpikedCrusherFlip) {
+ if (*spikedCrusherFlipPtr) {
this->actionFunc = BgHakaTrap_SpikedCrusher_Lift;
sSpikedCrusherFlip = false;
} else {
sSpikedCrusherFlip = true;
this->actionFunc = BgHakaTrap_SpikedCrusher_Fall;
- thisx->velocity.y = 0.5f;
+ this->dyna.actor.velocity.y = 0.5f;
}
-
// Assign the minimum height of the crusher. The crusher intentionally clips through the floor by 25
// units to allow the spikes to pierce the floor
- thisx->floorHeight = thisx->home.pos.y - (200 + 25);
-
+ this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y - (200 + 25);
// Assigns the height the crusher rises on first "tug". The final -25 offset is missing in other
// calculations of this variable.
- this->spikedCrusherStepY = (thisx->floorHeight + 50.0f) - 25.0f;
-
- this->colliderCylinder.dim.radius = 10;
- this->colliderCylinder.dim.height = 40;
+ this->spikedCrusherStepY = this->dyna.actor.floorHeight + 50.0f - 25.0f;
+ this->colliderCylinder.dim.radius = 0xA;
+ this->colliderCylinder.dim.height = 0x28;
} else {
- if (thisx->params == HAKA_TRAP_SPIKED_WALL_EAST) {
+ if (this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_WALL_EAST) {
CollisionHeader_GetVirtual(&gShadowTempleSpikedWallEastCol, &colHeader);
// Shift the home position toward the center of the room. This will become the target position that
// triggers the crush.
- thisx->home.pos.x -= 200.0f;
+ this->dyna.actor.home.pos.x -= 200.0f;
} else /* HAKA_TRAP_SPIKED_WALL_WEST */ {
// Shift the home position toward the center of the room. This will become the target position that
// triggers the crush.
- thisx->home.pos.x += 200.0f;
+ this->dyna.actor.home.pos.x += 200.0f;
CollisionHeader_GetVirtual(&gShadowTempleSpikedWallWestCol, &colHeader);
}
-
- Collider_InitTris(play, &this->spikesCollider);
- Collider_SetTris(play, &this->spikesCollider, thisx, &sSpikedWallTrisInit,
- this->spikesColliderElements);
-
+ Collider_InitTris(play, &this->spikedWallCollider);
+ Collider_SetTris(play, &this->spikedWallCollider, &this->dyna.actor, &sSpikedWallTrisInit,
+ this->spikedWallColliderElements);
this->colliderCylinder.dim.radius = 18;
this->colliderCylinder.dim.height = 115;
-
this->colliderCylinder.elem.atElemFlags &= ~ATELEM_SFX_NORMAL;
this->colliderCylinder.elem.atElemFlags |= ATELEM_SFX_WOOD;
-
this->actionFunc = BgHakaTrap_SpikedWall_CloseIn;
}
-
- this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader);
+ this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
}
} else {
// Initialize HAKA_TRAP_FAN_BLADE
this->timer = 40;
this->actionFunc = BgHakaTrap_FanBlade_Idle;
- thisx->cullingVolumeScale = 500.0f;
+ this->dyna.actor.cullingVolumeScale = 500.0f;
}
-
- CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit);
+ CollisionCheck_SetInfo(&this->dyna.actor.colChkInfo, NULL, &sColChkInfoInit);
}
void BgHakaTrap_Destroy(Actor* thisx, PlayState* play) {
BgHakaTrap* this = (BgHakaTrap*)thisx;
- if (this->dyna.actor.params != HAKA_TRAP_FAN_BLADE) {
- if (this->dyna.actor.params != HAKA_TRAP_GUILLOTINE) {
+ if (this->dyna.actor.params != BG_HAKA_TRAP_FAN_BLADE) {
+ if (this->dyna.actor.params != BG_HAKA_TRAP_GUILLOTINE) {
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
- if ((this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_EAST) ||
- (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_WEST)) {
- Collider_DestroyTris(play, &this->spikesCollider);
+ if ((this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_WALL_EAST) ||
+ (this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_WALL_WEST)) {
+ Collider_DestroyTris(play, &this->spikedWallCollider);
}
}
-
Collider_DestroyCylinder(play, &this->colliderCylinder);
}
-
Audio_StopSfxByPos(&this->chainLiftSfxPos);
}
-// Updates body collider for HAKA_TRAP_GUILLOTINE, HAKA_TRAP_SPIKED_WALL_EAST, HAKA_TRAP_SPIKED_WALL_WEST
+// Updates body collider for BG_HAKA_TRAP_GUILLOTINE, BG_HAKA_TRAP_SPIKED_WALL_EAST, BG_HAKA_TRAP_SPIKED_WALL_WEST
void BgHakaTrap_UpdateBodyColliderPos(BgHakaTrap* this, PlayState* play) {
f32 cos;
Vec3f colOff;
f32 sin;
- f32 zSign;
Player* player = GET_PLAYER(play);
Actor_WorldToActorCoords(&this->dyna.actor, &colOff, &player->actor.world.pos);
-
sin = Math_SinS(this->dyna.actor.shape.rot.y);
cos = Math_CosS(this->dyna.actor.shape.rot.y);
-
- if (this->dyna.actor.params == HAKA_TRAP_GUILLOTINE) {
+ if (this->dyna.actor.params == BG_HAKA_TRAP_GUILLOTINE) {
colOff.x = CLAMP(colOff.x, -50.0f, 50.0f);
- zSign = (colOff.z >= 0.0f) ? 1.0f : -1.0f;
- colOff.z = zSign * -15.0f;
+ colOff.z = ((colOff.z >= 0.0f) ? 1.0f : -1.0f) * -15.0f;
} else {
colOff.x = -CLAMP(colOff.x, -162.0f, 162.0f);
- zSign = (colOff.z >= 0.0f) ? 1.0f : -1.0f;
- colOff.z = zSign * 15.0f;
+ colOff.z = ((colOff.z >= 0.0f) ? 1.0f : -1.0f) * 15.0f;
}
-
- this->colliderCylinder.dim.pos.x = this->dyna.actor.world.pos.x + colOff.x * cos + colOff.z * sin;
- this->colliderCylinder.dim.pos.z = this->dyna.actor.world.pos.z + colOff.x * sin + colOff.z * cos;
+ this->colliderCylinder.dim.pos.x = this->dyna.actor.world.pos.x + (colOff.x * cos) + (colOff.z * sin);
+ this->colliderCylinder.dim.pos.z = this->dyna.actor.world.pos.z + (colOff.x * sin) + (colOff.z * cos);
}
#define BGHAKATRAP_SPIKEDWALL_HITEAST (1 << 0)
@@ -279,22 +268,22 @@ void BgHakaTrap_UpdateBodyColliderPos(BgHakaTrap* this, PlayState* play) {
void BgHakaTrap_SpikedWall_CloseIn(BgHakaTrap* this, PlayState* play) {
static s32 sSpikedWallFlags = 0;
+
Player* player = GET_PLAYER(play);
if (!sIsSpikeWallBurning && !Player_InCsMode(play)) {
- // Step towards the home position. If we haven't reached it, play the sliding sfx
- if (!Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x, 0.5f)) {
+ if (Math_StepToF(&this->dyna.actor.world.pos.x, this->dyna.actor.home.pos.x, 0.5f) == 0) {
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_TRAP_OBJ_SLIDE - SFX_FLAG);
- } else if (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_EAST) {
- sSpikedWallFlags |= BGHAKATRAP_SPIKEDWALL_HITEAST;
- } else if (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_WEST) {
- sSpikedWallFlags |= BGHAKATRAP_SPIKEDWALL_HITWEST;
+ } else {
+ if (this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_WALL_EAST) {
+ sSpikedWallFlags |= BGHAKATRAP_SPIKEDWALL_HITEAST;
+ } else if (this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_WALL_WEST) {
+ sSpikedWallFlags |= BGHAKATRAP_SPIKEDWALL_HITWEST;
+ }
}
}
-
BgHakaTrap_UpdateBodyColliderPos(this, play);
-
- if (this->spikesCollider.base.acFlags & AC_HIT) {
+ if (this->spikedWallCollider.base.acFlags & AC_HIT) {
this->timer = 20;
sIsSpikeWallBurning = true;
this->actionFunc = BgHakaTrap_SpikedWall_Burn;
@@ -305,29 +294,22 @@ void BgHakaTrap_SpikedWall_CloseIn(BgHakaTrap* this, PlayState* play) {
}
void BgHakaTrap_SpikedWall_Burn(BgHakaTrap* this, PlayState* play) {
- static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f };
- Vec3f vector;
- f32 xScale;
+ static Vec3f sEffVelAccel = { 0.0f, 0.0f, 0.0f };
+ Vec3f effPos;
s32 i;
if (this->timer != 0) {
this->timer--;
}
-
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_BURN_OUT - SFX_FLAG);
-
for (i = 0; i < 2; i++) {
- f32 rand = Rand_ZeroOne();
-
- xScale = (this->dyna.actor.params == HAKA_TRAP_SPIKED_WALL_EAST) ? -30.0f : 30.0f;
-
- vector.x = xScale * rand + this->dyna.actor.world.pos.x;
- vector.y = Rand_ZeroOne() * 10.0f + this->dyna.actor.world.pos.y + 30.0f;
- vector.z = Rand_CenteredFloat(320.0f) + this->dyna.actor.world.pos.z;
-
- EffectSsDeadDb_Spawn(play, &vector, &zeroVec, &zeroVec, 130, 20, 255, 255, 150, 170, 255, 0, 0, 1, 9, false);
+ effPos.x = (Rand_ZeroOne() * ((this->dyna.actor.params == BG_HAKA_TRAP_SPIKED_WALL_EAST) ? -30.0f : 30.0f)) +
+ this->dyna.actor.world.pos.x;
+ effPos.y = (Rand_ZeroOne() * 10.0f) + this->dyna.actor.world.pos.y + 30.0f;
+ effPos.z = Rand_CenteredFloat(320.0f) + this->dyna.actor.world.pos.z;
+ EffectSsDeadDb_Spawn(play, &effPos, &sEffVelAccel, &sEffVelAccel, 130, 20, 255, 255, 150, 170, 255, 0, 0, 1, 9,
+ false);
}
-
if (this->timer == 0) {
sIsSpikeWallBurning = false;
Actor_Kill(&this->dyna.actor);
@@ -343,28 +325,26 @@ void BgHakaTrap_Guillotine_Fall(BgHakaTrap* this, PlayState* play) {
} else {
this->dyna.actor.velocity.y *= 2.0f;
}
-
if (this->timer != 0) {
this->timer -= 1;
}
-
isDoneFalling =
Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 185.0f, this->dyna.actor.velocity.y);
timer = this->timer;
-
- if ((timer == 10 && !this->isGuillotineFast) || (timer == 13 && this->isGuillotineFast)) {
+ if (((timer == 10) && !this->isGuillotineFast) || ((timer == 13) && this->isGuillotineFast)) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GUILLOTINE_BOUND);
}
-
if (this->timer == 0) {
this->dyna.actor.velocity.y = 0.0f;
- this->timer = (this->isGuillotineFast) ? 10 : 40;
+ if (this->isGuillotineFast) {
+ this->timer = 10;
+ } else {
+ this->timer = 40;
+ }
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GUILLOTINE_UP);
this->actionFunc = BgHakaTrap_Guillotine_Lift;
}
-
BgHakaTrap_UpdateBodyColliderPos(this, play);
-
if (!isDoneFalling) {
CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderCylinder.base);
}
@@ -374,9 +354,7 @@ void BgHakaTrap_Guillotine_Lift(BgHakaTrap* this, PlayState* play) {
if (this->timer != 0) {
this->timer--;
}
-
if (this->isGuillotineFast) {
-
Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 27.0f);
} else {
if (this->timer > 20) {
@@ -384,76 +362,63 @@ void BgHakaTrap_Guillotine_Lift(BgHakaTrap* this, PlayState* play) {
} else {
Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.5f);
}
-
if (this->timer == 20) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GUILLOTINE_UP);
}
}
-
if (this->timer == 0) {
this->timer = 20;
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y;
this->dyna.actor.velocity.y = 0.1f;
this->actionFunc = BgHakaTrap_Guillotine_Fall;
}
-
BgHakaTrap_UpdateBodyColliderPos(this, play);
}
void BgHakaTrap_SpikedCrusher_Fall(BgHakaTrap* this, PlayState* play) {
- Vec3f vector;
- f32 floorHeight;
+ Vec3f pos;
f32 yIntersect;
+ f32 floorHeight;
s32 i;
s32 bgId;
this->dyna.actor.velocity.y *= 1.6f;
-
if (this->timer != 0) {
this->timer--;
}
-
// Perform a collision check for the "stone umbrella" block
// Because of the shape of the room and the size of the block we only need to check three positions,
// the center of the east edge, the centerpoint, and the center of the west edge of the crusher.
//
// The y coordinate is offset by 25 units, as the crusher is allowed to clip into the floor for visual effect.
-
- vector.x = this->dyna.actor.world.pos.x + 90.0f;
- vector.y = (this->dyna.actor.world.pos.y + 1.0f) + 25.0f;
- vector.z = this->dyna.actor.world.pos.z;
-
+ pos.x = this->dyna.actor.world.pos.x + 90.0f;
+ pos.y = this->dyna.actor.world.pos.y + 1.0f + 25.0f;
+ pos.z = this->dyna.actor.world.pos.z;
// actor.floorHeight is storing the minimum y position of the crusher
floorHeight = this->dyna.actor.floorHeight;
-
for (i = 0; i < 3; i++) {
yIntersect =
- BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &vector) -
+ BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &pos) -
25.0f;
if (floorHeight < yIntersect) {
floorHeight = yIntersect;
}
-
- vector.x -= 90.0f;
+ pos.x -= 90.0f;
}
-
- if (Math_StepToF(&this->dyna.actor.world.pos.y, floorHeight, this->dyna.actor.velocity.y)) {
+ if (Math_StepToF(&this->dyna.actor.world.pos.y, floorHeight, this->dyna.actor.velocity.y) != 0) {
if (this->dyna.actor.velocity.y > 0.01f) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_TRAP_BOUND);
}
this->dyna.actor.velocity.y = 0.0f;
}
-
if (this->dyna.actor.velocity.y >= 0.01f) {
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_CHINETRAP_DOWN - SFX_FLAG);
}
-
if (this->timer == 0) {
this->dyna.actor.velocity.y = 0.0f;
this->timer = 30;
this->spikedCrusherStepY = (s16)this->dyna.actor.world.pos.y + 50.0f;
- this->spikedCrusherStepY = CLAMP_MAX(this->spikedCrusherStepY, this->dyna.actor.home.pos.y);
-
+ this->spikedCrusherStepY = MIN(this->dyna.actor.home.pos.y, this->spikedCrusherStepY);
this->actionFunc = BgHakaTrap_SpikedCrusher_Lift;
}
}
@@ -462,14 +427,12 @@ void BgHakaTrap_SpikedCrusher_Lift(BgHakaTrap* this, PlayState* play) {
if (this->timer != 0) {
this->timer--;
}
-
if (this->timer > 20) {
this->isSpikedCrusherStationary = Math_StepToF(&this->dyna.actor.world.pos.y, this->spikedCrusherStepY, 15.0f);
} else {
this->isSpikedCrusherStationary =
Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 20.0f);
}
-
if (this->timer == 0) {
this->timer = 30;
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y;
@@ -482,7 +445,6 @@ void BgHakaTrap_FanBlade_Idle(BgHakaTrap* this, PlayState* play) {
if (this->timer != 0) {
this->timer -= 1;
}
-
if (this->timer == 0) {
// this->timer = 0, which signals the fan to turn on and speed up
this->actionFunc = BgHakaTrap_FanBlade_ToggleFanGust;
@@ -494,11 +456,10 @@ void BgHakaTrap_PushPlayer(BgHakaTrap* this, PlayState* play, s16 angularVelocit
Vec3f playerRelOff;
Actor_WorldToActorCoords(&this->dyna.actor, &playerRelOff, &player->actor.world.pos);
-
if ((fabsf(playerRelOff.x) < 70.0f) && (fabsf(playerRelOff.y) < 100.0f) && (playerRelOff.z < 500.0f) &&
- (GET_PLAYER(play)->currentBoots != PLAYER_BOOTS_IRON)) {
+ (GET_PLAYER(play)->currentBoots != 1)) {
player->pushedSpeed =
- ((500.0f - playerRelOff.z) * 0.06f + 5.0f) * angularVelocity * (1.0f / 0x3A00) * (2.0f / 3.0f);
+ (((500.0f - playerRelOff.z) * 0.06f) + 5.0f) * angularVelocity * (1.0f / 0x3A00) * (2.0f / 3.0f);
player->pushedYaw = this->dyna.actor.shape.rot.y;
}
}
@@ -511,23 +472,21 @@ void BgHakaTrap_FanBlade_ToggleFanGust(BgHakaTrap* this, PlayState* play) {
// world.rot.z is the current angular velocity of the fan
if (this->timer != 0) {
// Fan winds down
- if (Math_ScaledStepToS(&this->dyna.actor.world.rot.z, 0, this->dyna.actor.world.rot.z * 0.03f + 5.0f)) {
+ if (Math_ScaledStepToS(&this->dyna.actor.world.rot.z, 0, (this->dyna.actor.world.rot.z * 0.03f) + 5.0f)) {
this->timer = 40;
this->actionFunc = BgHakaTrap_FanBlade_Idle;
}
} else {
// Fan speeds up
- if (Math_ScaledStepToS(&this->dyna.actor.world.rot.z, 0x3A00, this->dyna.actor.world.rot.z * 0.03f + 5.0f)) {
+ if (Math_ScaledStepToS(&this->dyna.actor.world.rot.z, 0x3A00, (this->dyna.actor.world.rot.z * 0.03f) + 5.0f)) {
this->timer = 100;
this->actionFunc = BgHakaTrap_FanBlade_FullGust;
}
}
-
this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z;
if (this->dyna.actor.world.rot.z > 0x1800) {
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_WIND_TRAP - SFX_FLAG);
}
-
BgHakaTrap_PushPlayer(this, play, this->dyna.actor.world.rot.z);
}
@@ -535,14 +494,11 @@ void BgHakaTrap_FanBlade_FullGust(BgHakaTrap* this, PlayState* play) {
if (this->timer != 0) {
this->timer--;
}
-
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_WIND_TRAP - SFX_FLAG);
-
if (this->timer == 0) {
this->timer = 1; // setting this signals the fan to turn off and slow down
this->actionFunc = BgHakaTrap_FanBlade_ToggleFanGust;
}
-
// world.rot.z is the current angular velocity of the fan
this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z;
BgHakaTrap_PushPlayer(this, play, this->dyna.actor.world.rot.z);
@@ -550,21 +506,19 @@ void BgHakaTrap_FanBlade_FullGust(BgHakaTrap* this, PlayState* play) {
void BgHakaTrap_Update(Actor* thisx, PlayState* play) {
BgHakaTrap* this = (BgHakaTrap*)thisx;
- Vec3f* actorPos = &this->dyna.actor.world.pos;
+ s32 pad;
this->actionFunc(this, play);
- if ((this->dyna.actor.params != HAKA_TRAP_FAN_BLADE) && (thisx->params != HAKA_TRAP_SPIKED_CRUSHER)) {
- this->colliderCylinder.dim.pos.y = actorPos->y;
-
- if ((thisx->params == HAKA_TRAP_GUILLOTINE) || (thisx->params == HAKA_TRAP_GUILLOTINE_FAST)) {
+ if ((thisx->params != BG_HAKA_TRAP_FAN_BLADE) && (thisx->params != BG_HAKA_TRAP_SPIKED_CRUSHER)) {
+ this->colliderCylinder.dim.pos.y = this->dyna.actor.world.pos.y;
+ if ((thisx->params == BG_HAKA_TRAP_GUILLOTINE) || (thisx->params == BG_HAKA_TRAP_GUILLOTINE_FAST)) {
CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base);
CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base);
} else {
if (this->actionFunc == BgHakaTrap_SpikedWall_CloseIn) {
- CollisionCheck_SetAC(play, &play->colChkCtx, &this->spikesCollider.base);
+ CollisionCheck_SetAC(play, &play->colChkCtx, &this->spikedWallCollider.base);
}
-
CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderCylinder.base);
}
}
@@ -576,17 +530,17 @@ void BgHakaTrap_SpikedWall_UpdateCollider(BgHakaTrap* this) {
Matrix_MultVec3f(&sSpikedWallTrisElementsInit[0].dim.vtx[0], &vtx[0]);
Matrix_MultVec3f(&sSpikedWallTrisElementsInit[0].dim.vtx[1], &vtx[1]);
Matrix_MultVec3f(&sSpikedWallTrisElementsInit[0].dim.vtx[2], &vtx[2]);
- Collider_SetTrisVertices(&this->spikesCollider, 0, &vtx[0], &vtx[1], &vtx[2]);
-
+ Collider_SetTrisVertices(&this->spikedWallCollider, 0, &vtx[0], &vtx[1], &vtx[2]);
Matrix_MultVec3f(&sSpikedWallTrisElementsInit[1].dim.vtx[2], &vtx[1]);
- Collider_SetTrisVertices(&this->spikesCollider, 1, &vtx[0], &vtx[2], &vtx[1]);
+ Collider_SetTrisVertices(&this->spikedWallCollider, 1, &vtx[0], &vtx[2], &vtx[1]);
}
+Gfx* D_80881028[5] = {
+ gShadowTempleGuillotineDL, gShadowTempleSpikedCrusherDL, gShadowTempleSpikedWallEastDL,
+ gShadowTempleSpikedWallWestDL, gShadowTempleFanBladeDL,
+};
+
void BgHakaTrap_Draw(Actor* thisx, PlayState* play) {
- static Gfx* sDLists[5] = {
- gShadowTempleGuillotineDL, gShadowTempleSpikedCrusherDL, gShadowTempleSpikedWallEastDL,
- gShadowTempleSpikedWallWestDL, gShadowTempleFanBladeDL,
- };
static Color_RGBA8 sFogBlack = { 0, 0, 0, 0 };
BgHakaTrap* this = (BgHakaTrap*)thisx;
STACK_PAD(s32);
@@ -594,24 +548,19 @@ void BgHakaTrap_Draw(Actor* thisx, PlayState* play) {
if (this->actionFunc == BgHakaTrap_SpikedWall_Burn) {
func_80026230(play, &sFogBlack, this->timer + 20, 40);
}
-
- Gfx_DrawDListOpa(play, sDLists[this->dyna.actor.params]);
-
+ Gfx_DrawDListOpa(play, D_80881028[this->dyna.actor.params]);
if (this->actionFunc == BgHakaTrap_SpikedWall_CloseIn) {
BgHakaTrap_SpikedWall_UpdateCollider(this);
}
-
if (this->actionFunc == BgHakaTrap_SpikedWall_Burn) {
func_80026608(play);
}
-
- if ((this->actionFunc == BgHakaTrap_SpikedCrusher_Lift) && !this->isSpikedCrusherStationary) {
+ if ((this->actionFunc == BgHakaTrap_SpikedCrusher_Lift) && ((u8)this->isSpikedCrusherStationary == 0)) {
Vec3f sfxPos;
sfxPos.x = this->dyna.actor.world.pos.x;
sfxPos.z = this->dyna.actor.world.pos.z;
sfxPos.y = this->dyna.actor.world.pos.y + 110.0f;
-
SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &sfxPos, &this->chainLiftSfxPos);
Sfx_PlaySfxAtPos(&this->chainLiftSfxPos, NA_SE_EV_BRIDGE_CLOSE - SFX_FLAG);
}
diff --git a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.h b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.h
index 14c7c7a1a..a690c9f80 100644
--- a/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.h
+++ b/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.h
@@ -4,33 +4,33 @@
#include "ultra64.h"
#include "actor.h"
-typedef enum HakaTrapType {
- /* 0x00 */ HAKA_TRAP_GUILLOTINE,
- /* 0x01 */ HAKA_TRAP_SPIKED_CRUSHER,
- /* 0x02 */ HAKA_TRAP_SPIKED_WALL_EAST,
- /* 0x03 */ HAKA_TRAP_SPIKED_WALL_WEST,
- /* 0x04 */ HAKA_TRAP_FAN_BLADE,
- /* 0x05 */ HAKA_TRAP_GUILLOTINE_FAST
-} HakaTrapType;
+typedef enum BgHakaTrapType {
+ /* 0 */ BG_HAKA_TRAP_GUILLOTINE,
+ /* 1 */ BG_HAKA_TRAP_SPIKED_CRUSHER,
+ /* 2 */ BG_HAKA_TRAP_SPIKED_WALL_EAST,
+ /* 3 */ BG_HAKA_TRAP_SPIKED_WALL_WEST,
+ /* 4 */ BG_HAKA_TRAP_FAN_BLADE,
+ /* 5 */ BG_HAKA_TRAP_GUILLOTINE_FAST
+} BgHakaTrapType;
struct BgHakaTrap;
typedef void (*BgHakaTrapActionFunc)(struct BgHakaTrap*, struct PlayState*);
typedef struct BgHakaTrap {
- /* 0x0000 */ DynaPolyActor dyna;
- /* 0x0164 */ BgHakaTrapActionFunc actionFunc;
- /* 0x0168 */ u8 timer;
- /* 0x0169 */ u8 isSpikedCrusherStationary;
+ /* 0x000 */ DynaPolyActor dyna;
+ /* 0x164 */ BgHakaTrapActionFunc actionFunc;
+ /* 0x168 */ u8 timer;
+ /* 0x169 */ s8 isSpikedCrusherStationary;
/* 0x016A */ union {
s16 isGuillotineFast; // 0 slow, 1 fast
s16 spikedCrusherStepY; // when lifting the crusher, it will pause briefly at this height before being
// lifted to its maximum height
};
- /* 0x016C */ Vec3f chainLiftSfxPos;
- /* 0x0178 */ ColliderCylinder colliderCylinder;
- /* 0x01C4 */ ColliderTris spikesCollider;
- /* 0x01E4 */ ColliderTrisElement spikesColliderElements[2];
-} BgHakaTrap; // size = 0x029C
+ /* 0x16C */ Vec3f chainLiftSfxPos;
+ /* 0x178 */ ColliderCylinder colliderCylinder;
+ /* 0x1C4 */ ColliderTris spikedWallCollider;
+ /* 0x1E4 */ ColliderTrisElement spikedWallColliderElements[2];
+} BgHakaTrap; // size = 0x29C
#endif