Obj_Grass_Carry (#741)

* Obj_Grass_Carry

* Fix?

* Fix2?

* Merge

* Test

* Merge
This commit is contained in:
Maide 2022-03-29 18:16:05 +01:00 committed by GitHub
parent a8e9b6c9b3
commit 9af2914992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 318 additions and 39 deletions

3
spec
View File

@ -2283,8 +2283,7 @@ beginseg
name "ovl_Obj_Grass_Carry" name "ovl_Obj_Grass_Carry"
compress compress
include "build/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.o" include "build/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.o"
include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.data.o" include "build/src/overlays/actors/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry_reloc.o"
include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.reloc.o"
endseg endseg
beginseg beginseg

View File

@ -5,6 +5,7 @@
*/ */
#include "z_obj_grass.h" #include "z_obj_grass.h"
#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h"
#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_keep/gameplay_keep.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)
@ -266,7 +267,7 @@ void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) {
Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00);
if (ABS_ALT(yaw) < 0x2000) { if (ABS_ALT(yaw) < 0x2000) {
this->unk_3294 = &ptr->unk_0C[j].unk_00; this->unk_3294 = &ptr->unk_0C[j];
} }
} }
} }

View File

@ -5,8 +5,9 @@
#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" #include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h"
struct ObjGrass; struct ObjGrass;
struct ObjGrassCarry;
typedef struct { typedef struct ObjGrassStruct1_1 {
/* 0x00 */ Vec3f unk_00; /* 0x00 */ Vec3f unk_00;
/* 0x0C */ s16 unk_0C; /* 0x0C */ s16 unk_0C;
/* 0x0E */ s8 unk_0E; /* 0x0E */ s8 unk_0E;
@ -38,8 +39,9 @@ typedef struct ObjGrass {
/* 0x328C */ s16 unk_328C; /* 0x328C */ s16 unk_328C;
/* 0x328E */ s16 unk_328E; /* 0x328E */ s16 unk_328E;
/* 0x3290 */ s16 unk_3290; /* 0x3290 */ s16 unk_3290;
/* 0x3294 */ Vec3f* unk_3294; /* 0x3292 */ s16 unk_3292;
/* 0x3298 */ ObjGrassCarry* unk_3298[2]; /* 0x3294 */ ObjGrassStruct1_1* unk_3294;
/* 0x3298 */ struct ObjGrassCarry* unk_3298[2];
} ObjGrass; // size = 0x32A0 } ObjGrass; // size = 0x32A0
extern const ActorInit Obj_Grass_InitVars; extern const ActorInit Obj_Grass_InitVars;

View File

@ -5,6 +5,9 @@
*/ */
#include "z_obj_grass_carry.h" #include "z_obj_grass_carry.h"
#include "objects/gameplay_field_keep/gameplay_field_keep.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "overlays/actors/ovl_Obj_Grass/z_obj_grass.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000) #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000)
@ -14,7 +17,18 @@ void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx);
void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx);
#if 0 void func_809AB3C4(ObjGrassCarry* this);
void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx);
void func_809AB428(ObjGrassCarry* this);
void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx);
void func_809AB474(ObjGrassCarry* this);
void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx);
void func_809AB5FC(ObjGrassCarry* this);
void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx);
void func_809AB6FC(ObjGrassCarry* this);
void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx);
void func_809ABB7C(Actor* this, GlobalContext* globalCtx);
const ActorInit Obj_Grass_Carry_InitVars = { const ActorInit Obj_Grass_Carry_InitVars = {
ACTOR_OBJ_GRASS_CARRY, ACTOR_OBJ_GRASS_CARRY,
ACTORCAT_PROP, ACTORCAT_PROP,
@ -27,61 +41,320 @@ const ActorInit Obj_Grass_Carry_InitVars = {
(ActorFunc)NULL, (ActorFunc)NULL,
}; };
// static ColliderCylinderInit sCylinderInit = { static ColliderCylinderInit sCylinderInit = {
static ColliderCylinderInit D_809ABBD0 = { {
{ COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, COLTYPE_NONE,
{ ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, AT_ON | AT_TYPE_PLAYER,
AC_NONE,
OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2,
OC2_TYPE_2,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00400000, 0x00, 0x02 },
{ 0x00000000, 0x00, 0x00 },
TOUCH_ON | TOUCH_SFX_NONE,
BUMP_NONE,
OCELEM_ON,
},
{ 10, 44, 0, { 0, 0, 0 } }, { 10, 44, 0, { 0, 0, 0 } },
}; };
// static InitChainEntry sInitChain[] = { s16 D_809ABBFC = 0;
static InitChainEntry D_809ABC4C[] = { s16 D_809ABC00 = 0;
s16 D_809ABC04 = 0;
s16 D_809ABC08 = 0;
Vec3f D_809ABC0C[] = {
{ 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 InitChainEntry sInitChain[] = {
ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE),
ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE),
ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP),
}; };
#endif void func_809AAE60(ObjGrassCarry* this) {
this->actor.velocity.y += this->actor.gravity;
if (this->actor.velocity.y < this->actor.terminalVelocity) {
this->actor.velocity.y = this->actor.terminalVelocity;
}
}
extern ColliderCylinderInit D_809ABBD0; void func_809AAE94(Vec3f* arg0, f32 arg1) {
extern InitChainEntry D_809ABC4C[]; arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE60.s") arg0->x -= (arg0->x * arg1);
arg0->y -= (arg0->y * arg1);
arg0->z -= (arg0->z * arg1);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE94.s") void func_809AAF18(ObjGrassCarry* this) {
func_809AAE60(this);
func_809AAE94(&this->actor.velocity, 0.05f);
Actor_UpdatePos(&this->actor);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF18.s") void func_809AAF58(ObjGrassCarry* this, GlobalContext* globalCtx) {
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF58.s") void func_809AAF9C(Vec3f* arg0, s16 arg1, GlobalContext* globalCtx) {
if (!(arg1 & 0x10)) {
Item_DropCollectibleRandom(globalCtx, NULL, arg0, arg1 * 0x10);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF9C.s") void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) {
Vec3f spBC;
Vec3f spB0;
s32 i;
Vec3f* ptr;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAFE8.s") for (i = 0; i < ARRAY_COUNT(D_809ABC0C); i++) {
ptr = &D_809ABC0C[i];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Init.s") 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);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Destroy.s") spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f;
spBC.y = Rand_ZeroOne() * 10.0f;
spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3C4.s") EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0,
D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3D8.s") 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);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB428.s") spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f;
spBC.y = Rand_ZeroOne() * 10.0f;
spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB43C.s") EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0,
D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB474.s") void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx) {
ObjGrassCarry* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB4A8.s") Actor_ProcessInitChain(&this->actor, sInitChain);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
this->actor.colChkInfo.mass = 80;
func_809AB3C4(this);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB5FC.s") void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx) {
ObjGrassCarry* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB610.s") Collider_DestroyCylinder(globalCtx, &this->collider);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB6FC.s") if (this->unk_190 != NULL) {
ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB77C.s") if (this == *carry) {
*carry = NULL;
this->unk_190 = NULL;
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Update.s") void func_809AB3C4(ObjGrassCarry* this) {
this->actionFunc = func_809AB3D8;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809ABB7C.s") void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx) {
if (this->unk_190 != NULL) {
if (this->actor.params != this->unk_190->unk_3292) {
func_809AB474(this);
} else {
func_809AB428(this);
}
}
}
void func_809AB428(ObjGrassCarry* this) {
this->actionFunc = func_809AB43C;
}
void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx) {
if (this->actor.params != this->unk_190->unk_3292) {
func_809AB474(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 func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) {
ObjGrassCarry* this2 = this;
if (Actor_HasParent(&this->actor, globalCtx)) {
func_809AB5FC(this);
if (this->unk_194 != NULL) {
this->unk_194->unk_0F |= 4;
}
this->actor.draw = func_809ABB7C;
this->actor.shape.shadowDraw = ActorShadow_DrawCircle;
this->actor.shape.shadowAlpha = 60;
this->actor.shape.shadowScale = 1.0f;
this->unk_190->unk_3292 ^= 1;
this->actor.room = -1;
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT);
} else if (this->unk_190->unk_3294 != NULL) {
Player* player = GET_PLAYER(globalCtx);
this->unk_194 = this->unk_190->unk_3294;
Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_194->unk_00);
this->actor.shape.rot.y = this->actor.world.rot.y = this->unk_194->unk_0C;
this->unk_198 = this2->unk_194->unk_0E;
this->actor.xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor);
this->actor.playerHeightRel = Actor_HeightDiff(&this->actor, &player->actor);
this->actor.xyzDistToPlayerSq = SQ(this->actor.xzDistToPlayer) + SQ(this->actor.playerHeightRel);
this->actor.yawTowardsPlayer = Actor_YawBetweenActors(&this->actor, &player->actor);
Actor_LiftActor(&this->actor, globalCtx);
}
}
void func_809AB5FC(ObjGrassCarry* this) {
this->actionFunc = func_809AB610;
}
void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx) {
s32 pad;
Vec3f sp30;
s32 sp2C;
if (Actor_HasNoParent(&this->actor, globalCtx)) {
func_809AB6FC(this);
this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ;
this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ;
this->actor.gravity = -0.1f;
this->actor.terminalVelocity = -17.0f;
func_809AAF18(this);
func_809AAF58(this, globalCtx);
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;
this->actor.floorHeight =
BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30);
}
}
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 func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) {
s16 phi_s0;
s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0;
Vec3f sp5C;
s32 i;
if (temp_v0) {
this->collider.base.atFlags &= ~AT_HIT;
}
this->unk_19A--;
if ((this->actor.bgCheckFlags & (1 | 2 | 8)) || temp_v0 || (this->unk_19A <= 0)) {
func_809AAFE8(&this->actor.world.pos, globalCtx);
func_809AAF9C(&this->actor.world.pos, this->unk_198, globalCtx);
this->actor.draw = NULL;
this->actor.shape.shadowDraw = NULL;
if (this->unk_190 != NULL) {
this->actor.room = this->unk_190->actor.room;
}
if (!(this->actor.bgCheckFlags & 0x20)) {
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN);
}
func_809AB428(this);
return;
}
if (this->actor.bgCheckFlags & 0x40) {
sp5C.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(globalCtx, &sp5C, NULL, NULL, 0, 190);
}
sp5C.x = this->actor.world.pos.x;
sp5C.z = this->actor.world.pos.z;
EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 280);
EffectSsGRipple_Spawn(globalCtx, &sp5C, 300, 700, 0);
this->actor.terminalVelocity = -3.0f;
this->actor.velocity.x *= 0.1f;
this->actor.velocity.y *= 0.4f;
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;
this->actor.bgCheckFlags &= ~0x40;
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &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, globalCtx);
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) {
ObjGrassCarry* this = THIS;
if (this->unk_190 == NULL) {
if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) {
Actor_MarkForDeath(&this->actor);
return;
}
}
this->actionFunc(this, globalCtx);
}
void func_809ABB7C(Actor* this, GlobalContext* globalCtx) {
Gfx_DrawDListOpa(globalCtx, gKusaBushType1);
}

View File

@ -4,14 +4,18 @@
#include "global.h" #include "global.h"
struct ObjGrassCarry; struct ObjGrassCarry;
struct ObjGrass;
struct ObjGrassStruct1_1;
typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*);
typedef struct ObjGrassCarry { typedef struct ObjGrassCarry {
/* 0x0000 */ Actor actor; /* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x4C]; /* 0x0144 */ ColliderCylinder collider;
/* 0x0190 */ s32 unk_190; /* 0x0190 */ struct ObjGrass* unk_190;
/* 0x0194 */ char unk_194[0x8]; /* 0x0194 */ struct ObjGrassStruct1_1* unk_194;
/* 0x0198 */ s16 unk_198;
/* 0x019A */ s16 unk_19A;
/* 0x019C */ ObjGrassCarryActionFunc actionFunc; /* 0x019C */ ObjGrassCarryActionFunc actionFunc;
} ObjGrassCarry; // size = 0x1A0 } ObjGrassCarry; // size = 0x1A0