From 3199314a3f040a432a15cd9fa0afc4e9248c0881 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 5 Apr 2021 14:30:57 +0200 Subject: [PATCH] Compact some electro code --- qcsrc/common/effects/qc/rubble.qc | 2 +- qcsrc/common/weapons/weapon/electro.qc | 45 ++++++++------------------ 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/qcsrc/common/effects/qc/rubble.qc b/qcsrc/common/effects/qc/rubble.qc index f0a29bd5b..78bacbc10 100644 --- a/qcsrc/common/effects/qc/rubble.qc +++ b/qcsrc/common/effects/qc/rubble.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 274cf4ff2..1505503b3 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -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 { -- 2.39.2