mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 06:24:30 +00:00
Fix and cleanup ovl_En_Tubo_Trap (4/7 matched)
This commit is contained in:
parent
373dc7d2d8
commit
85237605e2
11 changed files with 207 additions and 514 deletions
|
@ -4,24 +4,16 @@
|
|||
* Description: Flying pot enemy
|
||||
*/
|
||||
|
||||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
#include "z_en_tubo_trap.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ ActorFunc playfunc;
|
||||
/* 0x0150 */ f32 pos_y_seek;
|
||||
/* 0x0154 */ Vec3f pos_init;
|
||||
/* 0x0160 */ ColliderCylinderMain capsule;
|
||||
} EnTuboTrap; // size = 0x01AC
|
||||
#include <vt.h>
|
||||
|
||||
void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx);
|
||||
|
||||
#define ROOM 0x00
|
||||
|
@ -44,7 +36,7 @@ static ColliderCylinderInit cylinderInitData =
|
|||
0x0000, 0x0000, 0x0000
|
||||
};
|
||||
|
||||
ActorInit En_Tubo_Trap_InitVars =
|
||||
const ActorInit En_Tubo_Trap_InitVars =
|
||||
{
|
||||
ACTOR_EN_TUBO_TRAP,
|
||||
ACTORTYPE_PROP,
|
||||
|
@ -58,321 +50,277 @@ ActorInit En_Tubo_Trap_InitVars =
|
|||
(ActorFunc)EnTuboTrap_Draw,
|
||||
};
|
||||
|
||||
extern u32 DL_SHARD;
|
||||
extern u32 DL_TUBO;
|
||||
extern UNK_TYPE D_05017A60;
|
||||
extern Gfx D_05017870[];
|
||||
|
||||
void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s32 pad;
|
||||
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 2.0f);
|
||||
osSyncPrintf("\n\n");
|
||||
osSyncPrintf("\x1b[32m☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n\x1b[m", this->actor.params);
|
||||
ActorCollider_AllocCylinder(globalCtx, &this->capsule);
|
||||
ActorCollider_InitCylinder(globalCtx, &this->capsule, &this->actor, &cylinderInitData);
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); // "Urn Trap"
|
||||
ActorCollider_AllocCylinder(globalCtx, &this->collider);
|
||||
ActorCollider_InitCylinder(globalCtx, &this->collider, &this->actor, &cylinderInitData);
|
||||
Actor_SetScale(&this->actor, 0.1f);
|
||||
this->playfunc = (ActorFunc*)EnTuboTrap_TestLevitate;
|
||||
this->actionFunc = (ActorFunc)EnTuboTrap_WaitForProximity;
|
||||
}
|
||||
|
||||
void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
ColliderCylinderMain* capsule = &this->capsule;
|
||||
ActorCollider_FreeCylinder(globalCtx, capsule);
|
||||
ColliderCylinderMain* collider = &this->collider;
|
||||
ActorCollider_FreeCylinder(globalCtx, collider);
|
||||
}
|
||||
|
||||
void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s16 params = this->actor.params;
|
||||
s16 param1 = (params >> 6) & 0x03FF;
|
||||
if (param1 >= 0 && param1 < 0x1A)
|
||||
s16 param3FF = (params >> 6) & 0x3FF;
|
||||
if (param3FF >= 0 && param3FF < 0x1A)
|
||||
{
|
||||
Item_DropCollectible(globalCtx, &this->actor.posRot, param1 | ((params & 0x03F) << 8));
|
||||
Item_DropCollectible(globalCtx, &this->actor.posRot, param3FF | ((params & 0x3F) << 8));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_Fragments(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnWaterFragments
|
||||
void EnTuboTrap_SpawnFragments(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
u32 uVar1;
|
||||
s32 rando_seed = 0;
|
||||
s32 shard_count = 0;
|
||||
Vec3f* actorPos;
|
||||
f32 rand;
|
||||
f32 cos;
|
||||
f32 sin;
|
||||
u32 addr;
|
||||
Vec3f spC8;
|
||||
Vec3f spBC;
|
||||
s16 var;
|
||||
s32 temp;
|
||||
s32 i;
|
||||
|
||||
/* spawn fragments */
|
||||
do
|
||||
addr = &D_05017A60;
|
||||
actorPos = &this->actor.posRot.pos;
|
||||
|
||||
for (i = 0, var = 0; i < 15; i++, var += 20000)
|
||||
{
|
||||
Vec3f burst_depth[2];
|
||||
f32 rng;
|
||||
sin = Math_Sins(var);
|
||||
cos = Math_Coss(var);
|
||||
spC8.x = sin * 8.0f;
|
||||
spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
spC8.z = cos * 8.0f;
|
||||
|
||||
/* burst_depth_x */
|
||||
burst_depth[0].x = Math_Sins(rando_seed) * 8.0f;
|
||||
burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
burst_depth[0].z = Math_Coss(rando_seed) * 8.0f;
|
||||
spBC.x = spC8.x * 0.23f;
|
||||
spBC.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
spBC.z = spC8.z * 0.23f;
|
||||
|
||||
/* burst_depth_y */
|
||||
burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f);
|
||||
burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f);
|
||||
spC8.x += actorPos->x;
|
||||
spC8.y += actorPos->y;
|
||||
spC8.z += actorPos->z;
|
||||
|
||||
VEC3_ADD(burst_depth[0], this->actor.posRot.pos)
|
||||
|
||||
rng = Math_Rand_ZeroOne();
|
||||
|
||||
if (rng < 0.2f)
|
||||
{
|
||||
uVar1 = 0x60;
|
||||
}
|
||||
rand = Math_Rand_ZeroOne();
|
||||
if (rand < 0.2f)
|
||||
temp = 96;
|
||||
else if (rand < 0.6f)
|
||||
temp = 64;
|
||||
else
|
||||
{
|
||||
uVar1 = 0x20;
|
||||
temp = 32;
|
||||
|
||||
if (rng < 0.6f)
|
||||
{
|
||||
uVar1 = 0x40;
|
||||
}
|
||||
}
|
||||
|
||||
/* The Heavy Lifting */
|
||||
Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1, 10, 10, 0,
|
||||
(Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD);
|
||||
|
||||
shard_count++;
|
||||
rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10;
|
||||
Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -240, temp, 10, 10, 0,
|
||||
(Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 60, -1, 3, addr);
|
||||
}
|
||||
while(shard_count != 15);
|
||||
|
||||
func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0);
|
||||
func_80033480(globalCtx, actorPos, 30.0f, 4, 20, 50, 0);
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s")
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_FragmentsWater(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnFragments
|
||||
void EnTuboTrap_SpawnWaterFragments(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
u32 uVar1;
|
||||
s32 rando_seed = 0;
|
||||
s32 shard_count = 0;
|
||||
Vec3f burst_depth[2];
|
||||
f32 rng;
|
||||
Vec3f* actorPos;
|
||||
f32 rand;
|
||||
f32 cos;
|
||||
f32 sin;
|
||||
u32 addr;
|
||||
Vec3f spC8;
|
||||
Vec3f spBC;
|
||||
s16 var;
|
||||
s32 temp;
|
||||
s32 i;
|
||||
|
||||
Math_Vec3f_Copy(&burst_depth[0], &this->actor.posRot.pos);
|
||||
burst_depth[0].y += this->actor.waterSurfaceDist;
|
||||
addr = &D_05017A60;
|
||||
actorPos = &this->actor.posRot.pos;
|
||||
|
||||
/* spawn a small splash */
|
||||
func_8002949C(globalCtx, &burst_depth[0], 0, 0, 0, 0x190);
|
||||
spC8 = *actorPos;
|
||||
spC8.y += this->actor.unk_84;
|
||||
|
||||
/* spawn fragments */
|
||||
do
|
||||
func_8002949C(globalCtx, &spC8, 0, 0, 0, 400);
|
||||
|
||||
for (i = 0, var = 0; i < 15; i++, var += 20000)
|
||||
{
|
||||
/* burst_depth_x */
|
||||
burst_depth[0].x = Math_Sins(rando_seed) * 8.0f;
|
||||
burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
burst_depth[0].z = Math_Coss(rando_seed) * 8.0f;
|
||||
sin = Math_Sins(var);
|
||||
cos = Math_Coss(var);
|
||||
spC8.x = sin * 8.0f;
|
||||
spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
spC8.z = cos * 8.0f;
|
||||
|
||||
/* burst_depth_y */
|
||||
burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f);
|
||||
burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f;
|
||||
burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f);
|
||||
spBC.x = spC8.x * 0.23f;
|
||||
spBC.y = (Math_Rand_ZeroOne() * 4.0f) + 2.0f;
|
||||
spBC.z = spC8.z * 0.23f;
|
||||
|
||||
VEC3_ADD(burst_depth[0], this->actor.posRot.pos)
|
||||
spC8.x += actorPos->x;
|
||||
spC8.y += actorPos->y;
|
||||
spC8.z += actorPos->z;
|
||||
|
||||
rng = Math_Rand_ZeroOne();
|
||||
|
||||
if (rng < 0.2f)
|
||||
{
|
||||
uVar1 = 0x60;
|
||||
}
|
||||
rand = Math_Rand_ZeroOne();
|
||||
if (rand < 0.2f)
|
||||
temp = 64;
|
||||
else
|
||||
{
|
||||
uVar1 = 0x20;
|
||||
temp = 32;
|
||||
|
||||
if (rng < 0.6f)
|
||||
{
|
||||
uVar1 = 0x40;
|
||||
}
|
||||
}
|
||||
|
||||
/* The Heavy Lifting */
|
||||
Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1,
|
||||
10, 10, 0, (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD);
|
||||
shard_count++;
|
||||
rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10;
|
||||
Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -180, temp, 30, 30, 0,
|
||||
(Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 70, -1, 3, addr);
|
||||
}
|
||||
while(shard_count != 15);
|
||||
|
||||
func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0);
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s")
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_TestCollider(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
u8 bVar1, bVar2;
|
||||
u16 uVar3;
|
||||
Actor* collided_this;
|
||||
s32 pad;
|
||||
Player* player = PLAYER;
|
||||
|
||||
if (!(this->actor.bgCheckFlags & 20))
|
||||
if ((this->actor.bgCheckFlags & 0x20) && (this->actor.unk_84 > 15.0f))
|
||||
{
|
||||
bVar1 = this->capsule.base.colliderFlags;
|
||||
EnTuboTrap_SpawnWaterFragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (this->collider.base.colliderFlags & 4)
|
||||
{
|
||||
if (this->actor.waterSurfaceDist > 15.0f)
|
||||
this->collider.base.colliderFlags &= ~4;
|
||||
EnTuboTrap_SpawnFragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->collider.base.collideFlags & 2)
|
||||
{
|
||||
this->collider.base.collideFlags &= ~2;
|
||||
EnTuboTrap_SpawnFragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_EXPLOSION);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->collider.base.colliderFlags & 2)
|
||||
{
|
||||
this->collider.base.colliderFlags &= ~2;
|
||||
if (this->collider.base.at == &player->actor)
|
||||
{
|
||||
EnTuboTrap_FragmentsWater(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER);
|
||||
EnTuboTrap_SpawnFragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 40, 0x83E);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
|
||||
bVar1 = this->capsule.base.collideFlags;
|
||||
}
|
||||
|
||||
if (!(bVar1 & 4))
|
||||
if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1))
|
||||
{
|
||||
bVar2 = this->capsule.base.collideFlags;
|
||||
if (!(bVar2 & 2))
|
||||
{
|
||||
if (!(bVar1 & 2))
|
||||
{
|
||||
uVar3 = this->actor.bgCheckFlags;
|
||||
}
|
||||
else
|
||||
{
|
||||
collided_this = this->capsule.base.actor;
|
||||
this->capsule.base.colliderFlags = bVar1 & 0xFD;
|
||||
|
||||
if (collided_this == &player->actor)
|
||||
{
|
||||
EnTuboTrap_Fragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 0x28, NA_SE_PL_BODY_HIT);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
uVar3 = this->actor.bgCheckFlags;
|
||||
}
|
||||
|
||||
if ((uVar3 & 8) || (uVar3 & 1))
|
||||
{
|
||||
EnTuboTrap_Fragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->capsule.base.collideFlags = bVar2 & 0xFD;
|
||||
EnTuboTrap_Fragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_EXPLOSION);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->capsule.base.colliderFlags = bVar1 & 0xFB;
|
||||
EnTuboTrap_Fragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_IT_SHIELD_REFLECT_SW);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
|
||||
EnTuboTrap_SpawnFragments(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
|
||||
EnTuboTrap_DropCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s")
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
Player* player = PLAYER;
|
||||
f32 seekY;
|
||||
f32 targetHeight;
|
||||
|
||||
if (BREG(2) != 0)
|
||||
{
|
||||
osSyncPrintf("[32m☆☆☆☆☆ わて ☆☆☆☆☆ %f\n", globalCtx, this->actor.posRot.pos.y);
|
||||
osSyncPrintf("[32m☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n");
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わて ☆☆☆☆☆ %f\n" VT_RST, this->actor.posRot.pos.y); // "You"
|
||||
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n" VT_RST, player->actor.posRot.pos.y); // "Me"
|
||||
osSyncPrintf("\n\n");
|
||||
}
|
||||
|
||||
if (this->actor.xzDistanceFromLink < 200.00000000 && this->actor.posRot.pos.y <= player->actor.posRot.pos.y)
|
||||
if (this->actor.xzDistanceFromLink < 200.0f && this->actor.posRot.pos.y <= player->actor.posRot.pos.y)
|
||||
{
|
||||
Actor_ChangeType(globalCtx, &globalCtx->actorCtx, this, ACTORTYPE_ENEMY);
|
||||
this->actor.flags |= 1;
|
||||
seekY = (f32)gSaveContext.link_age * -10.00000000 + 40.00000000;
|
||||
this->pos_y_seek = player->actor.posRot.pos.y;
|
||||
targetHeight = 40.0f + -10.0f * gSaveContext.link_age;
|
||||
|
||||
if (this->pos_y_seek < this->actor.posRot.pos.y)
|
||||
this->pos_y_seek = this->actor.posRot.pos.y + seekY;
|
||||
|
||||
this->actor.initPosRot.pos = this->actor.posRot.pos;
|
||||
this->targetY = player->actor.posRot.pos.y + targetHeight;
|
||||
if (this->targetY < this->actor.posRot.pos.y)
|
||||
this->targetY = this->actor.posRot.pos.y + targetHeight;
|
||||
|
||||
this->originPos = this->actor.posRot.pos;
|
||||
Audio_PlayActorSound2(this, NA_SE_EV_POT_MOVE_START);
|
||||
this->playfunc = (ActorFunc)EnTuboTrap_InitializeAttack;
|
||||
this->actionFunc = (ActorFunc)EnTuboTrap_Levitate;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s")
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
this->actor.posRot.rot.y += 5000;
|
||||
Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->pos_y_seek, 0.8f, 3.0f); /* Tween levitation */
|
||||
this->actor.shape.rot.y += 5000;
|
||||
Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->targetY, 0.8f, 3.0f);
|
||||
|
||||
if (ABS(this->actor.posRot.pos.y - this->pos_y_seek) < 10.0f)
|
||||
if (fabsf(this->actor.posRot.pos.y - this->targetY) < 10.0f)
|
||||
{
|
||||
this->actor.speedXZ = 10.0f;
|
||||
this->actor.posRot.rot.y = this->actor.rotTowardsLinkY;
|
||||
this->playfunc = (ActorFunc)EnTuboTrap_Fly;
|
||||
this->actionFunc = (ActorFunc)EnTuboTrap_Fly;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s")
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
Vec3f pos_delta;
|
||||
f32 dx = this->originPos.x - this->actor.posRot.pos.x;
|
||||
f32 dy = this->originPos.y - this->actor.posRot.pos.y;
|
||||
f32 dz = this->originPos.z - this->actor.posRot.pos.z;
|
||||
|
||||
VEC3_SUB(pos_delta, this->pos_init, this->actor.posRot.pos);
|
||||
Audio_PlayActorSound2(&this->actor, NA_SE_EN_TUBOOCK_FLY);
|
||||
Audio_PlayActorSound2(&this->actor, 0x3037);
|
||||
|
||||
if (240.0f < sqrtf(SQ(pos_delta.x) + SQ(pos_delta.y) + SQ(pos_delta.z)))
|
||||
Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); /* Tween to ground */
|
||||
if (240.0f < sqrtf(SQ(dx) + SQ(dy) + SQ(dz)))
|
||||
Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f);
|
||||
|
||||
this->actor.posRot.rot.y += 5000;
|
||||
EnTuboTrap_TestCollider(this, globalCtx);
|
||||
this->actor.shape.rot.y += 5000;
|
||||
EnTuboTrap_HandleImpact(this, globalCtx);
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s")
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
this->playfunc(this, globalCtx);
|
||||
Actor_MoveForward(&this->actor); /* Probably to haul ass towards Link */
|
||||
func_8002E4B4(globalCtx, &this->actor, 10.0f, 10.0f, 20.0f, 0x1D); /* Necessary for drawing a shadow */
|
||||
Actor_SetHeight(&this->actor, 0.0f);
|
||||
ActorCollider_Cylinder_Update(&this->actor, &this->capsule);
|
||||
Actor_CollisionCheck_SetAC(globalCtx, &globalCtx->sub_11E60, &this->capsule);
|
||||
Actor_CollisionCheck_SetAT(globalCtx, &globalCtx->sub_11E60, &this->capsule);
|
||||
EnTuboTrap* tuboTrap = this;
|
||||
SubGlobalContext11E60* sub_11E60 = &globalCtx->sub_11E60;
|
||||
|
||||
tuboTrap->actionFunc(tuboTrap, globalCtx);
|
||||
Actor_MoveForward(&tuboTrap->actor);
|
||||
func_8002E4B4(globalCtx, &tuboTrap->actor, 10.0f, 10.0f, 20.0f, 0x1D);
|
||||
Actor_SetHeight(&tuboTrap->actor, 0.0f);
|
||||
ActorCollider_Cylinder_Update(&tuboTrap->actor, &tuboTrap->collider);
|
||||
Actor_CollisionCheck_SetAC(globalCtx, sub_11E60, &tuboTrap->collider);
|
||||
Actor_CollisionCheck_SetAT(globalCtx, sub_11E60, &tuboTrap->collider);
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s")
|
||||
#endif
|
||||
|
||||
void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx)
|
||||
{
|
||||
Draw_DListOpa(globalCtx, &DL_TUBO);
|
||||
Draw_DListOpa(globalCtx, D_05017870);
|
||||
}
|
||||
|
|
18
src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h
Normal file
18
src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef _Z_EN_TUBO_TRAP_H_
|
||||
#define _Z_EN_TUBO_TRAP_H_
|
||||
|
||||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ ActorFunc actionFunc;
|
||||
/* 0x0150 */ f32 targetY;
|
||||
/* 0x0154 */ Vec3f originPos;
|
||||
/* 0x0160 */ ColliderCylinderMain collider;
|
||||
} EnTuboTrap; // size = 0x01AC
|
||||
|
||||
extern const ActorInit En_Tubo_Trap_InitVars;
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue