Skip to content

Commit

Permalink
Tweak infinite deku hops to stop velocity loss while in the air
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox committed Jan 25, 2025
1 parent 9d5e05b commit dc49212
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion mm/2s2h/BenGui/BenMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ void BenMenu::AddEnhancements() {
"launching out of a deku flower"));
AddWidget(path, "Infinite Deku Hopping", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Player.InfiniteDekuHopping")
.Options(CheckboxOptions().Tooltip("Allows Deku Link to hop indefinitely in water without drowning."));
.Options(CheckboxOptions().Tooltip("Allows Deku Link to hop indefinitely in water without drowning. This also "
"prevents the velocity loss while in the air."));
AddWidget(path, "Instant Putaway", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Player.InstantPutaway")
.Options(CheckboxOptions().Tooltip("Allows Link to instantly puts away held item without waiting."));
Expand Down
10 changes: 10 additions & 0 deletions mm/2s2h/Enhancements/Player/InfiniteDekuHopping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ void RegisterInfiniteDekuHopping() {
player->remainingHopsCounter = 5;
}
});

COND_VB_SHOULD(VB_APPLY_AIR_CONTROL, CVAR, {
f32* dekuSpeedTargetMultiplier = va_arg(args, f32*);
Player* player = GET_PLAYER(gPlayState);

if (player->transformation == PLAYER_FORM_DEKU && player->stateFlags3 & PLAYER_STATE3_200000) {
// Deku Link's air control speedTarget gets halved, so we negate that by doubling it when deku hopping
*dekuSpeedTargetMultiplier *= 2.0f;
}
});
}

static RegisterShipInitFunc initFunc(RegisterInfiniteDekuHopping, { CVAR_NAME });
6 changes: 4 additions & 2 deletions mm/2s2h/Enhancements/Restorations/FlipHopVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ extern "C" {
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterVariableFlipHop() {
COND_VB_SHOULD(VB_FLIP_HOP_VARIABLE, CVAR, {
COND_VB_SHOULD(VB_APPLY_AIR_CONTROL, CVAR, {
Player* player = GET_PLAYER(gPlayState);

if (player->stateFlags2 & PLAYER_STATE2_80000) {
if (player->stateFlags2 & PLAYER_STATE2_80000 &&
// Deku Hopping last hop is considered a backflip/sidehop so we make sure they aren't deku hopping
!(player->transformation == PLAYER_FORM_DEKU && player->stateFlags3 & PLAYER_STATE3_200000)) {
*should = false;
}
});
Expand Down
2 changes: 1 addition & 1 deletion mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef enum {
VB_TATL_INTERUPT_MSG3,
VB_TATL_INTERUPT_MSG6,
VB_ITEM_BE_RESTRICTED,
VB_FLIP_HOP_VARIABLE,
VB_APPLY_AIR_CONTROL,
VB_DISABLE_LETTERBOX,
VB_CLOCK_TOWER_OPENING_CONSIDER_THIS_FIRST_CYCLE,
VB_DRAW_SLIME_BODY_ITEM,
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 @@ -15016,7 +15016,9 @@ void Player_Action_25(Player* this, PlayState* play) {
s16 prevYaw = this->currentYaw;

func_808378FC(play, this);
func_8083CBC4(this, speedTarget * 0.5f, yawTarget, 2.0f, 0.2f, 0.1f, 0x190);
if (GameInteractor_Should(VB_APPLY_AIR_CONTROL, true, &speedTarget)) {
func_8083CBC4(this, speedTarget * 0.5f, yawTarget, 2.0f, 0.2f, 0.1f, 0x190);
}

if (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_pn_attack)) {
this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40);
Expand All @@ -15026,7 +15028,7 @@ void Player_Action_25(Player* this, PlayState* play) {
Math_StepToF(&this->unk_B10[1], 0.0f, this->unk_B10[0]);
}
} else {
if (GameInteractor_Should(VB_FLIP_HOP_VARIABLE, true)) {
if (GameInteractor_Should(VB_APPLY_AIR_CONTROL, true, &speedTarget)) {
func_8083CBC4(this, speedTarget, yawTarget, 1.0f, 0.05f, 0.1f, 0xC8);
}
}
Expand Down

0 comments on commit dc49212

Please sign in to comment.