]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Refactor HITTYPE_TERTIARY into HITTYPE_SPAM and use it for hook and electro combos
authorMario <mario.mario@y7mail.com>
Thu, 12 Sep 2024 08:53:25 +0000 (18:53 +1000)
committerMario <mario.mario@y7mail.com>
Thu, 12 Sep 2024 08:53:25 +0000 (18:53 +1000)
qcsrc/common/deathtypes/all.qh
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/electro.qh
qcsrc/common/weapons/weapon/hook.qc
qcsrc/server/damage.qc

index 48c94ad8467937a5aeba4174ff1cbed987eabb76..f83a2a5c81b45ce11d126d92792f8bd76eaf42a3 100644 (file)
@@ -23,13 +23,12 @@ 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 HITTYPE_TERTIARY = BITS(1) << 13;
-const int DEATH_HITTYPEMASK = HITTYPE_SECONDARY | HITTYPE_SPLASH | HITTYPE_BOUNCE | HITTYPE_ARMORPIERCE | HITTYPE_SOUND | HITTYPE_TERTIARY;
+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(14);
 
index 38c9c85f8ffca3818b9faebba1b62df515b3ae01..ee86922580ca87a8e4e9a8798a904f8e57eb6bf0 100644 (file)
@@ -53,7 +53,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
 
 void W_Electro_ExplodeComboThink(entity this)
 {
-       if(time - this.teleport_time > this.dmg_duration)
+       if(time >= this.ltime)
        {
                delete(this);
                return;
@@ -61,11 +61,11 @@ void W_Electro_ExplodeComboThink(entity this)
 
        this.nextthink = time;
 
-       float damage = this.dmg * PHYS_INPUT_TIMELENGTH;
-       float edgedamage = this.dmg_edge * PHYS_INPUT_TIMELENGTH;
+       float damage = WEP_CVAR(WEP_ELECTRO, combo_damage) * PHYS_INPUT_TIMELENGTH;
+       float edgedamage = WEP_CVAR(WEP_ELECTRO, combo_edgedamage) * PHYS_INPUT_TIMELENGTH;
 
-       RadiusDamage(this, this.realowner, damage, edgedamage, this.dmg_radius, NULL, NULL, 0, this.projectiledeathtype, this.weaponentity_fld, NULL);
-       this.projectiledeathtype |= HITTYPE_TERTIARY; // ensure it doesn't spam its effect
+       RadiusDamage(this, this.realowner, damage, edgedamage, WEP_CVAR(WEP_ELECTRO, combo_radius), NULL, NULL, 0, this.projectiledeathtype, this.weaponentity_fld, NULL);
+       this.projectiledeathtype |= HITTYPE_SPAM; // ensure it doesn't spam its effect
 }
 
 void W_Electro_ExplodeCombo(entity this)
@@ -85,11 +85,7 @@ void W_Electro_ExplodeCombo(entity this)
 
                setthink(this, W_Electro_ExplodeComboThink);
                this.nextthink = time;
-               this.dmg = WEP_CVAR(WEP_ELECTRO, combo_damage);
-               this.dmg_edge = WEP_CVAR(WEP_ELECTRO, combo_edgedamage);
-               this.dmg_radius = WEP_CVAR(WEP_ELECTRO, combo_radius);
-               this.dmg_duration = WEP_CVAR(WEP_ELECTRO, combo_duration);
-               this.teleport_time = time;
+               this.ltime = time + WEP_CVAR(WEP_ELECTRO, combo_duration);
                set_movetype(this, MOVETYPE_NONE);
 
                // fire the first damage tick immediately
index c09dcf099ced4653097886023b796db644e3ea8e..e7df4e039036a69e61f19c529d52a2fb44c5ff07 100644 (file)
@@ -79,11 +79,6 @@ REGISTER_WEAPON(ELECTRO, NEW(Electro));
 SPAWNFUNC_WEAPON(weapon_electro, WEP_ELECTRO)
 
 #ifdef SVQC
-.float dmg;
-.float dmg_edge;
-.float dmg_radius;
-.float dmg_duration;
-
 IntrusiveList LimitedElectroBallRubbleList;
 .float electro_count;
 .float electro_secondarytime;
index e383760d3ac223a051d2d492533e1430eeba2918..22338ef47956851365c66f47cba3b7fb3e3d2597 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 ba639d9ec443575078a8fd304fb531699b2828f4..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) && deathtype != (WEP_ELECTRO.m_id | HITTYPE_BOUNCE | HITTYPE_TERTIARY)) // only send damage over time bombs 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;