EnRat (Real Bombchu) OK and Documented, object_rat documented 🐀💣 (#966)

* EnRat_Init and EnRat_Destroy OK

* Tons of actionFuncs and other stuff

* EnRat_Update OK

* func_80A566E0 OK and better match for func_80A56EB8

* All draw functions OK

* EnRat OK

* Document object_rat

* Port documentation from Bom_Chu

* Document/name a few more things

* Name all funcs and struct vars

* Un-name unk_18D

* Name some more stuff

* Final round of docs before I ask for help

* Let's just PR this I suppose

* Respond to isghj5's review

* Name a variable I forgot to name

* hookedState stuff

* Clean up forward declares

* Fix after merge

* Respond to reviews

* Limbs -> Limb

* Names for these rascally Vec3f temps

* Name all the vec3fs for real this time

* world -> surface

* surfaceTangent -> forwardPos; there are many tangents, but only one is forward

* Use Elliptic's names + documentation

* worldForwardInHome -> worldPlusForwardInHome
This commit is contained in:
Tom Overton 2022-08-15 11:16:31 -07:00 committed by GitHub
parent f66ef00aeb
commit e44c98884b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1025 additions and 161 deletions

View File

@ -834,10 +834,12 @@
<Limb Name="gameplay_keep_Lodlimb_014540" Type="LOD" Offset="0x14540" />
<Skeleton Name="gameplay_keep_Skel_014560" Type="Normal" LimbType="Standard" Offset="0x14560" />
<Texture Name="gameplay_keep_Tex_014570" OutName="tex_014570" Format="rgba32" Width="16" Height="32" Offset="0x14570" />
<Texture Name="gameplay_keep_Tex_014D70" OutName="tex_014D70" Format="ia8" Width="64" Height="64" Offset="0x14D70" />
<DList Name="gameplay_keep_DL_015DB0" Offset="0x15DB0" />
<Texture Name="gameplay_keep_Tex_015E40" OutName="tex_015E40" Format="rgba16" Width="8" Height="8" Offset="0x15E40" />
<DList Name="gameplay_keep_DL_015FA0" Offset="0x15FA0" />
<!-- Bomb -->
<Texture Name="gBombBodyTex" OutName="bomb_body" Format="ia8" Width="64" Height="64" Offset="0x14D70" />
<DList Name="gBombBodyDL" Offset="0x15DB0" />
<Texture Name="gBombCapTex" OutName="bomb_cap" Format="rgba16" Width="8" Height="8" Offset="0x15E40" />
<DList Name="gBombCapDL" Offset="0x15FA0" />
<!-- Bombchu -->
<Texture Name="gBombchuBodyTex" OutName="bombchu_body" Format="rgba16" Width="8" Height="8" Offset="0x16060" />

View File

@ -1,28 +1,38 @@
<Root>
<!-- Assets for Real Bombchus -->
<File Name="object_rat" Segment="6">
<Animation Name="object_rat_Anim_000174" Offset="0x174" />
<Animation Name="object_rat_Anim_00026C" Offset="0x26C" />
<DList Name="object_rat_DL_000A50" Offset="0xA50" />
<DList Name="object_rat_DL_000B18" Offset="0xB18" />
<DList Name="object_rat_DL_000BC8" Offset="0xBC8" />
<DList Name="object_rat_DL_000C78" Offset="0xC78" />
<DList Name="object_rat_DL_000D28" Offset="0xD28" />
<DList Name="object_rat_DL_000DD8" Offset="0xDD8" />
<DList Name="object_rat_DL_000E20" Offset="0xE20" />
<DList Name="object_rat_DL_000E90" Offset="0xE90" />
<DList Name="object_rat_DL_000ED8" Offset="0xED8" />
<Texture Name="object_rat_Tex_0011C8" OutName="tex_0011C8" Format="rgba16" Width="16" Height="16" Offset="0x11C8" />
<Texture Name="object_rat_Tex_0013C8" OutName="tex_0013C8" Format="rgba16" Width="16" Height="16" Offset="0x13C8" />
<Texture Name="object_rat_Tex_0015C8" OutName="tex_0015C8" Format="rgba16" Width="16" Height="16" Offset="0x15C8" />
<Limb Name="object_rat_Standardlimb_0017C8" Type="Standard" EnumName="OBJECT_RAT_LIMB_01" Offset="0x17C8" />
<Limb Name="object_rat_Standardlimb_0017D4" Type="Standard" EnumName="OBJECT_RAT_LIMB_02" Offset="0x17D4" />
<Limb Name="object_rat_Standardlimb_0017E0" Type="Standard" EnumName="OBJECT_RAT_LIMB_03" Offset="0x17E0" />
<Limb Name="object_rat_Standardlimb_0017EC" Type="Standard" EnumName="OBJECT_RAT_LIMB_04" Offset="0x17EC" />
<Limb Name="object_rat_Standardlimb_0017F8" Type="Standard" EnumName="OBJECT_RAT_LIMB_05" Offset="0x17F8" />
<Limb Name="object_rat_Standardlimb_001804" Type="Standard" EnumName="OBJECT_RAT_LIMB_06" Offset="0x1804" />
<Limb Name="object_rat_Standardlimb_001810" Type="Standard" EnumName="OBJECT_RAT_LIMB_07" Offset="0x1810" />
<Limb Name="object_rat_Standardlimb_00181C" Type="Standard" EnumName="OBJECT_RAT_LIMB_08" Offset="0x181C" />
<Limb Name="object_rat_Standardlimb_001828" Type="Standard" EnumName="OBJECT_RAT_LIMB_09" Offset="0x1828" />
<Skeleton Name="object_rat_Skel_001858" Type="Flex" LimbType="Standard" LimbNone="OBJECT_RAT_LIMB_NONE" LimbMax="OBJECT_RAT_LIMB_MAX" EnumName="object_rat_Limbs" Offset="0x1858" />
<!-- Real Bombchu Animations -->
<Animation Name="gRealBombchuSpotAnim" Offset="0x174" /> <!-- Original name is "rat_hakken" ("detection") -->
<Animation Name="gRealBombchuRunAnim" Offset="0x26C" /> <!-- Original name is "rat_run" -->
<!-- Real Bombchu Limb DisplayLists -->
<DList Name="gRealBombchuBodyDL" Offset="0xA50" />
<DList Name="gRealBombchuBackRightLegDL" Offset="0xB18" />
<DList Name="gRealBombchuFrontRightLegDL" Offset="0xBC8" />
<DList Name="gRealBombchuBackLeftLegDL" Offset="0xC78" />
<DList Name="gRealBombchuFrontLeftLegDL" Offset="0xD28" />
<DList Name="gRealBombchuTailBaseDL" Offset="0xDD8" />
<DList Name="gRealBombchuTailMiddleDL" Offset="0xE20" />
<DList Name="gRealBombchuTailEndDL" Offset="0xE90" />
<DList Name="gRealBombchuHeadDL" Offset="0xED8" />
<!-- Real Bombchu Textures -->
<Texture Name="gRealBombchuSkinTex" OutName="real_bombchu_skin" Format="rgba16" Width="16" Height="16" Offset="0x11C8" />
<Texture Name="gRealBombchuMouthTex" OutName="real_bombchu_mouth" Format="rgba16" Width="16" Height="16" Offset="0x13C8" />
<Texture Name="gRealBombchuEyeTex" OutName="real_bombchu_eye" Format="rgba16" Width="16" Height="16" Offset="0x15C8" />
<!-- Real Bombchu Limbs -->
<Limb Name="gRealBombchuBodyLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_BODY" Offset="0x17C8" />
<Limb Name="gRealBombchuHeadLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_HEAD" Offset="0x17D4" />
<Limb Name="gRealBombchuTailBaseLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_TAIL_BASE" Offset="0x17E0" />
<Limb Name="gRealBombchuTailMiddleLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_TAIL_MIDDLE" Offset="0x17EC" />
<Limb Name="gRealBombchuTailEndLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_TAIL_END" Offset="0x17F8" />
<Limb Name="gRealBombchuFrontLeftLegLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_FRONT_LEFT_LEG" Offset="0x1804" />
<Limb Name="gRealBombchuBackLeftLegLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_BACK_LEFT_LEG" Offset="0x1810" />
<Limb Name="gRealBombchuFrontRightLegLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_FRONT_RIGHT_LEG" Offset="0x181C" />
<Limb Name="gRealBombchuBackRightLegLimb" Type="Standard" EnumName="REAL_BOMBCHU_LIMB_BACK_RIGHT_LEG" Offset="0x1828" />
<!-- Real Bombchu Skeleton -->
<Skeleton Name="gRealBombchuSkel" Type="Flex" LimbType="Standard" LimbNone="REAL_BOMBCHU_LIMB_NONE" LimbMax="REAL_BOMBCHU_LIMB_MAX" EnumName="RealBombchuLimb" Offset="0x1858" />
</File>
</Root>

3
spec
View File

@ -2864,8 +2864,7 @@ beginseg
name "ovl_En_Rat"
compress
include "build/src/overlays/actors/ovl_En_Rat/z_en_rat.o"
include "build/data/ovl_En_Rat/ovl_En_Rat.data.o"
include "build/data/ovl_En_Rat/ovl_En_Rat.reloc.o"
include "build/src/overlays/actors/ovl_En_Rat/ovl_En_Rat_reloc.o"
endseg
beginseg

View File

@ -610,7 +610,7 @@ void EnBom_Draw(Actor* thisx, PlayState* play) {
Matrix_MultVec3f(&D_80872EE0, &this->actor.home.pos);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_015FA0);
gSPDisplayList(POLY_OPA_DISP++, gBombCapDL);
Matrix_ReplaceRotation(&play->billboardMtxF);
Matrix_RotateXS(0x4000, MTXMODE_APPLY);
@ -619,7 +619,7 @@ void EnBom_Draw(Actor* thisx, PlayState* play) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, (s8)this->unk_1F4, 0, 40, 255);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, (s8)this->unk_1F4, 0, 40, 255);
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_015DB0);
gSPDisplayList(POLY_OPA_DISP++, gBombBodyDL);
} else {
Vec3f sp58;
Vec3f sp4C;

View File

@ -116,7 +116,6 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, PlayState
}
normDotUp = DOTXYZ(normal, this->axisUp);
if (fabsf(normDotUp) >= 0.999f) {
return false;
}
@ -129,7 +128,6 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, PlayState
Math3D_CrossProduct(&this->axisUp, &normal, &vec);
magnitude = Math3D_Vec3fMagnitude(&vec);
if (magnitude < 0.001f) {
EnBomChu_Explode(this, play);
return false;
@ -357,7 +355,8 @@ void EnBomChu_WaitForDeath(EnBomChu* this, PlayState* play) {
}
/**
* Transform coordinates from actor coordinate space to world space, according to current orientation.
* Transform coordinates from actor coordinate space (origin at actor's world.pos, z-axis is facing
* angle, i.e. shape.rot.y) to world space, according to current orientation.
* `offset` is expected to already be at world scale.
*/
void EnBomChu_ActorCoordsToWorld(EnBomChu* this, Vec3f* offset, Vec3f* pos) {
@ -497,7 +496,7 @@ void EnBomChu_Update(Actor* thisx, PlayState* play) {
if (this->isMoving) {
this->visualJitter =
(5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 512.0f) + 0x3000) * this->timer));
(5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 0x200) + 0x3000) * this->timer));
EnBomChu_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1);
EnBomChu_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2);

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,57 @@
#define Z_EN_RAT_H
#include "global.h"
#include "objects/object_rat/object_rat.h"
#define EN_RAT_IS_OVERWORLD_TYPE(thisx) ((thisx)->params & 0x8000)
#define EN_RAT_GET_TYPE(thisx) ((thisx)->params)
#define EN_RAT_GET_ATTACK_RANGE(thisx) ((thisx)->params & 0xFF)
/**
* There are many differences between the two types of Real Bombchu:
* - Dungeon-type don't respawn, while Overworld-type do.
* - Dungeon-type leave a blure trail behind them as they chase the player,
* while Overworld-type spawn dust around themselves instead.
* - Dungeon-type won't detonate automatically, while Overworld-type will
* detonate after 150 frames of chasing the player.
* - So long as EN_RAT_GET_ATTACK_RANGE returns something other than 0 or 255,
* Dungeon-type have 1/5th of the attack range compared to Overworld-type.
* - Dungeon-type do not drop items upon defeat, while Overworld-type do.
*/
typedef enum {
/* 0 */ EN_RAT_TYPE_DUNGEON,
/* 1 */ EN_RAT_TYPE_OVERWORLD,
} EnRatType;
struct EnRat;
typedef void (*EnRatActionFunc)(struct EnRat*, PlayState*);
typedef struct EnRat {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x17C];
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ EnRatActionFunc actionFunc;
/* 0x18C */ u8 hasLostTrackOfPlayer;
/* 0x18D */ u8 shouldRotateOntoSurfaces;
/* 0x18E */ s16 animLoopCounter;
/* 0x190 */ s16 timer; // Used for both exploding and reviving
/* 0x192 */ union {
s16 stunTimer;
s16 hookedState;
} damageReaction;
/* 0x194 */ Vec3s jointTable[REAL_BOMBCHU_LIMB_MAX];
/* 0x1D0 */ Vec3s morphTable[REAL_BOMBCHU_LIMB_MAX];
/* 0x20C */ Vec3f axisForwards;
/* 0x218 */ Vec3f axisUp;
/* 0x224 */ Vec3f axisLeft;
/* 0x230 */ Vec3f smokePos;
/* 0x23C */ Vec3f sparkOffsets[2];
/* 0x254 */ f32 visualJitter;
/* 0x258 */ f32 attackRange;
/* 0x25C */ f32 revivePosY;
/* 0x260 */ s32 blure1Index;
/* 0x264 */ s32 blure2Index;
/* 0x268 */ ColliderSphere collider;
} EnRat; // size = 0x2C0
extern const ActorInit En_Rat_InitVars;

