mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-08-13 17:03:47 -04:00
a5df9dddf0
* First batch some overlay
* Almost all overlay
* effect & gamestate
* kaleido stuffs
* more overlay
* more left over from code folder
* remaining hardcoded line and file
* Open & Close _DISP __FILE__ & __LINE__ clean up
* Some if (1) {} remove
* LOG_xxxx __FILE__ , __LINE__ cleaned
* ASSERT macro __FILE__ __LINE__
* mtx without line/file in functions
* " if (1) {} " & "if (0) {}" and tab/white place
* LogUtils as macro
* GameState_, GameAlloc_, SystemArena_ & ZeldaArena_
* Revert "GameState_, GameAlloc_, SystemArena_ & ZeldaArena_"
This reverts commit 0d85caaf7e
.
* Like last commit but as macro
* Fix matrix not using macros
* use function not macro
* DebugArena_* functions
GameAlloc_MallocDebug
BgCheck_PosErrorCheck as macros
removed issues with ; in macro file
218 lines
6.8 KiB
C
218 lines
6.8 KiB
C
/*
|
|
* File: z_bg_hidan_firewall.c
|
|
* Overlay: ovl_Bg_Hidan_Firewall
|
|
* Description: Proximity Triggered Flame Wall
|
|
*/
|
|
|
|
#include "z_bg_hidan_firewall.h"
|
|
#include "objects/object_hidan_objects/object_hidan_objects.h"
|
|
|
|
#define FLAGS 0
|
|
|
|
void BgHidanFirewall_Init(Actor* thisx, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Update(Actor* thisx, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Draw(Actor* thisx, GlobalContext* globalCtx);
|
|
|
|
s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Wait(BgHidanFirewall* this, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Countdown(BgHidanFirewall* this, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Erupt(BgHidanFirewall* this, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_Collide(BgHidanFirewall* this, GlobalContext* globalCtx);
|
|
void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, GlobalContext* globalCtx);
|
|
|
|
const ActorInit Bg_Hidan_Firewall_InitVars = {
|
|
ACTOR_BG_HIDAN_FIREWALL,
|
|
ACTORCAT_BG,
|
|
FLAGS,
|
|
OBJECT_HIDAN_OBJECTS,
|
|
sizeof(BgHidanFirewall),
|
|
(ActorFunc)BgHidanFirewall_Init,
|
|
(ActorFunc)BgHidanFirewall_Destroy,
|
|
(ActorFunc)BgHidanFirewall_Update,
|
|
NULL,
|
|
NULL,
|
|
};
|
|
|
|
static ColliderCylinderInit sCylinderInit = {
|
|
{
|
|
COLTYPE_NONE,
|
|
AT_ON | AT_TYPE_ENEMY,
|
|
AC_NONE,
|
|
OC1_ON | OC1_TYPE_PLAYER,
|
|
OC2_TYPE_2,
|
|
COLSHAPE_CYLINDER,
|
|
},
|
|
{
|
|
ELEMTYPE_UNK0,
|
|
{ 0x20000000, 0x01, 0x04 },
|
|
{ 0xFFCFFFFF, 0x00, 0x00 },
|
|
TOUCH_ON | TOUCH_SFX_NONE,
|
|
BUMP_NONE,
|
|
OCELEM_ON,
|
|
},
|
|
{ 30, 83, 0, { 0 } },
|
|
};
|
|
|
|
static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE };
|
|
|
|
void BgHidanFirewall_Init(Actor* thisx, GlobalContext* globalCtx) {
|
|
BgHidanFirewall* this = (BgHidanFirewall*)thisx;
|
|
|
|
this->actor.scale.x = 0.12f;
|
|
this->actor.scale.z = 0.12f;
|
|
this->actor.scale.y = 0.01f;
|
|
|
|
this->unk_150 = 0;
|
|
|
|
Collider_InitCylinder(globalCtx, &this->collider);
|
|
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
|
|
|
|
this->collider.dim.pos.y = this->actor.world.pos.y;
|
|
|
|
CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit);
|
|
|
|
this->actionFunc = BgHidanFirewall_Wait;
|
|
}
|
|
|
|
void BgHidanFirewall_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
|
BgHidanFirewall* this = (BgHidanFirewall*)thisx;
|
|
|
|
Collider_DestroyCylinder(globalCtx, &this->collider);
|
|
}
|
|
|
|
s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, GlobalContext* globalCtx) {
|
|
Player* player;
|
|
Vec3f distance;
|
|
|
|
player = GET_PLAYER(globalCtx);
|
|
func_8002DBD0(&this->actor, &distance, &player->actor.world.pos);
|
|
|
|
if (fabsf(distance.x) < 100.0f && fabsf(distance.z) < 120.0f) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void BgHidanFirewall_Wait(BgHidanFirewall* this, GlobalContext* globalCtx) {
|
|
if (BgHidanFirewall_CheckProximity(this, globalCtx) != 0) {
|
|
this->actor.draw = BgHidanFirewall_Draw;
|
|
this->actor.params = 5;
|
|
this->actionFunc = BgHidanFirewall_Countdown;
|
|
}
|
|
}
|
|
|
|
void BgHidanFirewall_Countdown(BgHidanFirewall* this, GlobalContext* globalCtx) {
|
|
|
|
if (this->actor.params != 0) {
|
|
this->actor.params--;
|
|
}
|
|
if (this->actor.params == 0) {
|
|
this->actionFunc = BgHidanFirewall_Erupt;
|
|
}
|
|
}
|
|
|
|
void BgHidanFirewall_Erupt(BgHidanFirewall* this, GlobalContext* globalCtx) {
|
|
if (BgHidanFirewall_CheckProximity(this, globalCtx) != 0) {
|
|
Math_StepToF(&this->actor.scale.y, 0.1f, 0.01f / 0.4f);
|
|
} else {
|
|
if (Math_StepToF(&this->actor.scale.y, 0.01f, 0.01f) != 0) {
|
|
this->actor.draw = NULL;
|
|
this->actionFunc = BgHidanFirewall_Wait;
|
|
} else {
|
|
this->actor.params = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
void BgHidanFirewall_Collide(BgHidanFirewall* this, GlobalContext* globalCtx) {
|
|
s16 phi_a3;
|
|
|
|
if (Actor_IsFacingPlayer(&this->actor, 0x4000)) {
|
|
phi_a3 = this->actor.shape.rot.y;
|
|
} else {
|
|
phi_a3 = this->actor.shape.rot.y + 0x8000;
|
|
}
|
|
|
|
func_8002F71C(globalCtx, &this->actor, 5.0f, phi_a3, 1.0f);
|
|
}
|
|
|
|
void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, GlobalContext* globalCtx) {
|
|
Player* player;
|
|
Vec3f sp30;
|
|
f32 temp_ret;
|
|
f32 sp28;
|
|
f32 phi_f0;
|
|
|
|
player = GET_PLAYER(globalCtx);
|
|
|
|
func_8002DBD0(&this->actor, &sp30, &player->actor.world.pos);
|
|
if (sp30.x < -70.0f) {
|
|
sp30.x = -70.0f;
|
|
} else {
|
|
if (70.0f < sp30.x) {
|
|
phi_f0 = 70.0f;
|
|
} else {
|
|
phi_f0 = sp30.x;
|
|
}
|
|
sp30.x = phi_f0;
|
|
}
|
|
if (this->actor.params == 0) {
|
|
if (0.0f < sp30.z) {
|
|
sp30.z = -25.0f;
|
|
this->actor.params = -1;
|
|
} else {
|
|
sp30.z = 25.0f;
|
|
this->actor.params = 1;
|
|
}
|
|
} else {
|
|
sp30.z = this->actor.params * 25.0f;
|
|
}
|
|
sp28 = Math_SinS(this->actor.shape.rot.y);
|
|
temp_ret = Math_CosS(this->actor.shape.rot.y);
|
|
this->collider.dim.pos.x = this->actor.world.pos.x + sp30.x * temp_ret + sp30.z * sp28;
|
|
this->collider.dim.pos.z = this->actor.world.pos.z - sp30.x * sp28 + sp30.z * temp_ret;
|
|
}
|
|
|
|
void BgHidanFirewall_Update(Actor* thisx, GlobalContext* globalCtx) {
|
|
BgHidanFirewall* this = (BgHidanFirewall*)thisx;
|
|
s32 pad;
|
|
|
|
this->unk_150 = (this->unk_150 + 1) % 8;
|
|
|
|
if (this->collider.base.atFlags & AT_HIT) {
|
|
this->collider.base.atFlags &= ~AT_HIT;
|
|
BgHidanFirewall_Collide(this, globalCtx);
|
|
}
|
|
|
|
this->actionFunc(this, globalCtx);
|
|
if (this->actionFunc == BgHidanFirewall_Erupt) {
|
|
BgHidanFirewall_ColliderFollowPlayer(this, globalCtx);
|
|
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
|
|
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
|
|
func_8002F974(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG);
|
|
}
|
|
}
|
|
|
|
static void* sFireballTexs[] = {
|
|
gFireTempleFireball0Tex, gFireTempleFireball1Tex, gFireTempleFireball2Tex, gFireTempleFireball3Tex,
|
|
gFireTempleFireball4Tex, gFireTempleFireball5Tex, gFireTempleFireball6Tex, gFireTempleFireball7Tex,
|
|
};
|
|
|
|
void BgHidanFirewall_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
|
BgHidanFirewall* this = (BgHidanFirewall*)thisx;
|
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx);
|
|
|
|
POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14);
|
|
|
|
gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sFireballTexs[this->unk_150]));
|
|
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150);
|
|
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255);
|
|
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
|
|
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
|
gSPDisplayList(POLY_XLU_DISP++, gFireTempleFireballUpperHalfDL);
|
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
|
}
|