+ // walk
+ if (onground && q->jump && canjump)
+ {
+ currentvelocity[2] += movevars_jumpvelocity;
+ onground = false;
+ canjump = false;
+ }
+ if (!q->jump)
+ canjump = true;
+ VectorSet(yawangles, 0, q->viewangles[1], 0);
+ AngleVectors(yawangles, forward, right, up);
+ VectorMAM(q->move[0], forward, q->move[1], right, wishvel);
+ wishspeed = VectorLength(wishvel);
+ if (wishspeed)
+ VectorScale(wishvel, 1 / wishspeed, wishdir);
+ else
+ VectorSet( wishdir, 0.0, 0.0, 0.0 );
+ wishspeed = min(wishspeed, movevars_maxspeed);
+ if (crouch)
+ wishspeed *= 0.5;
+ // check if onground
+ if (onground)
+ {
+ // apply ground friction
+ f = sqrt(currentvelocity[0] * currentvelocity[0] + currentvelocity[1] * currentvelocity[1]);
+ edgefriction = 1;
+ if (f > 0)
+ {
+ VectorSet(currentorigin2, currentorigin[0] + currentvelocity[0]*(16/f), currentorigin[1] + currentvelocity[1]*(16/f), currentorigin[2] + playermins[2]);
+ VectorSet(neworigin2, currentorigin2[0], currentorigin2[1], currentorigin2[2] - 34);
+ trace = CL_TraceBox(currentorigin2, vec3_origin, vec3_origin, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
+ if (trace.fraction == 1)
+ edgefriction = movevars_edgefriction;
+ }
+ // apply friction
+ f = 1 - frametime * edgefriction * ((f < movevars_stopspeed) ? (movevars_stopspeed / f) : 1) * movevars_friction;
+ f = max(f, 0);
+ VectorScale(currentvelocity, f, currentvelocity);
+ }
+ else
+ {
+ // apply air speed limit
+ wishspeed = min(wishspeed, movevars_maxairspeed);
+ }
+ if (gamemode == GAME_NEXUIZ)
+ addspeed = wishspeed;
+ else
+ addspeed = wishspeed - DotProduct(currentvelocity, wishdir);
+ if (addspeed > 0)