[nexuiz-commits] r6411 - in branches/nexuiz-2.0: . data data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Apr 2 06:52:36 EDT 2009
Author: div0
Date: 2009-04-02 06:52:36 -0400 (Thu, 02 Apr 2009)
New Revision: 6411
Modified:
branches/nexuiz-2.0/.patchsets
branches/nexuiz-2.0/data/defaultNexuiz.cfg
branches/nexuiz-2.0/data/qcsrc/server/cl_physics.qc
Log:
r6409 | div0 | 2009-04-02 12:43:45 +0200 (Thu, 02 Apr 2009) | 2 lines
jetpack: more correct fuel calculation
r6410 | div0 | 2009-04-02 12:51:58 +0200 (Thu, 02 Apr 2009) | 2 lines
we now have to take more fuel for the jetpack
Modified: branches/nexuiz-2.0/.patchsets
===================================================================
--- branches/nexuiz-2.0/.patchsets 2009-04-02 10:51:58 UTC (rev 6410)
+++ branches/nexuiz-2.0/.patchsets 2009-04-02 10:52:36 UTC (rev 6411)
@@ -1,2 +1,2 @@
master = svn://svn.icculus.org/nexuiz/trunk
-revisions_applied = 1-6407
+revisions_applied = 1-6410
Modified: branches/nexuiz-2.0/data/defaultNexuiz.cfg
===================================================================
--- branches/nexuiz-2.0/data/defaultNexuiz.cfg 2009-04-02 10:51:58 UTC (rev 6410)
+++ branches/nexuiz-2.0/data/defaultNexuiz.cfg 2009-04-02 10:52:36 UTC (rev 6411)
@@ -1427,7 +1427,7 @@
set g_jetpack_acceleration_up 600 "acceleration of the jetpack in z direction (note: you have to factor in gravity here, if antigravity is not 1)"
set g_jetpack_maxspeed_side 1500 "max speed of the jetpack in xy direction"
set g_jetpack_maxspeed_up 600 "max speed of the jetpack in z direction"
-set g_jetpack_fuel 5 "fuel per second for jetpack"
+set g_jetpack_fuel 8 "fuel per second for jetpack"
set g_balance_fuel_regen 0.1 "fuel regeneration (only applies if the player owns IT_FUEL_REGEN)"
set g_balance_fuel_rot 0.05
Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_physics.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_physics.qc 2009-04-02 10:51:58 UTC (rev 6410)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_physics.qc 2009-04-02 10:52:36 UTC (rev 6411)
@@ -649,13 +649,61 @@
wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1);
// add the unused velocity as up component
wishvel_z = 0;
- wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
+
+ // if(self.BUTTON_JUMP)
+ wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
+
// it is now normalized, so...
- wishvel_x *= cvar("g_jetpack_acceleration_side");
- wishvel_y *= cvar("g_jetpack_acceleration_side");
- wishvel_z *= cvar("g_jetpack_acceleration_up");
- wishvel_z += cvar("g_jetpack_antigravity") * sv_gravity;
+ float a_side, a_up, a_add, a_diff;
+ a_side = cvar("g_jetpack_acceleration_side");
+ a_up = cvar("g_jetpack_acceleration_up");
+ a_add = cvar("g_jetpack_antigravity") * sv_gravity;
+ wishvel_x *= a_side;
+ wishvel_y *= a_side;
+ wishvel_z *= a_up;
+ wishvel_z += a_add;
+
+ float best;
+ best = 0;
+ //////////////////////////////////////////////////////////////////////////////////////
+ // finding the maximum over all vectors of above form
+ // with wishvel having an absolute value of 1
+ //////////////////////////////////////////////////////////////////////////////////////
+ // we're finding the maximum over
+ // f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
+ // for z in the range from -1 to 1
+ //////////////////////////////////////////////////////////////////////////////////////
+ // maximum is EITHER attained at the single extreme point:
+ a_diff = a_side * a_side - a_up * a_up;
+ if(a_diff != 0)
+ {
+ f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
+ if(f > -1 && f < 1) // can it be attained?
+ {
+ best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
+ //print("middle\n");
+ }
+ }
+ // OR attained at z = 1:
+ f = (a_up + a_add) * (a_up + a_add);
+ if(f > best)
+ {
+ best = f;
+ //print("top\n");
+ }
+ // OR attained at z = -1:
+ f = (a_up - a_add) * (a_up - a_add);
+ if(f > best)
+ {
+ best = f;
+ //print("bottom\n");
+ }
+ best = sqrt(best);
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ //print("best possible acceleration: ", ftos(best), "\n");
+
float fxy, fz;
fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / cvar("g_jetpack_maxspeed_side"), 1);
if(wishvel_z - sv_gravity > 0)
@@ -668,13 +716,15 @@
wishvel_x *= fxy;
wishvel_y *= fxy;
wishvel_z = (wishvel_z - sv_gravity) * fz + sv_gravity;
- fvel = min(1, vlen(wishvel) / fvel);
+ fvel = min(1, vlen(wishvel) / best);
if(cvar("g_jetpack_fuel") && !(self.items & IT_UNLIMITED_WEAPON_AMMO))
f = min(1, self.ammo_fuel / (cvar("g_jetpack_fuel") * frametime * fvel));
else
f = 1;
+ //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
+
if (f > 0 && wishvel != '0 0 0')
{
self.velocity = self.velocity + wishvel * f * frametime;
More information about the nexuiz-commits
mailing list