]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a spam hittype for weapon attacks that repeatedly trigger radius damage
authorMario <mario.mario@y7mail.com>
Thu, 3 Oct 2024 15:41:40 +0000 (01:41 +1000)
committerMario <mario.mario@y7mail.com>
Thu, 3 Oct 2024 15:41:40 +0000 (01:41 +1000)
qcsrc/common/deathtypes/all.qh
qcsrc/common/weapons/weapon/hook.qc
qcsrc/server/damage.qc

index f4b49801872c8be06fff89cd4a04e08dca055312..f83a2a5c81b45ce11d126d92792f8bd76eaf42a3 100644 (file)
@@ -23,14 +23,14 @@ REGISTRY_DEFINE_GET(Deathtypes, NULL)
 
 const int DEATH_WEAPONMASK = BITS(8);
 const int HITTYPE_SECONDARY = BITS(1) << 8;
-/** automatically set by RadiusDamage */
-const int HITTYPE_SPLASH = BITS(1) << 9;
-const int HITTYPE_BOUNCE = BITS(1) << 10;
-const int HITTYPE_ARMORPIERCE = BITS(1) << 11;
-const int HITTYPE_SOUND = BITS(1) << 12;
-const int DEATH_HITTYPEMASK = HITTYPE_SECONDARY | HITTYPE_SPLASH | HITTYPE_BOUNCE | HITTYPE_ARMORPIERCE | HITTYPE_SOUND;
+const int HITTYPE_SPLASH = BITS(1) << 9; // automatically set by RadiusDamage
+const int HITTYPE_BOUNCE = BITS(1) << 10; // set manually after projectile has bounced
+const int HITTYPE_ARMORPIERCE = BITS(1) << 11; // ignore armor calculations
+const int HITTYPE_SOUND = BITS(1) << 12; // cause bleeding from ears
+const int HITTYPE_SPAM = BITS(1) << 13; // set manually after first RadiusDamage, stops effect spam
+const int DEATH_HITTYPEMASK = HITTYPE_SECONDARY | HITTYPE_SPLASH | HITTYPE_BOUNCE | HITTYPE_ARMORPIERCE | HITTYPE_SOUND | HITTYPE_SPAM;
 // normal deaths begin
-const int DT_FIRST = BIT(13);
+const int DT_FIRST = BIT(14);
 
 #define DEATH_ISSPECIAL(t)      (t >= DT_FIRST)
 #define DEATH_IS(t, dt)         (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)) == dt)
index d8174d3bde946e427dfa0c904c9a3fba9e676021..a5d2dc69e01dac21316bbc4ee2a815d1960a1bdc 100644 (file)
@@ -13,7 +13,7 @@ void W_Hook_ExplodeThink(entity this)
        this.dmg_last = dmg_remaining_next;
 
        RadiusDamage(this, this.realowner, this.dmg * f, this.dmg_edge * f, this.dmg_radius, this.realowner, NULL, this.dmg_force * f, this.projectiledeathtype, this.weaponentity_fld, NULL);
-       this.projectiledeathtype |= HITTYPE_BOUNCE;
+       this.projectiledeathtype |= HITTYPE_SPAM;
        //RadiusDamage(this, NULL, this.dmg * f, this.dmg_edge * f, this.dmg_radius, NULL, NULL, this.dmg_force * f, this.projectiledeathtype, NULL);
 
        if(dt < this.dmg_duration)
index d5a9a20c760d352a7d6631ed2530eba9cf2faad4..928f073e18d43eca41e093fb71018cef67b80c14 100644 (file)
@@ -895,19 +895,18 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
 
        total_damage_to_creatures = 0;
 
-       if(deathtype != (WEP_HOOK.m_id | HITTYPE_SECONDARY | HITTYPE_BOUNCE)) // only send gravity bomb damage once
-               if(!(deathtype & HITTYPE_SOUND)) // do not send radial sound damage (bandwidth hog)
-               {
-                       force = inflictorvelocity;
-                       if(force == '0 0 0')
-                               force = '0 0 -1';
-                       else
-                               force = normalize(force);
-                       if(forceintensity >= 0)
-                               Damage_DamageInfo(inflictororigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, 0, attacker);
-                       else
-                               Damage_DamageInfo(inflictororigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, 0, attacker);
-               }
+       if(!(deathtype & HITTYPE_SOUND) && !(deathtype & HITTYPE_SPAM)) // do not send bandwidth-hogging radial spam attacks
+       {
+               force = inflictorvelocity;
+               if(force == '0 0 0')
+                       force = '0 0 -1';
+               else
+                       force = normalize(force);
+               if(forceintensity >= 0)
+                       Damage_DamageInfo(inflictororigin, coredamage, edgedamage, rad, forceintensity * force, deathtype, 0, attacker);
+               else
+                       Damage_DamageInfo(inflictororigin, coredamage, edgedamage, -rad, (-forceintensity) * force, deathtype, 0, attacker);
+       }
 
        stat_damagedone = 0;