different probability distributions for spread (quake-style, solid circle, gaussian)
authordiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Sat, 7 Nov 2009 21:54:51 +0000 (21:54 +0000)
committerdiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Sat, 7 Nov 2009 21:54:51 +0000 (21:54 +0000)
Currently, all is quake-style.
quake-style: http://rm.endoftheinternet.org/img/uploaded/6ad7218846a2a279987cbf230f6bab9e.jpg
circle:      http://rm.endoftheinternet.org/img/uploaded/06ce7e1fa72bd651cd7a0fd0b23f689e.jpg
gaussian:    http://rm.endoftheinternet.org/img/uploaded/8203aa325bc0bbce07d6329e97f44a35.jpg
The cvar doesn't change the standard deviation!

git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8232 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

22 files changed:
data/balance.cfg
data/balance25.cfg
data/balanceHavoc.cfg
data/balanceNexrun.cfg
data/balanceSamual.cfg
data/qcsrc/common/mathlib.qc
data/qcsrc/common/util.qc
data/qcsrc/common/util.qh
data/qcsrc/server/cl_weaponsystem.qc
data/qcsrc/server/constants.qh
data/qcsrc/server/g_hook.qc
data/qcsrc/server/nexball.qc
data/qcsrc/server/w_common.qc
data/qcsrc/server/w_crylink.qc
data/qcsrc/server/w_electro.qc
data/qcsrc/server/w_fireball.qc
data/qcsrc/server/w_grenadelauncher.qc
data/qcsrc/server/w_hagar.qc
data/qcsrc/server/w_hlac.qc
data/qcsrc/server/w_laser.qc
data/qcsrc/server/w_porto.qc
data/qcsrc/server/w_rocketlauncher.qc

index ec32bb5..a3600eb 100644 (file)
@@ -3,7 +3,7 @@
 //
 // And... don't forget to edit the other balance*.cfg too.
 
-set cvar_check_balance 1904952fd0d915f79ab4e6f0622abdb6
+set cvar_check_balance 729b07b9caa8a86c08841a0f4275e97d
 
 // {{{ weapon replacement
 // NOTE: this only replaces weapons on the map
@@ -177,6 +177,13 @@ set g_projectiles_newton_style 0
 //  4: just add the player velocity length to the absolute velocity (tZork's sniper rockets)
 set g_projectiles_newton_style_2_minfactor 0.7
 set g_projectiles_newton_style_2_maxfactor 5
+set g_projectiles_spread_style 0
+// possible values:
+//  0: forward + solid sphere (like Quake) - varies velocity
+//  1: forward + flattened solid sphere
+//  2: forward + solid circle
+//  3: forward + normal distribution 3D - varies velocity
+//  4: forward + normal distribution on a plane
 set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1400
 set g_balance_falldamage_factor 0.15
@@ -220,6 +227,7 @@ set g_balance_laser_primary_edgedamage 10
 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_refire 0.7
 set g_balance_laser_primary_animtime 0.3
 set g_balance_laser_primary_lifetime 30
@@ -231,6 +239,7 @@ set g_balance_laser_secondary_edgedamage 10
 set g_balance_laser_secondary_force 400
 set g_balance_laser_secondary_radius 70
 set g_balance_laser_secondary_speed 9000
+set g_balance_laser_secondary_spread 0
 set g_balance_laser_secondary_refire 0.7
 set g_balance_laser_secondary_animtime 0.3
 set g_balance_laser_secondary_lifetime 30
@@ -278,6 +287,7 @@ set g_balance_grenadelauncher_primary_force 400
 set g_balance_grenadelauncher_primary_radius 140
 set g_balance_grenadelauncher_primary_speed 2000
 set g_balance_grenadelauncher_primary_speed_up 200
+set g_balance_grenadelauncher_primary_spread 0
 set g_balance_grenadelauncher_primary_lifetime 30
 set g_balance_grenadelauncher_primary_refire 0.8
 set g_balance_grenadelauncher_primary_animtime 0.5
@@ -288,6 +298,7 @@ set g_balance_grenadelauncher_secondary_force 400
 set g_balance_grenadelauncher_secondary_radius 140
 set g_balance_grenadelauncher_secondary_speed 1400
 set g_balance_grenadelauncher_secondary_speed_up 200
+set g_balance_grenadelauncher_secondary_spread 0
 set g_balance_grenadelauncher_secondary_lifetime 0.3
 set g_balance_grenadelauncher_secondary_refire 1
 set g_balance_grenadelauncher_secondary_animtime 0.5
@@ -302,6 +313,7 @@ set g_balance_electro_primary_force 200
 set g_balance_electro_primary_radius 90
 set g_balance_electro_primary_comboradius 300
 set g_balance_electro_primary_speed 2000
+set g_balance_electro_primary_spread 0
 set g_balance_electro_primary_lifetime 30
 set g_balance_electro_primary_refire 1
 set g_balance_electro_primary_animtime 0.3
@@ -313,6 +325,7 @@ set g_balance_electro_secondary_force 200
 set g_balance_electro_secondary_radius 90
 set g_balance_electro_secondary_speed 900
 set g_balance_electro_secondary_speed_up 200
