diff options
| author | angie <angheloalf95@gmail.com> | 2023-10-11 11:42:39 -0300 |
|---|---|---|
| committer | angie <angheloalf95@gmail.com> | 2023-10-11 11:42:39 -0300 |
| commit | a8b877c7f0a29abca80b5b00a68ff388b0eb1600 (patch) | |
| tree | 1a359f9cd2b96bac784bd3545ffd24cdc30bdad1 | |
| parent | 4c2b72e577a2272d641a2cf8c5624b7022ceb63b (diff) | |
| parent | 2c182bf7e35f6b7ac7853071875343f591c37510 (diff) | |
Merge remote-tracking branch 'upstream/main' into ovl_En_An
| -rw-r--r-- | assets/xml/objects/object_icicle.xml | 7 | ||||
| -rw-r--r-- | assets/xml/objects/object_jso.xml | 261 | ||||
| -rw-r--r-- | include/z64math.h | 9 | ||||
| -rw-r--r-- | spec | 3 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c | 4 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c | 384 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h | 54 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c | 283 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h | 10 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c | 166 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h | 3 |
11 files changed, 684 insertions, 500 deletions
diff --git a/assets/xml/objects/object_icicle.xml b/assets/xml/objects/object_icicle.xml index ac0000471..d3275aa46 100644 --- a/assets/xml/objects/object_icicle.xml +++ b/assets/xml/objects/object_icicle.xml @@ -1,7 +1,8 @@ <Root> + <!-- Object for Icicles --> <File Name="object_icicle" Segment="6"> - <DList Name="object_icicle_DL_0000D0" Offset="0xD0" /> <!-- Original name is "ice_turara_model" --> - <Collision Name="object_icicle_Colheader_000294" Offset="0x294" /> <!-- Original name is "ice_turara_bgdatainfo" --> - <Texture Name="object_icicle_Tex_0002C0" OutName="tex_0002C0" Format="i8" Width="64" Height="64" Offset="0x2C0" /> + <DList Name="gIcicleDL" Offset="0xD0" /> <!-- Original name is "ice_turara_model" --> + <Collision Name="gIcicleCol" Offset="0x294" /> <!-- Original name is "ice_turara_bgdatainfo" --> + <Texture Name="gIcicleTex" OutName="icicle" Format="i8" Width="64" Height="64" Offset="0x2C0" /> </File> </Root> diff --git a/assets/xml/objects/object_jso.xml b/assets/xml/objects/object_jso.xml index bfe271d69..d94ffdafe 100644 --- a/assets/xml/objects/object_jso.xml +++ b/assets/xml/objects/object_jso.xml @@ -1,122 +1,147 @@ <Root> + <!-- Assets for Garos and the Garo Master --> <File Name="object_jso" Segment="6"> - <!-- <Blob Name="object_jso_Blob_000000" Size="0x20" Offset="0x0" /> --> - <DList Name="object_jso_DL_001210" Offset="0x1210" /> - <DList Name="object_jso_DL_001348" Offset="0x1348" /> - <DList Name="object_jso_DL_0013F8" Offset="0x13F8" /> - <DList Name="object_jso_DL_001508" Offset="0x1508" /> - <DList Name="object_jso_DL_001640" Offset="0x1640" /> - <DList Name="object_jso_DL_0016F0" Offset="0x16F0" /> - <DList Name="object_jso_DL_001800" Offset="0x1800" /> - <DList Name="object_jso_DL_001908" Offset="0x1908" /> - <DList Name="object_jso_DL_001A18" Offset="0x1A18" /> - <DList Name="object_jso_DL_001B00" Offset="0x1B00" /> - <DList Name="object_jso_DL_001C48" Offset="0x1C48" /> - <DList Name="object_jso_DL_001D78" Offset="0x1D78" /> - <DList Name="object_jso_DL_001EA8" Offset="0x1EA8" /> - <DList Name="object_jso_DL_001FA8" Offset="0x1FA8" /> - <DList Name="object_jso_DL_001FF8" Offset="0x1FF8" /> - <DList Name="object_jso_DL_0020B0" Offset="0x20B0" /> - <DList Name="object_jso_DL_002100" Offset="0x2100" /> - <!-- <Blob Name="object_jso_Blob_0021B8" Size="0x100" Offset="0x21B8" /> --> - <Texture Name="object_jso_Tex_0022B8" OutName="tex_0022B8" Format="rgba16" Width="16" Height="16" Offset="0x22B8" /> - <Texture Name="object_jso_Tex_0024B8" OutName="tex_0024B8" Format="rgba16" Width="8" Height="16" Offset="0x24B8" /> - <!-- <Blob Name="object_jso_Blob_0025B8" Size="0x80" Offset="0x25B8" /> --> - <Texture Name="object_jso_Tex_002638" OutName="tex_002638" Format="rgba16" Width="4" Height="4" Offset="0x2638" /> - <Texture Name="object_jso_Tex_002658" OutName="tex_002658" Format="rgba16" Width="8" Height="32" Offset="0x2658" /> - <Texture Name="object_jso_TLUT_002858" OutName="tlut_002858" Format="rgba16" Width="16" Height="16" Offset="0x2858" /> - <Texture Name="object_jso_TLUT_002A58" OutName="tlut_002A58" Format="rgba16" Width="16" Height="16" Offset="0x2A58" /> - <Texture Name="object_jso_Tex_002C58" OutName="tex_002C58" Format="ci8" Width="16" Height="16" Offset="0x2C58" /> - <Texture Name="object_jso_Tex_002D58" OutName="tex_002D58" Format="ci8" Width="16" Height="16" Offset="0x2D58" /> - <DList Name="object_jso_DL_002ED8" Offset="0x2ED8" /> - <Texture Name="object_jso_Tex_002FB8" OutName="tex_002FB8" Format="rgba16" Width="8" Height="8" Offset="0x2FB8" /> - <Limb Name="object_jso_Standardlimb_003038" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_01" Offset="0x3038" /> - <Limb Name="object_jso_Standardlimb_003044" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_02" Offset="0x3044" /> - <Limb Name="object_jso_Standardlimb_003050" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_03" Offset="0x3050" /> - <Limb Name="object_jso_Standardlimb_00305C" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_04" Offset="0x305C" /> - <Limb Name="object_jso_Standardlimb_003068" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_05" Offset="0x3068" /> - <Limb Name="object_jso_Standardlimb_003074" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_06" Offset="0x3074" /> - <Limb Name="object_jso_Standardlimb_003080" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_07" Offset="0x3080" /> - <Limb Name="object_jso_Standardlimb_00308C" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_08" Offset="0x308C" /> - <Limb Name="object_jso_Standardlimb_003098" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_09" Offset="0x3098" /> - <Limb Name="object_jso_Standardlimb_0030A4" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_0A" Offset="0x30A4" /> - <Limb Name="object_jso_Standardlimb_0030B0" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_0B" Offset="0x30B0" /> - <Limb Name="object_jso_Standardlimb_0030BC" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_0C" Offset="0x30BC" /> - <Limb Name="object_jso_Standardlimb_0030C8" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_0D" Offset="0x30C8" /> - <Limb Name="object_jso_Standardlimb_0030D4" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_0E" Offset="0x30D4" /> - <Limb Name="object_jso_Standardlimb_0030E0" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_0F" Offset="0x30E0" /> - <Limb Name="object_jso_Standardlimb_0030EC" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_10" Offset="0x30EC" /> - <Limb Name="object_jso_Standardlimb_0030F8" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_11" Offset="0x30F8" /> - <Limb Name="object_jso_Standardlimb_003104" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_12" Offset="0x3104" /> - <Limb Name="object_jso_Standardlimb_003110" Type="Standard" EnumName="OBJECT_JSO_1_LIMB_13" Offset="0x3110" /> - <Skeleton Name="object_jso_Skel_003168" Type="Flex" LimbType="Standard" LimbNone="OBJECT_JSO_1_LIMB_NONE" LimbMax="OBJECT_JSO_1_LIMB_MAX" EnumName="ObjectJso1Limb" Offset="0x3168" /> - <Animation Name="object_jso_Anim_003238" Offset="0x3238" /> <!-- Original name is "jsk_pose" --> - <Animation Name="object_jso_Anim_003530" Offset="0x3530" /> <!-- Original name is "jso_attack1" --> - <Animation Name="object_jso_Anim_00378C" Offset="0x378C" /> <!-- Original name is "jso_attack2" --> - <Animation Name="object_jso_Anim_0038AC" Offset="0x38AC" /> <!-- Original name is "jso_attack_wait" --> - <Animation Name="object_jso_Anim_003D5C" Offset="0x3D5C" /> <!-- Original name is "jso_back" --> - <Animation Name="object_jso_Anim_004018" Offset="0x4018" /> <!-- Original name is "jso_bomb" --> - <Animation Name="object_jso_Anim_004384" Offset="0x4384" /> <!-- Original name is "jso_chakuchiD" --> - <Animation Name="object_jso_Anim_0044F8" Offset="0x44F8" /> <!-- Original name is "jso_damage" --> - <Animation Name="object_jso_Anim_004858" Offset="0x4858" /> <!-- Original name is "jso_defense" --> - <Animation Name="object_jso_Anim_005778" Offset="0x5778" /> <!-- Original name is "jso_demo_start" --> - <Animation Name="object_jso_Anim_005D5C" Offset="0x5D5C" /> <!-- Original name is "jso_down" --> - <Animation Name="object_jso_Anim_00603C" Offset="0x603C" /> <!-- Original name is "jso_hajiku" --> - <Animation Name="object_jso_Anim_0063A4" Offset="0x63A4" /> <!-- Original name is "jso_henahena" --> - <Animation Name="object_jso_Anim_0067F0" Offset="0x67F0" /> <!-- Original name is "jso_hetari" --> - <Animation Name="object_jso_Anim_0070BC" Offset="0x70BC" /> <!-- Original name is "jso_jakin" --> - <Animation Name="object_jso_Anim_0071E0" Offset="0x71E0" /> <!-- Original name is "jso_jumpD" --> - <Animation Name="object_jso_Anim_0072AC" Offset="0x72AC" /> <!-- Original name is "jso_kaiten" --> - <Animation Name="object_jso_Anim_00788C" Offset="0x788C" /> <!-- Original name is "jso_kyoro" --> - <Animation Name="object_jso_Anim_007B04" Offset="0x7B04" /> <!-- Original name is "jso_ororo" --> - <Animation Name="object_jso_Anim_0081F4" Offset="0x81F4" /> <!-- Original name is "jso_start" --> - <DList Name="object_jso_DL_008F50" Offset="0x8F50" /> - <DList Name="object_jso_DL_009008" Offset="0x9008" /> - <DList Name="object_jso_DL_0090C0" Offset="0x90C0" /> - <DList Name="object_jso_DL_009190" Offset="0x9190" /> - <DList Name="object_jso_DL_009248" Offset="0x9248" /> - <DList Name="object_jso_DL_009300" Offset="0x9300" /> - <DList Name="object_jso_DL_0093D0" Offset="0x93D0" /> - <DList Name="object_jso_DL_009428" Offset="0x9428" /> - <DList Name="object_jso_DL_0094E0" Offset="0x94E0" /> - <DList Name="object_jso_DL_009758" Offset="0x9758" /> - <DList Name="object_jso_DL_0098C8" Offset="0x98C8" /> - <DList Name="object_jso_DL_0099B8" Offset="0x99B8" /> - <DList Name="object_jso_DL_009AA8" Offset="0x9AA8" /> - <DList Name="object_jso_DL_009B80" Offset="0x9B80" /> - <DList Name="object_jso_DL_009BD8" Offset="0x9BD8" /> - <DList Name="object_jso_DL_009C98" Offset="0x9C98" /> - <DList Name="object_jso_DL_009CF0" Offset="0x9CF0" /> - <Texture Name="object_jso_Tex_009DB0" OutName="tex_009DB0" Format="rgba16" Width="8" Height="16" Offset="0x9DB0" /> - <Texture Name="object_jso_Tex_009EB0" OutName="tex_009EB0" Format="rgba16" Width="8" Height="8" Offset="0x9EB0" /> - <Texture Name="object_jso_Tex_009F30" OutName="tex_009F30" Format="rgba16" Width="16" Height="32" Offset="0x9F30" /> - <Texture Name="object_jso_Tex_00A330" OutName="tex_00A330" Format="rgba16" Width="16" Height="16" Offset="0xA330" /> - <Texture Name="object_jso_Tex_00A530" OutName="tex_00A530" Format="rgba16" Width="16" Height="8" Offset="0xA530" /> - <Texture Name="object_jso_Tex_00A630" OutName="tex_00A630" Format="rgba16" Width="8" Height="8" Offset="0xA630" /> - <Texture Name="object_jso_Tex_00A6B0" OutName="tex_00A6B0" Format="rgba16" Width="16" Height="16" Offset="0xA6B0" /> - <Texture Name="object_jso_Tex_00A8B0" OutName="tex_00A8B0" Format="rgba16" Width="4" Height="4" Offset="0xA8B0" /> - <Limb Name="object_jso_Standardlimb_00A8D0" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_01" Offset="0xA8D0" /> - <Limb Name="object_jso_Standardlimb_00A8DC" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_02" Offset="0xA8DC" /> - <Limb Name="object_jso_Standardlimb_00A8E8" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_03" Offset="0xA8E8" /> - <Limb Name="object_jso_Standardlimb_00A8F4" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_04" Offset="0xA8F4" /> - <Limb Name="object_jso_Standardlimb_00A900" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_05" Offset="0xA900" /> - <Limb Name="object_jso_Standardlimb_00A90C" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_06" Offset="0xA90C" /> - <Limb Name="object_jso_Standardlimb_00A918" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_07" Offset="0xA918" /> - <Limb Name="object_jso_Standardlimb_00A924" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_08" Offset="0xA924" /> - <Limb Name="object_jso_Standardlimb_00A930" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_09" Offset="0xA930" /> - <Limb Name="object_jso_Standardlimb_00A93C" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_0A" Offset="0xA93C" /> - <Limb Name="object_jso_Standardlimb_00A948" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_0B" Offset="0xA948" /> - <Limb Name="object_jso_Standardlimb_00A954" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_0C" Offset="0xA954" /> - <Limb Name="object_jso_Standardlimb_00A960" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_0D" Offset="0xA960" /> - <Limb Name="object_jso_Standardlimb_00A96C" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_0E" Offset="0xA96C" /> - <Limb Name="object_jso_Standardlimb_00A978" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_0F" Offset="0xA978" /> - <Limb Name="object_jso_Standardlimb_00A984" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_10" Offset="0xA984" /> - <Limb Name="object_jso_Standardlimb_00A990" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_11" Offset="0xA990" /> - <Limb Name="object_jso_Standardlimb_00A99C" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_12" Offset="0xA99C" /> - <Limb Name="object_jso_Standardlimb_00A9A8" Type="Standard" EnumName="OBJECT_JSO_2_LIMB_13" Offset="0xA9A8" /> - <Skeleton Name="object_jso_Skel_00AA00" Type="Flex" LimbType="Standard" LimbNone="OBJECT_JSO_2_LIMB_NONE" LimbMax="OBJECT_JSO_2_LIMB_MAX" EnumName="ObjectJso2Limb" Offset="0xAA00" /> - <Animation Name="object_jso_Anim_00AE80" Offset="0xAE80" /> <!-- Original name is "jso_wait" --> - <Animation Name="object_jso_Anim_00B1DC" Offset="0xB1DC" /> <!-- Original name is "jso_waitD" --> - <Animation Name="object_jso_Anim_00B5F0" Offset="0xB5F0" /> <!-- Original name is "jso_walk" --> + <!-- Unused Empty Texture Animations --> + <TextureAnimation Name="gGaroEmpty1TexAnim" Offset="0x0" /> + <TextureAnimation Name="gGaroEmpty2TexAnim" Offset="0x10" /> + + <!-- Garo Master Limb DisplayLists --> + <DList Name="gGaroMasterLeftThighDL" Offset="0x1210" /> + <DList Name="gGaroMasterLeftShinDL" Offset="0x1348" /> + <DList Name="gGaroMasterLeftFootDL" Offset="0x13F8" /> + <DList Name="gGaroMasterRightThighDL" Offset="0x1508" /> + <DList Name="gGaroMasterRightShinDL" Offset="0x1640" /> + <DList Name="gGaroMasterRightFootDL" Offset="0x16F0" /> + <DList Name="gGaroMasterTorsoDL" Offset="0x1800" /> + <DList Name="gGaroMasterHeadDL" Offset="0x1908" /> + <DList Name="gGaroMasterRobeTopDL" Offset="0x1A18" /> + <DList Name="gGaroMasterRobeFrontDL" Offset="0x1B00" /> + <DList Name="gGaroMasterRobeRightDL" Offset="0x1C48" /> + <DList Name="gGaroMasterRobeLeftDL" Offset="0x1D78" /> + <DList Name="gGaroMasterRobeBackDL" Offset="0x1EA8" /> + <DList Name="gGaroMasterRightArmDL" Offset="0x1FA8" /> + <DList Name="gGaroMasterRightSwordDL" Offset="0x1FF8" /> + <DList Name="gGaroMasterLeftArmDL" Offset="0x20B0" /> + <DList Name="gGaroMasterLeftSwordDL" Offset="0x2100" /> + + <!-- Garo Master Textures --> + <Texture Name="gGaroMasterUnusedLegWrappingTex" OutName="garo_master_unused_leg_wrapping" Format="rgba16" Width="8" Height="16" Offset="0x21B8" /> <!-- unused duplicate of gGaroLegWrappingTex --> + <Texture Name="gGaroMasterRobeFrontTex" OutName="garo_master_robe_front" Format="rgba16" Width="16" Height="16" Offset="0x22B8" /> + <Texture Name="gGaroMasterShinTex" OutName="garo_master_shin" Format="rgba16" Width="8" Height="16" Offset="0x24B8" /> + <Texture Name="gGaroMasterDuplicateEyeTex" OutName="garo_master_duplicate_eye" Format="rgba16" Width="8" Height="8" Offset="0x25B8" /> <!-- unused duplicate of gGaroMasterEyeTex --> + <Texture Name="gGaroMasterSwordTex" OutName="garo_master_sword" Format="rgba16" Width="4" Height="4" Offset="0x2638" /> + <Texture Name="gGaroMasterRobeTex" OutName="garo_master_robe" Format="rgba16" Width="8" Height="32" Offset="0x2658" /> + <Texture Name="gGaroMasterClothingTLUT" OutName="garo_master_clothing_tlut" Format="rgba16" Width="16" Height="16" Offset="0x2858" /> + <Texture Name="gGaroMasterMaskTLUT" OutName="garo_master_mask_tlut" Format="rgba16" Width="16" Height="16" Offset="0x2A58" /> + <Texture Name="gGaroMasterClothingTex" OutName="garo_master_clothing" Format="ci8" Width="16" Height="16" Offset="0x2C58" /> + <Texture Name="gGaroMasterMaskTex" OutName="garo_master_mask" Format="ci8" Width="16" Height="16" Offset="0x2D58" /> + + <!-- Garo Master Eyes Texture and DisplayList --> + <DList Name="gGaroMasterEyesDL" Offset="0x2ED8" /> + <Texture Name="gGaroMasterEyeTex" OutName="garo_master_eye" Format="rgba16" Width="8" Height="8" Offset="0x2FB8" /> + + <!-- Garo Master Limbs --> + <Limb Name="gGaroMasterRootLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_ROOT" Offset="0x3038" /> + <Limb Name="gGaroMasterTorsoLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_TORSO" Offset="0x3044" /> + <Limb Name="gGaroMasterLeftArmLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_LEFT_ARM" Offset="0x3050" /> <!-- Renders a single triangle instead of a normal-looking limb --> + <Limb Name="gGaroMasterLeftSwordLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_LEFT_SWORD" Offset="0x305C" /> + <Limb Name="gGaroMasterRightArmLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_RIGHT_ARM" Offset="0x3068" /> <!-- Renders a single triangle instead of a normal-looking limb --> + <Limb Name="gGaroMasterRightSwordLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_RIGHT_SWORD" Offset="0x3074" /> + <Limb Name="gGaroMasterRobeTopLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_ROBE_TOP" Offset="0x3080" /> + <Limb Name="gGaroMasterRobeBackLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_ROBE_BACK" Offset="0x308C" /> + <Limb Name="gGaroMasterRobeLeftLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_ROBE_LEFT" Offset="0x3098" /> + <Limb Name="gGaroMasterRobeRightLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_ROBE_RIGHT" Offset="0x30A4" /> + <Limb Name="gGaroMasterRobeFrontLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_ROBE_FRONT" Offset="0x30B0" /> + <Limb Name="gGaroMasterHeadLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_HEAD" Offset="0x30BC" /> + <Limb Name="gGaroMasterLowerBodyRootLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_LOWER_BODY_ROOT" Offset="0x30C8" /> + <Limb Name="gGaroMasterRightThighLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_RIGHT_THIGH" Offset="0x30D4" /> + <Limb Name="gGaroMasterRightShinLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_RIGHT_SHIN" Offset="0x30E0" /> + <Limb Name="gGaroMasterRightFootLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_RIGHT_FOOT" Offset="0x30EC" /> + <Limb Name="gGaroMasterLeftThighLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_LEFT_THIGH" Offset="0x30F8" /> + <Limb Name="gGaroMasterLeftShinLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_LEFT_SHIN" Offset="0x3104" /> + <Limb Name="gGaroMasterLeftFootLimb" Type="Standard" EnumName="GARO_MASTER_LIMB_LEFT_FOOT" Offset="0x3110" /> + + <!-- Garo Master Skeleton --> + <Skeleton Name="gGaroMasterSkel" Type="Flex" LimbType="Standard" LimbNone="GARO_MASTER_LIMB_NONE" LimbMax="GARO_MASTER_LIMB_MAX" EnumName="GaroMasterLimb" Offset="0x3168" /> + + <!-- Garo and Garo Master Animations --> + <Animation Name="gGaroStaticJumpPoseAnim" Offset="0x3238" /> <!-- Unused, one-frame long animation of the Garo jumping or falling. Original name is "jsk_pose" --> + <Animation Name="gGaroDashAttackAnim" Offset="0x3530" /> <!-- Original name is "jso_attack1" --> + <Animation Name="gGaroSlashStartAnim" Offset="0x378C" /> <!-- Original name is "jso_attack2" --> + <Animation Name="gGaroSlashLoopAnim" Offset="0x38AC" /> <!-- Original name is "jso_attack_wait" --> + <Animation Name="gGaroJumpBackAnim" Offset="0x3D5C" /> <!-- Original name is "jso_back" --> + <Animation Name="gGaroTakeOutBombAnim" Offset="0x4018" /> <!-- Original name is "jso_bomb" --> + <Animation Name="gGaroLandAnim" Offset="0x4384" /> <!-- Original name is "jso_chakuchiD" ("chakuchi" = "landing", "D" is probably short for "demo") --> + <Animation Name="gGaroDamagedAnim" Offset="0x44F8" /> <!-- Original name is "jso_damage" --> + <Animation Name="gGaroGuardAnim" Offset="0x4858" /> <!-- Original name is "jso_defense" --> + <Animation Name="gGaroAppearAndDrawSwordsAnim" Offset="0x5778" /> <!-- Original name is "jso_demo_start" --> + <Animation Name="gGaroFallDownAnim" Offset="0x5D5C" /> <!-- Original name is "jso_down" --> + <Animation Name="gGaroKnockedBackAnim" Offset="0x603C" /> <!-- Original name is "jso_hajiku" ("repelled" or "bounced back") --> + <Animation Name="gGaroTrembleAnim" Offset="0x63A4" /> <!-- Original name is "jso_henahena" (onomatopoeic for "weakly; helplessly") --> + <Animation Name="gGaroCollapseAnim" Offset="0x67F0" /> <!-- Original name is "jso_hetari" ("to sink down to the floor") --> + <Animation Name="gGaroDrawSwordsAnim" Offset="0x70BC" /> <!-- Original name is "jso_jakin" (possibly onomatopoeic for drawing a sword from a sheath) --> + <Animation Name="gGaroJumpDownAnim" Offset="0x71E0" /> <!-- Original name is "jso_jumpD" --> + <Animation Name="gGaroSpinAttackAnim" Offset="0x72AC" /> <!-- Original name is "jso_kaiten" ("rotation; turn; spin") --> + <Animation Name="gGaroLookAroundAnim" Offset="0x788C" /> <!-- Original name is "jso_kyoro" (onomatopoeic for "looking around restlessly") --> + <Animation Name="gGaroCowerAnim" Offset="0x7B04" /> <!-- Original name is "jso_ororo" (possibly onomatopoeic for "in a panic; helplessly" or "sobbing; tearfully") --> + <Animation Name="gGaroAppearAnim" Offset="0x81F4" /> <!-- Original name is "jso_start" --> + + <!-- Garo Limb DisplayLists --> + <DList Name="gGaroLeftThighDL" Offset="0x8F50" /> + <DList Name="gGaroLeftShinDL" Offset="0x9008" /> + <DList Name="gGaroLeftFootDL" Offset="0x90C0" /> + <DList Name="gGaroRightThighDL" Offset="0x9190" /> + <DList Name="gGaroRightShinDL" Offset="0x9248" /> + <DList Name="gGaroRightFootDL" Offset="0x9300" /> + <DList Name="gGaroTorsoDL" Offset="0x93D0" /> <!-- Renders a single triangle instead of a normal-looking limb --> + <DList Name="gGaroHeadDL" Offset="0x9428" /> + <DList Name="gGaroRobeTopDL" Offset="0x94E0" /> + <DList Name="gGaroRobeFrontDL" Offset="0x9758" /> + <DList Name="gGaroRobeRightDL" Offset="0x98C8" /> + <DList Name="gGaroRobeLeftDL" Offset="0x99B8" /> + <DList Name="gGaroRobeBackDL" Offset="0x9AA8" /> + <DList Name="gGaroRightArmDL" Offset="0x9B80" /> <!-- Renders a single triangle instead of a normal-looking limb --> + <DList Name="gGaroRightSwordDL" Offset="0x9BD8" /> + <DList Name="gGaroLeftArmDL" Offset="0x9C98" /> <!-- Renders a single triangle instead of a normal-looking limb --> + <DList Name="gGaroLeftSwordDL" Offset="0x9CF0" /> + + <!-- Garo Textures --> + <Texture Name="gGaroLegWrappingTex" OutName="garo_leg_wrapping" Format="rgba16" Width="8" Height="16" Offset="0x9DB0" /> + <Texture Name="gGaroThighTex" OutName="garo_thigh" Format="rgba16" Width="8" Height="8" Offset="0x9EB0" /> + <Texture Name="gGaroRobeFrontTex" OutName="garo_robe_front" Format="rgba16" Width="16" Height="32" Offset="0x9F30" /> + <Texture Name="gGaroRobeTex" OutName="garo_robe" Format="rgba16" Width="16" Height="16" Offset="0xA330" /> + <Texture Name="gGaroRobeStitchingTex" OutName="garo_robe_stitching" Format="rgba16" Width="16" Height="8" Offset="0xA530" /> + <Texture Name="gGaroRobeTopTex" OutName="garo_robe_top" Format="rgba16" Width="8" Height="8" Offset="0xA630" /> + <Texture Name="gGaroEyesTex" OutName="garo_eyes" Format="rgba16" Width="16" Height="16" Offset="0xA6B0" /> + <Texture Name="gGaroSwordTex" OutName="garo_sword" Format="rgba16" Width="4" Height="4" Offset="0xA8B0" /> + + <!-- Garo Limbs --> + <Limb Name="gGaroRootLimb" Type="Standard" EnumName="GARO_LIMB_ROOT" Offset="0xA8D0" /> + <Limb Name="gGaroTorsoLimb" Type="Standard" EnumName="GARO_LIMB_TORSO" Offset="0xA8DC" /> + <Limb Name="gGaroLeftArmLimb" Type="Standard" EnumName="GARO_LIMB_LEFT_ARM" Offset="0xA8E8" /> + <Limb Name="gGaroLeftSwordLimb" Type="Standard" EnumName="GARO_LIMB_LEFT_SWORD" Offset="0xA8F4" /> + <Limb Name="gGaroRightArmLimb" Type="Standard" EnumName="GARO_LIMB_RIGHT_ARM" Offset="0xA900" /> + <Limb Name="gGaroRightSwordLimb" Type="Standard" EnumName="GARO_LIMB_RIGHT_SWORD" Offset="0xA90C" /> + <Limb Name="gGaroRobeTopLimb" Type="Standard" EnumName="GARO_LIMB_ROBE_TOP" Offset="0xA918" /> + <Limb Name="gGaroRobeBackLimb" Type="Standard" EnumName="GARO_LIMB_ROBE_BACK" Offset="0xA924" /> + <Limb Name="gGaroRobeLeftLimb" Type="Standard" EnumName="GARO_LIMB_ROBE_LEFT" Offset="0xA930" /> + <Limb Name="gGaroRobeRightLimb" Type="Standard" EnumName="GARO_LIMB_ROBE_RIGHT" Offset="0xA93C" /> + <Limb Name="gGaroRobeFrontLimb" Type="Standard" EnumName="GARO_LIMB_ROBE_FRONT" Offset="0xA948" /> + <Limb Name="gGaroHeadLimb" Type="Standard" EnumName="GARO_LIMB_HEAD" Offset="0xA954" /> + <Limb Name="gGaroLowerBodyRootLimb" Type="Standard" EnumName="GARO_LIMB_LOWER_BODY_ROOT" Offset="0xA960" /> + <Limb Name="gGaroRightThighLimb" Type="Standard" EnumName="GARO_LIMB_RIGHT_THIGH" Offset="0xA96C" /> + <Limb Name="gGaroRightShinLimb" Type="Standard" EnumName="GARO_LIMB_RIGHT_SHIN" Offset="0xA978" /> + <Limb Name="gGaroRightFootLimb" Type="Standard" EnumName="GARO_LIMB_RIGHT_FOOT" Offset="0xA984" /> + <Limb Name="gGaroLeftThighLimb" Type="Standard" EnumName="GARO_LIMB_LEFT_THIGH" Offset="0xA990" /> + <Limb Name="gGaroLeftShinLimb" Type="Standard" EnumName="GARO_LIMB_LEFT_SHIN" Offset="0xA99C" /> + <Limb Name="gGaroLeftFootLimb" Type="Standard" EnumName="GARO_LIMB_LEFT_FOOT" Offset="0xA9A8" /> + + <!-- Garo Skeleton --> + <Skeleton Name="gGaroSkel" Type="Flex" LimbType="Standard" LimbNone="GARO_LIMB_NONE" LimbMax="GARO_LIMB_MAX" EnumName="GaroLimb" Offset="0xAA00" /> + + <!-- Garo and Garo Master Animations --> + <Animation Name="gGaroIdleAnim" Offset="0xAE80" /> <!-- Original name is "jso_wait" --> + <Animation Name="gGaroLaughAnim" Offset="0xB1DC" /> <!-- Original name is "jso_waitD" --> + <Animation Name="gGaroBounceAnim" Offset="0xB5F0" /> <!-- Original name is "jso_walk" --> </File> </Root> diff --git a/include/z64math.h b/include/z64math.h index 6fa64f4f4..4a4d15b98 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -40,6 +40,11 @@ typedef struct { } Vec3i; // size = 0xC typedef struct { + /* 0x0 */ f32 distance; + /* 0x4 */ s16 angle; +} VecPolar; // size = 0x8 + +typedef struct { /* 0x0 */ Vec3s center; /* 0x6 */ s16 radius; } Sphere16; // size = 0x8 @@ -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 diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c index a8eea2641..df6245c68 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -69,7 +69,7 @@ void BgIcicle_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_icicle_Colheader_000294); + DynaPolyActor_LoadMesh(play, &this->dyna, &gIcicleCol); Collider_InitAndSetCylinder(play, &this->collider, thisx, &sCylinderInit); Collider_UpdateCylinder(thisx, &this->collider); @@ -242,5 +242,5 @@ void BgIcicle_Update(Actor* thisx, PlayState* play) { } void BgIcicle_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, object_icicle_DL_0000D0); + Gfx_DrawDListOpa(play, gIcicleDL); } diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index e95f971c9..a1ce45b82 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -1,7 +1,9 @@ /* * File: z_obj_grass.c * Overlay: ovl_Obj_Grass - * Description: "Master" instance of grass for unit spawned by Obj_Grass_Unit + * Description: Optimized manager for processing grass "spawned" by ObjGrassUnit + * + * Instances of ObjGrass must be spawned by ObjGrassUnit to function correctly. */ #include "prevent_bss_reordering.h" @@ -18,10 +20,10 @@ void ObjGrass_Destroy(Actor* thisx, PlayState* play); void ObjGrass_Update(Actor* thisx, PlayState* play); void ObjGrass_Draw(Actor* thisx, PlayState* play); -ObjGrassStruct1* D_809AADA0[4]; -f32 D_809AADB0[4]; -ObjGrassStruct1_1* D_809AADC0[20]; -f32 D_809AAE10[20]; +ObjGrassGroup* sNearestGrassGroups[OBJ_GRASS_NEAREST_GROUP_MAX]; +f32 sNearestGrassGroupsDist[OBJ_GRASS_NEAREST_GROUP_MAX]; +ObjGrassElement* sNearestGrassElements[OBJ_GRASS_NEAREST_ELEM_MAX]; +f32 sNearestGrassElementsDistSq[OBJ_GRASS_NEAREST_ELEM_MAX]; #include "overlays/ovl_Obj_Grass/ovl_Obj_Grass.c" @@ -57,35 +59,35 @@ static ColliderCylinderInit sCylinderInit = { { 6, 44, 0, { 0, 0, 0 } }, }; -Vec3f D_809AAB4C[] = { - { 0.0f, 0.707099974155f, 0.707099974155f }, - { 0.707099974155f, 0.707099974155f, 0.0f }, - { 0.0f, 0.707099974155f, -0.707099974155f }, - { -0.707099974155f, 0.707099974155f, 0.0f }, +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_809AAB7C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; +static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; -s32 func_809A9110(PlayState* play, Vec3f* arg1) { - f32 sp2C; - Vec3f sp20; +s32 func_809A9110(PlayState* play, Vec3f* pos) { + f32 w; + Vec3f projectedPos; - SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg1, &sp20, &sp2C); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, pos, &projectedPos, &w); - if ((play->projectionMtxFDiagonal.z * -130.13191f) < sp20.z) { - if (sp2C < 1.0f) { - sp2C = 1.0f; + if ((play->projectionMtxFDiagonal.z * -130.13191f) < projectedPos.z) { + if (w < 1.0f) { + w = 1.0f; } - if (((fabsf(sp20.x) - (130.13191f * play->projectionMtxFDiagonal.x)) < sp2C) && - ((fabsf(sp20.y) - (130.13191f * play->projectionMtxFDiagonal.y)) < sp2C)) { + if (((fabsf(projectedPos.x) - (130.13191f * play->projectionMtxFDiagonal.x)) < w) && + ((fabsf(projectedPos.y) - (130.13191f * play->projectionMtxFDiagonal.y)) < w)) { return true; } } return false; } -void func_809A91FC(MtxF* matrix) { +void ObjGrass_OverrideMatrixCurrent(MtxF* matrix) { s32 i; MtxF* temp = Matrix_GetCurrent(); f32* tmp = &temp->xx; @@ -96,42 +98,44 @@ void func_809A91FC(MtxF* matrix) { } } -void func_809A92D0(ObjGrassStruct1_1* ptr, PlayState* play) { - if (!(ptr->unk_0E & 0x10)) { - Item_DropCollectibleRandom(play, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); +void ObjGrass_DropCollectible(ObjGrassElement* grassElem, PlayState* play) { + if (!(grassElem->dropTable & 0x10)) { + Item_DropCollectibleRandom(play, NULL, &grassElem->pos, grassElem->dropTable * 0x10); } } -void func_809A9314(ObjGrassStruct1_1* ptr, PlayState* play) { - Vec3f spBC; - Vec3f spB0; +void ObjGrass_SpawnFragments(Vec3f* basePos, PlayState* play) { + Vec3f velocity; + Vec3f pos; s32 i; - Vec3f* ptr2; + Vec3f* dir; - for (i = 0; i < ARRAY_COUNT(D_809AAB4C); i++) { - ptr2 = &D_809AAB4C[i]; + for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { + dir = &sUnitDirections[i]; - spB0.x = ptr->unk_00.x + (ptr2->x * 8.0f); - spB0.y = (ptr->unk_00.y + (ptr2->y * 8.0f)) + 10.0f; - spB0.z = ptr->unk_00.z + (ptr2->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_809AAB7C[(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 = ptr->unk_00.x + (ptr2->x * 16.0f); - spB0.y = (ptr->unk_00.y + (ptr2->y * 16.0f)) + 10.0f; - spB0.z = ptr->unk_00.z + (ptr2->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_809AAB7C[(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); } } @@ -141,9 +145,9 @@ void ObjGrass_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.4f); - for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { - Collider_InitCylinder(play, &this->unk_2948[i].collider); - Collider_SetCylinder(play, &this->unk_2948[i].collider, &this->actor, &sCylinderInit); + for (i = 0; i < ARRAY_COUNT(this->grassElemColliders); i++) { + Collider_InitCylinder(play, &this->grassElemColliders[i].collider); + Collider_SetCylinder(play, &this->grassElemColliders[i].collider, &this->actor, &sCylinderInit); } this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -158,117 +162,121 @@ void ObjGrass_Destroy(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { - Collider_DestroyCylinder(play, &this->unk_2948[i].collider); + for (i = 0; i < ARRAY_COUNT(this->grassElemColliders); i++) { + Collider_DestroyCylinder(play, &this->grassElemColliders[i].collider); } - for (i = 0; i < ARRAY_COUNT(this->unk_3298); i++) { - ObjGrassCarry** ptr = &this->unk_3298[i]; + for (i = 0; i < ARRAY_COUNT(this->grassCarry); i++) { + ObjGrassCarry** grassCarry = &this->grassCarry[i]; - if (*ptr != NULL) { - (*ptr)->unk_190 = 0; - *ptr = NULL; + if (*grassCarry != NULL) { + (*grassCarry)->grassManager = NULL; + *grassCarry = NULL; } } } -void func_809A9790(ObjGrass* this, PlayState* play) { +void ObjGrass_ProcessColliders(ObjGrass* this, PlayState* play) { s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { - ObjGrassStruct1_1* ptr = this->unk_2948[i].unk_4C; + for (i = 0; i < ARRAY_COUNT(this->grassElemColliders); i++) { + ObjGrassElement* grassElem = this->grassElemColliders[i].entity; - if ((ptr != NULL) && (this->unk_2948[i].collider.base.acFlags & AC_HIT)) { - func_809A9314(ptr, play); - func_809A92D0(ptr, play); - ptr->unk_0F |= 4; - SoundSource_PlaySfxAtFixedWorldPos(play, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); + if ((grassElem != NULL) && (this->grassElemColliders[i].collider.base.acFlags & AC_HIT)) { + ObjGrass_SpawnFragments(&grassElem->pos, play); + ObjGrass_DropCollectible(grassElem, play); + grassElem->flags |= OBJ_GRASS_ELEM_REMOVED; + SoundSource_PlaySfxAtFixedWorldPos(play, &grassElem->pos, 20, NA_SE_EV_PLANT_BROKEN); } } } -void func_809A983C(ObjGrass* this, PlayState* play) { +void ObjGrass_UpdateGrass(ObjGrass* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 i; s32 j; s32 x; s32 y; - f32 temp_f0; - ObjGrassStruct1* ptr; - ObjGrassStruct1_1* ptr2; - ObjGrassStruct2* ptr3; + f32 distSq; + ObjGrassGroup* grassGroup; s16 yaw; - for (i = 0; i < ARRAY_COUNT(D_809AADC0); i++) { - D_809AADC0[i] = NULL; - D_809AAE10[i] = 422500.0f; + for (i = 0; i < OBJ_GRASS_NEAREST_ELEM_MAX; i++) { + sNearestGrassElements[i] = NULL; + sNearestGrassElementsDistSq[i] = SQ(650.0f); } - for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { - D_809AADA0[i] = NULL; - D_809AADB0[i] = 422500.0f; + for (i = 0; i < OBJ_GRASS_NEAREST_GROUP_MAX; i++) { + sNearestGrassGroups[i] = NULL; + sNearestGrassGroupsDist[i] = SQ(650.0f); } - for (i = 0; i < this->unk_2944; i++) { - ptr = &this->unk_144[i]; + for (i = 0; i < this->activeGrassGroups; i++) { + grassGroup = &this->grassGroups[i]; - for (j = 0; j < ptr->unk_FC; j++) { - ptr->unk_0C[j].unk_0F &= (u16)~2; + for (j = 0; j < grassGroup->count; j++) { + grassGroup->elements[j].flags &= (u16)~OBJ_GRASS_ELEM_ANIM; } } - for (i = 0; i < this->unk_2944; i++) { - ptr = &this->unk_144[i]; - temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_00, &player->actor.world.pos); + for (i = 0; i < this->activeGrassGroups; i++) { + grassGroup = &this->grassGroups[i]; + distSq = Math3D_Vec3fDistSq(&grassGroup->homePos, &player->actor.world.pos); - for (j = 0; j < ARRAY_COUNT(D_809AADB0); j++) { - if (temp_f0 < D_809AADB0[j]) { + for (j = 0; j < OBJ_GRASS_NEAREST_GROUP_MAX; j++) { + if (distSq < sNearestGrassGroupsDist[j]) { break; } } - if (j < ARRAY_COUNT(D_809AADB0)) { - for (x = 2; x >= j; x--) { - D_809AADB0[x + 1] = D_809AADB0[x]; - D_809AADA0[x + 1] = D_809AADA0[x]; + if (j < OBJ_GRASS_NEAREST_GROUP_MAX) { + // Insert the grassGroup into the list + + // Shift each element under j that remains in the list down 1 + for (x = OBJ_GRASS_NEAREST_GROUP_MAX - 2; x >= j; x--) { + sNearestGrassGroupsDist[x + 1] = sNearestGrassGroupsDist[x]; + sNearestGrassGroups[x + 1] = sNearestGrassGroups[x]; } - D_809AADB0[j] = temp_f0; - D_809AADA0[j] = ptr; + sNearestGrassGroupsDist[j] = distSq; + sNearestGrassGroups[j] = grassGroup; } } - this->unk_3294 = NULL; + this->carryGrassElem = NULL; - for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { - ptr = D_809AADA0[i]; + for (i = 0; i < OBJ_GRASS_NEAREST_GROUP_MAX; i++) { + grassGroup = sNearestGrassGroups[i]; - if (ptr != NULL) { - for (j = 0; j < ptr->unk_FC; j++) { - if (!(ptr->unk_0C[j].unk_0F & 4)) { - temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_0C[j].unk_00, &player->actor.world.pos); + if (grassGroup != NULL) { + for (j = 0; j < grassGroup->count; j++) { + if (!(grassGroup->elements[j].flags & OBJ_GRASS_ELEM_REMOVED)) { + distSq = Math3D_Vec3fDistSq(&grassGroup->elements[j].pos, &player->actor.world.pos); - for (x = 0; x < ARRAY_COUNT(D_809AAE10); x++) { - if (temp_f0 < D_809AAE10[x]) { + for (x = 0; x < OBJ_GRASS_NEAREST_ELEM_MAX; x++) { + if (distSq < sNearestGrassElementsDistSq[x]) { break; } } - if (x < ARRAY_COUNT(D_809AAE10)) { - for (y = 18; y >= x; y--) { - D_809AAE10[y + 1] = D_809AAE10[y]; - D_809AADC0[y + 1] = D_809AADC0[y]; + if (x < OBJ_GRASS_NEAREST_ELEM_MAX) { + // Insert the GrassElement into the list + + // Shift each element under j that remains in the list down 1 + for (y = OBJ_GRASS_NEAREST_ELEM_MAX - 2; y >= x; y--) { + sNearestGrassElementsDistSq[y + 1] = sNearestGrassElementsDistSq[y]; + sNearestGrassElements[y + 1] = sNearestGrassElements[y]; } - D_809AAE10[x] = temp_f0; - D_809AADC0[x] = &ptr->unk_0C[j]; + sNearestGrassElementsDistSq[x] = distSq; + sNearestGrassElements[x] = &grassGroup->elements[j]; - if (temp_f0 < 2500.0f) { + if (distSq < SQ(50.0f)) { yaw = player->actor.shape.rot.y - - Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); + Math_Vec3f_Yaw(&player->actor.world.pos, &grassGroup->elements[j].pos); if (ABS_ALT(yaw) < 0x2000) { - this->unk_3294 = &ptr->unk_0C[j]; + this->carryGrassElem = &grassGroup->elements[j]; } } } @@ -277,28 +285,29 @@ void func_809A983C(ObjGrass* this, PlayState* play) { } } - for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { - ptr3 = &this->unk_2948[i]; - - ptr3->collider.base.acFlags &= (u16)~AC_HIT; - ptr3->collider.base.ocFlags1 &= (u16)~OC1_HIT; - - ptr2 = D_809AADC0[i]; - if (ptr2 != NULL) { - ptr3->collider.dim.pos.x = ptr2->unk_00.x; - ptr3->collider.dim.pos.y = ptr2->unk_00.y; - ptr3->collider.dim.pos.z = ptr2->unk_00.z; - CollisionCheck_SetAC(play, &play->colChkCtx, &ptr3->collider.base); - CollisionCheck_SetOC(play, &play->colChkCtx, &ptr3->collider.base); - ptr2->unk_0F |= 2; - ptr3->unk_4C = ptr2; + for (i = 0; i < ARRAY_COUNT(this->grassElemColliders); i++) { + ObjGrassCollider* grassCol = &this->grassElemColliders[i]; + ObjGrassElement* grassElem; + + grassCol->collider.base.acFlags &= (u16)~AC_HIT; + grassCol->collider.base.ocFlags1 &= (u16)~OC1_HIT; + + grassElem = sNearestGrassElements[i]; + if (grassElem != NULL) { + grassCol->collider.dim.pos.x = grassElem->pos.x; + grassCol->collider.dim.pos.y = grassElem->pos.y; + grassCol->collider.dim.pos.z = grassElem->pos.z; + CollisionCheck_SetAC(play, &play->colChkCtx, &grassCol->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &grassCol->collider.base); + grassElem->flags |= OBJ_GRASS_ELEM_ANIM; + grassCol->entity = grassElem; } else { - ptr3->unk_4C = NULL; + grassCol->entity = NULL; } } } -void func_809A9DB8(ObjGrass* this) { +void ObjGrass_CalcAnimationMatrices(ObjGrass* this) { s32 i; s32 pad; f32* ptr; @@ -345,8 +354,8 @@ void func_809A9DB8(ObjGrass* this) { sp6C[6] = (temp_f26 - temp_f22) * temp_f22 * temp_f20 * temp_f16 * 0.0015f; sp6C[7] = (spA4 - temp_f20) * sp94 * sp90 * temp_f16 * 0.0015f; - for (i = 0; i < ARRAY_COUNT(this->unk_2F88); i++) { - ptr = &this->unk_2F88[i].mf[0][0]; + for (i = 0; i < ARRAY_COUNT(this->distortionMtx); i++) { + ptr = &this->distortionMtx[i].mf[0][0]; tempf1 = sp6C[(i + 0) & 7]; tempf2 = sp6C[(i + 1) & 7]; @@ -379,64 +388,65 @@ void func_809A9DB8(ObjGrass* this) { void ObjGrass_Update(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; - func_809A9790(this, play); - func_809A983C(this, play); - func_809A9DB8(this); + ObjGrass_ProcessColliders(this, play); + ObjGrass_UpdateGrass(this, play); + ObjGrass_CalcAnimationMatrices(this); } -void func_809AA278(ObjGrass* this, PlayState* play) { - ObjGrassStruct1* ptr; - ObjGrassStruct1_1* ptr2; +void ObjGrass_InitDraw(ObjGrass* this, PlayState* play) { + ObjGrassGroup* grassGroup; + ObjGrassElement* grassElem; s32 i; s32 j; f32 distSq; - f32 temp_f22; + f32 eyeDist; - for (i = 0; i < this->unk_2944; i++) { - ptr = &this->unk_144[i]; + for (i = 0; i < this->activeGrassGroups; i++) { + grassGroup = &this->grassGroups[i]; - temp_f22 = Math3D_Vec3fDistSq(&ptr->unk_00, &GET_ACTIVE_CAM(play)->eye); + eyeDist = Math3D_Vec3fDistSq(&grassGroup->homePos, &GET_ACTIVE_CAM(play)->eye); - if ((temp_f22 < SQ(1280.0f)) && func_809A9110(play, &ptr->unk_00)) { - ptr->unk_FE |= 1; + if ((eyeDist < SQ(1280.0f)) && func_809A9110(play, &grassGroup->homePos)) { + grassGroup->flags |= OBJ_GRASS_GROUP_DRAW; - for (j = 0; j < ptr->unk_FC; j++) { - ptr2 = &ptr->unk_0C[j]; + for (j = 0; j < grassGroup->count; j++) { + grassElem = &grassGroup->elements[j]; - if (ptr2->unk_0F & 4) { - ptr2->unk_10 = 255; - ptr2->unk_0F &= ~1; + if (grassElem->flags & OBJ_GRASS_ELEM_REMOVED) { + grassElem->alpha = 255; + grassElem->flags &= ~OBJ_GRASS_ELEM_DRAW; } else { - ptr2->unk_0F |= 1; - if (temp_f22 < SQ(980.0f)) { - ptr2->unk_10 = 255; + grassElem->flags |= OBJ_GRASS_ELEM_DRAW; + if (eyeDist < SQ(980.0f)) { + grassElem->alpha = 255; } else { - distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(play)->eye); - if ((distSq <= SQ(1080.0f)) || ((ptr2->unk_0F & 8) && (distSq < SQ(1180.0f)))) { - ptr2->unk_10 = 255; + distSq = Math3D_Vec3fDistSq(&grassElem->pos, &GET_ACTIVE_CAM(play)->eye); + if ((distSq <= SQ(1080.0f)) || + ((grassElem->flags & OBJ_GRASS_ELEM_UNDERWATER) && (distSq < SQ(1180.0f)))) { + grassElem->alpha = 255; } else if (distSq >= SQ(1180.0f)) { - ptr2->unk_10 = 0; + grassElem->alpha = 0; } else { - ptr2->unk_10 = (1180.0f - sqrtf(distSq)) * 2.55f; + grassElem->alpha = (1180.0f - sqrtf(distSq)) * 2.55f; } } } } } else { - ptr->unk_FE &= ~1; + grassGroup->flags &= ~OBJ_GRASS_GROUP_DRAW; } } } -void func_809AA54C(Actor* thisx, PlayState* play2) { +void ObjGrass_DrawOpa(Actor* thisx, PlayState* play2) { ObjGrass* this = THIS; PlayState* play = play2; - Lights* temp_s0; - ObjGrassStruct1* ptr; + Lights* lights; + ObjGrassGroup* grassGroup; s32 i; s32 j; - Vec3s sp70 = { 0, 0, 0 }; - ObjGrassStruct1_1* ptr2; + Vec3s rot = { 0, 0, 0 }; + ObjGrassElement* grassElem; OPEN_DISPS(play->state.gfxCtx); @@ -445,23 +455,23 @@ void func_809AA54C(Actor* thisx, PlayState* play2) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AA9F0); - for (i = 0; i < this->unk_2944; i++) { - ptr = &this->unk_144[i]; + for (i = 0; i < this->activeGrassGroups; i++) { + grassGroup = &this->grassGroups[i]; - if (ptr->unk_FE & 1) { - temp_s0 = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); - Lights_BindAll(temp_s0, play->lightCtx.listHead, &ptr->unk_00, play); - Lights_Draw(temp_s0, play->state.gfxCtx); + if (grassGroup->flags & OBJ_GRASS_GROUP_DRAW) { + lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); + Lights_BindAll(lights, play->lightCtx.listHead, &grassGroup->homePos, play); + Lights_Draw(lights, play->state.gfxCtx); - for (j = 0; j < ptr->unk_FC; j++) { - ptr2 = &ptr->unk_0C[j]; + for (j = 0; j < grassGroup->count; j++) { + grassElem = &grassGroup->elements[j]; - if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { - sp70.y = ptr2->unk_0C; - Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + if ((grassElem->flags & OBJ_GRASS_ELEM_DRAW) && (grassElem->alpha == 255)) { + rot.y = grassElem->rotY; + Matrix_SetTranslateRotateYXZ(grassElem->pos.x, grassElem->pos.y, grassElem->pos.z, &rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (ptr2->unk_0F & 2) { - func_809A91FC(&this->unk_2F88[j]); + if (grassElem->flags & OBJ_GRASS_ELEM_ANIM) { + ObjGrass_OverrideMatrixCurrent(&this->distortionMtx[j]); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), @@ -475,13 +485,13 @@ void func_809AA54C(Actor* thisx, PlayState* play2) { CLOSE_DISPS(play->state.gfxCtx); } -void func_809AA798(Actor* thisx, PlayState* play) { +void ObjGrass_DrawXlu(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; - ObjGrassStruct1* ptr; - ObjGrassStruct1_1* ptr2; + ObjGrassGroup* grassGroup; + ObjGrassElement* grassElem; s32 i; s32 j; - Vec3s sp6C = { 0, 0, 0 }; + Vec3s rot = { 0, 0, 0 }; OPEN_DISPS(play->state.gfxCtx); @@ -489,21 +499,21 @@ void func_809AA798(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAA68); - for (i = 0; i < this->unk_2944; i++) { - ptr = &this->unk_144[i]; + for (i = 0; i < this->activeGrassGroups; i++) { + grassGroup = &this->grassGroups[i]; - if (ptr->unk_FE & 1) { - for (j = 0; j < ptr->unk_FC; j++) { - ptr2 = &ptr->unk_0C[j]; + if (grassGroup->flags & OBJ_GRASS_GROUP_DRAW) { + for (j = 0; j < grassGroup->count; j++) { + grassElem = &grassGroup->elements[j]; - if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { - sp6C.y = ptr2->unk_0C; - Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + if ((grassElem->flags & OBJ_GRASS_ELEM_DRAW) && (grassElem->alpha > 0) && (grassElem->alpha < 255)) { + rot.y = grassElem->rotY; + Matrix_SetTranslateRotateYXZ(grassElem->pos.x, grassElem->pos.y, grassElem->pos.z, &rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr2->unk_10); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, grassElem->alpha); gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAAE0); } } @@ -516,7 +526,7 @@ void func_809AA798(Actor* thisx, PlayState* play) { void ObjGrass_Draw(Actor* thisx, PlayState* play) { ObjGrass* this = THIS; - func_809AA278(this, play); - func_809AA54C(thisx, play); - func_809AA798(thisx, play); + ObjGrass_InitDraw(this, play); + ObjGrass_DrawOpa(thisx, play); + ObjGrass_DrawXlu(thisx, play); } diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index fffcdad4e..f3fb8705d 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -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 diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 1554a2403..4b9c424f4 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -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); } diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index fa870305e..3f20ea1c1 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -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 diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c index c57ed608f..dfb5d0527 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.c @@ -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 }, +}; + +// "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 }, +}; + +typedef struct { + /* 0x0 */ s32 count; + /* 0x4 */ VecPolar* positions; +} ObjGrassUnitPattern; // size = 0x8 + +static ObjGrassUnitPattern sGrassPatterns[2] = { + { ARRAY_COUNT(sGrassPatternCircle), sGrassPatternCircle }, + { ARRAY_COUNT(sGrassPatternMixed), sGrassPatternMixed }, +}; + +ObjGrass* sGrassManager = NULL; +ObjGrassCarry* sGrassCarry0 = NULL; +ObjGrassCarry* sGrassCarry1 = NULL; +s32 sInitialized = false; + +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; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABDE0.s") + grassManager = sGrassManager; + if (sGrassManager->activeGrassGroups >= ARRAY_COUNT(sGrassManager->grassGroups)) { + Actor_Kill(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABE54.s") + homePosYSum = 0.0f; + grassGroup = &grassManager->grassGroups[sGrassManager->activeGrassGroups]; + grassGroup->count = 0; + grassPattern = &sGrassPatterns[OBJGRASSUNIT_GET_PATTERN(this)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABEC4.s") + for (i = 0; i < grassPattern->count; i++) { + grassElem = &grassGroup->elements[grassGroup->count]; + grassPos = &grassPattern->positions[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/func_809ABF38.s") + 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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Unit/ObjGrassUnit_Init.s") + 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); +} diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h index 58a8a427a..7c24d1e58 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h @@ -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 { |
