From ba730be6b6bab967391114e981ff34bcede305a4 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 14 Aug 2019 03:03:27 +0000 Subject: [PATCH] Add Crouch Toggle gamefunc git-svn-id: https://svn.eduke32.com/eduke32@7978 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/_functio.h | 3 +++ source/duke3d/src/function.h | 3 ++- source/duke3d/src/game.cpp | 7 +++++++ source/duke3d/src/gamedef.h | 1 + source/duke3d/src/gamestructures.cpp | 3 +++ source/duke3d/src/player.cpp | 2 +- source/duke3d/src/player.h | 4 +++- 7 files changed, 20 insertions(+), 3 deletions(-) diff --git a/source/duke3d/src/_functio.h b/source/duke3d/src/_functio.h index 830f44ed0..87cfcb937 100644 --- a/source/duke3d/src/_functio.h +++ b/source/duke3d/src/_functio.h @@ -116,6 +116,7 @@ char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] = "Quick_Load", "Alt_Weapon", "Third_Person_View", + "Crouch_Toggle", }; #ifdef __SETUP__ @@ -184,6 +185,7 @@ const char keydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = "F9", "", "", "", "F7", "", + "", "", }; const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = @@ -250,6 +252,7 @@ const char oldkeydefaults[NUMGAMEFUNCTIONS*2][MAXGAMEFUNCLEN] = "F9", "", "", "", "F7", "", + "", "", }; static const char * mousedefaults[MAXMOUSEBUTTONS] = diff --git a/source/duke3d/src/function.h b/source/duke3d/src/function.h index 7ef17ef4a..fc0414f98 100644 --- a/source/duke3d/src/function.h +++ b/source/duke3d/src/function.h @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. extern "C" { #endif -#define NUMGAMEFUNCTIONS 62 +#define NUMGAMEFUNCTIONS 63 #define MAXGAMEFUNCLEN 32 extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; @@ -105,6 +105,7 @@ enum GameFunction_t gamefunc_Quick_Load, gamefunc_Alt_Weapon, gamefunc_Third_Person_View, + gamefunc_Crouch_Toggle, }; #ifdef __cplusplus } diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 78ffe9d49..d7c060ab3 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5060,6 +5060,12 @@ FAKE_F3: P_DoQuote(QUOTE_RUN_MODE_OFF + ud.auto_run, &myplayer); } + if (BUTTON(gamefunc_Crouch_Toggle)) + { + CONTROL_ClearButton(gamefunc_Crouch_Toggle); + myplayer.crouch_toggle = !myplayer.crouch_toggle; + } + if (BUTTON(gamefunc_Map)) { CONTROL_ClearButton(gamefunc_Map); @@ -7392,4 +7398,5 @@ static void G_SetupGameButtons(void) CONTROL_DefineFlag(gamefunc_Quick_Load, FALSE); CONTROL_DefineFlag(gamefunc_Alt_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Third_Person_View, FALSE); + CONTROL_DefineFlag(gamefunc_Crouch_Toggle, FALSE); } diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index e04175452..0e5bba1c2 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -450,6 +450,7 @@ enum PlayerLabel_t PLAYER_DEATHS, PLAYER_LAST_USED_WEAPON, PLAYER_BSUBWEAPON, + PLAYER_CROUCH_TOGGLE, PLAYER_END }; diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index a1ce77ca6..e0c22483f 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -544,6 +544,7 @@ const memberlabel_t PlayerLabels[]= { "deaths", PLAYER_DEATHS, 0, 0, -1 }, { "last_used_weapon", PLAYER_LAST_USED_WEAPON, 0, 0, -1 }, { "bsubweapon", PLAYER_BSUBWEAPON, LABEL_HASPARM2, MAX_WEAPONS, -1 }, + { "crouch_toggle", PLAYER_CROUCH_TOGGLE, 0, 0, -1 }, }; int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const lParm2) @@ -592,6 +593,7 @@ int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const case PLAYER_CHEAT_PHASE: labelNum = ps.cheat_phase; break; case PLAYER_CLIPDIST: labelNum = ps.clipdist; break; case PLAYER_CRACK_TIME: labelNum = ps.crack_time; break; + case PLAYER_CROUCH_TOGGLE: labelNum = ps.crouch_toggle; break; case PLAYER_CURR_WEAPON: labelNum = ps.curr_weapon; break; case PLAYER_CURSECTNUM: labelNum = ps.cursectnum; break; case PLAYER_CUSTOMEXITSOUND: labelNum = ps.customexitsound; break; @@ -785,6 +787,7 @@ void __fastcall VM_SetPlayer(int const playerNum, int const labelNum, int const case PLAYER_CHEAT_PHASE: ps.cheat_phase = newValue; break; case PLAYER_CLIPDIST: ps.clipdist = newValue; break; case PLAYER_CRACK_TIME: ps.crack_time = newValue; break; + case PLAYER_CROUCH_TOGGLE: ps.crouch_toggle = newValue; break; case PLAYER_CURR_WEAPON: ps.curr_weapon = newValue; break; case PLAYER_CURSECTNUM: ps.cursectnum = newValue; break; case PLAYER_CUSTOMEXITSOUND: ps.customexitsound = newValue; break; diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index fee0afd4c..0d17024db 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -3051,7 +3051,7 @@ void P_GetInput(int const playerNum) localInput.bits |= (BUTTON(gamefunc_Open) << SK_OPEN); - localInput.bits |= (BUTTON(gamefunc_Jump) << SK_JUMP) | (BUTTON(gamefunc_Crouch) << SK_CROUCH); + localInput.bits |= (BUTTON(gamefunc_Jump) << SK_JUMP) | ((BUTTON(gamefunc_Crouch)|pPlayer->crouch_toggle) << SK_CROUCH); localInput.bits |= (BUTTON(gamefunc_Aim_Up) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP; localInput.bits |= (BUTTON(gamefunc_Aim_Down) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN; diff --git a/source/duke3d/src/player.h b/source/duke3d/src/player.h index 393a85d9b..086340fb7 100644 --- a/source/duke3d/src/player.h +++ b/source/duke3d/src/player.h @@ -215,7 +215,9 @@ typedef struct { // anywhere (like with spritetype_t): g_player[i].ps->wa.idx == i. struct { int32_t idx; } wa; #endif - int8_t padding_[2]; + + int8_t crouch_toggle; + int8_t padding_[1]; } DukePlayer_t; // KEEPINSYNC lunatic/_defs_game.lua