From 7753548f341acceb832dfd0883f38fb7d8064e66 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sat, 21 Jul 2012 21:57:25 -0400 Subject: [PATCH] More work on spread handling --- balance25.cfg | 2 ++ balanceFruitieX.cfg | 2 ++ balanceXPM.cfg | 2 ++ balanceXonotic.cfg | 2 ++ qcsrc/server/autocvars.qh | 4 +++- qcsrc/server/w_laser.qc | 23 +++++++++++++---------- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/balance25.cfg b/balance25.cfg index c76f760eb..978a9875b 100644 --- a/balance25.cfg +++ b/balance25.cfg @@ -235,6 +235,8 @@ set g_balance_laser_primary_force 400 set g_balance_laser_primary_radius 70 set g_balance_laser_primary_speed 9000 set g_balance_laser_primary_spread 0 +set g_balance_laser_primary_spread_max 100 +set g_balance_laser_primary_spread_min 20 set g_balance_laser_primary_refire 0.7 set g_balance_laser_primary_animtime 0.3 set g_balance_laser_primary_lifetime 30 diff --git a/balanceFruitieX.cfg b/balanceFruitieX.cfg index 2e826476d..0ede467d9 100644 --- a/balanceFruitieX.cfg +++ b/balanceFruitieX.cfg @@ -235,6 +235,8 @@ set g_balance_laser_primary_force 150 // this looks insanely low, but actually i set g_balance_laser_primary_radius 60 set g_balance_laser_primary_speed 5000 set g_balance_laser_primary_spread 0 +set g_balance_laser_primary_spread_max 100 +set g_balance_laser_primary_spread_min 20 set g_balance_laser_primary_refire 0.6 set g_balance_laser_primary_animtime 0.4 set g_balance_laser_primary_lifetime 5 diff --git a/balanceXPM.cfg b/balanceXPM.cfg index 609d8fb5b..331051b97 100644 --- a/balanceXPM.cfg +++ b/balanceXPM.cfg @@ -235,6 +235,8 @@ set g_balance_laser_primary_force 300 set g_balance_laser_primary_radius 70 set g_balance_laser_primary_speed 6000 set g_balance_laser_primary_spread 0 +set g_balance_laser_primary_spread_max 100 +set g_balance_laser_primary_spread_min 20 set g_balance_laser_primary_refire 0.7 set g_balance_laser_primary_animtime 0.2 set g_balance_laser_primary_lifetime 5 diff --git a/balanceXonotic.cfg b/balanceXonotic.cfg index c0bb7ac16..cbc823277 100644 --- a/balanceXonotic.cfg +++ b/balanceXonotic.cfg @@ -235,6 +235,8 @@ set g_balance_laser_primary_force 300 set g_balance_laser_primary_radius 4000 set g_balance_laser_primary_speed 6000 set g_balance_laser_primary_spread 0.12 +set g_balance_laser_primary_spread_max 100 +set g_balance_laser_primary_spread_min 20 set g_balance_laser_primary_refire 0.7 set g_balance_laser_primary_animtime 0.2 set g_balance_laser_primary_lifetime 5 diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index edaae2f1a..53d72131a 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -442,7 +442,9 @@ float autocvar_g_balance_laser_primary_radius; float autocvar_g_balance_laser_primary_refire; float autocvar_g_balance_laser_primary_shotangle; float autocvar_g_balance_laser_primary_speed; -var float autocvar_g_balance_laser_primary_spread = 0.15; +float autocvar_g_balance_laser_primary_spread; +float autocvar_g_balance_laser_primary_spread_max; +float autocvar_g_balance_laser_primary_spread_min; float autocvar_g_balance_laser_secondary; float autocvar_g_balance_laser_secondary_animtime; float autocvar_g_balance_laser_secondary_damage; diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index ed8f0d4ec..95d9adf7f 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -43,21 +43,24 @@ void W_Laser_Think() CSQCProjectile(self, TRUE, PROJECTILE_LASER, TRUE); } -// TODO: change this into a macro to run faster (less function calls is better) -float W_Laser_Shockwave_CheckSpreadAngle(vector targetorg, vector nearest_on_line, vector sw_shotorg, vector sw_shotdir) + +float W_Laser_Shockwave_CheckSpreadAngle(vector targetorg, vector nearest_on_line, float distance_on_line, vector sw_shotorg) { vector angle_to_head = normalize(targetorg - sw_shotorg); - vector angle_to_attack = sw_shotdir; + + float spreadlimit = (autocvar_g_balance_laser_primary_spread_min * (1 - distance_on_line) + autocvar_g_balance_laser_primary_spread_max * distance_on_line); te_lightning2(world, targetorg, nearest_on_line); + + - if(vlen(targetorg - nearest_on_line) <= autocvar_g_balance_laser_primary_spread) + if(vlen(targetorg - nearest_on_line) <= spreadlimit) return TRUE; else return FALSE; } -float W_Laser_Shockwave_IsVisible(entity head, vector nearest_on_line, vector sw_shotorg, vector sw_shotdir) +float W_Laser_Shockwave_IsVisible(entity head, vector nearest_on_line, float distance_on_line, vector sw_shotorg) { vector nearest_to_attacker = head.WarpZone_findradius_nearest; vector center = (head.origin + (head.mins + head.maxs) * 0.5); @@ -65,14 +68,14 @@ float W_Laser_Shockwave_IsVisible(entity head, vector nearest_on_line, vector sw float i; // STEP ONE: Check if the nearest point is clear - if(W_Laser_Shockwave_CheckSpreadAngle(nearest_to_attacker, nearest_on_line, sw_shotorg, sw_shotdir)) + if(W_Laser_Shockwave_CheckSpreadAngle(nearest_to_attacker, nearest_on_line, distance_on_line, sw_shotorg)) { WarpZone_TraceLine(sw_shotorg, nearest_to_attacker, MOVE_WORLDONLY, self); if(trace_fraction == 1) { return TRUE; } // yes, the nearest point is clear and we can allow the damage } // STEP TWO: Check if shotorg to center point is clear - if(W_Laser_Shockwave_CheckSpreadAngle(center, nearest_on_line, sw_shotorg, sw_shotdir)) + if(W_Laser_Shockwave_CheckSpreadAngle(center, nearest_on_line, distance_on_line, sw_shotorg)) { WarpZone_TraceLine(sw_shotorg, center, MOVE_WORLDONLY, self); if(trace_fraction == 1) { return TRUE; } // yes, the center point is clear and we can allow the damage @@ -82,7 +85,7 @@ float W_Laser_Shockwave_IsVisible(entity head, vector nearest_on_line, vector sw for(i=1; i<=8; ++i) { corner = get_corner_position(head, i); - if(W_Laser_Shockwave_CheckSpreadAngle(corner, nearest_on_line, sw_shotorg, sw_shotdir)) + if(W_Laser_Shockwave_CheckSpreadAngle(corner, nearest_on_line, distance_on_line, sw_shotorg)) { WarpZone_TraceLine(sw_shotorg, corner, MOVE_WORLDONLY, self); if(trace_fraction == 1) { return TRUE; } // yes, this corner is clear and we can allow the damage @@ -158,10 +161,10 @@ void W_Laser_Shockwave (void) if(vlen(w_shotorg - nearest_to_attacker) <= autocvar_g_balance_laser_primary_radius) { - if(W_Laser_Shockwave_IsVisible(head, nearest_on_line, w_shotorg, w_shotdir)) + if(W_Laser_Shockwave_IsVisible(head, nearest_on_line, a, w_shotorg)) { if(autocvar_g_balance_laser_primary_spread) - final_damage = (final_spread / autocvar_g_balance_laser_primary_spread); + final_damage = (vlen(center - nearest_on_line) / autocvar_g_balance_laser_primary_spread_max); // todo make this match with the spread check else final_damage = 1; -- 2.39.2