+set g_balance_electro_secondary_spread 0
 set g_balance_electro_secondary_lifetime 1
 set g_balance_electro_secondary_refire 0.3
 set g_balance_electro_secondary_refire2 0
@@ -543,6 +556,7 @@ set g_balance_fireball_primary_lifetime 4.5
 set g_balance_fireball_primary_refire 1.5
 set g_balance_fireball_primary_speed 700
 set g_balance_fireball_primary_speed_up 100
+set g_balance_fireball_primary_spread 0
 set g_balance_fireball_secondary_ammo 15
 set g_balance_fireball_secondary_animtime 0.15
 set g_balance_fireball_secondary_bfgdamage 100
@@ -562,4 +576,5 @@ set g_balance_fireball_secondary_radius 200
 set g_balance_fireball_secondary_refire 3
 set g_balance_fireball_secondary_refire2 6
 set g_balance_fireball_secondary_speed 650
+set g_balance_fireball_secondary_spread 0
 //   }}}
index 36f0757..4a24921 100644 (file)
@@ -3,7 +3,7 @@
 //
 // And... don't forget to edit the other balance*.cfg too.
 
-set cvar_check_balance 1904952fd0d915f79ab4e6f0622abdb6
+set cvar_check_balance 729b07b9caa8a86c08841a0f4275e97d
 
 // {{{ weapon replacement
 // NOTE: this only replaces weapons on the map
@@ -177,6 +177,13 @@ set g_projectiles_newton_style 2
 //  4: just add the player velocity length to the absolute velocity (tZork's sniper rockets)
 set g_projectiles_newton_style_2_minfactor 0.7
 set g_projectiles_newton_style_2_maxfactor 5
+set g_projectiles_spread_style 0
+// possible values:
+//  0: forward + solid sphere (like Quake) - varies velocity
+//  1: forward + flattened solid sphere
+//  2: forward + solid circle
+//  3: forward + normal distribution 3D - varies velocity
+//  4: forward + normal distribution on a plane
 set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1400
 set g_balance_falldamage_factor 0.15
@@ -220,6 +227,7 @@ set g_balance_laser_primary_edgedamage 10
 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_refire 0.7
 set g_balance_laser_primary_animtime 0.3
 set g_balance_laser_primary_lifetime 30
@@ -231,6 +239,7 @@ set g_balance_laser_secondary_edgedamage 10
 set g_balance_laser_secondary_force 400
 set g_balance_laser_secondary_radius 70
 set g_balance_laser_secondary_speed 9000
+set g_balance_laser_secondary_spread 0
 set g_balance_laser_secondary_refire 0.7
 set g_balance_laser_secondary_animtime 0.3
 set g_balance_laser_secondary_lifetime 30
@@ -278,6 +287,7 @@ set g_balance_grenadelauncher_primary_force 400
 set g_balance_grenadelauncher_primary_radius 140
 set g_balance_grenadelauncher_primary_speed 2000
 set g_balance_grenadelauncher_primary_speed_up 200
+set g_balance_grenadelauncher_primary_spread 0
 set g_balance_grenadelauncher_primary_lifetime 30
 set g_balance_grenadelauncher_primary_refire 0.8
 set g_balance_grenadelauncher_primary_animtime 0.3
@@ -288,6 +298,7 @@ set g_balance_grenadelauncher_secondary_force 400
 set g_balance_grenadelauncher_secondary_radius 140
 set g_balance_grenadelauncher_secondary_speed 1400
 set g_balance_grenadelauncher_secondary_speed_up 200
+set g_balance_grenadelauncher_secondary_spread 0
 set g_balance_grenadelauncher_secondary_lifetime 2.5
 set g_balance_grenadelauncher_secondary_refire 0.7
 set g_balance_grenadelauncher_secondary_animtime 0.3
@@ -302,6 +313,7 @@ set g_balance_electro_primary_force 200
 set g_balance_electro_primary_radius 150
 set g_balance_electro_primary_comboradius 0
 set g_balance_electro_primary_speed 2000
+set g_balance_electro_primary_spread 0
 set g_balance_electro_primary_lifetime 30
 set g_balance_electro_primary_refire 0.6
 set g_balance_electro_primary_animtime 0.3
@@ -313,6 +325,7 @@ set g_balance_electro_secondary_force 200
 set g_balance_electro_secondary_radius 150
 set g_balance_electro_secondary_speed 900
 set g_balance_electro_secondary_speed_up 200
+set g_balance_electro_secondary_spread 0
 set g_balance_electro_secondary_lifetime 5
 set g_balance_electro_secondary_refire 0.3
 set g_balance_electro_secondary_refire2 0
@@ -543,6 +556,7 @@ set g_balance_fireball_primary_lifetime 7
 set g_balance_fireball_primary_refire 1.5
 set g_balance_fireball_primary_speed 700
 set g_balance_fireball_primary_speed_up 100
+set g_balance_fireball_primary_spread 0
 set g_balance_fireball_secondary_ammo 15
 set g_balance_fireball_secondary_animtime 0.15
 set g_balance_fireball_secondary_bfgdamage 200
@@ -562,4 +576,5 @@ set g_balance_fireball_secondary_radius 200
 set g_balance_fireball_secondary_refire 2
 set g_balance_fireball_secondary_refire2 0
 set g_balance_fireball_secondary_speed 650
