]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added sv_waterfriction, sv_airaccelerate, sv_wateraccelerate cvars (and corresponding...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 May 2006 23:22:06 +0000 (23:22 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 May 2006 23:22:06 +0000 (23:22 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6387 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
server.h
sv_main.c
sv_phys.c
sv_user.c

index 402a9ec68c6170ee64d85cac271983df3192a5c4..7c6fec1a241d3e6e1774bd66736de7f7c5283943 100644 (file)
@@ -274,9 +274,12 @@ cvar_t cl_movement_maxspeed = {0, "cl_movement_maxspeed", "320", "how fast you c
 cvar_t cl_movement_maxairspeed = {0, "cl_movement_maxairspeed", "30", "how fast you can move while in the air (should match sv_maxairspeed)"};
 cvar_t cl_movement_stopspeed = {0, "cl_movement_stopspeed", "100", "speed below which you will be slowed rapidly to a stop rather than sliding endlessly (should match sv_stopspeed)"};
 cvar_t cl_movement_friction = {0, "cl_movement_friction", "4", "how fast you slow down (should match sv_friction)"};
+cvar_t cl_movement_waterfriction = {0, "cl_movement_waterfriction", "-1", "how fast you slow down (should match sv_friction), if less than 0 the cl_movement_friction variable is used instead"};
 cvar_t cl_movement_edgefriction = {0, "cl_movement_edgefriction", "2", "how much to slow down when you may be about to fall off a ledge (should match edgefriction)"};
 cvar_t cl_movement_stepheight = {0, "cl_movement_stepheight", "18", "how tall a step you can step in one instant (should match sv_stepheight)"};
 cvar_t cl_movement_accelerate = {0, "cl_movement_accelerate", "10", "how fast you accelerate (should match sv_accelerate)"};
+cvar_t cl_movement_airaccelerate = {0, "cl_movement_airaccelerate", "-1", "how fast you accelerate while in the air (should match sv_airaccelerate), if less than 0 the cl_movement_accelerate variable is used instead"};
+cvar_t cl_movement_wateraccelerate = {0, "cl_movement_wateraccelerate", "-1", "how fast you accelerate while in the air (should match sv_airaccelerate), if less than 0 the cl_movement_accelerate variable is used instead"};
 cvar_t cl_movement_jumpvelocity = {0, "cl_movement_jumpvelocity", "270", "how fast you move upward when you begin a jump (should match the quakec code)"};
 cvar_t cl_gravity = {0, "cl_gravity", "800", "how much gravity to apply in client physics (should match sv_gravity)"};
 cvar_t cl_slowmo = {0, "cl_slowmo", "1", "speed of game time (should match slowmo)"};
@@ -1058,10 +1061,10 @@ void CL_ClientMovement_Replay(void)
                s.movevars_maxspeed = cl_movement_maxspeed.value;
                s.movevars_spectatormaxspeed = cl_movement_maxspeed.value;
                s.movevars_accelerate = cl_movement_accelerate.value;
-               s.movevars_airaccelerate = cl_movement_accelerate.value;
-               s.movevars_wateraccelerate = cl_movement_accelerate.value;
+               s.movevars_airaccelerate = cl_movement_airaccelerate.value < 0 ? cl_movement_accelerate.value : cl_movement_airaccelerate.value;
+               s.movevars_wateraccelerate = cl_movement_wateraccelerate.value < 0 ? cl_movement_accelerate.value : cl_movement_wateraccelerate.value;
                s.movevars_friction = cl_movement_friction.value;
-               s.movevars_waterfriction = cl_movement_friction.value;
+               s.movevars_waterfriction = cl_movement_waterfriction.value < 0 ? cl_movement_friction.value : cl_movement_waterfriction.value;
                s.movevars_entgravity = 1;
                s.movevars_jumpvelocity = cl_movement_jumpvelocity.value;
                s.movevars_edgefriction = cl_movement_edgefriction.value;
index 73ca5a6c5aab05533176d3a5985db266c6541434..bc6eb4f83a3d54ffc313cf0c0b6646ccae2528c6 100644 (file)
--- a/server.h
+++ b/server.h
@@ -246,11 +246,14 @@ extern cvar_t sv_maxvelocity;
 extern cvar_t sv_gravity;
 extern cvar_t sv_nostep;
 extern cvar_t sv_friction;
+extern cvar_t sv_waterfriction;
 extern cvar_t sv_edgefriction;
 extern cvar_t sv_stopspeed;
 extern cvar_t sv_maxspeed;
 extern cvar_t sv_maxairspeed;
 extern cvar_t sv_accelerate;
+extern cvar_t sv_airaccelerate;
+extern cvar_t sv_wateraccelerate;
 extern cvar_t sv_idealpitchscale;
 extern cvar_t sv_aim;
 extern cvar_t sv_stepheight;
index e2700e6cdea83d2b8bc1dd1ea021717554420d06..b7b71edfca25fcf582c5bd4ada2078a1ebbafe41 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -74,11 +74,14 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_maxvelocity);
        Cvar_RegisterVariable (&sv_gravity);
        Cvar_RegisterVariable (&sv_friction);
+       Cvar_RegisterVariable (&sv_waterfriction);
        Cvar_RegisterVariable (&sv_edgefriction);
        Cvar_RegisterVariable (&sv_stopspeed);
        Cvar_RegisterVariable (&sv_maxspeed);
        Cvar_RegisterVariable (&sv_maxairspeed);
        Cvar_RegisterVariable (&sv_accelerate);
+       Cvar_RegisterVariable (&sv_airaccelerate);
+       Cvar_RegisterVariable (&sv_wateraccelerate);
        Cvar_RegisterVariable (&sv_idealpitchscale);
        Cvar_RegisterVariable (&sv_aim);
        Cvar_RegisterVariable (&sv_nostep);
index 895e6876a9d1ef12179624abdb243757c27881e3..2355d16b7764716ebcee306df6993b647a2954f4 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -42,6 +42,7 @@ solid_edge items only clip against bsp models.
 */
 
 cvar_t sv_friction = {CVAR_NOTIFY, "sv_friction","4", "how fast you slow down"};
+cvar_t sv_waterfriction = {CVAR_NOTIFY, "sv_waterfriction","-1", "how fast you slow down, if less than 0 the sv_friction variable is used instead"};
 cvar_t sv_stopspeed = {CVAR_NOTIFY, "sv_stopspeed","100", "how fast you come to a complete stop"};
 cvar_t sv_gravity = {CVAR_NOTIFY, "sv_gravity","800", "how fast you fall (512 = roughly earth gravity)"};
 cvar_t sv_maxvelocity = {CVAR_NOTIFY, "sv_maxvelocity","2000", "universal speed limit on all entities"};
index 23a98966a07ccb2842698a8ef539d7586e6e1dbd..0cc8d24cf9060b9bdc2532a849c9983bc9d462d3 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -26,6 +26,8 @@ cvar_t sv_idealpitchscale = {0, "sv_idealpitchscale","0.8", "how much to look up
 cvar_t sv_maxspeed = {CVAR_NOTIFY, "sv_maxspeed", "320", "maximum speed a player can accelerate to when on ground (can be exceeded by tricks)"};
 cvar_t sv_maxairspeed = {0, "sv_maxairspeed", "30", "maximum speed a player can accelerate to when airborn (note that it is possible to completely stop by moving the opposite direction)"};
 cvar_t sv_accelerate = {0, "sv_accelerate", "10", "rate at which a player accelerates to sv_maxspeed"};
+cvar_t sv_airaccelerate = {0, "sv_airaccelerate", "-1", "rate at which a player accelerates to sv_maxairspeed while in the air, if less than 0 the sv_accelerate variable is used instead"};
+cvar_t sv_wateraccelerate = {0, "sv_wateraccelerate", "-1", "rate at which a player accelerates to sv_maxspeed while in the air, if less than 0 the sv_accelerate variable is used instead"};
 
 static usercmd_t cmd;
 
@@ -101,7 +103,6 @@ void SV_SetIdealPitch (void)
        host_client->edict->fields.server->idealpitch = -dir * sv_idealpitchscale.value;
 }
 
-#if 1
 static vec3_t wishdir, forward, right, up;
 static float wishspeed;
 
@@ -182,7 +183,7 @@ void SV_AirAccelerate (vec3_t wishveloc)
        addspeed = wishspd - currentspeed;
        if (addspeed <= 0)
                return;
-       accelspeed = sv_accelerate.value*wishspeed * sv.frametime;
+       accelspeed = (sv_airaccelerate.value < 0 ? sv_accelerate.value : sv_airaccelerate.value)*wishspeed * sv.frametime;
        if (accelspeed > addspeed)
                accelspeed = addspeed;
 
@@ -290,7 +291,7 @@ void SV_WaterMove (void)
                return;
 
        VectorNormalize (wishvel);
-       accelspeed = sv_accelerate.value * wishspeed * sv.frametime;
+       accelspeed = (sv_wateraccelerate.value < 0 ? sv_accelerate.value : sv_wateraccelerate.value) * wishspeed * sv.frametime;
        if (accelspeed > addspeed)
                accelspeed = addspeed;
 
@@ -427,176 +428,6 @@ void SV_ClientThink (void)
        SV_AirMove ();
 }
 
-#else
-
-extern cvar_t cl_rollspeed;
-extern cvar_t cl_rollangle;
-void SV_ClientThink(void)
-{
-       int j;
-       vec3_t wishvel, wishdir, v, v_forward, v_right, v_up, start, stop;
-       float wishspeed, f, limit;
-       trace_t trace;
-
-       if (host_client->edict->fields.server->movetype == MOVETYPE_NONE)
-               return;
-
-       f = DotProduct(host_client->edict->fields.server->punchangle, host_client->edict->fields.server->punchangle);
-       if (f)
-       {
-               limit = sqrt(f);
-               f = (limit - 10 * sv.frametime);
-               f /= limit;
-               f = max(0, f);
-               VectorScale(host_client->edict->fields.server->punchangle, f, host_client->edict->fields.server->punchangle);
-       }
-
-       // if dead, behave differently
-       if (host_client->edict->fields.server->health <= 0)
-               return;
-
-       AngleVectors(host_client->edict->fields.server->v_angle, v_forward, v_right, v_up);
-       // show 1/3 the pitch angle and all the roll angle
-       f = DotProduct(host_client->edict->fields.server->velocity, v_right) * (1.0 / cl_rollspeed.value);
-       host_client->edict->fields.server->angles[2] = bound(-1, f, 1) * cl_rollangle.value * 4;
-       if (!host_client->edict->fields.server->fixangle)
-       {
-               host_client->edict->fields.server->angles[0] = (host_client->edict->fields.server->v_angle[0] + host_client->edict->fields.server->punchangle[0]) * -0.333;
-               host_client->edict->fields.server->angles[1] = host_client->edict->fields.server->v_angle[1] + host_client->edict->fields.server->punchangle[1];
-       }
-
-       if ((int)host_client->edict->fields.server->flags & FL_WATERJUMP)
-       {
-               host_client->edict->fields.server->velocity[0] = host_client->edict->fields.server->movedir[0];
-               host_client->edict->fields.server->velocity[1] = host_client->edict->fields.server->movedir[1];
-               if (sv.time > host_client->edict->fields.server->teleport_time || host_client->edict->fields.server->waterlevel == 0)
-               {
-                       host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags - ((int)host_client->edict->fields.server->flags & FL_WATERJUMP);
-                       host_client->edict->fields.server->teleport_time = 0;
-               }
-               return;
-       }
-
-       // swim
-       if (host_client->edict->fields.server->waterlevel >= 2)
-       if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
-       {
-               if (host_client->cmd.forwardmove == 0 && host_client->cmd.sidemove == 0 && host_client->cmd.upmove == 0)
-               {
-                       // drift towards bottom
-                       wishvel[0] = 0;
-                       wishvel[1] = 0;
-                       wishvel[2] = -60;
-               }
-               else
-               {
-                       for (j = 0;j < 3;j++)
-                               wishvel[j] = v_forward[j] * host_client->cmd.forwardmove + v_right[j] * host_client->cmd.sidemove;
-                       wishvel[2] += host_client->cmd.upmove;
-               }
-
-               wishspeed = VectorLength(wishvel);
-               wishspeed = min(wishspeed, sv_maxspeed.value) * 0.7;
-
-               // water friction
-               f = VectorLength(host_client->edict->fields.server->velocity) * (1 - sv.frametime * sv_friction.value);
-               if (f > 0)
-                       f /= VectorLength(host_client->edict->fields.server->velocity);
-               else
-                       f = 0;
-               VectorScale(host_client->edict->fields.server->velocity, f, host_client->edict->fields.server->velocity);
-
-               // water acceleration
-               if (wishspeed <= f)
-                       return;
-
-               f = wishspeed - f;
-               limit = sv_accelerate.value * wishspeed * sv.frametime;
-               if (f > limit)
-                       f = limit;
-               limit = VectorLength(wishvel);
-               if (limit)
-                       f /= limit;
-               VectorMA(host_client->edict->fields.server->velocity, f, wishvel, host_client->edict->fields.server->velocity);
-               return;
-       }
-
-       // if not flying, move horizontally only
-       if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
-       {
-               VectorClear(wishvel);
-               wishvel[1] = host_client->edict->fields.server->v_angle[1];
-               AngleVectors(wishvel, v_forward, v_right, v_up);
-       }
-
-       // hack to not let you back into teleporter
-       VectorScale(v_right, host_client->cmd.sidemove, wishvel);
-       if (sv.time >= host_client->edict->fields.server->teleport_time || host_client->cmd.forwardmove > 0)
-               VectorMA(wishvel, host_client->cmd.forwardmove, v_forward, wishvel);
-       if (host_client->edict->fields.server->movetype != MOVETYPE_WALK)
-               wishvel[2] += cmd.upmove;
-
-       VectorCopy(wishvel, wishdir);
-       VectorNormalize(wishdir);
-       wishspeed = VectorLength(wishvel);
-       if (wishspeed > sv_maxspeed.value)
-               wishspeed = sv_maxspeed.value;
-
-       if (host_client->edict->fields.server->movetype == MOVETYPE_NOCLIP || host_client->edict->fields.server->movetype == MOVETYPE_FLY)
-       {
-               VectorScale(wishdir, wishspeed, host_client->edict->fields.server->velocity);
-               return;
-       }
-
-       if ((int)host_client->edict->fields.server->flags & FL_ONGROUND) // walking
-       {
-               // friction
-               f = host_client->edict->fields.server->velocity[0] * host_client->edict->fields.server->velocity[0] + host_client->edict->fields.server->velocity[1] * host_client->edict->fields.server->velocity[1];
-               if (f)
-               {
-                       f = sqrt(f);
-                       VectorCopy(host_client->edict->fields.server->velocity, v);
-                       v[2] = 0;
-
-                       // if the leading edge is over a dropoff, increase friction
-                       limit = 16.0f / f;
-                       VectorMA(host_client->edict->fields.server->origin, limit, v, v);
-                       v[2] += host_client->edict->fields.server->mins[2];
-
-                       VectorCopy(v, start);
-                       VectorCopy(v, stop);
-                       stop[2] -= 34;
-                       trace = SV_Move(start, vec3_origin, vec3_origin, stop, MOVE_NOMONSTERS, host_client->edict);
-
-                       // apply friction
-                       if (f < sv_stopspeed.value)
-                               f = sv_stopspeed.value / f;
-                       else
-                               f = 1;
-                       if (trace.fraction == 1)
-                               f *= sv_edgefriction.value;
-                       f = 1 - sv.frametime * f * sv_friction.value;
-
-                       if (f < 0)
-                               f = 0;
-                       VectorScale(host_client->edict->fields.server->velocity, f, host_client->edict->fields.server->velocity);
-               }
-       }
-       else // airborn
-               wishspeed = min(wishspeed, 30);
-
-       // ground or air acceleration
-       f = wishspeed - DotProduct(host_client->edict->fields.server->velocity, wishdir);
-       if (f > 0)
-       {
-               limit = sv_accelerate.value * sv.frametime * wishspeed;
-               if (f > limit)
-                       f = limit;
-               VectorMA(host_client->edict->fields.server->velocity, f, wishdir, host_client->edict->fields.server->velocity);
-       }
-}
-#endif
-
 /*
 ===================
 SV_ReadClientMove