]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
new toy: autocvar_g_damagepush_speedfactor - ENJOY
authorRudolf Polzer <divverent@xonotic.org>
Mon, 28 Mar 2011 14:13:59 +0000 (16:13 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Mon, 28 Mar 2011 14:17:35 +0000 (16:17 +0200)
13 files changed:
balance25.cfg
balanceLeeStricklin.cfg
balanceSamual.cfg
balanceXonotic.cfg
balancetZork.cfg
qcsrc/client/autocvars.qh
qcsrc/client/damage.qc
qcsrc/client/progs.src
qcsrc/common/explosion_equation.qc [new file with mode: 0644]
qcsrc/common/explosion_equation.qh [new file with mode: 0644]
qcsrc/server/autocvars.qh
qcsrc/server/g_damage.qc
qcsrc/server/progs.src

index 665dda5c90682f44730e5c33a4901e2239934e28..12e869118b7f1c9cc81a0dc1435a9b8dbaed83c3 100644 (file)
@@ -178,6 +178,7 @@ set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1400
 set g_balance_falldamage_factor 0.15
 set g_balance_falldamage_maxdamage 25
+set g_balance_damagepush_speedfactor 0
 // }}}
 
 // {{{ powerups
index 77aac858a72abb42b7f3ac1b53828439df052670..2da110fce655681f803ab69fa8864e7a62c17646 100644 (file)
@@ -178,6 +178,7 @@ set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1400
 set g_balance_falldamage_factor 0.15
 set g_balance_falldamage_maxdamage 25
+set g_balance_damagepush_speedfactor 0
 // }}}
 
 // {{{ powerups
index a117a44a9259546ef1b1b15794512402bde868ea..c30f46995205488516923a2c58d6535b9a539eec 100644 (file)
@@ -178,6 +178,7 @@ set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 1000
 set g_balance_falldamage_factor 0.20
 set g_balance_falldamage_maxdamage 15
+set g_balance_damagepush_speedfactor 0
 // }}}
 
 // {{{ powerups
index a782c6387927577d9e0b0d92a39d7d61c1deb534..1e97624083501ea5998cf6df133056a915a668f1 100644 (file)
@@ -178,6 +178,7 @@ set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 800
 set g_balance_falldamage_factor 0.20
 set g_balance_falldamage_maxdamage 15
+set g_balance_damagepush_speedfactor 5
 // }}}
 
 // {{{ powerups
index 2fb726764c7bae06ccea84a81d78af958fbd8171..e1027337a6efc9703768f3196493014cd371c247 100644 (file)
@@ -178,6 +178,7 @@ set g_balance_falldamage_deadminspeed 150
 set g_balance_falldamage_minspeed 800
 set g_balance_falldamage_factor 0.02 // maxspeed = minspeed + maxdamage / factor = 4550
 set g_balance_falldamage_maxdamage 75
+set g_balance_damagepush_speedfactor 0
 // }}}
 
 // {{{ powerups
index d380c7fc30902052883a2bc6449cb87cc2fb49b0..fe46be10c8fc47958ee8797316dacdfe937166a5 100644 (file)
@@ -128,6 +128,7 @@ float autocvar_crosshair_ring_reload_size;
 float autocvar_crosshair_size;
 float autocvar_ekg;
 float autocvar_fov;
+float autocvar_g_balance_damage_pushspeedfactor;
 float autocvar_g_balance_tuba_attenuation;
 float autocvar_g_balance_tuba_fadetime;
 float autocvar_g_balance_tuba_volume;
index 13c8e462e3d5d800cdafe161cca952e81bb246d2..21366ad7ba1ba7e834bd5b4ff9049815a92900bf 100644 (file)
@@ -57,7 +57,7 @@ void Ent_DamageInfo(float isNew)
                if(self.damageforcescale)
                        if(vlen(thisforce))
                        {
-                               self.move_velocity = self.move_velocity + self.damageforcescale * thisforce;
+                               self.move_velocity = self.move_velocity + self.damageforcescale * damage_explosion_calcpush(thisforce, self.move_velocity, autocvar_g_balance_damagepush_speedfactor);
                                self.move_flags &~= FL_ONGROUND;
                        }
 
index 1334d7d3c7b6251f25651ee280d418fffdf0a592..b79c759e817615ae71d9177cb75f830919e21311 100644 (file)
@@ -14,6 +14,7 @@ csqc_builtins.qc
 
 ../common/util.qh
 ../common/items.qh
+../common/explosion_equation.qh
 
 ../common/mapinfo.qh
 
@@ -71,6 +72,7 @@ noise.qc
 ../common/mapinfo.qc
 ../common/items.qc
 ../server/w_all.qc
+../common/explosion_equation.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/mathlib.qc
diff --git a/qcsrc/common/explosion_equation.qc b/qcsrc/common/explosion_equation.qc
new file mode 100644 (file)
index 0000000..4d5eb5a
--- /dev/null
@@ -0,0 +1,54 @@
+vector explosion_calcpush_nomultiplier(vector explosion_v, vector target_v)
+{
+       // solution of the equations:
+       //    v'                = v + alpha vp             // central hit
+       //    m*v'   + mp*vp'   = m*v + mp*vp              // conservation of momentum
+       //    m*v'^2 + mp*vp'^2 = m*v^2 + mp*vp^2          // conservation of energy (ELASTIC hit)
+       // -> alpha = 0                                    // case 1: did not hit
+       // -> alpha = 2*mp*(vp^2 - vp.v) / ((m+mp) * vp^2) // case 2: did hit
+       //                                                 // non-elastic hits are somewhere between these two
+
+       float alpha;
+       alpha  = explosion_v * (explosion_v - target_v);
+
+       if(alpha <= 0)
+               // target is too fast to be hittable by this
+               return '0 0 0';
+
+       alpha /= (explosion_v * explosion_v);
+               // now alpha is a multiplier
+               // we know we can divide by this, or above alpha would be == 0
+       
+       return
+               explosion_v * alpha;
+}
+
+#if 0
+vector explosion_calcpush(vector explosion_v, float explosion_m, vector target_v, float target_m, float elasticity)
+{
+       // solution of the equations:
+       //    v'                = v + alpha vp             // central hit
+       //    m*v'   + mp*vp'   = m*v + mp*vp              // conservation of momentum
+       //    m*v'^2 + mp*vp'^2 = m*v^2 + mp*vp^2          // conservation of energy (ELASTIC hit)
+       // -> alpha = 0                                    // case 1: did not hit
+       // -> alpha = 2*mp*(vp^2 - vp.v) / ((m+mp) * vp^2) // case 2: did hit
+       //                                                 // non-elastic hits are somewhere between these two
+
+       // this would be physically correct, but we don't do that
+       return explosion_calcpush_nomultiplier(explosion_v, target_v, 
+               (1 + elasticity) * (
+                       explosion_m
+               ) / (
+                       target_m + explosion_m
+               )
+       );
+}
+#endif
+
+// simplified formula, tuned so that if the target has velocity 0, we get exactly the original force
+vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor)
+{
+       if(speedfactor == 0)
+               return explosion_f;
+       return explosion_calcpush_nomultiplier(explosion_f * speedfactor, target_v) * (1.0 / speedfactor);
+}
diff --git a/qcsrc/common/explosion_equation.qh b/qcsrc/common/explosion_equation.qh
new file mode 100644 (file)
index 0000000..c8630cd
--- /dev/null
@@ -0,0 +1 @@
+vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor);
index c78460c17391b4cebfdd0cce5f6b8e55a57d5db3..2118694dcb20c54eadbd8bd74cf95cb6ab8c5ede 100644 (file)
@@ -735,6 +735,7 @@ float autocvar_g_ctf_shield_max_ratio;
 float autocvar_g_ctf_shield_min_negscore;
 float autocvar_g_cts_finish_kill_delay;
 float autocvar_g_cts_selfdamage;
