From af020337abf77f8b5d6d3c34833baed21a197e0a Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sun, 22 Jul 2012 01:46:12 -0400 Subject: [PATCH] Finishing up the spread work by adding new multiplier system for accuracy and distance factoring. --- balance25.cfg | 3 +++ balanceFruitieX.cfg | 3 +++ balanceXPM.cfg | 3 +++ balanceXonotic.cfg | 5 ++++- qcsrc/client/particles.qc | 2 +- qcsrc/server/autocvars.qh | 3 +++ qcsrc/server/w_laser.qc | 34 ++++++++++++++++++---------------- 7 files changed, 35 insertions(+), 18 deletions(-) diff --git a/balance25.cfg b/balance25.cfg index 978a9875b..7bfc14376 100644 --- a/balance25.cfg +++ b/balance25.cfg @@ -240,6 +240,9 @@ 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 +set g_balance_laser_primary_multiplier_min 0.5 +set g_balance_laser_primary_multiplier_accuracy 0.5 +set g_balance_laser_primary_multiplier_distance 0.5 set g_balance_laser_primary_shotangle 0 set g_balance_laser_primary_delay 0.05 set g_balance_laser_primary_gauntlet 0 diff --git a/balanceFruitieX.cfg b/balanceFruitieX.cfg index 0ede467d9..edfccec3c 100644 --- a/balanceFruitieX.cfg +++ b/balanceFruitieX.cfg @@ -240,6 +240,9 @@ 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 +set g_balance_laser_primary_multiplier_min 0.5 +set g_balance_laser_primary_multiplier_accuracy 0.5 +set g_balance_laser_primary_multiplier_distance 0.5 set g_balance_laser_primary_shotangle 0 set g_balance_laser_primary_delay 0 set g_balance_laser_primary_gauntlet 0 diff --git a/balanceXPM.cfg b/balanceXPM.cfg index 331051b97..5b41c2075 100644 --- a/balanceXPM.cfg +++ b/balanceXPM.cfg @@ -240,6 +240,9 @@ 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 +set g_balance_laser_primary_multiplier_min 0.5 +set g_balance_laser_primary_multiplier_accuracy 0.5 +set g_balance_laser_primary_multiplier_distance 0.5 set g_balance_laser_primary_shotangle 0 set g_balance_laser_primary_delay 0 set g_balance_laser_primary_gauntlet 0 diff --git a/balanceXonotic.cfg b/balanceXonotic.cfg index cbc823277..82800abee 100644 --- a/balanceXonotic.cfg +++ b/balanceXonotic.cfg @@ -232,7 +232,7 @@ set g_balance_laser_oldprimary 0 set g_balance_laser_primary_damage 25 set g_balance_laser_primary_edgedamage 12.5 set g_balance_laser_primary_force 300 -set g_balance_laser_primary_radius 4000 +set g_balance_laser_primary_radius 1000 set g_balance_laser_primary_speed 6000 set g_balance_laser_primary_spread 0.12 set g_balance_laser_primary_spread_max 100 @@ -240,6 +240,9 @@ 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 +set g_balance_laser_primary_multiplier_min 0.5 +set g_balance_laser_primary_multiplier_accuracy 0.6 +set g_balance_laser_primary_multiplier_distance 0.4 set g_balance_laser_primary_shotangle 0 set g_balance_laser_primary_delay 0 set g_balance_laser_primary_gauntlet 0 diff --git a/qcsrc/client/particles.qc b/qcsrc/client/particles.qc index d502bcd8e..e4276df83 100644 --- a/qcsrc/client/particles.qc +++ b/qcsrc/client/particles.qc @@ -325,7 +325,7 @@ void Net_ReadShockwaveParticle() deviation_y = v_forward_x; deviation_z = v_forward_y; deviation = deviation * spread; - print("v_forward = ", vtos(deviation), ".\n"); + //print("v_forward = ", vtos(deviation), ".\n"); deviation = ((shotdir + (right * deviation_y) + (up * deviation_z)) * 1000); //deviation = W_CalculateSpread(shotdir, spread, 1, cvar("g_projectiles_spread_style")); diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 53d72131a..6a9e05dbd 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -438,6 +438,9 @@ float autocvar_g_balance_laser_primary_force_velocitybias; float autocvar_g_balance_laser_primary_force_zscale; var float autocvar_g_balance_laser_primary_jumpradius = 150; float autocvar_g_balance_laser_primary_lifetime; +var float autocvar_g_balance_laser_primary_multiplier_min = 0.5; +var float autocvar_g_balance_laser_primary_multiplier_accuracy = 0.5; +var float autocvar_g_balance_laser_primary_multiplier_distance = 0.5; float autocvar_g_balance_laser_primary_radius; float autocvar_g_balance_laser_primary_refire; float autocvar_g_balance_laser_primary_shotangle; diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index 287f56df0..78a824d2d 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -50,14 +50,14 @@ float W_Laser_Shockwave_CheckSpread(vector targetorg, vector nearest_on_line, ve float distance_of_attack = vlen(sw_shotorg - attack_hitpos); float distance_from_line = vlen(targetorg - nearest_on_line); - spreadlimit = (vlen(sw_shotorg - nearest_on_line) / (distance_of_attack ? distance_of_attack : 1)); + spreadlimit = (distance_of_attack ? min(1, (vlen(sw_shotorg - nearest_on_line) / distance_of_attack)) : 1); spreadlimit = (autocvar_g_balance_laser_primary_spread_min * (1 - spreadlimit) + autocvar_g_balance_laser_primary_spread_max * spreadlimit); if(spreadlimit && (distance_from_line <= spreadlimit)) { - te_lightning2(world, targetorg, nearest_on_line); - te_lightning2(world, targetorg, sw_shotorg); - print("just in case: ", ftos(distance_from_line), ", ", ftos(spreadlimit), ".\n"); + //te_lightning2(world, targetorg, nearest_on_line); + //te_lightning2(world, targetorg, sw_shotorg); + //print("just in case: ", ftos(distance_from_line), ", ", ftos(spreadlimit), ".\n"); return bound(0, (distance_from_line / spreadlimit), 1); } @@ -105,7 +105,7 @@ void W_Laser_Shockwave (void) // declarations float final_damage, final_spread; entity head, next, aim_ent; - vector nearest_to_attacker, nearest_on_line, attack_hitpos, final_force, center; + vector attack_hitpos, final_force, center; // set up the shot direction vector wanted_shot_direction = (v_forward * cos(autocvar_g_balance_laser_primary_shotangle * DEG2RAD) + v_up * sin(autocvar_g_balance_laser_primary_shotangle * DEG2RAD)); @@ -154,31 +154,33 @@ void W_Laser_Shockwave (void) float h = vlen(center - self.origin); float ang = acos(dotproduct(normalize(center - self.origin), w_shotdir)); float a = h * cos(ang); - - nearest_on_line = (w_shotorg + a * w_shotdir); // ang = angle between shotdir and h // h = hypotenuse, which is the distance between attacker to head // a = adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin - nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line); + vector nearest_on_line = (w_shotorg + a * w_shotdir); + vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line); + float distance_to_target = vlen(w_shotorg - nearest_to_attacker); + float distance_of_attack = vlen(w_shotorg - attack_hitpos); - if(vlen(w_shotorg - nearest_to_attacker) <= autocvar_g_balance_laser_primary_radius) + if(distance_to_target <= autocvar_g_balance_laser_primary_radius) { if(W_Laser_Shockwave_IsVisible(head, nearest_on_line, w_shotorg, attack_hitpos)) { - final_damage = W_Laser_Shockwave_CheckSpread(nearest_to_attacker, nearest_on_line, w_shotorg, attack_hitpos); + float multiplier_from_accuracy = (1 - W_Laser_Shockwave_CheckSpread(nearest_to_attacker, nearest_on_line, w_shotorg, attack_hitpos)); + float multiplier_from_distance = (1 - (distance_of_attack ? min(1, (distance_to_target / autocvar_g_balance_laser_primary_radius)) : 1)); + + float multiplier = max(autocvar_g_balance_laser_primary_multiplier_min, ((multiplier_from_accuracy * autocvar_g_balance_laser_primary_multiplier_accuracy) + (multiplier_from_distance * autocvar_g_balance_laser_primary_multiplier_distance))); + print("multiplier = ", ftos(multiplier), ", multiplier_from_accuracy = ", ftos(multiplier_from_accuracy), ", multiplier_from_distance = ", ftos(multiplier_from_distance), "\n"); - //final_force = (normalize(nearest - w_shotorg) * autocvar_g_balance_laser_primary_force); // we dont want to use nearest here, because that would result in some rather weird force dirs for the attacker... - print(strcat("head.origin: ", vtos(head.origin), ", (w_shotorg + a * w_shotdir): ", vtos(w_shotorg + a * w_shotdir), ".\n")); - print("a = ", ftos(a), " h = ", ftos(h), " ang = ", ftos(ang), "\n"); - final_force = (normalize(center - (w_shotorg + a * w_shotdir)) * autocvar_g_balance_laser_primary_force); - final_damage = (autocvar_g_balance_laser_primary_damage * final_damage + autocvar_g_balance_laser_primary_edgedamage * (1 - final_damage)); + //print(strcat("head.origin: ", vtos(head.origin), ", nearest_on_line: ", vtos(nearest_on_line), ".\n")); + final_force = ((normalize(center - nearest_on_line) * autocvar_g_balance_laser_primary_force) * multiplier); + final_damage = (autocvar_g_balance_laser_primary_damage * multiplier + autocvar_g_balance_laser_primary_edgedamage * (1 - multiplier)); print(strcat("damage: ", ftos(final_damage), ", force: ", vtos(final_force), ".\n")); Damage(head, self, self, final_damage, WEP_LASER, head.origin, final_force); - //te_lightning2(world, nearest, w_shotorg); //pointparticles(particleeffectnum("rocket_guide"), w_shotorg, w_shotdir * 1000, 1); //SendCSQCShockwaveParticle(autocvar_g_balance_laser_primary_spread, trace_endpos); -- 2.39.2