]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
CPMA-style cl_movement physics settings possible! Variables for it:
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 May 2009 07:55:47 +0000 (07:55 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 May 2009 07:55:47 +0000 (07:55 +0000)
sv_aircontrol
sv_maxairstrafespeed
sv_airstrafeaccel
sv_airstopaccel

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8944 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
client.h
quakedef.h
server.h
sv_main.c

index 6edee3efd5fd73bcfb3d74ba8b88e7b081eef49d..a9da42ccf43cbc494461347617dbf084c3e82e96 100644 (file)
@@ -964,6 +964,30 @@ void CL_ClientMovement_Physics_Swim(cl_clientmovement_state_t *s)
        CL_ClientMovement_Move(s);
 }
 
+void CL_ClientMovement_Physics_CPM_PM_Aircontrol(cl_clientmovement_state_t *s, vec3_t wishdir, vec_t wishspeed)
+{
+       vec_t zspeed, speed, dot, k;
+
+       if(s->cmd.forwardmove == 0 || s->cmd.sidemove != 0)
+               return;
+       
+       zspeed = s->velocity[2];
+       s->velocity[2] = 0;
+       speed = VectorNormalizeLength(s->velocity);
+
+       dot = DotProduct(s->velocity, wishdir);
+       k = 32;
+       k *= cl.movevars_aircontrol*dot*dot*s->cmd.frametime;
+
+       if(dot > 0) { // we can't change direction while slowing down
+               VectorMAM(speed, s->velocity, k, wishdir, s->velocity);
+               VectorNormalize(s->velocity);
+       }
+
+       VectorScale(s->velocity, speed, s->velocity);
+       s->velocity[2] = zspeed;
+}
+
 void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
 {
        vec_t friction;
@@ -1057,9 +1081,26 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
                        vec_t vel_straight;
                        vec_t vel_z;
                        vec3_t vel_perpend;
+                       float wishspeed2, accel;
 
                        // apply air speed limit
                        wishspeed = min(wishspeed, cl.movevars_maxairspeed);
+                       accel = cl.movevars_airaccelerate;
+                       
+                       // CPM: air control
+                       wishspeed2 = wishspeed;
+                       if(cl.movevars_airstopaccelerate != 0)
+                               if(DotProduct(s->velocity, wishdir) < 0)
+                                       accel = cl.movevars_airstopaccelerate;
+                       if(s->cmd.forwardmove == 0 && s->cmd.sidemove != 0)
+                       {
+                               if(cl.movevars_maxairstrafespeed)
+                                       if(wishspeed > cl.movevars_maxairstrafespeed)
+                                               wishspeed = cl.movevars_maxairstrafespeed;
+                               if(cl.movevars_airstrafeaccelerate)
+                                       accel = cl.movevars_airstrafeaccelerate;
+                       }
+                       // !CPM
 
                        /*
                        addspeed = wishspeed - DotProduct(s->velocity, wishdir);
@@ -1077,14 +1118,17 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
 
                        f = wishspeed - vel_straight;
                        if(f > 0)
-                               vel_straight += min(f, cl.movevars_airaccelerate * s->cmd.frametime * wishspeed) * cl.movevars_airaccel_qw;
+                               vel_straight += min(f, accel * s->cmd.frametime * wishspeed) * cl.movevars_airaccel_qw;
                        if(wishspeed > 0)
-                               vel_straight += min(wishspeed, cl.movevars_airaccelerate * s->cmd.frametime * wishspeed) * (1 - cl.movevars_airaccel_qw);
+                               vel_straight += min(wishspeed, accel * s->cmd.frametime * wishspeed) * (1 - cl.movevars_airaccel_qw);
 
                        VectorM(1 - (s->cmd.frametime * (wishspeed / cl.movevars_maxairspeed) * cl.movevars_airaccel_sideways_friction), vel_perpend, vel_perpend);
 
                        VectorMA(vel_perpend, vel_straight, wishdir, s->velocity);
                        s->velocity[2] += vel_z;
+
+                       if(cl.movevars_aircontrol)
+                               CL_ClientMovement_Physics_CPM_PM_Aircontrol(s, wishdir, wishspeed2);
                }
                s->velocity[2] -= cl.movevars_gravity * cl.movevars_entgravity * s->cmd.frametime;
                CL_ClientMovement_Move(s);
@@ -1130,6 +1174,10 @@ void CL_UpdateMoveVars(void)
                cl.movevars_friction = cl.statsf[STAT_MOVEVARS_FRICTION];
                cl.movevars_wallfriction = cl.statsf[STAT_MOVEVARS_WALLFRICTION];
                cl.movevars_waterfriction = cl.statsf[STAT_MOVEVARS_WATERFRICTION];
+               cl.movevars_airstopaccelerate = cl.statsf[STAT_MOVEVARS_AIRSTOPACCELERATE];
+               cl.movevars_airstrafeaccelerate = cl.statsf[STAT_MOVEVARS_AIRSTRAFEACCELERATE];
+               cl.movevars_maxairstrafespeed = cl.statsf[STAT_MOVEVARS_MAXAIRSTRAFESPEED];
+               cl.movevars_aircontrol = cl.statsf[STAT_MOVEVARS_AIRCONTROL];
        }
        else
        {
@@ -1151,6 +1199,10 @@ void CL_UpdateMoveVars(void)
                cl.movevars_stepheight = cl_movement_stepheight.value;
                cl.movevars_airaccel_qw = cl_movement_airaccel_qw.value;
                cl.movevars_airaccel_sideways_friction = cl_movement_airaccel_sideways_friction.value;
+               cl.movevars_airstopaccelerate = 0;
+               cl.movevars_airstrafeaccelerate = 0;
+               cl.movevars_maxairstrafespeed = 0;
+               cl.movevars_aircontrol = 0;
        }
 }
 
index 16427924bdad29d9df8fcb6bd418fbf75d37670d..e470b9a5a4a8d7459bce12f2269e1fec2830b983 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1058,6 +1058,10 @@ typedef struct client_state_s
        float movevars_stepheight;
        float movevars_airaccel_qw;
        float movevars_airaccel_sideways_friction;
+       float movevars_airstopaccelerate;
+       float movevars_airstrafeaccelerate;
+       float movevars_maxairstrafespeed;
+       float movevars_aircontrol;
 
        // models used by qw protocol
        int qw_modelindex_spike;
index 6dc94ef159eb20005bccdb46b9e4070a87b8cd25..74ccc6d8538ad88050d8414fec9badafe728121b 100644 (file)
@@ -103,6 +103,10 @@ extern char engineversion[128];
 //#define STAT_TIME                    17 // FTE
 //#define STAT_VIEW2           20 // FTE
 #define STAT_VIEWZOOM          21 // DP
+#define STAT_MOVEVARS_AIRSTOPACCELERATE                                231 // DP
+#define STAT_MOVEVARS_AIRSTRAFEACCELERATE                      232 // DP
+#define STAT_MOVEVARS_MAXAIRSTRAFESPEED                                233 // DP
+#define STAT_MOVEVARS_AIRCONTROL                                       234 // DP
 #define STAT_FRAGLIMIT                                                         235 // DP
 #define STAT_TIMELIMIT                                                         236 // DP
 #define STAT_MOVEVARS_WALLFRICTION                                     237 // DP
index 86e07a764e3748eaa5770a8b88aa1dcc6890d32b..03d926509ff1482ac70f7299505d556f84b7adf7 100644 (file)
--- a/server.h
+++ b/server.h
@@ -371,6 +371,10 @@ extern cvar_t sv_aim;
 extern cvar_t sv_airaccel_qw;
 extern cvar_t sv_airaccel_sideways_friction;
 extern cvar_t sv_airaccelerate;
+extern cvar_t sv_airstopaccelerate;
+extern cvar_t sv_airstrafeaccelerate;
+extern cvar_t sv_maxairstrafespeed;
+extern cvar_t sv_aircontrol;
 extern cvar_t sv_allowdownloads;
 extern cvar_t sv_allowdownloads_archive;
 extern cvar_t sv_allowdownloads_config;
index 6e47d014bcee131cf86cbc973eae7f68c1052859..1bff09322e614cb87682c411c58aedba10187d66 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -50,6 +50,10 @@ cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's ver
 cvar_t sv_airaccel_qw = {0, "sv_airaccel_qw", "1", "ratio of QW-style air control as opposed to simple acceleration"};
 cvar_t sv_airaccel_sideways_friction = {0, "sv_airaccel_sideways_friction", "", "anti-sideways movement stabilization (reduces speed gain when zigzagging)"};
 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_airstopaccelerate = {0, "sv_airstopaccelerate", "0", "when set, replacement for sv_airaccelerate when moving backwards"};
+cvar_t sv_airstrafeaccelerate = {0, "sv_airstrafeaccelerate", "0", "when set, replacement for sv_airaccelerate when just strafing"};
+cvar_t sv_maxairstrafespeed = {0, "sv_maxairstrafespeed", "0", "when set, replacement for sv_maxairspeed when just strafing"};
+cvar_t sv_aircontrol = {0, "sv_aircontrol", "0", "CPMA-style air control"};
 cvar_t sv_allowdownloads = {0, "sv_allowdownloads", "1", "whether to allow clients to download files from the server (does not affect http downloads)"};
 cvar_t sv_allowdownloads_archive = {0, "sv_allowdownloads_archive", "0", "whether to allow downloads of archives (pak/pk3)"};
 cvar_t sv_allowdownloads_config = {0, "sv_allowdownloads_config", "0", "whether to allow downloads of config files (cfg)"};
@@ -329,6 +333,10 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_airaccel_qw);
        Cvar_RegisterVariable (&sv_airaccel_sideways_friction);
        Cvar_RegisterVariable (&sv_airaccelerate);
+       Cvar_RegisterVariable (&sv_airstopaccelerate);
+       Cvar_RegisterVariable (&sv_airstrafeaccelerate);
+       Cvar_RegisterVariable (&sv_maxairstrafespeed);
+       Cvar_RegisterVariable (&sv_aircontrol);
        Cvar_RegisterVariable (&sv_allowdownloads);
        Cvar_RegisterVariable (&sv_allowdownloads_archive);
        Cvar_RegisterVariable (&sv_allowdownloads_config);
@@ -1656,6 +1664,10 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        statsf[STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION] = sv_airaccel_sideways_friction.value;
        statsf[STAT_MOVEVARS_FRICTION] = sv_friction.value;
        statsf[STAT_MOVEVARS_WATERFRICTION] = sv_waterfriction.value >= 0 ? sv_waterfriction.value : sv_friction.value;
+       statsf[STAT_MOVEVARS_AIRSTOPACCELERATE] = sv_airstopaccelerate.value;
+       statsf[STAT_MOVEVARS_AIRSTRAFEACCELERATE] = sv_airstrafeaccelerate.value;
+       statsf[STAT_MOVEVARS_MAXAIRSTRAFESPEED] = sv_maxairstrafespeed.value;
+       statsf[STAT_MOVEVARS_AIRCONTROL] = sv_aircontrol.value;
        statsf[STAT_FRAGLIMIT] = fraglimit.value;
        statsf[STAT_TIMELIMIT] = timelimit.value;