From: Rudolf Polzer Date: Mon, 14 Feb 2011 17:54:19 +0000 (+0100) Subject: move hitsound clientside X-Git-Tag: xonotic-v0.5.0~311^2~18 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5a1b55edf62debd226ee50f07142ff8deac94b50;p=xonotic%2Fxonotic-data.pk3dir.git move hitsound clientside --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index c5e6872a6..c76176a84 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -304,7 +304,8 @@ set sv_ready_restart 0 "if set to 1 allow a map to be restarted once all players set sv_ready_restart_after_countdown 0 "if set to 1 the players and map items are reset after the countdown ended, otherwise they're reset already at the beginning of the countdown" set sv_ready_restart_repeatable 0 "allows the players to restart the game as often as needed" -set sv_hitsound_antispam_time 0.05 "don't play the hitsound more often than this for the electro lightning gun or the laser gauntlet" +seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy" +set cl_hitsound_antispam_time 0.05 "don't play the hitsound more often than this" //nifreks lockonrestart feature, used in team-based game modes, if set to 1 and all players readied up no other player can then join the game anymore, useful to block spectators from joining set teamplay_lockonrestart 0 "it set to 1 in a team-based game, the teams are locked once all players readied up and the game restarted (no new players can join after restart unless using the server-command unlockteams)" @@ -930,7 +931,6 @@ sv_sound_watersplash "" seta cl_sound_maptime_warning "1" "play announcer sound telling you the remaining maptime - 0: do not play at all, 1: play at one minute, 2: play at five minutes, 3: play both" seta cl_notify_carried_items "3" "notify you of carried items when you obtain them (e.g. flags in CTF) - 0: disabled, 1: notify of taken items, 2: notify of picking up dropped items, 3: notify of both" -seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy" seta cl_announcer default "name of the announcer you wish to use from data/sound/announcer" // startmap_dm is used when running with the -listen or -dedicated commandline options diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index f87538a9e..861486331 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -136,6 +136,8 @@ void CSQC_Init(void) WaypointSprite_Load(); // precaches + precache_sound("misc/hit.wav"); + precache_sound("misc/typehit.wav"); Projectile_Precache(); Hook_Precache(); GibSplash_Precache(); diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 6feab40b7..7270a9cf1 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -353,6 +353,8 @@ vector freeze_pmove_org, freeze_input_angles; entity nightvision_noise, nightvision_noise2; float pickup_crosshair_time, pickup_crosshair_size; +float hit_time, typehit_time; +float nextsound_hit_time, nextsound_typehit_time; float hitindication_crosshair_time, hitindication_crosshair_size; float use_nex_chargepool; @@ -810,6 +812,19 @@ void CSQC_UpdateView(float w, float h) scoreboard_active = HUD_WouldDrawScoreboard(); + hit_time = getstatf(STAT_HIT_TIME); + if(hit_time > nextsound_hit_time && autocvar_cl_hitsound) + { + sound(world, CHAN_AUTO, "misc/hit.wav", VOL_BASE, ATTN_NONE); + nextsound_hit_time = time + autocvar_cl_hitsound_antispam_time; + } + typehit_time = getstatf(STAT_TYPEHIT_TIME); + if(typehit_time > nextsound_typehit_time) + { + sound(world, CHAN_AUTO, "misc/typehit.wav", VOL_BASE, ATTN_NONE); + nextsound_typehit_time = time + autocvar_cl_hitsound_antispam_time; + } + float hud; hud = getstati(STAT_HUD); if(hud == HUD_SPIDERBOT) @@ -979,10 +994,10 @@ void CSQC_UpdateView(float w, float h) if(autocvar_crosshair_hitindication) { hitindication_color = stov(autocvar_crosshair_hitindication_color); - if(hitindication_crosshair_time < getstatf(STAT_HIT_TIME)) + if(hitindication_crosshair_time < hit_time) { hitindication_crosshair_size = 1; - hitindication_crosshair_time = getstatf(STAT_HIT_TIME); + hitindication_crosshair_time = hit_time; } if(hitindication_crosshair_size > 0) diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index c2fff2e83..790855c88 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -294,3 +294,5 @@ float autocvar_vid_conwidth; float autocvar_vid_pixelheight; float autocvar_viewsize; float autocvar_crosshair_color_by_health; +float autocvar_cl_hitsound; +float autocvar_cl_hitsound_antispam_time; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index d6752cca4..60633f574 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -314,6 +314,7 @@ const float STAT_LAST_PICKUP = 50; const float STAT_HUD = 51; const float STAT_NEX_CHARGEPOOL = 52; const float STAT_HIT_TIME = 53; +const float STAT_TYPEHIT_TIME = 54; // see DP source, quakedef.h const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222; diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 0820ef713..fdbdd4b05 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1120,7 +1120,6 @@ float autocvar_sv_friction; float autocvar_sv_friction_on_land; float autocvar_sv_gameplayfix_q2airaccelerate; #define autocvar_sv_gravity cvar("sv_gravity") -float autocvar_sv_hitsound_antispam_time; string autocvar_sv_intermission_cdtrack; string autocvar_sv_jumpspeedcap_max; float autocvar_sv_jumpspeedcap_max_disable_on_ramps; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 5dcd9078e..936cb9c6b 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -606,6 +606,7 @@ string matchid; .float last_pickup; .float hit_time; +.float typehit_time; .float stat_leadlimit; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index d27c31a6a..22497c99d 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -790,14 +790,11 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float if(damage > 0) { if(deathtype != DEATH_FIRE) - if(attacker.prevhitsound + autocvar_sv_hitsound_antispam_time < time) { if(targ.BUTTON_CHAT) attacker.typehitsound += 1; else attacker.hitsound += 1; - attacker.prevhitsound = time; - attacker.hit_time = time; } damage_goodhits += 1; @@ -823,10 +820,8 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float else { if(deathtype != DEATH_FIRE) - if(attacker.prevhitsound + autocvar_sv_hitsound_antispam_time < time) { attacker.typehitsound += 1; - attacker.prevhitsound = time; } if(mirrordamage > 0) if(time > attacker.teamkill_complain) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 996b89b45..268743b41 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -826,6 +826,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_BULLETS_LOADED, AS_INT, sniperrifle_bulletcounter); addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup); addstat(STAT_HIT_TIME, AS_FLOAT, hit_time); + addstat(STAT_TYPEHIT_TIME, AS_FLOAT, typehit_time); addstat(STAT_NEX_CHARGE, AS_FLOAT, nex_charge); addstat(STAT_NEX_CHARGEPOOL, AS_FLOAT, nex_chargepool_ammo); @@ -2841,16 +2842,16 @@ void EndFrame() if(self.classname == "spectator") { if(self.enemy.typehitsound) - play2(self, "misc/typehit.wav"); + self.typehit_time = time; else if(self.enemy.hitsound && self.cvar_cl_hitsound) - play2(self, "misc/hit.wav"); + self.hit_time = time; } else { if(self.typehitsound) - play2(self, "misc/typehit.wav"); + self.typehit_time = time; else if(self.hitsound && self.cvar_cl_hitsound) - play2(self, "misc/hit.wav"); + self.hit_time = time; } } altime = time + frametime * (1 + autocvar_g_antilag_nudge); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 508957b4a..c04c477cd 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1639,8 +1639,6 @@ void precache() precache_sound ("misc/gib_splat02.wav"); precache_sound ("misc/gib_splat03.wav"); precache_sound ("misc/gib_splat04.wav"); - precache_sound ("misc/hit.wav"); - precache_sound ("misc/typehit.wav"); PrecacheGlobalSound((globalsound_fall = "misc/hitground 4")); PrecacheGlobalSound((globalsound_metalfall = "misc/metalhitground 4")); precache_sound ("misc/null.wav"); diff --git a/qcsrc/server/nexball.qc b/qcsrc/server/nexball.qc index b1f59497a..13e8eea40 100644 --- a/qcsrc/server/nexball.qc +++ b/qcsrc/server/nexball.qc @@ -725,6 +725,7 @@ float w_nexball_weapon(float req) precache_model ("models/elaser.mdl"); precache_sound ("nexball/shoot1.wav"); precache_sound ("nexball/shoot2.wav"); + precache_sound ("misc/typehit.wav"); } else if (req == WR_SETUP) weapon_setup(WEP_PORTO);