+set g_balance_fireball_secondary_spread 0
 //   }}}
index 8901d81..95b1ccc 100644 (file)
@@ -3,7 +3,7 @@
 //
 // And... don't forget to edit the other balance*.cfg too.
 
-set cvar_check_balance 1904952fd0d915f79ab4e6f0622abdb6
+set cvar_check_balance 729b07b9caa8a86c08841a0f4275e97d
 
 // {{{ weapon replacement
 // NOTE: this only replaces weapons on the map
@@ -177,6 +177,13 @@ set g_projectiles_newton_style 0
 //  4: just add the player velocity length to the absolute velocity (tZork's sniper rockets)
 set g_projectiles_newton_style_2_minfactor 0.7
 set g_projectiles_newton_style_2_maxfactor 5
+set g_projectiles_spread_style 0
+// possible values:
+//  0: forward + solid sphere (like Quake) - varies velocity
+//  1: forward + flattened solid sphere
+//  2: forward + solid circle
+//  3: forward + normal distribution 3D - varies velocity
+//  4: forward + normal distribution on a plane
 set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1400
 set g_balance_falldamage_factor 0.15
@@ -220,6 +227,7 @@ set g_balance_laser_primary_edgedamage 10
 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_refire 0.7
 set g_balance_laser_primary_animtime 0.3
 set g_balance_laser_primary_lifetime 30
@@ -231,6 +239,7 @@ set g_balance_laser_secondary_edgedamage 10
 set g_balance_laser_secondary_force 400
 set g_balance_laser_secondary_radius 70
 set g_balance_laser_secondary_speed 9000
+set g_balance_laser_secondary_spread 0
 set g_balance_laser_secondary_refire 0.7
 set g_balance_laser_secondary_animtime 0.3
 set g_balance_laser_secondary_lifetime 30
@@ -278,6 +287,7 @@ set g_balance_grenadelauncher_primary_force 400
 set g_balance_grenadelauncher_primary_radius 140
 set g_balance_grenadelauncher_primary_speed 2000
 set g_balance_grenadelauncher_primary_speed_up 200
+set g_balance_grenadelauncher_primary_spread 0
 set g_balance_grenadelauncher_primary_lifetime 30
 set g_balance_grenadelauncher_primary_refire 0.8
 set g_balance_grenadelauncher_primary_animtime 0.5
@@ -288,6 +298,7 @@ set g_balance_grenadelauncher_secondary_force 400
 set g_balance_grenadelauncher_secondary_radius 140
 set g_balance_grenadelauncher_secondary_speed 1400
 set g_balance_grenadelauncher_secondary_speed_up 200
+set g_balance_grenadelauncher_secondary_spread 0
 set g_balance_grenadelauncher_secondary_lifetime 0.3
 set g_balance_grenadelauncher_secondary_refire 1
 set g_balance_grenadelauncher_secondary_animtime 0.5
@@ -302,6 +313,7 @@ set g_balance_electro_primary_force 200
 set g_balance_electro_primary_radius 90
 set g_balance_electro_primary_comboradius 300
 set g_balance_electro_primary_speed 2000
+set g_balance_electro_primary_spread 0
 set g_balance_electro_primary_lifetime 30
 set g_balance_electro_primary_refire 1
 set g_balance_electro_primary_animtime 0.3
@@ -313,6 +325,7 @@ set g_balance_electro_secondary_force 200
 set g_balance_electro_secondary_radius 90
 set g_balance_electro_secondary_speed 900
 set g_balance_electro_secondary_speed_up 200
+set g_balance_electro_secondary_spread 0
 set g_balance_electro_secondary_lifetime 1
 set g_balance_electro_secondary_refire 0.3
 set g_balance_electro_secondary_refire2 0
@@ -543,6 +556,7 @@ set g_balance_fireball_primary_lifetime 4.5
 set g_balance_fireball_primary_refire 1.5
 set g_balance_fireball_primary_speed 700
 set g_balance_fireball_primary_speed_up 100
+set g_balance_fireball_primary_spread 0
 set g_balance_fireball_secondary_ammo 15
 set g_balance_fireball_secondary_animtime 0.15
 set g_balance_fireball_secondary_bfgdamage 100
@@ -562,4 +576,5 @@ set g_balance_fireball_secondary_radius 200
 set g_balance_fireball_secondary_refire 3
 set g_balance_fireball_secondary_refire2 6
 set g_balance_fireball_secondary_speed 650
+set g_balance_fireball_secondary_spread 0
 //   }}}
index 766aec1..ecbf59e 100644 (file)
@@ -3,7 +3,7 @@
 //
 // And... don't forget to edit the other balance*.cfg too.
 
-set cvar_check_balance 1904952fd0d915f79ab4e6f0622abdb6
+set cvar_check_balance 729b07b9caa8a86c08841a0f4275e97d
 
 // {{{ weapon replacement
 // NOTE: this only replaces weapons on the map
@@ -178,6 +178,13 @@ set g_projectiles_newton_style 0
 //  4: just add the player velocity length to the absolute velocity (tZork's sniper rockets)
 set g_projectiles_newton_style_2_minfactor 0.7
 set g_projectiles_newton_style_2_maxfactor 5
