From c36468ccbd83da663e27d98256724ed9e93b49f4 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sat, 17 Jan 2026 00:11:17 -0600 Subject: [PATCH] Add bounce off walls toggle (#6110) --- .../ExtraModes/BounceOffWalls.cpp | 24 +++++++++++++++++++ soh/soh/SohGui/SohMenuEnhancements.cpp | 5 ++++ 2 files changed, 29 insertions(+) create mode 100644 soh/soh/Enhancements/ExtraModes/BounceOffWalls.cpp diff --git a/soh/soh/Enhancements/ExtraModes/BounceOffWalls.cpp b/soh/soh/Enhancements/ExtraModes/BounceOffWalls.cpp new file mode 100644 index 000000000..8d1643d8d --- /dev/null +++ b/soh/soh/Enhancements/ExtraModes/BounceOffWalls.cpp @@ -0,0 +1,24 @@ +#include +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" +#include "soh/ShipInit.hpp" + +extern "C" { +#include "macros.h" +#include "functions.h" +extern PlayState* gPlayState; +} + +#define CVAR_BOUNCE_OFF_WALLS_NAME CVAR_ENHANCEMENT("BounceOffWalls") +#define CVAR_BOUNCE_OFF_WALLS_VALUE CVarGetInteger(CVAR_BOUNCE_OFF_WALLS_NAME, 0) + +static RegisterShipInitFunc initFunc( + []() { + COND_HOOK(OnPlayerUpdate, CVAR_BOUNCE_OFF_WALLS_VALUE, []() { + Player* player = GET_PLAYER(gPlayState); + if (player->actor.bgCheckFlags & 0x08 && ABS(player->linearVelocity) > 15.0f) { + player->yaw = ((player->actor.wallYaw - player->yaw) + player->actor.wallYaw) - 0x8000; + Player_PlaySfx(&player->actor, NA_SE_PL_BODY_HIT); + } + }); + }, + { CVAR_BOUNCE_OFF_WALLS_NAME }); diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index 8ae21a2aa..accd7a664 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1555,6 +1555,11 @@ void SohMenu::AddMenuEnhancements() { AddSidebarEntry("Enhancements", path.sidebarName, 3); path.column = SECTION_COLUMN_1; + AddWidget(path, "Bounce off Walls", WIDGET_CVAR_CHECKBOX) + .CVar(CVAR_ENHANCEMENT("BounceOffWalls")) + .Options( + CheckboxOptions().Tooltip("Allows Link to bounce off walls when linear velocity is high enough, this is " + "relevant when frequently being knocked back by traps, CC, or in Anchor.")); AddWidget(path, "Mirrored World", WIDGET_CVAR_COMBOBOX) .CVar(CVAR_ENHANCEMENT("MirroredWorldMode")) .Options(