]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix unnecessary processing with combo triggering, add midaircombo_explode
authorSamual Lenks <samual@xonotic.org>
Mon, 9 Dec 2013 04:30:11 +0000 (23:30 -0500)
committerSamual Lenks <samual@xonotic.org>
Mon, 9 Dec 2013 04:30:11 +0000 (23:30 -0500)
qcsrc/common/weapons/w_electro.qc
qcsrc/common/weapons/w_shockwave.qc

index 4748ace2c9433d643b64831f9d0e99d154ef8c6f..fecfa3de05548b98129d90cc85ee1a9b0364a069 100644 (file)
@@ -23,6 +23,7 @@ REGISTER_WEAPON(
        w_cvar(WEP_ELECTRO, electro, MO_BOTH, spread) \
        w_cvar(WEP_ELECTRO, electro, MO_BOTH, lifetime) \
        w_cvar(WEP_ELECTRO, electro, MO_PRI,  comboradius) \
+       w_cvar(WEP_ELECTRO, electro, MO_PRI,  midaircombo_explode) \
        w_cvar(WEP_ELECTRO, electro, MO_PRI,  midaircombo_interval) \
        w_cvar(WEP_ELECTRO, electro, MO_PRI,  midaircombo_radius) \
        w_cvar(WEP_ELECTRO, electro, MO_SEC,  bouncefactor) \
@@ -65,21 +66,41 @@ void W_Plasma_TriggerCombo(vector org, float rad, entity own)
        {
                if(e.classname == "plasma")
                {
-                       // change owner to whoever caused the combo explosion
-                       WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
-
-                       if(
-                               (trace_fraction == 1)
-                               ||
-                               (WEP_CVAR(electro, combo_comboradius_thruwall) >= vlen(e.WarpZone_findradius_dist))
-                       )
+                       // do we allow thruwall triggering?
+                       if(WEP_CVAR(electro, combo_comboradius_thruwall))
                        {
-                               e.realowner = own;
-                               e.takedamage = DAMAGE_NO;
-                               e.classname = "plasma_chain";
-                               e.think = W_Plasma_Explode_Combo;
-                               e.nextthink = time + vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed); // delay combo chains, looks cooler
+                               // if distance is greater than thruwall distance, check to make sure it's not through a wall
+                               if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
+                               {
+                                       WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
+                                       if(trace_fraction != 1)
+                                       {
+                                               // trigger is through a wall and outside of thruwall range, abort
+                                               e = e.chain;
+                                               continue;
+                                       }
+                               }
                        }
+                       
+                       // change owner to whoever caused the combo explosion
+                       e.realowner = own;
+                       e.takedamage = DAMAGE_NO;
+                       e.classname = "plasma_chain";
+                       
+                       // now set the next one to trigger as well
+                       e.think = W_Plasma_Explode_Combo;
+                       
+                       // delay combo chains, looks cooler
+                       e.nextthink =
+                               (
+                                       time
+                                       +
+                                       (WEP_CVAR(electro, combo_speed) ?
+                                               (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
+                                               :
+                                               0
+                                       )
+                               );
                }
                e = e.chain;
        }
@@ -151,7 +172,7 @@ void W_Plasma_Explode_Combo(void)
                world
        );
 
-       remove (self);
+       remove(self);
 }
 
 void W_Plasma_Touch(void)
@@ -225,8 +246,44 @@ void W_Plasma_Think()
 
        if(WEP_CVAR_PRI(electro, midaircombo_radius))
        {
-               self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime);
-               W_Plasma_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), self.realowner);
+               float found = 0;
+               entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
+
+               // loop through nearby orbs and trigger them
+               while(e)
+               {
+                       if(e.classname == "plasma")
+                       {
+                               // change owner to whoever caused the combo explosion
+                               e.realowner = self.realowner;
+                               e.takedamage = DAMAGE_NO;
+                               e.classname = "plasma_chain";
+
+                               // now set the next one to trigger as well
+                               e.think = W_Plasma_Explode_Combo;
+                               
+                               // delay combo chains, looks cooler
+                               e.nextthink =
+                                       (
+                                               time
+                                               +
+                                               (WEP_CVAR(electro, combo_speed) ?
+                                                       (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
+                                                       :
+                                                       0
+                                               )
+                                       );
+
+                               ++found;
+                       }
+                       e = e.chain;
+               }
+
+               // if we triggered an orb, should we explode? if not, lets try again next time
+               if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
+                       { self.use(); }
+               else
+                       { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
        }
        else { self.nextthink = self.ltime; }
 }
index 9e0d0b6db4d641140ce899b141871380aeabc546..1be57ba3488bba71340020f3f2254bc88ed15eff 100644 (file)
@@ -421,8 +421,7 @@ void W_Shockwave_Attack()
                                                )
                                        );
 
-                               // calculate damage from multiplier
-                               // 1 = "highest" damage, 0 = "lowest" edgedamage
+                               // calculate damage from multiplier: 1 = "highest" damage, 0 = "lowest" edgedamage
                                final_damage =
                                        (
                                                (WEP_CVAR(shockwave, blast_jump_damage) * multiplier)