1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-07 14:50:15 +00:00

Decomp EnNiwGirl (#306)

* Fix Repo

* Update z_en_niw.h

* PR fixes

* Update z_en_niw_girl.c

Add all masks to switch at 142

* Added currentMask enum

* Small fixes

* Cleaned up a lot of little things

* PR fixes
This commit is contained in:
louist103 2020-08-15 19:37:26 -04:00 committed by GitHub
parent 117b1f6a5c
commit da58af403b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 257 additions and 822 deletions

View file

@ -8,7 +8,11 @@ struct EnNiw;
typedef struct EnNiw {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x66C];
/* 0x014C */ char unk_14C[0x19C];
/* 0x02E8 */ s16 unk_2E8;
/* 0x02EA */ char unk_2EA[0x2];
/* 0x02EC */ s16 unk_2EC;
/* 0x02EE */ char unk_2EE[0x4CA];
} EnNiw; // size = 0x07B8
extern const ActorInit En_Niw_InitVars;

View file

@ -1,4 +1,11 @@
/*
* File: z_en_niw_girl.c
* Overlay: ovl_En_Niw_Girl
* Description: Girl that chases a cuckoo around in Hyrule Market and Kakariko Village
*/
#include "z_en_niw_girl.h"
#include <vt.h>
#define FLAGS 0x00000019
@ -9,7 +16,10 @@ void EnNiwGirl_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnNiwGirl_Update(Actor* thisx, GlobalContext* globalCtx);
void EnNiwGirl_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void EnNiwGirl_Talk(EnNiwGirl* this, GlobalContext* globalCtx);
void func_80AB94D0(EnNiwGirl* this, GlobalContext* globalCtx);
void func_80AB9210(EnNiwGirl* this, GlobalContext* globalCtx);
const ActorInit En_Niw_Girl_InitVars = {
ACTOR_EN_NIW_GIRL,
ACTORTYPE_NPC,
@ -21,21 +31,224 @@ const ActorInit En_Niw_Girl_InitVars = {
(ActorFunc)EnNiwGirl_Update,
(ActorFunc)EnNiwGirl_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/EnNiwGirl_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/EnNiwGirl_Destroy.s")
static ColliderCylinderInit sCylinderInit = {
{ COLTYPE_UNK10, 0x00, 0x00, 0x39, 0x20, COLSHAPE_CYLINDER },
{ 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 },
{ 10, 30, 0, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/func_80AB918C.s")
static Vec3f sConstVec3f = { 0.2f, 0.2f, 0.2f };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/func_80AB9210.s")
Gfx* D_80AB99D8[] = { 0x06004178, 0x06004978, 0x06005178 };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/func_80AB93C0.s")
extern SkeletonHeader D_06009948;
extern AnimationHeader D_06000378;
extern AnimationHeader D_06009C78;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/func_80AB94D0.s")
void EnNiwGirl_Init(Actor* thisx, GlobalContext* globalCtx) {
EnNiwGirl* this = THIS;
s32 pad;
Vec3f vec1;
Vec3f vec2;
s32 pad2;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/EnNiwGirl_Update.s")
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06009948, &D_06000378, &this->limbDrawTable,
&this->transitionDrawTable, 17);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
this->actor.unk_1F = 6;
if (this->actor.params < 0) {
this->actor.params = 0;
}
this->path = ((this->actor.params >> 8) & 0xFF);
this->actor.gravity = -3.0f;
Matrix_RotateY((this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW);
vec2.x = vec2.y = vec2.z = 0.0f;
vec1.x = vec1.y = 0.0f;
vec1.z = 50.0;
Matrix_MultVec3f(&vec1, &vec2);
this->chasedEnNiw = (EnNiw*)Actor_SpawnAttached(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_NIW,
this->actor.posRot.pos.x + vec2.x, this->actor.posRot.pos.y + vec2.y,
this->actor.posRot.pos.z + vec2.z, 0, this->actor.posRot.rot.y, 0, 0xA);
if (this->chasedEnNiw != NULL) {
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ シツレイしちゃうわね!プンプン ☆☆☆☆☆ %d\n" VT_RST, this->actor.params);
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ きゃははははは、まてー ☆☆☆☆☆ %d\n" VT_RST, this->path);
osSyncPrintf("\n\n");
this->actor.colChkInfo.mass = 0xFF;
this->actionFunc = EnNiwGirl_Talk;
} else {
osSyncPrintf("\n\n");
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ なぜか、セットできむぅあせん ☆☆☆☆☆ %d\n" VT_RST, this->actor.params);
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ んんがくく ☆☆☆☆☆ %d\n" VT_RST, this->path);
osSyncPrintf("\n\n");
Actor_Kill(&this->actor);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/func_80AB97E4.s")
void EnNiwGirl_Destroy(Actor* thisx, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Niw_Girl/EnNiwGirl_Draw.s")
void EnNiwGirl_Jump(EnNiwGirl* this, GlobalContext* globalCtx) {
f32 frameCount = SkelAnime_GetFrameCount(&D_06000378);
SkelAnime_ChangeAnim(&this->skelAnime, &D_06000378, 1.0f, 0.0f, frameCount, 0, -10.0f);
this->actor.flags &= ~1;
this->actionFunc = func_80AB9210;
}
void func_80AB9210(EnNiwGirl* this, GlobalContext* globalCtx) {
Path* path = &globalCtx->setupPathList[this->path];
f32 xDistBetween;
f32 zDistBetween;
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
Math_SmoothScaleMaxF(&this->actor.speedXZ, 3.0f, 0.2f, 0.4f);
// Find the X and Z distance between the girl and the cuckoo she is chasing
xDistBetween = this->chasedEnNiw->actor.posRot.pos.x - this->actor.posRot.pos.x;
zDistBetween = this->chasedEnNiw->actor.posRot.pos.z - this->actor.posRot.pos.z;
if (func_8010BDBC(&globalCtx->msgCtx) != 0) {
this->chasedEnNiw->unk_2E8 = 0;
}
if (sqrtf(SQ(xDistBetween) + SQ(zDistBetween)) < 70.0f) {
this->chasedEnNiw->unk_2E8 = (this->path + 1);
this->chasedEnNiw->unk_2EC = path->count;
} else if (sqrtf(SQ(xDistBetween) + SQ(zDistBetween)) > 150.0f) {
this->chasedEnNiw->unk_2E8 = 0;
}
// Change her angle so that she is always facing the cuckoo
Math_SmoothScaleMaxMinS(&this->actor.shape.rot.y, Math_atan2f(xDistBetween, zDistBetween) * 10430.378f, 3,
this->unk_27C, 0);
Math_SmoothScaleMaxF(&this->unk_27C, 5000.0f, 30.0f, 150.0f);
this->actor.posRot.rot.y = this->actor.shape.rot.y;
// Only allow Link to talk to her when she is playing the jumping animation
if ((this->jumpTimer == 0) || (func_8008F080(globalCtx) != 0)) {
this->jumpTimer = 60;
this->actionFunc = EnNiwGirl_Talk;
}
}
void EnNiwGirl_Talk(EnNiwGirl* this, GlobalContext* globalCtx) {
SkelAnime_ChangeAnim(&this->skelAnime, &D_06009C78, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_06009C78), 0, -10.0f);
this->actor.flags |= 1;
this->actor.textId = 0x7000;
if ((gSaveContext.eventChkInf[8] & 1) && (this->unk_27A == 0)) {
this->actor.textId = 0x70EA;
}
switch (func_8008F080(globalCtx)) {
case 1:
this->actor.textId = 0x7118;
break;
case 3:
this->actor.textId =
0x7119;
break;
case 4:
case 6:
case 7:
this->actor.textId = 0x711A;
break;
case 2:
case 5:
case 8:
this->actor.textId = 0x711B;
break;
}
this->unk_270 = 6;
this->actionFunc = func_80AB94D0;
}
void func_80AB94D0(EnNiwGirl* this, GlobalContext* globalCtx) {
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (func_8010BDBC(&globalCtx->msgCtx)) {
this->chasedEnNiw->unk_2E8 = 0;
}
Math_SmoothDownscaleMaxF(&this->actor.speedXZ, 0.8f, 0.2f);
if (func_8002F194(&this->actor, globalCtx)) {
if (this->actor.textId == 0x70EA) {
this->unk_27A = 1;
}
} else {
if ((this->jumpTimer == 0) && !func_8010BDBC(&globalCtx->msgCtx)) {
this->jumpTimer = Math_Rand_ZeroFloat(100.0f) + 250.0f;
this->actionFunc = EnNiwGirl_Jump;
} else {
func_8002F2CC(&this->actor, globalCtx, 100.0f);
}
}
}
void EnNiwGirl_Update(Actor* thisx, GlobalContext* globalCtx) {
EnNiwGirl* this = THIS;
EnNiwGirlActionFunc tempActionFunc;
Player* player = PLAYER;
Actor_SetScale(&this->actor, 0.013f);
this->unkUpTimer++;
tempActionFunc = func_80AB94D0;
if (this->unk_274 == 0) {
this->unk_272++;
if (this->unk_272 >= 3) {
this->unk_272 = 0;
this->unk_274 = (s16)Math_Rand_ZeroFloat(60.0f) + 20;
}
}
this->unk_280 = 30.0f;
Actor_SetHeight(&this->actor, 30.0f);
if (tempActionFunc == this->actionFunc) {
this->unk_2D4.unk_18 = player->actor.posRot.pos;
if (LINK_IS_CHILD) {
this->unk_2D4.unk_18.y = player->actor.posRot.pos.y - 10.0f;
}
func_80034A14(&this->actor, &this->unk_2D4, 2, 4);
this->unk_260 = this->unk_2D4.unk_08;
this->unk_266 = this->unk_2D4.unk_0E;
} else {
Math_SmoothScaleMaxMinS(&this->unk_266.y, 0, 5, 3000, 0);
Math_SmoothScaleMaxMinS(&this->unk_260.y, 0, 5, 3000, 0);
Math_SmoothScaleMaxMinS(&this->unk_260.z, 0, 5, 3000, 0);
}
if (this->unk_274 != 0) {
this->unk_274--;
}
if (this->jumpTimer != 0) {
this->jumpTimer--;
}
this->actionFunc(this, globalCtx);
Actor_MoveForward(&this->actor);
func_8002E4B4(globalCtx, &this->actor, 100.0f, 100.0f, 200.0f, 0x1C);
Collider_CylinderUpdate(&this->actor, &this->collider);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider);
}
s32 EnNiwGirlOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
Actor* thisx) {
EnNiwGirl* this = THIS;
if (limbIndex == 3) {
rot->x += this->unk_266.y;
}
if (limbIndex == 4) {
rot->x += this->unk_260.y;
rot->z += this->unk_260.z;
}
return 0;
}
void EnNiwGirl_Draw(Actor* thisx, GlobalContext* globalCtx) {
EnNiwGirl* this = THIS;
s32 pad;
Vec3f sp4C = sConstVec3f;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* dispRefs[4];
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_en_niw_girl.c", 573);
func_80093D18(globalCtx->state.gfxCtx);
gSPSegment(gfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(D_80AB99D8[this->unk_272]));
SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount,
EnNiwGirlOverrideLimbDraw, 0, &this->actor);
func_80033C30(&this->actor.posRot.pos, &sp4C, 255, globalCtx);
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_en_niw_girl.c", 592);
}

View file

@ -3,12 +3,33 @@
#include <ultra64.h>
#include <global.h>
#include "../ovl_En_Niw/z_en_niw.h"
struct EnNiwGirl;
typedef void (*EnNiwGirlActionFunc)(struct EnNiwGirl*, GlobalContext*);
typedef struct EnNiwGirl {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x1B0];
/* 0x014C */ SkelAnime skelAnime;
/* 0x0190 */ Vec3s limbDrawTable[17];
/* 0x01F6 */ Vec3s transitionDrawTable[17];
/* 0x025C */ EnNiwGirlActionFunc actionFunc;
/* 0x0260 */ Vec3s unk_260;
/* 0x0266 */ Vec3s unk_266;
/* 0x026C */ s16 jumpTimer; // Controls how many frames she jumps for and how long until she jumps again
/* 0x026E */ s16 unkUpTimer;
/* 0x0270 */ s16 unk_270;
/* 0x0272 */ s16 unk_272;
/* 0x0274 */ s16 unk_274;
/* 0x0276 */ s16 path;
/* 0x0278 */ s16 unk_278;
/* 0x027A */ s16 unk_27A;
/* 0x027C */ f32 unk_27C;
/* 0x0280 */ f32 unk_280;
/* 0x0284 */ EnNiw* chasedEnNiw;
/* 0x0288 */ ColliderCylinder collider;
/* 0x02D4 */ struct_80034A14_arg1 unk_2D4;
} EnNiwGirl; // size = 0x02FC
extern const ActorInit En_Niw_Girl_InitVars;