X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=cl_input.c;h=54d3c33d5c84db4bc0b5692061b8a2fd35e040ff;hb=bd730d557d15a38a07b68233590a389bcd7be2d3;hp=c8665b31433ab84a26f6fdff47578b4d1c28eab0;hpb=b190f99e00e475fa3a92395bfa2e44e0cdb54b8a;p=xonotic%2Fdarkplaces.git diff --git a/cl_input.c b/cl_input.c index c8665b31..54d3c33d 100644 --- a/cl_input.c +++ b/cl_input.c @@ -413,6 +413,7 @@ cvar_t cl_backspeed = {CVAR_SAVE, "cl_backspeed","400","backward movement speed" cvar_t cl_sidespeed = {CVAR_SAVE, "cl_sidespeed","350","strafe movement speed"}; cvar_t cl_movespeedkey = {CVAR_SAVE, "cl_movespeedkey","2.0","how much +speed multiplies keyboard movement speed"}; +cvar_t cl_movecliptokeyboard = {0, "cl_movecliptokeyboard", "0", "if set to 1, any move is clipped to the nine keyboard states; if set to 2, only the direction is clipped, not the amount"}; cvar_t cl_yawspeed = {CVAR_SAVE, "cl_yawspeed","140","keyboard yaw turning speed"}; cvar_t cl_pitchspeed = {CVAR_SAVE, "cl_pitchspeed","150","keyboard pitch turning speed"}; @@ -666,6 +667,71 @@ void CL_Input (void) // clamp after the move to prevent rendering with bad angles CL_AdjustAngles (); + + if(cl_movecliptokeyboard.integer) + { + vec_t f = 1; + if (in_speed.state & 1) + f *= cl_movespeedkey.value; + if(cl_movecliptokeyboard.integer == 2) + { + // digital direction, analog amount + vec_t wishvel_x, wishvel_y; + f *= max(cl_sidespeed.value, max(cl_forwardspeed.value, cl_backspeed.value)); + wishvel_x = fabs(cl.cmd.forwardmove); + wishvel_y = fabs(cl.cmd.sidemove); + if(wishvel_x != 0 && wishvel_y != 0 && wishvel_x != wishvel_y) + { + vec_t wishspeed = sqrt(wishvel_x * wishvel_x + wishvel_y * wishvel_y); + if(wishvel_x >= 2 * wishvel_y) + { + // pure X motion + if(cl.cmd.forwardmove > 0) + cl.cmd.forwardmove = wishspeed; + else + cl.cmd.forwardmove = -wishspeed; + cl.cmd.sidemove = 0; + } + else if(wishvel_y >= 2 * wishvel_x) + { + // pure Y motion + cl.cmd.forwardmove = 0; + if(cl.cmd.sidemove > 0) + cl.cmd.sidemove = wishspeed; + else + cl.cmd.sidemove = -wishspeed; + } + else + { + // diagonal + if(cl.cmd.forwardmove > 0) + cl.cmd.forwardmove = 0.70710678118654752440 * wishspeed; + else + cl.cmd.forwardmove = -0.70710678118654752440 * wishspeed; + if(cl.cmd.sidemove > 0) + cl.cmd.sidemove = 0.70710678118654752440 * wishspeed; + else + cl.cmd.sidemove = -0.70710678118654752440 * wishspeed; + } + } + } + else if(cl_movecliptokeyboard.integer) + { + // digital direction, digital amount + if(cl.cmd.sidemove >= cl_sidespeed.value * f * 0.5) + cl.cmd.sidemove = cl_sidespeed.value * f; + else if(cl.cmd.sidemove <= -cl_sidespeed.value * f * 0.5) + cl.cmd.sidemove = -cl_sidespeed.value * f; + else + cl.cmd.sidemove = 0; + if(cl.cmd.forwardmove >= cl_forwardspeed.value * f * 0.5) + cl.cmd.forwardmove = cl_forwardspeed.value * f; + else if(cl.cmd.forwardmove <= -cl_backspeed.value * f * 0.5) + cl.cmd.forwardmove = -cl_backspeed.value * f; + else + cl.cmd.forwardmove = 0; + } + } } #include "cl_collision.h" @@ -826,7 +892,7 @@ void CL_ClientMovement_UpdateStatus(cl_clientmovement_state_t *s) // set onground VectorSet(origin1, s->origin[0], s->origin[1], s->origin[2] + 1); - VectorSet(origin2, s->origin[0], s->origin[1], s->origin[2] - 2); + VectorSet(origin2, s->origin[0], s->origin[1], s->origin[2] - 1); // -2 causes clientside doublejump bug at above 150fps, raising that to 300fps :) trace = CL_Move(origin1, s->mins, s->maxs, origin2, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, true, true, NULL, false); s->onground = trace.fraction < 1 && trace.plane.normal[2] > 0.7; @@ -1915,6 +1981,7 @@ void CL_InitInput (void) Cmd_AddCommand ("cycleweapon", IN_CycleWeapon, "send an impulse number to server to select the next usable weapon out of several (example: 9 4 8) if you are holding one of these, and choose the first one if you are holding none of these"); Cmd_AddCommand ("register_bestweapon", IN_BestWeapon_Register_f, "(for QC usage only) change weapon parameters to be used by bestweapon; stuffcmd this in ClientConnect"); + Cvar_RegisterVariable(&cl_movecliptokeyboard); Cvar_RegisterVariable(&cl_movement); Cvar_RegisterVariable(&cl_movement_minping); Cvar_RegisterVariable(&cl_movement_track_canjump);