mirror of
https://github.com/zeldaret/mm.git
synced 2024-11-23 12:59:44 +00:00
Ovl en nutsball OK (#115)
* EnNutsball Match but one function with sp issues * Updated ActorPlayer * Renamed unk144 to timer and added data as comment * Got update matched but stack issues with two vars * add back new line * Fixed stack issue based on PR comments. Added data * more descriptive variable names * Use OPEN_DISPS/CLOSE_DISPS macros in draw * Address PR comments
This commit is contained in:
parent
fcc87b3ae2
commit
e39141fb3d
@ -6,6 +6,7 @@
|
||||
extern Gfx D_040008D0[];
|
||||
extern Gfx D_04029CB0[];
|
||||
extern Gfx D_04029CF0[];
|
||||
extern Gfx D_04058BA0[];
|
||||
extern Gfx D_0405AAB0[];
|
||||
extern UNK_TYPE D_0405BEF0;
|
||||
extern UNK_TYPE D_0405B6F0;
|
||||
|
@ -214,7 +214,8 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ Actor base;
|
||||
/* 0x144 */ UNK_TYPE1 pad144[0x3];
|
||||
/* 0x144 */ UNK_TYPE1 unk144;
|
||||
/* 0x145 */ UNK_TYPE1 pad145[0x2];
|
||||
/* 0x147 */ s8 itemActionParam;
|
||||
/* 0x148 */ UNK_TYPE1 pad148[0x2];
|
||||
/* 0x14A */ s8 heldItemActionParam;
|
||||
@ -266,7 +267,9 @@ typedef struct {
|
||||
/* 0xB9C */ Vec3f unkB9C;
|
||||
/* 0xBA8 */ UNK_TYPE1 padBA8[0x44];
|
||||
/* 0xBEC */ Vec3f bodyPartsPos[18];
|
||||
/* 0xCC4 */ UNK_TYPE1 padCC4[0xB4];
|
||||
/* 0xCC4 */ UNK_TYPE1 padCC4[0x40];
|
||||
/* 0xD04 */ MtxF unkD04;
|
||||
/* 0xD44 */ UNK_TYPE1 padD08[0x34];
|
||||
} ActorPlayer; // size = 0xD78
|
||||
|
||||
typedef enum {
|
||||
|
@ -3179,9 +3179,9 @@ SECTIONS
|
||||
ovl_En_Nutsball : AT(RomLocation)
|
||||
{
|
||||
build/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.o(.text)
|
||||
build/asm/overlays/ovl_En_Nutsball_data.o(.data)
|
||||
build/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.o(.data)
|
||||
build/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.o(.rodata)
|
||||
build/asm/overlays/ovl_En_Nutsball_rodata.o(.rodata)
|
||||
build/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball_overlay.o(.ovl)
|
||||
}
|
||||
SegmentEnd = .;
|
||||
SegmentSize = SegmentEnd - SegmentStart;
|
||||
|
@ -1,6 +1,7 @@
|
||||
D_040008D0 = 0x040008D0;
|
||||
D_04029CB0 = 0x04029CB0;
|
||||
D_04029CF0 = 0x04029CF0;
|
||||
D_04058BA0 = 0x04058BA0;
|
||||
D_0405AAB0 = 0x0405AAB0;
|
||||
D_0405BEF0 = 0x0405BEF0;
|
||||
D_0405B6F0 = 0x0405B6F0;
|
||||
|
@ -9,7 +9,9 @@ void EnNutsball_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
void EnNutsball_InitColliderParams(EnNutsball* this);
|
||||
|
||||
|
||||
const ActorInit En_Nutsball_InitVars = {
|
||||
ACTOR_EN_NUTSBALL,
|
||||
ACTORCAT_PROP,
|
||||
@ -21,14 +23,146 @@ const ActorInit En_Nutsball_InitVars = {
|
||||
(ActorFunc)EnNutsball_Update,
|
||||
(ActorFunc)EnNutsball_Draw
|
||||
};
|
||||
*/
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Nutsball_0x80985C40/EnNutsball_Init.asm")
|
||||
static ColliderCylinderInit sCylinderInit = {
|
||||
{
|
||||
COLTYPE_NONE,
|
||||
AT_ON | AT_TYPE_ENEMY,
|
||||
AC_ON | AC_TYPE_PLAYER,
|
||||
OC1_ON | OC1_TYPE_ALL,
|
||||
OC2_TYPE_2,
|
||||
COLSHAPE_CYLINDER,
|
||||
},
|
||||
{
|
||||
ELEMTYPE_UNK0,
|
||||
{ 0xF7CFFFFF, 0x00, 0x04 },
|
||||
{ 0xF7CFFFFF, 0x00, 0x00 },
|
||||
TOUCH_ON | TOUCH_SFX_WOOD,
|
||||
BUMP_ON,
|
||||
OCELEM_ON,
|
||||
},
|
||||
{ 13, 13, 0, { 0, 0, 0 } },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Nutsball_0x80985C40/EnNutsball_Destroy.asm")
|
||||
void EnNutsball_Init(Actor *thisx, GlobalContext *globalCtx) {
|
||||
EnNutsball *this = THIS;
|
||||
|
||||
ActorShape_Init(&this->actor.shape, 400.0f, (ActorShadowFunc)func_800B3FC0, 13.0f);
|
||||
Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
|
||||
this->actor.shape.rot.y = 0;
|
||||
this->actor.speedXZ = 10.0f;
|
||||
if (this->actor.params == 2) {
|
||||
this->timer = 1;
|
||||
this->timerThreshold = 0;
|
||||
this->actor.gravity = -1.0f;
|
||||
} else {
|
||||
this->timer = 20;
|
||||
this->timerThreshold = 19;
|
||||
this->actor.gravity = -0.5f;
|
||||
}
|
||||
this->actor.world.rot.x = -this->actor.shape.rot.x;
|
||||
this->actor.shape.rot.x = 0;
|
||||
if (this->actor.params == 1) {
|
||||
EnNutsball_InitColliderParams(this);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Nutsball_0x80985C40/func_80985D3C.asm")
|
||||
void EnNutsball_Destroy(Actor *thisx, GlobalContext *globalCtx) {
|
||||
EnNutsball *this = THIS;
|
||||
Collider_DestroyCylinder(globalCtx, &this->collider);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Nutsball_0x80985C40/EnNutsball_Update.asm")
|
||||
void EnNutsball_InitColliderParams(EnNutsball *this) {
|
||||
this->collider.base.atFlags &= ~AT_TYPE_ENEMY & ~AT_BOUNCED & ~AT_HIT;
|
||||
this->collider.base.atFlags |= AT_TYPE_PLAYER;
|
||||
this->collider.info.toucher.dmgFlags = 0x400000;
|
||||
this->collider.info.toucher.damage = 2;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Nutsball_0x80985C40/EnNutsball_Draw.asm")
|
||||
void EnNutsball_Update(Actor *thisx, GlobalContext *globalCtx) {
|
||||
EnNutsball *this = THIS;
|
||||
GlobalContext *globalCtx2 = globalCtx;
|
||||
|
||||
ActorPlayer *player = PLAYER;
|
||||
Vec3f worldPos;
|
||||
Vec3s worldRot;
|
||||
Vec3f spawnBurstPos;
|
||||
f32 spdXZ;
|
||||
u32 bgId;
|
||||
CollisionPoly *poly;
|
||||
|
||||
if (!(player->stateFlags1 & 0x300000C0)) {
|
||||
this->timer--;
|
||||
if (this->timer < 0) {
|
||||
this->actor.velocity.y += this->actor.gravity;
|
||||
spdXZ = sqrtf((this->actor.velocity.x * this->actor.velocity.x) + (this->actor.velocity.z * this->actor.velocity.z));
|
||||
this->actor.world.rot.x = Math_FAtan2F(spdXZ, this->actor.velocity.y);
|
||||
}
|
||||
this->actor.home.rot.z += 0x2AA8;
|
||||
if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 16) || (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) {
|
||||
if ((player->unk144 == 1) && (this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_TYPE_ENEMY) && (this->collider.base.atFlags & AT_BOUNCED)) {
|
||||
EnNutsball_InitColliderParams(this);
|
||||
func_8018219C(&player->unkD04, &worldRot, 0);
|
||||
this->actor.world.rot.y = worldRot.y + 0x8000;
|
||||
this->timer = 20;
|
||||
} else {
|
||||
spawnBurstPos.x = this->actor.world.pos.x;
|
||||
spawnBurstPos.y = this->actor.world.pos.y + 4.0f;
|
||||
spawnBurstPos.z = this->actor.world.pos.z;
|
||||
EffectSsHahen_SpawnBurst(globalCtx, &spawnBurstPos, 0x40C00000, 0, 7, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL);
|
||||
if (this->actor.params == 1) {
|
||||
func_800F0568(globalCtx, &this->actor.world.pos, 20, 0x28F4);
|
||||
} else {
|
||||
func_800F0568(globalCtx, &this->actor.world.pos, 20, 0x38C0);
|
||||
}
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
}
|
||||
} else {
|
||||
if (this->timer == -300) {
|
||||
Actor_MarkForDeath(&this->actor);
|
||||
}
|
||||
}
|
||||
|
||||
Actor_SetVelocityAndMoveXYRotation(&this->actor);
|
||||
Math_Vec3f_Copy(&worldPos, &this->actor.world.pos);
|
||||
func_800B78B8(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 7);
|
||||
|
||||
if (this->actor.bgCheckFlags & 8) {
|
||||
if (func_800C9A4C(&globalCtx2->colCtx, this->actor.wallPoly, this->actor.wallBgId) & 0x30) {
|
||||
this->actor.bgCheckFlags &= ~8;
|
||||
if (func_800C55C4(&globalCtx2->colCtx, &this->actor.prevPos, &worldPos, &this->actor.world.pos, &poly, 1, 0, 0, 1, &bgId)) {
|
||||
if (func_800C9A4C(&globalCtx2->colCtx, poly, bgId) & 0x30) {
|
||||
this->actor.world.pos.x += this->actor.velocity.x * 0.01f;
|
||||
this->actor.world.pos.z += this->actor.velocity.z * 0.01f;
|
||||
} else {
|
||||
this->actor.bgCheckFlags |= 8;
|
||||
}
|
||||
} else {
|
||||
Math_Vec3f_Copy(&this->actor.world.pos, &worldPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collider_UpdateCylinder(&this->actor, &this->collider);
|
||||
|
||||
this->actor.flags |= 0x1000000;
|
||||
|
||||
CollisionCheck_SetAT(globalCtx, &globalCtx->colCheckCtx, &this->collider.base);
|
||||
CollisionCheck_SetAC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base);
|
||||
|
||||
if (this->timer < this->timerThreshold) {
|
||||
CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnNutsball_Draw(Actor *thisx, GlobalContext *globalCtx) {
|
||||
EnNutsball *this = THIS;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx)
|
||||
func_8012C28C(globalCtx->state.gfxCtx);
|
||||
SysMatrix_InsertMatrix(&globalCtx->unk187FC, 1);
|
||||
SysMatrix_InsertZRotation_s(this->actor.home.rot.z, 1);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_OPA_DISP++, D_04058BA0);
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ struct EnNutsball;
|
||||
|
||||
typedef struct EnNutsball {
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ char unk_144[0x50];
|
||||
/* 0x144 */ s16 timer;
|
||||
/* 0x146 */ s16 timerThreshold;
|
||||
/* 0x148 */ ColliderCylinder collider;
|
||||
} EnNutsball; // size = 0x194
|
||||
|
||||
extern const ActorInit En_Nutsball_InitVars;
|
||||
|
@ -8307,7 +8307,7 @@
|
||||
0x80985538:("EnMinislime_Update",),
|
||||
0x80985C40:("EnNutsball_Init",),
|
||||
0x80985D10:("EnNutsball_Destroy",),
|
||||
0x80985D3C:("func_80985D3C",),
|
||||
0x80985D3C:("EnNutsball_InitColliderParams",),
|
||||
0x80985D68:("EnNutsball_Update",),
|
||||
0x80986120:("EnNutsball_Draw",),
|
||||
0x80986270:("OceffWipe2_Init",),
|
||||
|
Loading…
Reference in New Issue
Block a user