summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bodner <30329717+jbodner09@users.noreply.github.com>2022-10-20 20:55:15 -0700
committerGitHub <noreply@github.com>2022-10-20 23:55:15 -0400
commit4fb78f9caa06efd7f1e716e6f032dc247c73d083 (patch)
treee52562bf1e879916c44ca3af3640952e2d92a805
parent262e036c22aa2078befc0445c630653de82d4e23 (diff)
Add toggle option for walk speed modifiers (#1783)
* Add toggle option for walk speed modifiers * Preserve toggle status between scene transitions * Apply suggestions from code review renaming from `gSpeedToggle` to `gWalkSpeedToggle` Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
-rw-r--r--soh/include/variables.h22
-rw-r--r--soh/soh/GameMenuBar.cpp1
-rw-r--r--soh/src/overlays/actors/ovl_player_actor/z_player.c51
-rw-r--r--soh/src/overlays/gamestates/ovl_opening/z_opening.c2
4 files changed, 58 insertions, 18 deletions
diff --git a/soh/include/variables.h b/soh/include/variables.h
index 2dc9d45f4..9a5fbad77 100644
--- a/soh/include/variables.h
+++ b/soh/include/variables.h
@@ -166,6 +166,8 @@ extern "C"
extern s32 gSystemArenaLogSeverity;
extern u8 __osPfsInodeCacheBank;
extern s32 __osPfsLastChannel;
+ extern u8 gWalkSpeedToggle1;
+ extern u8 gWalkSpeedToggle2;
extern const s16 D_8014A6C0[];
#define gTatumsPerBeat (D_8014A6C0[1])
@@ -211,16 +213,16 @@ extern "C"
extern volatile OSTime gRDPTotalTime;
extern FaultThreadStruct gFaultStruct;
-extern ActiveSound gActiveSounds[7][MAX_CHANNELS_PER_BANK]; // total size = 0xA8
-extern u8 gSoundBankMuted[];
-extern u8 D_801333F0;
-extern u8 gAudioSfxSwapOff;
-extern u16 gAudioSfxSwapSource[10];
-extern u16 gAudioSfxSwapTarget[10];
-extern u8 gAudioSfxSwapMode[10];
-extern unk_D_8016E750 D_8016E750[4];
-extern AudioContext gAudioContext;
-extern void(*D_801755D0)(void);
+ extern ActiveSound gActiveSounds[7][MAX_CHANNELS_PER_BANK]; // total size = 0xA8
+ extern u8 gSoundBankMuted[];
+ extern u8 D_801333F0;
+ extern u8 gAudioSfxSwapOff;
+ extern u16 gAudioSfxSwapSource[10];
+ extern u16 gAudioSfxSwapTarget[10];
+ extern u8 gAudioSfxSwapMode[10];
+ extern unk_D_8016E750 D_8016E750[4];
+ extern AudioContext gAudioContext;
+ extern void(*D_801755D0)(void);
extern u32 __osMalloc_FreeBlockTest_Enable;
extern Arena gSystemArena;
diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp
index 9735fcce5..defa34bb7 100644
--- a/soh/soh/GameMenuBar.cpp
+++ b/soh/soh/GameMenuBar.cpp
@@ -764,6 +764,7 @@ namespace GameMenuBar {
UIWidgets::PaddedEnhancementCheckbox("Enable walk speed modifiers", "gEnableWalkModify", true, false);
UIWidgets::Tooltip("Hold the assigned button to change the maximum walking speed\nTo change the assigned button, click Customize Game Controls");
if (CVar_GetS32("gEnableWalkModify", 0)) {
+ UIWidgets::PaddedEnhancementCheckbox("Toggle modifier instead of holding", "gWalkSpeedToggle", true, false);
UIWidgets::EnhancementSliderFloat("Modifier 1: %d %%", "##WalkMod1", "gWalkModifierOne", 0.0f, 5.0f, "", 1.0f, true);
UIWidgets::EnhancementSliderFloat("Modifier 2: %d %%", "##WalkMod2", "gWalkModifierTwo", 0.0f, 5.0f, "", 1.0f, true);
}
diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c
index 92e108a00..21d43654e 100644
--- a/soh/src/overlays/actors/ovl_player_actor/z_player.c
+++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c
@@ -1053,6 +1053,8 @@ static s8 sItemActionParams[] = {
};
static u8 sMaskMemory;
+u8 gWalkSpeedToggle1;
+u8 gWalkSpeedToggle2;
// Used to map action params to update functions
static s32 (*D_80853EDC[])(Player* this, GlobalContext* globalCtx) = {
@@ -6033,10 +6035,22 @@ void func_8083DFE0(Player* this, f32* arg1, s16* arg2) {
if (CVar_GetS32("gMMBunnyHood", 0) && this->currentMask == PLAYER_MASK_BUNNY) {
maxSpeed *= 1.5f;
- } else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) {
- maxSpeed *= CVar_GetFloat("gWalkModifierOne", 1.0f);
- } else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) {
- maxSpeed *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
+ }
+
+ if (CVar_GetS32("gEnableWalkModify", 0)) {
+ if (CVar_GetS32("gWalkSpeedToggle", 0)) {
+ if (gWalkSpeedToggle1) {
+ maxSpeed *= CVar_GetFloat("gWalkModifierOne", 1.0f);
+ } else if (gWalkSpeedToggle2) {
+ maxSpeed *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
+ }
+ } else {
+ if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) {
+ maxSpeed *= CVar_GetFloat("gWalkModifierOne", 1.0f);
+ } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) {
+ maxSpeed *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
+ }
+ }
}
this->linearVelocity = CLAMP(this->linearVelocity, -maxSpeed, maxSpeed);
@@ -7662,10 +7676,22 @@ void func_80842180(Player* this, GlobalContext* globalCtx) {
if (CVar_GetS32("gMMBunnyHood", 0) && this->currentMask == PLAYER_MASK_BUNNY) {
sp2C *= 1.5f;
- } else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) {
- sp2C *= CVar_GetFloat("gWalkModifierOne", 1.0f);
- } else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) {
- sp2C *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
+ }
+
+ if (CVar_GetS32("gEnableWalkModify", 0)) {
+ if (CVar_GetS32("gWalkSpeedToggle", 0)) {
+ if (gWalkSpeedToggle1) {
+ sp2C *= CVar_GetFloat("gWalkModifierOne", 1.0f);
+ } else if (gWalkSpeedToggle2) {
+ sp2C *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
+ }
+ } else {
+ if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) {
+ sp2C *= CVar_GetFloat("gWalkModifierOne", 1.0f);
+ } else if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) {
+ sp2C *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
+ }
+ }
}
func_8083DF68(this, sp2C, sp2A);
@@ -10956,6 +10982,15 @@ void Player_Update(Actor* thisx, GlobalContext* globalCtx) {
if (chaosEffectGravityLevel == GRAVITY_LEVEL_LIGHT) {
this->actor.gravity = -0.3f;
}
+
+ if (CVar_GetS32("gEnableWalkModify", 0) && CVar_GetS32("gWalkSpeedToggle", 0)) {
+ if (CHECK_BTN_ALL(sControlInput->press.button, BTN_MODIFIER1)) {
+ gWalkSpeedToggle1 = !gWalkSpeedToggle1;
+ }
+ if (CHECK_BTN_ALL(sControlInput->press.button, BTN_MODIFIER2)) {
+ gWalkSpeedToggle2 = !gWalkSpeedToggle2;
+ }
+ }
}
static struct_80858AC8 D_80858AC8;
diff --git a/soh/src/overlays/gamestates/ovl_opening/z_opening.c b/soh/src/overlays/gamestates/ovl_opening/z_opening.c
index 3b5beebd7..fb877bdc2 100644
--- a/soh/src/overlays/gamestates/ovl_opening/z_opening.c
+++ b/soh/src/overlays/gamestates/ovl_opening/z_opening.c
@@ -11,6 +11,8 @@ void Opening_SetupTitleScreen(OpeningContext* this) {
this->state.running = false;
gSaveContext.linkAge = 0;
gSaveContext.fileNum = 0xFF;
+ gWalkSpeedToggle1 = 0;
+ gWalkSpeedToggle2 = 0;
Sram_InitDebugSave();
gSaveContext.cutsceneIndex = 0xFFF3;
gSaveContext.sceneSetupIndex = 7;