Skip to content

Commit 463df67

Browse files
billsixKiritoDv
authored andcommitted
cheat - always fly on triple jump
1 parent 67e561c commit 463df67

6 files changed

Lines changed: 62 additions & 4 deletions

File tree

src/game/mario.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,12 @@ static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actio
789789
m->forwardVel *= 0.8f;
790790
break;
791791

792-
case ACT_FLYING_TRIPLE_JUMP:
793-
set_mario_y_vel_based_on_fspeed(m, 82.0f, 0.0f);
792+
case ACT_FLYING_TRIPLE_JUMP: {
793+
f32 launchVelocity = 82.0f;
794+
CALL_EVENT(FlyingTripleJumpLaunch, m, &launchVelocity);
795+
set_mario_y_vel_based_on_fspeed(m, launchVelocity, 0.0f);
794796
break;
797+
}
795798

796799
case ACT_WATER_JUMP:
797800
case ACT_HOLD_WATER_JUMP:

src/game/mario_actions_airborne.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "save_file.h"
1515
#include "rumble_init.h"
1616
#include "seq_ids.h"
17+
#include "port/hooks/list/PlayerEvent.h"
1718

1819
void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3) {
1920
s32 animFrame = m->marioObj->header.gfx.animInfo.animFrame;
@@ -1708,7 +1709,9 @@ s32 act_flying(struct MarioState *m) {
17081709
return set_mario_action(m, ACT_GROUND_POUND, 1);
17091710
}
17101711

1711-
if (!(m->flags & MARIO_WING_CAP)) {
1712+
bool canFly = (m->flags & MARIO_WING_CAP) != 0;
1713+
CALL_EVENT(FlyingActionUpdate, m, &canFly);
1714+
if (!canFly) {
17121715
if (m->area->camera->mode == CAMERA_MODE_BEHIND_MARIO) {
17131716
set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
17141717
}

src/game/mario_actions_moving.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "behavior_data.h"
1414
#include "rumble_init.h"
1515
#include "seq_ids.h"
16+
#include "port/hooks/list/PlayerEvent.h"
1617

1718
struct LandingAction {
1819
s16 numFrames;
@@ -146,7 +147,10 @@ void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction) {
146147
}
147148

148149
s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 actionArg) {
149-
if (m->flags & MARIO_WING_CAP) {
150+
bool useFlyingVariant = (m->flags & MARIO_WING_CAP) != 0;
151+
CALL_EVENT(SetTripleJumpAction, m, &useFlyingVariant);
152+
153+
if (useFlyingVariant) {
150154
return set_mario_action(m, ACT_FLYING_TRIPLE_JUMP, 0);
151155
} else if (m->forwardVel > 20.0f) {
152156
return set_mario_action(m, ACT_TRIPLE_JUMP, 0);

src/port/hooks/list/PlayerEvent.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ DEFINE_EVENT(PlayerExecuteAction,
4343
u32 arg;
4444
);
4545

46+
DEFINE_EVENT(SetTripleJumpAction,
47+
struct MarioState* m;
48+
bool* useFlyingVariant;
49+
);
50+
51+
DEFINE_EVENT(FlyingActionUpdate,
52+
struct MarioState* m;
53+
bool* canFly;
54+
);
55+
56+
DEFINE_EVENT(FlyingTripleJumpLaunch,
57+
struct MarioState* m;
58+
f32* launchVelocity;
59+
);
60+
4661
DEFINE_EVENT(ItemCollected,
4762
int16_t type;
4863
struct MarioState* marioState;

src/port/mods/PortEnhancements.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ void PortEnhancements_Init() {
8484
}
8585
});
8686

87+
REGISTER_LISTENER(SetTripleJumpAction, EVENT_PRIORITY_NORMAL, [](IEvent* event) {
88+
if (CVarGetInteger("gCheats.AlwaysFlyTripleJump", 0) == 0) {
89+
return;
90+
}
91+
SetTripleJumpAction* ev = (SetTripleJumpAction*)event;
92+
*ev->useFlyingVariant = true;
93+
});
94+
REGISTER_LISTENER(FlyingActionUpdate, EVENT_PRIORITY_NORMAL, [](IEvent* event) {
95+
if (CVarGetInteger("gCheats.AlwaysFlyTripleJump", 0) == 0) {
96+
return;
97+
}
98+
FlyingActionUpdate* ev = (FlyingActionUpdate*)event;
99+
*ev->canFly = true;
100+
});
101+
REGISTER_LISTENER(FlyingTripleJumpLaunch, EVENT_PRIORITY_NORMAL, [](IEvent* event) {
102+
if (CVarGetInteger("gCheats.FlyingTripleJumpHighLaunch", 0) == 0) {
103+
return;
104+
}
105+
FlyingTripleJumpLaunch* ev = (FlyingTripleJumpLaunch*)event;
106+
*ev->launchVelocity = 246.0f;
107+
});
108+
87109
auto OnDistanceFunc = [](IEvent* event) {
88110
if (CVarGetInteger("gEnhancements.DisableDrawDistance", 0) == 0) {
89111
return;
@@ -117,6 +139,9 @@ void PortEnhancements_Register() {
117139
REGISTER_EVENT(PlayerStartedDialog);
118140
REGISTER_EVENT(PlayerDeath);
119141
REGISTER_EVENT(PlayerExecuteAction);
142+
REGISTER_EVENT(SetTripleJumpAction);
143+
REGISTER_EVENT(FlyingActionUpdate);
144+
REGISTER_EVENT(FlyingTripleJumpLaunch);
120145

121146
// Register Rando Events
122147
REGISTER_EVENT(ItemCollected);

src/port/ui/GhostshipMenuEnhancements.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ void GhostshipMenu::AddMenuEnhancements() {
177177
.CVar(CVAR_CHEAT("PlayInDemo"))
178178
.RaceDisable(false)
179179
.Options(CheckboxOptions().Tooltip("Allows normal gameplay when a demo is playing."));
180+
AddWidget(path, "Always Fly on Triple Jump", WIDGET_CVAR_CHECKBOX)
181+
.CVar(CVAR_CHEAT("AlwaysFlyTripleJump"))
182+
.RaceDisable(false)
183+
.Options(CheckboxOptions().Tooltip("Triple jumping always starts flying, as if you always have the Wing Cap."));
184+
AddWidget(path, "Triple Jump High Launch", WIDGET_CVAR_CHECKBOX)
185+
.CVar(CVAR_CHEAT("FlyingTripleJumpHighLaunch"))
186+
.RaceDisable(false)
187+
.Options(CheckboxOptions().Tooltip("Flying triple jump launches 3x higher than normal."));
180188
}
181189

182190
} // namespace GhostshipGui

0 commit comments

Comments
 (0)