diff --git a/.gitignore b/.gitignore index 953afe8..7edb6c9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ !lib/public/SDL2.lib !utils/procinfo/lib/win32_vc6/procinfo.lib !utils/vgui/lib/win32_vc6/vgui.lib +.vs/ \ No newline at end of file diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json deleted file mode 100644 index 0cf5ea5..0000000 --- a/.vs/ProjectSettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "CurrentProjectSetting": "No Configurations" -} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index 534fb54..0000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ExpandedNodes": [ - "", - "\\projects", - "\\projects\\vs2019" - ], - "SelectedNode": "\\projects\\vs2019\\projects.sln", - "PreviewInSolutionExplorer": false -} \ No newline at end of file diff --git a/.vs/halflife-won/v16/.suo b/.vs/halflife-won/v16/.suo deleted file mode 100644 index 02a8ce5..0000000 Binary files a/.vs/halflife-won/v16/.suo and /dev/null differ diff --git a/.vs/halflife-won/v16/Browse.VC.db b/.vs/halflife-won/v16/Browse.VC.db deleted file mode 100644 index a94598b..0000000 Binary files a/.vs/halflife-won/v16/Browse.VC.db and /dev/null differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite deleted file mode 100644 index a2309d0..0000000 Binary files a/.vs/slnx.sqlite and /dev/null differ diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 7f8e257..15b7414 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -867,7 +867,7 @@ int CHudAmmo::Draw(float flTime) if (m_fFade > 0) m_fFade -= (gHUD.m_flTimeDelta * 20); - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); ScaleColors(r, g, b, a ); @@ -896,7 +896,7 @@ int CHudAmmo::Draw(float flTime) x += AmmoWidth/2; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); // draw the | bar FillRGBA(x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a); @@ -969,7 +969,7 @@ int DrawBar(int x, int y, int width, int height, float f) width -= w; } - UnpackRGB(r, g, b, RGB_YELLOWISH); + UnpackRGB(r, g, b, RGB_DEFAULT); FillRGBA(x, y, width, height, r, g, b, 128); @@ -1045,7 +1045,7 @@ int CHudAmmo::DrawWList(float flTime) { int iWidth; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); if ( iActiveSlot == i ) a = 255; @@ -1097,7 +1097,7 @@ int CHudAmmo::DrawWList(float flTime) if ( !p || !p->iId ) continue; - UnpackRGB( r,g,b, RGB_YELLOWISH ); + UnpackRGB( r,g,b, RGB_DEFAULT ); // if active, then we must have ammo. @@ -1117,7 +1117,7 @@ int CHudAmmo::DrawWList(float flTime) ScaleColors(r, g, b, 192); else { - UnpackRGB(r,g,b, RGB_REDISH); + UnpackRGB(r,g,b, RGB_GREY); ScaleColors(r, g, b, 128); } @@ -1139,7 +1139,7 @@ int CHudAmmo::DrawWList(float flTime) { // Draw Row of weapons. - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); for ( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) { @@ -1150,12 +1150,12 @@ int CHudAmmo::DrawWList(float flTime) if ( gWR.HasAmmo(p) ) { - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); a = 128; } else { - UnpackRGB(r,g,b, RGB_REDISH); + UnpackRGB(r,g,b, RGB_GREY); a = 96; } diff --git a/cl_dll/ammo_secondary.cpp b/cl_dll/ammo_secondary.cpp index 52b1bdf..c707dbd 100644 --- a/cl_dll/ammo_secondary.cpp +++ b/cl_dll/ammo_secondary.cpp @@ -60,7 +60,7 @@ int CHudAmmoSecondary :: Draw(float flTime) // draw secondary ammo icons above normal ammo readout int a, x, y, r, g, b, AmmoWidth; - UnpackRGB( r, g, b, RGB_YELLOWISH ); + UnpackRGB( r, g, b, RGB_DEFAULT ); a = (int) V_max( MIN_ALPHA, m_fFade ); if (m_fFade > 0) m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons diff --git a/cl_dll/ammohistory.cpp b/cl_dll/ammohistory.cpp index 8668fd4..a9adf14 100644 --- a/cl_dll/ammohistory.cpp +++ b/cl_dll/ammohistory.cpp @@ -124,7 +124,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime ) HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic ); int r, g, b; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; ScaleColors(r, g, b, V_min(scale, 255) ); @@ -148,10 +148,10 @@ int HistoryResource :: DrawAmmoHistory( float flTime ) return 1; // we don't know about the weapon yet, so don't draw anything int r, g, b; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); if ( !gWR.HasAmmo( weap ) ) - UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red + UnpackRGB(r,g,b, RGB_GREY); // if the weapon doesn't have ammo, display it as red float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; ScaleColors(r, g, b, V_min(scale, 255) ); @@ -170,7 +170,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime ) wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId ); - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; ScaleColors(r, g, b, V_min(scale, 255) ); diff --git a/cl_dll/battery.cpp b/cl_dll/battery.cpp index 3af851c..4677630 100644 --- a/cl_dll/battery.cpp +++ b/cl_dll/battery.cpp @@ -103,7 +103,7 @@ int CHudBattery::Draw(float flTime) rc.top += m_iHeight * ((float)(100-(V_min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 #endif - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) return 1; diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index d12cfbd..edc01e1 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -111,9 +111,9 @@ int CHudFlashlight::Draw(float flTime) a = MIN_ALPHA; if (m_flBat < 0.20) - UnpackRGB(r,g,b, RGB_REDISH); + UnpackRGB(r,g,b, RGB_GREY); else - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); ScaleColors(r, g, b, a); diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index 4ddf815..794f8c8 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -156,7 +156,7 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b ) #else if (m_iHealth > 25) { - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); } else { @@ -372,7 +372,7 @@ int CHudHealth::DrawDamage(float flTime) if (!m_bitsDamage) return 1; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); a = (int)( fabs(sin(flTime*2)) * 256.0); diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 45bde6d..5be19e7 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -83,8 +83,8 @@ extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, i extern cvar_t *sensitivity; cvar_t *cl_lw = NULL; -cvar_t* cl_viewrollangle; -cvar_t* cl_viewrollspeed; +cvar_t* cl_rollangle; +cvar_t* cl_rollspeed; void ShutdownInput (void); @@ -321,10 +321,11 @@ void CHud :: Init( void ) // VGUI Menus HOOK_MESSAGE( VGUIMenu ); + cl_rollangle = CVAR_CREATE("cl_rollangle", "0.65", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cl_rollspeed = CVAR_CREATE("cl_rollspeed", "300", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round - cl_viewrollangle = CVAR_CREATE("cl_viewrollangle", "0.65", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); - cl_viewrollspeed = CVAR_CREATE("cl_viewrollspeed", "300", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); m_iLogo = 0; diff --git a/cl_dll/hud.h b/cl_dll/hud.h index f91bd93..fd7b113 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -21,8 +21,8 @@ // // define HUD colors. hex codes are different here, rather than starting with "#" they start with "0x00" -#define RGB_YELLOWISH 0x000062ff //255,160,0 -#define RGB_REDISH 0x00FF1010 //255,160,0 +#define RGB_DEFAULT 0x003692f8 //54, 146, 248 +#define RGB_GREY 0x008e8f91 //255,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0 #ifndef _WIN32 diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index f749104..a70fc9e 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -1557,7 +1557,7 @@ void CHudSpectator::DrawOverviewEntities() z = m_OverviewData.layersHeights[0] * zScale; // get yellow/brown HUD color - UnpackRGB(ir,ig,ib, RGB_YELLOWISH); + UnpackRGB(ir,ig,ib, RGB_DEFAULT); r = (float)ir/255.0f; g = (float)ig/255.0f; b = (float)ib/255.0f; diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index d2fefd9..777a2d9 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -31,39 +31,39 @@ extern int g_weaponselect; extern cl_enginefunc_t gEngfuncs; // Defined in pm_math.c -float anglemod( float a ); +float anglemod(float a); -void IN_Init (void); -void IN_Move ( float frametime, usercmd_t *cmd); -void IN_Shutdown( void ); -void V_Init( void ); -void VectorAngles( const float *forward, float *angles ); -int CL_ButtonBits( int ); +void IN_Init(void); +void IN_Move(float frametime, usercmd_t* cmd); +void IN_Shutdown(void); +void V_Init(void); +void VectorAngles(const float* forward, float* angles); +int CL_ButtonBits(int); // xxx need client dll function to get and clear impuse -extern cvar_t *in_joystick; - -int in_impulse = 0; -int in_cancel = 0; - -cvar_t *m_pitch; -cvar_t *m_yaw; -cvar_t *m_forward; -cvar_t *m_side; - -cvar_t *lookstrafe; -cvar_t *lookspring; -cvar_t *cl_pitchup; -cvar_t *cl_pitchdown; -cvar_t *cl_upspeed; -cvar_t *cl_forwardspeed; -cvar_t *cl_backspeed; -cvar_t *cl_sidespeed; -cvar_t *cl_movespeedkey; -cvar_t *cl_yawspeed; -cvar_t *cl_pitchspeed; -cvar_t *cl_anglespeedkey; -cvar_t *cl_vsmoothing; +extern cvar_t* in_joystick; + +int in_impulse = 0; +int in_cancel = 0; + +cvar_t* m_pitch; +cvar_t* m_yaw; +cvar_t* m_forward; +cvar_t* m_side; + +cvar_t* lookstrafe; +cvar_t* lookspring; +cvar_t* cl_pitchup; +cvar_t* cl_pitchdown; +cvar_t* cl_upspeed; +cvar_t* cl_forwardspeed; +cvar_t* cl_backspeed; +cvar_t* cl_sidespeed; +cvar_t* cl_movespeedkey; +cvar_t* cl_yawspeed; +cvar_t* cl_pitchspeed; +cvar_t* cl_anglespeedkey; +cvar_t* cl_vsmoothing; /* =============================================================================== @@ -114,12 +114,12 @@ kbutton_t in_graph; // Display the netgraph typedef struct kblist_s { - struct kblist_s *next; - kbutton_t *pkey; + struct kblist_s* next; + kbutton_t* pkey; char name[32]; } kblist_t; -kblist_t *g_kbkeys = NULL; +kblist_t* g_kbkeys = NULL; /* ============ @@ -130,56 +130,56 @@ Removes references to +use and replaces them with the keyname in the output stri NOTE: Only works for text with +word in it. ============ */ -int KB_ConvertString( char *in, char **ppout ) +int KB_ConvertString(char* in, char** ppout) { - char sz[ 4096 ]; - char binding[ 64 ]; - char *p; - char *pOut; - char *pEnd; - const char *pBinding; - - if ( !ppout ) + char sz[4096]; + char binding[64]; + char* p; + char* pOut; + char* pEnd; + const char* pBinding; + + if (!ppout) return 0; *ppout = NULL; p = in; pOut = sz; - while ( *p ) + while (*p) { - if ( *p == '+' ) + if (*p == '+') { pEnd = binding; - while ( *p && ( isalnum( *p ) || ( pEnd == binding ) ) && ( ( pEnd - binding ) < 63 ) ) + while (*p && (isalnum(*p) || (pEnd == binding)) && ((pEnd - binding) < 63)) { *pEnd++ = *p++; } - *pEnd = '\0'; + *pEnd = '\0'; pBinding = NULL; - if ( strlen( binding + 1 ) > 0 ) + if (strlen(binding + 1) > 0) { // See if there is a binding for binding? - pBinding = gEngfuncs.Key_LookupBinding( binding + 1 ); + pBinding = gEngfuncs.Key_LookupBinding(binding + 1); } - if ( pBinding ) + if (pBinding) { *pOut++ = '['; - pEnd = (char *)pBinding; + pEnd = (char*)pBinding; } else { pEnd = binding; } - while ( *pEnd ) + while (*pEnd) { *pOut++ = *pEnd++; } - if ( pBinding ) + if (pBinding) { *pOut++ = ']'; } @@ -192,8 +192,8 @@ int KB_ConvertString( char *in, char **ppout ) *pOut = '\0'; - pOut = ( char * )malloc( strlen( sz ) + 1 ); - strcpy( pOut, sz ); + pOut = (char*)malloc(strlen(sz) + 1); + strcpy(pOut, sz); *ppout = pOut; return 1; @@ -206,15 +206,15 @@ KB_Find Allows the engine to get a kbutton_t directly ( so it can check +mlook state, etc ) for saving out to .cfg files ============ */ -struct kbutton_s DLLEXPORT *KB_Find( const char *name ) +struct kbutton_s DLLEXPORT* KB_Find(const char* name) { -// RecClFindKey(name); + // RecClFindKey(name); - kblist_t *p; + kblist_t* p; p = g_kbkeys; - while ( p ) + while (p) { - if ( !stricmp( name, p->name ) ) + if (!stricmp(name, p->name)) return p->pkey; p = p->next; @@ -229,20 +229,20 @@ KB_Add Add a kbutton_t * to the list of pointers the engine can retrieve via KB_Find ============ */ -void KB_Add( const char *name, kbutton_t *pkb ) +void KB_Add(const char* name, kbutton_t* pkb) { - kblist_t *p; - kbutton_t *kb; + kblist_t* p; + kbutton_t* kb; - kb = KB_Find( name ); - - if ( kb ) + kb = KB_Find(name); + + if (kb) return; - p = ( kblist_t * )malloc( sizeof( kblist_t ) ); - memset( p, 0, sizeof( *p ) ); + p = (kblist_t*)malloc(sizeof(kblist_t)); + memset(p, 0, sizeof(*p)); - strcpy( p->name, name ); + strcpy(p->name, name); p->pkey = pkb; p->next = g_kbkeys; @@ -256,13 +256,13 @@ KB_Init Add kbutton_t definitions that the engine can query if needed ============ */ -void KB_Init( void ) +void KB_Init(void) { g_kbkeys = NULL; - KB_Add( "in_graph", &in_graph ); - KB_Add( "in_mlook", &in_mlook ); - KB_Add( "in_jlook", &in_jlook ); + KB_Add("in_graph", &in_graph); + KB_Add("in_mlook", &in_mlook); + KB_Add("in_jlook", &in_jlook); } /* @@ -272,14 +272,14 @@ KB_Shutdown Clear kblist ============ */ -void KB_Shutdown( void ) +void KB_Shutdown(void) { - kblist_t *p, *n; + kblist_t* p, * n; p = g_kbkeys; - while ( p ) + while (p) { n = p->next; - free( p ); + free(p); p = n; } g_kbkeys = NULL; @@ -290,10 +290,10 @@ void KB_Shutdown( void ) KeyDown ============ */ -void KeyDown (kbutton_t *b) +void KeyDown(kbutton_t* b) { int k; - char *c; + char* c; c = gEngfuncs.Cmd_Argv(1); if (c[0]) @@ -303,17 +303,17 @@ void KeyDown (kbutton_t *b) if (k == b->down[0] || k == b->down[1]) return; // repeating key - + if (!b->down[0]) b->down[0] = k; else if (!b->down[1]) b->down[1] = k; else { - gEngfuncs.Con_DPrintf ("Three keys down for a button '%c' '%c' '%c'!\n", b->down[0], b->down[1], c); + gEngfuncs.Con_DPrintf("Three keys down for a button '%c' '%c' '%c'!\n", b->down[0], b->down[1], c); return; } - + if (b->state & 1) return; // still down b->state |= 1 + 2; // down + impulse down @@ -324,11 +324,11 @@ void KeyDown (kbutton_t *b) KeyUp ============ */ -void KeyUp (kbutton_t *b) +void KeyUp(kbutton_t* b) { int k; - char *c; - + char* c; + c = gEngfuncs.Cmd_Argv(1); if (c[0]) k = atoi(c); @@ -365,91 +365,91 @@ HUD_Key_Event Return 1 to allow engine to process the key, otherwise, act on it as needed ============ */ -int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding ) +int DLLEXPORT HUD_Key_Event(int down, int keynum, const char* pszCurrentBinding) { -// RecClKeyEvent(down, keynum, pszCurrentBinding); + // RecClKeyEvent(down, keynum, pszCurrentBinding); if (gViewPort) return gViewPort->KeyInput(down, keynum, pszCurrentBinding); - + return 1; } -void IN_BreakDown( void ) { KeyDown( &in_break );}; -void IN_BreakUp( void ) { KeyUp( &in_break ); }; -void IN_KLookDown (void) {KeyDown(&in_klook);} -void IN_KLookUp (void) {KeyUp(&in_klook);} -void IN_JLookDown (void) {KeyDown(&in_jlook);} -void IN_JLookUp (void) {KeyUp(&in_jlook);} -void IN_MLookDown (void) {KeyDown(&in_mlook);} -void IN_UpDown(void) {KeyDown(&in_up);} -void IN_UpUp(void) {KeyUp(&in_up);} -void IN_DownDown(void) {KeyDown(&in_down);} -void IN_DownUp(void) {KeyUp(&in_down);} -void IN_LeftDown(void) {KeyDown(&in_left);} -void IN_LeftUp(void) {KeyUp(&in_left);} -void IN_RightDown(void) {KeyDown(&in_right);} -void IN_RightUp(void) {KeyUp(&in_right);} +void IN_BreakDown(void) { KeyDown(&in_break); }; +void IN_BreakUp(void) { KeyUp(&in_break); }; +void IN_KLookDown(void) { KeyDown(&in_klook); } +void IN_KLookUp(void) { KeyUp(&in_klook); } +void IN_JLookDown(void) { KeyDown(&in_jlook); } +void IN_JLookUp(void) { KeyUp(&in_jlook); } +void IN_MLookDown(void) { KeyDown(&in_mlook); } +void IN_UpDown(void) { KeyDown(&in_up); } +void IN_UpUp(void) { KeyUp(&in_up); } +void IN_DownDown(void) { KeyDown(&in_down); } +void IN_DownUp(void) { KeyUp(&in_down); } +void IN_LeftDown(void) { KeyDown(&in_left); } +void IN_LeftUp(void) { KeyUp(&in_left); } +void IN_RightDown(void) { KeyDown(&in_right); } +void IN_RightUp(void) { KeyUp(&in_right); } void IN_ForwardDown(void) { KeyDown(&in_forward); - gHUD.m_Spectator.HandleButtonsDown( IN_FORWARD ); + gHUD.m_Spectator.HandleButtonsDown(IN_FORWARD); } void IN_ForwardUp(void) { KeyUp(&in_forward); - gHUD.m_Spectator.HandleButtonsUp( IN_FORWARD ); + gHUD.m_Spectator.HandleButtonsUp(IN_FORWARD); } void IN_BackDown(void) { KeyDown(&in_back); - gHUD.m_Spectator.HandleButtonsDown( IN_BACK ); + gHUD.m_Spectator.HandleButtonsDown(IN_BACK); } void IN_BackUp(void) { KeyUp(&in_back); - gHUD.m_Spectator.HandleButtonsUp( IN_BACK ); + gHUD.m_Spectator.HandleButtonsUp(IN_BACK); } -void IN_LookupDown(void) {KeyDown(&in_lookup);} -void IN_LookupUp(void) {KeyUp(&in_lookup);} -void IN_LookdownDown(void) {KeyDown(&in_lookdown);} -void IN_LookdownUp(void) {KeyUp(&in_lookdown);} +void IN_LookupDown(void) { KeyDown(&in_lookup); } +void IN_LookupUp(void) { KeyUp(&in_lookup); } +void IN_LookdownDown(void) { KeyDown(&in_lookdown); } +void IN_LookdownUp(void) { KeyUp(&in_lookdown); } void IN_MoveleftDown(void) { KeyDown(&in_moveleft); - gHUD.m_Spectator.HandleButtonsDown( IN_MOVELEFT ); + gHUD.m_Spectator.HandleButtonsDown(IN_MOVELEFT); } void IN_MoveleftUp(void) { KeyUp(&in_moveleft); - gHUD.m_Spectator.HandleButtonsUp( IN_MOVELEFT ); + gHUD.m_Spectator.HandleButtonsUp(IN_MOVELEFT); } void IN_MoverightDown(void) { KeyDown(&in_moveright); - gHUD.m_Spectator.HandleButtonsDown( IN_MOVERIGHT ); + gHUD.m_Spectator.HandleButtonsDown(IN_MOVERIGHT); } void IN_MoverightUp(void) { KeyUp(&in_moveright); - gHUD.m_Spectator.HandleButtonsUp( IN_MOVERIGHT ); + gHUD.m_Spectator.HandleButtonsUp(IN_MOVERIGHT); } -void IN_SpeedDown(void) {KeyDown(&in_speed);} -void IN_SpeedUp(void) {KeyUp(&in_speed);} -void IN_StrafeDown(void) {KeyDown(&in_strafe);} -void IN_StrafeUp(void) {KeyUp(&in_strafe);} +void IN_SpeedDown(void) { KeyDown(&in_speed); } +void IN_SpeedUp(void) { KeyUp(&in_speed); } +void IN_StrafeDown(void) { KeyDown(&in_strafe); } +void IN_StrafeUp(void) { KeyUp(&in_strafe); } // needs capture by hud/vgui also extern void __CmdFunc_InputPlayerSpecial(void); -void IN_Attack2Down(void) +void IN_Attack2Down(void) { KeyDown(&in_attack2); @@ -457,46 +457,46 @@ void IN_Attack2Down(void) __CmdFunc_InputPlayerSpecial(); #endif - gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK2 ); + gHUD.m_Spectator.HandleButtonsDown(IN_ATTACK2); } -void IN_Attack2Up(void) {KeyUp(&in_attack2);} -void IN_UseDown (void) +void IN_Attack2Up(void) { KeyUp(&in_attack2); } +void IN_UseDown(void) { KeyDown(&in_use); - gHUD.m_Spectator.HandleButtonsDown( IN_USE ); + gHUD.m_Spectator.HandleButtonsDown(IN_USE); } -void IN_UseUp (void) {KeyUp(&in_use);} -void IN_JumpDown (void) +void IN_UseUp(void) { KeyUp(&in_use); } +void IN_JumpDown(void) { KeyDown(&in_jump); - gHUD.m_Spectator.HandleButtonsDown( IN_JUMP ); + gHUD.m_Spectator.HandleButtonsDown(IN_JUMP); } -void IN_JumpUp (void) {KeyUp(&in_jump);} +void IN_JumpUp(void) { KeyUp(&in_jump); } void IN_DuckDown(void) { KeyDown(&in_duck); - gHUD.m_Spectator.HandleButtonsDown( IN_DUCK ); + gHUD.m_Spectator.HandleButtonsDown(IN_DUCK); } -void IN_DuckUp(void) {KeyUp(&in_duck);} -void IN_ReloadDown(void) {KeyDown(&in_reload);} -void IN_ReloadUp(void) {KeyUp(&in_reload);} -void IN_Alt1Down(void) {KeyDown(&in_alt1);} -void IN_Alt1Up(void) {KeyUp(&in_alt1);} -void IN_GraphDown(void) {KeyDown(&in_graph);} -void IN_GraphUp(void) {KeyUp(&in_graph);} +void IN_DuckUp(void) { KeyUp(&in_duck); } +void IN_ReloadDown(void) { KeyDown(&in_reload); } +void IN_ReloadUp(void) { KeyUp(&in_reload); } +void IN_Alt1Down(void) { KeyDown(&in_alt1); } +void IN_Alt1Up(void) { KeyUp(&in_alt1); } +void IN_GraphDown(void) { KeyDown(&in_graph); } +void IN_GraphUp(void) { KeyUp(&in_graph); } void IN_AttackDown(void) { - KeyDown( &in_attack ); - gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK ); + KeyDown(&in_attack); + gHUD.m_Spectator.HandleButtonsDown(IN_ATTACK); } void IN_AttackUp(void) { - KeyUp( &in_attack ); + KeyUp(&in_attack); in_cancel = 0; } @@ -506,15 +506,15 @@ void IN_Cancel(void) in_cancel = 1; } -void IN_Impulse (void) +void IN_Impulse(void) { - in_impulse = atoi( gEngfuncs.Cmd_Argv(1) ); + in_impulse = atoi(gEngfuncs.Cmd_Argv(1)); } void IN_ScoreDown(void) { KeyDown(&in_score); - if ( gViewPort ) + if (gViewPort) { gViewPort->ShowScoreBoard(); } @@ -523,16 +523,16 @@ void IN_ScoreDown(void) void IN_ScoreUp(void) { KeyUp(&in_score); - if ( gViewPort ) + if (gViewPort) { gViewPort->HideScoreBoard(); } } -void IN_MLookUp (void) +void IN_MLookUp(void) { - KeyUp( &in_mlook ); - if ( !( in_mlook.state & 1 ) && lookspring->value ) + KeyUp(&in_mlook); + if (!(in_mlook.state & 1) && lookspring->value) { V_StartPitchDrift(); } @@ -548,49 +548,49 @@ Returns 0.25 if a key was pressed and released during the frame, 1.0 if held for the entire time =============== */ -float CL_KeyState (kbutton_t *key) +float CL_KeyState(kbutton_t* key) { float val = 0.0; int impulsedown, impulseup, down; - + impulsedown = key->state & 2; - impulseup = key->state & 4; - down = key->state & 1; - - if ( impulsedown && !impulseup ) + impulseup = key->state & 4; + down = key->state & 1; + + if (impulsedown && !impulseup) { // pressed and held this frame? val = down ? 0.5 : 0.0; } - if ( impulseup && !impulsedown ) + if (impulseup && !impulsedown) { // released this frame? val = down ? 0.0 : 0.0; } - if ( !impulsedown && !impulseup ) + if (!impulsedown && !impulseup) { // held the entire frame? val = down ? 1.0 : 0.0; } - if ( impulsedown && impulseup ) + if (impulsedown && impulseup) { - if ( down ) + if (down) { // released and re-pressed this frame - val = 0.75; + val = 0.75; } else { // pressed and released this frame - val = 0.25; + val = 0.25; } } // clear impulses - key->state &= 1; + key->state &= 1; return val; } @@ -601,11 +601,11 @@ CL_AdjustAngles Moves the local angle positions ================ */ -void CL_AdjustAngles ( float frametime, float *viewangles ) +void CL_AdjustAngles(float frametime, float* viewangles) { float speed; float up, down; - + if (in_speed.state & 1) { speed = frametime * cl_anglespeedkey->value; @@ -617,26 +617,26 @@ void CL_AdjustAngles ( float frametime, float *viewangles ) if (!(in_strafe.state & 1)) { - viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right); - viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left); + viewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState(&in_right); + viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState(&in_left); viewangles[YAW] = anglemod(viewangles[YAW]); } if (in_klook.state & 1) { - V_StopPitchDrift (); - viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_forward); - viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_back); + V_StopPitchDrift(); + viewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState(&in_forward); + viewangles[PITCH] += speed * cl_pitchspeed->value * CL_KeyState(&in_back); } - - up = CL_KeyState (&in_lookup); + + up = CL_KeyState(&in_lookup); down = CL_KeyState(&in_lookdown); - - viewangles[PITCH] -= speed*cl_pitchspeed->value * up; - viewangles[PITCH] += speed*cl_pitchspeed->value * down; + + viewangles[PITCH] -= speed * cl_pitchspeed->value * up; + viewangles[PITCH] += speed * cl_pitchspeed->value * down; if (up || down) - V_StopPitchDrift (); - + V_StopPitchDrift(); + if (viewangles[PITCH] > cl_pitchdown->value) viewangles[PITCH] = cl_pitchdown->value; if (viewangles[PITCH] < -cl_pitchup->value) @@ -657,46 +657,46 @@ if active == 1 then we are 1) not playing back demos ( where our commands are ig 2 ) we have finished signing on to server ================ */ -void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active ) -{ -// RecClCL_CreateMove(frametime, cmd, active); +void DLLEXPORT CL_CreateMove(float frametime, struct usercmd_s* cmd, int active) +{ + // RecClCL_CreateMove(frametime, cmd, active); float spd; vec3_t viewangles; static vec3_t oldangles; - if ( active && !Bench_Active() ) + if (active && !Bench_Active()) { //memset( viewangles, 0, sizeof( vec3_t ) ); //viewangles[ 0 ] = viewangles[ 1 ] = viewangles[ 2 ] = 0.0; - gEngfuncs.GetViewAngles( (float *)viewangles ); + gEngfuncs.GetViewAngles((float*)viewangles); + + CL_AdjustAngles(frametime, viewangles); - CL_AdjustAngles ( frametime, viewangles ); + memset(cmd, 0, sizeof(*cmd)); - memset (cmd, 0, sizeof(*cmd)); - - gEngfuncs.SetViewAngles( (float *)viewangles ); + gEngfuncs.SetViewAngles((float*)viewangles); - if ( in_strafe.state & 1 ) + if (in_strafe.state & 1) { - cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right); - cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left); + cmd->sidemove += cl_sidespeed->value * CL_KeyState(&in_right); + cmd->sidemove -= cl_sidespeed->value * CL_KeyState(&in_left); } - cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright); - cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft); + cmd->sidemove += cl_sidespeed->value * CL_KeyState(&in_moveright); + cmd->sidemove -= cl_sidespeed->value * CL_KeyState(&in_moveleft); - cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up); - cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down); + cmd->upmove += cl_upspeed->value * CL_KeyState(&in_up); + cmd->upmove -= cl_upspeed->value * CL_KeyState(&in_down); - if ( !(in_klook.state & 1 ) ) - { - cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward); - cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back); - } + if (!(in_klook.state & 1)) + { + cmd->forwardmove += cl_forwardspeed->value * CL_KeyState(&in_forward); + cmd->forwardmove -= cl_backspeed->value * CL_KeyState(&in_back); + } // adjust for speed key - if ( in_speed.state & 1 ) + if (in_speed.state & 1) { cmd->forwardmove *= cl_movespeedkey->value; cmd->sidemove *= cl_movespeedkey->value; @@ -705,12 +705,12 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ // clip to maxspeed spd = gEngfuncs.GetClientMaxspeed(); - if ( spd != 0.0 ) + if (spd != 0.0) { // scale the 3 speeds so that the total velocity is not > cl.maxspeed - float fmov = sqrt( (cmd->forwardmove*cmd->forwardmove) + (cmd->sidemove*cmd->sidemove) + (cmd->upmove*cmd->upmove) ); + float fmov = sqrt((cmd->forwardmove * cmd->forwardmove) + (cmd->sidemove * cmd->sidemove) + (cmd->upmove * cmd->upmove)); - if ( fmov > spd ) + if (fmov > spd) { float fratio = spd / fmov; cmd->forwardmove *= fratio; @@ -720,7 +720,7 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ } // Allow mice and other controllers to add their inputs - IN_Move ( frametime, cmd ); + IN_Move(frametime, cmd); } cmd->impulse = in_impulse; @@ -731,39 +731,39 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ // // set button and flag bits // - cmd->buttons = CL_ButtonBits( 1 ); + cmd->buttons = CL_ButtonBits(1); // If they're in a modal dialog, ignore the attack button. - if(GetClientVoiceMgr()->IsInSquelchMode()) + if (GetClientVoiceMgr()->IsInSquelchMode()) cmd->buttons &= ~IN_ATTACK; // Using joystick? - if ( in_joystick->value ) + if (in_joystick->value) { - if ( cmd->forwardmove > 0 ) + if (cmd->forwardmove > 0) { cmd->buttons |= IN_FORWARD; } - else if ( cmd->forwardmove < 0 ) + else if (cmd->forwardmove < 0) { cmd->buttons |= IN_BACK; } } - gEngfuncs.GetViewAngles( (float *)viewangles ); + gEngfuncs.GetViewAngles((float*)viewangles); // Set current view angles. - if ( g_iAlive ) + if (g_iAlive) { - VectorCopy( viewangles, cmd->viewangles ); - VectorCopy( viewangles, oldangles ); + VectorCopy(viewangles, cmd->viewangles); + VectorCopy(viewangles, oldangles); } else { - VectorCopy( oldangles, cmd->viewangles ); + VectorCopy(oldangles, cmd->viewangles); } - Bench_SetViewAngles( 1, (float *)&cmd->viewangles, frametime, cmd ); + Bench_SetViewAngles(1, (float*)&cmd->viewangles, frametime, cmd); } /* @@ -773,9 +773,9 @@ CL_IsDead Returns 1 if health is <= 0 ============ */ -int CL_IsDead( void ) +int CL_IsDead(void) { - return ( gHUD.m_Health.m_iHealth <= 0 ) ? 1 : 0; + return (gHUD.m_Health.m_iHealth <= 0) ? 1 : 0; } /* @@ -786,30 +786,30 @@ Returns appropriate button info for keyboard and mouse state Set bResetState to 1 to clear old state info ============ */ -int CL_ButtonBits( int bResetState ) +int CL_ButtonBits(int bResetState) { int bits = 0; - if ( in_attack.state & 3 ) + if (in_attack.state & 3) { bits |= IN_ATTACK; } - + if (in_duck.state & 3) { bits |= IN_DUCK; } - + if (in_jump.state & 3) { bits |= IN_JUMP; } - if ( in_forward.state & 3 ) + if (in_forward.state & 3) { bits |= IN_FORWARD; } - + if (in_back.state & 3) { bits |= IN_BACK; @@ -825,21 +825,21 @@ int CL_ButtonBits( int bResetState ) bits |= IN_CANCEL; } - if ( in_left.state & 3 ) + if (in_left.state & 3) { bits |= IN_LEFT; } - + if (in_right.state & 3) { bits |= IN_RIGHT; } - - if ( in_moveleft.state & 3 ) + + if (in_moveleft.state & 3) { bits |= IN_MOVELEFT; } - + if (in_moveright.state & 3) { bits |= IN_MOVERIGHT; @@ -860,18 +860,18 @@ int CL_ButtonBits( int bResetState ) bits |= IN_ALT1; } - if ( in_score.state & 3 ) + if (in_score.state & 3) { bits |= IN_SCORE; } // Dead or in intermission? Shore scoreboard, too - if ( CL_IsDead() || gHUD.m_iIntermission ) + if (CL_IsDead() || gHUD.m_iIntermission) { bits |= IN_SCORE; } - if ( bResetState ) + if (bResetState) { in_attack.state &= ~2; in_duck.state &= ~2; @@ -898,17 +898,17 @@ CL_ResetButtonBits ============ */ -void CL_ResetButtonBits( int bits ) +void CL_ResetButtonBits(int bits) { - int bitsNew = CL_ButtonBits( 0 ) ^ bits; + int bitsNew = CL_ButtonBits(0) ^ bits; // Has the attack button been changed - if ( bitsNew & IN_ATTACK ) + if (bitsNew & IN_ATTACK) { // Was it pressed? or let go? - if ( bits & IN_ATTACK ) + if (bits & IN_ATTACK) { - KeyDown( &in_attack ); + KeyDown(&in_attack); } else { @@ -923,81 +923,81 @@ void CL_ResetButtonBits( int bits ) InitInput ============ */ -void InitInput (void) +void InitInput(void) { - gEngfuncs.pfnAddCommand ("+moveup",IN_UpDown); - gEngfuncs.pfnAddCommand ("-moveup",IN_UpUp); - gEngfuncs.pfnAddCommand ("+movedown",IN_DownDown); - gEngfuncs.pfnAddCommand ("-movedown",IN_DownUp); - gEngfuncs.pfnAddCommand ("+left",IN_LeftDown); - gEngfuncs.pfnAddCommand ("-left",IN_LeftUp); - gEngfuncs.pfnAddCommand ("+right",IN_RightDown); - gEngfuncs.pfnAddCommand ("-right",IN_RightUp); - gEngfuncs.pfnAddCommand ("+forward",IN_ForwardDown); - gEngfuncs.pfnAddCommand ("-forward",IN_ForwardUp); - gEngfuncs.pfnAddCommand ("+back",IN_BackDown); - gEngfuncs.pfnAddCommand ("-back",IN_BackUp); - gEngfuncs.pfnAddCommand ("+lookup", IN_LookupDown); - gEngfuncs.pfnAddCommand ("-lookup", IN_LookupUp); - gEngfuncs.pfnAddCommand ("+lookdown", IN_LookdownDown); - gEngfuncs.pfnAddCommand ("-lookdown", IN_LookdownUp); - gEngfuncs.pfnAddCommand ("+strafe", IN_StrafeDown); - gEngfuncs.pfnAddCommand ("-strafe", IN_StrafeUp); - gEngfuncs.pfnAddCommand ("+moveleft", IN_MoveleftDown); - gEngfuncs.pfnAddCommand ("-moveleft", IN_MoveleftUp); - gEngfuncs.pfnAddCommand ("+moveright", IN_MoverightDown); - gEngfuncs.pfnAddCommand ("-moveright", IN_MoverightUp); - gEngfuncs.pfnAddCommand ("+speed", IN_SpeedDown); - gEngfuncs.pfnAddCommand ("-speed", IN_SpeedUp); - gEngfuncs.pfnAddCommand ("+attack", IN_AttackDown); - gEngfuncs.pfnAddCommand ("-attack", IN_AttackUp); - gEngfuncs.pfnAddCommand ("+attack2", IN_Attack2Down); - gEngfuncs.pfnAddCommand ("-attack2", IN_Attack2Up); - gEngfuncs.pfnAddCommand ("+use", IN_UseDown); - gEngfuncs.pfnAddCommand ("-use", IN_UseUp); - gEngfuncs.pfnAddCommand ("+jump", IN_JumpDown); - gEngfuncs.pfnAddCommand ("-jump", IN_JumpUp); - gEngfuncs.pfnAddCommand ("impulse", IN_Impulse); - gEngfuncs.pfnAddCommand ("+klook", IN_KLookDown); - gEngfuncs.pfnAddCommand ("-klook", IN_KLookUp); - gEngfuncs.pfnAddCommand ("+mlook", IN_MLookDown); - gEngfuncs.pfnAddCommand ("-mlook", IN_MLookUp); - gEngfuncs.pfnAddCommand ("+jlook", IN_JLookDown); - gEngfuncs.pfnAddCommand ("-jlook", IN_JLookUp); - gEngfuncs.pfnAddCommand ("+duck", IN_DuckDown); - gEngfuncs.pfnAddCommand ("-duck", IN_DuckUp); - gEngfuncs.pfnAddCommand ("+reload", IN_ReloadDown); - gEngfuncs.pfnAddCommand ("-reload", IN_ReloadUp); - gEngfuncs.pfnAddCommand ("+alt1", IN_Alt1Down); - gEngfuncs.pfnAddCommand ("-alt1", IN_Alt1Up); - gEngfuncs.pfnAddCommand ("+score", IN_ScoreDown); - gEngfuncs.pfnAddCommand ("-score", IN_ScoreUp); - gEngfuncs.pfnAddCommand ("+showscores", IN_ScoreDown); - gEngfuncs.pfnAddCommand ("-showscores", IN_ScoreUp); - gEngfuncs.pfnAddCommand ("+graph", IN_GraphDown); - gEngfuncs.pfnAddCommand ("-graph", IN_GraphUp); - gEngfuncs.pfnAddCommand ("+break",IN_BreakDown); - gEngfuncs.pfnAddCommand ("-break",IN_BreakUp); - - lookstrafe = gEngfuncs.pfnRegisterVariable ( "lookstrafe", "0", FCVAR_ARCHIVE ); - lookspring = gEngfuncs.pfnRegisterVariable ( "lookspring", "0", FCVAR_ARCHIVE ); - cl_anglespeedkey = gEngfuncs.pfnRegisterVariable ( "cl_anglespeedkey", "0.67", 0 ); - cl_yawspeed = gEngfuncs.pfnRegisterVariable ( "cl_yawspeed", "210", 0 ); - cl_pitchspeed = gEngfuncs.pfnRegisterVariable ( "cl_pitchspeed", "225", 0 ); - cl_upspeed = gEngfuncs.pfnRegisterVariable ( "cl_upspeed", "320", 0 ); - cl_forwardspeed = gEngfuncs.pfnRegisterVariable ( "cl_forwardspeed", "400", FCVAR_ARCHIVE ); - cl_backspeed = gEngfuncs.pfnRegisterVariable ( "cl_backspeed", "400", FCVAR_ARCHIVE ); - cl_sidespeed = gEngfuncs.pfnRegisterVariable ( "cl_sidespeed", "400", 0 ); - cl_movespeedkey = gEngfuncs.pfnRegisterVariable ( "cl_movespeedkey", "0.3", 0 ); - cl_pitchup = gEngfuncs.pfnRegisterVariable ( "cl_pitchup", "89", 0 ); - cl_pitchdown = gEngfuncs.pfnRegisterVariable ( "cl_pitchdown", "89", 0 ); - - cl_vsmoothing = gEngfuncs.pfnRegisterVariable ( "cl_vsmoothing", "0.05", FCVAR_ARCHIVE ); - - m_pitch = gEngfuncs.pfnRegisterVariable ( "m_pitch","0.022", FCVAR_ARCHIVE ); - m_yaw = gEngfuncs.pfnRegisterVariable ( "m_yaw","0.022", FCVAR_ARCHIVE ); - m_forward = gEngfuncs.pfnRegisterVariable ( "m_forward","1", FCVAR_ARCHIVE ); - m_side = gEngfuncs.pfnRegisterVariable ( "m_side","0.8", FCVAR_ARCHIVE ); + gEngfuncs.pfnAddCommand("+moveup", IN_UpDown); + gEngfuncs.pfnAddCommand("-moveup", IN_UpUp); + gEngfuncs.pfnAddCommand("+movedown", IN_DownDown); + gEngfuncs.pfnAddCommand("-movedown", IN_DownUp); + gEngfuncs.pfnAddCommand("+left", IN_LeftDown); + gEngfuncs.pfnAddCommand("-left", IN_LeftUp); + gEngfuncs.pfnAddCommand("+right", IN_RightDown); + gEngfuncs.pfnAddCommand("-right", IN_RightUp); + gEngfuncs.pfnAddCommand("+forward", IN_ForwardDown); + gEngfuncs.pfnAddCommand("-forward", IN_ForwardUp); + gEngfuncs.pfnAddCommand("+back", IN_BackDown); + gEngfuncs.pfnAddCommand("-back", IN_BackUp); + gEngfuncs.pfnAddCommand("+lookup", IN_LookupDown); + gEngfuncs.pfnAddCommand("-lookup", IN_LookupUp); + gEngfuncs.pfnAddCommand("+lookdown", IN_LookdownDown); + gEngfuncs.pfnAddCommand("-lookdown", IN_LookdownUp); + gEngfuncs.pfnAddCommand("+strafe", IN_StrafeDown); + gEngfuncs.pfnAddCommand("-strafe", IN_StrafeUp); + gEngfuncs.pfnAddCommand("+moveleft", IN_MoveleftDown); + gEngfuncs.pfnAddCommand("-moveleft", IN_MoveleftUp); + gEngfuncs.pfnAddCommand("+moveright", IN_MoverightDown); + gEngfuncs.pfnAddCommand("-moveright", IN_MoverightUp); + gEngfuncs.pfnAddCommand("+speed", IN_SpeedDown); + gEngfuncs.pfnAddCommand("-speed", IN_SpeedUp); + gEngfuncs.pfnAddCommand("+attack", IN_AttackDown); + gEngfuncs.pfnAddCommand("-attack", IN_AttackUp); + gEngfuncs.pfnAddCommand("+attack2", IN_Attack2Down); + gEngfuncs.pfnAddCommand("-attack2", IN_Attack2Up); + gEngfuncs.pfnAddCommand("+use", IN_UseDown); + gEngfuncs.pfnAddCommand("-use", IN_UseUp); + gEngfuncs.pfnAddCommand("+jump", IN_JumpDown); + gEngfuncs.pfnAddCommand("-jump", IN_JumpUp); + gEngfuncs.pfnAddCommand("impulse", IN_Impulse); + gEngfuncs.pfnAddCommand("+klook", IN_KLookDown); + gEngfuncs.pfnAddCommand("-klook", IN_KLookUp); + gEngfuncs.pfnAddCommand("+mlook", IN_MLookDown); + gEngfuncs.pfnAddCommand("-mlook", IN_MLookUp); + gEngfuncs.pfnAddCommand("+jlook", IN_JLookDown); + gEngfuncs.pfnAddCommand("-jlook", IN_JLookUp); + gEngfuncs.pfnAddCommand("+duck", IN_DuckDown); + gEngfuncs.pfnAddCommand("-duck", IN_DuckUp); + gEngfuncs.pfnAddCommand("+reload", IN_ReloadDown); + gEngfuncs.pfnAddCommand("-reload", IN_ReloadUp); + gEngfuncs.pfnAddCommand("+alt1", IN_Alt1Down); + gEngfuncs.pfnAddCommand("-alt1", IN_Alt1Up); + gEngfuncs.pfnAddCommand("+score", IN_ScoreDown); + gEngfuncs.pfnAddCommand("-score", IN_ScoreUp); + gEngfuncs.pfnAddCommand("+showscores", IN_ScoreDown); + gEngfuncs.pfnAddCommand("-showscores", IN_ScoreUp); + gEngfuncs.pfnAddCommand("+graph", IN_GraphDown); + gEngfuncs.pfnAddCommand("-graph", IN_GraphUp); + gEngfuncs.pfnAddCommand("+break", IN_BreakDown); + gEngfuncs.pfnAddCommand("-break", IN_BreakUp); + + lookstrafe = gEngfuncs.pfnRegisterVariable("lookstrafe", "0", FCVAR_ARCHIVE); + lookspring = gEngfuncs.pfnRegisterVariable("lookspring", "0", FCVAR_ARCHIVE); + cl_anglespeedkey = gEngfuncs.pfnRegisterVariable("cl_anglespeedkey", "0.67", 0); + cl_yawspeed = gEngfuncs.pfnRegisterVariable("cl_yawspeed", "210", 0); + cl_pitchspeed = gEngfuncs.pfnRegisterVariable("cl_pitchspeed", "225", 0); + cl_upspeed = gEngfuncs.pfnRegisterVariable("cl_upspeed", "320", 0); + cl_forwardspeed = gEngfuncs.pfnRegisterVariable("cl_forwardspeed", "400", FCVAR_ARCHIVE); + cl_backspeed = gEngfuncs.pfnRegisterVariable("cl_backspeed", "400", FCVAR_ARCHIVE); + cl_sidespeed = gEngfuncs.pfnRegisterVariable("cl_sidespeed", "400", 0); + cl_movespeedkey = gEngfuncs.pfnRegisterVariable("cl_movespeedkey", "0.3", 0); + cl_pitchup = gEngfuncs.pfnRegisterVariable("cl_pitchup", "89", 0); + cl_pitchdown = gEngfuncs.pfnRegisterVariable("cl_pitchdown", "89", 0); + + cl_vsmoothing = gEngfuncs.pfnRegisterVariable("cl_vsmoothing", "0.05", FCVAR_ARCHIVE); + + m_pitch = gEngfuncs.pfnRegisterVariable("m_pitch", "0.022", FCVAR_ARCHIVE); + m_yaw = gEngfuncs.pfnRegisterVariable("m_yaw", "0.022", FCVAR_ARCHIVE); + m_forward = gEngfuncs.pfnRegisterVariable("m_forward", "1", FCVAR_ARCHIVE); + m_side = gEngfuncs.pfnRegisterVariable("m_side", "0.8", FCVAR_ARCHIVE); // Initialize third person camera controls. CAM_Init(); @@ -1014,28 +1014,28 @@ void InitInput (void) ShutdownInput ============ */ -void ShutdownInput (void) +void ShutdownInput(void) { IN_Shutdown(); KB_Shutdown(); } #include "interface.h" -void CL_UnloadParticleMan( void ); +void CL_UnloadParticleMan(void); #if defined( _TFC ) -void ClearEventList( void ); +void ClearEventList(void); #endif -void DLLEXPORT HUD_Shutdown( void ) +void DLLEXPORT HUD_Shutdown(void) { -// RecClShutdown(); + // RecClShutdown(); ShutdownInput(); #if defined( _TFC ) ClearEventList(); #endif - + CL_UnloadParticleMan(); -} +} \ No newline at end of file diff --git a/cl_dll/train.cpp b/cl_dll/train.cpp index 0286c68..747d2a0 100644 --- a/cl_dll/train.cpp +++ b/cl_dll/train.cpp @@ -54,7 +54,7 @@ int CHudTrain::Draw(float fTime) { int r, g, b, x, y; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB(r,g,b, RGB_DEFAULT); SPR_Set(m_hSprite, r, g, b ); // This should show up to the right and part way up the armor number diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index 736ea8c..f1e63c5 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -49,6 +49,7 @@ void VectorAngles( const float *forward, float *angles ); #include "r_studioint.h" #include "com_model.h" #include "kbutton.h" +#include "view.h" extern engine_studio_api_t IEngineStudio; @@ -85,11 +86,11 @@ cvar_t *scr_ofsz; cvar_t *v_centermove; cvar_t *v_centerspeed; -cvar_t *cl_bobcycle; -cvar_t *cl_bob; +cvar_t *cl_bobcycle_max; cvar_t *cl_bobup; cvar_t *cl_waterdist; cvar_t *cl_chasedist; +cvar_t* cl_viewroll; // These cvars are not registered (so users can't cheat), so set the ->value field directly // Register these cvars in V_Init() if needed for easy tweaking @@ -160,49 +161,114 @@ void V_InterpolateAngles( float *start, float *end, float *output, float frac ) V_NormalizeAngles( output ); } */ -// Quakeworld bob code, this fixes jitters in the mutliplayer since the clock (pparams->time) isn't quite linear -float V_CalcBob ( struct ref_params_s *pparams ) +inline float RemapVal(float val, float A, float B, float C, float D) { - static double bobtime; - static float bob; - float cycle; - static float lasttime; - vec3_t vel; - + if (A == B) + return val >= B ? D : C; + return C + (D - C) * (val - A) / (B - A); +} + +inline float clamp(float val, float minVal, float maxVal) +{ + if (maxVal < minVal) + return maxVal; + else if (val < minVal) + return minVal; + else if (val > maxVal) + return maxVal; + else + return val; +} - if ( pparams->onground == -1 || - pparams->time == lasttime ) +// +// Based on HL2 bob code +// https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/game/shared/hl2/basehlcombatweapon_shared.cpp#L256 + + +struct BobValues +{ + float verticalBob = 0; + float laterialBob = 0; +}; + +BobValues V_CalculateBob ( vec3_t velocity, float currentTime ) +{ + BobValues bob; + + static float bobtime; + static float lastbobtime; + float cycle; + + float speed = Length(velocity); + + speed = clamp(speed, -320.f, 320.f); + + float bob_offset = RemapVal(speed, 0, 320, 0.0f, 1.0f); + + bobtime += (currentTime - lastbobtime) * bob_offset; + lastbobtime = currentTime; + + auto bobmax = cl_bobcycle_max->value; + auto bobup = cl_bobup->value; + + //Calculate the vertical bob + cycle = bobtime - (int)(bobtime / bobmax) * bobmax; + cycle /= bobmax; + + if (cycle < bobup) { - // just use old value - return bob; + cycle = M_PI * cycle / bobup; + } + else + { + cycle = M_PI + M_PI * (cycle - bobup) / (1.0f - bobup); } - lasttime = pparams->time; + bob.verticalBob = speed * 0.005f; + bob.verticalBob = bob.verticalBob * 0.3 + bob.verticalBob * 0.7 * sin(cycle); - bobtime += pparams->frametime; - cycle = bobtime - (int)( bobtime / cl_bobcycle->value ) * cl_bobcycle->value; - cycle /= cl_bobcycle->value; - - if ( cycle < cl_bobup->value ) + bob.verticalBob = clamp(bob.verticalBob, -7.0f, 4.0f); + + //Calculate the lateral bob + cycle = bobtime - (int)(bobtime / bobmax * 2) * bobmax * 2; + cycle /= bobmax * 2; + + if (cycle < bobup) { - cycle = M_PI * cycle / cl_bobup->value; + cycle = M_PI * cycle / bobup; } else { - cycle = M_PI + M_PI * ( cycle - cl_bobup->value )/( 1.0 - cl_bobup->value ); + cycle = M_PI + M_PI * (cycle - bobup) / (1.0f - bobup); } - // bob is proportional to simulated velocity in the xy plane - // (don't count Z, or jumping messes it up) - VectorCopy( pparams->simvel, vel ); - vel[2] = 0; + bob.laterialBob = speed * 0.005f; + bob.laterialBob = bob.laterialBob * 0.3 + bob.laterialBob * 0.7 * sin(cycle); + bob.laterialBob = clamp(bob.laterialBob, -7.0f, 4.0f); - bob = sqrt( vel[0] * vel[0] + vel[1] * vel[1] ) * cl_bob->value; - bob = bob * 0.3 + bob * 0.7 * sin(cycle); - bob = V_min( bob, 4 ); - bob = V_max( bob, -7 ); return bob; - +} + +void V_ApplyBob(struct ref_params_s* pparams, cl_entity_t *view) +{ + if (!pparams->time) + return; + + auto bob = V_CalculateBob(pparams->simvel, pparams->time); + + // Apply bob, but scaled down to 40% + VectorMA(view->origin, bob.verticalBob * 0.1f, pparams->forward, view->origin); + + // Z bob a bit more + view->origin[2] += bob.verticalBob * 0.1f; + + // bob the angles + view->angles[ROLL] += bob.verticalBob * 0.5f; + view->angles[PITCH] -= bob.verticalBob * 0.4f; + + view->angles[YAW] -= bob.laterialBob *0.3f; + + VectorMA(view->origin, bob.laterialBob * 0.8f, pparams->right, view->origin); } /* @@ -401,8 +467,8 @@ V_CalcViewRoll Roll is induced by movement and damage ============== */ -extern cvar_t* cl_viewrollangle; -extern cvar_t* cl_viewrollspeed; +extern cvar_t* cl_rollangle; +extern cvar_t* cl_rollspeed; void V_CalcViewRoll ( struct ref_params_s *pparams ) { float side; @@ -411,7 +477,8 @@ void V_CalcViewRoll ( struct ref_params_s *pparams ) viewentity = gEngfuncs.GetEntityByIndex( pparams->viewentity ); if ( !viewentity ) return; - pparams->viewangles[ROLL] = V_CalcRoll(pparams->viewangles, pparams->simvel, cl_viewrollangle->value, cl_viewrollspeed->value) * 4; + if (cl_viewroll->value==1) pparams->viewangles[ROLL] += V_CalcRoll(pparams->viewangles, pparams->simvel, cl_rollangle->value, cl_rollspeed->value) * 4; + side = V_CalcRoll ( viewentity->angles, pparams->simvel, pparams->movevars->rollangle, pparams->movevars->rollspeed ); pparams->viewangles[ROLL] += side; @@ -468,70 +535,15 @@ void V_CalcIntermissionRefdef ( struct ref_params_s *pparams ) v_angles = pparams->viewangles; } -#define ORIGIN_BACKUP 64 -#define ORIGIN_MASK ( ORIGIN_BACKUP - 1 ) - -typedef struct -{ - float Origins[ ORIGIN_BACKUP ][3]; - float OriginTime[ ORIGIN_BACKUP ]; - - float Angles[ ORIGIN_BACKUP ][3]; - float AngleTime[ ORIGIN_BACKUP ]; - - int CurrentOrigin; - int CurrentAngle; -} viewinterp_t; /* ================== -V_CalcRefdef +V_WaterHackFixApply ================== */ -void V_CalcNormalRefdef ( struct ref_params_s *pparams ) +float V_CalcWaterOffsetHack ( struct ref_params_s* pparams ) { - cl_entity_t *ent, *view; - int i; - vec3_t angles; - float bob, waterOffset; - static viewinterp_t ViewInterp; - - static float oldz = 0; - static float lasttime; - - vec3_t camAngles, camForward, camRight, camUp; - cl_entity_t *pwater; - - V_DriftPitch ( pparams ); - - if ( gEngfuncs.IsSpectateOnly() ) - { - ent = gEngfuncs.GetEntityByIndex( g_iUser2 ); - } - else - { - // ent is the player model ( visible when out of body ) - ent = gEngfuncs.GetLocalPlayer(); - } - - // view is the weapon model (only visible from inside body ) - view = gEngfuncs.GetViewModel(); - - // transform the view offset by the model's matrix to get the offset from - // model origin for the view - bob = V_CalcBob ( pparams ); - - // refresh position - VectorCopy ( pparams->simorg, pparams->vieworg ); - pparams->vieworg[2] += ( bob ); - VectorAdd( pparams->vieworg, pparams->viewheight, pparams->vieworg ); - - VectorCopy ( pparams->cl_viewangles, pparams->viewangles ); - - gEngfuncs.V_CalcShake(); - gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0 ); - // never let view origin sit exactly on a node line, because a water plane can // dissapear when viewed with the eye exactly on it. // FIXME, we send origin at 1/128 now, change this? @@ -544,7 +556,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) // Check for problems around water, move the viewer artificially if necessary // -- this prevents drawing errors in GL due to waves - waterOffset = 0; + float waterOffset = 0; if ( pparams->waterlevel >= 2 ) { int i, contents, waterDist, waterEntity; @@ -556,7 +568,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) waterEntity = gEngfuncs.PM_WaterEntity( pparams->simorg ); if ( waterEntity >= 0 && waterEntity < pparams->max_entities ) { - pwater = gEngfuncs.GetEntityByIndex( waterEntity ); + cl_entity_t *pwater = gEngfuncs.GetEntityByIndex( waterEntity ); if ( pwater && ( pwater->model != NULL ) ) { waterDist += ( pwater->curstate.scale * 16 ); // Add in wave height @@ -599,120 +611,55 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) } } - pparams->vieworg[2] += waterOffset; - - V_CalcViewRoll ( pparams ); - - V_AddIdle ( pparams ); - - // offsets - VectorCopy( pparams->cl_viewangles, angles ); - - AngleVectors ( angles, pparams->forward, pparams->right, pparams->up ); - - // don't allow cheats in multiplayer - if ( pparams->maxclients <= 1 ) - { - for ( i=0 ; i<3 ; i++ ) - { - pparams->vieworg[i] += scr_ofsx->value*pparams->forward[i] + scr_ofsy->value*pparams->right[i] + scr_ofsz->value*pparams->up[i]; - } - } - - // Treating cam_ofs[2] as the distance - if( CL_IsThirdPerson() ) - { - vec3_t ofs; - - ofs[0] = ofs[1] = ofs[2] = 0.0; - - CL_CameraOffset( (float *)&ofs ); - - VectorCopy( ofs, camAngles ); - camAngles[ ROLL ] = 0; + return waterOffset; +} - AngleVectors( camAngles, camForward, camRight, camUp ); - for ( i = 0; i < 3; i++ ) - { - pparams->vieworg[ i ] += -ofs[2] * camForward[ i ]; - } - } - - // Give gun our viewangles - VectorCopy ( pparams->cl_viewangles, view->angles ); - - // set up gun position - V_CalcGunAngle ( pparams ); - - // Use predicted origin as view origin. - VectorCopy ( pparams->simorg, view->origin ); - view->origin[2] += ( waterOffset ); - VectorAdd( view->origin, pparams->viewheight, view->origin ); +#define ORIGIN_BACKUP 64 +#define ORIGIN_MASK ( ORIGIN_BACKUP - 1 ) - // Let the viewmodel shake at about 10% of the amplitude - gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9 ); +typedef struct +{ + float Origins[ ORIGIN_BACKUP ][3]; + float OriginTime[ ORIGIN_BACKUP ]; - for ( i = 0; i < 3; i++ ) - { - view->origin[ i ] += bob * 0.4 * pparams->forward[ i ]; - } - view->origin[2] += bob; + float Angles[ ORIGIN_BACKUP ][3]; + float AngleTime[ ORIGIN_BACKUP ]; - // throw in a little tilt. - view->angles[YAW] -= bob * 0.5; - view->angles[ROLL] -= bob * 1; - view->angles[PITCH] -= bob * 0.3; - VectorCopy(view->angles, view->curstate.angles); + int CurrentOrigin; + int CurrentAngle; +} viewinterp_t; - // pushing the view origin down off of the same X/Z plane as the ent's origin will give the - // gun a very nice 'shifting' effect when the player looks up/down. If there is a problem - // with view model distortion, this may be a cause. (SJB). - view->origin[2] -= 1; - // fudge position around to keep amount of weapon visible - // roughly equal with different FOV - if (pparams->viewsize == 110) - { - view->origin[2] += 1; - } - else if (pparams->viewsize == 100) - { - view->origin[2] += 2; - } - else if (pparams->viewsize == 90) - { - view->origin[2] += 1; - } - else if (pparams->viewsize == 80) - { - view->origin[2] += 0.5; - } - - // Add in the punchangle, if any - VectorAdd ( pparams->viewangles, pparams->punchangle, pparams->viewangles ); +/* +================== +V_ApplySmoothing - // Include client side punch, too - VectorAdd ( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles); +================== +*/ +void V_ApplySmoothing ( struct ref_params_s *pparams, cl_entity_t *view) +{ + static float oldz = 0; + static float lasttime; - V_DropPunchAngle ( pparams->frametime, (float *)&ev_punchangle ); + static viewinterp_t ViewInterp; // smooth out stair step ups #if 1 - if ( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0) + if (!pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0) { float steptime; - + steptime = pparams->time - lasttime; if (steptime < 0) - //FIXME I_Error ("steptime < 0"); + //FIXME I_Error ("steptime < 0"); steptime = 0; oldz += steptime * 150; if (oldz > pparams->simorg[2]) oldz = pparams->simorg[2]; if (pparams->simorg[2] - oldz > 18) - oldz = pparams->simorg[2]- 18; + oldz = pparams->simorg[2] - 18; pparams->vieworg[2] += oldz - pparams->simorg[2]; view->origin[2] += oldz - pparams->simorg[2]; } @@ -784,12 +731,145 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) VectorAdd( pparams->simorg, delta, pparams->simorg ); VectorAdd( pparams->vieworg, delta, pparams->vieworg ); VectorAdd( view->origin, delta, view->origin ); - } } } } + lasttime = pparams->time; +} + + +/* +================== +V_CalcRefdef + +================== +*/ +void V_CalcNormalRefdef ( struct ref_params_s *pparams ) +{ + cl_entity_t *ent, *view; + int i; + + vec3_t camAngles, camForward, camRight, camUp; + + V_DriftPitch ( pparams ); + + if ( gEngfuncs.IsSpectateOnly() ) + { + ent = gEngfuncs.GetEntityByIndex( g_iUser2 ); + } + else + { + // ent is the player model ( visible when out of body ) + ent = gEngfuncs.GetLocalPlayer(); + } + + // view is the weapon model (only visible from inside body ) + view = gEngfuncs.GetViewModel(); + + // transform the view offset by the model's matrix to get the offset from + // model origin for the view + + // add view height + VectorAdd( pparams->simorg, pparams->viewheight, pparams->vieworg ); + + VectorCopy ( pparams->cl_viewangles, pparams->viewangles ); + + gEngfuncs.V_CalcShake(); + gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0 ); + + float waterOffset = V_CalcWaterOffsetHack ( pparams ); + pparams->vieworg[2] += waterOffset; + + V_CalcViewRoll ( pparams ); + + V_AddIdle ( pparams ); + + // offsets + vec3_t angles = pparams->cl_viewangles; + + AngleVectors ( angles, pparams->forward, pparams->right, pparams->up ); + + // don't allow cheats in multiplayer + if ( pparams->maxclients <= 1 ) + { + for ( i=0 ; i<3 ; i++ ) + { + pparams->vieworg[i] += scr_ofsx->value*pparams->forward[i] + scr_ofsy->value*pparams->right[i] + scr_ofsz->value*pparams->up[i]; + } + } + + // Treating cam_ofs[2] as the distance + if( CL_IsThirdPerson() ) + { + vec3_t ofs; + + ofs[0] = ofs[1] = ofs[2] = 0.0; + + CL_CameraOffset( (float *)&ofs ); + + VectorCopy( ofs, camAngles ); + camAngles[ ROLL ] = 0; + + AngleVectors( camAngles, camForward, camRight, camUp ); + + for ( i = 0; i < 3; i++ ) + { + pparams->vieworg[ i ] += -ofs[2] * camForward[ i ]; + } + } + + // Give gun our viewangles + VectorCopy ( pparams->cl_viewangles, view->angles ); + + // set up gun position + V_CalcGunAngle ( pparams ); + + // Use predicted origin as view origin. + VectorCopy ( pparams->simorg, view->origin ); + view->origin[2] += ( waterOffset ); + VectorAdd( view->origin, pparams->viewheight, view->origin ); + + // Let the viewmodel shake at about 10% of the amplitude + gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9 ); + + V_ApplyBob( pparams, view ); + + // pushing the view origin down off of the same X/Z plane as the ent's origin will give the + // gun a very nice 'shifting' effect when the player looks up/down. If there is a problem + // with view model distortion, this may be a cause. (SJB). + view->origin[2] -= 1; + + // fudge position around to keep amount of weapon visible + // roughly equal with different FOV + if (pparams->viewsize == 110) + { + view->origin[2] += 1; + } + else if (pparams->viewsize == 100) + { + view->origin[2] += 2; + } + else if (pparams->viewsize == 90) + { + view->origin[2] += 1; + } + else if (pparams->viewsize == 80) + { + view->origin[2] += 0.5; + } + + // Add in the punchangle, if any + VectorAdd ( pparams->viewangles, pparams->punchangle, pparams->viewangles ); + + // Include client side punch, too + VectorAdd ( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles); + + V_DropPunchAngle ( pparams->frametime, (float *)&ev_punchangle ); + + V_ApplySmoothing ( pparams, view ); + // Store off v_angles before munging for third person v_angles = pparams->viewangles; v_lastAngles = pparams->viewangles; @@ -830,8 +910,6 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) } } - lasttime = pparams->time; - v_origin = pparams->vieworg; } @@ -1714,11 +1792,12 @@ void V_Init (void) v_centermove = gEngfuncs.pfnRegisterVariable( "v_centermove", "0.15", 0 ); v_centerspeed = gEngfuncs.pfnRegisterVariable( "v_centerspeed","500", 0 ); - cl_bobcycle = gEngfuncs.pfnRegisterVariable( "cl_bobcycle","0.8", 0 );// best default for my experimental gun wag (sjb) - cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.01", 0 );// best default for my experimental gun wag (sjb) - cl_bobup = gEngfuncs.pfnRegisterVariable( "cl_bobup","0.5", 0 ); + cl_bobcycle_max = gEngfuncs.pfnRegisterVariable( "cl_bobcycle_max", "0.45", 0 ); + cl_bobup = gEngfuncs.pfnRegisterVariable( "cl_bobup", "0.5", 0 ); + cl_waterdist = gEngfuncs.pfnRegisterVariable( "cl_waterdist","4", 0 ); cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 ); + cl_viewroll = gEngfuncs.pfnRegisterVariable("cl_viewroll", "0", 0); } diff --git a/dlls/apache.cpp b/dlls/apache.cpp index 4555b90..ef481be 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -1027,7 +1027,7 @@ void CApacheHVR :: IgniteThink( void ) void CApacheHVR :: AccelerateThink( void ) { // check world boundaries - if (pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) + if (pev->origin.x < -16384 || pev->origin.x > 16384 || pev->origin.y < -16384 || pev->origin.y > 16384 || pev->origin.z < -16384 || pev->origin.z > 16384) { UTIL_Remove( this ); return; diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 02b619d..bd1b4e8 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -701,12 +701,12 @@ int CBaseEntity :: IsDormant( void ) BOOL CBaseEntity :: IsInWorld( void ) { // position - if (pev->origin.x >= 4096) return FALSE; - if (pev->origin.y >= 4096) return FALSE; - if (pev->origin.z >= 4096) return FALSE; - if (pev->origin.x <= -4096) return FALSE; - if (pev->origin.y <= -4096) return FALSE; - if (pev->origin.z <= -4096) return FALSE; + if (pev->origin.x >= 16384) return FALSE; + if (pev->origin.y >= 16384) return FALSE; + if (pev->origin.z >= 16384) return FALSE; + if (pev->origin.x <= -16384) return FALSE; + if (pev->origin.y <= -16384) return FALSE; + if (pev->origin.z <= -16384) return FALSE; // speed if (pev->velocity.x >= 2000) return FALSE; if (pev->velocity.y >= 2000) return FALSE; diff --git a/dlls/controller.cpp b/dlls/controller.cpp index 34253c0..cd05039 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -1211,7 +1211,7 @@ void CControllerHeadBall :: HuntThink( void ) MESSAGE_END(); // check world boundaries - if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) + if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -16384 || pev->origin.x > 16384 || pev->origin.y < -16384 || pev->origin.y > 16384 || pev->origin.z < -16384 || pev->origin.z > 16384) { SetTouch( NULL ); UTIL_Remove( this ); diff --git a/dlls/game.cpp b/dlls/game.cpp index 77624bd..e5a8daa 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -24,20 +24,21 @@ cvar_t fragsleft = {"mp_fragsleft","0", FCVAR_SERVER | FCVAR_UNLOGGED }; // Do cvar_t timeleft = {"mp_timeleft","0" , FCVAR_SERVER | FCVAR_UNLOGGED }; // " " // multiplayer server rules -cvar_t teamplay = {"mp_teamplay","0", FCVAR_SERVER }; -cvar_t fraglimit = {"mp_fraglimit","0", FCVAR_SERVER }; -cvar_t timelimit = {"mp_timelimit","0", FCVAR_SERVER }; -cvar_t friendlyfire= {"mp_friendlyfire","0", FCVAR_SERVER }; -cvar_t falldamage = {"mp_falldamage","0", FCVAR_SERVER }; -cvar_t weaponstay = {"mp_weaponstay","0", FCVAR_SERVER }; -cvar_t forcerespawn= {"mp_forcerespawn","1", FCVAR_SERVER }; -cvar_t flashlight = {"mp_flashlight","0", FCVAR_SERVER }; -cvar_t aimcrosshair= {"mp_autocrosshair","1", FCVAR_SERVER }; -cvar_t decalfrequency = {"decalfrequency","30", FCVAR_SERVER }; -cvar_t teamlist = {"mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; -cvar_t teamoverride = {"mp_teamoverride","1" }; -cvar_t defaultteam = {"mp_defaultteam","0" }; -cvar_t allowmonsters={"mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t teamplay = { "mp_teamplay","0", FCVAR_SERVER }; +cvar_t fraglimit = { "mp_fraglimit","0", FCVAR_SERVER }; +cvar_t timelimit = { "mp_timelimit","0", FCVAR_SERVER }; +cvar_t friendlyfire= { "mp_friendlyfire","0", FCVAR_SERVER }; +cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; +cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; +cvar_t forcerespawn= { "mp_forcerespawn","1", FCVAR_SERVER }; +cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; +cvar_t aimcrosshair= { "mp_autocrosshair","1", FCVAR_SERVER }; +cvar_t decalfrequency = { "decalfrequency","30", FCVAR_SERVER }; +cvar_t teamlist = { "mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; +cvar_t teamoverride = { "mp_teamoverride","1" }; +cvar_t defaultteam = { "mp_defaultteam","0" }; +cvar_t allowmonsters={ "mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t mp5_old_rate = { "sv_mp5_old_rate", "1", FCVAR_SERVER }; cvar_t allow_spectators = { "allow_spectators", "0.0", FCVAR_SERVER }; // 0 prevents players from being spectators diff --git a/dlls/game.h b/dlls/game.h index df82f00..0ca7f56 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -36,6 +36,7 @@ extern cvar_t teamlist; extern cvar_t teamoverride; extern cvar_t defaultteam; extern cvar_t allowmonsters; +extern cvar_t mp5_old_rate; // Engine Cvars extern cvar_t *g_psv_gravity; diff --git a/dlls/hurtremote.cpp b/dlls/hurtremote.cpp new file mode 100644 index 0000000..29c97ea --- /dev/null +++ b/dlls/hurtremote.cpp @@ -0,0 +1,38 @@ +/* + TRIGGER_HURT_REMOTE written by Sabian Roberts. + Copyright © 2020 The Phoenix Project + This software follows the Half Life 1 SDK LICENSE. +*/ +/* + + Copyright (c) 1996-2001, Valve LLC. All rights reserved. + + This product contains software technology licensed from Id + Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. + All Rights Reserved. + + Use, distribution, and modification of this source code and/or resulting + object code is restricted to non-commercial enhancements to products from + Valve LLC. All other use, distribution, or modification is prohibited + without written permission from Valve LLC. + +*/ + +/* + +====hurtremote.cpp====================================== +Purpose: Creates the trigger_hurt_remote entity. This entity hurts whatever's in its target field, rather than whatever's inside the brush. +======================================================== +*/ + +#include "extdll.h" +#include "util.h" +#include "cbase.h" + +class CTriggerHurtRemote : public CBaseEntity +{ +public: + void Spawn(); + void KeyValue(KeyValueData* pkvd); + void Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value); +}; \ No newline at end of file diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index c22dcb5..b07e1ea 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -22,6 +22,7 @@ #include "player.h" #include "soundent.h" #include "gamerules.h" +#include "game.h" enum mp5_e { @@ -127,6 +128,9 @@ BOOL CMP5::Deploy( ) void CMP5::PrimaryAttack() { +#ifndef CLIENT_DLL + int mp5OldRate = mp5_old_rate.value; +#endif // don't fire underwater if (m_pPlayer->pev->waterlevel == 3) { @@ -188,7 +192,10 @@ void CMP5::PrimaryAttack() m_flNextPrimaryAttack = GetNextAttackDelay(0.08); if ( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; +#ifndef CLIENT_DLL + if (mp5_old_rate.value == 0) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + if (mp5_old_rate.value == 1) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.08; +#endif m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 4a36d4e..da0ce4b 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -704,7 +704,7 @@ void PlayCDTrack( int iTrack ) if ( !pClient ) return; - if ( iTrack < -1 || iTrack > 30 ) + if ( iTrack < -1 || iTrack > 100 ) { ALERT ( at_console, "TriggerCDAudio - Track %d out of range\n" ); return; diff --git a/dlls/wpn_shared/hl_wpn_glock.cpp b/dlls/wpn_shared/hl_wpn_glock.cpp index a72d52c..931a39a 100644 --- a/dlls/wpn_shared/hl_wpn_glock.cpp +++ b/dlls/wpn_shared/hl_wpn_glock.cpp @@ -100,7 +100,7 @@ void CGlock::SecondaryAttack( void ) void CGlock::PrimaryAttack( void ) { - GlockFire( 0.01, 0.3, TRUE ); + GlockFire( 0.1, 0.3, TRUE ); } void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) diff --git a/dlls/zai.cpp b/dlls/zai.cpp new file mode 100644 index 0000000..f16269a --- /dev/null +++ b/dlls/zai.cpp @@ -0,0 +1,1428 @@ +/*** +* +* Copyright (c) 1996-2001, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* This source code contains proprietary and confidential information of +* Valve LLC and its suppliers. Access to this code is restricted to +* persons who have executed a written SDK license with Valve. Any access, +* use or distribution of this code by or to any unlicensed person is illegal. +* +****/ +//========================================================= +// human scientist (passive lab worker) +//========================================================= + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "talkmonster.h" +#include "schedule.h" +#include "defaultai.h" +#include "scripted.h" +#include "animation.h" +#include "soundent.h" + + +#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model +enum { HEAD_GLASSES = 0, HEAD_EINSTEIN = 1, HEAD_LUTHER = 2, HEAD_SLICK = 3 }; + +enum +{ + SCHED_HIDE = LAST_TALKMONSTER_SCHEDULE + 1, + SCHED_FEAR, + SCHED_PANIC, + SCHED_STARTLE, + SCHED_TARGET_CHASE_SCARED, + SCHED_TARGET_FACE_SCARED, +}; + +enum +{ + TASK_SAY_HEAL = LAST_TALKMONSTER_TASK + 1, + TASK_HEAL, + TASK_SAY_FEAR, + TASK_RUN_PATH_SCARED, + TASK_SCREAM, + TASK_RANDOM_SCREAM, + TASK_MOVE_TO_TARGET_RANGE_SCARED, +}; + +//========================================================= +// Monster's Anim Events Go Here +//========================================================= +#define SCIENTIST_AE_HEAL ( 1 ) +#define SCIENTIST_AE_NEEDLEON ( 2 ) +#define SCIENTIST_AE_NEEDLEOFF ( 3 ) + +//======================================================= +// Scientist +//======================================================= + +class CZai : public CTalkMonster +{ +public: + void Spawn( void ); + void Precache( void ); + + void SetYawSpeed( void ); + int Classify ( void ); + void HandleAnimEvent( MonsterEvent_t *pEvent ); + void RunTask( Task_t *pTask ); + void StartTask( Task_t *pTask ); + int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; } + int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); + virtual int FriendNumber( int arrayNumber ); + void SetActivity ( Activity newActivity ); + Activity GetStoppedActivity( void ); + int ISoundMask( void ); + void DeclineFollowing( void ); + + float CoverRadius( void ) { return 1200; } // Need more room for cover because scientists want to get far away! + BOOL DisregardEnemy( CBaseEntity *pEnemy ) { return !pEnemy->IsAlive() || (gpGlobals->time - m_fearTime) > 15; } + + BOOL CanHeal( void ); + void Heal( void ); + void Scream( void ); + + // Override these to set behavior + Schedule_t *GetScheduleOfType ( int Type ); + Schedule_t *GetSchedule ( void ); + MONSTERSTATE GetIdealState ( void ); + + void DeathSound( void ); + void PainSound( void ); + + void TalkInit( void ); + + void Killed( entvars_t *pevAttacker, int iGib ); + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + CUSTOM_SCHEDULES; + +private: + float m_painTime; + float m_healTime; + float m_fearTime; +}; + +LINK_ENTITY_TO_CLASS( monster_zamn_zai, CZai ); + +TYPEDESCRIPTION CZai::m_SaveData[] = +{ + DEFINE_FIELD( CZai, m_painTime, FIELD_TIME ), + DEFINE_FIELD( CZai, m_healTime, FIELD_TIME ), + DEFINE_FIELD( CZai, m_fearTime, FIELD_TIME ), +}; + +IMPLEMENT_SAVERESTORE( CZai, CTalkMonster ); + +//========================================================= +// AI Schedules Specific to this monster +//========================================================= +Task_t tlFollow[] = +{ + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_CANT_FOLLOW }, // If you fail, bail out of follow + { TASK_MOVE_TO_TARGET_RANGE,(float)128 }, // Move within 128 of target ent (client) +// { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, +}; + +Schedule_t slFollow[] = +{ + { + tlFollow, + ARRAYSIZE ( tlFollow ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND, + bits_SOUND_COMBAT | + bits_SOUND_DANGER, + "Follow" + }, +}; + +Task_t tlFollowScared[] = +{ + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE },// If you fail, follow normally + { TASK_MOVE_TO_TARGET_RANGE_SCARED,(float)128 }, // Move within 128 of target ent (client) +// { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE_SCARED }, +}; + +Schedule_t slFollowScared[] = +{ + { + tlFollowScared, + ARRAYSIZE ( tlFollowScared ), + bits_COND_NEW_ENEMY | + bits_COND_HEAR_SOUND | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE, + bits_SOUND_DANGER, + "FollowScared" + }, +}; + +Task_t tlFaceTargetScared[] = +{ + { TASK_FACE_TARGET, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE_SCARED }, +}; + +Schedule_t slFaceTargetScared[] = +{ + { + tlFaceTargetScared, + ARRAYSIZE ( tlFaceTargetScared ), + bits_COND_HEAR_SOUND | + bits_COND_NEW_ENEMY, + bits_SOUND_DANGER, + "FaceTargetScared" + }, +}; + +Task_t tlStopFollowing[] = +{ + { TASK_CANT_FOLLOW, (float)0 }, +}; + +Schedule_t slStopFollowing[] = +{ + { + tlStopFollowing, + ARRAYSIZE ( tlStopFollowing ), + 0, + 0, + "StopFollowing" + }, +}; + + +Task_t tlHeal[] = +{ + { TASK_MOVE_TO_TARGET_RANGE,(float)50 }, // Move within 60 of target ent (client) + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE }, // If you fail, catch up with that guy! (change this to put syringe away and then chase) + { TASK_FACE_IDEAL, (float)0 }, + { TASK_SAY_HEAL, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_ARM }, // Whip out the needle + { TASK_HEAL, (float)0 }, // Put it in the player + { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_DISARM }, // Put away the needle +}; + +Schedule_t slHeal[] = +{ + { + tlHeal, + ARRAYSIZE ( tlHeal ), + 0, // Don't interrupt or he'll end up running around with a needle all the time + 0, + "Heal" + }, +}; + + +Task_t tlFaceTarget[] = +{ + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_TARGET, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE }, +}; + +Schedule_t slFaceTarget[] = +{ + { + tlFaceTarget, + ARRAYSIZE ( tlFaceTarget ), + bits_COND_CLIENT_PUSH | + bits_COND_NEW_ENEMY | + bits_COND_HEAR_SOUND, + bits_SOUND_COMBAT | + bits_SOUND_DANGER, + "FaceTarget" + }, +}; + + +Task_t tlSciPanic[] = +{ + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SCREAM, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_EXCITED }, // This is really fear-stricken excitement + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, +}; + +Schedule_t slSciPanic[] = +{ + { + tlSciPanic, + ARRAYSIZE ( tlSciPanic ), + 0, + 0, + "SciPanic" + }, +}; + + +Task_t tlIdleSciStand[] = +{ + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds. + { TASK_TLK_HEADRESET, (float)0 }, // reset head position +}; + +Schedule_t slIdleSciStand[] = +{ + { + tlIdleSciStand, + ARRAYSIZE ( tlIdleSciStand ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL | + bits_COND_CLIENT_PUSH | + bits_COND_PROVOKED, + + bits_SOUND_COMBAT |// sound flags + //bits_SOUND_PLAYER | + //bits_SOUND_WORLD | + bits_SOUND_DANGER | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | + bits_SOUND_GARBAGE, + "IdleSciStand" + + }, +}; + + +Task_t tlScientistCover[] = +{ + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH_SCARED, (float)0 }, + { TASK_TURN_LEFT, (float)179 }, + { TASK_SET_SCHEDULE, (float)SCHED_HIDE }, +}; + +Schedule_t slScientistCover[] = +{ + { + tlScientistCover, + ARRAYSIZE ( tlScientistCover ), + bits_COND_NEW_ENEMY, + 0, + "ScientistCover" + }, +}; + + + +Task_t tlScientistHide[] = +{ + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, + { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, // FIXME: This looks lame + { TASK_WAIT_RANDOM, (float)10.0 }, +}; + +Schedule_t slScientistHide[] = +{ + { + tlScientistHide, + ARRAYSIZE ( tlScientistHide ), + bits_COND_NEW_ENEMY | + bits_COND_HEAR_SOUND | + bits_COND_SEE_ENEMY | + bits_COND_SEE_HATE | + bits_COND_SEE_FEAR | + bits_COND_SEE_DISLIKE, + bits_SOUND_DANGER, + "ScientistHide" + }, +}; + + +Task_t tlScientistStartle[] = +{ + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! + { TASK_RANDOM_SCREAM, (float)0.3 }, // Scream 30% of the time + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH }, + { TASK_RANDOM_SCREAM, (float)0.1 }, // Scream again 10% of the time + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCHIDLE }, + { TASK_WAIT_RANDOM, (float)1.0 }, +}; + +Schedule_t slScientistStartle[] = +{ + { + tlScientistStartle, + ARRAYSIZE ( tlScientistStartle ), + bits_COND_NEW_ENEMY | + bits_COND_SEE_ENEMY | + bits_COND_SEE_HATE | + bits_COND_SEE_FEAR | + bits_COND_SEE_DISLIKE, + 0, + "ScientistStartle" + }, +}; + + + +Task_t tlFear[] = +{ + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SAY_FEAR, (float)0 }, +// { TASK_PLAY_SEQUENCE, (float)ACT_FEAR_DISPLAY }, +}; + +Schedule_t slFear[] = +{ + { + tlFear, + ARRAYSIZE ( tlFear ), + bits_COND_NEW_ENEMY, + 0, + "Fear" + }, +}; + + +DEFINE_CUSTOM_SCHEDULES( CZai ) +{ + slFollow, + slFaceTarget, + slIdleSciStand, + slFear, + slScientistCover, + slScientistHide, + slScientistStartle, + slHeal, + slStopFollowing, + slSciPanic, + slFollowScared, + slFaceTargetScared, +}; + + +IMPLEMENT_CUSTOM_SCHEDULES( CZai, CTalkMonster ); + + +void CZai::DeclineFollowing( void ) +{ + Talk( 10 ); + m_hTalkTarget = m_hEnemy; + PlaySentence( "SC_POK", 2, VOL_NORM, ATTN_NORM ); +} + + +void CZai :: Scream( void ) +{ + if ( FOkToSpeak() ) + { + Talk( 10 ); + m_hTalkTarget = m_hEnemy; + PlaySentence( "SC_SCREAM", RANDOM_FLOAT(3, 6), VOL_NORM, ATTN_NORM ); + } +} + + +Activity CZai::GetStoppedActivity( void ) +{ + if ( m_hEnemy != NULL ) + return ACT_EXCITED; + return CTalkMonster::GetStoppedActivity(); +} + + +void CZai :: StartTask( Task_t *pTask ) +{ + switch( pTask->iTask ) + { + case TASK_SAY_HEAL: +// if ( FOkToSpeak() ) + Talk( 2 ); + m_hTalkTarget = m_hTargetEnt; + PlaySentence( "SC_HEAL", 2, VOL_NORM, ATTN_IDLE ); + + TaskComplete(); + break; + + case TASK_SCREAM: + Scream(); + TaskComplete(); + break; + + case TASK_RANDOM_SCREAM: + if ( RANDOM_FLOAT( 0, 1 ) < pTask->flData ) + Scream(); + TaskComplete(); + break; + + case TASK_SAY_FEAR: + if ( FOkToSpeak() ) + { + Talk( 2 ); + m_hTalkTarget = m_hEnemy; + if ( m_hEnemy->IsPlayer() ) + PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); + else + PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); + } + TaskComplete(); + break; + + case TASK_HEAL: + m_IdealActivity = ACT_MELEE_ATTACK1; + break; + + case TASK_RUN_PATH_SCARED: + m_movementActivity = ACT_RUN_SCARED; + break; + + case TASK_MOVE_TO_TARGET_RANGE_SCARED: + { + if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) + TaskComplete(); + else + { + m_vecMoveGoal = m_hTargetEnt->pev->origin; + if ( !MoveToTarget( ACT_WALK_SCARED, 0.5 ) ) + TaskFail(); + } + } + break; + + default: + CTalkMonster::StartTask( pTask ); + break; + } +} + +void CZai :: RunTask( Task_t *pTask ) +{ + switch ( pTask->iTask ) + { + case TASK_RUN_PATH_SCARED: + if ( MovementIsComplete() ) + TaskComplete(); + if ( RANDOM_LONG(0,31) < 8 ) + Scream(); + break; + + case TASK_MOVE_TO_TARGET_RANGE_SCARED: + { + if ( RANDOM_LONG(0,63)< 8 ) + Scream(); + + if ( m_hEnemy == NULL ) + { + TaskFail(); + } + else + { + float distance; + + distance = ( m_vecMoveGoal - pev->origin ).Length2D(); + // Re-evaluate when you think your finished, or the target has moved too far + if ( (distance < pTask->flData) || (m_vecMoveGoal - m_hTargetEnt->pev->origin).Length() > pTask->flData * 0.5 ) + { + m_vecMoveGoal = m_hTargetEnt->pev->origin; + distance = ( m_vecMoveGoal - pev->origin ).Length2D(); + FRefreshRoute(); + } + + // Set the appropriate activity based on an overlapping range + // overlap the range to prevent oscillation + if ( distance < pTask->flData ) + { + TaskComplete(); + RouteClear(); // Stop moving + } + else if ( distance < 190 && m_movementActivity != ACT_WALK_SCARED ) + m_movementActivity = ACT_WALK_SCARED; + else if ( distance >= 270 && m_movementActivity != ACT_RUN_SCARED ) + m_movementActivity = ACT_RUN_SCARED; + } + } + break; + + case TASK_HEAL: + if ( m_fSequenceFinished ) + { + TaskComplete(); + } + else + { + if ( TargetDistance() > 90 ) + TaskComplete(); + pev->ideal_yaw = UTIL_VecToYaw( m_hTargetEnt->pev->origin - pev->origin ); + ChangeYaw( pev->yaw_speed ); + } + break; + default: + CTalkMonster::RunTask( pTask ); + break; + } +} + +//========================================================= +// Classify - indicates this monster's place in the +// relationship table. +//========================================================= +int CZai :: Classify ( void ) +{ + return CLASS_HUMAN_PASSIVE; +} + + +//========================================================= +// SetYawSpeed - allows each sequence to have a different +// turn rate associated with it. +//========================================================= +void CZai :: SetYawSpeed ( void ) +{ + int ys; + + ys = 90; + + switch ( m_Activity ) + { + case ACT_IDLE: + ys = 120; + break; + case ACT_WALK: + ys = 180; + break; + case ACT_RUN: + ys = 150; + break; + case ACT_TURN_LEFT: + case ACT_TURN_RIGHT: + ys = 120; + break; + } + + pev->yaw_speed = ys; +} + +//========================================================= +// HandleAnimEvent - catches the monster-specific messages +// that occur when tagged animation frames are played. +//========================================================= +void CZai :: HandleAnimEvent( MonsterEvent_t *pEvent ) +{ + switch( pEvent->event ) + { + case SCIENTIST_AE_HEAL: // Heal my target (if within range) + Heal(); + break; + case SCIENTIST_AE_NEEDLEON: + { + int oldBody = pev->body; + pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 1; + } + break; + case SCIENTIST_AE_NEEDLEOFF: + { + int oldBody = pev->body; + pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 0; + } + break; + + default: + CTalkMonster::HandleAnimEvent( pEvent ); + } +} + +//========================================================= +// Spawn +//========================================================= +void CZai :: Spawn( void ) +{ + Precache( ); + + SET_MODEL(ENT(pev), "models/scientist.mdl"); + UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = gSkillData.scientistHealth; + pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin. + m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello + m_MonsterState = MONSTERSTATE_NONE; + +// m_flDistTooFar = 256.0; + + m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; + + // White hands + pev->skin = 0; + + if ( pev->body == -1 ) + {// -1 chooses a random head + pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head + } + + // Luther is black, make his hands black + if ( pev->body == HEAD_LUTHER ) + pev->skin = 1; + + MonsterInit(); + SetUse( &CZai::FollowerUse ); +} + +//========================================================= +// Precache - precaches all resources this monster needs +//========================================================= +void CZai :: Precache( void ) +{ + PRECACHE_MODEL("models/scientist.mdl"); + PRECACHE_SOUND("scientist/sci_pain1.wav"); + PRECACHE_SOUND("scientist/sci_pain2.wav"); + PRECACHE_SOUND("scientist/sci_pain3.wav"); + PRECACHE_SOUND("scientist/sci_pain4.wav"); + PRECACHE_SOUND("scientist/sci_pain5.wav"); + + // every new scientist must call this, otherwise + // when a level is loaded, nobody will talk (time is reset to 0) + TalkInit(); + + CTalkMonster::Precache(); +} + +// Init talk data +void CZai :: TalkInit() +{ + + CTalkMonster::TalkInit(); + + // scientist will try to talk to friends in this order: + + m_szFriends[0] = "monster_zamn_zai"; + m_szFriends[1] = "monster_sitting_scientist"; + m_szFriends[2] = "monster_barney"; + + // scientists speach group names (group names are in sentences.txt) + + m_szGrp[TLK_ANSWER] = "SC_ANSWER"; + m_szGrp[TLK_QUESTION] = "SC_QUESTION"; + m_szGrp[TLK_IDLE] = "SC_IDLE"; + m_szGrp[TLK_STARE] = "SC_STARE"; + m_szGrp[TLK_USE] = "SC_OK"; + m_szGrp[TLK_UNUSE] = "SC_WAIT"; + m_szGrp[TLK_STOP] = "SC_STOP"; + m_szGrp[TLK_NOSHOOT] = "SC_SCARED"; + m_szGrp[TLK_HELLO] = "SC_HELLO"; + + m_szGrp[TLK_PLHURT1] = "!SC_CUREA"; + m_szGrp[TLK_PLHURT2] = "!SC_CUREB"; + m_szGrp[TLK_PLHURT3] = "!SC_CUREC"; + + m_szGrp[TLK_PHELLO] = "SC_PHELLO"; + m_szGrp[TLK_PIDLE] = "SC_PIDLE"; + m_szGrp[TLK_PQUESTION] = "SC_PQUEST"; + m_szGrp[TLK_SMELL] = "SC_SMELL"; + + m_szGrp[TLK_WOUND] = "SC_WOUND"; + m_szGrp[TLK_MORTAL] = "SC_MORTAL"; + + // get voice for head + switch (pev->body % 3) + { + default: + case HEAD_GLASSES: m_voicePitch = 105; break; //glasses + case HEAD_EINSTEIN: m_voicePitch = 100; break; //einstein + case HEAD_LUTHER: m_voicePitch = 95; break; //luther + case HEAD_SLICK: m_voicePitch = 100; break;//slick + } +} + +int CZai :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + + if ( pevInflictor && pevInflictor->flags & FL_CLIENT ) + { + Remember( bits_MEMORY_PROVOKED ); + StopFollowing( TRUE ); + } + + // make sure friends talk about it if player hurts scientist... + return CTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); +} + + +//========================================================= +// ISoundMask - returns a bit mask indicating which types +// of sounds this monster regards. In the base class implementation, +// monsters care about all sounds, but no scents. +//========================================================= +int CZai :: ISoundMask ( void ) +{ + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_DANGER | + bits_SOUND_PLAYER; +} + +//========================================================= +// PainSound +//========================================================= +void CZai :: PainSound ( void ) +{ + if (gpGlobals->time < m_painTime ) + return; + + m_painTime = gpGlobals->time + RANDOM_FLOAT(0.5, 0.75); + + switch (RANDOM_LONG(0,4)) + { + case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 2: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 3: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain4.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 4: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain5.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + } +} + +//========================================================= +// DeathSound +//========================================================= +void CZai :: DeathSound ( void ) +{ + PainSound(); +} + + +void CZai::Killed( entvars_t *pevAttacker, int iGib ) +{ + SetUse( NULL ); + CTalkMonster::Killed( pevAttacker, iGib ); +} + + +void CZai :: SetActivity ( Activity newActivity ) +{ + int iSequence; + + iSequence = LookupActivity ( newActivity ); + + // Set to the desired anim, or default anim if the desired is not present + if ( iSequence == ACTIVITY_NOT_AVAILABLE ) + newActivity = ACT_IDLE; + CTalkMonster::SetActivity( newActivity ); +} + + +Schedule_t* CZai :: GetScheduleOfType ( int Type ) +{ + Schedule_t *psched; + + switch( Type ) + { + // Hook these to make a looping schedule + case SCHED_TARGET_FACE: + // call base class default so that scientist will talk + // when 'used' + psched = CTalkMonster::GetScheduleOfType(Type); + + if (psched == slIdleStand) + return slFaceTarget; // override this for different target face behavior + else + return psched; + + case SCHED_TARGET_CHASE: + return slFollow; + + case SCHED_CANT_FOLLOW: + return slStopFollowing; + + case SCHED_PANIC: + return slSciPanic; + + case SCHED_TARGET_CHASE_SCARED: + return slFollowScared; + + case SCHED_TARGET_FACE_SCARED: + return slFaceTargetScared; + + case SCHED_IDLE_STAND: + // call base class default so that scientist will talk + // when standing during idle + psched = CTalkMonster::GetScheduleOfType(Type); + + if (psched == slIdleStand) + return slIdleSciStand; + else + return psched; + + case SCHED_HIDE: + return slScientistHide; + + case SCHED_STARTLE: + return slScientistStartle; + + case SCHED_FEAR: + return slFear; + } + + return CTalkMonster::GetScheduleOfType( Type ); +} + +Schedule_t *CZai :: GetSchedule ( void ) +{ + // so we don't keep calling through the EHANDLE stuff + CBaseEntity *pEnemy = m_hEnemy; + + if ( HasConditions( bits_COND_HEAR_SOUND ) ) + { + CSound *pSound; + pSound = PBestSound(); + + ASSERT( pSound != NULL ); + if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); + } + + switch( m_MonsterState ) + { + case MONSTERSTATE_ALERT: + case MONSTERSTATE_IDLE: + if ( pEnemy ) + { + if ( HasConditions( bits_COND_SEE_ENEMY ) ) + m_fearTime = gpGlobals->time; + else if ( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert + { + m_hEnemy = NULL; + pEnemy = NULL; + } + } + + if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE)) + { + // flinch if hurt + return GetScheduleOfType( SCHED_SMALL_FLINCH ); + } + + // Cower when you hear something scary + if ( HasConditions( bits_COND_HEAR_SOUND ) ) + { + CSound *pSound; + pSound = PBestSound(); + + ASSERT( pSound != NULL ); + if ( pSound ) + { + if ( pSound->m_iType & (bits_SOUND_DANGER | bits_SOUND_COMBAT) ) + { + if ( gpGlobals->time - m_fearTime > 3 ) // Only cower every 3 seconds or so + { + m_fearTime = gpGlobals->time; // Update last fear + return GetScheduleOfType( SCHED_STARTLE ); // This will just duck for a second + } + } + } + } + + // Behavior for following the player + if ( IsFollowing() ) + { + if ( !m_hTargetEnt->IsAlive() ) + { + // UNDONE: Comment about the recently dead player here? + StopFollowing( FALSE ); + break; + } + + int relationship = R_NO; + + // Nothing scary, just me and the player + if ( pEnemy != NULL ) + relationship = IRelationship( pEnemy ); + + // UNDONE: Model fear properly, fix R_FR and add multiple levels of fear + if ( relationship != R_DL && relationship != R_HT ) + { + // If I'm already close enough to my target + if ( TargetDistance() <= 128 ) + { + if ( CanHeal() ) // Heal opportunistically + return slHeal; + if ( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move + return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW ); + } + return GetScheduleOfType( SCHED_TARGET_FACE ); // Just face and follow. + } + else // UNDONE: When afraid, scientist won't move out of your way. Keep This? If not, write move away scared + { + if ( HasConditions( bits_COND_NEW_ENEMY ) ) // I just saw something new and scary, react + return GetScheduleOfType( SCHED_FEAR ); // React to something scary + return GetScheduleOfType( SCHED_TARGET_FACE_SCARED ); // face and follow, but I'm scared! + } + } + + if ( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move + return GetScheduleOfType( SCHED_MOVE_AWAY ); + + // try to say something about smells + TrySmellTalk(); + break; + case MONSTERSTATE_COMBAT: + if ( HasConditions( bits_COND_NEW_ENEMY ) ) + return slFear; // Point and scream! + if ( HasConditions( bits_COND_SEE_ENEMY ) ) + return slScientistCover; // Take Cover + + if ( HasConditions( bits_COND_HEAR_SOUND ) ) + return slTakeCoverFromBestSound; // Cower and panic from the scary sound! + + return slScientistCover; // Run & Cower + break; + } + + return CTalkMonster::GetSchedule(); +} + +MONSTERSTATE CZai :: GetIdealState ( void ) +{ + switch ( m_MonsterState ) + { + case MONSTERSTATE_ALERT: + case MONSTERSTATE_IDLE: + if ( HasConditions( bits_COND_NEW_ENEMY ) ) + { + if ( IsFollowing() ) + { + int relationship = IRelationship( m_hEnemy ); + if ( relationship != R_FR || relationship != R_HT && !HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) + { + // Don't go to combat if you're following the player + m_IdealMonsterState = MONSTERSTATE_ALERT; + return m_IdealMonsterState; + } + StopFollowing( TRUE ); + } + } + else if ( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) + { + // Stop following if you take damage + if ( IsFollowing() ) + StopFollowing( TRUE ); + } + break; + + case MONSTERSTATE_COMBAT: + { + CBaseEntity *pEnemy = m_hEnemy; + if ( pEnemy != NULL ) + { + if ( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert + { + // Strip enemy when going to alert + m_IdealMonsterState = MONSTERSTATE_ALERT; + m_hEnemy = NULL; + return m_IdealMonsterState; + } + // Follow if only scared a little + if ( m_hTargetEnt != NULL ) + { + m_IdealMonsterState = MONSTERSTATE_ALERT; + return m_IdealMonsterState; + } + + if ( HasConditions ( bits_COND_SEE_ENEMY ) ) + { + m_fearTime = gpGlobals->time; + m_IdealMonsterState = MONSTERSTATE_COMBAT; + return m_IdealMonsterState; + } + + } + } + break; + } + + return CTalkMonster::GetIdealState(); +} + + +BOOL CZai::CanHeal( void ) +{ + if ( (m_healTime > gpGlobals->time) || (m_hTargetEnt == NULL) || (m_hTargetEnt->pev->health > (m_hTargetEnt->pev->max_health * 0.5)) ) + return FALSE; + + return TRUE; +} + +void CZai::Heal( void ) +{ + if ( !CanHeal() ) + return; + + Vector target = m_hTargetEnt->pev->origin - pev->origin; + if ( target.Length() > 100 ) + return; + + m_hTargetEnt->TakeHealth( gSkillData.scientistHeal, DMG_GENERIC ); + // Don't heal again for 1 minute + m_healTime = gpGlobals->time + 60; +} + +int CZai::FriendNumber( int arrayNumber ) +{ + static int array[3] = { 1, 2, 0 }; + if ( arrayNumber < 3 ) + return array[ arrayNumber ]; + return arrayNumber; +} + + +//========================================================= +// Dead Scientist PROP +//========================================================= +class CDeadZai : public CBaseMonster +{ +public: + void Spawn( void ); + int Classify ( void ) { return CLASS_HUMAN_PASSIVE; } + + void KeyValue( KeyValueData *pkvd ); + int m_iPose;// which sequence to display + static const char *m_szPoses[7]; +}; +const char *CDeadZai::m_szPoses[] = { "lying_on_back", "lying_on_stomach", "dead_sitting", "dead_hang", "dead_table1", "dead_table2", "dead_table3" }; + +void CDeadZai::KeyValue( KeyValueData *pkvd ) +{ + if (FStrEq(pkvd->szKeyName, "pose")) + { + m_iPose = atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseMonster::KeyValue( pkvd ); +} +LINK_ENTITY_TO_CLASS( monster_zamn_zai_dead, CDeadZai ); + +// +// ********** DeadScientist SPAWN ********** +// +void CDeadZai :: Spawn( ) +{ + PRECACHE_MODEL("models/scientist.mdl"); + SET_MODEL(ENT(pev), "models/scientist.mdl"); + + pev->effects = 0; + pev->sequence = 0; + // Corpses have less health + pev->health = 8;//gSkillData.scientistHealth; + + m_bloodColor = BLOOD_COLOR_RED; + + if ( pev->body == -1 ) + {// -1 chooses a random head + pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head + } + // Luther is black, make his hands black + if ( pev->body == HEAD_LUTHER ) + pev->skin = 1; + else + pev->skin = 0; + + pev->sequence = LookupSequence( m_szPoses[m_iPose] ); + if (pev->sequence == -1) + { + ALERT ( at_console, "Dead scientist with bad pose\n" ); + } + + // pev->skin += 2; // use bloody skin -- UNDONE: Turn this back on when we have a bloody skin again! + MonsterInitDead(); +} + + +//========================================================= +// Sitting Scientist PROP +//========================================================= + +class CSittingZai : public CZai // kdb: changed from public CBaseMonster so he can speak +{ +public: + void Spawn( void ); + void Precache( void ); + + void EXPORT SittingThink( void ); + int Classify ( void ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + virtual void SetAnswerQuestion( CTalkMonster *pSpeaker ); + int FriendNumber( int arrayNumber ); + + int FIdleSpeak ( void ); + int m_baseSequence; + int m_headTurn; + float m_flResponseDelay; +}; + +LINK_ENTITY_TO_CLASS( monster_sitting_scientist, CSittingZai ); +TYPEDESCRIPTION CSittingZai::m_SaveData[] = +{ + // Don't need to save/restore m_baseSequence (recalced) + DEFINE_FIELD( CSittingZai, m_headTurn, FIELD_INTEGER ), + DEFINE_FIELD( CSittingZai, m_flResponseDelay, FIELD_FLOAT ), +}; + +IMPLEMENT_SAVERESTORE( CSittingZai, CZai ); + +// animation sequence aliases +typedef enum +{ +SITTING_ANIM_sitlookleft, +SITTING_ANIM_sitlookright, +SITTING_ANIM_sitscared, +SITTING_ANIM_sitting2, +SITTING_ANIM_sitting3 +} SITTING_ANIM; + + +// +// ********** Scientist SPAWN ********** +// +void CSittingZai :: Spawn( ) +{ + PRECACHE_MODEL("models/scientist.mdl"); + SET_MODEL(ENT(pev), "models/scientist.mdl"); + Precache(); + InitBoneControllers(); + + UTIL_SetSize(pev, Vector(-14, -14, 0), Vector(14, 14, 36)); + + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + pev->effects = 0; + pev->health = 50; + + m_bloodColor = BLOOD_COLOR_RED; + m_flFieldOfView = VIEW_FIELD_WIDE; // indicates the width of this monster's forward view cone ( as a dotproduct result ) + + m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD; + + SetBits(pev->spawnflags, SF_MONSTER_PREDISASTER); // predisaster only! + + if ( pev->body == -1 ) + {// -1 chooses a random head + pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head + } + // Luther is black, make his hands black + if ( pev->body == HEAD_LUTHER ) + pev->skin = 1; + + m_baseSequence = LookupSequence( "sitlookleft" ); + pev->sequence = m_baseSequence + RANDOM_LONG(0,4); + ResetSequenceInfo( ); + + SetThink (&CSittingZai::SittingThink); + pev->nextthink = gpGlobals->time + 0.1; + + DROP_TO_FLOOR ( ENT(pev) ); +} + +void CSittingZai :: Precache( void ) +{ + m_baseSequence = LookupSequence( "sitlookleft" ); + TalkInit(); +} + +//========================================================= +// ID as a passive human +//========================================================= +int CSittingZai :: Classify ( void ) +{ + return CLASS_HUMAN_PASSIVE; +} + + +int CSittingZai::FriendNumber( int arrayNumber ) +{ + static int array[3] = { 2, 1, 0 }; + if ( arrayNumber < 3 ) + return array[ arrayNumber ]; + return arrayNumber; +} + + + +//========================================================= +// sit, do stuff +//========================================================= +void CSittingZai :: SittingThink( void ) +{ + CBaseEntity *pent; + + StudioFrameAdvance( ); + + // try to greet player + if (FIdleHello()) + { + pent = FindNearestFriend(TRUE); + if (pent) + { + float yaw = VecToYaw(pent->pev->origin - pev->origin) - pev->angles.y; + + if (yaw > 180) yaw -= 360; + if (yaw < -180) yaw += 360; + + if (yaw > 0) + pev->sequence = m_baseSequence + SITTING_ANIM_sitlookleft; + else + pev->sequence = m_baseSequence + SITTING_ANIM_sitlookright; + + ResetSequenceInfo( ); + pev->frame = 0; + SetBoneController( 0, 0 ); + } + } + else if (m_fSequenceFinished) + { + int i = RANDOM_LONG(0,99); + m_headTurn = 0; + + if (m_flResponseDelay && gpGlobals->time > m_flResponseDelay) + { + // respond to question + IdleRespond(); + pev->sequence = m_baseSequence + SITTING_ANIM_sitscared; + m_flResponseDelay = 0; + } + else if (i < 30) + { + pev->sequence = m_baseSequence + SITTING_ANIM_sitting3; + + // turn towards player or nearest friend and speak + + if (!FBitSet(m_bitsSaid, bit_saidHelloPlayer)) + pent = FindNearestFriend(TRUE); + else + pent = FindNearestFriend(FALSE); + + if (!FIdleSpeak() || !pent) + { + m_headTurn = RANDOM_LONG(0,8) * 10 - 40; + pev->sequence = m_baseSequence + SITTING_ANIM_sitting3; + } + else + { + // only turn head if we spoke + float yaw = VecToYaw(pent->pev->origin - pev->origin) - pev->angles.y; + + if (yaw > 180) yaw -= 360; + if (yaw < -180) yaw += 360; + + if (yaw > 0) + pev->sequence = m_baseSequence + SITTING_ANIM_sitlookleft; + else + pev->sequence = m_baseSequence + SITTING_ANIM_sitlookright; + + //ALERT(at_console, "sitting speak\n"); + } + } + else if (i < 60) + { + pev->sequence = m_baseSequence + SITTING_ANIM_sitting3; + m_headTurn = RANDOM_LONG(0,8) * 10 - 40; + if (RANDOM_LONG(0,99) < 5) + { + //ALERT(at_console, "sitting speak2\n"); + FIdleSpeak(); + } + } + else if (i < 80) + { + pev->sequence = m_baseSequence + SITTING_ANIM_sitting2; + } + else if (i < 100) + { + pev->sequence = m_baseSequence + SITTING_ANIM_sitscared; + } + + ResetSequenceInfo( ); + pev->frame = 0; + SetBoneController( 0, m_headTurn ); + } + pev->nextthink = gpGlobals->time + 0.1; +} + +// prepare sitting scientist to answer a question +void CSittingZai :: SetAnswerQuestion( CTalkMonster *pSpeaker ) +{ + m_flResponseDelay = gpGlobals->time + RANDOM_FLOAT(3, 4); + m_hTalkTarget = (CBaseMonster *)pSpeaker; +} + + +//========================================================= +// FIdleSpeak +// ask question of nearby friend, or make statement +//========================================================= +int CSittingZai :: FIdleSpeak ( void ) +{ + // try to start a conversation, or make statement + int pitch; + + if (!FOkToSpeak()) + return FALSE; + + // set global min delay for next conversation + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); + + pitch = GetVoicePitch(); + + // if there is a friend nearby to speak to, play sentence, set friend's response time, return + + // try to talk to any standing or sitting scientists nearby + CBaseEntity *pentFriend = FindNearestFriend(FALSE); + + if (pentFriend && RANDOM_LONG(0,1)) + { + CTalkMonster *pTalkMonster = GetClassPtr((CTalkMonster *)pentFriend->pev); + pTalkMonster->SetAnswerQuestion( this ); + + IdleHeadTurn(pentFriend->pev->origin); + SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_PQUESTION], 1.0, ATTN_IDLE, 0, pitch ); + // set global min delay for next conversation + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); + return TRUE; + } + + // otherwise, play an idle statement + if (RANDOM_LONG(0,1)) + { + SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_PIDLE], 1.0, ATTN_IDLE, 0, pitch ); + // set global min delay for next conversation + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); + return TRUE; + } + + // never spoke + CTalkMonster::g_talkWaitTime = 0; + return FALSE; +} diff --git a/dlls/zamn.cpp b/dlls/zamn.cpp new file mode 100644 index 0000000..740b927 --- /dev/null +++ b/dlls/zamn.cpp @@ -0,0 +1,339 @@ +/* + Half-Life SDK Copyright © Valve + Code modified by Sabian Roberts + This code follows the Half Life 1 SDK LICENSE +*/ +//========================================================= +// ZAMN ZOMBIE +//========================================================= + +// UNDONE: Don't flinch every time you get hit + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "schedule.h" + + +//========================================================= +// Monster's Anim Events Go Here +//========================================================= +#define ZOMBIE_AE_ATTACK_RIGHT 0x01 +#define ZOMBIE_AE_ATTACK_LEFT 0x02 +#define ZOMBIE_AE_ATTACK_BOTH 0x03 + +#define ZOMBIE_FLINCH_DELAY 2 // at most one flinch every n secs + +class CZamnZombie : public CBaseMonster +{ +public: + void Spawn(void); + void Precache( void ); + void SetYawSpeed( void ); + int Classify ( void ); + void HandleAnimEvent( MonsterEvent_t *pEvent ); + int IgnoreConditions ( void ); + + float m_flNextFlinch; + + void PainSound( void ); + void AlertSound( void ); + void IdleSound( void ); + void AttackSound( void ); + + static const char *pAttackSounds[]; + static const char *pIdleSounds[]; + static const char *pAlertSounds[]; + static const char *pPainSounds[]; + static const char *pAttackHitSounds[]; + static const char *pAttackMissSounds[]; + + // No range attacks + BOOL CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; } + BOOL CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; } + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); +}; + +LINK_ENTITY_TO_CLASS( monster_zamn, CZamnZombie ); + +const char *CZamnZombie::pAttackHitSounds[] = +{ + "zombie/claw_strike1.wav", + "zombie/claw_strike2.wav", + "zombie/claw_strike3.wav", +}; + +const char *CZamnZombie::pAttackMissSounds[] = +{ + "zombie/claw_miss1.wav", + "zombie/claw_miss2.wav", +}; + +const char *CZamnZombie::pAttackSounds[] = +{ + "zombie/zo_attack1.wav", + "zombie/zo_attack2.wav", +}; + +const char *CZamnZombie::pIdleSounds[] = +{ + "zombie/zo_idle1.wav", + "zombie/zo_idle2.wav", + "zombie/zo_idle3.wav", + "zombie/zo_idle4.wav", +}; + +const char *CZamnZombie::pAlertSounds[] = +{ + "zombie/zo_alert10.wav", + "zombie/zo_alert20.wav", + "zombie/zo_alert30.wav", +}; + +const char *CZamnZombie::pPainSounds[] = +{ + "zombie/zo_pain1.wav", + "zombie/zo_pain2.wav", +}; + +//========================================================= +// Classify - indicates this monster's place in the +// relationship table. +//========================================================= +int CZamnZombie :: Classify ( void ) +{ + return CLASS_ALIEN_MONSTER; +} + +//========================================================= +// SetYawSpeed - allows each sequence to have a different +// turn rate associated with it. +//========================================================= +void CZamnZombie :: SetYawSpeed ( void ) +{ + int ys; + + ys = 120; + +#if 0 + switch ( m_Activity ) + { + } +#endif + + pev->yaw_speed = ys; +} + +int CZamnZombie :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +{ + // Take 30% damage from bullets + if ( bitsDamageType == DMG_BULLET ) + { + Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; + vecDir = vecDir.Normalize(); + float flForce = DamageForce( flDamage ); + pev->velocity = pev->velocity + vecDir * flForce; + flDamage *= 0.3; + } + + // HACK HACK -- until we fix this. + if ( IsAlive() ) + PainSound(); + return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); +} + +void CZamnZombie :: PainSound( void ) +{ + int pitch = 95 + RANDOM_LONG(0,9); + + if (RANDOM_LONG(0,5) < 2) + EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); +} + +void CZamnZombie :: AlertSound( void ) +{ + int pitch = 95 + RANDOM_LONG(0,9); + + EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); +} + +void CZamnZombie :: IdleSound( void ) +{ + int pitch = 100 + RANDOM_LONG(-5,5); + + // Play a random idle sound + EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pIdleSounds[ RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); +} + +void CZamnZombie :: AttackSound( void ) +{ + int pitch = 100 + RANDOM_LONG(-5,5); + + // Play a random attack sound + EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); +} + + +//========================================================= +// HandleAnimEvent - catches the monster-specific messages +// that occur when tagged animation frames are played. +//========================================================= +void CZamnZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) +{ + switch( pEvent->event ) + { + case ZOMBIE_AE_ATTACK_RIGHT: + { + // do stuff for this event. + // ALERT( at_console, "Slash right!\n" ); + CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); + if ( pHurt ) + { + if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + { + pHurt->pev->punchangle.z = -18; + pHurt->pev->punchangle.x = 5; + pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; + } + // Play a random attack hit sound + EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + } + else // Play a random attack miss sound + EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + + if (RANDOM_LONG(0,1)) + AttackSound(); + } + break; + + case ZOMBIE_AE_ATTACK_LEFT: + { + // do stuff for this event. + // ALERT( at_console, "Slash left!\n" ); + CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); + if ( pHurt ) + { + if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + { + pHurt->pev->punchangle.z = 18; + pHurt->pev->punchangle.x = 5; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 100; + } + EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + } + else + EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + + if (RANDOM_LONG(0,1)) + AttackSound(); + } + break; + + case ZOMBIE_AE_ATTACK_BOTH: + { + // do stuff for this event. + CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgBothSlash, DMG_SLASH ); + if ( pHurt ) + { + if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + { + pHurt->pev->punchangle.x = 5; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * -100; + } + EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + } + else + EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + + if (RANDOM_LONG(0,1)) + AttackSound(); + } + break; + + default: + CBaseMonster::HandleAnimEvent( pEvent ); + break; + } +} + +//========================================================= +// Spawn +//========================================================= +void CZamnZombie :: Spawn() +{ + Precache( ); + + SET_MODEL(ENT(pev), "models/zamnzombie.mdl"); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); + + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_GREEN; + pev->health = gSkillData.zombieHealth; + pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin. + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; + m_afCapability = bits_CAP_DOORS_GROUP; + + MonsterInit(); +} + +//========================================================= +// Precache - precaches all resources this monster needs +//========================================================= +void CZamnZombie :: Precache() +{ + int i; + + PRECACHE_MODEL("models/zamnzombie.mdl"); + + for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) + PRECACHE_SOUND((char *)pAttackHitSounds[i]); + + for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) + PRECACHE_SOUND((char *)pAttackMissSounds[i]); + + for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) + PRECACHE_SOUND((char *)pAttackSounds[i]); + + for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) + PRECACHE_SOUND((char *)pIdleSounds[i]); + + for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) + PRECACHE_SOUND((char *)pAlertSounds[i]); + + for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) + PRECACHE_SOUND((char *)pPainSounds[i]); +} + +//========================================================= +// AI Schedules Specific to this monster +//========================================================= + + + +int CZamnZombie::IgnoreConditions ( void ) +{ + int iIgnore = CBaseMonster::IgnoreConditions(); + + if ((m_Activity == ACT_MELEE_ATTACK1) || (m_Activity == ACT_MELEE_ATTACK1)) + { +#if 0 + if (pev->health < 20) + iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); + else +#endif + if (m_flNextFlinch >= gpGlobals->time) + iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); + } + + if ((m_Activity == ACT_SMALL_FLINCH) || (m_Activity == ACT_BIG_FLINCH)) + { + if (m_flNextFlinch < gpGlobals->time) + m_flNextFlinch = gpGlobals->time + ZOMBIE_FLINCH_DELAY; + } + + return iIgnore; + +} \ No newline at end of file diff --git a/dmc/cl_dll/view.cpp b/dmc/cl_dll/view.cpp index d9f7c47..a5546b8 100644 --- a/dmc/cl_dll/view.cpp +++ b/dmc/cl_dll/view.cpp @@ -1588,7 +1588,7 @@ void V_Init (void) v_centerspeed = gEngfuncs.pfnRegisterVariable( "v_centerspeed","500", 0 ); cl_bobcycle = gEngfuncs.pfnRegisterVariable( "cl_bobcycle","0.8", 0 );// best default for my experimental gun wag (sjb) - cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.02", 0 );// best default for my experimental gun wag (sjb) + cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.01", 0 );// best default for my experimental gun wag (sjb) cl_bobup = gEngfuncs.pfnRegisterVariable( "cl_bobup","0.5", 0 ); cl_waterdist = gEngfuncs.pfnRegisterVariable( "cl_waterdist","4", 0 ); cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 ); diff --git a/pm_shared/pm_shared.cpp b/pm_shared/pm_shared.cpp index 3f32779..a9951f1 100644 --- a/pm_shared/pm_shared.cpp +++ b/pm_shared/pm_shared.cpp @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -30,10 +30,10 @@ #include // isspace #ifdef CLIENT_DLL - // Spectator Mode - int iJumpSpectator; - float vJumpOrigin[3]; - float vJumpAngles[3]; +// Spectator Mode +int iJumpSpectator; +float vJumpOrigin[3]; +float vJumpAngles[3]; #endif static int pm_shared_initialized = 0; @@ -42,13 +42,13 @@ static int pm_shared_initialized = 0; //That version is actually considered to be Vector vec3_origin, so some compilers will fail to link it //Until the code for vectors is rewritten to allow for a single definition on client and server, this separate version is needed //TODO: fix -vec3_t shared_vec3_origin = {0,0,0}; +vec3_t shared_vec3_origin = { 0,0,0 }; #pragma warning( disable : 4305 ) -typedef enum {mod_brush, mod_sprite, mod_alias, mod_studio} modtype_t; +typedef enum { mod_brush, mod_sprite, mod_alias, mod_studio } modtype_t; -playermove_t *pmove = NULL; +playermove_t* pmove = NULL; typedef struct { @@ -67,8 +67,8 @@ typedef struct mplane_s typedef struct hull_s { - dclipnode_t *clipnodes; - mplane_t *planes; + dclipnode_t* clipnodes; + mplane_t* planes; int firstclipnode; int lastclipnode; vec3_t clip_mins; @@ -149,41 +149,41 @@ static int rgStuckLast[MAX_CLIENTS][2]; // Texture names static int gcTextures = 0; -static char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; +static char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; static char grgchTextureType[CTEXTURESMAX]; int g_onladder = 0; -void PM_SwapTextures( int i, int j ) +void PM_SwapTextures(int i, int j) { char chTemp; - char szTemp[ CBTEXTURENAMEMAX ]; + char szTemp[CBTEXTURENAMEMAX]; + + strcpy(szTemp, grgszTextureName[i]); + chTemp = grgchTextureType[i]; - strcpy( szTemp, grgszTextureName[ i ] ); - chTemp = grgchTextureType[ i ]; - - strcpy( grgszTextureName[ i ], grgszTextureName[ j ] ); - grgchTextureType[ i ] = grgchTextureType[ j ]; + strcpy(grgszTextureName[i], grgszTextureName[j]); + grgchTextureType[i] = grgchTextureType[j]; - strcpy( grgszTextureName[ j ], szTemp ); - grgchTextureType[ j ] = chTemp; + strcpy(grgszTextureName[j], szTemp); + grgchTextureType[j] = chTemp; } -void PM_SortTextures( void ) +void PM_SortTextures(void) { // Bubble sort, yuck, but this only occurs at startup and it's only 512 elements... // int i, j; - for ( i = 0 ; i < gcTextures; i++ ) + for (i = 0; i < gcTextures; i++) { - for ( j = i + 1; j < gcTextures; j++ ) + for (j = i + 1; j < gcTextures; j++) { - if ( stricmp( grgszTextureName[ i ], grgszTextureName[ j ] ) > 0 ) + if (stricmp(grgszTextureName[i], grgszTextureName[j]) > 0) { // Swap // - PM_SwapTextures( i, j ); + PM_SwapTextures(i, j); } } } @@ -193,11 +193,11 @@ void PM_InitTextureTypes() { char buffer[512]; int i, j; - byte *pMemFile; + byte* pMemFile; int fileSize, filePos; static qboolean bTextureTypeInit = false; - if ( bTextureTypeInit ) + if (bTextureTypeInit) return; memset(&(grgszTextureName[0][0]), 0, CTEXTURESMAX * CBTEXTURENAMEMAX); @@ -206,20 +206,20 @@ void PM_InitTextureTypes() gcTextures = 0; memset(buffer, 0, 512); - fileSize = pmove->COM_FileSize( "sound/materials.txt" ); - pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); - if ( !pMemFile ) + fileSize = pmove->COM_FileSize("sound/materials.txt"); + pMemFile = pmove->COM_LoadFile("sound/materials.txt", 5, NULL); + if (!pMemFile) return; filePos = 0; // for each line in the file... - while ( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX) ) + while (pmove->memfgets(pMemFile, fileSize, &filePos, buffer, 511) != NULL && (gcTextures < CTEXTURESMAX)) { // skip whitespace i = 0; - while(buffer[i] && isspace(buffer[i])) + while (buffer[i] && isspace(buffer[i])) i++; - + if (!buffer[i]) continue; @@ -231,9 +231,9 @@ void PM_InitTextureTypes() grgchTextureType[gcTextures] = toupper(buffer[i++]); // skip whitespace - while(buffer[i] && isspace(buffer[i])) + while (buffer[i] && isspace(buffer[i])) i++; - + if (!buffer[i]) continue; @@ -246,43 +246,43 @@ void PM_InitTextureTypes() continue; // null-terminate name and save in sentences array - j = V_min (j, CBTEXTURENAMEMAX-1+i); + j = V_min(j, CBTEXTURENAMEMAX - 1 + i); buffer[j] = 0; strcpy(&(grgszTextureName[gcTextures++][0]), &(buffer[i])); } // Must use engine to free since we are in a .dll - pmove->COM_FreeFile ( pMemFile ); + pmove->COM_FreeFile(pMemFile); PM_SortTextures(); bTextureTypeInit = true; } -char PM_FindTextureType( char *name ) +char PM_FindTextureType(char* name) { int left, right, pivot; int val; - assert( pm_shared_initialized ); + assert(pm_shared_initialized); left = 0; right = gcTextures - 1; - while ( left <= right ) + while (left <= right) { - pivot = ( left + right ) / 2; + pivot = (left + right) / 2; - val = strnicmp( name, grgszTextureName[ pivot ], CBTEXTURENAMEMAX-1 ); - if ( val == 0 ) + val = strnicmp(name, grgszTextureName[pivot], CBTEXTURENAMEMAX - 1); + if (val == 0) { - return grgchTextureType[ pivot ]; + return grgchTextureType[pivot]; } - else if ( val > 0 ) + else if (val > 0) { left = pivot + 1; } - else if ( val < 0 ) + else if (val < 0) { right = pivot - 1; } @@ -291,7 +291,7 @@ char PM_FindTextureType( char *name ) return CHAR_TEX_CONCRETE; } -void PM_PlayStepSound( int step, float fvol ) +void PM_PlayStepSound(int step, float fvol) { static int iSkipStep = 0; int irand; @@ -299,21 +299,21 @@ void PM_PlayStepSound( int step, float fvol ) pmove->iStepLeft = !pmove->iStepLeft; - if ( !pmove->runfuncs ) + if (!pmove->runfuncs) { return; } - - irand = pmove->RandomLong(0,1) + ( pmove->iStepLeft * 2 ); + + irand = pmove->RandomLong(0, 1) + (pmove->iStepLeft * 2); // FIXME mp_footsteps needs to be a movevar - if ( pmove->multiplayer && !pmove->movevars->footsteps ) + if (pmove->multiplayer && !pmove->movevars->footsteps) return; - VectorCopy( pmove->velocity, hvel ); + VectorCopy(pmove->velocity, hvel); hvel[2] = 0.0; - if ( pmove->multiplayer && ( !g_onladder && Length( hvel ) <= 220 ) ) + if (pmove->multiplayer && (!g_onladder && Length(hvel) <= 220)) return; // irand - 0,1 for right foot, 2,3 for left foot @@ -326,131 +326,131 @@ void PM_PlayStepSound( int step, float fvol ) case STEP_CONCRETE: switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_step1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_step3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_step2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_step4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_METAL: - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_metal1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_metal3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_metal2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_metal4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_DIRT: - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_dirt1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_dirt3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_dirt2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_dirt4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_VENT: - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_duct1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_duct3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_duct2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_duct4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_GRATE: - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_grate1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_grate3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_grate2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_grate4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_TILE: - if ( !pmove->RandomLong(0,4) ) + if (!pmove->RandomLong(0, 4)) irand = 4; - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 4: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile5.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_tile1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_tile3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_tile2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_tile4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 4: pmove->PM_PlaySound(CHAN_BODY, "player/pl_tile5.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_SLOSH: - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_WADE: - if ( iSkipStep == 0 ) + if (iSkipStep == 0) { iSkipStep++; break; } - if ( iSkipStep++ == 3 ) + if (iSkipStep++ == 3) { iSkipStep = 0; } switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_LADDER: - switch(irand) + switch (irand) { - // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_ladder1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_ladder3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_ladder2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_ladder4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; } -} +} int PM_MapTextureTypeStepType(char chTextureType) { switch (chTextureType) { - default: - case CHAR_TEX_CONCRETE: return STEP_CONCRETE; - case CHAR_TEX_METAL: return STEP_METAL; - case CHAR_TEX_DIRT: return STEP_DIRT; - case CHAR_TEX_VENT: return STEP_VENT; - case CHAR_TEX_GRATE: return STEP_GRATE; - case CHAR_TEX_TILE: return STEP_TILE; - case CHAR_TEX_SLOSH: return STEP_SLOSH; + default: + case CHAR_TEX_CONCRETE: return STEP_CONCRETE; + case CHAR_TEX_METAL: return STEP_METAL; + case CHAR_TEX_DIRT: return STEP_DIRT; + case CHAR_TEX_VENT: return STEP_VENT; + case CHAR_TEX_GRATE: return STEP_GRATE; + case CHAR_TEX_TILE: return STEP_TILE; + case CHAR_TEX_SLOSH: return STEP_SLOSH; } } @@ -461,13 +461,13 @@ PM_CatagorizeTextureType Determine texture info for the texture we are standing on. ==================== */ -void PM_CatagorizeTextureType( void ) +void PM_CatagorizeTextureType(void) { vec3_t start, end; - const char *pTextureName; + const char* pTextureName; - VectorCopy( pmove->origin, start ); - VectorCopy( pmove->origin, end ); + VectorCopy(pmove->origin, start); + VectorCopy(pmove->origin, end); // Straight down end[2] -= 64; @@ -476,8 +476,8 @@ void PM_CatagorizeTextureType( void ) pmove->sztexturename[0] = '\0'; pmove->chtexturetype = CHAR_TEX_CONCRETE; - pTextureName = pmove->PM_TraceTexture( pmove->onground, start, end ); - if ( !pTextureName ) + pTextureName = pmove->PM_TraceTexture(pmove->onground, start, end); + if (!pTextureName) return; // strip leading '-0' or '+0~' or '{' or '!' @@ -487,15 +487,15 @@ void PM_CatagorizeTextureType( void ) if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') pTextureName++; // '}}' - - strcpy( pmove->sztexturename, pTextureName); - pmove->sztexturename[ CBTEXTURENAMEMAX - 1 ] = 0; - + + strcpy(pmove->sztexturename, pTextureName); + pmove->sztexturename[CBTEXTURENAMEMAX - 1] = 0; + // get texture type - pmove->chtexturetype = PM_FindTextureType( pmove->sztexturename ); + pmove->chtexturetype = PM_FindTextureType(pmove->sztexturename); } -void PM_UpdateStepSound( void ) +void PM_UpdateStepSound(void) { int fWalking; float fvol; @@ -510,21 +510,21 @@ void PM_UpdateStepSound( void ) int fLadder; int step; - if ( pmove->flTimeStepSound > 0 ) + if (pmove->flTimeStepSound > 0) return; - if ( pmove->flags & FL_FROZEN ) + if (pmove->flags & FL_FROZEN) return; PM_CatagorizeTextureType(); - speed = Length( pmove->velocity ); + speed = Length(pmove->velocity); // determine if we are on a ladder - fLadder = ( pmove->movetype == MOVETYPE_FLY );// IsOnLadder(); + fLadder = (pmove->movetype == MOVETYPE_FLY);// IsOnLadder(); // UNDONE: need defined numbers for run, walk, crouch, crouch run velocities!!!! - if ( ( pmove->flags & FL_DUCKING) || fLadder ) + if ((pmove->flags & FL_DUCKING) || fLadder) { velwalk = 60; // These constants should be based on cl_movespeedkey * cl_forwardspeed somehow velrun = 80; // UNDONE: Move walking to server @@ -540,17 +540,17 @@ void PM_UpdateStepSound( void ) // If we're on a ladder or on the ground, and we're moving fast enough, // play step sound. Also, if pmove->flTimeStepSound is zero, get the new // sound right away - we just started moving in new level. - if ( (fLadder || ( pmove->onground != -1 ) ) && - ( Length( pmove->velocity ) > 0.0 ) && - ( speed >= velwalk || !pmove->flTimeStepSound ) ) + if ((fLadder || (pmove->onground != -1)) && + (Length(pmove->velocity) > 0.0) && + (speed >= velwalk || !pmove->flTimeStepSound)) { - fWalking = speed < velrun; + fWalking = speed < velrun; - VectorCopy( pmove->origin, center ); - VectorCopy( pmove->origin, knee ); - VectorCopy( pmove->origin, feet ); + VectorCopy(pmove->origin, center); + VectorCopy(pmove->origin, knee); + VectorCopy(pmove->origin, feet); - height = pmove->player_maxs[ pmove->usehull ][ 2 ] - pmove->player_mins[ pmove->usehull ][ 2 ]; + height = pmove->player_maxs[pmove->usehull][2] - pmove->player_mins[pmove->usehull][2]; knee[2] = pmove->origin[2] - 0.3 * height; feet[2] = pmove->origin[2] - 0.5 * height; @@ -562,43 +562,43 @@ void PM_UpdateStepSound( void ) fvol = 0.35; pmove->flTimeStepSound = 350; } - else if ( pmove->PM_PointContents ( knee, NULL ) == CONTENTS_WATER ) + else if (pmove->PM_PointContents(knee, NULL) == CONTENTS_WATER) { step = STEP_WADE; fvol = 0.65; pmove->flTimeStepSound = 600; } - else if ( pmove->PM_PointContents ( feet, NULL ) == CONTENTS_WATER ) + else if (pmove->PM_PointContents(feet, NULL) == CONTENTS_WATER) { step = STEP_SLOSH; fvol = fWalking ? 0.2 : 0.5; - pmove->flTimeStepSound = fWalking ? 400 : 300; + pmove->flTimeStepSound = fWalking ? 400 : 300; } else { // find texture under player, if different from current texture, // get material type - step = PM_MapTextureTypeStepType( pmove->chtexturetype ); + step = PM_MapTextureTypeStepType(pmove->chtexturetype); - switch ( pmove->chtexturetype ) + switch (pmove->chtexturetype) { default: - case CHAR_TEX_CONCRETE: + case CHAR_TEX_CONCRETE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_METAL: + case CHAR_TEX_METAL: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_DIRT: + case CHAR_TEX_DIRT: fvol = fWalking ? 0.25 : 0.55; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_VENT: + case CHAR_TEX_VENT: fvol = fWalking ? 0.4 : 0.7; pmove->flTimeStepSound = fWalking ? 400 : 300; break; @@ -608,7 +608,7 @@ void PM_UpdateStepSound( void ) pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_TILE: + case CHAR_TEX_TILE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; @@ -619,17 +619,17 @@ void PM_UpdateStepSound( void ) break; } } - + pmove->flTimeStepSound += flduck; // slower step time if ducking // play the sound // 35% volume if ducking - if ( pmove->flags & FL_DUCKING ) + if (pmove->flags & FL_DUCKING) { fvol *= 0.35; } - PM_PlayStepSound( step, fvol ); + PM_PlayStepSound(step, fvol); } } @@ -652,7 +652,7 @@ qboolean PM_AddToTouched(pmtrace_t tr, vec3_t impactvelocity) if (i != pmove->numtouch) // Already in list. return false; - VectorCopy( impactvelocity, tr.deltavelocity ); + VectorCopy(impactvelocity, tr.deltavelocity); if (pmove->numtouch >= MAX_PHYSENTS) pmove->Con_DPrintf("Too many entities were touched!\n"); @@ -668,36 +668,36 @@ PM_CheckVelocity See if the player has a bogus velocity value. ================ */ -void PM_CheckVelocity () +void PM_CheckVelocity() { int i; -// -// bound velocity -// - for (i=0 ; i<3 ; i++) + // + // bound velocity + // + for (i = 0; i < 3; i++) { // See if it's bogus. if (IS_NAN(pmove->velocity[i])) { - pmove->Con_Printf ("PM Got a NaN velocity %i\n", i); + pmove->Con_Printf("PM Got a NaN velocity %i\n", i); pmove->velocity[i] = 0; } if (IS_NAN(pmove->origin[i])) { - pmove->Con_Printf ("PM Got a NaN origin on %i\n", i); + pmove->Con_Printf("PM Got a NaN origin on %i\n", i); pmove->origin[i] = 0; } // Bound it. - if (pmove->velocity[i] > pmove->movevars->maxvelocity) + if (pmove->velocity[i] > pmove->movevars->maxvelocity) { - pmove->Con_DPrintf ("PM Got a velocity too high on %i\n", i); + pmove->Con_DPrintf("PM Got a velocity too high on %i\n", i); pmove->velocity[i] = pmove->movevars->maxvelocity; } else if (pmove->velocity[i] < -pmove->movevars->maxvelocity) { - pmove->Con_DPrintf ("PM Got a velocity too low on %i\n", i); + pmove->Con_DPrintf("PM Got a velocity too low on %i\n", i); pmove->velocity[i] = -pmove->movevars->maxvelocity; } } @@ -713,43 +713,43 @@ returns the blocked flags: 0x02 == step / wall ================== */ -int PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) +int PM_ClipVelocity(vec3_t in, vec3_t normal, vec3_t out, float overbounce) { float backoff; float change; float angle; int i, blocked; - - angle = normal[ 2 ]; + + angle = normal[2]; blocked = 0x00; // Assume unblocked. if (angle > 0) // If the plane that is blocking us has a positive z component, then assume it's a floor. blocked |= 0x01; // if (!angle) // If the plane has no Z, it is vertical (wall/step) blocked |= 0x02; // - + // Determine how far along plane to slide based on incoming direction. // Scale by overbounce factor. - backoff = DotProduct (in, normal) * overbounce; + backoff = DotProduct(in, normal) * overbounce; - for (i=0 ; i<3 ; i++) + for (i = 0; i < 3; i++) { - change = normal[i]*backoff; + change = normal[i] * backoff; out[i] = in[i] - change; // If out velocity is too small, zero it out. if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) out[i] = 0; } - + // Return blocking flags. return blocked; } -void PM_AddCorrectGravity () +void PM_AddCorrectGravity() { float ent_gravity; - if ( pmove->waterjumptime ) + if (pmove->waterjumptime) return; if (pmove->gravity) @@ -759,7 +759,7 @@ void PM_AddCorrectGravity () // Add gravity so they'll be in the correct position during movement // yes, this 0.5 looks wrong, but it's not. - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * 0.5 * pmove->frametime ); + pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * 0.5 * pmove->frametime); pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; pmove->basevelocity[2] = 0; @@ -767,11 +767,11 @@ void PM_AddCorrectGravity () } -void PM_FixupGravityVelocity () +void PM_FixupGravityVelocity() { float ent_gravity; - if ( pmove->waterjumptime ) + if (pmove->waterjumptime) return; if (pmove->gravity) @@ -780,7 +780,7 @@ void PM_FixupGravityVelocity () ent_gravity = 1.0; // Get the correct velocity for the end of the dt - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5 ); + pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5); PM_CheckVelocity(); } @@ -792,7 +792,7 @@ PM_FlyMove The basic solid body movement clip that slides along multiple planes ============ */ -int PM_FlyMove (void) +int PM_FlyMove(void) { int bumpcount, numbumps; vec3_t dir; @@ -806,29 +806,29 @@ int PM_FlyMove (void) vec3_t end; float time_left, allFraction; int blocked; - - numbumps = 4; // Bump up to four times - - blocked = 0; // Assume not blocked + + numbumps = 4; // Bump up to four times + + blocked = 0; // Assume not blocked numplanes = 0; // and not sliding along any planes - VectorCopy (pmove->velocity, original_velocity); // Store original velocity - VectorCopy (pmove->velocity, primal_velocity); - + VectorCopy(pmove->velocity, original_velocity); // Store original velocity + VectorCopy(pmove->velocity, primal_velocity); + allFraction = 0; time_left = pmove->frametime; // Total time for this movement operation. - for (bumpcount=0 ; bumpcountvelocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) break; // Assume we can move all the way from the current origin to the // end point. - for (i=0 ; i<3 ; i++) + for (i = 0; i < 3; i++) end[i] = pmove->origin[i] + time_left * pmove->velocity[i]; // See if we can make it from origin to end point. - trace = pmove->PM_PlayerTrace (pmove->origin, end, PM_NORMAL, -1 ); + trace = pmove->PM_PlayerTrace(pmove->origin, end, PM_NORMAL, -1); allFraction += trace.fraction; // If we started in a solid object, or we were in solid space @@ -836,7 +836,7 @@ int PM_FlyMove (void) // are blocked by floor and wall. if (trace.allsolid) { // entity is trapped in another solid - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); //Con_DPrintf("Trapped 4\n"); return 4; } @@ -846,22 +846,22 @@ int PM_FlyMove (void) // zero the plane counter. if (trace.fraction > 0) { // actually covered some distance - VectorCopy (trace.endpos, pmove->origin); - VectorCopy (pmove->velocity, original_velocity); + VectorCopy(trace.endpos, pmove->origin); + VectorCopy(pmove->velocity, original_velocity); numplanes = 0; } // If we covered the entire distance, we are done // and can return. if (trace.fraction == 1) - break; // moved the entire distance + break; // moved the entire distance - //if (!trace.ent) - // Sys_Error ("PM_PlayerTrace: !trace.ent"); + //if (!trace.ent) + // Sys_Error ("PM_PlayerTrace: !trace.ent"); - // Save entity that blocked us (since fraction was < 1.0) - // for contact - // Add it if it's not already in the list!!! + // Save entity that blocked us (since fraction was < 1.0) + // for contact + // Add it if it's not already in the list!!! PM_AddToTouched(trace, pmove->velocity); // If the plane we hit has a high z component in the normal, then @@ -881,98 +881,98 @@ int PM_FlyMove (void) // Reduce amount of pmove->frametime left by total time left * fraction // that we covered. time_left -= time_left * trace.fraction; - + // Did we run out of planes to clip against? if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen // Stop our movement if so. - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); //Con_DPrintf("Too many planes 4\n"); break; } // Set up next clipping plane - VectorCopy (trace.plane.normal, planes[numplanes]); + VectorCopy(trace.plane.normal, planes[numplanes]); numplanes++; -// + // -// modify original_velocity so it parallels all of the clip planes -// - if ( pmove->movetype == MOVETYPE_WALK && - ((pmove->onground == -1) || (pmove->friction != 1)) ) // relfect player velocity + // modify original_velocity so it parallels all of the clip planes + // + if (pmove->movetype == MOVETYPE_WALK && + ((pmove->onground == -1) || (pmove->friction != 1))) // relfect player velocity { - for ( i = 0; i < numplanes; i++ ) + for (i = 0; i < numplanes; i++) { - if ( planes[i][2] > 0.7 ) + if (planes[i][2] > 0.7) {// floor or slope - PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1 ); - VectorCopy( new_velocity, original_velocity ); + PM_ClipVelocity(original_velocity, planes[i], new_velocity, 1); + VectorCopy(new_velocity, original_velocity); } - else - PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * (1-pmove->friction) ); + else + PM_ClipVelocity(original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * (1 - pmove->friction)); } - VectorCopy( new_velocity, pmove->velocity ); - VectorCopy( new_velocity, original_velocity ); + VectorCopy(new_velocity, pmove->velocity); + VectorCopy(new_velocity, original_velocity); } else { - for (i=0 ; ivelocity, 1); - for (j=0 ; jvelocity, planes[j]) < 0) + if (DotProduct(pmove->velocity, planes[j]) < 0) break; // not ok } if (j == numplanes) // Didn't have to clip, so we're ok break; } - + // Did we go all the way through plane set if (i != numplanes) { // go along this plane // pmove->velocity is set in clipping call, no need to set again. - ; + ; } else { // go along the crease if (numplanes != 2) { //Con_Printf ("clip velocity, numplanes == %i\n",numplanes); - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); //Con_DPrintf("Trapped 4\n"); break; } - CrossProduct (planes[0], planes[1], dir); - d = DotProduct (dir, pmove->velocity); - VectorScale (dir, d, pmove->velocity ); + CrossProduct(planes[0], planes[1], dir); + d = DotProduct(dir, pmove->velocity); + VectorScale(dir, d, pmove->velocity); } - // - // if original velocity is against the original velocity, stop dead - // to avoid tiny occilations in sloping corners - // - if (DotProduct (pmove->velocity, primal_velocity) <= 0) + // + // if original velocity is against the original velocity, stop dead + // to avoid tiny occilations in sloping corners + // + if (DotProduct(pmove->velocity, primal_velocity) <= 0) { //Con_DPrintf("Back\n"); - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); break; } } } - if ( allFraction == 0 ) + if (allFraction == 0) { - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); //Con_DPrintf( "Don't stick\n" ); } @@ -984,7 +984,7 @@ int PM_FlyMove (void) PM_Accelerate ============== */ -void PM_Accelerate (vec3_t wishdir, float wishspeed, float accel) +void PM_Accelerate(vec3_t wishdir, float wishspeed, float accel) { int i; float addspeed, accelspeed, currentspeed; @@ -998,7 +998,7 @@ void PM_Accelerate (vec3_t wishdir, float wishspeed, float accel) return; // See if we are changing direction a bit - currentspeed = DotProduct (pmove->velocity, wishdir); + currentspeed = DotProduct(pmove->velocity, wishdir); // Reduce wishspeed by the amount of veer. addspeed = wishspeed - currentspeed; @@ -1009,15 +1009,15 @@ void PM_Accelerate (vec3_t wishdir, float wishspeed, float accel) // Determine amount of accleration. accelspeed = accel * pmove->frametime * wishspeed * pmove->friction; - + // Cap at addspeed if (accelspeed > addspeed) accelspeed = addspeed; - + // Adjust velocity. - for (i=0 ; i<3 ; i++) + for (i = 0; i < 3; i++) { - pmove->velocity[i] += accelspeed * wishdir[i]; + pmove->velocity[i] += accelspeed * wishdir[i]; } } @@ -1028,7 +1028,7 @@ PM_WalkMove Only used by players. Moves along the ground when player is a MOVETYPE_WALK. ====================== */ -void PM_WalkMove () +void PM_WalkMove() { int clip; int oldonground; @@ -1046,48 +1046,48 @@ void PM_WalkMove () float downdist, updist; pmtrace_t trace; - + // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + // Zero out z components of movement vectors pmove->forward[2] = 0; - pmove->right[2] = 0; - - VectorNormalize (pmove->forward); // Normalize remainder of vectors. - VectorNormalize (pmove->right); // - - for (i=0 ; i<2 ; i++) // Determine x and y parts of velocity - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; - + pmove->right[2] = 0; + + VectorNormalize(pmove->forward); // Normalize remainder of vectors. + VectorNormalize(pmove->right); // + + for (i = 0; i < 2; i++) // Determine x and y parts of velocity + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; + wishvel[2] = 0; // Zero out z part of velocity - VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move + VectorCopy(wishvel, wishdir); // Determine maginitude of speed of move wishspeed = VectorNormalize(wishdir); -// -// Clamp to server defined max speed -// + // + // Clamp to server defined max speed + // if (wishspeed > pmove->maxspeed) { - VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); + VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); wishspeed = pmove->maxspeed; } // Set pmove velocity pmove->velocity[2] = 0; - PM_Accelerate (wishdir, wishspeed, pmove->movevars->accelerate); + PM_Accelerate(wishdir, wishspeed, pmove->movevars->accelerate); pmove->velocity[2] = 0; // Add in any base velocity to the current velocity. - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity ); + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - spd = Length( pmove->velocity ); + spd = Length(pmove->velocity); if (spd < 1.0f) { - VectorClear( pmove->velocity ); + VectorClear(pmove->velocity); return; } @@ -1097,24 +1097,24 @@ void PM_WalkMove () oldonground = pmove->onground; -// first try just moving to the destination - dest[0] = pmove->origin[0] + pmove->velocity[0]*pmove->frametime; - dest[1] = pmove->origin[1] + pmove->velocity[1]*pmove->frametime; + // first try just moving to the destination + dest[0] = pmove->origin[0] + pmove->velocity[0] * pmove->frametime; + dest[1] = pmove->origin[1] + pmove->velocity[1] * pmove->frametime; dest[2] = pmove->origin[2]; // first try moving directly to the next spot - VectorCopy (dest, start); - trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); + VectorCopy(dest, start); + trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); // If we made it all the way, then copy trace end // as new player position. if (trace.fraction == 1) { - VectorCopy (trace.endpos, pmove->origin); + VectorCopy(trace.endpos, pmove->origin); return; } if (oldonground == -1 && // Don't walk up stairs if not on ground. - pmove->waterlevel == 0) + pmove->waterlevel == 0) return; if (pmove->waterjumptime) // If we are jumping out of water, don't do anything more. @@ -1122,69 +1122,70 @@ void PM_WalkMove () // Try sliding forward both on ground and up 16 pixels // take the move that goes farthest - VectorCopy (pmove->origin, original); // Save out original pos & - VectorCopy (pmove->velocity, originalvel); // velocity. + VectorCopy(pmove->origin, original); // Save out original pos & + VectorCopy(pmove->velocity, originalvel); // velocity. // Slide move - clip = PM_FlyMove (); + clip = PM_FlyMove(); // Copy the results out - VectorCopy (pmove->origin , down); - VectorCopy (pmove->velocity, downvel); + VectorCopy(pmove->origin, down); + VectorCopy(pmove->velocity, downvel); // Reset original values. - VectorCopy (original, pmove->origin); + VectorCopy(original, pmove->origin); - VectorCopy (originalvel, pmove->velocity); + VectorCopy(originalvel, pmove->velocity); // Start out up one stair height - VectorCopy (pmove->origin, dest); + VectorCopy(pmove->origin, dest); dest[2] += pmove->movevars->stepsize; - - trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); + + trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); // If we started okay and made it part of the way at least, // copy the results to the movement start position and then // run another move try. if (!trace.startsolid && !trace.allsolid) { - VectorCopy (trace.endpos, pmove->origin); + VectorCopy(trace.endpos, pmove->origin); } -// slide move the rest of the way. - clip = PM_FlyMove (); + // slide move the rest of the way. + clip = PM_FlyMove(); -// Now try going back down from the end point -// press down the stepheight - VectorCopy (pmove->origin, dest); + // Now try going back down from the end point + // press down the stepheight + VectorCopy(pmove->origin, dest); dest[2] -= pmove->movevars->stepsize; - - trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); + + trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); // If we are not on the ground any more then // use the original movement attempt - if ( trace.plane.normal[2] < 0.7) + if (trace.plane.normal[2] < 0.7) goto usedown; // If the trace ended up in empty space, copy the end // over to the origin. if (!trace.startsolid && !trace.allsolid) { - VectorCopy (trace.endpos, pmove->origin); + VectorCopy(trace.endpos, pmove->origin); } // Copy this origion to up. - VectorCopy (pmove->origin, pmove->up); + VectorCopy(pmove->origin, pmove->up); // decide which one went farther - downdist = (down[0] - original[0])*(down[0] - original[0]) - + (down[1] - original[1])*(down[1] - original[1]); - updist = (pmove->up[0] - original[0])*(pmove->up[0] - original[0]) - + (pmove->up[1] - original[1])*(pmove->up[1] - original[1]); + downdist = (down[0] - original[0]) * (down[0] - original[0]) + + (down[1] - original[1]) * (down[1] - original[1]); + updist = (pmove->up[0] - original[0]) * (pmove->up[0] - original[0]) + + (pmove->up[1] - original[1]) * (pmove->up[1] - original[1]); if (downdist > updist) { -usedown: - VectorCopy (down , pmove->origin); - VectorCopy (downvel, pmove->velocity); - } else // copy z value from slide move + usedown: + VectorCopy(down, pmove->origin); + VectorCopy(downvel, pmove->velocity); + } + else // copy z value from slide move pmove->velocity[2] = downvel[2]; } @@ -1196,24 +1197,24 @@ PM_Friction Handles both ground friction and water friction ================== */ -void PM_Friction (void) +void PM_Friction(void) { - float *vel; + float* vel; float speed, newspeed, control; float friction; float drop; vec3_t newvel; - + // If we are in water jump cycle, don't apply friction if (pmove->waterjumptime) return; // Get velocity vel = pmove->velocity; - + // Calculate speed - speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1] + vel[2]*vel[2]); - + speed = sqrt(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2]); + // If too slow, return if (speed < 0.1f) { @@ -1222,24 +1223,24 @@ void PM_Friction (void) drop = 0; -// apply ground friction + // apply ground friction if (pmove->onground != -1) // On an entity that is the ground { vec3_t start, stop; pmtrace_t trace; - start[0] = stop[0] = pmove->origin[0] + vel[0]/speed*16; - start[1] = stop[1] = pmove->origin[1] + vel[1]/speed*16; + start[0] = stop[0] = pmove->origin[0] + vel[0] / speed * 16; + start[1] = stop[1] = pmove->origin[1] + vel[1] / speed * 16; start[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2]; stop[2] = start[2] - 34; - trace = pmove->PM_PlayerTrace (start, stop, PM_NORMAL, -1 ); + trace = pmove->PM_PlayerTrace(start, stop, PM_NORMAL, -1); if (trace.fraction == 1.0) - friction = pmove->movevars->friction*pmove->movevars->edgefriction; + friction = pmove->movevars->friction * pmove->movevars->edgefriction; else friction = pmove->movevars->friction; - + // Grab friction value. //friction = pmove->movevars->friction; @@ -1250,14 +1251,14 @@ void PM_Friction (void) control = (speed < pmove->movevars->stopspeed) ? pmove->movevars->stopspeed : speed; // Add the amount to t'he drop amount. - drop += control*friction*pmove->frametime; + drop += control * friction * pmove->frametime; } -// apply water friction -// if (pmove->waterlevel) -// drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime; + // apply water friction + // if (pmove->waterlevel) + // drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime; -// scale the velocity + // scale the velocity newspeed = speed - drop; if (newspeed < 0) newspeed = 0; @@ -1270,14 +1271,14 @@ void PM_Friction (void) newvel[1] = vel[1] * newspeed; newvel[2] = vel[2] * newspeed; - VectorCopy( newvel, pmove->velocity ); + VectorCopy(newvel, pmove->velocity); } -void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) +void PM_AirAccelerate(vec3_t wishdir, float wishspeed, float accel) { int i; float addspeed, accelspeed, currentspeed, wishspd = wishspeed; - + if (pmove->dead) return; if (pmove->waterjumptime) @@ -1285,11 +1286,11 @@ void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) // Cap speed //wishspd = VectorNormalize (pmove->wishveloc); - + if (wishspd > 30) wishspd = 30; // Determine veer amount - currentspeed = DotProduct (pmove->velocity, wishdir); + currentspeed = DotProduct(pmove->velocity, wishdir); // See how much to add addspeed = wishspd - currentspeed; // If not adding any, done. @@ -1301,11 +1302,11 @@ void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) // Cap it if (accelspeed > addspeed) accelspeed = addspeed; - + // Adjust pmove vel. - for (i=0 ; i<3 ; i++) + for (i = 0; i < 3; i++) { - pmove->velocity[i] += accelspeed*wishdir[i]; + pmove->velocity[i] += accelspeed * wishdir[i]; } } @@ -1315,7 +1316,7 @@ PM_WaterMove =================== */ -void PM_WaterMove (void) +void PM_WaterMove(void) { int i; vec3_t wishvel; @@ -1327,11 +1328,11 @@ void PM_WaterMove (void) float speed, newspeed, addspeed, accelspeed; -// -// user intentions -// - for (i=0 ; i<3 ; i++) - wishvel[i] = pmove->forward[i]*pmove->cmd.forwardmove + pmove->right[i]*pmove->cmd.sidemove; + // + // user intentions + // + for (i = 0; i < 3; i++) + wishvel[i] = pmove->forward[i] * pmove->cmd.forwardmove + pmove->right[i] * pmove->cmd.sidemove; // Sinking after no other movement occurs if (!pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove) @@ -1340,20 +1341,20 @@ void PM_WaterMove (void) wishvel[2] += pmove->cmd.upmove; // Copy it over and determine speed - VectorCopy (wishvel, wishdir); + VectorCopy(wishvel, wishdir); wishspeed = VectorNormalize(wishdir); // Cap speed. if (wishspeed > pmove->maxspeed) { - VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); + VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); wishspeed = pmove->maxspeed; } // Slow us down a bit. wishspeed *= 0.8; - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); -// Water friction + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + // Water friction VectorCopy(pmove->velocity, temp); speed = VectorNormalize(temp); if (speed) @@ -1362,15 +1363,15 @@ void PM_WaterMove (void) if (newspeed < 0) newspeed = 0; - VectorScale (pmove->velocity, newspeed/speed, pmove->velocity); + VectorScale(pmove->velocity, newspeed / speed, pmove->velocity); } else newspeed = 0; -// -// water acceleration -// - if ( wishspeed < 0.1f ) + // + // water acceleration + // + if (wishspeed < 0.1f) { return; } @@ -1388,20 +1389,20 @@ void PM_WaterMove (void) pmove->velocity[i] += accelspeed * wishvel[i]; } -// Now move -// assume it is a stair or a slope, so press down from stepheight above - VectorMA (pmove->origin, pmove->frametime, pmove->velocity, dest); - VectorCopy (dest, start); + // Now move + // assume it is a stair or a slope, so press down from stepheight above + VectorMA(pmove->origin, pmove->frametime, pmove->velocity, dest); + VectorCopy(dest, start); start[2] += pmove->movevars->stepsize + 1; - trace = pmove->PM_PlayerTrace (start, dest, PM_NORMAL, -1 ); + trace = pmove->PM_PlayerTrace(start, dest, PM_NORMAL, -1); if (!trace.startsolid && !trace.allsolid) // FIXME: check steep slope? { // walked up the step, so just keep result and exit - VectorCopy (trace.endpos, pmove->origin); + VectorCopy(trace.endpos, pmove->origin); return; } - + // Try moving straight along out normal path. - PM_FlyMove (); + PM_FlyMove(); } @@ -1411,7 +1412,7 @@ PM_AirMove =================== */ -void PM_AirMove (void) +void PM_AirMove(void) { int i; vec3_t wishvel; @@ -1422,44 +1423,44 @@ void PM_AirMove (void) // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + // Zero out z components of movement vectors pmove->forward[2] = 0; - pmove->right[2] = 0; + pmove->right[2] = 0; // Renormalize - VectorNormalize (pmove->forward); - VectorNormalize (pmove->right); + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); // Determine x and y parts of velocity - for (i=0 ; i<2 ; i++) + for (i = 0; i < 2; i++) { - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; } // Zero out z part of velocity - wishvel[2] = 0; + wishvel[2] = 0; - // Determine maginitude of speed of move - VectorCopy (wishvel, wishdir); + // Determine maginitude of speed of move + VectorCopy(wishvel, wishdir); wishspeed = VectorNormalize(wishdir); // Clamp to server defined max speed if (wishspeed > pmove->maxspeed) { - VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); + VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); wishspeed = pmove->maxspeed; } - - PM_AirAccelerate (wishdir, wishspeed, pmove->movevars->airaccelerate); + + PM_AirAccelerate(wishdir, wishspeed, pmove->movevars->airaccelerate); // Add in any base velocity to the current velocity. - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity ); + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - PM_FlyMove (); + PM_FlyMove(); } -qboolean PM_InWater( void ) +qboolean PM_InWater(void) { - return ( pmove->waterlevel > 1 ); + return (pmove->waterlevel > 1); } /* @@ -1469,7 +1470,7 @@ PM_CheckWater Sets pmove->waterlevel and pmove->watertype values. ============= */ -qboolean PM_CheckWater () +qboolean PM_CheckWater() { vec3_t point; int cont; @@ -1481,15 +1482,15 @@ qboolean PM_CheckWater () point[0] = pmove->origin[0] + (pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0]) * 0.5; point[1] = pmove->origin[1] + (pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1]) * 0.5; point[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2] + 1; - + // Assume that we are not in water at all. pmove->waterlevel = 0; pmove->watertype = CONTENTS_EMPTY; // Grab point contents. - cont = pmove->PM_PointContents (point, &truecont ); + cont = pmove->PM_PointContents(point, &truecont); // Are we under water? (not solid and not empty?) - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) { // Set water type pmove->watertype = cont; @@ -1502,9 +1503,9 @@ qboolean PM_CheckWater () // Now check a point that is at the player hull midpoint. point[2] = pmove->origin[2] + heightover2; - cont = pmove->PM_PointContents (point, NULL ); + cont = pmove->PM_PointContents(point, NULL); // If that point is also under water... - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) { // Set a higher water level. pmove->waterlevel = 2; @@ -1512,14 +1513,14 @@ qboolean PM_CheckWater () // Now check the eye position. (view_ofs is relative to the origin) point[2] = pmove->origin[2] + pmove->view_ofs[2]; - cont = pmove->PM_PointContents (point, NULL ); - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + cont = pmove->PM_PointContents(point, NULL); + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) pmove->waterlevel = 3; // In over our eyes } // Adjust velocity based on water current, if any. - if ( ( truecont <= CONTENTS_CURRENT_0 ) && - ( truecont >= CONTENTS_CURRENT_DOWN ) ) + if ((truecont <= CONTENTS_CURRENT_0) && + (truecont >= CONTENTS_CURRENT_DOWN)) { // The deeper we are, the stronger the current. static vec3_t current_table[] = @@ -1528,7 +1529,7 @@ qboolean PM_CheckWater () {0, -1, 0}, {0, 0, 1}, {0, 0, -1} }; - VectorMA (pmove->basevelocity, 50.0*pmove->waterlevel, current_table[CONTENTS_CURRENT_0 - truecont], pmove->basevelocity); + VectorMA(pmove->basevelocity, 50.0 * pmove->waterlevel, current_table[CONTENTS_CURRENT_0 - truecont], pmove->basevelocity); } } @@ -1540,21 +1541,21 @@ qboolean PM_CheckWater () PM_CatagorizePosition ============= */ -void PM_CatagorizePosition (void) +void PM_CatagorizePosition(void) { vec3_t point; pmtrace_t tr; -// if the player hull point one unit down is solid, the player -// is on ground + // if the player hull point one unit down is solid, the player + // is on ground -// see if standing on something solid + // see if standing on something solid - // Doing this before we move may introduce a potential latency in water detection, but - // doing it after can get us stuck on the bottom in water if the amount we move up - // is less than the 1 pixel 'threshold' we're about to snap to. Also, we'll call - // this several times per frame, so we really need to avoid sticking to the bottom of - // water on each call, and the converse case will correct itself if called twice. + // Doing this before we move may introduce a potential latency in water detection, but + // doing it after can get us stuck on the bottom in water if the amount we move up + // is less than the 1 pixel 'threshold' we're about to snap to. Also, we'll call + // this several times per frame, so we really need to avoid sticking to the bottom of + // water on each call, and the converse case will correct itself if called twice. PM_CheckWater(); point[0] = pmove->origin[0]; @@ -1568,9 +1569,9 @@ void PM_CatagorizePosition (void) else { // Try and move down. - tr = pmove->PM_PlayerTrace (pmove->origin, point, PM_NORMAL, -1 ); + tr = pmove->PM_PlayerTrace(pmove->origin, point, PM_NORMAL, -1); // If we hit a steep plane, we are not on ground - if ( tr.plane.normal[2] < 0.7) + if (tr.plane.normal[2] < 0.7) pmove->onground = -1; // too steep else pmove->onground = tr.ent; // Otherwise, point to index of ent under us. @@ -1582,7 +1583,7 @@ void PM_CatagorizePosition (void) pmove->waterjumptime = 0; // If we could make the move, drop us down that 1 pixel if (pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid) - VectorCopy (tr.endpos, pmove->origin); + VectorCopy(tr.endpos, pmove->origin); } // Standing on an entity other than the world @@ -1603,7 +1604,7 @@ Grab a test offset for the player based on a passed in index */ int PM_GetRandomStuckOffsets(int nIndex, int server, vec3_t offset) { - // Last time we did a full + // Last time we did a full int idx; idx = rgStuckLast[nIndex][server]++; @@ -1628,7 +1629,7 @@ allow for the cut precision of the net coordinates */ #define PM_CHECKSTUCK_MINTIME 0.05 // Don't check again too quickly. -int PM_CheckStuck (void) +int PM_CheckStuck(void) { vec3_t base; vec3_t offset; @@ -1642,14 +1643,14 @@ int PM_CheckStuck (void) static float rgStuckCheckTime[MAX_CLIENTS][2]; // Last time we did a full // If position is okay, exit - hitent = pmove->PM_TestPlayerPosition (pmove->origin, &traceresult ); - if (hitent == -1 ) + hitent = pmove->PM_TestPlayerPosition(pmove->origin, &traceresult); + if (hitent == -1) { - PM_ResetStuckOffsets( pmove->player_index, pmove->server ); + PM_ResetStuckOffsets(pmove->player_index, pmove->server); return 0; } - VectorCopy (pmove->origin, base); + VectorCopy(pmove->origin, base); // // Deal with precision error in network. @@ -1657,21 +1658,21 @@ int PM_CheckStuck (void) if (!pmove->server) { // World or BSP model - if ( ( hitent == 0 ) || - ( pmove->physents[hitent].model != NULL ) ) + if ((hitent == 0) || + (pmove->physents[hitent].model != NULL)) { int nReps = 0; - PM_ResetStuckOffsets( pmove->player_index, pmove->server ); - do + PM_ResetStuckOffsets(pmove->player_index, pmove->server); + do { i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); VectorAdd(base, offset, test); - if (pmove->PM_TestPlayerPosition (test, &traceresult ) == -1) + if (pmove->PM_TestPlayerPosition(test, &traceresult) == -1) { - PM_ResetStuckOffsets( pmove->player_index, pmove->server ); - - VectorCopy ( test, pmove->origin ); + PM_ResetStuckOffsets(pmove->player_index, pmove->server); + + VectorCopy(test, pmove->origin); return 0; } nReps++; @@ -1688,54 +1689,54 @@ int PM_CheckStuck (void) fTime = pmove->Sys_FloatTime(); // Too soon? - if (rgStuckCheckTime[pmove->player_index][idx] >= - ( fTime - PM_CHECKSTUCK_MINTIME ) ) + if (rgStuckCheckTime[pmove->player_index][idx] >= + (fTime - PM_CHECKSTUCK_MINTIME)) { return 1; } rgStuckCheckTime[pmove->player_index][idx] = fTime; - pmove->PM_StuckTouch( hitent, &traceresult ); + pmove->PM_StuckTouch(hitent, &traceresult); i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); VectorAdd(base, offset, test); - if ( ( hitent = pmove->PM_TestPlayerPosition ( test, NULL ) ) == -1 ) + if ((hitent = pmove->PM_TestPlayerPosition(test, NULL)) == -1) { //Con_DPrintf("Nudged\n"); - PM_ResetStuckOffsets( pmove->player_index, pmove->server ); + PM_ResetStuckOffsets(pmove->player_index, pmove->server); if (i >= 27) - VectorCopy ( test, pmove->origin ); + VectorCopy(test, pmove->origin); return 0; } // If player is flailing while stuck in another player ( should never happen ), then see // if we can't "unstick" them forceably. - if ( pmove->cmd.buttons & ( IN_JUMP | IN_DUCK | IN_ATTACK ) && ( pmove->physents[ hitent ].player != 0 ) ) + if (pmove->cmd.buttons & (IN_JUMP | IN_DUCK | IN_ATTACK) && (pmove->physents[hitent].player != 0)) { float x, y, z; float xystep = 8.0; float zstep = 18.0; float xyminmax = xystep; float zminmax = 4 * zstep; - - for ( z = 0; z <= zminmax; z += zstep ) + + for (z = 0; z <= zminmax; z += zstep) { - for ( x = -xyminmax; x <= xyminmax; x += xystep ) + for (x = -xyminmax; x <= xyminmax; x += xystep) { - for ( y = -xyminmax; y <= xyminmax; y += xystep ) + for (y = -xyminmax; y <= xyminmax; y += xystep) { - VectorCopy( base, test ); + VectorCopy(base, test); test[0] += x; test[1] += y; test[2] += z; - if ( pmove->PM_TestPlayerPosition ( test, NULL ) == -1 ) + if (pmove->PM_TestPlayerPosition(test, NULL) == -1) { - VectorCopy( test, pmove->origin ); + VectorCopy(test, pmove->origin); return 0; } } @@ -1753,7 +1754,7 @@ int PM_CheckStuck (void) PM_SpectatorMove =============== */ -void PM_SpectatorMove (void) +void PM_SpectatorMove(void) { float speed, drop, friction, control, newspeed; //float accel; @@ -1767,35 +1768,35 @@ void PM_SpectatorMove (void) // there a two different main move types : track player or moce freely (OBS_ROAMING) // doesn't need excate track position, only to generate PVS, so just copy // targets position and real view position is calculated on client (saves server CPU) - - if ( pmove->iuser1 == OBS_ROAMING) + + if (pmove->iuser1 == OBS_ROAMING) { #ifdef CLIENT_DLL // jump only in roaming mode - if ( iJumpSpectator ) + if (iJumpSpectator) { - VectorCopy( vJumpOrigin, pmove->origin ); - VectorCopy( vJumpAngles, pmove->angles ); - VectorCopy(shared_vec3_origin, pmove->velocity ); - iJumpSpectator = 0; + VectorCopy(vJumpOrigin, pmove->origin); + VectorCopy(vJumpAngles, pmove->angles); + VectorCopy(shared_vec3_origin, pmove->velocity); + iJumpSpectator = 0; return; } #endif // Move around in normal spectator method - - speed = Length (pmove->velocity); + + speed = Length(pmove->velocity); if (speed < 1) { - VectorCopy (shared_vec3_origin, pmove->velocity) + VectorCopy(shared_vec3_origin, pmove->velocity) } else { drop = 0; - friction = pmove->movevars->friction*1.5; // extra friction + friction = pmove->movevars->friction * 1.5; // extra friction control = speed < pmove->movevars->stopspeed ? pmove->movevars->stopspeed : speed; - drop += control*friction*pmove->frametime; + drop += control * friction * pmove->frametime; // scale the velocity newspeed = speed - drop; @@ -1803,23 +1804,23 @@ void PM_SpectatorMove (void) newspeed = 0; newspeed /= speed; - VectorScale (pmove->velocity, newspeed, pmove->velocity); + VectorScale(pmove->velocity, newspeed, pmove->velocity); } // accelerate fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - - VectorNormalize (pmove->forward); - VectorNormalize (pmove->right); - for (i=0 ; i<3 ; i++) + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); + + for (i = 0; i < 3; i++) { - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; } wishvel[2] += pmove->cmd.upmove; - VectorCopy (wishvel, wishdir); + VectorCopy(wishvel, wishdir); wishspeed = VectorNormalize(wishdir); // @@ -1827,7 +1828,7 @@ void PM_SpectatorMove (void) // if (wishspeed > pmove->movevars->spectatormaxspeed) { - VectorScale (wishvel, pmove->movevars->spectatormaxspeed/wishspeed, wishvel); + VectorScale(wishvel, pmove->movevars->spectatormaxspeed / wishspeed, wishvel); wishspeed = pmove->movevars->spectatormaxspeed; } @@ -1836,15 +1837,15 @@ void PM_SpectatorMove (void) if (addspeed <= 0) return; - accelspeed = pmove->movevars->accelerate*pmove->frametime*wishspeed; + accelspeed = pmove->movevars->accelerate * pmove->frametime * wishspeed; if (accelspeed > addspeed) accelspeed = addspeed; - - for (i=0 ; i<3 ; i++) - pmove->velocity[i] += accelspeed*wishdir[i]; + + for (i = 0; i < 3; i++) + pmove->velocity[i] += accelspeed * wishdir[i]; // move - VectorMA (pmove->origin, pmove->frametime, pmove->velocity, pmove->origin); + VectorMA(pmove->origin, pmove->frametime, pmove->velocity, pmove->origin); } else { @@ -1853,13 +1854,13 @@ void PM_SpectatorMove (void) int target; // no valid target ? - if ( pmove->iuser2 <= 0) + if (pmove->iuser2 <= 0) return; // Find the client this player's targeting for (target = 0; target < pmove->numphysent; target++) { - if ( pmove->physents[target].info == pmove->iuser2 ) + if (pmove->physents[target].info == pmove->iuser2) break; } @@ -1867,11 +1868,11 @@ void PM_SpectatorMove (void) return; // use targets position as own origin for PVS - VectorCopy( pmove->physents[target].angles, pmove->angles ); - VectorCopy( pmove->physents[target].origin, pmove->origin ); + VectorCopy(pmove->physents[target].angles, pmove->angles); + VectorCopy(pmove->physents[target].origin, pmove->origin); // no velocity - VectorCopy(shared_vec3_origin, pmove->velocity ); + VectorCopy(shared_vec3_origin, pmove->velocity); } } @@ -1883,7 +1884,7 @@ Use for ease-in, ease-out style interpolation (accel/decel) Used by ducking code. ================== */ -float PM_SplineFraction( float value, float scale ) +float PM_SplineFraction(float value, float scale) { float valueSquared; @@ -1894,53 +1895,53 @@ float PM_SplineFraction( float value, float scale ) return 3 * valueSquared - 2 * valueSquared * value; } -void PM_FixPlayerCrouchStuck( int direction ) +void PM_FixPlayerCrouchStuck(int direction) { int hitent; int i; vec3_t test; - hitent = pmove->PM_TestPlayerPosition ( pmove->origin, NULL ); - if (hitent == -1 ) + hitent = pmove->PM_TestPlayerPosition(pmove->origin, NULL); + if (hitent == -1) return; - - VectorCopy( pmove->origin, test ); - for ( i = 0; i < 36; i++ ) + + VectorCopy(pmove->origin, test); + for (i = 0; i < 36; i++) { pmove->origin[2] += direction; - hitent = pmove->PM_TestPlayerPosition ( pmove->origin, NULL ); - if (hitent == -1 ) + hitent = pmove->PM_TestPlayerPosition(pmove->origin, NULL); + if (hitent == -1) return; } - VectorCopy( test, pmove->origin ); // Failed + VectorCopy(test, pmove->origin); // Failed } -void PM_UnDuck( void ) +void PM_UnDuck(void) { int i; pmtrace_t trace; vec3_t newOrigin; - VectorCopy( pmove->origin, newOrigin ); + VectorCopy(pmove->origin, newOrigin); - if ( pmove->onground != -1 ) + if (pmove->onground != -1) { - for ( i = 0; i < 3; i++ ) + for (i = 0; i < 3; i++) { - newOrigin[i] += ( pmove->player_mins[1][i] - pmove->player_mins[0][i] ); + newOrigin[i] += (pmove->player_mins[1][i] - pmove->player_mins[0][i]); } } - - trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 ); - if ( !trace.startsolid ) + trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); + + if (!trace.startsolid) { pmove->usehull = 0; // Oh, no, changing hulls stuck us into something, try unsticking downward first. - trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 ); - if ( trace.startsolid ) + trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); + if (trace.startsolid) { // See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot //Con_Printf( "unstick got stuck\n" ); @@ -1949,30 +1950,30 @@ void PM_UnDuck( void ) } pmove->flags &= ~FL_DUCKING; - pmove->bInDuck = false; + pmove->bInDuck = false; pmove->view_ofs[2] = VEC_VIEW; pmove->flDuckTime = 0; - - VectorCopy( newOrigin, pmove->origin ); + + VectorCopy(newOrigin, pmove->origin); // Recatagorize position since ducking can change origin PM_CatagorizePosition(); } } -void PM_Duck( void ) +void PM_Duck(void) { int i; float time; float duckFraction; - int buttonsChanged = ( pmove->oldbuttons ^ pmove->cmd.buttons ); // These buttons have changed this frame - int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" + int buttonsChanged = (pmove->oldbuttons ^ pmove->cmd.buttons); // These buttons have changed this frame + int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" - int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; - int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; + int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; + int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; - if ( pmove->cmd.buttons & IN_DUCK ) + if (pmove->cmd.buttons & IN_DUCK) { pmove->oldbuttons |= IN_DUCK; } @@ -1982,41 +1983,41 @@ void PM_Duck( void ) } // Prevent ducking if the iuser3 variable is set - if ( pmove->iuser3 || pmove->dead ) + if (pmove->iuser3 || pmove->dead) { // Try to unduck - if ( pmove->flags & FL_DUCKING ) + if (pmove->flags & FL_DUCKING) { PM_UnDuck(); } return; } - if ( pmove->flags & FL_DUCKING ) + if (pmove->flags & FL_DUCKING) { pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER; - pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; - pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; } - if ( ( pmove->cmd.buttons & IN_DUCK ) || ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) + if ((pmove->cmd.buttons & IN_DUCK) || (pmove->bInDuck) || (pmove->flags & FL_DUCKING)) { - if ( pmove->cmd.buttons & IN_DUCK ) + if (pmove->cmd.buttons & IN_DUCK) { - if ( (nButtonPressed & IN_DUCK ) && !( pmove->flags & FL_DUCKING ) ) + if ((nButtonPressed & IN_DUCK) && !(pmove->flags & FL_DUCKING)) { // Use 1 second so super long jump will work pmove->flDuckTime = 1000; - pmove->bInDuck = true; + pmove->bInDuck = true; } - time = V_max( 0.0, ( 1.0 - (float)pmove->flDuckTime / 1000.0 ) ); - - if ( pmove->bInDuck ) + time = V_max(0.0, (1.0 - (float)pmove->flDuckTime / 1000.0)); + + if (pmove->bInDuck) { // Finish ducking immediately if duck time is over or not on ground - if ( ( (float)pmove->flDuckTime / 1000.0 <= ( 1.0 - TIME_TO_DUCK ) ) || - ( pmove->onground == -1 ) ) + if (((float)pmove->flDuckTime / 1000.0 <= (1.0 - TIME_TO_DUCK)) || + (pmove->onground == -1)) { pmove->usehull = 1; pmove->view_ofs[2] = VEC_DUCK_VIEW; @@ -2024,14 +2025,14 @@ void PM_Duck( void ) pmove->bInDuck = false; // HACKHACK - Fudge for collision bug - no time to fix this properly - if ( pmove->onground != -1 ) + if (pmove->onground != -1) { - for ( i = 0; i < 3; i++ ) + for (i = 0; i < 3; i++) { - pmove->origin[i] -= ( pmove->player_mins[1][i] - pmove->player_mins[0][i] ); + pmove->origin[i] -= (pmove->player_mins[1][i] - pmove->player_mins[0][i]); } // See if we are stuck? - PM_FixPlayerCrouchStuck( STUCK_MOVEUP ); + PM_FixPlayerCrouchStuck(STUCK_MOVEUP); // Recatagorize position since ducking can change origin PM_CatagorizePosition(); @@ -2042,8 +2043,8 @@ void PM_Duck( void ) float fMore = (VEC_DUCK_HULL_MIN - VEC_HULL_MIN); // Calc parametric time - duckFraction = PM_SplineFraction( time, (1.0/TIME_TO_DUCK) ); - pmove->view_ofs[2] = ((VEC_DUCK_VIEW - fMore ) * duckFraction) + (VEC_VIEW * (1-duckFraction)); + duckFraction = PM_SplineFraction(time, (1.0 / TIME_TO_DUCK)); + pmove->view_ofs[2] = ((VEC_DUCK_VIEW - fMore) * duckFraction) + (VEC_VIEW * (1 - duckFraction)); } } } @@ -2055,7 +2056,7 @@ void PM_Duck( void ) } } -void PM_LadderMove( physent_t *pLadder ) +void PM_LadderMove(physent_t* pLadder) { vec3_t ladderCenter; trace_t trace; @@ -2063,78 +2064,78 @@ void PM_LadderMove( physent_t *pLadder ) vec3_t floor; vec3_t modelmins, modelmaxs; - if ( pmove->movetype == MOVETYPE_NOCLIP ) + if (pmove->movetype == MOVETYPE_NOCLIP) return; - + #if defined( _TFC ) // this is how TFC freezes players, so we don't want them climbing ladders - if ( pmove->maxspeed <= 1.0 ) + if (pmove->maxspeed <= 1.0) return; #endif - pmove->PM_GetModelBounds( pLadder->model, modelmins, modelmaxs ); + pmove->PM_GetModelBounds(pLadder->model, modelmins, modelmaxs); - VectorAdd( modelmins, modelmaxs, ladderCenter ); - VectorScale( ladderCenter, 0.5, ladderCenter ); + VectorAdd(modelmins, modelmaxs, ladderCenter); + VectorScale(ladderCenter, 0.5, ladderCenter); pmove->movetype = MOVETYPE_FLY; // On ladder, convert movement to be relative to the ladder - VectorCopy( pmove->origin, floor ); + VectorCopy(pmove->origin, floor); floor[2] += pmove->player_mins[pmove->usehull][2] - 1; - if ( pmove->PM_PointContents( floor, NULL ) == CONTENTS_SOLID ) + if (pmove->PM_PointContents(floor, NULL) == CONTENTS_SOLID) onFloor = true; else onFloor = false; pmove->gravity = 0; - pmove->PM_TraceModel( pLadder, pmove->origin, ladderCenter, &trace ); - if ( trace.fraction != 1.0 ) + pmove->PM_TraceModel(pLadder, pmove->origin, ladderCenter, &trace); + if (trace.fraction != 1.0) { float forward = 0, right = 0; vec3_t vpn, v_right; float flSpeed = MAX_CLIMB_SPEED; // they shouldn't be able to move faster than their maxspeed - if ( flSpeed > pmove->maxspeed ) + if (flSpeed > pmove->maxspeed) { flSpeed = pmove->maxspeed; } - AngleVectors( pmove->angles, vpn, v_right, NULL ); + AngleVectors(pmove->angles, vpn, v_right, NULL); - if ( pmove->flags & FL_DUCKING ) + if (pmove->flags & FL_DUCKING) { flSpeed *= PLAYER_DUCKING_MULTIPLIER; } - if ( pmove->cmd.buttons & IN_BACK ) + if (pmove->cmd.buttons & IN_BACK) { forward -= flSpeed; } - if ( pmove->cmd.buttons & IN_FORWARD ) + if (pmove->cmd.buttons & IN_FORWARD) { forward += flSpeed; } - if ( pmove->cmd.buttons & IN_MOVELEFT ) + if (pmove->cmd.buttons & IN_MOVELEFT) { right -= flSpeed; } - if ( pmove->cmd.buttons & IN_MOVERIGHT ) + if (pmove->cmd.buttons & IN_MOVERIGHT) { right += flSpeed; } - if ( pmove->cmd.buttons & IN_JUMP ) + if (pmove->cmd.buttons & IN_JUMP) { pmove->movetype = MOVETYPE_WALK; - VectorScale( trace.plane.normal, 270, pmove->velocity ); + VectorScale(trace.plane.normal, 270, pmove->velocity); } else { - if ( forward != 0 || right != 0 ) + if (forward != 0 || right != 0) { vec3_t velocity, perp, cross, lateral, tmp; float normal; @@ -2143,74 +2144,74 @@ void PM_LadderMove( physent_t *pLadder ) // pev->velocity.x, pev->velocity.y, pev->velocity.z); // Calculate player's intended velocity //Vector velocity = (forward * gpGlobals->v_forward) + (right * gpGlobals->v_right); - VectorScale( vpn, forward, velocity ); - VectorMA( velocity, right, v_right, velocity ); + VectorScale(vpn, forward, velocity); + VectorMA(velocity, right, v_right, velocity); + - // Perpendicular in the ladder plane // Vector perp = CrossProduct( Vector(0,0,1), trace.vecPlaneNormal ); // perp = perp.Normalize(); - VectorClear( tmp ); + VectorClear(tmp); tmp[2] = 1; - CrossProduct( tmp, trace.plane.normal, perp ); - VectorNormalize( perp ); + CrossProduct(tmp, trace.plane.normal, perp); + VectorNormalize(perp); // decompose velocity into ladder plane - normal = DotProduct( velocity, trace.plane.normal ); + normal = DotProduct(velocity, trace.plane.normal); // This is the velocity into the face of the ladder - VectorScale( trace.plane.normal, normal, cross ); + VectorScale(trace.plane.normal, normal, cross); // This is the player's additional velocity - VectorSubtract( velocity, cross, lateral ); + VectorSubtract(velocity, cross, lateral); // This turns the velocity into the face of the ladder into velocity that // is roughly vertically perpendicular to the face of the ladder. // NOTE: It IS possible to face up and move down or face down and move up // because the velocity is a sum of the directional velocity and the converted // velocity through the face of the ladder -- by design. - CrossProduct( trace.plane.normal, perp, tmp ); - VectorMA( lateral, -normal, tmp, pmove->velocity ); - if ( onFloor && normal > 0 ) // On ground moving away from the ladder + CrossProduct(trace.plane.normal, perp, tmp); + VectorMA(lateral, -normal, tmp, pmove->velocity); + if (onFloor && normal > 0) // On ground moving away from the ladder { - VectorMA( pmove->velocity, MAX_CLIMB_SPEED, trace.plane.normal, pmove->velocity ); + VectorMA(pmove->velocity, MAX_CLIMB_SPEED, trace.plane.normal, pmove->velocity); } //pev->velocity = lateral - (CrossProduct( trace.vecPlaneNormal, perp ) * normal); } else { - VectorClear( pmove->velocity ); + VectorClear(pmove->velocity); } } } } -physent_t *PM_Ladder( void ) +physent_t* PM_Ladder(void) { int i; - physent_t *pe; - hull_t *hull; + physent_t* pe; + hull_t* hull; int num; vec3_t test; - for ( i = 0; i < pmove->nummoveent; i++ ) + for (i = 0; i < pmove->nummoveent; i++) { pe = &pmove->moveents[i]; - - if ( pe->model && (modtype_t)pmove->PM_GetModelType( pe->model ) == mod_brush && pe->skin == CONTENTS_LADDER ) + + if (pe->model && (modtype_t)pmove->PM_GetModelType(pe->model) == mod_brush && pe->skin == CONTENTS_LADDER) { - hull = (hull_t *)pmove->PM_HullForBsp( pe, test ); + hull = (hull_t*)pmove->PM_HullForBsp(pe, test); num = hull->firstclipnode; // Offset the test point appropriately for this hull. - VectorSubtract ( pmove->origin, test, test); + VectorSubtract(pmove->origin, test, test); // Test the player's hull for intersection with this model - if ( pmove->PM_HullPointContents (hull, num, test) == CONTENTS_EMPTY) + if (pmove->PM_HullPointContents(hull, num, test) == CONTENTS_EMPTY) continue; - + return pe; } } @@ -2220,19 +2221,19 @@ physent_t *PM_Ladder( void ) -void PM_WaterJump (void) +void PM_WaterJump(void) { - if ( pmove->waterjumptime > 10000 ) + if (pmove->waterjumptime > 10000) { pmove->waterjumptime = 10000; } - if ( !pmove->waterjumptime ) + if (!pmove->waterjumptime) return; pmove->waterjumptime -= pmove->cmd.msec; - if ( pmove->waterjumptime < 0 || - !pmove->waterlevel ) + if (pmove->waterjumptime < 0 || + !pmove->waterlevel) { pmove->waterjumptime = 0; pmove->flags &= ~FL_WATERJUMP; @@ -2248,7 +2249,7 @@ PM_AddGravity ============ */ -void PM_AddGravity () +void PM_AddGravity() { float ent_gravity; @@ -2258,7 +2259,7 @@ void PM_AddGravity () ent_gravity = 1.0; // Add gravity incorrectly - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime ); + pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime); pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; pmove->basevelocity[2] = 0; PM_CheckVelocity(); @@ -2270,16 +2271,16 @@ PM_PushEntity Does not change the entities velocity at all ============ */ -pmtrace_t PM_PushEntity (vec3_t push) +pmtrace_t PM_PushEntity(vec3_t push) { pmtrace_t trace; vec3_t end; - - VectorAdd (pmove->origin, push, end); - trace = pmove->PM_PlayerTrace (pmove->origin, end, PM_NORMAL, -1 ); - - VectorCopy (trace.endpos, pmove->origin); + VectorAdd(pmove->origin, push, end); + + trace = pmove->PM_PlayerTrace(pmove->origin, end, PM_NORMAL, -1); + + VectorCopy(trace.endpos, pmove->origin); // So we can run impact function afterwards. if (trace.fraction < 1.0 && @@ -2289,7 +2290,7 @@ pmtrace_t PM_PushEntity (vec3_t push) } return trace; -} +} /* ============ @@ -2310,42 +2311,42 @@ void PM_Physics_Toss() pmove->onground = -1; // If on ground and not moving, return. - if ( pmove->onground != -1 ) + if (pmove->onground != -1) { if (VectorCompare(pmove->basevelocity, shared_vec3_origin) && - VectorCompare(pmove->velocity, shared_vec3_origin)) + VectorCompare(pmove->velocity, shared_vec3_origin)) return; } - PM_CheckVelocity (); + PM_CheckVelocity(); + + // add gravity + if (pmove->movetype != MOVETYPE_FLY && + pmove->movetype != MOVETYPE_BOUNCEMISSILE && + pmove->movetype != MOVETYPE_FLYMISSILE) + PM_AddGravity(); -// add gravity - if ( pmove->movetype != MOVETYPE_FLY && - pmove->movetype != MOVETYPE_BOUNCEMISSILE && - pmove->movetype != MOVETYPE_FLYMISSILE ) - PM_AddGravity (); + // move origin + // Base velocity is not properly accounted for since this entity will move again after the bounce without + // taking it into account + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); -// move origin - // Base velocity is not properly accounted for since this entity will move again after the bounce without - // taking it into account - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); - PM_CheckVelocity(); - VectorScale (pmove->velocity, pmove->frametime, move); - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); + VectorScale(pmove->velocity, pmove->frametime, move); + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); - trace = PM_PushEntity (move); // Should this clear basevelocity + trace = PM_PushEntity(move); // Should this clear basevelocity PM_CheckVelocity(); if (trace.allsolid) - { + { // entity is trapped in another solid pmove->onground = trace.ent; - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); return; } - + if (trace.fraction == 1) { PM_CheckWater(); @@ -2360,15 +2361,15 @@ void PM_Physics_Toss() else backoff = 1; - PM_ClipVelocity (pmove->velocity, trace.plane.normal, pmove->velocity, backoff); + PM_ClipVelocity(pmove->velocity, trace.plane.normal, pmove->velocity, backoff); // stop if on ground if (trace.plane.normal[2] > 0.7) - { + { float vel; vec3_t base; - VectorClear( base ); + VectorClear(base); if (pmove->velocity[2] < pmove->movevars->gravity * pmove->frametime) { // we're rolling on the ground, add static friction. @@ -2376,24 +2377,24 @@ void PM_Physics_Toss() pmove->velocity[2] = 0; } - vel = DotProduct( pmove->velocity, pmove->velocity ); + vel = DotProduct(pmove->velocity, pmove->velocity); // Con_DPrintf("%f %f: %.0f %.0f %.0f\n", vel, trace.fraction, ent->velocity[0], ent->velocity[1], ent->velocity[2] ); if (vel < (30 * 30) || (pmove->movetype != MOVETYPE_BOUNCE && pmove->movetype != MOVETYPE_BOUNCEMISSILE)) { pmove->onground = trace.ent; - VectorCopy (shared_vec3_origin, pmove->velocity); + VectorCopy(shared_vec3_origin, pmove->velocity); } else { - VectorScale (pmove->velocity, (1.0 - trace.fraction) * pmove->frametime * 0.9, move); - trace = PM_PushEntity (move); + VectorScale(pmove->velocity, (1.0 - trace.fraction) * pmove->frametime * 0.9, move); + trace = PM_PushEntity(move); } - VectorSubtract( pmove->velocity, base, pmove->velocity ) + VectorSubtract(pmove->velocity, base, pmove->velocity) } - -// check for in water + + // check for in water PM_CheckWater(); } @@ -2408,26 +2409,26 @@ void PM_NoClip() int i; vec3_t wishvel; float fmove, smove; -// float currentspeed, addspeed, accelspeed; + // float currentspeed, addspeed, accelspeed; - // Copy movement amounts + // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - - VectorNormalize ( pmove->forward ); - VectorNormalize ( pmove->right ); - for (i=0 ; i<3 ; i++) // Determine x and y parts of velocity + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); + + for (i = 0; i < 3; i++) // Determine x and y parts of velocity { - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; } wishvel[2] += pmove->cmd.upmove; - VectorMA (pmove->origin, pmove->frametime, wishvel, pmove->origin); - + VectorMA(pmove->origin, pmove->frametime, wishvel, pmove->origin); + // Zero out the velocity so that we don't accumulate a huge downward velocity from // gravity, etc. - VectorClear( pmove->velocity ); + VectorClear(pmove->velocity); } @@ -2440,7 +2441,7 @@ void PM_NoClip() // running PM_AirMove, which doesn't crop velocity to maxspeed like the ground / other // movement logic does. //----------------------------------------------------------------------------- -void PM_PreventMegaBunnyJumping( void ) +/*void PM_PreventMegaBunnyJumping(void) { // Current player speed float spd; @@ -2452,25 +2453,25 @@ void PM_PreventMegaBunnyJumping( void ) maxscaledspeed = BUNNYJUMP_MAX_SPEED_FACTOR * pmove->maxspeed; // Don't divide by zero - if ( maxscaledspeed <= 0.0f ) + if (maxscaledspeed <= 0.0f) return; - spd = Length( pmove->velocity ); + spd = Length(pmove->velocity); - if ( spd <= maxscaledspeed ) + if (spd <= maxscaledspeed) return; - fraction = ( maxscaledspeed / spd ) * 0.65; //Returns the modifier for the velocity - - VectorScale( pmove->velocity, fraction, pmove->velocity ); //Crop it down!. -} + fraction = (maxscaledspeed / spd) * 0.65; //Returns the modifier for the velocity + VectorScale(pmove->velocity, fraction, pmove->velocity); //Crop it down!. +} +*/ /* ============= PM_Jump ============= */ -void PM_Jump (void) +void PM_Jump(void) { int i; qboolean tfc = false; @@ -2479,21 +2480,21 @@ void PM_Jump (void) if (pmove->dead) { - pmove->oldbuttons |= IN_JUMP ; // don't jump again until released + pmove->oldbuttons |= IN_JUMP; // don't jump again until released return; } - tfc = atoi( pmove->PM_Info_ValueForKey( pmove->physinfo, "tfc" ) ) == 1 ? true : false; + tfc = atoi(pmove->PM_Info_ValueForKey(pmove->physinfo, "tfc")) == 1 ? true : false; // Spy that's feigning death cannot jump - if ( tfc && - ( pmove->deadflag == ( DEAD_DISCARDBODY + 1 ) ) ) + if (tfc && + (pmove->deadflag == (DEAD_DISCARDBODY + 1))) { return; } // See if we are waterjumping. If so, decrement count and return. - if ( pmove->waterjumptime ) + if (pmove->waterjumptime) { pmove->waterjumptime -= pmove->cmd.msec; if (pmove->waterjumptime < 0) @@ -2516,23 +2517,23 @@ void PM_Jump (void) pmove->velocity[2] = 50; // play swiming sound - if ( pmove->flSwimTime <= 0 ) + if (pmove->flSwimTime <= 0) { // Don't play sound again for 1 second pmove->flSwimTime = 1000; - switch ( pmove->RandomLong( 0, 3 ) ) - { + switch (pmove->RandomLong(0, 3)) + { case 0: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; case 1: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade2.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; case 2: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade3.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade3.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; case 3: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade4.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade4.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; } } @@ -2541,7 +2542,7 @@ void PM_Jump (void) } // No more effect - if ( pmove->onground == -1 ) + if (pmove->onground == -1) { // Flag that we jumped. // HACK HACK HACK @@ -2550,44 +2551,44 @@ void PM_Jump (void) return; // in air, so no effect } - if ( pmove->oldbuttons & IN_JUMP ) - return; // don't pogo stick + /*if (pmove->oldbuttons & IN_JUMP) + return; // don't pogo stick*/ // In the air now. - pmove->onground = -1; + pmove->onground = -1; - PM_PreventMegaBunnyJumping(); + // PM_PreventMegaBunnyJumping(); - if ( tfc ) + if (tfc) { - pmove->PM_PlaySound( CHAN_BODY, "player/plyrjmp8.wav", 0.5, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/plyrjmp8.wav", 0.5, ATTN_NORM, 0, PITCH_NORM); } else { - PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), 1.0 ); + PM_PlayStepSound(PM_MapTextureTypeStepType(pmove->chtexturetype), 1.0); } // See if user can super long jump? - cansuperjump = atoi( pmove->PM_Info_ValueForKey( pmove->physinfo, "slj" ) ) == 1 ? true : false; + cansuperjump = atoi(pmove->PM_Info_ValueForKey(pmove->physinfo, "slj")) == 1 ? true : false; // Acclerate upward // If we are ducking... - if ( ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) + if ((pmove->bInDuck) || (pmove->flags & FL_DUCKING)) { // Adjust for super long jump module // UNDONE -- note this should be based on forward angles, not current velocity. - if ( cansuperjump && - ( pmove->cmd.buttons & IN_DUCK ) && - ( pmove->flDuckTime > 0 ) && - Length( pmove->velocity ) > 50 ) + if (cansuperjump && + (pmove->cmd.buttons & IN_DUCK) && + (pmove->flDuckTime > 0) && + Length(pmove->velocity) > 50) { pmove->punchangle[0] = -5; - for (i =0; i < 2; i++) + for (i = 0; i < 2; i++) { pmove->velocity[i] = pmove->forward[i] * PLAYER_LONGJUMP_SPEED * 1.6; } - + pmove->velocity[2] = sqrt(2 * 800 * 56.0); } else @@ -2613,7 +2614,7 @@ PM_CheckWaterJump ============= */ #define WJ_HEIGHT 8 -void PM_CheckWaterJump (void) +void PM_CheckWaterJump(void) { vec3_t vecStart, vecEnd; vec3_t flatforward; @@ -2623,11 +2624,11 @@ void PM_CheckWaterJump (void) int savehull; // Already water jumping. - if ( pmove->waterjumptime ) + if (pmove->waterjumptime) return; // Don't hop out if we just jumped in - if ( pmove->velocity[2] < -180 ) + if (pmove->velocity[2] < -180) return; // only hop out if we are moving up // See if we are backing up @@ -2636,35 +2637,35 @@ void PM_CheckWaterJump (void) flatvelocity[2] = 0; // Must be moving - curspeed = VectorNormalize( flatvelocity ); - + curspeed = VectorNormalize(flatvelocity); + // see if near an edge flatforward[0] = pmove->forward[0]; flatforward[1] = pmove->forward[1]; flatforward[2] = 0; - VectorNormalize (flatforward); + VectorNormalize(flatforward); // Are we backing into water from steps or something? If so, don't pop forward - if ( curspeed != 0.0 && ( DotProduct( flatvelocity, flatforward ) < 0.0 ) ) + if (curspeed != 0.0 && (DotProduct(flatvelocity, flatforward) < 0.0)) return; - VectorCopy( pmove->origin, vecStart ); + VectorCopy(pmove->origin, vecStart); vecStart[2] += WJ_HEIGHT; - VectorMA ( vecStart, 24, flatforward, vecEnd ); - + VectorMA(vecStart, 24, flatforward, vecEnd); + // Trace, this trace should use the point sized collision hull savehull = pmove->usehull; pmove->usehull = 2; - tr = pmove->PM_PlayerTrace( vecStart, vecEnd, PM_NORMAL, -1 ); - if ( tr.fraction < 1.0 && fabs( tr.plane.normal[2] ) < 0.1f ) // Facing a near vertical wall? + tr = pmove->PM_PlayerTrace(vecStart, vecEnd, PM_NORMAL, -1); + if (tr.fraction < 1.0 && fabs(tr.plane.normal[2]) < 0.1f) // Facing a near vertical wall? { - vecStart[2] += pmove->player_maxs[ savehull ][2] - WJ_HEIGHT; - VectorMA( vecStart, 24, flatforward, vecEnd ); - VectorMA(shared_vec3_origin, -50, tr.plane.normal, pmove->movedir ); + vecStart[2] += pmove->player_maxs[savehull][2] - WJ_HEIGHT; + VectorMA(vecStart, 24, flatforward, vecEnd); + VectorMA(shared_vec3_origin, -50, tr.plane.normal, pmove->movedir); - tr = pmove->PM_PlayerTrace( vecStart, vecEnd, PM_NORMAL, -1 ); - if ( tr.fraction == 1.0 ) + tr = pmove->PM_PlayerTrace(vecStart, vecEnd, PM_NORMAL, -1); + if (tr.fraction == 1.0) { pmove->waterjumptime = 2000; pmove->velocity[2] = 225; @@ -2677,18 +2678,18 @@ void PM_CheckWaterJump (void) pmove->usehull = savehull; } -void PM_CheckFalling( void ) +void PM_CheckFalling(void) { - if ( pmove->onground != -1 && - !pmove->dead && - pmove->flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD ) + if (pmove->onground != -1 && + !pmove->dead && + pmove->flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD) { float fvol = 0.5; - if ( pmove->waterlevel > 0 ) + if (pmove->waterlevel > 0) { } - else if ( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) + else if (pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED) { // NOTE: In the original game dll , there were no breaks after these cases, causing the first one to // cascade into the second @@ -2698,50 +2699,50 @@ void PM_CheckFalling( void ) //pmove->PM_PlaySound( CHAN_VOICE, "player/pl_fallpain2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); //break; //case 1: - pmove->PM_PlaySound( CHAN_VOICE, "player/pl_fallpain3.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_VOICE, "player/pl_fallpain3.wav", 1, ATTN_NORM, 0, PITCH_NORM); // break; //} fvol = 1.0; } - else if ( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED / 2 ) + else if (pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED / 2) { qboolean tfc = false; - tfc = atoi( pmove->PM_Info_ValueForKey( pmove->physinfo, "tfc" ) ) == 1 ? true : false; + tfc = atoi(pmove->PM_Info_ValueForKey(pmove->physinfo, "tfc")) == 1 ? true : false; - if ( tfc ) + if (tfc) { - pmove->PM_PlaySound( CHAN_VOICE, "player/pl_fallpain3.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_VOICE, "player/pl_fallpain3.wav", 1, ATTN_NORM, 0, PITCH_NORM); } fvol = 0.85; } - else if ( pmove->flFallVelocity < PLAYER_MIN_BOUNCE_SPEED ) + else if (pmove->flFallVelocity < PLAYER_MIN_BOUNCE_SPEED) { fvol = 0; } - if ( fvol > 0.0 ) + if (fvol > 0.0) { // Play landing step right away pmove->flTimeStepSound = 0; - + PM_UpdateStepSound(); - + // play step sound for current texture - PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), fvol ); + PM_PlayStepSound(PM_MapTextureTypeStepType(pmove->chtexturetype), fvol); // Knock the screen around a little bit, temporary effect - pmove->punchangle[ 2 ] = pmove->flFallVelocity * 0.013; // punch z axis + pmove->punchangle[2] = pmove->flFallVelocity * 0.013; // punch z axis - if ( pmove->punchangle[ 0 ] > 8 ) + if (pmove->punchangle[0] > 8) { - pmove->punchangle[ 0 ] = 8; + pmove->punchangle[0] = 8; } } } - if ( pmove->onground != -1 ) - { + if (pmove->onground != -1) + { pmove->flFallVelocity = 0; } } @@ -2752,25 +2753,25 @@ PM_PlayWaterSounds ================= */ -void PM_PlayWaterSounds( void ) +void PM_PlayWaterSounds(void) { // Did we enter or leave water? - if ( ( pmove->oldwaterlevel == 0 && pmove->waterlevel != 0 ) || - ( pmove->oldwaterlevel != 0 && pmove->waterlevel == 0 ) ) + if ((pmove->oldwaterlevel == 0 && pmove->waterlevel != 0) || + (pmove->oldwaterlevel != 0 && pmove->waterlevel == 0)) { - switch ( pmove->RandomLong(0,3) ) + switch (pmove->RandomLong(0, 3)) { case 0: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; case 1: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade2.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; case 2: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade3.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade3.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; case 3: - pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade4.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade4.wav", 1, ATTN_NORM, 0, PITCH_NORM); break; } } @@ -2782,32 +2783,32 @@ PM_CalcRoll =============== */ -float PM_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollspeed ) +float PM_CalcRoll(vec3_t angles, vec3_t velocity, float rollangle, float rollspeed) { - float sign; - float side; - float value; + float sign; + float side; + float value; vec3_t forward, right, up; - - AngleVectors (angles, forward, right, up); - - side = DotProduct (velocity, right); - + + AngleVectors(angles, forward, right, up); + + side = DotProduct(velocity, right); + sign = side < 0 ? -1 : 1; - + side = fabs(side); - + value = rollangle; - + if (side < rollspeed) { side = side * value / rollspeed; } - else + else { side = value; } - + return side * sign; } @@ -2817,14 +2818,14 @@ PM_DropPunchAngle ============= */ -void PM_DropPunchAngle ( vec3_t punchangle ) +void PM_DropPunchAngle(vec3_t punchangle) { float len; - - len = VectorNormalize ( punchangle ); + + len = VectorNormalize(punchangle); len -= (10.0 + len * 0.5) * pmove->frametime; - len = V_max( len, 0.0 ); - VectorScale ( punchangle, len, punchangle); + len = V_max(len, 0.0); + VectorScale(punchangle, len, punchangle); } /* @@ -2833,62 +2834,62 @@ PM_CheckParamters ============== */ -void PM_CheckParamters( void ) +void PM_CheckParamters(void) { float spd; float maxspeed; vec3_t v_angle; - spd = ( pmove->cmd.forwardmove * pmove->cmd.forwardmove ) + - ( pmove->cmd.sidemove * pmove->cmd.sidemove ) + - ( pmove->cmd.upmove * pmove->cmd.upmove ); - spd = sqrt( spd ); + spd = (pmove->cmd.forwardmove * pmove->cmd.forwardmove) + + (pmove->cmd.sidemove * pmove->cmd.sidemove) + + (pmove->cmd.upmove * pmove->cmd.upmove); + spd = sqrt(spd); maxspeed = pmove->clientmaxspeed; //atof( pmove->PM_Info_ValueForKey( pmove->physinfo, "maxspd" ) ); - if ( maxspeed != 0.0 ) + if (maxspeed != 0.0) { - pmove->maxspeed = V_min( maxspeed, pmove->maxspeed ); + pmove->maxspeed = V_min(maxspeed, pmove->maxspeed); } - if ( ( spd != 0.0 ) && - ( spd > pmove->maxspeed ) ) + if ((spd != 0.0) && + (spd > pmove->maxspeed)) { float fRatio = pmove->maxspeed / spd; pmove->cmd.forwardmove *= fRatio; - pmove->cmd.sidemove *= fRatio; - pmove->cmd.upmove *= fRatio; + pmove->cmd.sidemove *= fRatio; + pmove->cmd.upmove *= fRatio; } - if ( pmove->flags & FL_FROZEN || - pmove->flags & FL_ONTRAIN || - pmove->dead ) + if (pmove->flags & FL_FROZEN || + pmove->flags & FL_ONTRAIN || + pmove->dead) { pmove->cmd.forwardmove = 0; - pmove->cmd.sidemove = 0; - pmove->cmd.upmove = 0; + pmove->cmd.sidemove = 0; + pmove->cmd.upmove = 0; } - PM_DropPunchAngle( pmove->punchangle ); + PM_DropPunchAngle(pmove->punchangle); // Take angles from command. - if ( !pmove->dead ) + if (!pmove->dead) { - VectorCopy ( pmove->cmd.viewangles, v_angle ); - VectorAdd( v_angle, pmove->punchangle, v_angle ); + VectorCopy(pmove->cmd.viewangles, v_angle); + VectorAdd(v_angle, pmove->punchangle, v_angle); // Set up view angles. - pmove->angles[ROLL] = PM_CalcRoll ( v_angle, pmove->velocity, pmove->movevars->rollangle, pmove->movevars->rollspeed )*4; - pmove->angles[PITCH] = v_angle[PITCH]; - pmove->angles[YAW] = v_angle[YAW]; + pmove->angles[ROLL] = PM_CalcRoll(v_angle, pmove->velocity, pmove->movevars->rollangle, pmove->movevars->rollspeed) * 4; + pmove->angles[PITCH] = v_angle[PITCH]; + pmove->angles[YAW] = v_angle[YAW]; } else { - VectorCopy( pmove->oldangles, pmove->angles ); + VectorCopy(pmove->oldangles, pmove->angles); } // Set dead player view_offset - if ( pmove->dead ) + if (pmove->dead) { pmove->view_ofs[2] = PM_DEAD_VIEWHEIGHT; } @@ -2901,28 +2902,28 @@ void PM_CheckParamters( void ) } -void PM_ReduceTimers( void ) +void PM_ReduceTimers(void) { - if ( pmove->flTimeStepSound > 0 ) + if (pmove->flTimeStepSound > 0) { pmove->flTimeStepSound -= pmove->cmd.msec; - if ( pmove->flTimeStepSound < 0 ) + if (pmove->flTimeStepSound < 0) { pmove->flTimeStepSound = 0; } } - if ( pmove->flDuckTime > 0 ) + if (pmove->flDuckTime > 0) { pmove->flDuckTime -= pmove->cmd.msec; - if ( pmove->flDuckTime < 0 ) + if (pmove->flDuckTime < 0) { pmove->flDuckTime = 0; } } - if ( pmove->flSwimTime > 0 ) + if (pmove->flSwimTime > 0) { pmove->flSwimTime -= pmove->cmd.msec; - if ( pmove->flSwimTime < 0 ) + if (pmove->flSwimTime < 0) { pmove->flSwimTime = 0; } @@ -2939,31 +2940,31 @@ Numtouch and touchindex[] will be set if any of the physents were contacted during the move. ============= */ -void PM_PlayerMove ( qboolean server ) +void PM_PlayerMove(qboolean server) { - physent_t *pLadder = NULL; + physent_t* pLadder = NULL; // Are we running server code? - pmove->server = server; + pmove->server = server; // Adjust speeds etc. PM_CheckParamters(); // Assume we don't touch anything - pmove->numtouch = 0; + pmove->numtouch = 0; // # of msec to apply movement - pmove->frametime = pmove->cmd.msec * 0.001; + pmove->frametime = pmove->cmd.msec * 0.001; PM_ReduceTimers(); // Convert view angles to vectors - AngleVectors (pmove->angles, pmove->forward, pmove->right, pmove->up); + AngleVectors(pmove->angles, pmove->forward, pmove->right, pmove->up); // PM_ShowClipBox(); // Special handling for spectator and observers. (iuser1 is set if the player's in observer mode) - if ( pmove->spectator || pmove->iuser1 > 0 ) + if (pmove->spectator || pmove->iuser1 > 0) { PM_SpectatorMove(); PM_CatagorizePosition(); @@ -2971,9 +2972,9 @@ void PM_PlayerMove ( qboolean server ) } // Always try and unstick us unless we are in NOCLIP mode - if ( pmove->movetype != MOVETYPE_NOCLIP && pmove->movetype != MOVETYPE_NONE ) + if (pmove->movetype != MOVETYPE_NOCLIP && pmove->movetype != MOVETYPE_NONE) { - if ( PM_CheckStuck() ) + if (PM_CheckStuck()) { return; // Can't move, we're stuck } @@ -2986,17 +2987,17 @@ void PM_PlayerMove ( qboolean server ) pmove->oldwaterlevel = pmove->waterlevel; // If we are not on ground, store off how fast we are moving down - if ( pmove->onground == -1 ) + if (pmove->onground == -1) { pmove->flFallVelocity = -pmove->velocity[2]; } g_onladder = 0; // Don't run ladder code if dead or on a train - if ( !pmove->dead && !(pmove->flags & FL_ONTRAIN) ) + if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) { pLadder = PM_Ladder(); - if ( pLadder ) + if (pLadder) { g_onladder = 1; } @@ -3005,16 +3006,16 @@ void PM_PlayerMove ( qboolean server ) PM_UpdateStepSound(); PM_Duck(); - + // Don't run ladder code if dead or on a train - if ( !pmove->dead && !(pmove->flags & FL_ONTRAIN) ) + if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) { - if ( pLadder ) + if (pLadder) { - PM_LadderMove( pLadder ); + PM_LadderMove(pLadder); } - else if ( pmove->movetype != MOVETYPE_WALK && - pmove->movetype != MOVETYPE_NOCLIP ) + else if (pmove->movetype != MOVETYPE_WALK && + pmove->movetype != MOVETYPE_NOCLIP) { // Clear ladder stuff unless player is noclipping // it will be set immediately again next frame if necessary @@ -3024,14 +3025,14 @@ void PM_PlayerMove ( qboolean server ) #if !defined( _TFC ) // Slow down, I'm pulling it! (a box maybe) but only when I'm standing on ground - if ( ( pmove->onground != -1 ) && ( pmove->cmd.buttons & IN_USE) ) + if ((pmove->onground != -1) && (pmove->cmd.buttons & IN_USE)) { - VectorScale( pmove->velocity, 0.3, pmove->velocity ); + VectorScale(pmove->velocity, 0.3, pmove->velocity); } #endif // Handle movement - switch ( pmove->movetype ) + switch (pmove->movetype) { default: pmove->Con_DPrintf("Bogus pmove player movetype %i on (%i) 0=cl 1=sv\n", pmove->movetype, pmove->server); @@ -3050,38 +3051,38 @@ void PM_PlayerMove ( qboolean server ) break; case MOVETYPE_FLY: - + PM_CheckWater(); // Was jump button pressed? // If so, set velocity to 270 away from ladder. This is currently wrong. // Also, set MOVE_TYPE to walk, too. - if ( pmove->cmd.buttons & IN_JUMP ) + if (pmove->cmd.buttons & IN_JUMP) { - if ( !pLadder ) + if (!pLadder) { - PM_Jump (); + PM_Jump(); } } else { pmove->oldbuttons &= ~IN_JUMP; } - + // Perform the move accounting for any base velocity. - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); - PM_FlyMove (); - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + PM_FlyMove(); + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); break; case MOVETYPE_WALK: - if ( !PM_InWater() ) + if (!PM_InWater()) { PM_AddCorrectGravity(); } // If we are leaping out of the water, just update the counters. - if ( pmove->waterjumptime ) + if (pmove->waterjumptime) { PM_WaterJump(); PM_FlyMove(); @@ -3093,15 +3094,15 @@ void PM_PlayerMove ( qboolean server ) // If we are swimming in the water, see if we are nudging against a place we can jump up out // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 - if ( pmove->waterlevel >= 2 ) + if (pmove->waterlevel >= 2) { - if ( pmove->waterlevel == 2 ) + if (pmove->waterlevel == 2) { PM_CheckWaterJump(); } // If we are falling again, then we must not trying to jump out of water any more. - if ( pmove->velocity[2] < 0 && pmove->waterjumptime ) + if (pmove->velocity[2] < 0 && pmove->waterjumptime) { pmove->waterjumptime = 0; } @@ -3109,7 +3110,7 @@ void PM_PlayerMove ( qboolean server ) // Was jump button pressed? if (pmove->cmd.buttons & IN_JUMP) { - PM_Jump (); + PM_Jump(); } else { @@ -3118,22 +3119,22 @@ void PM_PlayerMove ( qboolean server ) // Perform regular water movement PM_WaterMove(); - - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); + + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); // Get a final position PM_CatagorizePosition(); } else - // Not underwater + // Not underwater { // Was jump button pressed? - if ( pmove->cmd.buttons & IN_JUMP ) + if (pmove->cmd.buttons & IN_JUMP) { - if ( !pLadder ) + if (!pLadder) { - PM_Jump (); + PM_Jump(); } } else @@ -3143,7 +3144,7 @@ void PM_PlayerMove ( qboolean server ) // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, // we don't slow when standing still, relative to the conveyor. - if ( pmove->onground != -1 ) + if (pmove->onground != -1) { pmove->velocity[2] = 0.0; PM_Friction(); @@ -3153,7 +3154,7 @@ void PM_PlayerMove ( qboolean server ) PM_CheckVelocity(); // Are we on ground now - if ( pmove->onground != -1 ) + if (pmove->onground != -1) { PM_WalkMove(); } @@ -3168,19 +3169,19 @@ void PM_PlayerMove ( qboolean server ) // Now pull the base velocity back out. // Base velocity is set if you are on a moving object, like // a conveyor (or maybe another monster?) - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity ); - + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); + // Make sure velocity is valid. PM_CheckVelocity(); // Add any remaining gravitational component. - if ( !PM_InWater() ) + if (!PM_InWater()) { PM_FixupGravityVelocity(); } // If we are on ground, no downward velocity. - if ( pmove->onground != -1 ) + if (pmove->onground != -1) { pmove->velocity[2] = 0; } @@ -3196,7 +3197,7 @@ void PM_PlayerMove ( qboolean server ) } } -void PM_CreateStuckTable( void ) +void PM_CreateStuckTable(void) { float x, y, z; int idx; @@ -3209,7 +3210,7 @@ void PM_CreateStuckTable( void ) // Little Moves. x = y = 0; // Z moves - for (z = -0.125 ; z <= 0.125 ; z += 0.125) + for (z = -0.125; z <= 0.125; z += 0.125) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3218,7 +3219,7 @@ void PM_CreateStuckTable( void ) } x = z = 0; // Y moves - for (y = -0.125 ; y <= 0.125 ; y += 0.125) + for (y = -0.125; y <= 0.125; y += 0.125) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3227,7 +3228,7 @@ void PM_CreateStuckTable( void ) } y = z = 0; // X moves - for (x = -0.125 ; x <= 0.125 ; x += 0.125) + for (x = -0.125; x <= 0.125; x += 0.125) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3236,11 +3237,11 @@ void PM_CreateStuckTable( void ) } // Remaining multi axis nudges. - for ( x = - 0.125; x <= 0.125; x += 0.250 ) + for (x = -0.125; x <= 0.125; x += 0.250) { - for ( y = - 0.125; y <= 0.125; y += 0.250 ) + for (y = -0.125; y <= 0.125; y += 0.250) { - for ( z = - 0.125; z <= 0.125; z += 0.250 ) + for (z = -0.125; z <= 0.125; z += 0.250) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3269,7 +3270,7 @@ void PM_CreateStuckTable( void ) x = z = 0; // Y moves - for (y = -2.0f ; y <= 2.0f ; y += 2.0) + for (y = -2.0f; y <= 2.0f; y += 2.0) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3278,7 +3279,7 @@ void PM_CreateStuckTable( void ) } y = z = 0; // X moves - for (x = -2.0f ; x <= 2.0f ; x += 2.0f) + for (x = -2.0f; x <= 2.0f; x += 2.0f) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3287,13 +3288,13 @@ void PM_CreateStuckTable( void ) } // Remaining multi axis nudges. - for (i = 0 ; i < 3; i++) + for (i = 0; i < 3; i++) { z = zi[i]; - - for (x = -2.0f ; x <= 2.0f ; x += 2.0f) + + for (x = -2.0f; x <= 2.0f; x += 2.0f) { - for (y = -2.0f ; y <= 2.0f ; y += 2.0) + for (y = -2.0f; y <= 2.0f; y += 2.0) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3307,21 +3308,21 @@ void PM_CreateStuckTable( void ) /* -This modume implements the shared player physics code between any particular game and +This modume implements the shared player physics code between any particular game and the engine. The same PM_Move routine is built into the game .dll and the client .dll and is invoked by each side as appropriate. There should be no distinction, internally, between server and client. This will ensure that prediction behaves appropriately. */ -void PM_Move ( struct playermove_s *ppmove, int server ) +void PM_Move(struct playermove_s* ppmove, int server) { - assert( pm_shared_initialized ); + assert(pm_shared_initialized); pmove = ppmove; - - PM_PlayerMove( ( server != 0 ) ? true : false ); - if ( pmove->onground != -1 ) + PM_PlayerMove((server != 0) ? true : false); + + if (pmove->onground != -1) { pmove->flags |= FL_ONGROUND; } @@ -3331,33 +3332,33 @@ void PM_Move ( struct playermove_s *ppmove, int server ) } // In single player, reset friction after each movement to FrictionModifier Triggers work still. - if ( !pmove->multiplayer && ( pmove->movetype == MOVETYPE_WALK ) ) + if (!pmove->multiplayer && (pmove->movetype == MOVETYPE_WALK)) { pmove->friction = 1.0f; } } -int PM_GetVisEntInfo( int ent ) +int PM_GetVisEntInfo(int ent) { - if ( ent >= 0 && ent <= pmove->numvisent ) + if (ent >= 0 && ent <= pmove->numvisent) { - return pmove->visents[ ent ].info; + return pmove->visents[ent].info; } return -1; } -int PM_GetPhysEntInfo( int ent ) +int PM_GetPhysEntInfo(int ent) { - if ( ent >= 0 && ent <= pmove->numphysent) + if (ent >= 0 && ent <= pmove->numphysent) { - return pmove->physents[ ent ].info; + return pmove->physents[ent].info; } return -1; } -void PM_Init( struct playermove_s *ppmove ) +void PM_Init(struct playermove_s* ppmove) { - assert( !pm_shared_initialized ); + assert(!pm_shared_initialized); pmove = ppmove; @@ -3365,4 +3366,4 @@ void PM_Init( struct playermove_s *ppmove ) PM_InitTextureTypes(); pm_shared_initialized = 1; -} +} \ No newline at end of file diff --git a/projects/vs2019/hldll.vcxproj b/projects/vs2019/hldll.vcxproj index 2cf8342..44fba6e 100644 --- a/projects/vs2019/hldll.vcxproj +++ b/projects/vs2019/hldll.vcxproj @@ -146,6 +146,7 @@ + @@ -200,6 +201,7 @@ + @@ -224,6 +226,7 @@ + diff --git a/projects/vs2019/hldll.vcxproj.filters b/projects/vs2019/hldll.vcxproj.filters index c352807..3a8c106 100644 --- a/projects/vs2019/hldll.vcxproj.filters +++ b/projects/vs2019/hldll.vcxproj.filters @@ -345,6 +345,12 @@ Source Files\pm_shared + + Source Files\dlls + + + Source Files\dlls + @@ -485,5 +491,8 @@ Header Files\common + + Header Files\dlls + \ No newline at end of file diff --git a/ricochet/cl_dll/hud.cpp b/ricochet/cl_dll/hud.cpp index a87aba9..a0e6da1 100644 --- a/ricochet/cl_dll/hud.cpp +++ b/ricochet/cl_dll/hud.cpp @@ -82,8 +82,6 @@ extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, i extern cvar_t *sensitivity; cvar_t *cl_lw = NULL; -cvar_t* cl_viewrollangle; -cvar_t* cl_viewrollspeed; void ShutdownInput (void); @@ -229,8 +227,6 @@ void CHud :: Init( void ) CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); default_fov = CVAR_CREATE( "default_fov", "90", 0 ); - cl_viewrollangle = CVAR_CREATE("cl_viewrollangle", "0.65", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); - cl_viewrollspeed = CVAR_CREATE("cl_viewrollspeed", "300", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); diff --git a/ricochet/cl_dll/view.cpp b/ricochet/cl_dll/view.cpp index 4fbbff4..aab55ea 100644 --- a/ricochet/cl_dll/view.cpp +++ b/ricochet/cl_dll/view.cpp @@ -375,8 +375,6 @@ V_CalcViewRoll Roll is induced by movement and damage ============== */ -extern cvar_t* cl_viewrollangle; -extern cvar_t* cl_viewrollspeed; void V_CalcViewRoll ( struct ref_params_s *pparams ) { float side; @@ -386,7 +384,6 @@ void V_CalcViewRoll ( struct ref_params_s *pparams ) if ( !viewentity ) return; - pparams->viewangles[ROLL] = V_CalcRoll(pparams->viewangles, pparams->simvel, cl_viewrollangle->value, cl_viewrollspeed->value) * 4; side = V_CalcRoll ( viewentity->angles, pparams->simvel, pparams->movevars->rollangle, pparams->movevars->rollspeed ); pparams->viewangles[ROLL] += side; @@ -740,7 +737,6 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) view->angles[YAW] -= bob * 0.5; view->angles[ROLL] -= bob * 1; view->angles[PITCH] -= bob * 0.3; - VectorCopy(view->angles, view->curstate.angles); // pushing the view origin down off of the same X/Z plane as the ent's origin will give the // gun a very nice 'shifting' effect when the player looks up/down. If there is a problem