diff --git a/source/cl_pred.c b/source/cl_pred.c index 4f86633..9862ea9 100644 --- a/source/cl_pred.c +++ b/source/cl_pred.c @@ -95,6 +95,7 @@ void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, pmove.waterjumptime = from->waterjumptime; pmove.dead = cl.stats[STAT_HEALTH] <= 0; pmove.spectator = spectator; + pmove.flying = cl.stats[STAT_FLYMODE]; pmove.cmd = *u; diff --git a/source/pmove.c b/source/pmove.c index 5f2381d..87b9e91 100644 --- a/source/pmove.c +++ b/source/pmove.c @@ -232,6 +232,51 @@ int PM_FlyMove (void) return blocked; } + +void PM_Accelerate (vec3_t, float, float); + +/* + PM_FlymodeMove + + Pre-PM_FlyMove function for MOVETYPE_FLY players. Could have altered + other physics to fit this in, but that's to easy to screw up. --KB +*/ +void +PM_FlymodeMove ( void ) +{ + vec3_t start, dest, pmvel, pmtmp; + pmtrace_t trace; + float pmspeed; + + pmvel[0] = forward[0]*pmove.cmd.forwardmove + right[0]*pmove.cmd.sidemove; + pmvel[1] = forward[1]*pmove.cmd.forwardmove + right[1]*pmove.cmd.sidemove; + pmvel[2] = forward[2]*pmove.cmd.forwardmove + right[2]*pmove.cmd.sidemove + + pmove.cmd.upmove; + + VectorCopy (pmvel, pmtmp); + pmspeed = VectorNormalize(pmtmp); // don't alter pmvel + + if (pmspeed > movevars.maxspeed) // there IS a spoon, Neo.. + { + VectorScale (pmvel, movevars.maxspeed / pmspeed, pmvel); + pmspeed = movevars.maxspeed; + } + PM_Accelerate (pmtmp, pmspeed, movevars.wateraccelerate); + + VectorMA (pmove.origin, frametime, pmove.velocity, dest); + VectorCopy (dest, start); + start[2] += STEPSIZE + 1; + trace = PM_PlayerMove (start, dest); + if (!trace.startsolid && !trace.allsolid) + { + VectorCopy (trace.endpos, pmove.origin); + return; // just step up + } + + PM_FlyMove (); // NOW we fly. +} + + /* ============= PM_GroundMove @@ -332,7 +377,7 @@ Handles both ground friction and water friction void PM_Friction (void) { float *vel; - float speed, newspeed, control; + float speed, newspeed; float friction; float drop; vec3_t start, stop; @@ -371,12 +416,10 @@ void PM_Friction (void) if (waterlevel >= 2) // apply water friction drop += speed*movevars.waterfriction*waterlevel*frametime; + else if (pmove.flying) // apply flying friction + drop += max(movevars.stopspeed, speed) * friction * frametime; else if (onground != -1) // apply ground friction - { - control = speed < movevars.stopspeed ? movevars.stopspeed : speed; - drop += control*friction*frametime; - } - + drop += max(movevars.stopspeed, speed) * friction * frametime; // scale the velocity newspeed = speed - drop; @@ -550,9 +593,12 @@ void PM_AirMove (void) PM_Accelerate (wishdir, wishspeed, movevars.accelerate); pmove.velocity[2] -= movevars.entgravity * movevars.gravity * frametime; PM_GroundMove (); - } - else - { // not on ground, so little effect on velocity + } else if (pmove.flying) + { + PM_AirAccelerate (wishdir, wishspeed, movevars.accelerate); + PM_FlyMove (); + } else { + // not on ground, so little effect on velocity PM_AirAccelerate (wishdir, wishspeed, movevars.accelerate); // add gravity @@ -702,7 +748,7 @@ void CheckWaterJump (void) int cont; vec3_t flatforward; - if (pmove.waterjumptime) + if (pmove.waterjumptime || pmove.flying) return; // ZOID, don't hop out if we just jumped in @@ -900,6 +946,8 @@ void PlayerMove (void) if (waterlevel >= 2) PM_WaterMove (); + else if (pmove.flying) + PM_FlymodeMove (); else PM_AirMove (); diff --git a/source/sv_main.c b/source/sv_main.c index 2718c8e..b2647c1 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -1374,12 +1374,12 @@ void SV_InitLocal (void) for (i=0 ; iv.items | ((int)pr_global_struct->serverflags << 28); + // Extensions to the QW 2.40 protocol for MegaTF --KB + stats[STAT_VIEWHEIGHT] = (int)ent->v.view_ofs[2]; + stats[STAT_FLYMODE] = (ent->v.movetype == MOVETYPE_FLY); + for (i=0 ; istats[i]) { diff --git a/source/sv_user.c b/source/sv_user.c index 0a17f12..aed8ff3 100644 --- a/source/sv_user.c +++ b/source/sv_user.c @@ -1435,6 +1435,7 @@ void SV_RunCmd (usercmd_t *ucmd) VectorCopy (sv_player->v.velocity, pmove.velocity); VectorCopy (sv_player->v.v_angle, pmove.angles); + pmove.flying = sv_player->v.movetype == MOVETYPE_FLY; pmove.spectator = host_client->spectator; pmove.waterjumptime = sv_player->v.teleport_time; pmove.numphysent = 1;