+set g_projectiles_spread_style 0
+// possible values:
+//  0: forward + solid sphere (like Quake) - varies velocity
+//  1: forward + flattened solid sphere
+//  2: forward + solid circle
+//  3: forward + normal distribution 3D - varies velocity
+//  4: forward + normal distribution on a plane
 set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 675
 set g_balance_falldamage_factor 0.25
@@ -221,6 +228,7 @@ set g_balance_laser_primary_edgedamage 0
 set g_balance_laser_primary_force 75
 set g_balance_laser_primary_radius 3
 set g_balance_laser_primary_speed 1500
+set g_balance_laser_primary_spread 0
 set g_balance_laser_primary_refire 0
 set g_balance_laser_primary_animtime 0.1
 set g_balance_laser_primary_lifetime 0.066
@@ -232,6 +240,7 @@ set g_balance_laser_secondary_edgedamage 0
 set g_balance_laser_secondary_force 100
 set g_balance_laser_secondary_radius 3
 set g_balance_laser_secondary_speed 1500
+set g_balance_laser_secondary_spread 0
 set g_balance_laser_secondary_refire 0
 set g_balance_laser_secondary_animtime 0.15
 set g_balance_laser_secondary_lifetime 0.066
@@ -279,6 +288,7 @@ set g_balance_grenadelauncher_primary_force 250
 set g_balance_grenadelauncher_primary_radius 120
 set g_balance_grenadelauncher_primary_speed 2000
 set g_balance_grenadelauncher_primary_speed_up 200
+set g_balance_grenadelauncher_primary_spread 0
 set g_balance_grenadelauncher_primary_lifetime 3
 set g_balance_grenadelauncher_primary_refire 0.7
 set g_balance_grenadelauncher_primary_animtime 0.6
@@ -289,6 +299,7 @@ set g_balance_grenadelauncher_secondary_force 250
 set g_balance_grenadelauncher_secondary_radius 150
 set g_balance_grenadelauncher_secondary_speed 1000
 set g_balance_grenadelauncher_secondary_speed_up 0
+set g_balance_grenadelauncher_secondary_spread 0
 set g_balance_grenadelauncher_secondary_lifetime 2
 set g_balance_grenadelauncher_secondary_refire 0.7
 set g_balance_grenadelauncher_secondary_animtime 0.6
@@ -303,6 +314,7 @@ set g_balance_electro_primary_force 150
 set g_balance_electro_primary_radius 80
 set g_balance_electro_primary_comboradius 150
 set g_balance_electro_primary_speed 2000
+set g_balance_electro_primary_spread 0
 set g_balance_electro_primary_lifetime 3
 set g_balance_electro_primary_refire 0.7
 set g_balance_electro_primary_animtime 0.7
@@ -314,6 +326,7 @@ set g_balance_electro_secondary_force 100
 set g_balance_electro_secondary_radius 150
 set g_balance_electro_secondary_speed 900
 set g_balance_electro_secondary_speed_up 200
+set g_balance_electro_secondary_spread 0
 set g_balance_electro_secondary_lifetime 2.5
 set g_balance_electro_secondary_refire 0.1
 set g_balance_electro_secondary_refire2 2
@@ -543,6 +556,7 @@ set g_balance_fireball_primary_laserradius 110
 set g_balance_fireball_primary_lifetime 7
 set g_balance_fireball_primary_refire 2
 set g_balance_fireball_primary_speed 900
+set g_balance_fireball_primary_spread 0
 set g_balance_fireball_primary_speed_up 100
 set g_balance_fireball_secondary_ammo 25
 set g_balance_fireball_secondary_animtime 0.15
@@ -563,4 +577,5 @@ set g_balance_fireball_secondary_radius 200
 set g_balance_fireball_secondary_refire 0
 set g_balance_fireball_secondary_refire2 4
 set g_balance_fireball_secondary_speed 650
+set g_balance_fireball_secondary_spread 0
 //   }}}
index 32325a0..e3c8cec 100644 (file)
@@ -3,7 +3,7 @@
 //
 // And... don't forget to edit the other balance*.cfg too.
 
-set cvar_check_balance 1904952fd0d915f79ab4e6f0622abdb6
+set cvar_check_balance 729b07b9caa8a86c08841a0f4275e97d
 
 // {{{ weapon replacement
 // NOTE: this only replaces weapons on the map
@@ -178,6 +178,13 @@ set g_projectiles_newton_style 2
 //  4: just add the player velocity length to the absolute velocity (tZork's sniper rockets)
 set g_projectiles_newton_style_2_minfactor 0.8
 set g_projectiles_newton_style_2_maxfactor 1.5
+set g_projectiles_spread_style 0
+// possible values:
+//  0: forward + solid sphere (like Quake) - varies velocity
+//  1: forward + flattened solid sphere
+//  2: forward + solid circle
+//  3: forward + normal distribution 3D - varies velocity
+//  4: forward + normal distribution on a plane
 set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1400
 set g_balance_falldamage_factor 0.15
@@ -221,6 +228,7 @@ set g_balance_laser_primary_edgedamage 10
 set g_balance_laser_primary_force 400
 set g_balance_laser_primary_radius 70
 set g_balance_laser_primary_speed 12000
