]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
move hitsound clientside
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 14 Feb 2011 17:54:19 +0000 (18:54 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 14 Feb 2011 18:06:27 +0000 (19:06 +0100)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/common/constants.qh
qcsrc/server/autocvars.qh
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/nexball.qc

index c5e6872a629fc06b89fdd0e8c1b2bc3761467e63..c76176a843fbbff851f86403ba198fb2c3c05f41 100644 (file)
@@ -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
index f87538a9eebf76e80d1483d714b88e9a2ca1c378..8614863318dcac9396237f4d6462dc30cdcf2826 100644 (file)
@@ -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();
index 6feab40b7ba2daebc26423a53996de2a591ad572..7270a9cf19e0882a9f41bf26434ff325dcb33f9f 100644 (file)
@@ -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)
index c2fff2e83c959ba06d2dc16dad675d4ea72db447..790855c88d0025bb5ec33f1fc864fc70404a342a 100644 (file)
@@ -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;
index d6752cca4c11a56fca1d316b548aca46a9af991c..60633f57472b111687223018d3491f9488a28fbf 100644 (file)
@@ -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;
index 0820ef713f2d261caf9414ee34a2ff8c86cf6fda..fdbdd4b05508ba1c7df86f4128cad3fb415d34ea 100644 (file)
@@ -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;
index 5dcd9078e290513587197b209f494ce133682db2..936cb9c6b651f85f181fc82a86bc65bd7c3aadd3 100644 (file)
@@ -606,6 +606,7 @@ string matchid;
 .float last_pickup;
 
 .float hit_time; 
+.float typehit_time; 
 
 .float stat_leadlimit;
 
index d27c31a6aafec21f2fe5ee23e5eaf14488573d2a..22497c99d978eb9ba4cc74511d5d6c96cc793b7b 100644 (file)
@@ -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)
index 996b89b45add77861b00f6590328e84adc3ee700..268743b41542393e8389fef479be07b8109eb18f 100644 (file)
@@ -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);
index 508957b4aa4c6b14edb98c49d50f48216afc4dcd..c04c477cdf778cc0b32be50b5e628999342ad3f4 100644 (file)
@@ -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");
index b1f59497abde896bff38abc3fcfbad79120252ad..13e8eea40a9103424f89eb187af775d0903f247f 100644 (file)
@@ -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);