From 2a69d07ee0b7304a041611d606926b996bed973e Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 3 Dec 2016 01:35:50 +0100 Subject: [PATCH] Last commit for tonight, slowly adding in clientside sounds for the viewmodels --- Source/Client/Defs.h | 5 +++++ Source/Client/Sound.c | 12 ++++++++++++ Source/Client/VGUI_BuyMenu.c | 4 ++-- Source/Globals.h | 3 ++- Source/Server/EntHostage.c | 1 + Source/Server/Main.c | 2 ++ Source/Server/Spawn.c | 6 ++---- Source/Server/progs.src | 2 -- Source/Shared/WeaponAK47.c | 4 +++- Source/Shared/WeaponDeagle.c | 9 +++++---- Source/Shared/WeaponElites.c | 6 +++--- Source/Shared/WeaponFiveSeven.c | 6 +++--- Source/Shared/WeaponG3SG1.c | 6 +++--- Source/Shared/WeaponGlock18.c | 11 +++++++---- Source/Shared/WeaponM4A1.c | 15 ++++++++------- Source/Shared/WeaponP228.c | 6 +++--- Source/Shared/WeaponSG550.c | 6 +++--- Source/Shared/WeaponScout.c | 6 +++--- Source/Shared/WeaponUSP45.c | 21 +++++++++++---------- 19 files changed, 78 insertions(+), 53 deletions(-) diff --git a/Source/Client/Defs.h b/Source/Client/Defs.h index 1197080a..394673c1 100644 --- a/Source/Client/Defs.h +++ b/Source/Client/Defs.h @@ -37,4 +37,9 @@ float fInputKeyDown; float fMouseClick; vector vMousePos; +// Sound Stuff +.string sSoundSample; +.float fVolume; + void View_PlayAnimation( int iSequence ); +void Sound_Delayed( string sSample, float fVol, float fDelay ); diff --git a/Source/Client/Sound.c b/Source/Client/Sound.c index 03a37b01..ff53f7c4 100644 --- a/Source/Client/Sound.c +++ b/Source/Client/Sound.c @@ -21,3 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. float CSQC_Event_Sound( float entnum, float channel, string soundname, float vol, float attenuation, vector pos, float pitchmod, float flags ) { } + +void Sound_Delayed( string sSample, float fVol, float fDelay ) { + static void Sound_Delayed_PlayBack( void ) { + localsound( self.sSoundSample, CHAN_AUTO, self.fVolume ); + remove( self ); + } + entity eSound = spawn(); + eSound.think = Sound_Delayed_PlayBack; + eSound.sSoundSample = sSample; + eSound.fVolume = fVol; + eSound.nextthink = time + fDelay; +} diff --git a/Source/Client/VGUI_BuyMenu.c b/Source/Client/VGUI_BuyMenu.c index 1fdde718..3aa0fac9 100644 --- a/Source/Client/VGUI_BuyMenu.c +++ b/Source/Client/VGUI_BuyMenu.c @@ -203,7 +203,7 @@ VGUI_BuyMenu_Rifles void VGUI_BuyMenu_Rifles( vector vPos ) { vVGUIButtonPos = vPos + '16 116 0'; - if ( getplayerkeyvalue( player_localnum, "team" ) == "t" ) { + if ( getstati( STAT_TEAM ) == TEAM_T ) { VGUI_BuyMenu_Button( WEAPON_AK47 ); VGUI_BuyMenu_Button( WEAPON_SG552 ); @@ -213,7 +213,7 @@ void VGUI_BuyMenu_Rifles( vector vPos ) { VGUI_BuyMenu_Button( WEAPON_G3SG1 ); } - if ( getplayerkeyvalue( player_localnum, "team" ) == "ct" ) { + if ( getstati( STAT_TEAM ) == TEAM_CT ) { VGUI_BuyMenu_Button( WEAPON_M4A1 ); VGUI_BuyMenu_Button( WEAPON_AUG ); diff --git a/Source/Globals.h b/Source/Globals.h index 2411e1ce..f283ae41 100644 --- a/Source/Globals.h +++ b/Source/Globals.h @@ -35,7 +35,8 @@ enum { STAT_SLOT_SECONDARY, STAT_SLOT_GRENADE, STAT_CURRENT_CLIP, - STAT_CURRENT_CALIBER + STAT_CURRENT_CALIBER, + STAT_TEAM }; enum { diff --git a/Source/Server/EntHostage.c b/Source/Server/EntHostage.c index eb13c4a6..6e314b06 100644 --- a/Source/Server/EntHostage.c +++ b/Source/Server/EntHostage.c @@ -30,6 +30,7 @@ void hostage_pain( void ) { } void hostage_die( void ) { + sound( world, CHAN_VOICE, "radio/hosdown.wav", 1.0, ATTN_NONE ); self.frame = 30 + ceil( random() * 5); self.solid = SOLID_NOT; self.takedamage = DAMAGE_NO; diff --git a/Source/Server/Main.c b/Source/Server/Main.c index 4858dfaa..4dd9bee3 100644 --- a/Source/Server/Main.c +++ b/Source/Server/Main.c @@ -61,6 +61,7 @@ void worldspawn( void ) { precache_sound( "radio/letsgo.wav" ); precache_sound( "radio/locknload.wav" ); precache_sound( "radio/rescued.wav" ); + precache_sound( "radio/hosdown.wav" ); precache_sound( "hostage/hos1.wav" ); precache_sound( "hostage/hos2.wav" ); @@ -237,6 +238,7 @@ void worldspawn( void ) { clientstat( STAT_SLOT_GRENADE, EV_INTEGER, iSlotGrenade ); clientstat( STAT_CURRENT_CLIP, EV_INTEGER, iCurrentClip ); clientstat( STAT_CURRENT_CALIBER, EV_INTEGER, iCurrentCaliber ); + clientstat( STAT_TEAM, EV_INTEGER, team ); pointerstat( STAT_GAMETIME, EV_FLOAT, &fGameTime ); } diff --git a/Source/Server/Spawn.c b/Source/Server/Spawn.c index 12b321c4..d64020ce 100644 --- a/Source/Server/Spawn.c +++ b/Source/Server/Spawn.c @@ -32,16 +32,14 @@ void Spawn_GameClient( float fTeam ) { return; } else if( fTeam < 5 ) { eSpawn = find ( world, classname, "info_player_deathmatch" ); - self.team = TEAM_T; // This is only important to the Server codebase - forceinfokey( self, "team", "t" ); // This is for the Client codebase + self.team = TEAM_T; // TODO: Move this away from here Weapon_AddItem( WEAPON_GLOCK18 ); Weapon_GiveAmmo( WEAPON_GLOCK18, 40 ); } else { eSpawn = find ( world, classname, "info_player_start" ); - self.team = TEAM_CT; // This is only important to the Server codebase - forceinfokey( self, "team", "ct" ); // This is for the Client codebase + self.team = TEAM_CT; // TODO: Move this away from here Weapon_AddItem( WEAPON_USP45 ); diff --git a/Source/Server/progs.src b/Source/Server/progs.src index 6907db19..ce7349ec 100644 --- a/Source/Server/progs.src +++ b/Source/Server/progs.src @@ -2,8 +2,6 @@ #pragma progs_dat "../../Main/progs.dat" -#define SSQC - #includelist ../Builtins.h ../Globals.h diff --git a/Source/Shared/WeaponAK47.c b/Source/Shared/WeaponAK47.c index 86f3a742..de847ea4 100644 --- a/Source/Shared/WeaponAK47.c +++ b/Source/Shared/WeaponAK47.c @@ -56,9 +56,9 @@ enum { void WeaponAK47_Draw( void ) { #ifdef SSQC OpenCSGunBase_Draw(); - sound( self, CHAN_WEAPON, "weapons/ak47_boltpull.wav", 1, ATTN_IDLE ); // TODO: Move to the client...? #else View_PlayAnimation( ANIM_AK47_DRAW ); + Sound_Delayed( "weapons/ak47_boltpull.wav", 1.0, 0.5 ); #endif } @@ -90,5 +90,7 @@ void WeaponAK47_Reload( void ) { } #else View_PlayAnimation( ANIM_AK47_RELOAD ); + Sound_Delayed( "weapons/ak47_clipout.wav", 1.0, 0.6 ); + Sound_Delayed( "weapons/ak47_clipin.wav", 1.0, 1.5 ); #endif } diff --git a/Source/Shared/WeaponDeagle.c b/Source/Shared/WeaponDeagle.c index 8b1807fe..027cd2b0 100644 --- a/Source/Shared/WeaponDeagle.c +++ b/Source/Shared/WeaponDeagle.c @@ -38,9 +38,9 @@ weaponinfo_t wptDEAGLE = { 2.1, // Reload-Delay iAmmo_50AE, // Caliber Pointer iClip_DEAGLE, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table @@ -56,7 +56,6 @@ enum { void WeaponDEAGLE_Draw( void ) { #ifdef SSQC OpenCSGunBase_Draw(); - sound( self, CHAN_WEAPON, "weapons/de_deploy.wav", 1, ATTN_IDLE ); // TODO: Move to the client.. #else View_PlayAnimation( ANIM_DEAGLE_DRAW ); #endif @@ -92,5 +91,7 @@ void WeaponDEAGLE_Reload( void ) { } #else View_PlayAnimation( ANIM_DEAGLE_RELOAD ); + Sound_Delayed( "weapons/de_clipout.wav", 1.0, 0.5 ); + Sound_Delayed( "weapons/de_clipin.wav", 1.0, 1.2 ); #endif } diff --git a/Source/Shared/WeaponElites.c b/Source/Shared/WeaponElites.c index 98f6c88b..e2665a47 100644 --- a/Source/Shared/WeaponElites.c +++ b/Source/Shared/WeaponElites.c @@ -44,9 +44,9 @@ weaponinfo_t wptELITES = { 4.6, // Reload-Delay iAmmo_9MM, // Caliber Pointer iClip_ELITES, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table diff --git a/Source/Shared/WeaponFiveSeven.c b/Source/Shared/WeaponFiveSeven.c index 60e1dfe7..abfcd5f1 100644 --- a/Source/Shared/WeaponFiveSeven.c +++ b/Source/Shared/WeaponFiveSeven.c @@ -38,9 +38,9 @@ weaponinfo_t wptFIVESEVEN = { 3.1, // Reload-Delay iAmmo_57MM, // Caliber Pointer iClip_FIVESEVEN, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table diff --git a/Source/Shared/WeaponG3SG1.c b/Source/Shared/WeaponG3SG1.c index 46eb8a04..6763bc69 100644 --- a/Source/Shared/WeaponG3SG1.c +++ b/Source/Shared/WeaponG3SG1.c @@ -38,9 +38,9 @@ weaponinfo_t wptG3SG1 = { 4.6, // Reload-Delay iAmmo_762MM, // Caliber Pointer iClip_G3SG1, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table diff --git a/Source/Shared/WeaponGlock18.c b/Source/Shared/WeaponGlock18.c index 962b7863..9bf748b1 100644 --- a/Source/Shared/WeaponGlock18.c +++ b/Source/Shared/WeaponGlock18.c @@ -44,9 +44,9 @@ weaponinfo_t wptGLOCK18 = { 2.0, // Reload-Delay iAmmo_9MM, // Caliber Pointer iClip_GLOCK18, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracyy }; // Anim Table @@ -69,13 +69,13 @@ enum { void WeaponGLOCK18_Draw( void ) { #ifdef SSQC OpenCSGunBase_Draw(); - sound( self, CHAN_WEAPON, "weapons/slideback1.wav", 1, ATTN_IDLE ); // TODO: Move to the client...? #else if ( random() <= 0.5 ) { View_PlayAnimation( ANIM_GLOCK_DRAW1 ); } else { View_PlayAnimation( ANIM_GLOCK_DRAW2 ); } + Sound_Delayed( "weapons/slideback1.wav", 1.0, 0.5 ); #endif } @@ -135,6 +135,9 @@ void WeaponGLOCK18_Reload( void ) { View_PlayAnimation( ANIM_GLOCK_RELOAD1 ); } else { View_PlayAnimation( ANIM_GLOCK_RELOAD2 ); + Sound_Delayed( "weapons/clipout1.wav", 1.0, 0.6 ); + Sound_Delayed( "weapons/clipin1.wav", 1.0, 1.0 ); + Sound_Delayed( "weapons/sliderelease1.wav", 1.0, 1.7 ); } #endif } diff --git a/Source/Shared/WeaponM4A1.c b/Source/Shared/WeaponM4A1.c index c79444a9..8f5f6fdd 100644 --- a/Source/Shared/WeaponM4A1.c +++ b/Source/Shared/WeaponM4A1.c @@ -75,6 +75,8 @@ void WeaponM4A1_Draw( void ) { } else { View_PlayAnimation( ANIM_M4A1_DRAW ); } + + Sound_Delayed( "weapons/m4a1_boltpull.wav", 1.0, 0.5 ); #endif } @@ -124,20 +126,15 @@ void WeaponM4A1_Secondary( void ) { // Tell the client that we switched modes, too Client_SendEvent( self, EV_WEAPON_SECONDARYATTACK ); - - if ( self.iMode_M4A1 == TRUE ) { - sound( self, CHAN_WEAPON, "weapons/m4a1_silencer_on.wav", 1, ATTN_NORM ); - } else { - sound( self, CHAN_WEAPON, "weapons/m4a1_silencer_off.wav", 1, ATTN_NORM ); - } - #else iWeaponMode_M4A1 = 1 - iWeaponMode_M4A1; if ( iWeaponMode_M4A1 == TRUE ) { View_PlayAnimation( ANIM_M4A1_SILENCER_ADD ); + Sound_Delayed( "weapons/m4a1_silencer_on.wav", 1.0, 0.95 ); } else { View_PlayAnimation( ANIM_M4A1_SILENCER_REMOVE ); + Sound_Delayed( "weapons/m4a1_silencer_off.wav", 1.0, 0.6 ); } #endif } @@ -153,5 +150,9 @@ void WeaponM4A1_Reload( void ) { } else { View_PlayAnimation( ANIM_M4A1_RELOAD ); } + + Sound_Delayed( "weapons/m4a1_clipout.wav", 1.0, 0.5 ); + Sound_Delayed( "weapons/m4a1_clipin.wav", 1.0, 1.5 ); + Sound_Delayed( "weapons/m4a1_boltpull.wav", 1.0, 2.4 ); #endif } diff --git a/Source/Shared/WeaponP228.c b/Source/Shared/WeaponP228.c index 69483f39..8f7eab4d 100644 --- a/Source/Shared/WeaponP228.c +++ b/Source/Shared/WeaponP228.c @@ -38,9 +38,9 @@ weaponinfo_t wptP228 = { 2.7, // Reload-Delay iAmmo_357SIG, // Caliber Pointer iClip_P228, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table diff --git a/Source/Shared/WeaponSG550.c b/Source/Shared/WeaponSG550.c index 7f94a483..6d698566 100644 --- a/Source/Shared/WeaponSG550.c +++ b/Source/Shared/WeaponSG550.c @@ -38,9 +38,9 @@ weaponinfo_t wptSG550 = { 3.8, // Reload-Delay iAmmo_556MM, // Caliber Pointer iClip_SG550, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table diff --git a/Source/Shared/WeaponScout.c b/Source/Shared/WeaponScout.c index 332de7e9..56bb535e 100644 --- a/Source/Shared/WeaponScout.c +++ b/Source/Shared/WeaponScout.c @@ -38,9 +38,9 @@ weaponinfo_t wptSCOUT = { 2.0, // Reload-Delay iAmmo_762MM, // Caliber Pointer iClip_SCOUT, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; // Anim Table diff --git a/Source/Shared/WeaponUSP45.c b/Source/Shared/WeaponUSP45.c index 63461c44..be1af579 100644 --- a/Source/Shared/WeaponUSP45.c +++ b/Source/Shared/WeaponUSP45.c @@ -44,9 +44,9 @@ weaponinfo_t wptUSP45 = { 2.5, // Reload-Delay iAmmo_45ACP, // Caliber Pointer iClip_USP45, // Clip Pointer - -1, // Accuracy Divisor - 0, // Accuracy Offset - 0 // Max Inaccuracy + 200, // Accuracy Divisor + 0.55, // Accuracy Offset + 1.4 // Max Inaccuracy }; enum { @@ -77,6 +77,8 @@ void WeaponUSP45_Draw( void ) { } else { View_PlayAnimation( ANIM_USP45_DRAW ); } + + Sound_Delayed( "weapons/usp_slideback.wav", 1.0, 0.5 ); #endif } @@ -134,20 +136,15 @@ void WeaponUSP45_Secondary( void ) { // Tell the client that we switched modes, too Client_SendEvent( self, EV_WEAPON_SECONDARYATTACK ); - - if ( self.iMode_M4A1 == TRUE ) { - sound( self, CHAN_WEAPON, "weapons/usp_silencer_on.wav", 1, ATTN_NORM ); - } else { - sound( self, CHAN_WEAPON, "weapons/usp_silencer_off.wav", 1, ATTN_NORM ); - } - #else iWeaponMode_USP45 = 1 - iWeaponMode_USP45; if ( iWeaponMode_USP45 == TRUE ) { View_PlayAnimation( ANIM_USP45_SILENCER_ADD ); + Sound_Delayed( "weapons/usp_silencer_on.wav", 1.0, 0.95 ); } else { View_PlayAnimation( ANIM_USP45_SILENCER_REMOVE ); + Sound_Delayed( "weapons/usp_silencer_off.wav", 1.0, 0.6 ); } #endif } @@ -163,5 +160,9 @@ void WeaponUSP45_Reload( void ) { } else { View_PlayAnimation( ANIM_USP45_RELOAD ); } + + Sound_Delayed( "weapons/usp_clipout.wav", 1.0, 0.5 ); + Sound_Delayed( "weapons/usp_clipin.wav", 1.0, 1.1 ); + Sound_Delayed( "weapons/usp_sliderelease.wav", 1.0, 2.2 ); #endif }