+set g_balance_laser_primary_spread 0
 set g_balance_laser_primary_refire 0.7
 set g_balance_laser_primary_animtime 0.3
 set g_balance_laser_primary_lifetime 30
@@ -232,6 +240,7 @@ set g_balance_laser_secondary_edgedamage 10
 set g_balance_laser_secondary_force 400
 set g_balance_laser_secondary_radius 70
 set g_balance_laser_secondary_speed 12000
+set g_balance_laser_secondary_spread 0
 set g_balance_laser_secondary_refire 0.7
 set g_balance_laser_secondary_animtime 0.3
 set g_balance_laser_secondary_lifetime 30
@@ -279,6 +288,7 @@ set g_balance_grenadelauncher_primary_force 400
 set g_balance_grenadelauncher_primary_radius 140
 set g_balance_grenadelauncher_primary_speed 2200
 set g_balance_grenadelauncher_primary_speed_up 220
+set g_balance_grenadelauncher_primary_spread 0
 set g_balance_grenadelauncher_primary_lifetime 30
 set g_balance_grenadelauncher_primary_refire 0.8
 set g_balance_grenadelauncher_primary_animtime 0.3
@@ -289,6 +299,7 @@ set g_balance_grenadelauncher_secondary_force 400
 set g_balance_grenadelauncher_secondary_radius 140
 set g_balance_grenadelauncher_secondary_speed 1400
 set g_balance_grenadelauncher_secondary_speed_up 150
+set g_balance_grenadelauncher_secondary_spread 0
 set g_balance_grenadelauncher_secondary_lifetime 1
 set g_balance_grenadelauncher_secondary_refire 0.7
 set g_balance_grenadelauncher_secondary_animtime 0.3
@@ -303,6 +314,7 @@ set g_balance_electro_primary_force 200
 set g_balance_electro_primary_radius 150
 set g_balance_electro_primary_comboradius 0
 set g_balance_electro_primary_speed 2000
+set g_balance_electro_primary_spread 0
 set g_balance_electro_primary_lifetime 30
 set g_balance_electro_primary_refire 0.6
 set g_balance_electro_primary_animtime 0.3
@@ -314,6 +326,7 @@ set g_balance_electro_secondary_force 200
 set g_balance_electro_secondary_radius 150
 set g_balance_electro_secondary_speed 900
 set g_balance_electro_secondary_speed_up 200
+set g_balance_electro_secondary_spread 0
 set g_balance_electro_secondary_lifetime 2.5
 set g_balance_electro_secondary_refire 0.2
 set g_balance_electro_secondary_refire2 1
@@ -544,6 +557,7 @@ set g_balance_fireball_primary_lifetime 7
 set g_balance_fireball_primary_refire 2
 set g_balance_fireball_primary_speed 900
 set g_balance_fireball_primary_speed_up 100
+set g_balance_fireball_primary_spread 0
 set g_balance_fireball_secondary_ammo 25
 set g_balance_fireball_secondary_animtime 0.15
 set g_balance_fireball_secondary_bfgdamage 100
@@ -563,4 +577,5 @@ set g_balance_fireball_secondary_radius 200
 set g_balance_fireball_secondary_refire 0
 set g_balance_fireball_secondary_refire2 4
 set g_balance_fireball_secondary_speed 650
+set g_balance_fireball_secondary_spread 0
 //   }}}
index b657518..33168e7 100644 (file)
@@ -120,7 +120,7 @@ float log(float x)
                return 2 * log(sqrt(x)); // faster
        r = 1;
        r0 = 0;
-       for(i = 1; fabs(r - r0) >= 0.0000001; ++i)
+       for(i = 1; fabs(r - r0) >= 0.00001; ++i)
        {
                // Newton iteration on exp(r) = x:
                //   r <- r - (exp(r) - x) / (exp(r))
@@ -128,7 +128,6 @@ float log(float x)
                r0 = r;
                r = r0 - 1 + x / exp(r0);
        }
-       print(ftos(i), "\n");
        return r;
 }
 float log10(float x)
index 33080b5..e8d4d7b 100644 (file)
@@ -1662,3 +1662,30 @@ float float2range01(float f)
        // continuous function mapping all reals into 0..1
        return 0.5 + 0.5 * float2range11(f);
 }
+
+// from the GNU Scientific Library
+float gsl_ran_gaussian_lastvalue;
+float gsl_ran_gaussian_lastvalue_set;
+float gsl_ran_gaussian(float sigma)
+{
+       float x, y, r2;
+       if(gsl_ran_gaussian_lastvalue_set)
+       {
+               gsl_ran_gaussian_lastvalue_set = 0;
+               return sigma * gsl_ran_gaussian_lastvalue;
+       }
+       else
+       {
+               do
+               {
+                       x = -1 + 2 * random();
+                       y = -1 + 2 * random();
+                       r2 = x * x + y * y;
+               }
+               while(r2 > 1 || r2 == 0);
+               r2 = sqrt(-2 * log(r2) / r2);
+               gsl_ran_gaussian_lastvalue = x * r2;
+               gsl_ran_gaussian_lastvalue_set = 1;
+               return sigma * y * r2;
+       }
+}
index e318652..9240b1a 100644 (file)
@@ -200,3 +200,5 @@ const var void func_null(void); FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(func_nu
 const var string string_null;
 float float2range11(float f);
 float float2range01(float f);
+
+float gsl_ran_gaussian(float sigma);
index bc62e56..d9f484e 100644 (file)
@@ -1228,14 +1228,6 @@ vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity)
        return outvelocity;
 }
 
