From d58833b05f619cb8f598881a1921a1d3ac56aa42 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sun, 8 Dec 2013 23:30:11 -0500 Subject: [PATCH] Fix unnecessary processing with combo triggering, add midaircombo_explode --- qcsrc/common/weapons/w_electro.qc | 89 +++++++++++++++++++++++------ qcsrc/common/weapons/w_shockwave.qc | 3 +- 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/weapons/w_electro.qc b/qcsrc/common/weapons/w_electro.qc index 4748ace2c..fecfa3de0 100644 --- a/qcsrc/common/weapons/w_electro.qc +++ b/qcsrc/common/weapons/w_electro.qc @@ -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; } } diff --git a/qcsrc/common/weapons/w_shockwave.qc b/qcsrc/common/weapons/w_shockwave.qc index 9e0d0b6db..1be57ba34 100644 --- a/qcsrc/common/weapons/w_shockwave.qc +++ b/qcsrc/common/weapons/w_shockwave.qc @@ -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) -- 2.39.2