mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
ovl_Obj_Grass_Unit OK and some grass documentation (#1172)
* z_obj_grass_unit OK * document some grass * pr suggestions, add grass_unit comment * pr suggestions * implement constants
This commit is contained in:
+7
-2
@@ -39,6 +39,11 @@ typedef struct {
|
||||
/* 0x8 */ s32 z;
|
||||
} Vec3i; // size = 0xC
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ f32 distance;
|
||||
/* 0x4 */ s16 angle;
|
||||
} VecPolar; // size = 0x8
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ Vec3s center;
|
||||
/* 0x6 */ s16 radius;
|
||||
@@ -49,8 +54,8 @@ typedef struct {
|
||||
/* 0xC */ f32 radius;
|
||||
} Spheref; // size = 0x10
|
||||
|
||||
/*
|
||||
The plane paramaters are of form `ax + by + cz + d = 0`
|
||||
/*
|
||||
The plane paramaters are of form `ax + by + cz + d = 0`
|
||||
where `(a,b,c)` is the plane's normal vector and d is the originDist
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
@@ -2137,8 +2137,7 @@ beginseg
|
||||
name "ovl_Obj_Grass_Unit"
|
||||
compress
|
||||
include "build/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.o"
|
||||
include "build/data/ovl_Obj_Grass_Unit/ovl_Obj_Grass_Unit.data.o"
|
||||
include "build/data/ovl_Obj_Grass_Unit/ovl_Obj_Grass_Unit.reloc.o"
|
||||
include "build/src/overlays/actors/ovl_Obj_Grass_Unit/ovl_Obj_Grass_Unit_reloc.o"
|
||||
endseg
|
||||
|
||||
beginseg
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,40 +7,52 @@
|
||||
struct ObjGrass;
|
||||
struct ObjGrassCarry;
|
||||
|
||||
typedef struct ObjGrassStruct1_1 {
|
||||
/* 0x00 */ Vec3f unk_00;
|
||||
/* 0x0C */ s16 unk_0C;
|
||||
/* 0x0E */ s8 unk_0E;
|
||||
/* 0x0F */ u8 unk_0F;
|
||||
/* 0x10 */ u8 unk_10;
|
||||
} ObjGrassStruct1_1; // size = 0x14
|
||||
#define OBJ_GRASS_NEAREST_GROUP_MAX 4
|
||||
#define OBJ_GRASS_NEAREST_ELEM_MAX 20
|
||||
|
||||
#define OBJ_GRASS_GROUP_ELEM_COUNT_MAX 12
|
||||
|
||||
#define OBJ_GRASS_GROUP_DRAW 1
|
||||
|
||||
#define OBJ_GRASS_ELEM_DRAW 1
|
||||
#define OBJ_GRASS_ELEM_ANIM 2
|
||||
#define OBJ_GRASS_ELEM_REMOVED 4
|
||||
#define OBJ_GRASS_ELEM_UNDERWATER 8
|
||||
|
||||
typedef struct ObjGrassElement {
|
||||
/* 0x00 */ Vec3f pos;
|
||||
/* 0x0C */ s16 rotY;
|
||||
/* 0x0E */ s8 dropTable;
|
||||
/* 0x0F */ u8 flags;
|
||||
/* 0x10 */ u8 alpha;
|
||||
} ObjGrassElement; // size = 0x14
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ Vec3f unk_00;
|
||||
/* 0x0C */ ObjGrassStruct1_1 unk_0C[12];
|
||||
/* 0xFC */ s16 unk_FC;
|
||||
/* 0xFE */ u8 unk_FE;
|
||||
} ObjGrassStruct1; // size = 0x100
|
||||
/* 0x00 */ Vec3f homePos;
|
||||
/* 0x0C */ ObjGrassElement elements[OBJ_GRASS_GROUP_ELEM_COUNT_MAX];
|
||||
/* 0xFC */ s16 count;
|
||||
/* 0xFE */ u8 flags;
|
||||
} ObjGrassGroup; // size = 0x100
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ ColliderCylinder collider;
|
||||
/* 0x4C */ ObjGrassStruct1_1* unk_4C;
|
||||
} ObjGrassStruct2; // size = 0x50
|
||||
/* 0x4C */ ObjGrassElement* entity;
|
||||
} ObjGrassCollider; // size = 0x50
|
||||
|
||||
typedef struct ObjGrass {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x0144 */ ObjGrassStruct1 unk_144[40];
|
||||
/* 0x2944 */ s16 unk_2944;
|
||||
/* 0x2948 */ ObjGrassStruct2 unk_2948[20];
|
||||
/* 0x2F88 */ MtxF unk_2F88[12];
|
||||
/* 0x0144 */ ObjGrassGroup grassGroups[40];
|
||||
/* 0x2944 */ s16 activeGrassGroups;
|
||||
/* 0x2948 */ ObjGrassCollider grassElemColliders[OBJ_GRASS_NEAREST_ELEM_MAX];
|
||||
/* 0x2F88 */ MtxF distortionMtx[OBJ_GRASS_GROUP_ELEM_COUNT_MAX];
|
||||
/* 0x3288 */ s16 unk_3288;
|
||||
/* 0x328A */ s16 unk_328A;
|
||||
/* 0x328C */ s16 unk_328C;
|
||||
/* 0x328E */ s16 unk_328E;
|
||||
/* 0x3290 */ s16 unk_3290;
|
||||
/* 0x3292 */ s16 unk_3292;
|
||||
/* 0x3294 */ ObjGrassStruct1_1* unk_3294;
|
||||
/* 0x3298 */ struct ObjGrassCarry* unk_3298[2];
|
||||
/* 0x3292 */ s16 activeGrassCarry;
|
||||
/* 0x3294 */ ObjGrassElement* carryGrassElem;
|
||||
/* 0x3298 */ struct ObjGrassCarry* grassCarry[2];
|
||||
} ObjGrass; // size = 0x32A0
|
||||
|
||||
#endif // Z_OBJ_GRASS_H
|
||||
|
||||
@@ -17,17 +17,17 @@ void ObjGrassCarry_Init(Actor* thisx, PlayState* play);
|
||||
void ObjGrassCarry_Destroy(Actor* thisx, PlayState* play);
|
||||
void ObjGrassCarry_Update(Actor* thisx, PlayState* play);
|
||||
|
||||
void func_809AB3C4(ObjGrassCarry* this);
|
||||
void func_809AB3D8(ObjGrassCarry* this, PlayState* play);
|
||||
void func_809AB428(ObjGrassCarry* this);
|
||||
void func_809AB43C(ObjGrassCarry* this, PlayState* play);
|
||||
void func_809AB474(ObjGrassCarry* this);
|
||||
void func_809AB4A8(ObjGrassCarry* this, PlayState* play);
|
||||
void func_809AB5FC(ObjGrassCarry* this);
|
||||
void func_809AB610(ObjGrassCarry* this, PlayState* play);
|
||||
void func_809AB6FC(ObjGrassCarry* this);
|
||||
void func_809AB77C(ObjGrassCarry* this, PlayState* play);
|
||||
void func_809ABB7C(Actor* this, PlayState* play);
|
||||
void ObjGrassCarry_SetupAwaitSpawnManager(ObjGrassCarry* this);
|
||||
void ObjGrassCarry_AwaitSpawnManager(ObjGrassCarry* this, PlayState* play);
|
||||
void ObjGrassCarry_SetupIdle(ObjGrassCarry* this);
|
||||
void ObjGrassCarry_Idle(ObjGrassCarry* this, PlayState* play);
|
||||
void ObjGrassCarry_Reset(ObjGrassCarry* this);
|
||||
void ObjGrassCarry_Main(ObjGrassCarry* this, PlayState* play);
|
||||
void ObjGrassCarry_SetupLiftedUp(ObjGrassCarry* this);
|
||||
void ObjGrassCarry_LiftedUp(ObjGrassCarry* this, PlayState* play);
|
||||
void ObjGrassCarry_SetupFall(ObjGrassCarry* this);
|
||||
void ObjGrassCarry_Fall(ObjGrassCarry* this, PlayState* play);
|
||||
void ObjGrassCarry_Draw(Actor* this, PlayState* play);
|
||||
|
||||
ActorInit Obj_Grass_Carry_InitVars = {
|
||||
ACTOR_OBJ_GRASS_CARRY,
|
||||
@@ -61,19 +61,19 @@ static ColliderCylinderInit sCylinderInit = {
|
||||
{ 10, 44, 0, { 0, 0, 0 } },
|
||||
};
|
||||
|
||||
s16 D_809ABBFC = 0;
|
||||
s16 D_809ABC00 = 0;
|
||||
s16 D_809ABC04 = 0;
|
||||
s16 D_809ABC08 = 0;
|
||||
static s16 sRotSpeedXTarget = 0;
|
||||
static s16 sRotSpeedX = 0;
|
||||
static s16 sRotSpeedYTarget = 0;
|
||||
static s16 sRotSpeedY = 0;
|
||||
|
||||
Vec3f D_809ABC0C[] = {
|
||||
static Vec3f sUnitDirections[] = {
|
||||
{ 0.0f, 0.7071f, 0.7071f },
|
||||
{ 0.7071f, 0.7071f, 0.0f },
|
||||
{ 0.0f, 0.7071f, -0.7071f },
|
||||
{ -0.7071f, 0.7071f, 0.0f },
|
||||
};
|
||||
|
||||
s16 D_809ABC3C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 };
|
||||
static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 };
|
||||
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE),
|
||||
@@ -81,69 +81,71 @@ static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
void func_809AAE60(ObjGrassCarry* this) {
|
||||
void ObjGrassCarry_UpdateVelY(ObjGrassCarry* this) {
|
||||
this->actor.velocity.y += this->actor.gravity;
|
||||
if (this->actor.velocity.y < this->actor.terminalVelocity) {
|
||||
this->actor.velocity.y = this->actor.terminalVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AAE94(Vec3f* arg0, f32 arg1) {
|
||||
arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1;
|
||||
void ObjGrassCarry_RandScaleVecToZero(Vec3f* velocity, f32 scale) {
|
||||
scale += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scale;
|
||||
|
||||
arg0->x -= (arg0->x * arg1);
|
||||
arg0->y -= (arg0->y * arg1);
|
||||
arg0->z -= (arg0->z * arg1);
|
||||
velocity->x -= velocity->x * scale;
|
||||
velocity->y -= velocity->y * scale;
|
||||
velocity->z -= velocity->z * scale;
|
||||
}
|
||||
|
||||
void func_809AAF18(ObjGrassCarry* this) {
|
||||
func_809AAE60(this);
|
||||
func_809AAE94(&this->actor.velocity, 0.05f);
|
||||
void ObjGrassCarry_UpdatePos(ObjGrassCarry* this) {
|
||||
ObjGrassCarry_UpdateVelY(this);
|
||||
ObjGrassCarry_RandScaleVecToZero(&this->actor.velocity, 0.05f);
|
||||
Actor_UpdatePos(&this->actor);
|
||||
}
|
||||
|
||||
void func_809AAF58(ObjGrassCarry* this, PlayState* play) {
|
||||
void ObjGrassCarry_UpdateBgCheckInfo(ObjGrassCarry* this, PlayState* play) {
|
||||
Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f,
|
||||
UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 |
|
||||
UPDBGCHECKINFO_FLAG_80);
|
||||
}
|
||||
|
||||
void func_809AAF9C(Vec3f* arg0, s16 arg1, PlayState* play) {
|
||||
if (!(arg1 & 0x10)) {
|
||||
Item_DropCollectibleRandom(play, NULL, arg0, arg1 * 0x10);
|
||||
void ObjGrassCarry_DropCollectible(Vec3f* pos, s16 dropTable, PlayState* play) {
|
||||
if ((dropTable & 0x10) == 0) {
|
||||
Item_DropCollectibleRandom(play, NULL, pos, dropTable * 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AAFE8(Vec3f* arg0, PlayState* play) {
|
||||
Vec3f spBC;
|
||||
Vec3f spB0;
|
||||
void ObjGrassCarry_SpawnFragments(Vec3f* basePos, PlayState* play) {
|
||||
Vec3f velocity;
|
||||
Vec3f pos;
|
||||
s32 i;
|
||||
Vec3f* ptr;
|
||||
Vec3f* dir;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(D_809ABC0C); i++) {
|
||||
ptr = &D_809ABC0C[i];
|
||||
for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) {
|
||||
dir = &sUnitDirections[i];
|
||||
|
||||
spB0.x = arg0->x + (ptr->x * 8.0f);
|
||||
spB0.y = arg0->y + (ptr->y * 8.0f) + 10.0f;
|
||||
spB0.z = arg0->z + (ptr->z * 8.0f);
|
||||
pos.x = basePos->x + (dir->x * 8.0f);
|
||||
pos.y = basePos->y + (dir->y * 8.0f) + 10.0f;
|
||||
pos.z = basePos->z + (dir->z * 8.0f);
|
||||
|
||||
spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f;
|
||||
spBC.y = Rand_ZeroOne() * 10.0f;
|
||||
spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f;
|
||||
velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f;
|
||||
velocity.y = Rand_ZeroOne() * 10.0f;
|
||||
velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f;
|
||||
|
||||
EffectSsKakera_Spawn(play, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0,
|
||||
D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddleDL);
|
||||
EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -100, 64, 40, 3, 0,
|
||||
sFragmentScales[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, GAMEPLAY_KEEP,
|
||||
gKakeraLeafMiddleDL);
|
||||
|
||||
spB0.x = arg0->x + (ptr->x * 16.0f);
|
||||
spB0.y = arg0->y + (ptr->y * 16.0f) + 10.0f;
|
||||
spB0.z = arg0->z + (ptr->z * 16.0f);
|
||||
pos.x = basePos->x + (dir->x * 16.0f);
|
||||
pos.y = basePos->y + (dir->y * 16.0f) + 10.0f;
|
||||
pos.z = basePos->z + (dir->z * 16.0f);
|
||||
|
||||
spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f;
|
||||
spBC.y = Rand_ZeroOne() * 10.0f;
|
||||
spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f;
|
||||
velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f;
|
||||
velocity.y = Rand_ZeroOne() * 10.0f;
|
||||
velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f;
|
||||
|
||||
EffectSsKakera_Spawn(play, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0,
|
||||
D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTipDL);
|
||||
EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -100, 64, 40, 3, 0,
|
||||
sFragmentScales[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, GAMEPLAY_KEEP,
|
||||
gKakeraLeafTipDL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +156,7 @@ void ObjGrassCarry_Init(Actor* thisx, PlayState* play) {
|
||||
Collider_InitCylinder(play, &this->collider);
|
||||
Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
|
||||
this->actor.colChkInfo.mass = 80;
|
||||
func_809AB3C4(this);
|
||||
ObjGrassCarry_SetupAwaitSpawnManager(this);
|
||||
}
|
||||
|
||||
void ObjGrassCarry_Destroy(Actor* thisx, PlayState* play) {
|
||||
@@ -162,73 +164,69 @@ void ObjGrassCarry_Destroy(Actor* thisx, PlayState* play) {
|
||||
|
||||
Collider_DestroyCylinder(play, &this->collider);
|
||||
|
||||
if (this->unk_190 != NULL) {
|
||||
ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params];
|
||||
if (this->grassManager != NULL) {
|
||||
ObjGrassCarry** carry = &this->grassManager->grassCarry[this->actor.params];
|
||||
|
||||
if (this == *carry) {
|
||||
*carry = NULL;
|
||||
this->unk_190 = NULL;
|
||||
this->grassManager = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AB3C4(ObjGrassCarry* this) {
|
||||
this->actionFunc = func_809AB3D8;
|
||||
void ObjGrassCarry_SetupAwaitSpawnManager(ObjGrassCarry* this) {
|
||||
this->actionFunc = ObjGrassCarry_AwaitSpawnManager;
|
||||
}
|
||||
|
||||
void func_809AB3D8(ObjGrassCarry* this, PlayState* play) {
|
||||
if (this->unk_190 != NULL) {
|
||||
if (this->actor.params != this->unk_190->unk_3292) {
|
||||
func_809AB474(this);
|
||||
void ObjGrassCarry_AwaitSpawnManager(ObjGrassCarry* this, PlayState* play) {
|
||||
if (this->grassManager != NULL) {
|
||||
if (this->actor.params != this->grassManager->activeGrassCarry) {
|
||||
ObjGrassCarry_Reset(this);
|
||||
} else {
|
||||
func_809AB428(this);
|
||||
ObjGrassCarry_SetupIdle(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AB428(ObjGrassCarry* this) {
|
||||
this->actionFunc = func_809AB43C;
|
||||
void ObjGrassCarry_SetupIdle(ObjGrassCarry* this) {
|
||||
this->actionFunc = ObjGrassCarry_Idle;
|
||||
}
|
||||
|
||||
void func_809AB43C(ObjGrassCarry* this, PlayState* play) {
|
||||
if (this->actor.params != this->unk_190->unk_3292) {
|
||||
func_809AB474(this);
|
||||
void ObjGrassCarry_Idle(ObjGrassCarry* this, PlayState* play) {
|
||||
if (this->actor.params != this->grassManager->activeGrassCarry) {
|
||||
ObjGrassCarry_Reset(this);
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AB474(ObjGrassCarry* this) {
|
||||
this->actor.shape.rot.z = 0;
|
||||
this->actionFunc = func_809AB4A8;
|
||||
this->unk_194 = NULL;
|
||||
this->actor.shape.rot.y = this->actor.shape.rot.z;
|
||||
this->actor.shape.rot.x = this->actor.shape.rot.z;
|
||||
this->actor.world.rot.z = this->actor.shape.rot.z;
|
||||
this->actor.world.rot.y = this->actor.shape.rot.z;
|
||||
this->actor.world.rot.x = this->actor.shape.rot.z;
|
||||
void ObjGrassCarry_Reset(ObjGrassCarry* this) {
|
||||
this->actionFunc = ObjGrassCarry_Main;
|
||||
this->grassElem = NULL;
|
||||
this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = this->actor.shape.rot.x =
|
||||
this->actor.shape.rot.y = this->actor.shape.rot.z = 0;
|
||||
}
|
||||
|
||||
void func_809AB4A8(ObjGrassCarry* this, PlayState* play) {
|
||||
void ObjGrassCarry_Main(ObjGrassCarry* this, PlayState* play) {
|
||||
Actor* thisx = &this->actor;
|
||||
|
||||
if (Actor_HasParent(thisx, play)) {
|
||||
func_809AB5FC(this);
|
||||
if (this->unk_194 != NULL) {
|
||||
this->unk_194->unk_0F |= 4;
|
||||
ObjGrassCarry_SetupLiftedUp(this);
|
||||
if (this->grassElem != NULL) {
|
||||
this->grassElem->flags |= OBJ_GRASS_ELEM_REMOVED;
|
||||
}
|
||||
thisx->draw = func_809ABB7C;
|
||||
thisx->draw = ObjGrassCarry_Draw;
|
||||
thisx->shape.shadowDraw = ActorShadow_DrawCircle;
|
||||
thisx->shape.shadowAlpha = 60;
|
||||
thisx->shape.shadowScale = 1.0f;
|
||||
this->unk_190->unk_3292 ^= 1;
|
||||
this->grassManager->activeGrassCarry ^= 1;
|
||||
thisx->room = -1;
|
||||
SoundSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 20, NA_SE_PL_PULL_UP_PLANT);
|
||||
} else if (this->unk_190->unk_3294 != NULL) {
|
||||
} else if (this->grassManager->carryGrassElem != NULL) {
|
||||
Player* player = GET_PLAYER(play);
|
||||
|
||||
this->unk_194 = this->unk_190->unk_3294;
|
||||
Math_Vec3f_Copy(&thisx->world.pos, &this->unk_194->unk_00);
|
||||
thisx->shape.rot.y = thisx->world.rot.y = this->unk_194->unk_0C;
|
||||
this->unk_198 = this->unk_194->unk_0E;
|
||||
this->grassElem = this->grassManager->carryGrassElem;
|
||||
Math_Vec3f_Copy(&thisx->world.pos, &this->grassElem->pos);
|
||||
thisx->shape.rot.y = thisx->world.rot.y = this->grassElem->rotY;
|
||||
this->dropTable = this->grassElem->dropTable;
|
||||
thisx->xzDistToPlayer = Actor_WorldDistXZToActor(&this->actor, &player->actor);
|
||||
thisx->playerHeightRel = Actor_HeightDiff(&this->actor, &player->actor);
|
||||
thisx->xyzDistToPlayerSq = SQ(thisx->xzDistToPlayer) + SQ(thisx->playerHeightRel);
|
||||
@@ -237,87 +235,88 @@ void func_809AB4A8(ObjGrassCarry* this, PlayState* play) {
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AB5FC(ObjGrassCarry* this) {
|
||||
this->actionFunc = func_809AB610;
|
||||
void ObjGrassCarry_SetupLiftedUp(ObjGrassCarry* this) {
|
||||
this->actionFunc = ObjGrassCarry_LiftedUp;
|
||||
}
|
||||
|
||||
void func_809AB610(ObjGrassCarry* this, PlayState* play) {
|
||||
void ObjGrassCarry_LiftedUp(ObjGrassCarry* this, PlayState* play) {
|
||||
s32 pad;
|
||||
Vec3f sp30;
|
||||
s32 sp2C;
|
||||
|
||||
if (Actor_HasNoParent(&this->actor, play)) {
|
||||
func_809AB6FC(this);
|
||||
ObjGrassCarry_SetupFall(this);
|
||||
this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speed;
|
||||
this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speed;
|
||||
this->actor.gravity = -0.1f;
|
||||
this->actor.terminalVelocity = -17.0f;
|
||||
func_809AAF18(this);
|
||||
func_809AAF58(this, play);
|
||||
ObjGrassCarry_UpdatePos(this);
|
||||
ObjGrassCarry_UpdateBgCheckInfo(this, play);
|
||||
this->actor.gravity = -3.2f;
|
||||
} else {
|
||||
sp30.x = this->actor.world.pos.x;
|
||||
sp30.y = this->actor.world.pos.y + 20.0f;
|
||||
sp30.z = this->actor.world.pos.z;
|
||||
Vec3f pos;
|
||||
s32 bgId;
|
||||
|
||||
pos.x = this->actor.world.pos.x;
|
||||
pos.y = this->actor.world.pos.y + 20.0f;
|
||||
pos.z = this->actor.world.pos.z;
|
||||
this->actor.floorHeight =
|
||||
BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30);
|
||||
BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos);
|
||||
}
|
||||
}
|
||||
|
||||
void func_809AB6FC(ObjGrassCarry* this) {
|
||||
this->actionFunc = func_809AB77C;
|
||||
D_809ABBFC = -0xBB8;
|
||||
D_809ABC04 = (Rand_ZeroOne() - 0.5f) * 1600.0f;
|
||||
D_809ABC00 = 0;
|
||||
D_809ABC08 = 0;
|
||||
this->unk_19A = 60;
|
||||
void ObjGrassCarry_SetupFall(ObjGrassCarry* this) {
|
||||
this->actionFunc = ObjGrassCarry_Fall;
|
||||
sRotSpeedXTarget = -0xBB8;
|
||||
sRotSpeedYTarget = (Rand_ZeroOne() - 0.5f) * 1600.0f;
|
||||
sRotSpeedX = 0;
|
||||
sRotSpeedY = 0;
|
||||
this->fallTimer = 60;
|
||||
}
|
||||
|
||||
void func_809AB77C(ObjGrassCarry* this, PlayState* play) {
|
||||
s16 phi_s0;
|
||||
s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0;
|
||||
Vec3f sp5C;
|
||||
void ObjGrassCarry_Fall(ObjGrassCarry* this, PlayState* play) {
|
||||
s16 angle;
|
||||
s32 atHit = (this->collider.base.atFlags & AT_HIT) != 0;
|
||||
Vec3f pos;
|
||||
s32 i;
|
||||
|
||||
if (temp_v0) {
|
||||
if (atHit) {
|
||||
this->collider.base.atFlags &= ~AT_HIT;
|
||||
}
|
||||
|
||||
this->unk_19A--;
|
||||
this->fallTimer--;
|
||||
|
||||
if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || temp_v0 ||
|
||||
(this->unk_19A <= 0)) {
|
||||
func_809AAFE8(&this->actor.world.pos, play);
|
||||
func_809AAF9C(&this->actor.world.pos, this->unk_198, play);
|
||||
if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || atHit ||
|
||||
(this->fallTimer <= 0)) {
|
||||
ObjGrassCarry_SpawnFragments(&this->actor.world.pos, play);
|
||||
ObjGrassCarry_DropCollectible(&this->actor.world.pos, this->dropTable, play);
|
||||
|
||||
this->actor.draw = NULL;
|
||||
this->actor.shape.shadowDraw = NULL;
|
||||
|
||||
if (this->unk_190 != NULL) {
|
||||
this->actor.room = this->unk_190->actor.room;
|
||||
if (this->grassManager != NULL) {
|
||||
this->actor.room = this->grassManager->actor.room;
|
||||
}
|
||||
|
||||
if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
|
||||
SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN);
|
||||
}
|
||||
func_809AB428(this);
|
||||
ObjGrassCarry_SetupIdle(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) {
|
||||
sp5C.y = this->actor.world.pos.y + this->actor.depthInWater;
|
||||
pos.y = this->actor.world.pos.y + this->actor.depthInWater;
|
||||
|
||||
for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) {
|
||||
sp5C.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x;
|
||||
sp5C.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z;
|
||||
EffectSsGSplash_Spawn(play, &sp5C, NULL, NULL, 0, 190);
|
||||
for (angle = 0, i = 0; i < 4; i++, angle += 0x4000) {
|
||||
pos.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angle) * 15.0f) + this->actor.world.pos.x;
|
||||
pos.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angle) * 15.0f) + this->actor.world.pos.z;
|
||||
EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 190);
|
||||
}
|
||||
|
||||
sp5C.x = this->actor.world.pos.x;
|
||||
sp5C.z = this->actor.world.pos.z;
|
||||
pos.x = this->actor.world.pos.x;
|
||||
pos.z = this->actor.world.pos.z;
|
||||
|
||||
EffectSsGSplash_Spawn(play, &sp5C, NULL, NULL, 0, 280);
|
||||
EffectSsGRipple_Spawn(play, &sp5C, 300, 700, 0);
|
||||
EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 280);
|
||||
EffectSsGRipple_Spawn(play, &pos, 300, 700, 0);
|
||||
|
||||
this->actor.terminalVelocity = -3.0f;
|
||||
this->actor.velocity.x *= 0.1f;
|
||||
@@ -325,20 +324,20 @@ void func_809AB77C(ObjGrassCarry* this, PlayState* play) {
|
||||
this->actor.velocity.z *= 0.1f;
|
||||
this->actor.gravity *= 0.5f;
|
||||
|
||||
D_809ABC00 = D_809ABC00 >> 1;
|
||||
D_809ABBFC = D_809ABBFC >> 1;
|
||||
D_809ABC08 = D_809ABC08 >> 1;
|
||||
D_809ABC04 = D_809ABC04 >> 1;
|
||||
sRotSpeedX >>= 1;
|
||||
sRotSpeedXTarget >>= 1;
|
||||
sRotSpeedY >>= 1;
|
||||
sRotSpeedYTarget >>= 1;
|
||||
this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH;
|
||||
SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L);
|
||||
}
|
||||
|
||||
Math_StepToS(&D_809ABC00, D_809ABBFC, 0x1F4);
|
||||
Math_StepToS(&D_809ABC08, D_809ABC04, 0xAA);
|
||||
this->actor.shape.rot.x += D_809ABC00;
|
||||
this->actor.shape.rot.y += D_809ABC08;
|
||||
func_809AAF18(this);
|
||||
func_809AAF58(this, play);
|
||||
Math_StepToS(&sRotSpeedX, sRotSpeedXTarget, 0x1F4);
|
||||
Math_StepToS(&sRotSpeedY, sRotSpeedYTarget, 0xAA);
|
||||
this->actor.shape.rot.x += sRotSpeedX;
|
||||
this->actor.shape.rot.y += sRotSpeedY;
|
||||
ObjGrassCarry_UpdatePos(this);
|
||||
ObjGrassCarry_UpdateBgCheckInfo(this, play);
|
||||
|
||||
Collider_UpdateCylinder(&this->actor, &this->collider);
|
||||
CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base);
|
||||
@@ -348,8 +347,8 @@ void func_809AB77C(ObjGrassCarry* this, PlayState* play) {
|
||||
void ObjGrassCarry_Update(Actor* thisx, PlayState* play) {
|
||||
ObjGrassCarry* this = THIS;
|
||||
|
||||
if (this->unk_190 == NULL) {
|
||||
if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) {
|
||||
if (this->grassManager == NULL) {
|
||||
if ((this->actionFunc != ObjGrassCarry_LiftedUp) && (this->actionFunc != ObjGrassCarry_Fall)) {
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
@@ -358,6 +357,6 @@ void ObjGrassCarry_Update(Actor* thisx, PlayState* play) {
|
||||
this->actionFunc(this, play);
|
||||
}
|
||||
|
||||
void func_809ABB7C(Actor* this, PlayState* play) {
|
||||
void ObjGrassCarry_Draw(Actor* this, PlayState* play) {
|
||||
Gfx_DrawDListOpa(play, gKusaBushType1DL);
|
||||
}
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
|
||||
struct ObjGrassCarry;
|
||||
struct ObjGrass;
|
||||
struct ObjGrassStruct1_1;
|
||||
struct ObjGrassElement;
|
||||
|
||||
typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, PlayState*);
|
||||
|
||||
typedef struct ObjGrassCarry {
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ ColliderCylinder collider;
|
||||
/* 0x190 */ struct ObjGrass* unk_190;
|
||||
/* 0x194 */ struct ObjGrassStruct1_1* unk_194;
|
||||
/* 0x198 */ s16 unk_198;
|
||||
/* 0x19A */ s16 unk_19A;
|
||||
/* 0x190 */ struct ObjGrass* grassManager;
|
||||
/* 0x194 */ struct ObjGrassElement* grassElem;
|
||||
/* 0x198 */ s16 dropTable;
|
||||
/* 0x19A */ s16 fallTimer;
|
||||
/* 0x19C */ ObjGrassCarryActionFunc actionFunc;
|
||||
} ObjGrassCarry; // size = 0x1A0
|
||||
|
||||
|
||||
@@ -1,38 +1,168 @@
|
||||
/*
|
||||
* File: z_obj_grass_unit.c
|
||||
* Overlay: ovl_Obj_Grass_Unit
|
||||
* Description: Spawner for circular patch of grass
|
||||
* Description: Initializes a pattern of grass to be passed to an ObjGrass instance.
|
||||
*
|
||||
* ObjGrassUnit instances are intended to be spawned from room data so that just one ObjGrass instance manages the grass
|
||||
* for that room. When a room with ObjGrassUnit spawns loads, it allocates ovl_Obj_Grass_Unit and creates N instances of
|
||||
* ObjGrassUnit. The first instance processed initializes sGrassManager, then all instances live on that cycle pass type
|
||||
* and position data to that ObjGrass instance before calling Actor_Kill. Since ovl_Obj_Grass_Unit uses
|
||||
* ALLOCTYPE_NORMAL, it is deleted and loses the reference to the newly created ObjGrass. This allows for ObjGrassUnit
|
||||
* spawned in a different room to be associated to a new ObjGrass instance.
|
||||
*/
|
||||
|
||||
#include "z_obj_grass_unit.h"
|
||||
#include "overlays/actors/ovl_Obj_Grass/z_obj_grass.h"
|
||||
#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h"
|
||||
|
||||
#define FLAGS 0x00000000
|
||||
|
||||
#define THIS ((ObjGrassUnit*)thisx)
|
||||
|
||||
void ObjGrassUnit_Init(Actor* thisx, PlayState* play);
|
||||
void ObjGrassUnit_Init(Actor* this, PlayState* play2);
|
||||
|
||||
#if 0
|
||||
ActorInit Obj_Grass_Unit_InitVars = {
|
||||
ACTOR_OBJ_GRASS_UNIT,
|
||||
ACTORCAT_BG,
|
||||
FLAGS,
|
||||
GAMEPLAY_FIELD_KEEP,
|
||||
sizeof(ObjGrassUnit),
|
||||
(ActorFunc)ObjGrassUnit_Init,
|
||||
(ActorFunc)Actor_Noop,
|
||||
(ActorFunc)Actor_Noop,
|
||||
(ActorFunc)NULL,
|
||||
ACTOR_OBJ_GRASS_UNIT, ACTORCAT_BG, FLAGS,
|
||||
GAMEPLAY_FIELD_KEEP, sizeof(ObjGrassUnit), (ActorFunc)ObjGrassUnit_Init,
|
||||
(ActorFunc)Actor_Noop, (ActorFunc)Actor_Noop, (ActorFunc)NULL,
|
||||
};
|
||||
|
||||
#endif
|
||||
// Neat circular pattern with a single bush in the center
|
||||
static VecPolar sGrassPatternCircle[] = {
|
||||
{ 0.0f, 0x0000 }, { 80.0f, 0x0000 }, { 80.0f, 0x2000 }, { 80.0f, 0x4000 }, { 80.0f, 0x6000 },
|
||||
{ 80.0f, 0x8000 }, { 80.0f, 0xA000 }, { 80.0f, 0xC000 }, { 80.0f, 0xE000 },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABDE0.s")
|
||||
// "Random" looking pattern
|
||||
static VecPolar sGrassPatternMixed[] = {
|
||||
{ 40.0f, 0x0666 }, { 40.0f, 0x2CCC }, { 40.0f, 0x5999 }, { 40.0f, 0x8667 }, { 20.0f, 0xC000 }, { 80.0f, 0x1333 },
|
||||
{ 80.0f, 0x4000 }, { 80.0f, 0x6CCC }, { 80.0f, 0x9334 }, { 80.0f, 0xACCD }, { 80.0f, 0xC667 }, { 60.0f, 0xE000 },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABE54.s")
|
||||
typedef struct {
|
||||
/* 0x0 */ s32 count;
|
||||
/* 0x4 */ VecPolar* positions;
|
||||
} ObjGrassUnitPattern; // size = 0x8
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABEC4.s")
|
||||
static ObjGrassUnitPattern sGrassPatterns[2] = {
|
||||
{ ARRAY_COUNT(sGrassPatternCircle), sGrassPatternCircle },
|
||||
{ ARRAY_COUNT(sGrassPatternMixed), sGrassPatternMixed },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABF38.s")
|
||||
ObjGrass* sGrassManager = NULL;
|
||||
ObjGrassCarry* sGrassCarry0 = NULL;
|
||||
ObjGrassCarry* sGrassCarry1 = NULL;
|
||||
s32 sInitialized = false;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/ObjGrassUnit_Init.s")
|
||||
s32 ObjGrassUnit_SpawnObjGrass(Actor* this, PlayState* play) {
|
||||
sGrassManager = (ObjGrass*)Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_GRASS, 0.0f, 0.0f, 0.0f, 0, 0, 0, -1);
|
||||
if (sGrassManager != NULL) {
|
||||
sGrassManager->actor.room = this->room;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 ObjGrassUnit_SpawnObjGrassCarry0(Actor* this, PlayState* play) {
|
||||
sGrassCarry0 =
|
||||
(ObjGrassCarry*)Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_GRASS_CARRY, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0);
|
||||
if (sGrassCarry0 != NULL) {
|
||||
sGrassCarry0->actor.room = this->room;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 ObjGrassUnit_SpawnObjGrassCarry1(Actor* this, PlayState* play) {
|
||||
sGrassCarry1 =
|
||||
(ObjGrassCarry*)Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_GRASS_CARRY, 0.0f, 0.0f, 0.0f, 0, 0, 0, 1);
|
||||
if (sGrassCarry1 != NULL) {
|
||||
sGrassCarry1->actor.room = this->room;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 ObjGrassUnit_IsUnderwater(PlayState* play, Vec3f* pos) {
|
||||
WaterBox* waterBox;
|
||||
f32 ySurface;
|
||||
s32 bgId;
|
||||
|
||||
if (WaterBox_GetSurfaceImpl(play, &play->colCtx, pos->x, pos->z, &ySurface, &waterBox, &bgId) &&
|
||||
(pos->y < ySurface)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ObjGrassUnit_Init(Actor* this, PlayState* play2) {
|
||||
PlayState* play = play2;
|
||||
ObjGrassGroup* grassGroup;
|
||||
ObjGrass* grassManager;
|
||||
f32 homePosYSum;
|
||||
f32 tmp;
|
||||
s32 i;
|
||||
VecPolar* grassPos;
|
||||
CollisionPoly* poly;
|
||||
s32 bgId;
|
||||
ObjGrassElement* grassElem;
|
||||
ObjGrassUnitPattern* grassPattern;
|
||||
s8 dropTable = OBJGRASSUNIT_GET_DROPTABLE(this);
|
||||
|
||||
if ((sGrassManager == NULL) && !ObjGrassUnit_SpawnObjGrass(this, play)) {
|
||||
Actor_Kill(this);
|
||||
return;
|
||||
}
|
||||
if ((sGrassCarry0 == NULL) && ObjGrassUnit_SpawnObjGrassCarry0(this, play)) {
|
||||
sGrassCarry0->grassManager = sGrassManager;
|
||||
}
|
||||
if ((sGrassCarry1 == NULL) && ObjGrassUnit_SpawnObjGrassCarry1(this, play)) {
|
||||
sGrassCarry1->grassManager = sGrassManager;
|
||||
}
|
||||
if (!sInitialized && (sGrassManager != NULL) && (sGrassCarry0 != NULL) && (sGrassCarry1 != NULL)) {
|
||||
sInitialized = true;
|
||||
sGrassManager->grassCarry[0] = sGrassCarry0;
|
||||
sGrassManager->grassCarry[1] = sGrassCarry1;
|
||||
sGrassCarry0->grassManager = sGrassManager;
|
||||
sGrassCarry1->grassManager = sGrassManager;
|
||||
}
|
||||
|
||||
grassManager = sGrassManager;
|
||||
if (sGrassManager->activeGrassGroups >= ARRAY_COUNT(sGrassManager->grassGroups)) {
|
||||
Actor_Kill(this);
|
||||
return;
|
||||
}
|
||||
|
||||
homePosYSum = 0.0f;
|
||||
grassGroup = &grassManager->grassGroups[sGrassManager->activeGrassGroups];
|
||||
grassGroup->count = 0;
|
||||
grassPattern = &sGrassPatterns[OBJGRASSUNIT_GET_PATTERN(this)];
|
||||
|
||||
for (i = 0; i < grassPattern->count; i++) {
|
||||
grassElem = &grassGroup->elements[grassGroup->count];
|
||||
grassPos = &grassPattern->positions[i];
|
||||
|
||||
grassElem->pos.x = (Math_CosS((this->home.rot.y + grassPos->angle)) * grassPos->distance) + this->home.pos.x;
|
||||
grassElem->pos.y = this->home.pos.y + 100.0f;
|
||||
grassElem->pos.z = (Math_SinS((this->home.rot.y + grassPos->angle)) * grassPos->distance) + this->home.pos.z;
|
||||
|
||||
grassElem->pos.y = BgCheck_EntityRaycastFloor5(&play->colCtx, &poly, &bgId, this, &grassElem->pos);
|
||||
tmp = grassElem->pos.y - this->home.pos.y;
|
||||
if ((fabsf(tmp) < 80.0f) && (grassElem->pos.y > BGCHECK_Y_MIN)) {
|
||||
grassGroup->count++;
|
||||
grassElem->rotY = (s16)(Rand_Next() >> 0x10);
|
||||
grassElem->dropTable = dropTable;
|
||||
if (ObjGrassUnit_IsUnderwater(play, &grassElem->pos)) {
|
||||
grassElem->flags |= OBJ_GRASS_ELEM_UNDERWATER;
|
||||
}
|
||||
homePosYSum += grassElem->pos.y;
|
||||
}
|
||||
}
|
||||
if (grassGroup->count > 0) {
|
||||
grassManager->activeGrassGroups++;
|
||||
grassGroup->homePos.x = this->home.pos.x;
|
||||
grassGroup->homePos.y = (homePosYSum / grassGroup->count);
|
||||
grassGroup->homePos.z = this->home.pos.z;
|
||||
}
|
||||
Actor_Kill(this);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#define OBJGRASSUNIT_GET_DROPTABLE(thisx) (((thisx)->params >> 8) & 0x1F)
|
||||
#define OBJGRASSUNIT_GET_PATTERN(thisx) ((thisx)->params & 1)
|
||||
|
||||
struct ObjGrassUnit;
|
||||
|
||||
typedef struct ObjGrassUnit {
|
||||
|
||||
Reference in New Issue
Block a user