View File

@ -10641,32 +10641,32 @@
0x80A560F0:("EnFirefly2_Draw",),
0x80A56150:("EnRat_Init",),
0x80A56370:("EnRat_Destroy",),
0x80A563CC:("func_80A563CC",),
0x80A56444:("func_80A56444",),
0x80A5665C:("func_80A5665C",),
0x80A566E0:("func_80A566E0",),
0x80A56994:("func_80A56994",),
0x80A56AFC:("func_80A56AFC",),
0x80A56EB8:("func_80A56EB8",),
0x80A56F68:("func_80A56F68",),
0x80A57010:("func_80A57010",),
0x80A57118:("func_80A57118",),
0x80A57180:("func_80A57180",),
0x80A5723C:("func_80A5723C",),
0x80A57330:("func_80A57330",),
0x80A57384:("func_80A57384",),
0x80A57488:("func_80A57488",),
0x80A574E8:("func_80A574E8",),
0x80A57570:("func_80A57570",),
0x80A575F4:("func_80A575F4",),
0x80A5764C:("func_80A5764C",),
0x80A57918:("func_80A57918",),
0x80A57984:("func_80A57984",),
0x80A57A08:("func_80A57A08",),
0x80A57A9C:("func_80A57A9C",),
0x80A563CC:("EnRat_InitializeAxes",),
0x80A56444:("EnRat_UpdateFloorPoly",),
0x80A5665C:("EnRat_UpdateRotation",),
0x80A566E0:("EnRat_ChooseDirection",),
0x80A56994:("EnRat_IsOnCollisionPoly",),
0x80A56AFC:("EnRat_IsTouchingSurface",),
0x80A56EB8:("EnRat_ActorCoordsToWorld",),
0x80A56F68:("EnRat_SpawnWaterEffects",),
0x80A57010:("EnRat_HandleNonSceneCollision",),
0x80A57118:("EnRat_SpawnSmoke",),
0x80A57180:("EnRat_SetupRevive",),
0x80A5723C:("EnRat_Revive",),
0x80A57330:("EnRat_SetupIdle",),
0x80A57384:("EnRat_Idle",),
0x80A57488:("EnRat_SetupSpottedPlayer",),
0x80A574E8:("EnRat_SpottedPlayer",),
0x80A57570:("EnRat_UpdateSparkOffsets",),
0x80A575F4:("EnRat_SetupChasePlayer",),
0x80A5764C:("EnRat_ChasePlayer",),
0x80A57918:("EnRat_SetupBounced",),
0x80A57984:("EnRat_Bounced",),
0x80A57A08:("EnRat_Explode",),
0x80A57A9C:("EnRat_PostDetonation",),
0x80A57AE0:("EnRat_Update",),
0x80A57F10:("func_80A57F10",),
0x80A57F4C:("func_80A57F4C",),
0x80A57F10:("EnRat_OverrideLimbDraw",),
0x80A57F4C:("EnRat_PostLimbDraw",),
0x80A58354:("EnRat_Draw",),
0x80A587A0:("func_80A587A0",),
0x80A58908:("func_80A58908",),