-void W_SetupProjectileVelocity(entity missile)
-{
-       if(missile.owner == world)
-               error("Unowned missile");
-
-       missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, missile.velocity);
-}
-
 void W_AttachToShotorg(entity flash, vector offset)
 {
        entity xflash;
@@ -1268,3 +1260,92 @@ void W_AttachToShotorg(entity flash, vector offset)
                }
        }
 }
+
+vector cliptoplane(vector v, vector p)
+{
+       return v - (v * p) * p;
+}
+
+vector findperpendicular(vector v)
+{
+       vector p;
+       p_x = v_z;
+       p_y = -v_x;
+       p_z = v_y;
+       return normalize(cliptoplane(p, v));
+}
+
+vector W_CalculateProjectileSpread(vector forward, float spread)
+{
+       float sigma;
+       vector v1, v2;
+       float dx, dy;
+       float sstyle;
+       if(spread <= 0)
+               return forward;
+       sstyle = cvar("g_projectiles_spread_style");
+       if(sstyle == 0)
+       {
+               // this is the baseline for the spread value!
+               // standard deviation: sqrt(2/5)
+               return forward + randomvec() * spread;
+       }
+       else if(sstyle == 1)
+       {
+               // same thing, basically
+               return normalize(forward + cliptoplane(randomvec() * spread, forward));
+       }
+       else if(sstyle == 2)
+       {
+               // circle spread... has at sigma=1 a standard deviation of sqrt(1/2)
+               sigma = spread * 0.89442719099991587855; // match baseline stddev
+               v1 = findperpendicular(forward);
+               v2 = cross(forward, v1);
+               do
+               {
+                       dx = -1 + 2 * random();
+                       dy = -1 + 2 * random();
+               }
+               while(dx * dx + dy * dy >= 1);
+               return normalize(forward + (v1 * dx + v2 * dy) * sigma);
+       }
+       else if(sstyle == 3)
+       {
+               sigma = spread * 0.63245553203368; // match baseline stddev
+               v1 = forward;
+               v1_x += gsl_ran_gaussian(sigma);
+               v1_y += gsl_ran_gaussian(sigma);
+               v1_z += gsl_ran_gaussian(sigma);
+               return v1;
+       }
+       else if(sstyle == 4)
+       {
+               sigma = spread * 0.51639777949433; // match baseline stddev
+               v1_x = gsl_ran_gaussian(sigma);
+               v1_y = gsl_ran_gaussian(sigma);
+               v1_z = gsl_ran_gaussian(sigma);
+               return normalize(forward + cliptoplane(v1, forward));
+       }
+       else
+               error("g_projectiles_spread_style must be 0 (sphere), 1 (flattened sphere), 2 (circle), 3 (gauss 3D), 4 (gauss plane)!");
+       return '0 0 0';
+}
+
+void W_SetupProjectileVelocityEx(entity missile, vector dir, vector upDir, float pSpeed, float pUpSpeed, float spread)
+{
+       if(missile.owner == world)
+               error("Unowned missile");
+
+       dir = dir + upDir * (pUpSpeed / pSpeed);
+       pSpeed *= vlen(dir);
+       dir = normalize(dir);
+       missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, pSpeed * W_CalculateProjectileSpread(dir, spread));
+}
+
+void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
+{
+       W_SetupProjectileVelocityEx(missile, w_shotdir, v_up, pSpeed, 0, spread);
+}
+
+#define W_SETUPPROJECTILEVELOCITY_UP(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), cvar(#s "_speed_up"), cvar(#s "_spread"))
+#define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, cvar(#s "_spread"))
index 78917bd..e1460f8 100644 (file)
@@ -1,5 +1,5 @@
 string CVAR_CHECK_DEFAULT = "9ede7a7edae0b7ae4c8b7e6517293a6a";
-string CVAR_CHECK_BALANCE = "1904952fd0d915f79ab4e6f0622abdb6";
+string CVAR_CHECK_BALANCE = "729b07b9caa8a86c08841a0f4275e97d";
 
 float  FALSE                                   = 0;
 float  TRUE                                    = 1;
index 636428d..a3100db 100644 (file)
@@ -340,8 +340,7 @@ void FireGrapplingHook (void)
 
        missile.state = 0; // not latched onto anything
 
-       missile.velocity = v_forward * cvar("g_balance_grapplehook_speed_fly");
-       W_SetupProjectileVelocity(missile);
+       W_SetupProjectileVelocityEx(missile, v_forward, v_up, cvar("g_balance_grapplehook_speed_fly"), 0, 0);
 
        missile.angles = vectoangles (missile.velocity);
        //missile.glow_color = 250; // 244, 250
index 3f8c3ea..099349c 100644 (file)
@@ -675,8 +675,7 @@ void W_Nexball_Attack2 (void)
        setsize (missile, '0 0 0', '0 0 0');
        setorigin (missile, w_shotorg);
 
