1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-06 14:20:11 +00:00

Bg_Haka_Sgami OK (#532)

* spinning scythe trap, 4/6 matching

* fixed typo

* Almost matched sgami init

* Matched sgami Init

* starting to clean up func_8087E858

* func_8087E858 half-way done

* Scythe matched

* update scythe

* Removed asm files

* Delete z_bg_haka_sgami.reloc.s

* Update src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>

* Update src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>

* Update src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>

* Update z_bg_haka_sgami.c

Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain>
Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
This commit is contained in:
Zelllll 2020-12-19 03:59:35 -06:00 committed by GitHub
parent 3369d0657d
commit eadf85f17c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 236 additions and 749 deletions

View file

@ -1,7 +1,7 @@
/*
* File: z_bg_haka_sgami.c
* Overlay: ovl_Bg_Haka_Sgami
* Description: Shadow Temple Spinning Scythe Trap
* Description: Spinning Scythe Trap
*/
#include "z_bg_haka_sgami.h"
@ -10,17 +10,25 @@
#define THIS ((BgHakaSgami*)thisx)
typedef enum {
/* 0 */ SCYTHE_TRAP_SHADOW_TEMPLE,
/* 1 */ SCYTHE_TRAP_SHADOW_TEMPLE_INVISIBLE,
/* 2 */ SCYTHE_TRAP_ICE_CAVERN
} SpinningScytheTrapMode;
#define SCYTHE_SPIN_TIME 32
void BgHakaSgami_Init(Actor* thisx, GlobalContext* globalCtx);
void BgHakaSgami_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgHakaSgami_Update(Actor* thisx, GlobalContext* globalCtx);
void BgHakaSgami_Draw(Actor* thisx, GlobalContext* globalCtx);
void func_8087E7E4(BgHakaSgami* this, GlobalContext* globalCtx);
void func_8087E858(BgHakaSgami* this, GlobalContext* globalCtx);
void func_8087EDC0(BgHakaSgami* this, GlobalContext* globalCtx);
void BgHakaSgami_SetupSpin(BgHakaSgami* this, GlobalContext* globalCtx);
void BgHakaSgami_Spin(BgHakaSgami* this, GlobalContext* globalCtx);
extern UNK_TYPE D_0600BF20;
extern Gfx D_0600BF20[];
extern Gfx D_060021F0[];
/*
const ActorInit Bg_Haka_Sgami_InitVars = {
ACTOR_BG_HAKA_SGAMI,
ACTORTYPE_PROP,
@ -32,15 +40,221 @@ const ActorInit Bg_Haka_Sgami_InitVars = {
(ActorFunc)BgHakaSgami_Update,
NULL,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Sgami/BgHakaSgami_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Sgami/BgHakaSgami_Destroy.s")
static ColliderTrisItemInit sTriItemsInit[] = {
{
{ 0x02, { 0x20000000, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, 0x01, 0x00, 0x00 },
{ { { 365.0f, 45.0f, 27.0f }, { 130.0f, 45.0f, 150.0f }, { 290.0f, 45.0f, 145.0f } } },
},
{
{ 0x02, { 0x20000000, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, 0x01, 0x00, 0x00 },
{ { { 250.0f, 45.0f, 90.0f }, { 50.0f, 45.0f, 80.0f }, { 160.0f, 45.0f, 160.0f } } },
},
{
{ 0x02, { 0x20000000, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, 0x01, 0x00, 0x00 },
{ { { -305.0f, 33.0f, -7.0f }, { -220.0f, 33.0f, 40.0f }, { -130.0f, 33.0f, -5.0f } } },
},
{
{ 0x02, { 0x20000000, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, 0x01, 0x00, 0x00 },
{ { { -190.0f, 33.0f, 40.0f }, { -30.0f, 33.0f, 15.0f }, { -70.0f, 33.0f, -30.0f } } },
},
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Sgami/func_8087E7E4.s")
static ColliderTrisInit sTrisInit = {
{ COLTYPE_UNK10, 0x11, 0x00, 0x00, 0x20, COLSHAPE_TRIS },
4,
sTriItemsInit,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Sgami/func_8087E858.s")
static ColliderCylinderInit sCylinderInit = {
{ COLTYPE_UNK10, 0x00, 0x00, 0x39, 0x20, COLSHAPE_CYLINDER },
{ 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 },
{ 80, 130, 0, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Sgami/BgHakaSgami_Update.s")
static CollisionCheckInfoInit sColChkInfoInit = { 0, 80, 130, 0xFF };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Sgami/func_8087EDC0.s")
static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE),
ICHAIN_U8(unk_1F, 4, ICHAIN_CONTINUE),
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
void BgHakaSgami_Init(Actor* thisx, GlobalContext* globalCtx) {
static u8 sP1StartColor[] = { 250, 250, 250, 200 };
static u8 sP2StartColor[] = { 200, 200, 200, 130 };
static u8 sP1EndColor[] = { 200, 200, 200, 60 };
static u8 sP2EndColor[] = { 150, 150, 150, 20 };
BgHakaSgami* this = THIS;
EffectBlureInit1 blureInit;
s32 i;
ColliderTris* colliderScythe = &this->colliderScythe;
Actor_ProcessInitChain(thisx, sInitChain);
this->unk_151 = thisx->params & 0xFF;
thisx->params = (thisx->params >> 8) & 0xFF;
if (this->unk_151 != 0) {
thisx->flags |= 0x80;
}
Collider_InitTris(globalCtx, colliderScythe);
Collider_SetTris(globalCtx, colliderScythe, thisx, &sTrisInit, this->colliderScytheItems);
Collider_InitCylinder(globalCtx, &this->colliderScytheCenter);
Collider_SetCylinder(globalCtx, &this->colliderScytheCenter, thisx, &sCylinderInit);
this->colliderScytheCenter.dim.pos.x = thisx->posRot.pos.x;
this->colliderScytheCenter.dim.pos.y = thisx->posRot.pos.y;
this->colliderScytheCenter.dim.pos.z = thisx->posRot.pos.z;
func_80061ED4(&thisx->colChkInfo, NULL, &sColChkInfoInit);
for (i = 0; i < 4; i++) {
blureInit.p1StartColor[i] = sP1StartColor[i];
blureInit.p2StartColor[i] = sP2StartColor[i];
blureInit.p1EndColor[i] = sP1EndColor[i];
blureInit.p2EndColor[i] = sP2EndColor[i];
}
blureInit.elemDuration = 10;
blureInit.unkFlag = false;
blureInit.calcMode = 2;
Effect_Add(globalCtx, &this->blureEffectIndex[0], EFFECT_BLURE1, 0, 0, &blureInit);
Effect_Add(globalCtx, &this->blureEffectIndex[1], EFFECT_BLURE1, 0, 0, &blureInit);
if (thisx->params == SCYTHE_TRAP_SHADOW_TEMPLE) {
this->requiredObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS);
thisx->flags &= ~1;
} else {
this->requiredObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_OBJECTS);
this->colliderScytheCenter.dim.radius = 30;
this->colliderScytheCenter.dim.height = 70;
Actor_SetHeight(thisx, 40.0f);
}
if (this->requiredObjBankIndex < 0) {
Actor_Kill(thisx);
return;
}
this->actionFunc = BgHakaSgami_SetupSpin;
}
void BgHakaSgami_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgHakaSgami* this = THIS;
Effect_Delete(globalCtx, this->blureEffectIndex[0]);
Effect_Delete(globalCtx, this->blureEffectIndex[1]);
Collider_DestroyTris(globalCtx, &this->colliderScythe);
Collider_DestroyCylinder(globalCtx, &this->colliderScytheCenter);
}
void BgHakaSgami_SetupSpin(BgHakaSgami* this, GlobalContext* globalCtx) {
if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) {
this->actor.objBankIndex = this->requiredObjBankIndex;
this->actor.draw = BgHakaSgami_Draw;
this->timer = SCYTHE_SPIN_TIME;
this->actor.flags &= ~0x10;
this->actionFunc = BgHakaSgami_Spin;
}
}
void BgHakaSgami_Spin(BgHakaSgami* this, GlobalContext* globalCtx) {
static Vec3f blureEffectVertices2[] = {
{ -20.0f, 50.0f, 130.0f },
{ -50.0f, 33.0f, 20.0f },
};
static Vec3f blureEffectVertices1[] = {
{ 380.0f, 50.0f, 50.0f },
{ 310.0f, 33.0f, 0.0f },
};
s32 i;
s32 j;
Vec3f scytheVertices[3];
f32 actorRotYSin;
f32 actorRotYCos;
s32 iterateCount;
ColliderTrisItemInit* colliderList;
if (this->timer != 0) {
this->timer--;
}
this->actor.shape.rot.y += ((s16)(512.0f * sinf(this->timer * (M_PI / 16.0f))) + 0x400) >> 1;
if (this->timer == 0) {
this->timer = SCYTHE_SPIN_TIME;
}
actorRotYSin = Math_Sins(this->actor.shape.rot.y);
actorRotYCos = Math_Coss(this->actor.shape.rot.y);
iterateCount = (this->actor.params != 0) ? 4 : 2;
for (i = iterateCount - 2; i < iterateCount; i++) {
colliderList = &sTrisInit.list[i];
for (j = 0; j < 3; j++) {
scytheVertices[j].x = this->actor.posRot.pos.x + colliderList->dim.vtx[j].z * actorRotYSin +
colliderList->dim.vtx[j].x * actorRotYCos;
scytheVertices[j].y = this->actor.posRot.pos.y + colliderList->dim.vtx[j].y;
scytheVertices[j].z = this->actor.posRot.pos.z + colliderList->dim.vtx[j].z * actorRotYCos -
colliderList->dim.vtx[j].x * actorRotYSin;
}
func_800627A0(&this->colliderScythe, i, &scytheVertices[0], &scytheVertices[1], &scytheVertices[2]);
for (j = 0; j < 3; j++) {
scytheVertices[j].x = (2 * this->actor.posRot.pos.x) - scytheVertices[j].x;
scytheVertices[j].z = (2 * this->actor.posRot.pos.z) - scytheVertices[j].z;
}
func_800627A0(&this->colliderScythe, (i + 2) % 4, &scytheVertices[0], &scytheVertices[1], &scytheVertices[2]);
}
if ((this->unk_151 == 0) || (globalCtx->actorCtx.unk_03 != 0)) {
scytheVertices[0].x = this->actor.posRot.pos.x + blureEffectVertices1[this->actor.params].z * actorRotYSin +
blureEffectVertices1[this->actor.params].x * actorRotYCos;
scytheVertices[0].y = this->actor.posRot.pos.y + blureEffectVertices1[this->actor.params].y;
scytheVertices[0].z = this->actor.posRot.pos.z + blureEffectVertices1[this->actor.params].z * actorRotYCos -
blureEffectVertices1[this->actor.params].x * actorRotYSin;
scytheVertices[1].x = this->actor.posRot.pos.x + blureEffectVertices2[this->actor.params].z * actorRotYSin +
blureEffectVertices2[this->actor.params].x * actorRotYCos;
scytheVertices[1].y = this->actor.posRot.pos.y + blureEffectVertices2[this->actor.params].y;
scytheVertices[1].z = this->actor.posRot.pos.z + blureEffectVertices2[this->actor.params].z * actorRotYCos -
blureEffectVertices2[this->actor.params].x * actorRotYSin;
EffectBlure_AddVertex(Effect_GetByIndex(this->blureEffectIndex[0]), &scytheVertices[0], &scytheVertices[1]);
for (j = 0; j < 2; j++) {
scytheVertices[j].x = (2 * this->actor.posRot.pos.x) - scytheVertices[j].x;
scytheVertices[j].z = (2 * this->actor.posRot.pos.z) - scytheVertices[j].z;
}
EffectBlure_AddVertex(Effect_GetByIndex(this->blureEffectIndex[1]), &scytheVertices[0], &scytheVertices[1]);
}
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderScythe.base);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderScytheCenter.base);
func_8002F974(&this->actor, NA_SE_EV_ROLLCUTTER_MOTOR - SFX_FLAG);
}
void BgHakaSgami_Update(Actor* thisx, GlobalContext* globalCtx) {
BgHakaSgami* this = THIS;
Player* player = PLAYER;
if (!(player->stateFlags1 & 0x300000C0) || (this->actionFunc == BgHakaSgami_SetupSpin)) {
this->actionFunc(this, globalCtx);
}
}
void BgHakaSgami_Draw(Actor* thisx, GlobalContext* globalCtx) {
BgHakaSgami* this = THIS;
if (this->unk_151 != 0) {
Gfx_DrawDListXlu(globalCtx, D_0600BF20);
} else if (this->actor.params == SCYTHE_TRAP_SHADOW_TEMPLE) {
Gfx_DrawDListOpa(globalCtx, D_0600BF20);
} else {
Gfx_DrawDListOpa(globalCtx, D_060021F0);
}
}

View file

@ -11,7 +11,13 @@ typedef void (*BgHakaSgamiActionFunc)(struct BgHakaSgami*, GlobalContext*);
typedef struct BgHakaSgami {
/* 0x0000 */ Actor actor;
/* 0x014C */ BgHakaSgamiActionFunc actionFunc;
/* 0x0150 */ char unk_150[0x1E8];
/* 0x0150 */ s8 requiredObjBankIndex;
/* 0x0151 */ s8 unk_151;
/* 0x0152 */ s16 timer;
/* 0x0154 */ s32 blureEffectIndex[2];
/* 0x015C */ ColliderCylinder colliderScytheCenter;
/* 0x01A8 */ ColliderTris colliderScythe;
/* 0x01C8 */ ColliderTrisItem colliderScytheItems[4];
} BgHakaSgami; // size = 0x0338
extern const ActorInit Bg_Haka_Sgami_InitVars;