1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-12 19:04:38 +00:00

En_Bom and En_Bombf (#264)

* data migrated

* progress

* progress

* enbom ok

* cleanup

* progress

* still have stack issues

* bombf done

* done i think

* review comments 1

* add type enums

* move enums and use -1

* remove unwanted file
This commit is contained in:
fig02 2020-07-19 14:04:30 -04:00 committed by GitHub
parent 15f75b0ddd
commit 15038468ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 853 additions and 1899 deletions

View file

@ -1,3 +1,9 @@
/*
* File: z_en_bom.c
* Overlay: ovl_En_Bom
* Description: Bomb
*/
#include "z_en_bom.h"
#define FLAGS 0x00000030
@ -9,7 +15,9 @@ void EnBom_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnBom_Update(Actor* thisx, GlobalContext* globalCtx);
void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void EnBom_Move(EnBom* this, GlobalContext* globalCtx);
void EnBom_WaitForRelease(EnBom* this, GlobalContext* globalCtx);
const ActorInit En_Bom_InitVars = {
ACTOR_EN_BOM,
ACTORTYPE_EXPLOSIVES,
@ -21,19 +29,329 @@ const ActorInit En_Bom_InitVars = {
(ActorFunc)EnBom_Update,
(ActorFunc)EnBom_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/func_809C26D0.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/EnBom_Init.s")
static ColliderCylinderInit sCylinderInit = {
{ COLTYPE_UNK0, 0x00, 0x29, 0x39, 0x20, COLSHAPE_CYLINDER },
{ 0x02, { 0x00000000, 0x00, 0x00 }, { 0x0003F828, 0x00, 0x00 }, 0x00, 0x01, 0x01 },
{ 6, 11, 14, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/EnBom_Destroy.s")
static ColliderJntSphItemInit sJntSphItemsInit[1] = {
{
{ 0x00, { 0x00000008, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, 0x19, 0x00, 0x00 },
{ 0, { { 0, 0, 0 }, 0 }, 100 },
},
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/func_809C282C.s")
static ColliderJntSphInit sJntSphInit = {
{ COLTYPE_UNK0, 0x39, 0x00, 0x00, 0x00, COLSHAPE_JNTSPH },
1,
sJntSphItemsInit,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/func_809C29F4.s")
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F(scale, 0, ICHAIN_CONTINUE),
ICHAIN_F32(unk_4C, 2000, ICHAIN_CONTINUE),
ICHAIN_F32_DIV1000(gravity, 61536, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/func_809C2A38.s")
extern Gfx D_04007A50[]; // gold fuse cap
extern Gfx D_04007860[]; // bomb
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/EnBom_Update.s")
void EnBom_SetupAction(EnBom* this, EnBomActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bom/EnBom_Draw.s")
void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) {
EnBom* this = THIS;
Actor_ProcessInitChain(&this->actor, sInitChain);
ActorShape_Init(&this->actor.shape, 700.0f, ActorShadow_DrawFunc_Circle, 16.0f);
this->actor.colChkInfo.mass = 200;
this->actor.colChkInfo.unk_10 = 5;
this->actor.colChkInfo.unk_12 = 0xA;
this->timer = 70;
this->flashSpeedScale = 7;
Collider_InitCylinder(globalCtx, &this->bombCollider);
Collider_InitJntSph(globalCtx, &this->explosionCollider);
Collider_SetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit);
Collider_SetJntSph(globalCtx, &this->explosionCollider, &this->actor, &sJntSphInit,
&this->explosionColliderItems[0]);
this->explosionColliderItems[0].body.toucher.damage += (thisx->shape.rot.z & 0xFF00) >> 8;
this->actor.shape.rot.z &= 0xFF;
if (this->actor.shape.rot.z & 0x80) {
this->actor.shape.rot.z |= 0xFF00;
}
EnBom_SetupAction(this, EnBom_Move);
}
void EnBom_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnBom* this = THIS;
Collider_DestroyJntSph(globalCtx, &this->explosionCollider);
Collider_DestroyCylinder(globalCtx, &this->bombCollider);
}
void EnBom_Move(EnBom* this, GlobalContext* globalCtx) {
// if attached A is not null, the bomb hasnt been released yet
if (func_8002F410(&this->actor, globalCtx)) {
EnBom_SetupAction(this, EnBom_WaitForRelease);
this->actor.room = -1;
return;
}
if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) {
this->actor.velocity.y = -this->actor.velocity.y;
}
// rebound bomb off the wall it hits
if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) {
if (ABS((s16)(this->actor.wallPolyRot - this->actor.posRot.rot.y)) > 0x4000) {
this->actor.posRot.rot.y =
((this->actor.wallPolyRot - this->actor.posRot.rot.y) + this->actor.wallPolyRot) - 0x8000;
}
Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_BOUND);
Actor_MoveForward(&this->actor);
this->actor.speedXZ *= 0.7f;
this->actor.bgCheckFlags &= ~8;
}
if (!(this->actor.bgCheckFlags & 1)) {
Math_ApproxF(&this->actor.speedXZ, 0.0f, 0.08f);
} else {
Math_ApproxF(&this->actor.speedXZ, 0.0f, 1.0f);
if ((this->actor.bgCheckFlags & 2) && (this->actor.velocity.y < -3.0f)) {
func_8002F850(globalCtx, &this->actor);
this->actor.velocity.y *= -0.3f;
this->actor.bgCheckFlags &= ~2;
} else if (this->timer >= 4) {
func_8002F580(&this->actor, globalCtx);
}
}
Actor_MoveForward(&this->actor);
}
void EnBom_WaitForRelease(EnBom* this, GlobalContext* globalCtx) {
// if attachedA is NULL bomb has been released
if (func_8002F5A0(&this->actor, globalCtx)) {
EnBom_SetupAction(this, EnBom_Move);
EnBom_Move(this, globalCtx);
}
}
void EnBom_Explode(EnBom* this, GlobalContext* globalCtx) {
Player* player;
if (this->explosionCollider.list->dim.modelSphere.radius == 0) {
this->actor.flags |= 0x20;
func_800AA000(this->actor.xzDistFromLink, 0xFF, 0x14, 0x96);
}
this->explosionCollider.list->dim.worldSphere.radius += this->actor.shape.rot.z + 8;
if (this->actor.params == BOMB_EXPLOSION) {
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->explosionCollider.base);
}
if (globalCtx->envCtx.unk_8C[3] != 0) {
globalCtx->envCtx.unk_8C[3] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[4] != 0) {
globalCtx->envCtx.unk_8C[4] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[5] != 0) {
globalCtx->envCtx.unk_8C[5] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[0] != 0) {
globalCtx->envCtx.unk_8C[0] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[1] != 0) {
globalCtx->envCtx.unk_8C[1] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[2] != 0) {
globalCtx->envCtx.unk_8C[2] -= 0x19;
}
if (this->timer == 0) {
player = PLAYER;
if ((player->stateFlags1 & 0x800) && (player->heldActor == &this->actor)) {
player->actor.attachedB = NULL;
player->heldActor = NULL;
player->interactRangeActor = NULL;
player->stateFlags1 &= ~0x800;
}
Actor_Kill(&this->actor);
}
}
void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) {
Vec3f effVelocity = { 0.0f, 0.0f, 0.0f };
Vec3f bomb2Accel = { 0.0f, 0.1f, 0.0f };
Vec3f effAccel = { 0.0f, 0.0f, 0.0f };
Vec3f effPos;
Vec3f dustAccel = { 0.0f, 0.6f, 0.0f };
Color_RGBA8_n dustColor = { 255, 255, 255, 255 };
s32 pad[2];
EnBom* this = THIS;
this->actor.gravity = -1.2f;
if (this->timer != 0) {
this->timer--;
}
if (this->timer == 67) {
Audio_PlayActorSound2(&this->actor, NA_SE_PL_TAKE_OUT_SHIELD);
Actor_SetScale(&this->actor, 0.01f);
}
if ((this->actor.xzDistFromLink >= 20.0f) || (ABS(this->actor.yDistFromLink) >= 80.0f)) {
this->bumpOn = true;
}
this->actionFunc(this, globalCtx);
func_8002E4B4(globalCtx, &this->actor, 5.0f, 10.0f, 15.0f, 0x1F);
if (this->actor.params == BOMB_BODY) {
if (this->timer < 63) {
dustAccel.y = 0.2f;
// spawn spark effect on even frames
effPos = this->actor.posRot.pos;
effPos.y += 17.0f;
if ((globalCtx->gameplayFrames % 2) == 0) {
func_80029184(globalCtx, this, &effPos, &effVelocity, &effAccel);
}
Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG);
effPos.y += 3.0f;
func_8002829C(globalCtx, &effPos, &effVelocity, &dustAccel, &dustColor, &dustColor, 0x32, 5);
}
if ((this->bombCollider.base.acFlags & 2) ||
((this->bombCollider.base.maskA & 2) && (this->bombCollider.base.oc->type == ACTORTYPE_ENEMY))) {
this->timer = 0;
this->actor.shape.rot.z = 0;
} else {
// if a lit stick touches the bomb, set timer to 100
// these bombs never have a timer over 70, so this isnt used
if ((this->timer > 100) && func_8008EF5C(globalCtx, &this->actor.posRot.pos, 30.0f, 50.0f)) {
this->timer = 100;
}
}
dustAccel.y = 0.2f;
effPos = this->actor.posRot.pos;
effPos.y += 10.0f;
// double bomb flash speed and adjust red color at certain times during the countdown
if ((this->timer == 3) || (this->timer == 20) || (this->timer == 40)) {
this->actor.shape.rot.z = 0;
this->flashSpeedScale >>= 1;
}
if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) {
Math_SmoothScaleMaxMinF(&this->flashIntensity, 140.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f);
} else {
Math_SmoothScaleMaxMinF(&this->flashIntensity, 0.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f);
}
if (this->timer < 3) {
Actor_SetScale(&this->actor, this->actor.scale.x + 0.002f);
}
if (this->timer == 0) {
effPos = this->actor.posRot.pos;
effPos.y += 10.0f;
if (func_8002F410(&this->actor, globalCtx)) {
effPos.y += 30.0f;
}
func_80028E84(globalCtx, &effPos, &effVelocity, &bomb2Accel, 0x64, (this->actor.shape.rot.z * 6) + 0x13);
effPos.y = this->actor.groundY;
if (this->actor.groundY > -32000.0f) {
func_80029024(globalCtx, &effPos, &effVelocity, &effAccel);
}
Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION);
if (globalCtx) {};
globalCtx->envCtx.unk_8C[3] = globalCtx->envCtx.unk_8C[4] = globalCtx->envCtx.unk_8C[5] = 0xFA;
globalCtx->envCtx.unk_8C[0] = globalCtx->envCtx.unk_8C[1] = globalCtx->envCtx.unk_8C[2] = 0xFA;
func_8005AA1C(&globalCtx->cameras[0], 2, 0xB, 8);
this->actor.params = BOMB_EXPLOSION;
this->timer = 10;
this->actor.flags |= 0x20;
EnBom_SetupAction(this, EnBom_Explode);
}
}
Actor_SetHeight(&this->actor, 20.0f);
if (this->actor.params <= BOMB_BODY) {
Collider_CylinderUpdate(&this->actor, &this->bombCollider);
// if link is not holding the bomb anymore and bump conditions are met, subscribe to OC
if (!func_8002F410(&this->actor, globalCtx) && this->bumpOn) {
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base);
}
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bombCollider.base);
}
if ((this->actor.scale.x >= 0.01f) && (this->actor.params != BOMB_EXPLOSION)) {
if (this->actor.waterY >= 20.0f) {
func_8002A9F4(globalCtx, &this->actor.projectedPos, NA_SE_IT_BOMB_UNEXPLOSION, 1, 1, 0xA);
Actor_Kill(&this->actor);
return;
}
if (this->actor.bgCheckFlags & 0x40) {
this->actor.bgCheckFlags &= ~0x40;
Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER);
}
}
}
void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
EnBom* this = THIS;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
if (1) {}
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_en_bom.c", 913);
if (this->actor.params == BOMB_BODY) {
func_80093D18(globalCtx->state.gfxCtx);
func_800D1FD4(&globalCtx->mf_11DA0);
func_8002EBCC(&this->actor, globalCtx, 0);
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bom.c", 928),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfxCtx->polyOpa.p++, D_04007A50);
Matrix_RotateRPY(0x4000, 0, 0, MTXMODE_APPLY);
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bom.c", 934),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gDPPipeSync(gfxCtx->polyOpa.p++);
gDPSetEnvColor(gfxCtx->polyOpa.p++, (s16)this->flashIntensity, 0, 40, 255);
gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, (s16)this->flashIntensity, 0, 40, 255);
gSPDisplayList(gfxCtx->polyOpa.p++, D_04007860);
func_800628A4(0, &this->explosionCollider);
}
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_en_bom.c", 951);
}

