+
+ // 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)