View File

@ -11739,20 +11739,19 @@
0x80A55E40:("D_80A55E40","f32","",0x4),
0x80A56100:("En_Firefly2_InitVars","UNK_TYPE1","",0x1),
0x80A583E0:("En_Rat_InitVars","UNK_TYPE1","",0x1),
0x80A58400:("D_80A58400","UNK_TYPE1","",0x1),
0x80A58428:("D_80A58428","UNK_TYPE2","",0x2),
0x80A5842C:("D_80A5842C","UNK_TYPE1","",0x1),
0x80A5844C:("D_80A5844C","UNK_TYPE1","",0x1),
0x80A58454:("D_80A58454","UNK_TYPE4","",0x4),
0x80A58464:("D_80A58464","UNK_TYPE1","",0x1),
0x80A58470:("D_80A58470","EffectBlureInit2","",0x24),
0x80A58494:("D_80A58494","UNK_TYPE4","",0x4),
0x80A58498:("D_80A58498","UNK_TYPE1","",0x1),
0x80A584A4:("D_80A584A4","UNK_TYPE1","",0x1),
0x80A584A8:("D_80A584A8","UNK_TYPE1","",0x1),
0x80A584B4:("D_80A584B4","UNK_TYPE1","",0x1),
0x80A584C0:("D_80A584C0","UNK_TYPE1","",0x1),
0x80A584CC:("D_80A584CC","UNK_TYPE1","",0x1),
0x80A58400:("sSphereInit","UNK_TYPE1","",0x1),
0x80A5842C:("sDamageTable","UNK_TYPE1","",0x1),
0x80A5844C:("sColChkInfoInit","UNK_TYPE1","",0x1),
0x80A58454:("sSparkTextures","UNK_TYPE4","",0x4),
0x80A58464:("sInitChain","UNK_TYPE1","",0x1),
0x80A58470:("sBlureInit","EffectBlureInit2","",0x24),
0x80A58494:("sTexturesDesegmented","UNK_TYPE4","",0x4),
0x80A58498:("sSmokeAccel","UNK_TYPE1","",0x1),
0x80A584A4:("sSmokeColor","UNK_TYPE1","",0x1),
0x80A584A8:("sBlureP1Offset","UNK_TYPE1","",0x1),
0x80A584B4:("sBlureP2LeftOffset","UNK_TYPE1","",0x1),
0x80A584C0:("sBlureP2RightOffset","UNK_TYPE1","",0x1),
0x80A584CC:("sDustVelocity","UNK_TYPE1","",0x1),
0x80A584E0:("D_80A584E0","f32","",0x4),
0x80A584E4:("D_80A584E4","f32","",0x4),
0x80A584E8:("D_80A584E8","f32","",0x4),

View File

@ -1290,12 +1290,6 @@ D_06004340 = 0x06004340;
D_06001A80 = 0x06001A80;
// ovl_En_Rat
D_06000174 = 0x06000174;
D_0600026C = 0x0600026C;
D_06001858 = 0x06001858;
// ovl_En_Ru
D_0600C700 = 0x0600C700;