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>
This commit is contained in:
Josh Bodner 2022-10-20 20:55:15 -07:00 committed by GitHub
commit 4fb78f9caa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 18 deletions

View file

@ -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;

View file

@ -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;