From b5a881f9ab6dfb3eda813ada6b7d6f58bf6eb670 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Thu, 1 Sep 2022 18:21:44 -0700 Subject: [PATCH 1/9] Add magic arrow enhancements, non-rando Changes to red ice actor, sun switch actor, and mudwall actor to adjust their collision --- libultraship/libultraship/ImGuiImpl.cpp | 8 ++ .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 51 ++++++++++- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.h | 1 + .../ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c | 65 ++++++++++++- .../actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c | 6 +- .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 91 ++++++++++++++++++- 6 files changed, 210 insertions(+), 12 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index ed3287a5c..50b748203 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1495,6 +1495,10 @@ namespace SohImGui { Tooltip("Injects Golden Skulltula total count in pickup messages"); PaddedEnhancementCheckbox("Pull grave during the day", "gDayGravePull", true, false); Tooltip("Allows graves to be pulled when child during the day"); + PaddedEnhancementCheckbox("Blue Fire Arrows", "gBlueFireArrows", true, false); + Tooltip("Allows Ice Arrows to melt red ice"); + PaddedEnhancementCheckbox("Sunlight Arrows", "gSunlightArrows", true, false); + Tooltip("Allows Light Arrows to activate sun switches"); ImGui::EndMenu(); } @@ -2322,6 +2326,10 @@ namespace SohImGui { CVar_SetS32("gInjectSkulltulaCount", 0); // Pull grave during the day CVar_SetS32("gDayGravePull", 0); + // Blue Fire Arrows + CVar_SetS32("gBlueFireArrows", 0); + // Sunlight Arrows + CVar_SetS32("gSunlightArrows", 0); // Rotate link (0 to 2) CVar_SetS32("gPauseLiveLinkRotation", 0); diff --git a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index 4951fb9a9..e25e80751 100644 --- a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -59,6 +59,27 @@ static ColliderQuadInit sQuadInit = { { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; +// This quad only used for "Blue Fire Arrows" enhancement +static ColliderQuadInit sIceArrowQuadInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + static BombableWallInfo sBombableWallInfo[] = { { &object_bwall_Col_000118, object_bwall_DL_000040, 0 }, { &object_bwall_Col_000118, object_bwall_DL_000040, 0 }, @@ -73,6 +94,8 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; +bool blueFireArrowsDC = false; + void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { this->actionFunc = actionFunc; } @@ -82,6 +105,8 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; + blueFireArrowsDC = (CVar_GetS32("gBlueFireArrows", 0) != 0); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DPM_UNK); this->bombableWallDList = sBombableWallInfo[wallType].dList; @@ -100,6 +125,11 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); Collider_InitQuad(globalCtx, &this->collider); Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sQuadInit); + // If "Blue Fire Arrows" are enabled, set up this collider for them + if (blueFireArrowsDC) { + Collider_InitQuad(globalCtx, &this->colliderIceArrow); + Collider_SetQuad(globalCtx, &this->colliderIceArrow, &this->dyna.actor, &sIceArrowQuadInit); + } } else { this->dyna.actor.world.pos.y -= 40.0f; } @@ -227,7 +257,22 @@ void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx) { * despawn itself. */ void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & 2) { + bool blueFireArrowHit = false; + // If "Blue Fire Arrows" enabled, check this collider for a hit + if (blueFireArrowsDC) { + if (this->colliderIceArrow.base.acFlags & AC_HIT) { + this->colliderIceArrow.base.acFlags &= ~AC_HIT; + if ((this->colliderIceArrow.base.ac != NULL) && (this->colliderIceArrow.base.ac->id == ACTOR_EN_ARROW)) { + + if (this->colliderIceArrow.base.ac->child != NULL && + this->colliderIceArrow.base.ac->child->id == ACTOR_ARROW_ICE) { + blueFireArrowHit = true; + } + } + } + } + + if (this->collider.base.acFlags & 2 || blueFireArrowHit) { Vec3f effectPos; s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; @@ -313,6 +358,10 @@ void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { Collider_SetQuadVertices(&this->collider, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (blueFireArrowsDC) { + Collider_SetQuadVertices(&this->colliderIceArrow, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderIceArrow.base); + } } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 43fd4ee93..09089469e 100644 --- a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -14,6 +14,7 @@ typedef struct BgBreakwall { /* 0x0168 */ s8 colType; /* 0x0169 */ s8 bankIndex; /* 0x016C */ ColliderQuad collider; + ColliderQuad colliderIceArrow; // For "Blue Fire Arrows" enhancement /* 0x01EC */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x01F0 diff --git a/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c b/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c index 70a1ea1a6..3d7bd114f 100644 --- a/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c +++ b/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c @@ -14,6 +14,8 @@ void func_808911BC(BgIceShelter* this); void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx); void func_808911D4(BgIceShelter* this, GlobalContext* globalCtx); +void CheckIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx); + const ActorInit Bg_Ice_Shelter_InitVars = { ACTOR_BG_ICE_SHELTER, ACTORCAT_BG, @@ -32,7 +34,7 @@ static f32 sScales[] = { 0.1f, 0.06f, 0.1f, 0.1f, 0.25f }; static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; static Color_RGBA8 sDustEnvColor = { 180, 180, 180, 255 }; -static ColliderCylinderInit D_8089170C = { +static ColliderCylinderInit sCylinder1Init = { { COLTYPE_NONE, AT_NONE, @@ -52,7 +54,7 @@ static ColliderCylinderInit D_8089170C = { { 0, 0, 0, { 0, 0, 0 } }, }; -static ColliderCylinderInit D_80891738 = { +static ColliderCylinderInit sCylinder2Init = { { COLTYPE_HARD, AT_NONE, @@ -72,14 +74,44 @@ static ColliderCylinderInit D_80891738 = { { 0, 0, 0, { 0, 0, 0 } }, }; +// This cylinder only used for "Blue Fire Arrows" enhancement +static ColliderCylinderInit sIceArrowCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_OTHER | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xFFCFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, 0, 0, { 0, 0, 0 } }, +}; + +bool blueFireArrows = false; + void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) { static s16 cylinderRadii[] = { 47, 33, 44, 41, 100 }; static s16 cylinderHeights[] = { 80, 54, 90, 60, 200 }; s32 pad; s32 type = (this->dyna.actor.params >> 8) & 7; + blueFireArrows = (CVar_GetS32("gBlueFireArrows", 0) != 0); + Collider_InitCylinder(globalCtx, &this->cylinder1); - Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &D_8089170C); + // If "Blue Fire Arrows" is enabled, set up a collider on the red ice that responds to them + if (blueFireArrows) { + Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sIceArrowCylinderInit); + } else { + Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sCylinder1Init); + } Collider_UpdateCylinder(&this->dyna.actor, &this->cylinder1); this->cylinder1.dim.radius = cylinderRadii[type]; @@ -87,7 +119,7 @@ void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) { if (type == 0 || type == 1 || type == 4) { Collider_InitCylinder(globalCtx, &this->cylinder2); - Collider_SetCylinder(globalCtx, &this->cylinder2, &this->dyna.actor, &D_80891738); + Collider_SetCylinder(globalCtx, &this->cylinder2, &this->dyna.actor, &sCylinder2Init); Collider_UpdateCylinder(&this->dyna.actor, &this->cylinder2); this->cylinder2.dim.radius = cylinderRadii[type]; this->cylinder2.dim.height = cylinderHeights[type]; @@ -292,7 +324,12 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) { this->dyna.actor.parent->freezeTimer = 10000; } } - + // If we have "Blue Fire Arrows" enabled, check both cylinders for a hit + if (blueFireArrows) { + CheckIceArrowHit(this, this->cylinder1, type, globalCtx); + CheckIceArrowHit(this, this->cylinder2, type, globalCtx); + } + // Default blue fire check if (this->cylinder1.base.acFlags & AC_HIT) { this->cylinder1.base.acFlags &= ~AC_HIT; @@ -320,6 +357,24 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder1.base); } +// Check for an Ice Arrow hit (for "Blue Fire Arrows" enhancement). Copied from default blue fire check +void CheckIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx) { + if (cylinder.base.acFlags & AC_HIT) { + cylinder.base.acFlags &= ~AC_HIT; + if ((cylinder.base.ac != NULL) && (cylinder.base.ac->id == ACTOR_EN_ARROW)) { + if (cylinder.base.ac->child != NULL && cylinder.base.ac->child->id == ACTOR_ARROW_ICE) { + if (type == 4) { + if (this->dyna.actor.parent != NULL) { + this->dyna.actor.parent->freezeTimer = 50; + } + } + func_808911BC(this); + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ICE_MELT); + } + } + } +} + void func_808911BC(BgIceShelter* this) { this->actionFunc = func_808911D4; this->alpha = 255; diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c b/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c index 57c7ac413..32a0fdee6 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c @@ -96,7 +96,11 @@ void BgJyaLift_DelayMove(BgJyaLift* this, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) || (this->moveDelay > 0)) { this->moveDelay++; if (this->moveDelay >= 20) { - OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM); + // Skip this cutscene if using Sunlight Arrows in rando, since activating the switch while + // not standing on the platform will cause the cutscene to show the unloaded central room + if (!(gSaveContext.n64ddFlag && CVar_GetS32("gSunlightArrows", 0) != 0)) { + OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM); + } BgJyaLift_SetupMove(this); } } diff --git a/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index 459f20218..67c338483 100644 --- a/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -73,6 +73,36 @@ static ColliderJntSphInit sColliderJntSphInit = { 1, sColliderJntSphElementInit, }; +// Collider info used for "Sunlight Arrows" +static ColliderJntSphElementInit sColliderLightArrowElementInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00202000, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_ON, + OCELEM_ON, + }, + { 0, { { 0, 0, 0 }, 19 }, 100 }, + }, +}; +// Sphere collider used for "Sunlight Arrows" +static ColliderJntSphInit sColliderLightArrowInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sColliderLightArrowElementInit, +}; + +bool activatedByLightArrow = false; +bool sunLightArrows = false; static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; @@ -91,9 +121,15 @@ static InitChainEntry sInitChain[] = { void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) { s32 pad; + sunLightArrows = (CVar_GetS32("gSunlightArrows", 0) != 0); Collider_InitJntSph(globalCtx, &this->collider); - Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems); + // If "Sunlight Arrows" is enabled, set up the collider to allow Light Arrow hits + if (sunLightArrows) { + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderLightArrowInit, this->colliderItems); + } else { + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems); + } Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), this->actor.world.pos.z, &this->actor.shape.rot); @@ -211,6 +247,26 @@ void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; ObjLightswitch* this = (ObjLightswitch*)thisx; + // Unset the switch flag on room exit to prevent the rock in the wall from + // vanishing on its own after activating the sun switch by Light Arrow + // Also prevents the cobra mirror from rotating to face the sun on its own + // Makes sun switches temporary when activated by Light Arrows (will turn off on room exit) + if (activatedByLightArrow && sunLightArrows) { + switch (this->actor.params >> 4 & 3) { + case OBJLIGHTSWITCH_TYPE_STAY_ON: + case OBJLIGHTSWITCH_TYPE_2: + case OBJLIGHTSWITCH_TYPE_1: + // Except for this one, because we want the chain platform to stay down for good + if (this->actor.room != 25) { + Flags_UnsetSwitch(globalCtx, this->actor.params >> 8 & 0x3F); + } + activatedByLightArrow = false; + break; + case OBJLIGHTSWITCH_TYPE_BURN: + break; + } + } + Collider_DestroyJntSph(globalCtx, &this->collider); } @@ -221,8 +277,11 @@ void ObjLightswitch_SetupOff(ObjLightswitch* this) { this->color[1] = 125 << 6; this->color[2] = 255 << 6; this->alpha = 255 << 6; + if (sunLightArrows) { + activatedByLightArrow = false; + } } - +// A Sun Switch that is currently turned off void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) { switch (this->actor.params >> 4 & 3) { case OBJLIGHTSWITCH_TYPE_STAY_ON: @@ -230,6 +289,13 @@ void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { ObjLightswitch_SetupTurnOn(this); ObjLightswitch_SetSwitchFlag(this, globalCtx); + // Remember if we've been activated by a Light Arrow, so we can + // prevent the switch from immediately turning back off + if (sunLightArrows) { + if (this->collider.base.ac != NULL && this->collider.base.ac->id == ACTOR_EN_ARROW) { + activatedByLightArrow = true; + } + } } break; case OBJLIGHTSWITCH_TYPE_1: @@ -289,13 +355,19 @@ void ObjLightswitch_SetupOn(ObjLightswitch* this) { this->flameRingRotSpeed = -0xAA; this->timer = 0; } - +// A Sun Switch that is currently turned on void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) { switch (this->actor.params >> 4 & 3) { case OBJLIGHTSWITCH_TYPE_STAY_ON: if (!Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F)) { ObjLightswitch_SetupTurnOff(this); } + // If hit by sunlight after already being turned on, then behave as if originally activated by sunlight + if (sunLightArrows && (this->collider.base.acFlags & AC_HIT)) { + if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) { + activatedByLightArrow = false; + } + } break; case OBJLIGHTSWITCH_TYPE_1: if (this->collider.base.acFlags & AC_HIT && !(this->prevFrameACflags & AC_HIT)) { @@ -304,10 +376,19 @@ void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) { } break; case OBJLIGHTSWITCH_TYPE_2: + // If hit by sunlight after already being turned on, then behave as if originally activated by sunlight + if (sunLightArrows && (this->collider.base.acFlags & AC_HIT)) { + if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) { + activatedByLightArrow = false; + } + } if (!(this->collider.base.acFlags & AC_HIT)) { if (this->timer >= 7) { - ObjLightswitch_SetupTurnOff(this); - ObjLightswitch_ClearSwitchFlag(this, globalCtx); + // If we aren't using Enhanced Light Arrows, let the switch turn off normally + if (!activatedByLightArrow) { + ObjLightswitch_SetupTurnOff(this); + ObjLightswitch_ClearSwitchFlag(this, globalCtx); + } } else { this->timer++; } From 41256359f29711a0f12c961a1374bfa9f215bd70 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Thu, 1 Sep 2022 18:44:23 -0700 Subject: [PATCH 2/9] Update tooltip --- libultraship/libultraship/ImGuiImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 50b748203..d790ac575 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1496,9 +1496,9 @@ namespace SohImGui { PaddedEnhancementCheckbox("Pull grave during the day", "gDayGravePull", true, false); Tooltip("Allows graves to be pulled when child during the day"); PaddedEnhancementCheckbox("Blue Fire Arrows", "gBlueFireArrows", true, false); - Tooltip("Allows Ice Arrows to melt red ice"); + Tooltip("Allows Ice Arrows to melt red ice (may need to reload the room when first enabled)"); PaddedEnhancementCheckbox("Sunlight Arrows", "gSunlightArrows", true, false); - Tooltip("Allows Light Arrows to activate sun switches"); + Tooltip("Allows Light Arrows to activate sun switches (may need to reload the room when first enabled)"); ImGui::EndMenu(); } From 5a9540585a24f4aa2c193dcbc63931b628af5098 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 3 Sep 2022 11:35:19 -0700 Subject: [PATCH 3/9] Simplify mudwall collision check --- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 31 +++++++++---------- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.h | 1 - 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index e25e80751..aff800c53 100644 --- a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -59,20 +59,20 @@ static ColliderQuadInit sQuadInit = { { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// This quad only used for "Blue Fire Arrows" enhancement +// Replacement quad used for "Blue Fire Arrows" enhancement static ColliderQuadInit sIceArrowQuadInit = { { COLTYPE_NONE, AT_NONE, - AC_ON | AC_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_TYPE_2, COLSHAPE_QUAD, }, { ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0xFFCFFFFF, 0x00, 0x00 }, + { 0x00000048, 0x00, 0x00 }, + { 0x00001048, 0x00, 0x00 }, TOUCH_NONE, BUMP_ON, OCELEM_NONE, @@ -123,12 +123,14 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); - Collider_InitQuad(globalCtx, &this->collider); - Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sQuadInit); + // If "Blue Fire Arrows" are enabled, set up this collider for them if (blueFireArrowsDC) { - Collider_InitQuad(globalCtx, &this->colliderIceArrow); - Collider_SetQuad(globalCtx, &this->colliderIceArrow, &this->dyna.actor, &sIceArrowQuadInit); + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sIceArrowQuadInit); + } else { + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sQuadInit); } } else { this->dyna.actor.world.pos.y -= 40.0f; @@ -260,12 +262,11 @@ void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) { bool blueFireArrowHit = false; // If "Blue Fire Arrows" enabled, check this collider for a hit if (blueFireArrowsDC) { - if (this->colliderIceArrow.base.acFlags & AC_HIT) { - this->colliderIceArrow.base.acFlags &= ~AC_HIT; - if ((this->colliderIceArrow.base.ac != NULL) && (this->colliderIceArrow.base.ac->id == ACTOR_EN_ARROW)) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && (this->collider.base.ac->id == ACTOR_EN_ARROW)) { - if (this->colliderIceArrow.base.ac->child != NULL && - this->colliderIceArrow.base.ac->child->id == ACTOR_ARROW_ICE) { + if (this->collider.base.ac->child != NULL && + this->collider.base.ac->child->id == ACTOR_ARROW_ICE) { blueFireArrowHit = true; } } @@ -358,10 +359,6 @@ void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { Collider_SetQuadVertices(&this->collider, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (blueFireArrowsDC) { - Collider_SetQuadVertices(&this->colliderIceArrow, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderIceArrow.base); - } } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 09089469e..43fd4ee93 100644 --- a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -14,7 +14,6 @@ typedef struct BgBreakwall { /* 0x0168 */ s8 colType; /* 0x0169 */ s8 bankIndex; /* 0x016C */ ColliderQuad collider; - ColliderQuad colliderIceArrow; // For "Blue Fire Arrows" enhancement /* 0x01EC */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x01F0 From b31b1ef15720059ad3f4df603b66af3ffe3ce2a9 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 3 Sep 2022 11:43:31 -0700 Subject: [PATCH 4/9] Restore checkboxes in menu Accidentally lost these during merge --- soh/soh/GameMenuBar.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index cf843cc8b..cb50fc2c6 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -237,6 +237,10 @@ namespace GameMenuBar { CVar_SetS32("gInjectSkulltulaCount", 0); // Pull grave during the day CVar_SetS32("gDayGravePull", 0); + // Blue Fire Arrows + CVar_SetS32("gBlueFireArrows", 0); + // Sunlight Arrows + CVar_SetS32("gSunlightArrows", 0); // Rotate link (0 to 2) CVar_SetS32("gPauseLiveLinkRotation", 0); @@ -873,6 +877,10 @@ namespace GameMenuBar { UIWidgets::Tooltip("Injects Golden Skulltula total count in pickup messages"); UIWidgets::PaddedEnhancementCheckbox("Pull grave during the day", "gDayGravePull", true, false); UIWidgets::Tooltip("Allows graves to be pulled when child during the day"); + UIWidgets::PaddedEnhancementCheckbox("Blue Fire Arrows", "gBlueFireArrows", true, false); + UIWidgets::Tooltip("Allows Ice Arrows to melt red ice"); + UIWidgets::PaddedEnhancementCheckbox("Sunlight Arrows", "gSunlightArrows", true, false); + UIWidgets::Tooltip("Allows Light Arrows to activate sun switches"); ImGui::EndMenu(); } From dc4d8e322be3329e593518f715e1e87fb71b7839 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 3 Sep 2022 14:19:59 -0700 Subject: [PATCH 5/9] Update tooltip --- soh/soh/GameMenuBar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index cb50fc2c6..50e914dd3 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -878,9 +878,9 @@ namespace GameMenuBar { UIWidgets::PaddedEnhancementCheckbox("Pull grave during the day", "gDayGravePull", true, false); UIWidgets::Tooltip("Allows graves to be pulled when child during the day"); UIWidgets::PaddedEnhancementCheckbox("Blue Fire Arrows", "gBlueFireArrows", true, false); - UIWidgets::Tooltip("Allows Ice Arrows to melt red ice"); + UIWidgets::Tooltip("Allows Ice Arrows to melt red ice. May require a room reload if toggled during gameplay."); UIWidgets::PaddedEnhancementCheckbox("Sunlight Arrows", "gSunlightArrows", true, false); - UIWidgets::Tooltip("Allows Light Arrows to activate sun switches"); + UIWidgets::Tooltip("Allows Light Arrows to activate sun switches. May require a room reload if toggled during gameplay."); ImGui::EndMenu(); } From e9822eed62a89c9de09d6fa6181df102da8e7e69 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 3 Sep 2022 14:25:47 -0700 Subject: [PATCH 6/9] Add line break in tooltip --- soh/soh/GameMenuBar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index 50e914dd3..ae6aae2df 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -878,9 +878,9 @@ namespace GameMenuBar { UIWidgets::PaddedEnhancementCheckbox("Pull grave during the day", "gDayGravePull", true, false); UIWidgets::Tooltip("Allows graves to be pulled when child during the day"); UIWidgets::PaddedEnhancementCheckbox("Blue Fire Arrows", "gBlueFireArrows", true, false); - UIWidgets::Tooltip("Allows Ice Arrows to melt red ice. May require a room reload if toggled during gameplay."); + UIWidgets::Tooltip("Allows Ice Arrows to melt red ice.\nMay require a room reload if toggled during gameplay."); UIWidgets::PaddedEnhancementCheckbox("Sunlight Arrows", "gSunlightArrows", true, false); - UIWidgets::Tooltip("Allows Light Arrows to activate sun switches. May require a room reload if toggled during gameplay."); + UIWidgets::Tooltip("Allows Light Arrows to activate sun switches.\nMay require a room reload if toggled during gameplay."); ImGui::EndMenu(); } From 3b844375b799eb80e49a7b17fd80207fb886ef54 Mon Sep 17 00:00:00 2001 From: aMannus Date: Tue, 6 Sep 2022 11:27:26 +0200 Subject: [PATCH 7/9] Add missing pendingFlags (#1414) --- soh/src/code/z_play.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index f831bc830..3d536e9f3 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -218,7 +218,8 @@ void GivePlayerRandoRewardNocturne(GlobalContext* globalCtx, RandomizerCheck che !Player_InBlockingCsMode(globalCtx, player) && !Flags_GetEventChkInf(0xAA)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_NOCTURNE_OF_SHADOW); GiveItemEntryWithoutActor(globalCtx, getItemEntry); - Flags_SetEventChkInf(0xAA); + player->pendingFlag.flagID = 0xAA; + player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF; } } @@ -230,7 +231,8 @@ void GivePlayerRandoRewardRequiem(GlobalContext* globalCtx, RandomizerCheck chec !Player_InBlockingCsMode(globalCtx, player)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); GiveItemEntryWithoutActor(globalCtx, getItemEntry); - Flags_SetEventChkInf(0xAC); + player->pendingFlag.flagID = 0xAC; + player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF; } } } From a73729b9b1090b0d41ce84b981537cfd385ac6d6 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 6 Sep 2022 10:40:26 -0700 Subject: [PATCH 8/9] Clarify var names and comments Also preserve chain platform cutscene in spirit based on Link's position --- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 9 +++--- .../ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c | 20 ++++++------ .../actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c | 15 ++++++--- .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 32 ++++++++++--------- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index aff800c53..c50324e6b 100644 --- a/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/soh/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -94,7 +94,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), }; -bool blueFireArrowsDC = false; +bool blueFireArrowsEnabledOnMudwallLoad = false; void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { this->actionFunc = actionFunc; @@ -105,7 +105,8 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF; - blueFireArrowsDC = (CVar_GetS32("gBlueFireArrows", 0) != 0); + // Initialize this with the mud wall, so it can't be affected by toggling while the actor is loaded + blueFireArrowsEnabledOnMudwallLoad = (CVar_GetS32("gBlueFireArrows", 0) != 0); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DPM_UNK); @@ -125,7 +126,7 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); // If "Blue Fire Arrows" are enabled, set up this collider for them - if (blueFireArrowsDC) { + if (blueFireArrowsEnabledOnMudwallLoad) { Collider_InitQuad(globalCtx, &this->collider); Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sIceArrowQuadInit); } else { @@ -261,7 +262,7 @@ void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx) { void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) { bool blueFireArrowHit = false; // If "Blue Fire Arrows" enabled, check this collider for a hit - if (blueFireArrowsDC) { + if (blueFireArrowsEnabledOnMudwallLoad) { if (this->collider.base.acFlags & AC_HIT) { if ((this->collider.base.ac != NULL) && (this->collider.base.ac->id == ACTOR_EN_ARROW)) { diff --git a/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c b/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c index 3d7bd114f..8004bbc46 100644 --- a/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c +++ b/soh/src/overlays/actors/ovl_Bg_Ice_Shelter/z_bg_ice_shelter.c @@ -14,7 +14,8 @@ void func_808911BC(BgIceShelter* this); void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx); void func_808911D4(BgIceShelter* this, GlobalContext* globalCtx); -void CheckIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx); +// For "Blue Fire Arrows" enhancement +void MeltOnIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx); const ActorInit Bg_Ice_Shelter_InitVars = { ACTOR_BG_ICE_SHELTER, @@ -95,7 +96,7 @@ static ColliderCylinderInit sIceArrowCylinderInit = { { 0, 0, 0, { 0, 0, 0 } }, }; -bool blueFireArrows = false; +bool blueFireArrowsEnabledOnRedIceLoad = false; void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) { static s16 cylinderRadii[] = { 47, 33, 44, 41, 100 }; @@ -103,11 +104,12 @@ void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) { s32 pad; s32 type = (this->dyna.actor.params >> 8) & 7; - blueFireArrows = (CVar_GetS32("gBlueFireArrows", 0) != 0); + // Initialize this with the red ice, so it can't be affected by toggling while the actor is loaded + blueFireArrowsEnabledOnRedIceLoad = (CVar_GetS32("gBlueFireArrows", 0) != 0); Collider_InitCylinder(globalCtx, &this->cylinder1); // If "Blue Fire Arrows" is enabled, set up a collider on the red ice that responds to them - if (blueFireArrows) { + if (blueFireArrowsEnabledOnRedIceLoad) { Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sIceArrowCylinderInit); } else { Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sCylinder1Init); @@ -325,9 +327,9 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) { } } // If we have "Blue Fire Arrows" enabled, check both cylinders for a hit - if (blueFireArrows) { - CheckIceArrowHit(this, this->cylinder1, type, globalCtx); - CheckIceArrowHit(this, this->cylinder2, type, globalCtx); + if (blueFireArrowsEnabledOnRedIceLoad) { + MeltOnIceArrowHit(this, this->cylinder1, type, globalCtx); + MeltOnIceArrowHit(this, this->cylinder2, type, globalCtx); } // Default blue fire check if (this->cylinder1.base.acFlags & AC_HIT) { @@ -357,8 +359,8 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder1.base); } -// Check for an Ice Arrow hit (for "Blue Fire Arrows" enhancement). Copied from default blue fire check -void CheckIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx) { +// For "Blue Fire Arrows" enhancement: If hit by an Ice Arrow, melt the red ice (copied from the default blue fire function above). +void MeltOnIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx) { if (cylinder.base.acFlags & AC_HIT) { cylinder.base.acFlags &= ~AC_HIT; if ((cylinder.base.ac != NULL) && (cylinder.base.ac->id == ACTOR_EN_ARROW)) { diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c b/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c index 32a0fdee6..a8f3eefce 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c @@ -96,12 +96,19 @@ void BgJyaLift_DelayMove(BgJyaLift* this, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) || (this->moveDelay > 0)) { this->moveDelay++; if (this->moveDelay >= 20) { - // Skip this cutscene if using Sunlight Arrows in rando, since activating the switch while - // not standing on the platform will cause the cutscene to show the unloaded central room - if (!(gSaveContext.n64ddFlag && CVar_GetS32("gSunlightArrows", 0) != 0)) { + // The cutscene of the platform lowering will show the central room in an unloaded state if + // Link is not standing on the platform as it lowers. Therefore check for the Sunlight arrows + // enhancement and if it's enabled, check that Link is on the platform. Otherwise skip it. + if (gSaveContext.n64ddFlag && CVar_GetS32("gSunlightArrows", 0)) { + if (GET_PLAYER(globalCtx)->actor.world.pos.x > -19.0f && GET_PLAYER(globalCtx)->actor.world.pos.x < 139.0f && + GET_PLAYER(globalCtx)->actor.world.pos.z > -1172.0f && GET_PLAYER(globalCtx)->actor.world.pos.z < -1009.0f) { + OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM); + } + BgJyaLift_SetupMove(this); + } else { OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM); + BgJyaLift_SetupMove(this); } - BgJyaLift_SetupMove(this); } } } diff --git a/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index 67c338483..009b5847d 100644 --- a/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -101,8 +101,8 @@ static ColliderJntSphInit sColliderLightArrowInit = { sColliderLightArrowElementInit, }; -bool activatedByLightArrow = false; -bool sunLightArrows = false; +bool sunSwitchActivatedByLightArrow = false; +bool sunLightArrowsEnabledOnSunSwitchLoad = false; static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; @@ -121,11 +121,13 @@ static InitChainEntry sInitChain[] = { void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) { s32 pad; - sunLightArrows = (CVar_GetS32("gSunlightArrows", 0) != 0); + + // Initialize this with the sun switch, so it can't be affected by toggling while the actor is loaded + sunLightArrowsEnabledOnSunSwitchLoad = (CVar_GetS32("gSunlightArrows", 0) != 0); Collider_InitJntSph(globalCtx, &this->collider); // If "Sunlight Arrows" is enabled, set up the collider to allow Light Arrow hits - if (sunLightArrows) { + if (sunLightArrowsEnabledOnSunSwitchLoad) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderLightArrowInit, this->colliderItems); } else { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems); @@ -251,7 +253,7 @@ void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) { // vanishing on its own after activating the sun switch by Light Arrow // Also prevents the cobra mirror from rotating to face the sun on its own // Makes sun switches temporary when activated by Light Arrows (will turn off on room exit) - if (activatedByLightArrow && sunLightArrows) { + if (sunSwitchActivatedByLightArrow) { switch (this->actor.params >> 4 & 3) { case OBJLIGHTSWITCH_TYPE_STAY_ON: case OBJLIGHTSWITCH_TYPE_2: @@ -260,7 +262,7 @@ void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) { if (this->actor.room != 25) { Flags_UnsetSwitch(globalCtx, this->actor.params >> 8 & 0x3F); } - activatedByLightArrow = false; + sunSwitchActivatedByLightArrow = false; break; case OBJLIGHTSWITCH_TYPE_BURN: break; @@ -277,8 +279,8 @@ void ObjLightswitch_SetupOff(ObjLightswitch* this) { this->color[1] = 125 << 6; this->color[2] = 255 << 6; this->alpha = 255 << 6; - if (sunLightArrows) { - activatedByLightArrow = false; + if (sunLightArrowsEnabledOnSunSwitchLoad) { + sunSwitchActivatedByLightArrow = false; } } // A Sun Switch that is currently turned off @@ -291,9 +293,9 @@ void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) { ObjLightswitch_SetSwitchFlag(this, globalCtx); // Remember if we've been activated by a Light Arrow, so we can // prevent the switch from immediately turning back off - if (sunLightArrows) { + if (sunLightArrowsEnabledOnSunSwitchLoad) { if (this->collider.base.ac != NULL && this->collider.base.ac->id == ACTOR_EN_ARROW) { - activatedByLightArrow = true; + sunSwitchActivatedByLightArrow = true; } } } @@ -363,9 +365,9 @@ void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) { ObjLightswitch_SetupTurnOff(this); } // If hit by sunlight after already being turned on, then behave as if originally activated by sunlight - if (sunLightArrows && (this->collider.base.acFlags & AC_HIT)) { + if (sunLightArrowsEnabledOnSunSwitchLoad && (this->collider.base.acFlags & AC_HIT)) { if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) { - activatedByLightArrow = false; + sunSwitchActivatedByLightArrow = false; } } break; @@ -377,15 +379,15 @@ void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) { break; case OBJLIGHTSWITCH_TYPE_2: // If hit by sunlight after already being turned on, then behave as if originally activated by sunlight - if (sunLightArrows && (this->collider.base.acFlags & AC_HIT)) { + if (sunLightArrowsEnabledOnSunSwitchLoad && (this->collider.base.acFlags & AC_HIT)) { if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) { - activatedByLightArrow = false; + sunSwitchActivatedByLightArrow = false; } } if (!(this->collider.base.acFlags & AC_HIT)) { if (this->timer >= 7) { // If we aren't using Enhanced Light Arrows, let the switch turn off normally - if (!activatedByLightArrow) { + if (!sunSwitchActivatedByLightArrow) { ObjLightswitch_SetupTurnOff(this); ObjLightswitch_ClearSwitchFlag(this, globalCtx); } From 5991be825666dddf60d65483f1d031babd48fecd Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 6 Sep 2022 10:57:08 -0700 Subject: [PATCH 9/9] Remove !=0 from cvar check --- soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index 009b5847d..1345dd0c7 100644 --- a/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/soh/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -123,7 +123,7 @@ void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) s32 pad; // Initialize this with the sun switch, so it can't be affected by toggling while the actor is loaded - sunLightArrowsEnabledOnSunSwitchLoad = (CVar_GetS32("gSunlightArrows", 0) != 0); + sunLightArrowsEnabledOnSunSwitchLoad = (CVar_GetS32("gSunlightArrows", 0)); Collider_InitJntSph(globalCtx, &this->collider); // If "Sunlight Arrows" is enabled, set up the collider to allow Light Arrow hits