+float autocvar_g_damagepush_speedfactor;
 float autocvar_g_deathglow;
 float autocvar_g_debug_bot_commands;
 float autocvar_g_domination_default_teams;
index c00a718217a556c95f4eba027c144aa9d66e8ae6..fcd3d9bd1a07fcc8f61257f6afe952df2f0e7586 100644 (file)
@@ -839,7 +839,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
        if (vlen(force))
        if (self.classname != "player" || time >= self.spawnshieldtime || g_midair)
        {
-               self.velocity = self.velocity + self.damageforcescale * force;
+               self.velocity = self.velocity + self.damageforcescale * damage_explosion_calcpush(force, self.velocity, autocvar_g_damagepush_speedfactor);
                self.flags &~= FL_ONGROUND;
                UpdateCSQCProjectile(self);
        }
index c76395fdbc27df7bdd26371a491fe1da65064276..cf5c7d6a8269e3eecc1f1e13c6043d85df930da7 100644 (file)
@@ -17,6 +17,7 @@ post-builtins.qh
 ../common/constants.qh
 ../common/util.qh
 ../common/items.qh
+../common/explosion_equation.qh
 
 autocvars.qh
 constants.qh
@@ -179,6 +180,8 @@ anticheat.qc
 cheats.qc
 playerstats.qc
 
+../common/explosion_equation.qc
+
 mutators/base.qc
 mutators/gamemode_keyhunt.qc
 mutators/gamemode_freezetag.qc