View file

@ -6,11 +6,25 @@
struct EnBom;
typedef void (*EnBomActionFunc)(struct EnBom*, struct GlobalContext*);
typedef struct EnBom {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0xBC];
/* 0x014C */ ColliderCylinder bombCollider;
/* 0x0198 */ ColliderJntSph explosionCollider;
/* 0x01B8 */ ColliderJntSphItem explosionColliderItems[1];
/* 0x01F8 */ s16 timer;
/* 0x01FA */ s16 flashSpeedScale;
/* 0x01FC */ f32 flashIntensity;
/* 0x0200 */ u8 bumpOn;
/* 0x0204 */ EnBomActionFunc actionFunc;
} EnBom; // size = 0x0208
typedef enum {
/* 0x00 */ BOMB_BODY,
/* 0x01 */ BOMB_EXPLOSION,
} EnBomType;
extern const ActorInit En_Bom_InitVars;
#endif

View file

@ -1,3 +1,9 @@
/*
* File: z_en_bombf.c
* Overlay: ovl_En_Bombf
* Description: Bomb Flower
*/
#include "z_en_bombf.h"
#define FLAGS 0x00000011
@ -9,7 +15,12 @@ void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx);
void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void EnBombf_Move(EnBombf* this, GlobalContext* globalCtx);
void EnBombf_GrowBomb(EnBombf* this, GlobalContext* globalCtx);
void EnBombf_WaitForRelease(EnBombf* this, GlobalContext* globalCtx);
void EnBombf_Explode(EnBombf* this, GlobalContext* globalCtx);
void EnBombf_SetupGrowBomb(EnBombf* this, s16 params);
const ActorInit En_Bombf_InitVars = {
ACTOR_EN_BOMBF,
ACTORTYPE_PROP,
@ -21,25 +32,475 @@ const ActorInit En_Bombf_InitVars = {
(ActorFunc)EnBombf_Update,
(ActorFunc)EnBombf_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C6F60.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/EnBombf_Init.s")
static ColliderCylinderInit sCylinderInit = {
{ COLTYPE_UNK10, 0x00, 0x29, 0x39, 0x20, COLSHAPE_CYLINDER },
{ 0x02, { 0x00000000, 0x00, 0x00 }, { 0x0003F828, 0x00, 0x00 }, 0x00, 0x01, 0x01 },
{ 9, 18, 10, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/EnBombf_Destroy.s")
static ColliderJntSphItemInit sJntSphItemsInit[1] = {
{
{ 0x00, { 0x00000008, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, 0x19, 0x00, 0x00 },
{ 0, { { 0, 0, 0 }, 0 }, 100 },
},
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C7180.s")
static ColliderJntSphInit sJntSphInit = {
{ COLTYPE_UNK10, 0x39, 0x00, 0x00, 0x00, COLSHAPE_JNTSPH },
1,
sJntSphItemsInit,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C71A8.s")
extern Gfx D_06000340[];
extern Gfx D_06000408[];
extern Gfx D_06000530[];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C74AC.s")
void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C75C8.s")
void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx) {
f32 shapeUnk10 = 0.0f;
s32 pad;
EnBombf* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C7624.s")
Actor_SetScale(&this->actor, 0.01f);
this->unk_200 = 1;
Collider_InitCylinder(globalCtx, &this->bombCollider);
Collider_InitJntSph(globalCtx, &this->explosionCollider);
Collider_SetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit);
Collider_SetJntSph(globalCtx, &this->explosionCollider, &this->actor, &sJntSphInit,
&this->explosionColliderItems[0]);
if (this->actor.params == BOMBFLOWER_BODY) {
shapeUnk10 = 1000.0f;
}
ActorShape_Init(&this->actor.shape, shapeUnk10, ActorShadow_DrawFunc_Circle, 12.0f);
this->actor.posRot2.pos = this->actor.posRot.pos;
if (Actor_FindNearby(globalCtx, &this->actor, ACTOR_BG_DDAN_KD, ACTORTYPE_BG, 10000.0f) != NULL) {
this->actor.flags |= 0x20;
}
this->actor.colChkInfo.unk_10 = 10.0f;
this->actor.colChkInfo.unk_12 = 10;
this->actor.unk_1F = 0;
if (this->actor.params == BOMBFLOWER_BODY) {
this->timer = 140;
this->flashSpeedScale = 15;
this->actor.gravity = -1.5f;
Actor_ChangeType(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORTYPE_EXPLOSIVES);
this->actor.colChkInfo.mass = 200;
this->actor.flags &= ~1;
EnBombf_SetupAction(this, EnBombf_Move);
} else {
this->actor.colChkInfo.mass = 0xFF;
this->bumpOn = true;
this->flowerBombScale = 1.0f;
EnBombf_SetupGrowBomb(this, thisx->params);
}
this->actor.uncullZoneScale += 31000.0f;
this->actor.uncullZoneForward += 31000.0f;
}
void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnBombf* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->bombCollider);
Collider_DestroyJntSph(globalCtx, &this->explosionCollider);
}
void EnBombf_SetupGrowBomb(EnBombf* this, s16 params) {
EnBombf_SetupAction(this, EnBombf_GrowBomb);
}
void EnBombf_GrowBomb(EnBombf* this, GlobalContext* globalCtx) {
EnBombf* bombFlower;
s32 pad;
s32 pad1;
Player* player = PLAYER;
s32 pad2;
if (this->flowerBombScale >= 1.0f) {
if (func_8002F410(&this->actor, globalCtx)) {
bombFlower =
(EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.posRot.pos.x,
this->actor.posRot.pos.y, this->actor.posRot.pos.z, 0, 0, 0, 0);
if (bombFlower != NULL) {
func_8002F5C4(&this->actor, bombFlower, globalCtx);
this->timer = 180;
this->flowerBombScale = 0.0f;
Audio_PlayActorSound2(&this->actor, NA_SE_PL_PULL_UP_ROCK);
this->actor.flags &= ~1;
} else {
player->actor.attachedB = NULL;
player->heldActor = NULL;
player->interactRangeActor = NULL;
this->actor.attachedA = NULL;
player->stateFlags1 &= ~0x800;
}
} else if (this->bombCollider.base.acFlags & 2) {
this->bombCollider.base.acFlags &= ~2;
if (this->bombCollider.base.ac->type != ACTORTYPE_BOSS) {
bombFlower =
(EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.posRot.pos.x,
this->actor.posRot.pos.y, this->actor.posRot.pos.z, 0, 0, 0, 0);
if (bombFlower != NULL) {
bombFlower->unk_200 = 1;
bombFlower->timer = 0;
this->timer = 180;
this->actor.flags &= ~1;
this->flowerBombScale = 0.0f;
}
}
} else {
if (func_8008EF5C(globalCtx, &this->actor.posRot.pos, 30.0f, 50.0f)) {
bombFlower =
(EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.posRot.pos.x,
this->actor.posRot.pos.y, this->actor.posRot.pos.z, 0, 0, 0, 0);
if (bombFlower != NULL) {
bombFlower->timer = 100;
this->timer = 180;
this->actor.flags &= ~1;
this->flowerBombScale = 0.0f;
}
} else {
if (!func_8002F410(&this->actor, globalCtx)) {
func_8002F580(&this->actor, globalCtx);
} else {
player->actor.attachedB = NULL;
player->heldActor = NULL;
player->interactRangeActor = NULL;
this->actor.attachedA = NULL;
player->stateFlags1 &= ~0x800;
this->actor.posRot.pos = this->actor.initPosRot.pos;
}
}
}
} else {
if (this->timer == 0) {
this->flowerBombScale += 0.05f;
if (this->flowerBombScale >= 1.0f) {
this->actor.flags |= 1;
}
}
if (func_8002F410(&this->actor, globalCtx)) {
player->actor.attachedB = NULL;
player->heldActor = NULL;
player->interactRangeActor = NULL;
this->actor.attachedA = NULL;
player->stateFlags1 &= ~0x800;
this->actor.posRot.pos = this->actor.initPosRot.pos;
}
}
}
void EnBombf_Move(EnBombf* this, GlobalContext* globalCtx) {
if (func_8002F410(&this->actor, globalCtx)) {
// setting flowerBombScale does not do anything in the context of a bomb that link picks up
// this and the assignment below are probably left overs
this->flowerBombScale = 0.0f;
EnBombf_SetupAction(this, EnBombf_WaitForRelease);
this->actor.room = -1;
return;
}
this->flowerBombScale = 1.0f;
if (!(this->actor.bgCheckFlags & 1)) {
Math_SmoothScaleMaxMinF(&this->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f);
} else {
Math_SmoothScaleMaxMinF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f);
if ((this->actor.bgCheckFlags & 2) && (this->actor.velocity.y < -6.0f)) {
func_8002F850(globalCtx, &this->actor);
this->actor.velocity.y *= -0.5f;
} else if (this->timer >= 4) {
func_8002F580(&this->actor, globalCtx);
}
}
}
void EnBombf_WaitForRelease(EnBombf* this, GlobalContext* globalCtx) {
// if attachedA is NULL bomb has been released
if (func_8002F5A0(&this->actor, globalCtx)) {
EnBombf_SetupAction(this, EnBombf_Move);
EnBombf_Move(this, globalCtx);
} else {
this->actor.velocity.y = 0.0f;
}
}
void EnBombf_Explode(EnBombf* this, GlobalContext* globalCtx) {
Player* player;
if (this->explosionCollider.list->dim.modelSphere.radius == 0) {
this->actor.flags |= 0x20;
func_800AA000(this->actor.xzDistFromLink, 0xFF, 0x14, 0x96);
}
this->explosionCollider.list->dim.modelSphere.radius += 8;
this->explosionCollider.list->dim.worldSphere.radius = this->explosionCollider.list->dim.modelSphere.radius;
if (this->actor.params == BOMBFLOWER_EXPLOSION) {
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->explosionCollider.base);
}
if (globalCtx->envCtx.unk_8C[3] != 0) {
globalCtx->envCtx.unk_8C[3] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[4] != 0) {
globalCtx->envCtx.unk_8C[4] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[5] != 0) {
globalCtx->envCtx.unk_8C[5] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[0] != 0) {
globalCtx->envCtx.unk_8C[0] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[1] != 0) {
globalCtx->envCtx.unk_8C[1] -= 0x19;
}
if (globalCtx->envCtx.unk_8C[2] != 0) {
globalCtx->envCtx.unk_8C[2] -= 0x19;
}
if (this->timer == 0) {
player = PLAYER;
if ((player->stateFlags1 & 0x800) && (player->heldActor == &this->actor)) {
player->actor.attachedB = NULL;
player->heldActor = NULL;
player->interactRangeActor = NULL;
player->stateFlags1 &= ~0x800;
}
Actor_Kill(&this->actor);
}
}
#ifdef NON_MATCHING
// stack issues. exact problems are commented in the function
void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) {
Vec3f effVelocity = { 0.0f, 0.0f, 0.0f };
Vec3f bomb2Accel = { 0.0f, 0.1f, 0.0f };
Vec3f effAccel = { 0.0f, 0.0f, 0.0f };
Vec3f effPos;
Vec3f dustAccel = { 0.0f, 0.6f, 0.0f };
Color_RGBA8_n dustColor = { 255, 255, 255, 255 };
EnBombf* this = THIS;
s32 pad1;
s32 pad2;
if ((this->unk_200 != 0) && (this->timer != 0)) {
this->timer--;
}
if ((!this->bumpOn) && (!func_8002F410(&this->actor, globalCtx)) &&
((this->actor.xzDistFromLink >= 20.0f) || (ABS(this->actor.yDistFromLink) >= 80.0f))) {
this->bumpOn = true;
}
this->actionFunc(this, globalCtx);
if (this->actor.params == BOMBFLOWER_BODY) {
Actor_MoveForward(&this->actor);
}
if (this->actor.gravity != 0.0f) {
DREG(6) = 1;
func_8002E4B4(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F);
DREG(6) = 0;
}
if (this->actor.params == BOMBFLOWER_BODY) {
if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) {
this->actor.velocity.y = -this->actor.velocity.y;
}
// rebound bomb off the wall it hits
if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) {
if (ABS((s16)(this->actor.wallPolyRot - this->actor.posRot.rot.y)) > 0x4000) {
this->actor.posRot.rot.y =
((this->actor.wallPolyRot - this->actor.posRot.rot.y) + this->actor.wallPolyRot) - 0x8000;
}
Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_BOUND);
Actor_MoveForward(&this->actor);
DREG(6) = 1;
func_8002E4B4(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F);
DREG(6) = 0;
this->actor.speedXZ *= 0.7f;
this->actor.bgCheckFlags &= ~8;
}
if ((this->bombCollider.base.acFlags & 2) ||
((this->bombCollider.base.maskA & 2) && (this->bombCollider.base.oc->type == ACTORTYPE_ENEMY))) {
this->unk_200 = 1;
this->timer = 0;
} else {
// if a lit stick touches the bomb, set timer to 100
if ((this->timer > 100) && func_8008EF5C(globalCtx, &this->actor.posRot.pos, 30.0f, 50.0f)) {
this->timer = 100;
}
}
if (this->unk_200 != 0) {
dustAccel.y = 0.2f;
effPos = this->actor.posRot.pos; // pointer to position supposed to go to sp3C, goes to 38
effPos.y += 25.0f;
if (this->timer < 127) {
// spawn spark effect on even frames
if ((globalCtx->gameplayFrames % 2) == 0) {
func_80029184(globalCtx, this, &effPos, &effVelocity, &effAccel);
}
Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG);
effPos.y += 3.0f;
func_8002829C(globalCtx, &effPos, &effVelocity, &dustAccel, &dustColor, &dustColor, 50, 5);
if (1) {}
}
// double bomb flash speed and adjust red color at certain times during the countdown
if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) {
this->flashSpeedScale >>= 1;
}
if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) {
Math_SmoothScaleMaxMinF(&this->flashIntensity, 150.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f);
} else {
Math_SmoothScaleMaxMinF(&this->flashIntensity, 0.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f);
}
if (this->timer < 3) {
Actor_SetScale(&this->actor, this->actor.scale.x + 0.002f);
}
if (this->timer == 0) {
effPos =
this->actor.posRot.pos; // same position copy from earlier, gets loaded from sp38 instead of sp3C
effPos.y += 10.0f;
// globalCtx+0x10000 gets stored to sp3C here instead of sp38
if (func_8002F410(&this->actor, globalCtx)) {
effPos.y += 30.0f;
}
func_80028E84(globalCtx, &effPos, &effVelocity, &bomb2Accel, 0x64, 0x13);
effPos.y = this->actor.groundY;
if (this->actor.groundY > -32000.0f) {
func_80029024(globalCtx, &effPos, &effVelocity, &effAccel);
}
Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION);
globalCtx->envCtx.unk_8C[3] = globalCtx->envCtx.unk_8C[4] = globalCtx->envCtx.unk_8C[5] = 0xFA;
globalCtx->envCtx.unk_8C[0] = globalCtx->envCtx.unk_8C[1] = globalCtx->envCtx.unk_8C[2] = 0xFA;
func_8005AA1C(&globalCtx->cameras[0], 2, 0xB, 8);
this->actor.params = BOMBFLOWER_EXPLOSION;
this->timer = 10;
this->actor.flags |= 0x20;
EnBombf_SetupAction(this, EnBombf_Explode);
}
}
}
this->actor.posRot2.pos = this->actor.posRot.pos;
this->actor.posRot2.pos.y += 10.0f;
if (this->actor.params <= BOMBFLOWER_BODY) {
Collider_CylinderUpdate(&this->actor, &this->bombCollider); // bombCollider goes to sp38 instead of sp3C
if ((this->flowerBombScale >= 1.0f) && (this->bumpOn)) {
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx,
&this->bombCollider.base); // bombCollider loads from sp38 instead of sp3C
}
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx,
&this->bombCollider.base); // bombCollider loads from sp38 instead of sp3C
}
if ((this->actor.scale.x >= 0.01f) && (this->actor.params != BOMBFLOWER_EXPLOSION)) {
if (this->actor.waterY >= 20.0f) {
func_8002A9F4(globalCtx, &this->actor.projectedPos, NA_SE_IT_BOMB_UNEXPLOSION, 1, 1, 0xA);
Actor_Kill(&this->actor);
return;
}
if (this->actor.bgCheckFlags & 0x40) {
this->actor.bgCheckFlags &= ~0x40;
Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER);
}
}
}
#else
Vec3f D_809C82C0 = { 0.0f, 0.0f, 0.0f };
Vec3f D_809C82CC = { 0.0f, 0.1f, 0.0f };
Vec3f D_809C82D8 = { 0.0f, 0.0f, 0.0f };
Vec3f D_809C82E4 = { 0.0f, 0.6f, 0.0f };
Color_RGBA8_n D_809C82F0 = { 255, 255, 255, 255 };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/EnBombf_Update.s")
#endif
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/func_809C7F24.s")
Gfx* EnBombf_NewMtxDList(GraphicsContext* gfxCtx, GlobalContext* globalCtx) {
Gfx* displayList;
Gfx* displayListHead;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Bombf/EnBombf_Draw.s")
displayList = Graph_Alloc(gfxCtx, 5 * sizeof(Gfx));
displayListHead = displayList;
func_800D1FD4(&globalCtx->mf_11DA0);
gSPMatrix(displayListHead++, Matrix_NewMtx(gfxCtx, "../z_en_bombf.c", 1021),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPEndDisplayList(displayListHead);
return displayList;
}
void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
EnBombf* this = THIS;
GraphicsContext* gfxCtx;
Gfx* disRefs[4];
if (1) {}
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(&disRefs, globalCtx->state.gfxCtx, "../z_en_bombf.c", 1034);
if (this->actor.params <= BOMBFLOWER_BODY) {
func_80093D18(globalCtx->state.gfxCtx);
if (this->actor.params != BOMBFLOWER_BODY) {
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bombf.c", 1041),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfxCtx->polyOpa.p++, D_06000340);
gSPDisplayList(gfxCtx->polyOpa.p++, D_06000530);
Matrix_Translate(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY);
Matrix_Scale(this->flowerBombScale, this->flowerBombScale, this->flowerBombScale, MTXMODE_APPLY);
}
gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, 200, 255, 200, 255);
gDPPipeSync(gfxCtx->polyOpa.p++);
gDPSetEnvColor(gfxCtx->polyOpa.p++, (s16)this->flashIntensity, 20, 10, 0);
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_bombf.c", 1054),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPSegment(gfxCtx->polyOpa.p++, 0x08,
SEGMENTED_TO_VIRTUAL(EnBombf_NewMtxDList(globalCtx->state.gfxCtx, globalCtx)));
gSPDisplayList(gfxCtx->polyOpa.p++, D_06000408);
} else {
func_800628A4(0, &this->explosionCollider);
}
Graph_CloseDisps(&disRefs, globalCtx->state.gfxCtx, "../z_en_bombf.c", 1063);
}

View file

@ -6,11 +6,28 @@
struct EnBombf;
typedef void (*EnBombfActionFunc)(struct EnBombf*, struct GlobalContext*);
typedef struct EnBombf {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0xC4];
/* 0x014C */ ColliderCylinder bombCollider;
/* 0x0198 */ ColliderJntSph explosionCollider;
/* 0x01B8 */ ColliderJntSphItem explosionColliderItems[1];
/* 0x01F8 */ s16 timer;
/* 0x01FC */ EnBombfActionFunc actionFunc;
/* 0x0200 */ s32 unk_200;
/* 0x0204 */ u8 bumpOn;
/* 0x0206 */ s16 flashSpeedScale;
/* 0x0208 */ f32 flashIntensity;
/* 0x020C */ f32 flowerBombScale;
} EnBombf; // size = 0x0210
typedef enum {
/* 0xFFFF */ BOMBFLOWER_FLOWER = -1,
/* 0x0000 */ BOMBFLOWER_BODY,
/* 0x0001 */ BOMBFLOWER_EXPLOSION,
} EnBombfType;
extern const ActorInit En_Bombf_InitVars;
#endif