]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Compact some electro code
authorterencehill <piuntn@gmail.com>
Mon, 5 Apr 2021 12:30:57 +0000 (14:30 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 5 Apr 2021 12:30:57 +0000 (14:30 +0200)
qcsrc/common/effects/qc/rubble.qc
qcsrc/common/weapons/weapon/electro.qc

index f0a29bd5ba5edf38cb8874aab28a5109cb116f25..78bacbc10325006461fc8a21174b58c8749ddd82 100644 (file)
@@ -15,7 +15,7 @@ void LimitedChildrenRubble(IntrusiveList list, string cname, int limit, void(ent
                // compare to all other matching entities
                IL_EACH(list, it.classname == cname,
                {
-                       if(!parent ||parent == it.owner){
+                       if(!parent || parent == it.owner){
                                ++c;
                                if(!oldest || oldesttime > it.creationtime)
                                {
index 274cf4ff21dc40af937fe149e45fdc2826e1f455..1505503b31bb6b7f58584e382dade98479bbd05a 100644 (file)
@@ -35,16 +35,10 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
                        setthink(e, W_Electro_ExplodeCombo);
 
                        // delay combo chains, looks cooler
-                       e.nextthink =
-                               (
-                                       time
-                                       +
-                                       (WEP_CVAR(electro, combo_speed) ?
-                                               (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
-                                               :
-                                               0
-                                       )
-                               );
+                       float delay = 0;
+                       if (WEP_CVAR(electro, combo_speed))
+                               delay = vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed);
+                       e.nextthink = time + delay;
                }
                e = e.chain;
        }
@@ -181,17 +175,10 @@ void W_Electro_Bolt_Think(entity this)
                                        // (the bolt and orb should explode together because they interacted together)
                                        // while keeping the chaining delay.
                                        setthink(e, W_Electro_ExplodeCombo);
-                                       e.nextthink =
-                                       (
-                                               time
-                                               +
-                                               (WEP_CVAR_PRI(electro, midaircombo_speed) ?
-                                                       (vlen(e.WarpZone_findradius_dist) / WEP_CVAR_PRI(electro, midaircombo_speed))
-                                                       :
-                                                       0
-                                               )
-                                       );
-
+                                       float delay = 0;
+                                       if (WEP_CVAR_PRI(electro, midaircombo_speed))
+                                               delay = vlen(e.WarpZone_findradius_dist) / WEP_CVAR_PRI(electro, midaircombo_speed);
+                                       e.nextthink = time + delay;
 
                                        ++found;
                                }
@@ -346,17 +333,11 @@ void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float
                        this.realowner = inflictor.realowner;
                        this.classname = "electro_orb_chain";
                        setthink(this, W_Electro_ExplodeCombo);
-                       this.nextthink = time +
-                               (
-                                       // bound the length, inflictor may be in a galaxy far far away (warpzones)
-                                       min(
-                                               WEP_CVAR(electro, combo_radius),
-                                               vlen(this.origin - inflictor.origin)
-                                       )
-                                       /
-                                       // delay combo chains, looks cooler
-                                       WEP_CVAR(electro, combo_speed)
-                               );
+                       // delay combo chains, looks cooler
+                       // bound the length, inflictor may be in a galaxy far far away (warpzones)
+                       float len = min(WEP_CVAR(electro, combo_radius), vlen(this.origin - inflictor.origin));
+                       float delay = len / WEP_CVAR(electro, combo_speed);
+                       this.nextthink = time + delay;
                }
                else
                {