diff options
| author | Zelllll <56516451+Zelllll@users.noreply.github.com> | 2021-01-21 09:21:05 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-21 10:21:05 -0500 |
| commit | d73976503126d10a82016f8f72fac4092dff1932 (patch) | |
| tree | 5cf50bc07828f498e05e7b3d0cb1a7179d687ac2 /src | |
| parent | 3f669bea1e23a4d781f0419846543ab442aab88b (diff) | |
Bg_Haka_Zou OK (#598)
* started init, not matched yet
* all except init matched
* haka_zou OK
* haka_zou done
* fix jenkins problem
* various improvements
* removed unused asm
* fixed things
* fixed new dyna names
* more dyna fixes
* ok now?????
* this better build OK
* applied roman's suggestions
* function renames
Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain>
Co-authored-by: Fig02 <fig02srl@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c | 397 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h | 10 |
2 files changed, 371 insertions, 36 deletions
diff --git a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c index 26ca26c17..7cd25540e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c +++ b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c @@ -8,30 +8,31 @@ #define FLAGS 0x00000010 +typedef enum { + /* 0x0 */ STA_GIANT_BIRD_STATUE, + /* 0x1 */ STA_BOMBABLE_SKULL_WALL, + /* 0x2 */ STA_BOMBABLE_RUBBLE, + /* 0x3 */ STA_UNKNOWN +} ShadowTempleAssetsType; + #define THIS ((BgHakaZou*)thisx) void BgHakaZou_Init(Actor* thisx, GlobalContext* globalCtx); void BgHakaZou_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaZou_Update(Actor* thisx, GlobalContext* globalCtx); +void BgHakaZou_Draw(Actor* thisx, GlobalContext* globalCtx); -extern UNK_TYPE D_06000A10; -extern UNK_TYPE D_06005E30; -extern UNK_TYPE D_06006F70; +void BgHakaZou_Wait(BgHakaZou* this, GlobalContext* globalCtx); +void func_80882BDC(BgHakaZou* this, GlobalContext* globalCtx); +void func_80883000(BgHakaZou* this, GlobalContext* globalCtx); +void func_80883104(BgHakaZou* this, GlobalContext* globalCtx); +void func_80883144(BgHakaZou* this, GlobalContext* globalCtx); +void func_80883254(BgHakaZou* this, GlobalContext* globalCtx); +void func_80883328(BgHakaZou* this, GlobalContext* globalCtx); +void func_808834D8(BgHakaZou* this, GlobalContext* globalCtx); +void BgHakaZou_DoNothing(BgHakaZou* this, GlobalContext* globalCtx); -/* -const ActorInit Bg_Haka_Zou_InitVars = { - ACTOR_BG_HAKA_ZOU, - ACTORCAT_PROP, - FLAGS, - OBJECT_GAMEPLAY_KEEP, - sizeof(BgHakaZou), - (ActorFunc)BgHakaZou_Init, - (ActorFunc)BgHakaZou_Destroy, - (ActorFunc)BgHakaZou_Update, - NULL, -}; - -static ColliderCylinderInit D_808835F0 = { +static ColliderCylinderInit sCylinderInit = { { COLTYPE_NONE, AT_NONE, @@ -50,35 +51,363 @@ static ColliderCylinderInit D_808835F0 = { }, { 5, 60, 0, { 0, 0, 0 } }, }; -*/ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/BgHakaZou_Init.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/BgHakaZou_Destroy.s") +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +const ActorInit Bg_Haka_Zou_InitVars = { + ACTOR_BG_HAKA_ZOU, + ACTORCAT_PROP, + FLAGS, + OBJECT_GAMEPLAY_KEEP, + sizeof(BgHakaZou), + (ActorFunc)BgHakaZou_Init, + (ActorFunc)BgHakaZou_Destroy, + (ActorFunc)BgHakaZou_Update, + NULL, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; + +extern Gfx D_06000A10[]; +extern CollisionHeader D_06005E30; +extern CollisionHeader D_06006F70; +extern CollisionHeader D_06000C2C; + +void BgHakaZou_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHakaZou* this = THIS; + s32 pad; + + Actor_ProcessInitChain(thisx, sInitChain); + + this->switchFlag = (thisx->params >> 8) & 0xFF; + thisx->params &= 0xFF; + + if (thisx->params == STA_UNKNOWN) { + Actor_SetScale(thisx, (Rand_ZeroOne() * 0.005f) + 0.025f); + + thisx->speedXZ = Rand_ZeroOne(); + thisx->world.rot.y = thisx->shape.rot.y * ((Rand_ZeroOne() < 0.5f) ? -1 : 1) + Rand_CenteredFloat(4096.0f); + this->timer = 20; + thisx->world.rot.x = Rand_S16Offset(0x100, 0x300) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + thisx->world.rot.z = Rand_S16Offset(0x400, 0x800) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + } else { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); + + DynaPolyActor_Init(&this->dyna, 0); + + if (thisx->params == STA_GIANT_BIRD_STATUE) { + thisx->uncullZoneForward = 2000.0f; + thisx->uncullZoneScale = 3000.0f; + thisx->uncullZoneDownward = 3000.0f; + } + } + + this->requiredObjBankIndex = (thisx->params == STA_BOMBABLE_RUBBLE) + ? Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKACH_OBJECTS) + : Object_GetIndex(&globalCtx->objectCtx, OBJECT_HAKA_OBJECTS); + + if (this->requiredObjBankIndex < 0) { + Actor_Kill(thisx); + } else if ((thisx->params != STA_UNKNOWN) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (thisx->params != STA_GIANT_BIRD_STATUE) { + Actor_Kill(thisx); + } else { + thisx->shape.rot.x = -0x4000; + thisx->world.pos.z -= 80.0f; + thisx->world.pos.y -= 54.0f; + } + } + + this->actionFunc = BgHakaZou_Wait; +} + +void BgHakaZou_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaZou* this = THIS; + + if (this->dyna.actor.params != STA_UNKNOWN) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_808828F4(BgHakaZou* this, GlobalContext* globalCtx) { + Vec3f effectPos; + Vec3f effectVelocity; + f32 rand; + s32 i; + + effectVelocity.x = 0.0f; + effectVelocity.y = 1.0f; + effectVelocity.z = 2.0f; + + for (i = 0; i < 2; i++) { + if (i == 0) { + effectPos.x = this->dyna.actor.world.pos.x - (Rand_CenteredFloat(10.0f) + 112.0f); + } else { + effectPos.x = Rand_CenteredFloat(10.0f) + this->dyna.actor.world.pos.x; + } + + rand = Rand_ZeroOne(); + effectPos.y = this->dyna.actor.world.pos.y + (60.0f * rand); + effectPos.z = this->dyna.actor.world.pos.z + (112.0f * rand); + + func_800286CC(globalCtx, &effectPos, &effectVelocity, &sZeroVec, (Rand_ZeroOne() * 200.0f) + 1000.0f, 100); + } +} + +void BgHakaZou_Wait(BgHakaZou* this, GlobalContext* globalCtx) { + CollisionHeader* colHeader; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { + this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + this->dyna.actor.draw = BgHakaZou_Draw; + + if (this->dyna.actor.params == STA_UNKNOWN) { + this->actionFunc = func_80882BDC; + return; + } + + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + + colHeader = NULL; + + if (this->dyna.actor.params == STA_GIANT_BIRD_STATUE) { + CollisionHeader_GetVirtual(&D_06006F70, &colHeader); + this->collider.dim.radius = 80; + this->collider.dim.height = 100; + this->collider.dim.yShift = -30; + this->collider.dim.pos.x -= 56; + this->collider.dim.pos.z += 56; + this->dyna.actor.uncullZoneScale = 1500.0f; + } else if (this->dyna.actor.params == STA_BOMBABLE_SKULL_WALL) { + CollisionHeader_GetVirtual(&D_06005E30, &colHeader); + this->collider.dim.yShift = -50; + } else { + CollisionHeader_GetVirtual(&D_06000C2C, &colHeader); + this->collider.dim.radius = 55; + this->collider.dim.height = 20; + } + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + + if ((this->dyna.actor.params == STA_GIANT_BIRD_STATUE) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->actionFunc = BgHakaZou_DoNothing; + return; + } + + this->actionFunc = func_80883000; + } +} +void func_80882BDC(BgHakaZou* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + this->dyna.actor.shape.rot.x += this->dyna.actor.world.rot.x; + this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z; + + if (this->dyna.actor.bgCheckFlags & 2) { + if (this->dyna.actor.velocity.y < -8.0f) { + this->dyna.actor.velocity.y *= -0.6f; + this->dyna.actor.velocity.y = (this->dyna.actor.velocity.y > 10.0f) ? 10.0f : this->dyna.actor.velocity.y; + this->dyna.actor.bgCheckFlags &= ~3; + this->dyna.actor.speedXZ = 2.0f; + } else { + Actor_Kill(&this->dyna.actor); + } + } + + if (this->timer == 0) { + Actor_Kill(&this->dyna.actor); + } +} + +void func_80882CC4(BgHakaZou* this, GlobalContext* globalCtx) { + s32 i; + s32 j; + Vec3f actorSpawnPos; + f32 sin; + f32 cos; + s32 pad; + + sin = Math_SinS(this->dyna.actor.shape.rot.y - 0x4000) * 40.0f; + cos = Math_CosS(this->dyna.actor.shape.rot.y - 0x4000) * 40.0f; + + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + actorSpawnPos.x = this->dyna.actor.world.pos.x + (j - 1) * sin; + actorSpawnPos.z = this->dyna.actor.world.pos.z + (j - 1) * cos; + actorSpawnPos.y = this->dyna.actor.world.pos.y + (i - 1) * 55; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_HAKA_ZOU, actorSpawnPos.x, actorSpawnPos.y, + actorSpawnPos.z, 0, this->dyna.actor.shape.rot.y, 0, this->dyna.actor.params + 2); + func_800286CC(globalCtx, &actorSpawnPos, &sZeroVec, &sZeroVec, 1000, 50); + } + } +} + +void func_80882E54(BgHakaZou* this, GlobalContext* globalCtx) { + Vec3f fragmentPos; + s32 i; + s32 j; + s32 num = 25; + + fragmentPos.x = this->collider.dim.pos.x; + fragmentPos.y = this->collider.dim.pos.y; + fragmentPos.z = this->collider.dim.pos.z; + + EffectSsHahen_SpawnBurst(globalCtx, &fragmentPos, 10.0f, 0, 10, 10, 4, 141, 40, D_06000A10); + + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + fragmentPos.x = this->collider.dim.pos.x + (((j * 2) - 1) * num); + fragmentPos.z = this->collider.dim.pos.z + (((i * 2) - 1) * num); + EffectSsHahen_SpawnBurst(globalCtx, &fragmentPos, 10.0f, 0, 10, 10, 4, 141, 40, D_06000A10); + func_800286CC(globalCtx, &fragmentPos, &sZeroVec, &sZeroVec, 1000, 50); + } + } +} + +void func_80883000(BgHakaZou* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & 2) { + Flags_SetSwitch(globalCtx, this->switchFlag); + + if (this->dyna.actor.params == STA_GIANT_BIRD_STATUE) { + this->timer = 20; + this->actionFunc = func_80883144; + func_800800F8(globalCtx, 3400, 999, &this->dyna.actor, 0); + } else if (this->dyna.actor.params == 2) { + func_80882E54(this, globalCtx); + this->dyna.actor.draw = NULL; + this->timer = 1; + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_EXPLOSION); + this->actionFunc = func_80883104; + } else { + func_80882CC4(this, globalCtx); + this->timer = 1; + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80883104; + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80883104(BgHakaZou* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + Actor_Kill(&this->dyna.actor); + } +} + +void func_80883144(BgHakaZou* this, GlobalContext* globalCtx) { + Vec3f explosionPos; + + if (this->timer != 0) { + this->timer--; + } + + if (!(this->timer % 4)) { + explosionPos.x = Rand_CenteredFloat(200.0f) + (this->dyna.actor.world.pos.x - 56.0f); + explosionPos.y = (Rand_ZeroOne() * 80.0f) + this->dyna.actor.world.pos.y; + explosionPos.z = Rand_CenteredFloat(200.0f) + (this->dyna.actor.world.pos.z + 56.0f); + + EffectSsBomb2_SpawnLayered(globalCtx, &explosionPos, &sZeroVec, &sZeroVec, 150, 70); + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + } + + if (this->timer == 0) { + this->timer = 20; + this->actionFunc = func_80883254; + } +} + +void func_80883254(BgHakaZou* this, GlobalContext* globalCtx) { + f32 moveDist = (Rand_ZeroOne() * 0.5f) + 0.5f; + + Math_StepToF(&this->dyna.actor.world.pos.z, this->dyna.actor.home.pos.z - 80.0f, 2.0f * moveDist); + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 40.0f, moveDist)) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + this->timer = 60; + this->dyna.actor.world.rot.x = 0x0008; + this->actionFunc = func_80883328; + } + } else { + func_808828F4(this, globalCtx); + } +} + +void func_80883328(BgHakaZou* this, GlobalContext* globalCtx) { + Vec3f effectPos; + s32 i; + s32 j; + + this->dyna.actor.world.rot.x += this->dyna.actor.world.rot.x * 0.125f; + + if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, -0x4000, this->dyna.actor.world.rot.x) != 0) { + effectPos.x = this->dyna.actor.world.pos.x; + effectPos.y = this->dyna.actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_808828F4.s") + for (j = 0; j < 2; j++) { + effectPos.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80882A70.s") + for (i = 0; i < 4; i++) { + effectPos.z -= (i == 2) ? 550.0f : 50.0f; + func_800286CC(globalCtx, &effectPos, &sZeroVec, &sZeroVec, (Rand_ZeroOne() * 200.0f) + 1000.0f, 200); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80882BDC.s") + effectPos.x -= 112.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80882CC4.s") + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONE_BOUND); + this->timer = 25; + this->actionFunc = func_808834D8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80882E54.s") +void func_808834D8(BgHakaZou* this, GlobalContext* globalCtx) { + f32 moveDist; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80883000.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80883104.s") + moveDist = ((this->timer % 2) ? 15.0f : -15.0f); + this->dyna.actor.world.pos.y += ((this->timer & 0xFE) * 0.04f * moveDist); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80883144.s") + if (this->timer == 0) { + this->actionFunc = BgHakaZou_DoNothing; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80883254.s") +void BgHakaZou_DoNothing(BgHakaZou* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80883328.s") +void BgHakaZou_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaZou* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_808834D8.s") + this->actionFunc(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_80883568.s") + if (this->dyna.actor.params == 3) { + Actor_MoveForward(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/BgHakaZou_Update.s") +void BgHakaZou_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* dLists[] = { 0x060064E0, 0x06005CE0, 0x06000A10, 0x06005CE0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Zou/func_808835B8.s") + Gfx_DrawDListOpa(globalCtx, dLists[thisx->params]); +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h index 10f711a03..06e3b7ff6 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h +++ b/src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.h @@ -6,9 +6,15 @@ struct BgHakaZou; +typedef void (*BgHakaZouActionFunc)(struct BgHakaZou*, GlobalContext*); + typedef struct BgHakaZou { - /* 0x0000 */ Actor actor; - /* 0x014C */ char unk_14C[0x6C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x0164 */ BgHakaZouActionFunc actionFunc; + /* 0x0168 */ s8 requiredObjBankIndex; + /* 0x0169 */ u8 switchFlag; + /* 0x016A */ s16 timer; + /* 0x016C */ ColliderCylinder collider; } BgHakaZou; // size = 0x01B8 extern const ActorInit Bg_Haka_Zou_InitVars; |