-       missile.velocity = w_shotdir * cvar("g_balance_nexball_secondary_speed");
-       W_SetupProjectileVelocity(missile);
+       W_SetupProjectileVelocity(missile, cvar("g_balance_nexball_secondary_speed"), 0);
        missile.angles = vectoangles (missile.velocity);
        missile.touch = W_Nexball_Touch;
        missile.think = SUB_Remove;
index 33de174..4a1c498 100644 (file)
@@ -361,8 +361,7 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
                proj.movetype = MOVETYPE_FLY;
        proj.think = SUB_Remove;
        proj.nextthink = time + lifetime; // min(pLifetime, vlen(world.maxs - world.mins) / pSpeed);
-       proj.velocity = (dir + randomvec() * spread) * pSpeed;
-       W_SetupProjectileVelocity(proj);
+       W_SetupProjectileVelocityEx(proj, dir, v_up, pSpeed, 0, spread);
        proj.angles = vectoangles(proj.velocity);
        proj.dmg_radius = cvar("g_ballistics_materialconstant") / bulletconstant;
        // so: bulletconstant = bullet mass / area of bullet circle
index 7994354..8e09ee0 100644 (file)
@@ -101,9 +101,7 @@ void W_Crylink_Attack (void)
                        s_z = v_forward_y;
                }
                s = s * cvar("g_balance_crylink_primary_spread");
-               proj.velocity = (w_shotdir + right * s_y + up * s_z) * cvar("g_balance_crylink_primary_speed");
-//             proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
-               W_SetupProjectileVelocity(proj);
+               W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_crylink_primary_speed"), 0, 0);
                proj.touch = W_Crylink_Touch;
                if(counter == 0)
                        SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_middle_lifetime"), cvar("g_balance_crylink_primary_middle_fadetime"));
@@ -154,8 +152,7 @@ void W_Crylink_Attack2 (void)
                setorigin (proj, w_shotorg);
                setsize(proj, '0 0 0', '0 0 0');
 
-               proj.velocity = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
-               W_SetupProjectileVelocity(proj);
+               W_SetupProjectileVelocityEx(proj, (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")), v_up, cvar("g_balance_crylink_secondary_speed"), 0, 0);
                proj.touch = W_Crylink_Touch2;
                if(counter == (shots - 1) / 2)
                        SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_middle_lifetime"), cvar("g_balance_crylink_secondary_middle_fadetime"));
index fc657f4..dd2cd12 100644 (file)
@@ -127,8 +127,7 @@ void W_Electro_Attack()
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
                self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
        proj.movetype = MOVETYPE_FLY;
-       proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
-       W_SetupProjectileVelocity(proj);
+       W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
        proj.angles = vectoangles(proj.velocity);
        proj.touch = W_Plasma_TouchExplode;
        setsize(proj, '0 0 -3', '0 0 -3');
@@ -166,8 +165,7 @@ void W_Electro_Attack2()
        //proj.glow_size = 50;
        //proj.glow_color = 45;
        proj.movetype = MOVETYPE_BOUNCE;
-       proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_electro_secondary_spread")) * cvar("g_balance_electro_secondary_speed") + v_up * cvar("g_balance_electro_secondary_speed_up");
-       W_SetupProjectileVelocity(proj);
+       W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
        proj.touch = W_Plasma_Touch;
        setsize(proj, '0 0 -3', '0 0 -3');
        proj.takedamage = DAMAGE_YES;
index eb63ea4..a32718f 100644 (file)
@@ -145,8 +145,7 @@ void W_Fireball_Attack2()
        setorigin(proj, w_shotorg);
 
        proj.movetype = MOVETYPE_FLY;
-       proj.velocity = w_shotdir * cvar("g_balance_fireball_secondary_speed");
-       W_SetupProjectileVelocity(proj);
+       W_SETUPPROJECTILEVELOCITY(proj, g_balance_fireball_secondary);
        proj.angles = vectoangles(proj.velocity);
        proj.touch = W_Fireball_TouchExplode;
        setsize(proj, '-16 -16 -16', '16 16 16');
@@ -280,9 +279,8 @@ void W_Fireball_Attack1()
        proj.think = W_Firemine_Think;
        proj.nextthink = time;
        proj.damageforcescale = cvar("g_balance_fireball_primary_damageforcescale");
-       proj.velocity = w_shotdir * cvar("g_balance_fireball_primary_speed") + v_up * cvar("g_balance_fireball_primary_speed_up");
        proj.pushltime = time + cvar("g_balance_fireball_primary_lifetime");
-       W_SetupProjectileVelocity(proj);
+       W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_fireball_primary);
 
        proj.angles = vectoangles(proj.velocity);
        proj.flags = FL_PROJECTILE;
index dbe5ae5..14ef43d 100644 (file)
@@ -99,8 +99,7 @@ void W_Grenade_Attack (void)
        gren.think = adaptor_think2use;
        gren.use = W_Grenade_Explode;
        gren.touch = W_Grenade_Touch1;
-       gren.velocity = w_shotdir * cvar("g_balance_grenadelauncher_primary_speed") + v_up * cvar("g_balance_grenadelauncher_primary_speed_up");
-       W_SetupProjectileVelocity(gren);
+       W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_primary);
 
        gren.angles = vectoangles (gren.velocity);
        gren.flags = FL_PROJECTILE;
