]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add support for a kill sound (still need a sound file for it)
authorMario <mario@smbclan.net>
Wed, 7 Dec 2016 15:11:48 +0000 (01:11 +1000)
committerMario <mario@smbclan.net>
Wed, 7 Dec 2016 15:11:48 +0000 (01:11 +1000)
qcsrc/client/view.qc
qcsrc/common/sounds/all.inc
qcsrc/common/stats.qh
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc

index 2ca531166a936555ce61bde93b471579ed3a9a10..95e3a7b7dcf96aeb29d9a3d65e7e80670f2a6b05 100644 (file)
@@ -854,6 +854,14 @@ void HitSound()
                sound(NULL, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
                typehit_time_prev = typehit_time;
        }
+
+       static float kill_time_prev = 0;
+       float kill_time = STAT(KILL_TIME);
+       if (COMPARE_INCREASING(kill_time, kill_time_prev) > autocvar_cl_hitsound_antispam_time)
+       {
+               sound(NULL, CH_INFO, SND_KILL, VOL_BASE, ATTN_NONE);
+               kill_time_prev = kill_time;
+       }
 }
 
 vector crosshair_getcolor(entity this, float health_stat)
index 69a95be0cce22074d75686a5aaf52c90c017ad80..99e377e6464f2b91cb5e448e13849038ed1904fb 100644 (file)
@@ -265,6 +265,7 @@ Sound SND_GIB_SPLAT_RANDOM() {
 
 SOUND(HIT, "misc/hit");
 SOUND(TYPEHIT, "misc/typehit");
+SOUND(KILL, "misc/kill");
 
 SOUND(SPAWN, "misc/spawn");
 
index 82398aa56b1c7d40513bdfb5e735115a0e4087ee..5816d5ad198dfe27dcb6de687e32e1e30a9f76cc 100644 (file)
@@ -125,6 +125,7 @@ REGISTER_STAT(CAPTURE_PROGRESS, float)
 REGISTER_STAT(ENTRAP_ORB, float)
 REGISTER_STAT(ENTRAP_ORB_ALPHA, float)
 REGISTER_STAT(ITEMSTIME, int, autocvar_sv_itemstime)
+REGISTER_STAT(KILL_TIME, float)
 
 #ifdef SVQC
 int autocvar_g_multijump;
index 52153fcd7edeedaf2b7c3aec557103786fcca343..42cf15db4c57fdc13d64372daace3b49e8c49f8d 100644 (file)
@@ -96,7 +96,7 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 .float         dmgtime;
 
 .float         killcount;
-.float damage_dealt, typehitsound;
+.float damage_dealt, typehitsound, killsound;
 
 .float watersound_finished;
 .float iscreature;
@@ -320,6 +320,7 @@ string matchid;
 
 .float hit_time = _STAT(HIT_TIME);
 .float typehit_time = _STAT(TYPEHIT_TIME);
+.float kill_time = _STAT(KILL_TIME);
 
 .float damage_dealt_total = _STAT(DAMAGE_DEALT_TOTAL);
 
index a604a2bade1ef61b8ac45bb1eeac7d068ed3b406..ab487eac20f142712f702bcd94b2f6bcd1151f45 100644 (file)
@@ -370,6 +370,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
                        attacker.taunt_soundtime = time + 1;
                        attacker.killcount = attacker.killcount + 1;
 
+                       attacker.killsound += 1;
+
                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
                                case counta: \
                                { \
index 8edcf3b8f58f7b0010efffabd1279ab4c6d9ab9f..c9d25353237bd89b854e6b6a5fa921000904a269 100644 (file)
@@ -2072,6 +2072,8 @@ void EndFrame()
                entity e = IS_SPEC(it) ? it.enemy : it;
                if (e.typehitsound) {
                        it.typehit_time = time;
+               } else if (e.killsound) {
+                       it.kill_time = time;
                } else if (e.damage_dealt) {
                        it.hit_time = time;
                        it.damage_dealt_total += ceil(e.damage_dealt);
@@ -2086,6 +2088,7 @@ void EndFrame()
        FOREACH_CLIENT(true, {
                it.typehitsound = false;
                it.damage_dealt = 0;
+               it.killsound = false;
                antilag_record(it, CS(it), altime);
        });
        IL_EACH(g_monsters, true,