From 9fe41706872f32d6798ecc1bd03f5e8219ec0703 Mon Sep 17 00:00:00 2001 From: Caladius Date: Sat, 12 Oct 2024 19:47:57 -0400 Subject: [PATCH 1/9] header file for functions --- soh/soh/Enhancements/accessibility/accessibility.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 soh/soh/Enhancements/accessibility/accessibility.h diff --git a/soh/soh/Enhancements/accessibility/accessibility.h b/soh/soh/Enhancements/accessibility/accessibility.h new file mode 100644 index 00000000000..e69de29bb2d From cb7f7bd36294125da6f68ec94d24cdaf54848ece Mon Sep 17 00:00:00 2001 From: Caladius Date: Sat, 12 Oct 2024 20:54:38 -0400 Subject: [PATCH 2/9] Framework for VB Hook System --- .../accessibility/accessibility.cpp | 33 +++++++++++++++++++ .../game-interactor/GameInteractor.h | 4 +++ .../GameInteractor_HookTable.h | 1 + .../game-interactor/GameInteractor_Hooks.cpp | 4 +++ .../game-interactor/GameInteractor_Hooks.h | 1 + soh/soh/SohMenuBar.cpp | 3 ++ 6 files changed, 46 insertions(+) create mode 100644 soh/soh/Enhancements/accessibility/accessibility.cpp diff --git a/soh/soh/Enhancements/accessibility/accessibility.cpp b/soh/soh/Enhancements/accessibility/accessibility.cpp new file mode 100644 index 00000000000..2ab2d340806 --- /dev/null +++ b/soh/soh/Enhancements/accessibility/accessibility.cpp @@ -0,0 +1,33 @@ +#include "accessibility.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/OTRGlobals.h" + + +extern "C" { +#include +#include "macros.h" +#include "functions.h" +#include "variables.h" +extern SaveContext gSaveContext; +extern PlayState* gPlayState; +} + +void RegisterLightSensitivityBehavior() { + static uint32_t shouldHookId1 = 0; + GameInteractor::Instance->UnregisterGameHookForID(shouldHookId1); + shouldHookId1 = 0; + + if (!gPlayState) { + return; + } + + if (!CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { + return; + } + + shouldHookId1 = REGISTER_VB_SHOULD(VB_DISABLE_LIGHT_SENSITIVITY, { + + *should = false; + return; + }); +} \ No newline at end of file diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index 5e30441db96..8f67dc78bbb 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -479,6 +479,10 @@ typedef enum { // Vanilla condition: Actor is ACTOR_EN_ELF, ACTOR_EN_FISH, ACTOR_EN_ICE_HONO, or ACTOR_EN_INSECT // Opt: *Actor VB_BOTTLE_ACTOR, + + /*** Accessibility ***/ + // Vanilla Condition: false + VB_DISABLE_LIGHT_SENSITIVITY, } GIVanillaBehavior; #ifdef __cplusplus diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index 46f306a3c83..4ee038da2d8 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -18,6 +18,7 @@ DEFINE_HOOK(OnFlagSet, (int16_t flagType, int16_t flag)); DEFINE_HOOK(OnFlagUnset, (int16_t flagType, int16_t flag)); DEFINE_HOOK(OnSceneSpawnActors, ()); DEFINE_HOOK(OnPlayerUpdate, ()); +DEFINE_HOOK(OnPlayerHealthChange, ()); DEFINE_HOOK(OnOcarinaSongAction, ()); DEFINE_HOOK(OnShopSlotChange, (uint8_t cursorIndex, int16_t price)); DEFINE_HOOK(OnActorInit, (void* actor)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 24efb40c151..574a1752e59 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -64,6 +64,10 @@ void GameInteractor_ExecuteOnPlayerUpdate() { GameInteractor::Instance->ExecuteHooks(); } +void GameInteractor_ExecuteOnPlayerHealthChange() { + GameInteractor::Instance->ExecuteHooks(); +} + void GameInteractor_ExecuteOnOcarinaSongAction() { GameInteractor::Instance->ExecuteHooks(); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index dccc9930ae2..fea6258ab1e 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -18,6 +18,7 @@ void GameInteractor_ExecuteOnFlagSet(int16_t flagType, int16_t flag); void GameInteractor_ExecuteOnFlagUnset(int16_t flagType, int16_t flag); void GameInteractor_ExecuteOnSceneSpawnActors(); void GameInteractor_ExecuteOnPlayerUpdate(); +void GameInteractor_ExecuteOnPlayerHealthChange(); void GameInteractor_ExecuteOnOcarinaSongAction(); void GameInteractor_ExecuteOnActorInit(void* actor); void GameInteractor_ExecuteOnActorUpdate(void* actor); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 3e8201b9df8..ebf0a8d2cb0 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -549,6 +549,9 @@ void DrawSettingsMenu() { #endif UIWidgets::PaddedEnhancementCheckbox("Disable Idle Camera Re-Centering", CVAR_SETTING("A11yDisableIdleCam")); UIWidgets::Tooltip("Disables the automatic re-centering of the camera when idle."); + + UIWidgets::PaddedEnhancementCheckbox("Enable Lightsensitivity Assistance", CVAR_SETTING("Lightsensitivity")); + UIWidgets::Tooltip("Reduces effects that would cause impact to those sensitive to Light."); ImGui::EndMenu(); } From 37d0ef5ec2c3d8cba37b1b44929b10dd43c2af2b Mon Sep 17 00:00:00 2001 From: Caladius Date: Sat, 12 Oct 2024 21:29:58 -0400 Subject: [PATCH 3/9] Deku Nut Flash Effect --- .../Enhancements/accessibility/accessibility.cpp | 16 +++++++++++----- .../Enhancements/accessibility/accessibility.h | 1 + soh/soh/Enhancements/mods.cpp | 5 +++++ .../overlays/actors/ovl_En_Arrow/z_en_arrow.c | 7 ++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/accessibility/accessibility.cpp b/soh/soh/Enhancements/accessibility/accessibility.cpp index 2ab2d340806..3f8cd9640d1 100644 --- a/soh/soh/Enhancements/accessibility/accessibility.cpp +++ b/soh/soh/Enhancements/accessibility/accessibility.cpp @@ -12,7 +12,7 @@ extern SaveContext gSaveContext; extern PlayState* gPlayState; } -void RegisterLightSensitivityBehavior() { +void Accessibility_LightSensitivity(GIVanillaBehavior _, bool* should, va_list originalArgs) { static uint32_t shouldHookId1 = 0; GameInteractor::Instance->UnregisterGameHookForID(shouldHookId1); shouldHookId1 = 0; @@ -21,13 +21,19 @@ void RegisterLightSensitivityBehavior() { return; } - if (!CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { + if (CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { return; } shouldHookId1 = REGISTER_VB_SHOULD(VB_DISABLE_LIGHT_SENSITIVITY, { - - *should = false; + *should = true; return; }); -} \ No newline at end of file + + *should = false; + return; +} + +void RegisterLightSensitivityBehavior() { + GameInteractor::Instance->RegisterGameHookForID(VB_DISABLE_LIGHT_SENSITIVITY, Accessibility_LightSensitivity); +} diff --git a/soh/soh/Enhancements/accessibility/accessibility.h b/soh/soh/Enhancements/accessibility/accessibility.h index e69de29bb2d..400d465edb5 100644 --- a/soh/soh/Enhancements/accessibility/accessibility.h +++ b/soh/soh/Enhancements/accessibility/accessibility.h @@ -0,0 +1 @@ +void RegisterLightSensitivityBehavior(); diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index adac0d96812..e18f6a51fc1 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -37,6 +37,8 @@ #include "objects/object_link_child/object_link_child.h" #include "kaleido.h" +#include "soh/Enhancements/accessibility/accessibility.h" + extern "C" { #include #include "align_asset_macro.h" @@ -1444,4 +1446,7 @@ void InitMods() { RegisterHurtContainerModeHandler(); RegisterPauseMenuHooks(); RandoKaleido_RegisterHooks(); + + // Accessibility Mod Inits + RegisterLightSensitivityBehavior(); } diff --git a/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index c13833d6d93..4aa8f27020d 100644 --- a/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -7,6 +7,8 @@ #include "z_en_arrow.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_gi_nuts/object_gi_nuts.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) @@ -315,7 +317,10 @@ void EnArrow_Fly(EnArrow* this, PlayState* play) { } if (this->actor.params == ARROW_NUT) { - iREG(50) = -1; + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + iREG(50) = -1; + } + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0, true); sfxId = NA_SE_IT_DEKU; From b0ca4125c7d898e8064f9ab5cc94d341207e09ff Mon Sep 17 00:00:00 2001 From: Caladius Date: Sun, 13 Oct 2024 13:05:53 -0400 Subject: [PATCH 4/9] Remove Bomb/Bombchu/BombFlower Flash Timers --- soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c | 11 ++++--- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 31 ++++++++++--------- .../overlays/actors/ovl_En_Bombf/z_en_bombf.c | 12 ++++--- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 434556a5163..2a11a939081 100644 --- a/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -8,6 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) @@ -320,10 +321,12 @@ void EnBom_Update(Actor* thisx, PlayState* play2) { this->flashSpeedScale >>= 1; } - if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { - Math_SmoothStepToF(&this->flashIntensity, 140.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); - } else { - Math_SmoothStepToF(&this->flashIntensity, 0.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { + Math_SmoothStepToF(&this->flashIntensity, 140.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); + } else { + Math_SmoothStepToF(&this->flashIntensity, 0.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); + } } if (this->timer < 3) { diff --git a/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index c265b3eb070..83e7279d655 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -1,6 +1,8 @@ #include "z_en_bom_chu.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED @@ -497,24 +499,25 @@ void EnBomChu_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); func_8002EBCC(&this->actor, play, 0); + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (this->timer >= 40) { + blinkTime = this->timer % 20; + blinkHalfPeriod = 10; + } else if (this->timer >= 10) { + blinkTime = this->timer % 10; + blinkHalfPeriod = 5; + } else { + blinkTime = this->timer & 1; + blinkHalfPeriod = 1; + } - if (this->timer >= 40) { - blinkTime = this->timer % 20; - blinkHalfPeriod = 10; - } else if (this->timer >= 10) { - blinkTime = this->timer % 10; - blinkHalfPeriod = 5; - } else { - blinkTime = this->timer & 1; - blinkHalfPeriod = 1; - } + if (blinkTime > blinkHalfPeriod) { + blinkTime = 2 * blinkHalfPeriod - blinkTime; + } - if (blinkTime > blinkHalfPeriod) { - blinkTime = 2 * blinkHalfPeriod - blinkTime; + colorIntensity = blinkTime / (f32)blinkHalfPeriod; } - colorIntensity = blinkTime / (f32)blinkHalfPeriod; - if (CVarGetInteger(CVAR_COSMETIC("Equipment.ChuBody.Changed"), 0)) { Color_RGB8 color = CVarGetColor24(CVAR_COSMETIC("Equipment.ChuBody.Value"), (Color_RGB8){ 209.0f, 34.0f, -35.0f }); gDPSetEnvColor(POLY_OPA_DISP++, (colorIntensity * color.r), (colorIntensity * color.g), diff --git a/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 2eecc1fb3f7..c59c0cf7096 100644 --- a/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -7,6 +7,8 @@ #include "z_en_bombf.h" #include "objects/object_bombf/object_bombf.h" #include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_UPDATE_WHILE_CULLED) @@ -396,10 +398,12 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { this->flashSpeedScale >>= 1; } - if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { - Math_SmoothStepToF(&this->flashIntensity, 150.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); - } else { - Math_SmoothStepToF(&this->flashIntensity, 0.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { + Math_SmoothStepToF(&this->flashIntensity, 150.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); + } else { + Math_SmoothStepToF(&this->flashIntensity, 0.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); + } } if (this->timer < 3) { From 6d3c98d797ba34fd7535ad85a04bc8901c2ffba7 Mon Sep 17 00:00:00 2001 From: Caladius Date: Sun, 13 Oct 2024 15:19:34 -0400 Subject: [PATCH 5/9] Gold Skulltulas Flash and Storms Lightning Strike Flash --- soh/src/code/z_actor.c | 11 +++++++---- .../ovl_En_Okarina_Effect/z_en_okarina_effect.c | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 7c3914095cb..d8452a36ac6 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3582,7 +3582,9 @@ Actor* Actor_Find(ActorContext* actorCtx, s32 actorId, s32 actorCategory) { * While the screen flashes, the game freezes. */ void Enemy_StartFinishingBlow(PlayState* play, Actor* actor) { - play->actorCtx.freezeFlashTimer = 5; + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + play->actorCtx.freezeFlashTimer = 5; + } SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); } @@ -4171,9 +4173,10 @@ void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s1 if ((colorFlag == 0x8000) && !(colorIntensityMax & 0x8000)) { Audio_PlayActorSound2(actor, NA_SE_EN_LIGHT_ARROW_HIT); } - - actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; - actor->colorFilterTimer = duration; + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; + actor->colorFilterTimer = duration; + } } Hilite* func_800342EC(Vec3f* object, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 9daa4f50114..6db17b7869e 100644 --- a/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -6,6 +6,8 @@ #include "z_en_okarina_effect.h" #include "vt.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_NO_FREEZE_OCARINA) @@ -64,7 +66,9 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, PlayState* play) { if ((gWeatherMode != 0) || play->envCtx.unk_17 != 0) { play->envCtx.unk_DE = 1; } - play->envCtx.lightningMode = LIGHTNING_MODE_ON; + if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + play->envCtx.lightningMode = LIGHTNING_MODE_ON; + } Environment_PlayStormNatureAmbience(play); EnOkarinaEffect_SetupAction(this, EnOkarinaEffect_ManageStorm); } From 3fed37e236ed1f31a3b2915c2b65523ddbca47de Mon Sep 17 00:00:00 2001 From: Caladius Date: Sun, 13 Oct 2024 15:50:51 -0400 Subject: [PATCH 6/9] Update Hook system to re-register when enabled. --- .../accessibility/accessibility.cpp | 29 ++++++------------- .../game-interactor/GameInteractor.h | 4 +-- soh/soh/SohMenuBar.cpp | 6 +++- soh/src/code/z_actor.c | 4 +-- .../overlays/actors/ovl_En_Arrow/z_en_arrow.c | 2 +- soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c | 2 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 2 +- .../overlays/actors/ovl_En_Bombf/z_en_bombf.c | 2 +- .../z_en_okarina_effect.c | 2 +- 9 files changed, 23 insertions(+), 30 deletions(-) diff --git a/soh/soh/Enhancements/accessibility/accessibility.cpp b/soh/soh/Enhancements/accessibility/accessibility.cpp index 3f8cd9640d1..55cfdad5d16 100644 --- a/soh/soh/Enhancements/accessibility/accessibility.cpp +++ b/soh/soh/Enhancements/accessibility/accessibility.cpp @@ -12,28 +12,17 @@ extern SaveContext gSaveContext; extern PlayState* gPlayState; } -void Accessibility_LightSensitivity(GIVanillaBehavior _, bool* should, va_list originalArgs) { - static uint32_t shouldHookId1 = 0; - GameInteractor::Instance->UnregisterGameHookForID(shouldHookId1); +void RegisterLightSensitivityBehavior() { + static uint32_t shouldHookId1 = 0; + GameInteractor::Instance->UnregisterGameHookForID(shouldHookId1); shouldHookId1 = 0; - - if (!gPlayState) { - return; - } if (CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { - return; - } - - shouldHookId1 = REGISTER_VB_SHOULD(VB_DISABLE_LIGHT_SENSITIVITY, { - *should = true; - return; - }); + return; + } - *should = false; - return; -} - -void RegisterLightSensitivityBehavior() { - GameInteractor::Instance->RegisterGameHookForID(VB_DISABLE_LIGHT_SENSITIVITY, Accessibility_LightSensitivity); + shouldHookId1 = REGISTER_VB_SHOULD(VB_ALLOW_FLASHING_LIGHTS, { + *should = false; + return; + }); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index 8f67dc78bbb..ffb7f3b4e3d 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -481,8 +481,8 @@ typedef enum { VB_BOTTLE_ACTOR, /*** Accessibility ***/ - // Vanilla Condition: false - VB_DISABLE_LIGHT_SENSITIVITY, + // Vanilla Condition: true + VB_ALLOW_FLASHING_LIGHTS, } GIVanillaBehavior; #ifdef __cplusplus diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index ebf0a8d2cb0..7d9b5cfb9e7 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -40,6 +40,8 @@ #include "Enhancements/resolution-editor/ResolutionEditor.h" #include "Enhancements/enemyrandomizer.h" +#include "soh/Enhancements/accessibility/accessibility.h"; + // FA icons are kind of wonky, if they worked how I expected them to the "+ 2.0f" wouldn't be needed, but // they don't work how I expect them to so I added that because it looked good when I eyeballed it #define FA_ICON_BUTTON_FRAME_PADDING_X(icon) (((optionsButtonSize.x - ImGui::CalcTextSize(icon).x) / 2) + 2.0f) @@ -550,7 +552,9 @@ void DrawSettingsMenu() { UIWidgets::PaddedEnhancementCheckbox("Disable Idle Camera Re-Centering", CVAR_SETTING("A11yDisableIdleCam")); UIWidgets::Tooltip("Disables the automatic re-centering of the camera when idle."); - UIWidgets::PaddedEnhancementCheckbox("Enable Lightsensitivity Assistance", CVAR_SETTING("Lightsensitivity")); + if (UIWidgets::PaddedEnhancementCheckbox("Enable Lightsensitivity Assistance", CVAR_SETTING("Lightsensitivity"))) { + RegisterLightSensitivityBehavior(); + } UIWidgets::Tooltip("Reduces effects that would cause impact to those sensitive to Light."); ImGui::EndMenu(); diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index d8452a36ac6..2e9b6e86e99 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3582,7 +3582,7 @@ Actor* Actor_Find(ActorContext* actorCtx, s32 actorId, s32 actorCategory) { * While the screen flashes, the game freezes. */ void Enemy_StartFinishingBlow(PlayState* play, Actor* actor) { - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { play->actorCtx.freezeFlashTimer = 5; } SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); @@ -4173,7 +4173,7 @@ void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s1 if ((colorFlag == 0x8000) && !(colorIntensityMax & 0x8000)) { Audio_PlayActorSound2(actor, NA_SE_EN_LIGHT_ARROW_HIT); } - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; actor->colorFilterTimer = duration; } diff --git a/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index 4aa8f27020d..0ed9504357c 100644 --- a/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/soh/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -317,7 +317,7 @@ void EnArrow_Fly(EnArrow* this, PlayState* play) { } if (this->actor.params == ARROW_NUT) { - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { iREG(50) = -1; } diff --git a/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 2a11a939081..faa43ef20cf 100644 --- a/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -321,7 +321,7 @@ void EnBom_Update(Actor* thisx, PlayState* play2) { this->flashSpeedScale >>= 1; } - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, false)) { if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { Math_SmoothStepToF(&this->flashIntensity, 140.0f, 1.0f, 140.0f / this->flashSpeedScale, 0.0f); } else { diff --git a/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 83e7279d655..fb84a8894b4 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/soh/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -499,7 +499,7 @@ void EnBomChu_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); func_8002EBCC(&this->actor, play, 0); - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, false)) { if (this->timer >= 40) { blinkTime = this->timer % 20; blinkHalfPeriod = 10; diff --git a/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index c59c0cf7096..eaa02a66fa8 100644 --- a/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -398,7 +398,7 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { this->flashSpeedScale >>= 1; } - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, false)) { if ((this->timer < 100) && ((this->timer & (this->flashSpeedScale + 1)) != 0)) { Math_SmoothStepToF(&this->flashIntensity, 150.0f, 1.0f, 150.0f / this->flashSpeedScale, 0.0f); } else { diff --git a/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 6db17b7869e..9287630e3c5 100644 --- a/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -66,7 +66,7 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, PlayState* play) { if ((gWeatherMode != 0) || play->envCtx.unk_17 != 0) { play->envCtx.unk_DE = 1; } - if (GameInteractor_Should(VB_DISABLE_LIGHT_SENSITIVITY, false)) { + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { play->envCtx.lightningMode = LIGHTNING_MODE_ON; } Environment_PlayStormNatureAmbience(play); From af9c2cb23c48c92f911adde65d0f3623641fcd58 Mon Sep 17 00:00:00 2001 From: Caladius Date: Sun, 13 Oct 2024 17:11:05 -0400 Subject: [PATCH 7/9] Remove Gohmas Light Flashing around eye and body when stunned/hit --- .../accessibility/accessibility.cpp | 14 ++++++- .../accessibility/accessibility.h | 8 ++++ .../actors/ovl_Boss_Goma/z_boss_goma.c | 40 ++++++++++--------- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/soh/soh/Enhancements/accessibility/accessibility.cpp b/soh/soh/Enhancements/accessibility/accessibility.cpp index 55cfdad5d16..2cd3651f410 100644 --- a/soh/soh/Enhancements/accessibility/accessibility.cpp +++ b/soh/soh/Enhancements/accessibility/accessibility.cpp @@ -2,7 +2,6 @@ #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/OTRGlobals.h" - extern "C" { #include #include "macros.h" @@ -10,14 +9,18 @@ extern "C" { #include "variables.h" extern SaveContext gSaveContext; extern PlayState* gPlayState; +#include "src/overlays/actors/ovl_Boss_Goma/z_boss_goma.h" } void RegisterLightSensitivityBehavior() { static uint32_t shouldHookId1 = 0; + static uint32_t ActorUpdateHookId = 0; GameInteractor::Instance->UnregisterGameHookForID(shouldHookId1); + GameInteractor::Instance->UnregisterGameHookForID(ActorUpdateHookId); shouldHookId1 = 0; + ActorUpdateHookId = 0; - if (CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { + if (!CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { return; } @@ -25,4 +28,11 @@ void RegisterLightSensitivityBehavior() { *should = false; return; }); + + ActorUpdateHookId = GameInteractor::Instance->RegisterGameHookForID(ACTOR_BOSS_GOMA, [](void* refActor) { + BossGoma* actor = (BossGoma*)refActor; + //if (actor->visualState >= VISUALSTATE_STUNNED) { + actor->visualState = VISUALSTATE_RED; + //}; + }); } diff --git a/soh/soh/Enhancements/accessibility/accessibility.h b/soh/soh/Enhancements/accessibility/accessibility.h index 400d465edb5..cb96ca620b1 100644 --- a/soh/soh/Enhancements/accessibility/accessibility.h +++ b/soh/soh/Enhancements/accessibility/accessibility.h @@ -1 +1,9 @@ +typedef enum { + VISUALSTATE_RED, + VISUALSTATE_DEFAULT, + VISUALSTATE_DEFEATED, + VISUALSTATE_STUNNED = 4, + VISUALSTATE_HIT +}; + void RegisterLightSensitivityBehavior(); diff --git a/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index 0644f73a829..b0718a600c7 100644 --- a/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -1878,24 +1878,26 @@ void BossGoma_UpdateMainEnvColor(BossGoma* this) { { 0.0f, 255.0f, 170.0f }, { 0.0f, 0.0f, 255.0f }, { 255.0f, 17.0f, 0.0f }, }; - if (this->visualState == VISUALSTATE_DEFAULT && this->frameCount & 0x10) { - Math_ApproachF(&this->mainEnvColor[0], 50.0f, 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[1], 50.0f, 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[2], 50.0f, 0.5f, 20.0f); - } else if (this->invincibilityFrames != 0) { - if (this->invincibilityFrames & 2) { - this->mainEnvColor[0] = colors2[this->visualState][0]; - this->mainEnvColor[1] = colors2[this->visualState][1]; - this->mainEnvColor[2] = colors2[this->visualState][2]; - } else { - this->mainEnvColor[0] = colors1[this->visualState][0]; - this->mainEnvColor[1] = colors1[this->visualState][1]; - this->mainEnvColor[2] = colors1[this->visualState][2]; + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { + if (this->visualState == VISUALSTATE_DEFAULT && this->frameCount & 0x10) { + Math_ApproachF(&this->mainEnvColor[0], 50.0f, 0.5f, 20.0f); + Math_ApproachF(&this->mainEnvColor[1], 50.0f, 0.5f, 20.0f); + Math_ApproachF(&this->mainEnvColor[2], 50.0f, 0.5f, 20.0f); + } else if (this->invincibilityFrames != 0) { + if (this->invincibilityFrames & 2) { + this->mainEnvColor[0] = colors2[this->visualState][0]; + this->mainEnvColor[1] = colors2[this->visualState][1]; + this->mainEnvColor[2] = colors2[this->visualState][2]; + } else { + this->mainEnvColor[0] = colors1[this->visualState][0]; + this->mainEnvColor[1] = colors1[this->visualState][1]; + this->mainEnvColor[2] = colors1[this->visualState][2]; + } } } else { - Math_ApproachF(&this->mainEnvColor[0], colors1[this->visualState][0], 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[1], colors1[this->visualState][1], 0.5f, 20.0f); - Math_ApproachF(&this->mainEnvColor[2], colors1[this->visualState][2], 0.5f, 20.0f); + Math_ApproachF(&this->mainEnvColor[0], colors1[this->visualState][0], 0.5f, 20.0f); + Math_ApproachF(&this->mainEnvColor[1], colors1[this->visualState][1], 0.5f, 20.0f); + Math_ApproachF(&this->mainEnvColor[2], colors1[this->visualState][2], 0.5f, 20.0f); } } @@ -1982,8 +1984,10 @@ s32 BossGoma_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f if (this->eyeState == EYESTATE_IRIS_FOLLOW_BONUS_IFRAMES && this->eyeLidBottomRotX < -0xA8C) { *dList = NULL; } else if (this->invincibilityFrames != 0) { - gDPSetEnvColor(POLY_OPA_DISP++, (s16)(Rand_ZeroOne() * 255.0f), (s16)(Rand_ZeroOne() * 255.0f), - (s16)(Rand_ZeroOne() * 255.0f), 63); + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { + gDPSetEnvColor(POLY_OPA_DISP++, (s16)(Rand_ZeroOne() * 255.0f), (s16)(Rand_ZeroOne() * 255.0f), + (s16)(Rand_ZeroOne() * 255.0f), 63); + } } else { gDPSetEnvColor(POLY_OPA_DISP++, (s16)this->eyeEnvColor[0], (s16)this->eyeEnvColor[1], (s16)this->eyeEnvColor[2], 63); From 9d54b4bcca008d2b15ca8cf69be54b527e137ba8 Mon Sep 17 00:00:00 2001 From: Caladius Date: Sun, 13 Oct 2024 17:41:44 -0400 Subject: [PATCH 8/9] Graveyard Storms Lightning Flash, clean up VB Function --- .../accessibility/accessibility.cpp | 20 +++++++++---------- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 5 +++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/soh/soh/Enhancements/accessibility/accessibility.cpp b/soh/soh/Enhancements/accessibility/accessibility.cpp index 2cd3651f410..da4455df8e1 100644 --- a/soh/soh/Enhancements/accessibility/accessibility.cpp +++ b/soh/soh/Enhancements/accessibility/accessibility.cpp @@ -9,30 +9,28 @@ extern "C" { #include "variables.h" extern SaveContext gSaveContext; extern PlayState* gPlayState; -#include "src/overlays/actors/ovl_Boss_Goma/z_boss_goma.h" } void RegisterLightSensitivityBehavior() { static uint32_t shouldHookId1 = 0; - static uint32_t ActorUpdateHookId = 0; GameInteractor::Instance->UnregisterGameHookForID(shouldHookId1); - GameInteractor::Instance->UnregisterGameHookForID(ActorUpdateHookId); shouldHookId1 = 0; - ActorUpdateHookId = 0; if (!CVarGetInteger(CVAR_SETTING("Lightsensitivity"), 0)) { return; } shouldHookId1 = REGISTER_VB_SHOULD(VB_ALLOW_FLASHING_LIGHTS, { + if (!gPlayState) { + return; + } + + // Requires Scene Change to update Storm Weather + if (gPlayState->envCtx.lightningMode != 0) { + gPlayState->envCtx.lightningMode = 0; + } + *should = false; return; }); - - ActorUpdateHookId = GameInteractor::Instance->RegisterGameHookForID(ACTOR_BOSS_GOMA, [](void* refActor) { - BossGoma* actor = (BossGoma*)refActor; - //if (actor->visualState >= VISUALSTATE_STUNNED) { - actor->visualState = VISUALSTATE_RED; - //}; - }); } diff --git a/soh/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/soh/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index f8b1cfd10d7..c088b297e0b 100644 --- a/soh/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/soh/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -7,6 +7,9 @@ #include "z_en_weather_tag.h" #include "vt.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" + #define FLAGS ACTOR_FLAG_UPDATE_WHILE_CULLED void EnWeatherTag_Init(Actor* thisx, PlayState* play); @@ -324,6 +327,8 @@ void EnWeatherTag_EnabledRainThunder(EnWeatherTag* this, PlayState* play) { void EnWeatherTag_Update(Actor* thisx, PlayState* play) { EnWeatherTag* this = (EnWeatherTag*)thisx; + GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, false); + this->actionFunc(this, play); if (BREG(0) != 0) { DebugDisplay_AddObject(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, From c129721419825c934e4d6cb1e058e3ae8229d9b1 Mon Sep 17 00:00:00 2001 From: Caladius Date: Sun, 13 Oct 2024 18:18:56 -0400 Subject: [PATCH 9/9] Start of KD --- .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 59c83fc829e..4ab0994ae4f 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -683,8 +683,8 @@ void BossDodongo_SetupInhale(BossDodongo* this) { void BossDodongo_Damaged(BossDodongo* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToF(&this->unk_1F8, 1.0f, 0.5f, 0.02f, 0.001f); - Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); + //Math_SmoothStepToF(&this->unk_1F8, 1.0f, 0.5f, 0.02f, 0.001f); + //Math_SmoothStepToF(&this->unk_208, 0.05f, 1.0f, 0.005f, 0.0f); if (Animation_OnFrame(&this->skelAnime, Animation_GetLastFrame(&object_kingdodongo_Anim_001074))) { BossDodongo_SetupRoll(this); @@ -1074,18 +1074,20 @@ void BossDodongo_Update(Actor* thisx, PlayState* play2) { } if (this->unk_1BE != 0) { - if (this->unk_1BE >= 1000) { - Math_SmoothStepToF(&this->colorFilterR, 30.0f, 1, 20.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterG, 10.0f, 1, 20.0f, 0.0); - } else { - this->unk_1BE--; - Math_SmoothStepToF(&this->colorFilterR, 255.0f, 1, 20.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterG, 0.0f, 1, 20.0f, 0.0); + if (GameInteractor_Should(VB_ALLOW_FLASHING_LIGHTS, true)) { + if (this->unk_1BE >= 1000) { + Math_SmoothStepToF(&this->colorFilterR, 30.0f, 1, 20.0f, 0.0); + Math_SmoothStepToF(&this->colorFilterG, 10.0f, 1, 20.0f, 0.0); + } else { + this->unk_1BE--; + Math_SmoothStepToF(&this->colorFilterR, 255.0f, 1, 20.0f, 0.0); + Math_SmoothStepToF(&this->colorFilterG, 0.0f, 1, 20.0f, 0.0); + } + + Math_SmoothStepToF(&this->colorFilterB, 0.0f, 1, 20.0f, 0.0); + Math_SmoothStepToF(&this->colorFilterMin, 900.0f, 1, 10.0f, 0.0); + Math_SmoothStepToF(&this->colorFilterMax, 1099.0f, 1, 10.0f, 0.0); } - - Math_SmoothStepToF(&this->colorFilterB, 0.0f, 1, 20.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterMin, 900.0f, 1, 10.0f, 0.0); - Math_SmoothStepToF(&this->colorFilterMax, 1099.0f, 1, 10.0f, 0.0); } else { Math_SmoothStepToF(&this->colorFilterR, play->lightCtx.fogColor[0], 1, 5.0f, 0.0); Math_SmoothStepToF(&this->colorFilterG, play->lightCtx.fogColor[1], 1.0f, 5.0f, 0.0);