Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colliders: elemType -> elemMaterial #2189

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions include/z64collision_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,21 @@ typedef struct ColliderElementDamageInfoACInit {
/* 0x05 */ u8 defense; // Damage Resistance
} ColliderElementDamageInfoACInit; // size = 0x08

/**
* Affects the sound Link's sword makes when hitting it, hookability,
* and possibly other things. It's definitely not flags, as all checks
* are == or !=. Will probably need more actors decomped to truly
* understand what this is.
*/
typedef enum ElementType {
/* 0 */ ELEMTYPE_UNK0,
/* 1 */ ELEMTYPE_UNK1,
/* 2 */ ELEMTYPE_UNK2,
/* 3 */ ELEMTYPE_UNK3,
/* 4 */ ELEMTYPE_UNK4,
/* 5 */ ELEMTYPE_UNK5,
/* 6 */ ELEMTYPE_UNK6,
/* 7 */ ELEMTYPE_UNK7
} ElementType;
typedef enum ElementMaterial {
/* 0 */ ELEM_MATERIAL_UNK0,
/* 1 */ ELEM_MATERIAL_UNK1,
/* 2 */ ELEM_MATERIAL_UNK2,
/* 3 */ ELEM_MATERIAL_UNK3,
/* 4 */ ELEM_MATERIAL_UNK4,
/* 5 */ ELEM_MATERIAL_UNK5,
/* 6 */ ELEM_MATERIAL_UNK6,
/* 7 */ ELEM_MATERIAL_UNK7
} ElementMaterial;
Copy link
Contributor

@krm01 krm01 Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed, the structs above this use ColliderElementXXXXXX instead of simply ElementXXXX like this one. should it be consistent? (not that it matters much, this enum name is never referenced afaict 😁 )


