Skip to content

Commit

Permalink
Add PreventDiveOverWater enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox committed Jan 29, 2025
1 parent 26012da commit 3196bf7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mm/2s2h/BenGui/BenMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ void BenMenu::AddEnhancements() {
.Min(1)
.Max(5)
.DefaultValue(1));
AddWidget(path, "Prevent Diving Over Water", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Player.PreventDiveOverWater")
.Options(CheckboxOptions().Tooltip("Prevents Link from automatically diving over bodies of water."));
AddWidget(path, "Dpad Equips", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Dpad.DpadEquips")
.Options(CheckboxOptions().Tooltip("Allows you to equip items to your d-pad"));
Expand Down
12 changes: 12 additions & 0 deletions mm/2s2h/Enhancements/Player/PreventDiveOverWater.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/ShipInit.hpp"

#define CVAR_NAME "gEnhancements.Player.PreventDiveOverWater"
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterPreventDiveOverWater() {
COND_VB_SHOULD(VB_LINK_DIVE_OVER_WATER, CVAR, { *should = false; });
}

static RegisterShipInitFunc initFunc(RegisterPreventDiveOverWater, { CVAR_NAME });
1 change: 1 addition & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ typedef enum {
VB_GORON_ROLL_DISABLE_SPIKE_MODE,
VB_DEKU_LINK_SPIN_ON_LAST_HOP,
VB_CLAMP_ANIMATION_SPEED,
VB_LINK_DIVE_OVER_WATER,
} GIVanillaBehavior;

typedef enum {
Expand Down
6 changes: 4 additions & 2 deletions mm/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -7343,8 +7343,10 @@ void func_8083827C(Player* this, PlayState* play) {
sp48 = func_80835CD8(play, this, &D_8085D154, &sp4C, &sp60, &sp5C);
sp44 = this->actor.world.pos.y;

if (WaterBox_GetSurface1(play, &play->colCtx, sp4C.x, sp4C.z, &sp44, &sp58) &&
((sp44 - sp48) > 50.0f)) {
if (GameInteractor_Should(
VB_LINK_DIVE_OVER_WATER,
WaterBox_GetSurface1(play, &play->colCtx, sp4C.x, sp4C.z, &sp44, &sp58) &&
((sp44 - sp48) > 50.0f))) {
func_80834DB8(this, &gPlayerAnim_link_normal_run_jump_water_fall, 6.0f, play);
Player_SetAction(play, this, Player_Action_27, 0);
return;
Expand Down

0 comments on commit 3196bf7

Please sign in to comment.