Skip to content

Commit

Permalink
reset bind rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
zweek committed Jan 25, 2023
1 parent efa1617 commit 63ee271
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/scripts/kb_act.lst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"blank" "=========================="
"blank" "RESETTING"
"blank" "=========================="
"restart;sv_cheats 0;set_loading_progress_detente #INTROSCREEN_HINT_PC #INTROSCREEN_HINT_CONSOLE" "Individual Level Reset"
"fgr" "Any% Reset"
"fgr;hr" "All Helmets Reset"
"hr" "Reset Helmets"
"sr_reset_il" "Individual Level Reset"
"sr_reset_anypercent" "Any% Reset"
"sr_reset_allhelmets" "All Helmets Reset"
"resethelmets" "Reset Helmets"
"blank" "=========================="
"blank" "#KEY_BINDINGS_HEADER_ACTIONS"
"blank" "=========================="
Expand Down
1 change: 1 addition & 0 deletions src/scripts/vscripts/scripts.rson
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ Scripts:
[
sp/_savegame.gnut
sp/srmm_savestates.nut
sp/srmm_resets.nut
_trigger_functions_sp.gnut
_script_movers.gnut
sp/_ai_sp.gnut
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/vscripts/sp/_savegame.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void function InitSaveGame()
FlagInit( "SaveRequires_PlayerIsTitan" )
AddClientCommandCallback( "RestartFromLevelTransition", RestartFromLevelTransition )
AddClientCommandCallback( "RespawnNowSP", RespawnNowSP )
AddCallback_OnClientConnected( SaveStateInit )
AddCallback_OnClientConnected( SRMM_SaveStateInit )
AddCallback_OnClientConnected( SRMM_ResetsInit )
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
47 changes: 47 additions & 0 deletions src/scripts/vscripts/sp/srmm_resets.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// untyped
global function SRMM_ResetsInit

void function SRMM_ResetsInit ( entity player )
{
AddClientCommandCallback( "sr_reset_il", Pressed_ResetIL )
AddClientCommandCallback( "sr_reset_anypercent", Pressed_ResetAnyPercent )
AddClientCommandCallback( "sr_reset_allhelmets", Pressed_ResetAllHelmets )
AddClientCommandCallback( "resethelmets", Pressed_ResetCollectibles )

// aliases to shorten commands since there's a limit to the string length (hr = helmet reset, fgr = full game reset, lp = load prompt)
// ClientCommand("alias hr \"sp_unlocks_level_0 0;sp_unlocks_level_1 0;sp_unlocks_level_2 0;sp_unlocks_level_3 0;sp_unlocks_level_4 0;sp_unlocks_level_5 0;sp_unlocks_level_6 0;sp_unlocks_level_7 0;sp_unlocks_level_8 0;sp_unlocks_level_9 0;sp_unlocks_level_10 0;sp_unlocks_level_11 0;sp_unlocks_level_12 0;sp_unlocks_level_13 0;sp_unlocks_level_14 0\"")
ClientCommand( player, "alias fgr \"sp_startpoint 0;map sp_training;sp_difficulty 0;sv_cheats 0;\"" )
ClientCommand( player, "alias lp \"set_loading_progress_detente #INTROSCREEN_HINT_PC #INTROSCREEN_HINT_CONSOLE\"" )
}

bool function Pressed_ResetIL ( entity player, array<string> args )
{
if ( !SRMM_getSetting(SRMM_settings.practiceMode) ) {
SetConVarInt( "sv_cheats", 0 )
}
ClientCommand( player, "restart; lp" )
return true
}

bool function Pressed_ResetAnyPercent ( entity player, array<string> args )
{
ClientCommand( player, "fgr; lp" )
SRMM_setSetting( SRMM_settings.practiceMode, false )
SetConVarFloat("player_respawnInputDebounceDuration", 0.5)
return true
}

bool function Pressed_ResetAllHelmets ( entity player, array<string> args )
{
ResetCollectiblesProgress_All()
ClientCommand( player, "fgr; lp" )
SRMM_setSetting( SRMM_settings.practiceMode, false )
SetConVarFloat("player_respawnInputDebounceDuration", 0.5)
return true
}

bool function Pressed_ResetCollectibles ( entity player, array<string> args )
{
ResetCollectiblesProgress_All()
return true
}
26 changes: 13 additions & 13 deletions src/scripts/vscripts/srmm_h.nut
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ global enum SRMM_settings {
CKfix,
}

global string srmmVersion = "SRMM v2.4"
global string srmmVersion = "SRMM v2.4.1"

bool function SRMM_getSetting(int i) {
if ((GetConVarInt("voice_forcemicrecord") & (1 << i)) > 0) {
bool function SRMM_getSetting( int i ) {
if ( (GetConVarInt( "voice_forcemicrecord" ) & (1 << i)) > 0 ) {
return true
}
return false
}

void function SRMM_setSetting(int i, int value) {
int settings = GetConVarInt("voice_forcemicrecord")
if (value == 1) {
void function SRMM_setSetting( int i, bool enableSetting ) {
int settings = GetConVarInt( "voice_forcemicrecord" )
if ( enableSetting ) {
// set bit at position i to 1
SetConVarInt("voice_forcemicrecord", settings | (1 << i))
} else if (value == 0) {
SetConVarInt( "voice_forcemicrecord", settings | (1 << i) )
} else {
// set bit at position i to 0
SetConVarInt("voice_forcemicrecord", settings & ~(1 << i))
} else return
SetConVarInt( "voice_forcemicrecord", settings & ~(1 << i) )
}
}

void function SRMM_toggleSetting(int i) {
int settings = GetConVarInt("voice_forcemicrecord")
SetConVarInt("voice_forcemicrecord", settings ^ (1 << i))
void function SRMM_toggleSetting( int i ) {
int settings = GetConVarInt( "voice_forcemicrecord" )
SetConVarInt( "voice_forcemicrecord", settings ^ (1 << i) )
}
7 changes: 0 additions & 7 deletions src/scripts/vscripts/ui/menu_main.nut
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ struct

void function InitMainMenu()
{
// helmet reset
ClientCommand("alias hr \"sp_unlocks_level_0 0;sp_unlocks_level_1 0;sp_unlocks_level_2 0;sp_unlocks_level_3 0;sp_unlocks_level_4 0;sp_unlocks_level_5 0;sp_unlocks_level_6 0;sp_unlocks_level_7 0;sp_unlocks_level_8 0;sp_unlocks_level_9 0;sp_unlocks_level_10 0;sp_unlocks_level_11 0;sp_unlocks_level_12 0;sp_unlocks_level_13 0;sp_unlocks_level_14 0\"")
// full game reset
ClientCommand("alias fgr \"sp_startpoint 0;map sp_training;sp_difficulty 0;sv_cheats 0;set_loading_progress_detente #INTROSCREEN_HINT_PC #INTROSCREEN_HINT_CONSOLE\"")
// loadprompt
ClientCommand("alias lp \"set_loading_progress_detente #INTROSCREEN_HINT_PC #INTROSCREEN_HINT_CONSOLE\"")

RegisterSignal( "EndOnMainMenu_Open" )

var menu = GetMenu( "MainMenu" )
Expand Down

0 comments on commit 63ee271

Please sign in to comment.