@@ -138,8 +137,7 @@ void W_Grenade_Attack2 (void)
        gren.health = cvar("g_balance_grenadelauncher_secondary_health");
        gren.damageforcescale = cvar("g_balance_grenadelauncher_secondary_damageforcescale");
        gren.event_damage = W_Grenade_Damage;
-       gren.velocity = w_shotdir * cvar("g_balance_grenadelauncher_secondary_speed") + v_up * cvar("g_balance_grenadelauncher_secondary_speed_up");
-       W_SetupProjectileVelocity(gren);
+       W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_secondary);
 
        gren.angles = vectoangles (gren.velocity);
        gren.flags = FL_PROJECTILE;
index 0d9fdf3..968a744 100644 (file)
@@ -61,8 +61,7 @@ void W_Hagar_Attack (void)
        setsize(missile, '0 0 0', '0 0 0');
 
        missile.movetype = MOVETYPE_FLY;
-       missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
-       W_SetupProjectileVelocity(missile);
+       W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
 
        missile.angles = vectoangles (missile.velocity);
        missile.flags = FL_PROJECTILE;
@@ -97,9 +96,7 @@ void W_Hagar_Attack2 (void)
        setsize(missile, '0 0 0', '0 0 0');
 
        missile.movetype = MOVETYPE_BOUNCEMISSILE;
-       missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed");
-       W_SetupProjectileVelocity(missile);
-       missile.avelocity = '100 10 10';
+       W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
 
        missile.angles = vectoangles (missile.velocity);
        missile.flags = FL_PROJECTILE;
index 73ae1a0..efc03d9 100644 (file)
@@ -58,9 +58,7 @@ void W_HLAC_Attack (void)
        setorigin (missile, w_shotorg);
        setsize(missile, '0 0 0', '0 0 0');
 
-    missile.velocity = (w_shotdir + randomvec() * spread) * cvar("g_balance_hlac_primary_speed");
-
-       W_SetupProjectileVelocity(missile);
+       W_SetupProjectileVelocity(missile, cvar("g_balance_hlac_primary_speed"), spread);
        missile.angles = vectoangles (missile.velocity);
 
        missile.touch = W_HLAC_Touch;
@@ -102,9 +100,7 @@ void W_HLAC_Attack2f (void)
        setorigin (missile, w_shotorg);
        setsize(missile, '0 0 0', '0 0 0');
 
-    missile.velocity = (w_shotdir + randomvec() * spread) * cvar("g_balance_hlac_secondary_speed");
-
-       W_SetupProjectileVelocity(missile);
+       W_SetupProjectileVelocity(missile, cvar("g_balance_hlac_secondary_speed"), spread);
        missile.angles = vectoangles (missile.velocity);
 
        missile.touch = W_HLAC_Touch2;
index 53439b5..8dc76c7 100644 (file)
@@ -72,10 +72,9 @@ void W_Laser_Attack (float issecondary)
        setsize(missile, '0 0 0', '0 0 0');
 
        if (issecondary == 1)
-               missile.velocity = w_shotdir * cvar("g_balance_laser_secondary_speed");
+               W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_secondary);
        else
-               missile.velocity = w_shotdir * cvar("g_balance_laser_primary_speed");
-       W_SetupProjectileVelocity(missile);
+               W_SETUPPROJECTILEVELOCITY(missile, g_balance_laser_primary);
        missile.angles = vectoangles (missile.velocity);
        //missile.glow_color = 250; // 244, 250
        //missile.glow_size = 120;
index 91e8624..08c80d3 100644 (file)
@@ -179,10 +179,10 @@ void W_Porto_Attack (void)
        gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
        gren.think = W_Porto_Think;
        gren.touch = W_Porto_Touch;
-       gren.velocity = w_shotdir * cvar("g_balance_porto_primary_speed");
        if(self.items & IT_STRENGTH)
-               gren.velocity = gren.velocity * cvar("g_balance_powerup_strength_force");
-       W_SetupProjectileVelocity(gren);
+               W_SetupProjectileVelocity(gren, cvar("g_balance_porto_primary_speed") * cvar("g_balance_powerup_strength_force"), 0);
+       else
+               W_SetupProjectileVelocity(gren, cvar("g_balance_porto_primary_speed"), 0);
 
        gren.angles = vectoangles (gren.velocity);
        gren.flags = FL_PROJECTILE;
index 1cd8260..15832f6 100644 (file)
@@ -319,10 +319,9 @@ void W_Rocket_Attack (void)
 
        setorigin (missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
        if(g_laserguided_missile && self.laser_on)
-               missile.velocity = w_shotdir * cvar("g_balance_rocketlauncher_laserguided_speedstart") * g_weaponspeedfactor;
+               W_SetupProjectileVelocity(missile, cvar("g_balance_rocketlauncher_laserguided_speedstart"), 0);
        else
-               missile.velocity = w_shotdir * cvar("g_balance_rocketlauncher_speedstart") * g_weaponspeedfactor;
-       W_SetupProjectileVelocity(missile);
+               W_SetupProjectileVelocity(missile, cvar("g_balance_rocketlauncher_speedstart"), 0);
        missile.angles = vectoangles (missile.velocity);
 
        missile.touch = W_Rocket_Touch;