mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 06:24:30 +00:00
en_dog OK
This commit is contained in:
parent
898a103b78
commit
f3b509eb68
32 changed files with 373 additions and 1383 deletions
|
@ -3,27 +3,18 @@
|
|||
#define ROOM 0x00
|
||||
#define FLAGS 0x00000000
|
||||
|
||||
void func_809FAFD0(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB038(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB0A0(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB108(EnDog* this);
|
||||
s8 func_809FB29C(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB320(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB3AC(EnDog* this, GlobalContext* globalCtx);
|
||||
void EnDog_Init(EnDog* this, GlobalContext* globalCtx);
|
||||
void EnDog_Destroy(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB6C4(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB858(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FB940(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FBABC(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FBB64(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FBC6C(EnDog* this, GlobalContext* globalCtx);
|
||||
void EnDog_Update(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FBD8C(EnDog* this, GlobalContext* globalCtx);
|
||||
void func_809FBDA4(EnDog* this, GlobalContext* globalCtx);
|
||||
void EnDog_Draw(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_Init(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_Destroy(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_Update(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_Draw(EnDog* this, GlobalContext* globalCtx);
|
||||
|
||||
static void EnDog_FollowPath(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_ChooseMovement(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_FollowLink(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_RunAway(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_FaceLink(EnDog* this, GlobalContext* globalCtx);
|
||||
static void EnDog_Wait(EnDog* this, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
const ActorInit En_Dog_InitVars =
|
||||
{
|
||||
ACTOR_EN_DOG,
|
||||
|
@ -37,11 +28,10 @@ const ActorInit En_Dog_InitVars =
|
|||
(ActorFunc)EnDog_Update,
|
||||
(ActorFunc)EnDog_Draw,
|
||||
};
|
||||
*/
|
||||
|
||||
static ColliderCylinderInit cylinderInit =
|
||||
{
|
||||
0x06, 0x00, 0x09, 0x39, // ColliderBodyInfo
|
||||
0x06, 0x00, 0x09, 0x39,
|
||||
0x10, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00000000,
|
||||
|
@ -50,12 +40,14 @@ static ColliderCylinderInit cylinderInit =
|
|||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x01, 0x00,
|
||||
|
||||
0x0010, // radius
|
||||
0x0014, // height
|
||||
0x0000, // yShift
|
||||
0x0000, 0x0000, 0x0000 //Vec3s xyz
|
||||
0x0010,
|
||||
0x0014,
|
||||
0x0000,
|
||||
0x0000, 0x0000, 0x0000,
|
||||
};
|
||||
|
||||
// There are multiple versions of sub98 init structs
|
||||
// Keeping these local until z_collision_check is decompiled
|
||||
typedef struct
|
||||
{
|
||||
/* 0x00 */ u8 health;
|
||||
|
@ -65,82 +57,170 @@ typedef struct
|
|||
/* 0x08 */ u8 mass;
|
||||
}sub98Init;
|
||||
|
||||
sub98Init sub98Data =
|
||||
static sub98Init sub98Data =
|
||||
{
|
||||
0x00, //health
|
||||
0x0000, //unk_10
|
||||
0x0000, //unk_12
|
||||
0x0000, //unk_14
|
||||
0x32 //mass
|
||||
0x32, //mass
|
||||
};
|
||||
|
||||
struct_80034EC0_Entry skelanimeArr[]=
|
||||
static struct_80034EC0_Entry animations[]=
|
||||
{
|
||||
{0x06001368, 1.0f, 0.0f, -1.0f, 0x00, 0.0f},
|
||||
{0x06001368, 1.0f, 0.0f, -1.0f, 0x00, -6.0f},
|
||||
{0x06000D78, 1.0f, 0.0f, -1.0f, 0x00, -6.0f},
|
||||
{0x06000278, 1.0f, 0.0f, -1.0f, 0x00, -6.0f},
|
||||
{0x06001150, 1.0f, 0.0f, 4.0f, 0x02, -6.0f},
|
||||
{0x06001150, 1.0f, 0.0f, 25.0f,0x04, -6.0f},
|
||||
{0x06001150, 1.0f, 5.0f, 25.0f,0x04, -6.0f},
|
||||
{0x06000928, 1.0f, 0.0f, 6.0f, 0x02, -6.0f},
|
||||
{0x06000C28, 1.0f, 0.0f, -1.0f, 0x00, -6.0f}
|
||||
{0x06000C28, 1.0f, 0.0f, -1.0f, 0x00, -6.0f},
|
||||
};
|
||||
|
||||
extern D_06007290;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FAFD0.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FB038.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FB0A0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FB108.s")
|
||||
/*
|
||||
void func_809FB108(EnDog* this)
|
||||
// Bandaid fix for a lw vs lh issue in EnDog_FollowPath. Roman will look at it later.
|
||||
typedef union
|
||||
{
|
||||
s32 animationIndex;
|
||||
|
||||
if (this->unk_1F0 != this->unk_1F2)
|
||||
/* 0x00 */ s32 entry;
|
||||
struct
|
||||
{
|
||||
if (this->unk_1F0 == 4)
|
||||
{
|
||||
this->unk_1F0 = 3;
|
||||
}
|
||||
if (this->unk_1F0 == 6)
|
||||
{
|
||||
this->unk_1F0 = 5;
|
||||
}
|
||||
s16 unk_0;
|
||||
s16 unk_2;
|
||||
};
|
||||
}s16ArrEntry;
|
||||
|
||||
this->unk_1F2 = this->unk_1F0;
|
||||
if (this->unk_1F0 < 6U)
|
||||
{
|
||||
switch(this->unk_1F0)
|
||||
{
|
||||
case 1: animationIndex = 2;
|
||||
case 2: animationIndex = 3;
|
||||
case 3: animationIndex = 4;
|
||||
case 5: animationIndex = 6;
|
||||
default: animationIndex = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
typedef enum
|
||||
{
|
||||
/* 0x00 */ DOG_WALK,
|
||||
/* 0x01 */ DOG_RUN,
|
||||
/* 0x02 */ DOG_BARK,
|
||||
/* 0x03 */ DOG_SIT,
|
||||
/* 0x04 */ DOG_SIT_2,
|
||||
/* 0x05 */ DOG_BOW,
|
||||
/* 0x06 */ DOG_BOW_2,
|
||||
} DogBehavior;
|
||||
|
||||
if (this->unk_1F2 < 6U)
|
||||
extern UNK_PTR D_06007290;
|
||||
extern UNK_PTR D_06001368;
|
||||
extern UNK_PTR D_06000D78;
|
||||
extern UNK_PTR D_06000278;
|
||||
|
||||
static void EnDog_WalkSFX(EnDog* this)
|
||||
{
|
||||
u32* walk = &D_06001368;
|
||||
if (this->skelAnime.animCurrent == walk)
|
||||
{
|
||||
|
||||
if ((this->skelAnime.animCurrentFrame == 1.0f) || (this->skelAnime.animCurrentFrame == 7.0f))
|
||||
{
|
||||
Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
s8 func_809FB29C(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_RunSFX(EnDog* this)
|
||||
{
|
||||
u32* run = &D_06000D78;
|
||||
if (this->skelAnime.animCurrent == run)
|
||||
{
|
||||
if ((this->skelAnime.animCurrentFrame == 2.0f) || (this->skelAnime.animCurrentFrame == 4.0f))
|
||||
{
|
||||
Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_WALK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void EnDog_BarkSFX(EnDog* this)
|
||||
{
|
||||
u32* bark = &D_06000278;
|
||||
if (this->skelAnime.animCurrent == bark)
|
||||
{
|
||||
if ((this->skelAnime.animCurrentFrame == 13.0f) || (this->skelAnime.animCurrentFrame == 19.0f))
|
||||
{
|
||||
Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static s32 EnDog_PlayAnimSFX(EnDog* this)
|
||||
{
|
||||
s32 animation;
|
||||
|
||||
if (this->behavior != this->nextBehavior)
|
||||
{
|
||||
if (this->nextBehavior == DOG_SIT_2)
|
||||
{
|
||||
this->nextBehavior = DOG_SIT;
|
||||
}
|
||||
if (this->nextBehavior == DOG_BOW_2)
|
||||
{
|
||||
this->nextBehavior = DOG_BOW;
|
||||
}
|
||||
|
||||
this->behavior = this->nextBehavior;
|
||||
switch(this->behavior)
|
||||
{
|
||||
case DOG_WALK:
|
||||
animation = 1;
|
||||
break;
|
||||
case DOG_RUN:
|
||||
animation = 2;
|
||||
break;
|
||||
case DOG_BARK:
|
||||
animation = 3;
|
||||
break;
|
||||
case DOG_SIT:
|
||||
animation = 4;
|
||||
break;
|
||||
case DOG_BOW:
|
||||
animation = 6;
|
||||
break;
|
||||
}
|
||||
func_80034EC0(&this->skelAnime, &animations, animation);
|
||||
}
|
||||
|
||||
switch(this->behavior)
|
||||
{
|
||||
case DOG_SIT:
|
||||
if (func_800A56C8(&this->skelAnime, this->skelAnime.animFrameCount) != 0)
|
||||
{
|
||||
func_80034EC0(&this->skelAnime, &animations, 5);
|
||||
this->behavior = this->nextBehavior = DOG_SIT_2;
|
||||
}
|
||||
break;
|
||||
case DOG_BOW:
|
||||
if (func_800A56C8(&this->skelAnime, this->skelAnime.animFrameCount) != 0)
|
||||
{
|
||||
func_80034EC0(&this->skelAnime, &animations, 7);
|
||||
this->behavior = this->nextBehavior = DOG_BOW_2;
|
||||
}
|
||||
break;
|
||||
case DOG_WALK:
|
||||
EnDog_WalkSFX(this);
|
||||
break;
|
||||
case DOG_RUN:
|
||||
EnDog_RunSFX(this);
|
||||
break;
|
||||
case DOG_BARK:
|
||||
EnDog_BarkSFX(this);
|
||||
if (this){} // needed for regalloc
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static s8 EnDog_CanFollow(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
if ((this->collider.base.collideFlags & 2) != 0)
|
||||
{
|
||||
this->collider.base.collideFlags &= 0xFFFD;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (globalCtx->sceneNum == SCENE_MARKET_DAY)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((this->collider.base.maskB & 1) != 0)
|
||||
{
|
||||
this->collider.base.maskB &= 0xFFFE;
|
||||
|
@ -151,13 +231,67 @@ s8 func_809FB29C(EnDog* this, GlobalContext* globalCtx)
|
|||
gSaveContext.dogParams = (this->actor.params & 0x7FFF);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FB320.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FB3AC.s")
|
||||
static EnDog_UpdateWaypoint(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s32 change;
|
||||
|
||||
void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
|
||||
if (this->path == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this->reverse)
|
||||
{
|
||||
change = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
change = 1;
|
||||
}
|
||||
|
||||
this->waypoint += change;
|
||||
|
||||
if (this->reverse != 0)
|
||||
{
|
||||
if (this->waypoint < 0)
|
||||
{
|
||||
this->waypoint = this->path->count - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((this->path->count - 1) < this->waypoint)
|
||||
{
|
||||
this->waypoint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static s32 EnDog_Orient(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s16 targetYaw;
|
||||
f32 waypointDistSq;
|
||||
|
||||
waypointDistSq = func_8008E520(&this->actor, this->path, this->waypoint, &targetYaw);
|
||||
Math_SmoothScaleMaxMinS(&this->actor.posRot.rot.y, targetYaw, 10, 1000, 1);
|
||||
|
||||
if ((waypointDistSq > 0.0f) && (waypointDistSq < 1000.0f))
|
||||
{
|
||||
return EnDog_UpdateWaypoint(this, globalCtx);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
SkelAnime* skelAnime;
|
||||
s16 followingDog;
|
||||
|
@ -167,11 +301,11 @@ void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
|
|||
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 24.0f);
|
||||
skelAnime = &this->skelAnime;
|
||||
func_800A46F8(globalCtx, skelAnime, &D_06007290, 0, &this->unk_1F4, &this->unk_242, 13);
|
||||
func_80034EC0(skelAnime, skelanimeArr, 0);
|
||||
func_80034EC0(skelAnime, animations, 0);
|
||||
|
||||
if ((this->actor.params & 0x8000) == 0)
|
||||
{
|
||||
this->actor.params = (this->actor.params & 0xF0FF) | ((((this->actor.params & 0xF00) >> 8) + 1) << 8);
|
||||
this->actor.params = (this->actor.params & 0xF0FF) | ((((this->actor.params & 0x0F00) >> 8) + 1) << 8);
|
||||
}
|
||||
|
||||
followingDog = ((gSaveContext.dogParams & 0x0F00) >> 8);
|
||||
|
@ -185,9 +319,9 @@ void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
|
|||
ActorCollider_InitCylinder(globalCtx, collider, &this->actor, &cylinderInit);
|
||||
func_80061EFC(&this->actor.sub_98, 0, &sub98Data);
|
||||
Actor_SetScale(&this->actor, 0.0075f);
|
||||
this->unk_1E6 = 0;
|
||||
this->waypoint = 0;
|
||||
this->actor.gravity = -1.0f;
|
||||
this->movementPath = func_8008E4E0(globalCtx, ((((this->actor.params & 0x00F0) >> 4) << 0x10) >> 0x10), 0xF);
|
||||
this->path = func_8008E4E0(globalCtx, (s16)((this->actor.params & 0x00F0) >> 4), 0xF);
|
||||
|
||||
switch (globalCtx->sceneNum)
|
||||
{
|
||||
|
@ -203,8 +337,8 @@ void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
|
|||
{
|
||||
if (gSaveContext.richardIsLost == 0)
|
||||
{
|
||||
this->unk_1F0 = 3;
|
||||
this->actionFunc = &func_809FBC6C;
|
||||
this->nextBehavior = DOG_SIT;
|
||||
this->actionFunc = EnDog_Wait;
|
||||
this->actor.speedXZ = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
@ -221,102 +355,136 @@ void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
|
|||
|
||||
if ((u32)(this->actor.params & 0x8000) != 0)
|
||||
{
|
||||
this->unk_1F0 = 0;
|
||||
this->actionFunc = &func_809FB940;
|
||||
this->nextBehavior = DOG_WALK;
|
||||
this->actionFunc = EnDog_FollowLink;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unk_1F0 = 3;
|
||||
this->actionFunc = &func_809FB858;
|
||||
this->nextBehavior = DOG_SIT;
|
||||
this->actionFunc = EnDog_ChooseMovement;
|
||||
}
|
||||
}
|
||||
|
||||
void EnDog_Destroy(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_Destroy(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
ColliderCylinderMain* collider = &this->collider;
|
||||
ActorCollider_FreeCylinder(globalCtx, collider);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FB6C4.s")
|
||||
|
||||
void func_809FB858(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_FollowPath(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s32 temp1EC;
|
||||
s16ArrEntry behaviors[] = { 3, 5, 2 };
|
||||
s16ArrEntry unused[] = { 40, 80, 20 };
|
||||
f32 speed;
|
||||
s32 frame;
|
||||
|
||||
if (func_809FB29C(this, globalCtx) == 1) //if this dog is the one thats following
|
||||
if (EnDog_CanFollow(this, globalCtx) == 1)
|
||||
{
|
||||
this->actionFunc = &func_809FB940; //follow function?
|
||||
this->actionFunc = EnDog_FollowLink;
|
||||
}
|
||||
|
||||
if (this->unk_1EC == 0)
|
||||
if(DECR(this->behaviorTimer))
|
||||
{
|
||||
temp1EC = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unk_1EC -= 1;
|
||||
temp1EC = this->unk_1EC;
|
||||
}
|
||||
|
||||
if(temp1EC == 0)
|
||||
{
|
||||
this->unk_1EC = Math_Rand_S16Offset(200, 100);
|
||||
if ((globalCtx->state.frames & 1) != 0) //odd frame
|
||||
if (this->nextBehavior == DOG_WALK)
|
||||
{
|
||||
this->unk_1F0 = 0;
|
||||
speed = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unk_1F0 = 1;
|
||||
speed = 4.0f;
|
||||
}
|
||||
Math_SmoothScaleMaxMinF(&this->actor.speedXZ, speed, 0.4f, 1.0f, 0.0f);
|
||||
EnDog_Orient(this, globalCtx);
|
||||
this->actor.shape.rot = this->actor.posRot.rot;
|
||||
|
||||
// Used to change between two text boxes for Richard's owner in the Market Day scene
|
||||
// depending on where he is on his path. En_Hy checks these event flags.
|
||||
if (this->waypoint < 9)
|
||||
{
|
||||
// Richard is close to her, text says something about his coat
|
||||
gSaveContext.event_inf[3] |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Richard is far, text says something about running fast
|
||||
gSaveContext.event_inf[3] &= ~1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = globalCtx->state.frames % 3;
|
||||
this->nextBehavior = behaviors[frame].entry;
|
||||
// no clue why they're using the action id to calculate timer. possibly meant to use the unused array?
|
||||
this->behaviorTimer = Math_Rand_S16Offset(60, behaviors[frame].unk_2);
|
||||
this->actionFunc = EnDog_ChooseMovement;
|
||||
}
|
||||
}
|
||||
|
||||
static void EnDog_ChooseMovement(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
if (EnDog_CanFollow(this, globalCtx) == 1)
|
||||
{
|
||||
this->actionFunc = EnDog_FollowLink;
|
||||
}
|
||||
|
||||
if(DECR(this->behaviorTimer) == 0)
|
||||
{
|
||||
this->behaviorTimer = Math_Rand_S16Offset(200, 100);
|
||||
if (globalCtx->state.frames % 2)
|
||||
{
|
||||
this->nextBehavior = DOG_WALK;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->nextBehavior = DOG_RUN;
|
||||
}
|
||||
|
||||
if (this->unk_1F0 == 1)
|
||||
if (this->nextBehavior == DOG_RUN)
|
||||
{
|
||||
this->unk_1EC = (this->unk_1EC / 2);
|
||||
this->behaviorTimer = (this->behaviorTimer / 2);
|
||||
}
|
||||
this->actionFunc = &func_809FB6C4;
|
||||
this->actionFunc = EnDog_FollowPath;
|
||||
}
|
||||
Math_SmoothScaleMaxMinF(&this->actor.speedXZ, 0.0f, 0.4f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
//EnDog_Follow
|
||||
void func_809FB940(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_FollowLink(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
f32 speed;
|
||||
|
||||
if (gSaveContext.dogParams == 0)
|
||||
{
|
||||
this->unk_1F0 = 3;
|
||||
this->actionFunc = &func_809FBC6C;
|
||||
this->nextBehavior = DOG_SIT;
|
||||
this->actionFunc = EnDog_Wait;
|
||||
this->actor.speedXZ = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->actor.xzDistanceFromLink > 400.0f)
|
||||
{
|
||||
if (this->unk_1F0 != 3 && this->unk_1F0 != 4)
|
||||
if (this->nextBehavior != DOG_SIT && this->nextBehavior != DOG_SIT_2)
|
||||
{
|
||||
this->unk_1F0 = 5;
|
||||
this->nextBehavior = DOG_BOW;
|
||||
}
|
||||
gSaveContext.dogParams = 0;
|
||||
speed = 0.0f;
|
||||
}
|
||||
else if (this->actor.xzDistanceFromLink > 100.0f)
|
||||
{
|
||||
this->unk_1F0 = 1;
|
||||
this->nextBehavior = DOG_RUN;
|
||||
speed = 4.0f;
|
||||
}
|
||||
else if (this->actor.xzDistanceFromLink < 40.0f)
|
||||
{
|
||||
if (this->unk_1F0 != 5 && this->unk_1F0 != 6)
|
||||
if (this->nextBehavior != DOG_BOW && this->nextBehavior != DOG_BOW_2)
|
||||
{
|
||||
this->unk_1F0 = 5;
|
||||
this->nextBehavior = DOG_BOW;
|
||||
}
|
||||
speed = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unk_1F0 = 0;
|
||||
this->nextBehavior = DOG_WALK;
|
||||
speed = 1.0f;
|
||||
}
|
||||
|
||||
|
@ -329,7 +497,7 @@ void func_809FB940(EnDog* this, GlobalContext* globalCtx)
|
|||
}
|
||||
}
|
||||
|
||||
void func_809FBABC(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_RunAway(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
if (this->actor.xzDistanceFromLink < 200.0f)
|
||||
{
|
||||
|
@ -338,20 +506,21 @@ void func_809FBABC(EnDog* this, GlobalContext* globalCtx)
|
|||
}
|
||||
else
|
||||
{
|
||||
this->actionFunc = &func_809FBB64;
|
||||
this->actionFunc = EnDog_FaceLink;
|
||||
}
|
||||
this->actor.shape.rot = this->actor.posRot.rot;
|
||||
}
|
||||
|
||||
void func_809FBB64(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_FaceLink(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s16 rotTowardLink;
|
||||
s16 prevRotY;
|
||||
f32 absAngleDiff;
|
||||
|
||||
// if the dog is more than 200 units away from Link, turn to face him then wait
|
||||
if (200.0f <= this->actor.xzDistanceFromLink)
|
||||
{
|
||||
this->unk_1F0 = 0;
|
||||
this->nextBehavior = DOG_WALK;
|
||||
|
||||
Math_SmoothScaleMaxF(&this->actor.speedXZ, 1.0f, 0.6f, 1.0f);
|
||||
|
||||
|
@ -359,51 +528,79 @@ void func_809FBB64(EnDog* this, GlobalContext* globalCtx)
|
|||
prevRotY = this->actor.posRot.rot.y;
|
||||
Math_SmoothScaleMaxMinS(&this->actor.posRot.rot.y, rotTowardLink, 10, 1000, 1);
|
||||
|
||||
//weird temp reuse needed for regalloc
|
||||
absAngleDiff = this->actor.posRot.rot.y;
|
||||
absAngleDiff -= prevRotY;
|
||||
absAngleDiff = fabsf(absAngleDiff);
|
||||
if (absAngleDiff < 200.0f)
|
||||
{
|
||||
this->unk_1F0 = 3;
|
||||
this->actionFunc = &func_809FBC6C;
|
||||
this->nextBehavior = 3;
|
||||
this->actionFunc = EnDog_Wait;
|
||||
this->actor.speedXZ = 0.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unk_1F0 = 1;
|
||||
this->actionFunc = &func_809FBABC;
|
||||
this->nextBehavior = DOG_RUN;
|
||||
this->actionFunc = EnDog_RunAway;
|
||||
}
|
||||
this->actor.shape.rot = this->actor.posRot.rot;
|
||||
}
|
||||
|
||||
void func_809FBC6C(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_Wait(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
this->spawnAngle = (this->actor.rotTowardsLinkY - this->actor.shape.rot.y);
|
||||
if ((gSaveContext.richardIsLost != 0) && (this->actor.xzDistanceFromLink < 200.0f))
|
||||
this->unusedAngle = (this->actor.rotTowardsLinkY - this->actor.shape.rot.y);
|
||||
|
||||
// If another dog is following Link and he gets within 200 units of waiting dog, run away
|
||||
if ((gSaveContext.dogParams != 0) && (this->actor.xzDistanceFromLink < 200.0f))
|
||||
{
|
||||
this->unk_1F0 = 1;
|
||||
this->actionFunc = &func_809FBABC;
|
||||
this->nextBehavior = DOG_RUN;
|
||||
this->actionFunc = EnDog_RunAway;
|
||||
}
|
||||
}
|
||||
|
||||
void EnDog_Update(EnDog* this, GlobalContext* globalCtx)
|
||||
static void EnDog_Update(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s32 pad1;
|
||||
s32 pad2;
|
||||
|
||||
func_809FB108(this);
|
||||
EnDog_PlayAnimSFX(this);
|
||||
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
|
||||
func_8002E4B4(globalCtx, &this->actor, (f32)this->collider.dim.radius, (f32)this->collider.dim.height * 0.5f, 0.0f, 5);
|
||||
func_8002E4B4(globalCtx, &this->actor, (f32)this->collider.dim.radius,
|
||||
(f32)this->collider.dim.height * 0.5f, 0.0f, 5);
|
||||
Actor_MoveForward(&this->actor);
|
||||
this->actionFunc(this, globalCtx);
|
||||
ActorCollider_Cylinder_Update(&this->actor, &this->collider);
|
||||
Actor_CollisionCheck_SetOT(globalCtx, &globalCtx->sub_11E60, &this->collider);
|
||||
}
|
||||
|
||||
static UNK_TYPE EnDog_Callback1(UNK_TYPE unused1, UNK_TYPE unused2, UNK_TYPE unused3, UNK_TYPE unused4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FBD8C.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/func_809FBDA4.s")
|
||||
static void EnDog_Callback2(UNK_TYPE unused1, UNK_TYPE unused2, UNK_TYPE unused3, UNK_TYPE unused4)
|
||||
{
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Dog/EnDog_Draw.s")
|
||||
}
|
||||
|
||||
static void EnDog_Draw(EnDog* this, GlobalContext* globalCtx)
|
||||
{
|
||||
s32 pad;
|
||||
Color_RGBA8 colors[] = { {0xFF, 0xFF, 0xC8, 0x00}, {0x96, 0x64, 0x32, 0x00} };
|
||||
GraphicsContext* gfxCtx;
|
||||
s32 pad2[2];
|
||||
Gfx* gfxArr[2];
|
||||
|
||||
gfxCtx = globalCtx->state.gfxCtx;
|
||||
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_en_dog.c", 972);
|
||||
func_80093D18(globalCtx->state.gfxCtx);
|
||||
|
||||
gDPPipeSync(gfxCtx->polyOpa.p++);
|
||||
gDPSetEnvColor(gfxCtx->polyOpa.p++,
|
||||
colors[this->actor.params & 0xF].r, colors[this->actor.params & 0xF].g,
|
||||
colors[this->actor.params & 0xF].b, colors[this->actor.params & 0xF].a);
|
||||
|
||||
func_800A1AC8(globalCtx, this->skelAnime.limbIndex, this->skelAnime.actorDrawTbl,
|
||||
this->skelAnime.dListCount, EnDog_Callback1, EnDog_Callback2, &this->actor);
|
||||
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_en_dog.c", 994);
|
||||
}
|
||||
|
|
|
@ -11,19 +11,19 @@ typedef struct
|
|||
/* 0x018C */ char unk_18C[0x4];
|
||||
/* 0x0190 */ ActorFunc actionFunc;
|
||||
/* 0x0194 */ ColliderCylinderMain collider;
|
||||
/* 0x01E0 */ UNK_PTR movementPath;
|
||||
/* 0x01E4 */ char unk_1E4[0x2];
|
||||
/* 0x01E6 */ u16 unk_1E6;
|
||||
/* 0x01E8 */ s16 spawnAngle;
|
||||
/* 0x01E0 */ Path* path;
|
||||
/* 0x01E4 */ u8 reverse;
|
||||
/* 0x01E6 */ s16 waypoint;
|
||||
/* 0x01E8 */ s16 unusedAngle;
|
||||
/* 0x01EA */ char unk_1EA[0x2];
|
||||
/* 0x01EC */ s16 unk_1EC;
|
||||
/* 0x01EC */ s16 behaviorTimer;
|
||||
/* 0x01EE */ char unk_1EE[0x2];
|
||||
/* 0x01F0 */ s16 unk_1F0;
|
||||
/* 0x01F2 */ s16 unk_1F2;
|
||||
/* 0x01F4 */ u8 unk_1F4;
|
||||
/* 0x01F5 */ char unk_1F5[0x4D];
|
||||
/* 0x0242 */ u8 unk_242;
|
||||
/* 0x0243 */ char unk_243[0x4D];
|
||||
/* 0x01F0 */ s16 nextBehavior;
|
||||
/* 0x01F2 */ s16 behavior;
|
||||
/* 0x01F4 */ u8 unk_1F4; //gets passed to skelanime thing
|
||||
/* 0x01F5 */ char unk_1F5[0x4D]; //something allocated by skelanime
|
||||
/* 0x0242 */ u8 unk_242; //very likley a variable from some skelanime struct
|
||||
/* 0x0243 */ char unk_243[0x4D]; //something allocated by skelanime
|
||||
} EnDog; // size = 0x0290
|
||||
|
||||
extern const ActorInit En_Dog_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue