diff --git a/soh/soh/Enhancements/ExtraModes/BounceOffWalls.cpp b/soh/soh/Enhancements/ExtraModes/BounceOffWalls.cpp new file mode 100644 index 00000000000..8d1643d8d67 --- /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 30cf7d5494f..cfb176570af 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1535,6 +1535,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(