diff --git a/main/source/cl_dll/hud.cpp b/main/source/cl_dll/hud.cpp index e5b95de3..1be79cda 100644 --- a/main/source/cl_dll/hud.cpp +++ b/main/source/cl_dll/hud.cpp @@ -34,6 +34,10 @@ #include "mod/AvHNetworkMessages.h" #include "ui/ChatPanel.h" +// tankefugl: duck toggle +bool g_bDuckToggled; +// :tankefugl + class CHLVoiceStatusHelper : public IVoiceStatusHelper { public: @@ -192,6 +196,10 @@ void CHud :: Init( void ) m_iLogo = 0; m_iFOV = 0; + // tankefugl: duck toggle + g_bDuckToggled = false; + // :tankefugl + CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); default_fov = CVAR_CREATE( "default_fov", "90", 0 ); m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); diff --git a/main/source/cl_dll/hud_msg.cpp b/main/source/cl_dll/hud_msg.cpp index a672cfb6..f3c64ca9 100644 --- a/main/source/cl_dll/hud_msg.cpp +++ b/main/source/cl_dll/hud_msg.cpp @@ -21,6 +21,10 @@ #include "common/r_efx.h" #include "mod/AvHNetworkMessages.h" +// tankefugl: duck toggle +extern bool g_bDuckToggled; +// :tankefugl + #define MAX_CLIENTS 32 #if !defined( _TFC ) @@ -46,6 +50,10 @@ int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) // reset sensitivity m_flMouseSensitivity = 0; + // tankefugl: duck toggle + g_bDuckToggled = false; + // :tankefugl + return 0; } diff --git a/main/source/cl_dll/input.cpp b/main/source/cl_dll/input.cpp index 31882ea1..9a31d67d 100644 --- a/main/source/cl_dll/input.cpp +++ b/main/source/cl_dll/input.cpp @@ -61,6 +61,10 @@ extern "C" #include "engine/APIProxy.h" #include "Exports.h" +// tankefugl: duck toggle +extern bool g_bDuckToggled; +// :tankefugl + extern int g_iAlive; extern int g_weaponselect; @@ -790,6 +794,12 @@ void IN_DuckDown(void) } void IN_DuckUp(void) {KeyUp(&in_duck);} +// tankefugl: duck toggle +void IN_DuckToggle(void) +{ + g_bDuckToggled = !g_bDuckToggled; +} +// :tankefugl void IN_ReloadDown(void) {KeyDown(&in_reload);} void IN_ReloadUp(void) {KeyUp(&in_reload);} void IN_Alt1Down(void) {KeyDown(&in_alt1);} @@ -1318,11 +1328,20 @@ int CL_ButtonBits( int bResetState ) bits |= IN_ATTACK; } - if (in_duck.state & 3) + // tankefugl: duck toggle + if ( g_bDuckToggled ) + { + if (!(in_duck.state & 3)) + { + bits |= IN_DUCK; + } + } + else if (in_duck.state & 3) { bits |= IN_DUCK; } - + // :tankefugl + if (in_jump.state & 3) { bits |= IN_JUMP; @@ -1489,6 +1508,9 @@ void InitInput (void) gEngfuncs.pfnAddCommand ("-jlook", IN_JLookUp); gEngfuncs.pfnAddCommand ("+duck", IN_DuckDown); gEngfuncs.pfnAddCommand ("-duck", IN_DuckUp); + // tankefugl: duck toggle + gEngfuncs.pfnAddCommand ("toggleduck", IN_DuckToggle); + // :tankefugl gEngfuncs.pfnAddCommand ("+reload", IN_ReloadDown); gEngfuncs.pfnAddCommand ("-reload", IN_ReloadUp); gEngfuncs.pfnAddCommand ("+alt1", IN_Alt1Down);