typedef struct ColliderElement {
/* 0x00 */ ColliderElementDamageInfoAT atDmgInfo; // Damage properties when acting as an AT collider
/* 0x08 */ ColliderElementDamageInfoAC acDmgInfo; // Damage properties when acting as an AC collider
/* 0x14 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x14 */ u8 elemMaterial; // Affects sfx when attacked by Player, and interaction with hookshot and arrows.
/* 0x15 */ u8 atElemFlags; // Information flags for AT collisions
/* 0x16 */ u8 acElemFlags; // Information flags for AC collisions
/* 0x17 */ u8 ocElemFlags; // Information flags for OC collisions
Expand All @@ -130,7 +124,7 @@ typedef struct ColliderElement {
} ColliderElement; // size = 0x28

typedef struct ColliderElementInit {
/* 0x00 */ u8 elemType; // Affects sfx reaction when attacked by Link and hookability. Full purpose unknown.
/* 0x00 */ u8 elemMaterial; // Affects sfx when attacked by Player, and interaction with hookshot and arrows.
/* 0x04 */ ColliderElementDamageInfoAT atDmgInfo; // Damage properties when acting as an AT collider
/* 0x0C */ ColliderElementDamageInfoACInit acDmgInfo; // Damage properties when acting as an AC collider
/* 0x14 */ u8 atElemFlags; // Information flags for AT collisions
Expand Down
27 changes: 16 additions & 11 deletions src/code/z_collision_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ s32 Collider_SetElementDamageInfoAC(PlayState* play, ColliderElementDamageInfoAC

s32 Collider_InitElement(PlayState* play, ColliderElement* elem) {
static ColliderElement init = {
{ 0, 0, 0 }, { 0xFFCFFFFF, 0, 0, { 0, 0, 0 } },
ELEMTYPE_UNK0, ATELEM_NONE,
ACELEM_NONE, OCELEM_NONE,
NULL, NULL,
NULL, NULL,
{ 0, 0, 0 },
{ 0xFFCFFFFF, 0, 0, { 0, 0, 0 } },
ELEM_MATERIAL_UNK0,
ATELEM_NONE,
ACELEM_NONE,
OCELEM_NONE,
NULL,
NULL,
NULL,
NULL,
};

*elem = init;
Expand All @@ -209,7 +214,7 @@ s32 Collider_DestroyElement(PlayState* play, ColliderElement* elem) {
}

s32 Collider_SetElement(PlayState* play, ColliderElement* elem, ColliderElementInit* elemInit) {
elem->elemType = elemInit->elemType;
elem->elemMaterial = elemInit->elemMaterial;
Collider_SetElementDamageInfoAT(play, &elem->atDmgInfo, &elemInit->atDmgInfo);
Collider_SetElementDamageInfoAC(play, &elem->acDmgInfo, &elemInit->acDmgInfo);
elem->atElemFlags = elemInit->atElemFlags;
Expand Down Expand Up @@ -1584,20 +1589,20 @@ void CollisionCheck_HitSolid(PlayState* play, ColliderElement* elem, Collider* c
}

/**
* Plays a hit sound effect for AT colliders attached to Player based on the AC element's elemType.
* Plays a hit sound effect for AT colliders attached to Player based on the AC element's elemMaterial.
*/
s32 CollisionCheck_SwordHitAudio(Collider* atCol, ColliderElement* acElem) {
if (atCol->actor != NULL && atCol->actor->category == ACTORCAT_PLAYER) {
if (acElem->elemType == ELEMTYPE_UNK0) {
if (acElem->elemMaterial == ELEM_MATERIAL_UNK0) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_STRIKE, &atCol->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else if (acElem->elemType == ELEMTYPE_UNK1) {
} else if (acElem->elemMaterial == ELEM_MATERIAL_UNK1) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_STRIKE_HARD, &atCol->actor->projectedPos, 4,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else if (acElem->elemType == ELEMTYPE_UNK2) {
} else if (acElem->elemMaterial == ELEM_MATERIAL_UNK2) {
Audio_PlaySfxGeneral(NA_SE_NONE, &atCol->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else if (acElem->elemType == ELEMTYPE_UNK3) {
} else if (acElem->elemMaterial == ELEM_MATERIAL_UNK3) {
Audio_PlaySfxGeneral(NA_SE_NONE, &atCol->actor->projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_en_a_keep.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x00000000, 0x00, 0x00 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_en_item00.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000010, 0x00, 0x00 },
ATELEM_NONE | ATELEM_SFX_NORMAL,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static ColliderQuadInit sQuadInit = {
COLSHAPE_QUAD,
},
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x00000080, 0x00, 0x01 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_ON | ATELEM_NEAREST | ATELEM_SFX_NORMAL,
Expand Down Expand Up @@ -150,7 +150,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
ArmsHook_CheckForCancel(this);

if ((this->timer != 0) && (this->collider.base.atFlags & AT_HIT) &&
(this->collider.elem.atHitElem->elemType != ELEMTYPE_UNK4)) {
(this->collider.elem.atHitElem->elemMaterial != ELEM_MATERIAL_UNK4)) {
Actor* touchedActor = this->collider.base.at;

if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_9 | ACTOR_FLAG_10))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0xFFCFFFFF, 0x00, 0x04 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_HARD,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Bdan_Switch/z_bg_bdan_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ActorProfile Bg_Bdan_Switch_Profile = {
static ColliderJntSphElementInit sJntSphElementsInit[] = {
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xEFC1FFFE, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
6 changes: 3 additions & 3 deletions src/overlays/actors/ovl_Bg_Bombwall/z_bg_bombwall.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void func_8086EE94(BgBombwall* this, PlayState* play);
static ColliderTrisElementInit sTrisElementsInit[3] = {
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x40000048, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -34,7 +34,7 @@ static ColliderTrisElementInit sTrisElementsInit[3] = {
},
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x40000048, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -45,7 +45,7 @@ static ColliderTrisElementInit sTrisElementsInit[3] = {
},
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x40000048, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static ColliderQuadInit sQuadInit = {
COLSHAPE_QUAD,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000048, 0x00, 0x00 },
{ 0x00000048, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x00000000, 0x00, 0x00 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static ColliderCylinderInit sColCylinderInitMain = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x00000000, 0x00, 0x00 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -62,7 +62,7 @@ static ColliderCylinderInit sColCylinderInitLeftRight = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0xFFCFFFFF, 0x00, 0x00 },
{ 0x00020800, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
10 changes: 5 additions & 5 deletions src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ActorProfile Bg_Haka_Sgami_Profile = {
static ColliderTrisElementInit sTrisElementsInit[4] = {
{
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x20000000, 0x00, 0x04 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NORMAL,
Expand All @@ -52,7 +52,7 @@ static ColliderTrisElementInit sTrisElementsInit[4] = {
},
{
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x20000000, 0x00, 0x04 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NORMAL,
Expand All @@ -63,7 +63,7 @@ static ColliderTrisElementInit sTrisElementsInit[4] = {
},
{
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x20000000, 0x00, 0x04 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NORMAL,
Expand All @@ -74,7 +74,7 @@ static ColliderTrisElementInit sTrisElementsInit[4] = {
},
{
{
ELEMTYPE_UNK2,
ELEM_MATERIAL_UNK2,
{ 0x20000000, 0x00, 0x04 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NORMAL,
Expand Down Expand Up @@ -108,7 +108,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000000, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
6 changes: 3 additions & 3 deletions src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0xFFCFFFFF, 0x00, 0x04 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NORMAL,
Expand All @@ -64,7 +64,7 @@ static ColliderCylinderInit sCylinderInit = {
static ColliderTrisElementInit sTrisElementsInit[2] = {
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00020000, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -75,7 +75,7 @@ static ColliderTrisElementInit sTrisElementsInit[2] = {
},
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00020000, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/actors/ovl_Bg_Haka_Tubo/z_bg_haka_tubo.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static ColliderCylinderInit sPotColliderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000008, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -60,7 +60,7 @@ static ColliderCylinderInit sFlamesColliderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x20000000, 0x01, 0x04 },
{ 0x00000008, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Haka_Zou/z_bg_haka_zou.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000008, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x20000000, 0x01, 0x04 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NONE,
Expand Down
8 changes: 4 additions & 4 deletions src/overlays/actors/ovl_Bg_Hidan_Dalm/z_bg_hidan_dalm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ActorProfile Bg_Hidan_Dalm_Profile = {
static ColliderTrisElementInit sTrisElementInit[4] = {
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000040, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -43,7 +43,7 @@ static ColliderTrisElementInit sTrisElementInit[4] = {
},
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000040, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -54,7 +54,7 @@ static ColliderTrisElementInit sTrisElementInit[4] = {
},
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000040, 0x00, 0x00 },
ATELEM_NONE,
Expand All @@ -65,7 +65,7 @@ static ColliderTrisElementInit sTrisElementInit[4] = {
},
{
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000040, 0x00, 0x00 },
ATELEM_NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x20000000, 0x01, 0x04 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NONE,
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Bg_Hidan_Fwbig/z_bg_hidan_fwbig.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static ColliderCylinderInit sCylinderInit = {
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
ELEM_MATERIAL_UNK0,
{ 0x20000000, 0x01, 0x04 },
{ 0xFFCFFFFF, 0x00, 0x00 },
ATELEM_ON | ATELEM_SFX_NONE,
Expand Down
Loading