]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/electro.qc
Merge branch 'master' into Mario/electro_combo_over_time
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / electro.qc
index 10005f22e541eb41f8e472ad9ca307fe1e0cecc7..e650138289aea9b3eee2364cf897d45db62fc37e 100644 (file)
@@ -49,12 +49,51 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
        }
 }
 
+void W_Electro_ExplodeComboThink(entity this)
+{
+       float dt = time - this.teleport_time + this.dmg_interval;
+       float dmg_remaining_next = (bound(0, 1 - dt / this.dmg_duration, 1) ** this.dmg_power);
+
+       float f = this.dmg_last - dmg_remaining_next;
+       this.dmg_last = dmg_remaining_next;
+
+       RadiusDamage(this, this.realowner, this.dmg * f, this.dmg_edge * f, this.dmg_radius, NULL, NULL, this.dmg_force * f, this.projectiledeathtype, this.weaponentity_fld, NULL);
+       this.projectiledeathtype |= HITTYPE_BOUNCE; // ensure it doesn't spam its effect
+
+       if(dt < this.dmg_duration)
+               this.nextthink = time + this.dmg_interval; // soon
+       else
+               delete(this);
+}
+
 void W_Electro_ExplodeCombo(entity this)
 {
        W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner);
 
        this.event_damage = func_null;
 
+       if(WEP_CVAR(electro, combo_duration))
+       {
+               this.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SPLASH;
+               this.event_damage = func_null;
+               settouch(this, func_null);
+               this.effects |= EF_NODRAW;
+
+               setthink(this, W_Electro_ExplodeComboThink);
+               this.nextthink = time;
+               this.dmg = WEP_CVAR(electro, combo_damage);
+               this.dmg_edge = WEP_CVAR(electro, combo_edgedamage);
+               this.dmg_radius = WEP_CVAR(electro, combo_radius);
+               this.dmg_force = WEP_CVAR(electro, combo_force);
+               this.dmg_power = WEP_CVAR(electro, combo_power);
+               this.dmg_duration = WEP_CVAR(electro, combo_duration);
+               this.dmg_interval = WEP_CVAR(electro, combo_damage_interval);
+               this.teleport_time = time;
+               this.dmg_last = 1;
+               set_movetype(this, MOVETYPE_NONE);
+               return;
+       }
+
        RadiusDamage(
                this,
                this.realowner,
@@ -570,7 +609,17 @@ METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
     }
     else
     {
-        if(w_deathtype & HITTYPE_BOUNCE)
+       if(w_deathtype & HITTYPE_SPLASH)
+       {
+               org2 = w_org + w_backoff * 2;
+               if(particleeffectnum(EFFECT_ELECTRO_COMBO_LONG) >= 0)
+               pointparticles(EFFECT_ELECTRO_COMBO_LONG, org2, '0 0 0', 1);
+               else
+               pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1);
+            if(!w_issilent)
+                sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
+       }
+        else if(w_deathtype & HITTYPE_BOUNCE)
         {
             // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
             pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);