void Physics_AddStats()
{
+ // static view offset and hitbox vectors
+ // networked for all you bandwidth pigs out there
+ addstat(STAT_PL_VIEW_OFS1, AS_FLOAT, stat_pl_view_ofs_x);
+ addstat(STAT_PL_VIEW_OFS2, AS_FLOAT, stat_pl_view_ofs_y);
+ addstat(STAT_PL_VIEW_OFS3, AS_FLOAT, stat_pl_view_ofs_z);
+ addstat(STAT_PL_CROUCH_VIEW_OFS1, AS_FLOAT, stat_pl_crouch_view_ofs_x);
+ addstat(STAT_PL_CROUCH_VIEW_OFS2, AS_FLOAT, stat_pl_crouch_view_ofs_y);
+ addstat(STAT_PL_CROUCH_VIEW_OFS3, AS_FLOAT, stat_pl_crouch_view_ofs_z);
+
+ addstat(STAT_PL_MIN1, AS_FLOAT, stat_pl_min_x);
+ addstat(STAT_PL_MIN2, AS_FLOAT, stat_pl_min_y);
+ addstat(STAT_PL_MIN3, AS_FLOAT, stat_pl_min_z);
+ addstat(STAT_PL_MAX1, AS_FLOAT, stat_pl_max_x);
+ addstat(STAT_PL_MAX2, AS_FLOAT, stat_pl_max_y);
+ addstat(STAT_PL_MAX3, AS_FLOAT, stat_pl_max_z);
+ addstat(STAT_PL_CROUCH_MIN1, AS_FLOAT, stat_pl_crouch_min_x);
+ addstat(STAT_PL_CROUCH_MIN2, AS_FLOAT, stat_pl_crouch_min_y);
+ addstat(STAT_PL_CROUCH_MIN3, AS_FLOAT, stat_pl_crouch_min_z);
+ addstat(STAT_PL_CROUCH_MAX1, AS_FLOAT, stat_pl_crouch_max_x);
+ addstat(STAT_PL_CROUCH_MAX2, AS_FLOAT, stat_pl_crouch_max_y);
+ addstat(STAT_PL_CROUCH_MAX3, AS_FLOAT, stat_pl_crouch_max_z);
+
// g_movementspeed hack
addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw);
addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed);
addstat(STAT_MOVEVARS_FRICTION_ONLAND, AS_FLOAT, stat_sv_friction_on_land);
addstat(STAT_MOVEVARS_FRICTION_SLICK, AS_FLOAT, stat_sv_friction_slick);
addstat(STAT_GAMEPLAYFIX_EASIERWATERJUMP, AS_INT, stat_gameplayfix_easierwaterjump);
+
+ addstat(STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, AS_INT, stat_gameplayfix_upvelocityclearsonground);
}
void Physics_UpdateStats(float maxspd_mod)
{
+ // blah
+ self.stat_pl_view_ofs = PL_VIEW_OFS;
+ self.stat_pl_crouch_view_ofs = PL_CROUCH_VIEW_OFS;
+
+ self.stat_pl_min = PL_MIN;
+ self.stat_pl_max = PL_MAX;
+ self.stat_pl_crouch_min = PL_CROUCH_MIN;
+ self.stat_pl_crouch_max = PL_CROUCH_MAX;
+
self.stat_sv_airaccel_qw = AdjustAirAccelQW(autocvar_sv_airaccel_qw, maxspd_mod);
if (autocvar_sv_airstrafeaccel_qw)
self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(autocvar_sv_airstrafeaccel_qw, maxspd_mod);
self.stat_sv_friction_slick = PHYS_FRICTION_SLICK;
self.stat_gameplayfix_easierwaterjump = GAMEPLAYFIX_EASIERWATERJUMP;
+
+ self.stat_gameplayfix_upvelocityclearsonground = UPWARD_VELOCITY_CLEARS_ONGROUND;
}
#endif
-float IsMoveInDirection(vector mv, float angle) // key mix factor
+float IsMoveInDirection(vector mv, float ang) // key mix factor
{
if (mv_x == 0 && mv_y == 0)
return 0; // avoid division by zero
- angle -= RAD2DEG * atan2(mv_y, mv_x);
- angle = remainder(angle, 360) / 45;
- return angle > 1 ? 0 : angle < -1 ? 0 : 1 - fabs(angle);
+ ang -= RAD2DEG * atan2(mv_y, mv_x);
+ ang = remainder(ang, 360) / 45;
+ return ang > 1 ? 0 : ang < -1 ? 0 : 1 - fabs(ang);
}
float GeomLerp(float a, float lerp, float b)
origin1_z += self.mins_z + 1;
self.waterlevel = WATERLEVEL_NONE;
- self.watertype = (pointcontents(origin1) == CONTENT_WATER);
+ int thepoint = pointcontents(origin1);
+
+ self.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME);
if(self.watertype)
{
self.waterlevel = WATERLEVEL_WETFEET;
origin1_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5;
- if(pointcontents(origin1) == CONTENT_WATER)
+ thepoint = pointcontents(origin1);
+ if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
{
self.waterlevel = WATERLEVEL_SWIMMING;
origin1_z = self.origin_z + 22;
- if(pointcontents(origin1) == CONTENT_WATER)
+ thepoint = pointcontents(origin1);
+ if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME)
self.waterlevel = WATERLEVEL_SUBMERGED;
}
}
void PM_ClientMovement_Move()
{
#ifdef CSQC
- float t = PHYS_INPUT_TIMELENGTH;
- vector primalvelocity = self.velocity;
+ int bump;
+ float t;
+ float f;
+ vector neworigin;
+ vector currentorigin2;
+ vector neworigin2;
+ vector primalvelocity;
+
+ vector trace1_endpos = '0 0 0';
+ vector trace2_endpos = '0 0 0';
+ vector trace3_endpos = '0 0 0';
+ float trace1_fraction = 0;
+ float trace2_fraction = 0;
+ float trace3_fraction = 0;
+ vector trace1_plane_normal = '0 0 0';
+ vector trace2_plane_normal = '0 0 0';
+ vector trace3_plane_normal = '0 0 0';
+
+
PM_ClientMovement_UpdateStatus(false);
- float bump = 0;
- for (bump = 0; bump < MAX_CLIP_PLANES && (self.velocity * self.velocity) > 0; bump++)
+ primalvelocity = self.velocity;
+ for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++)
{
- vector neworigin = self.origin + t * self.velocity;
+ neworigin = self.origin + t * self.velocity;
tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self);
- float old_trace1_fraction = trace_fraction;
- vector old_trace1_endpos = trace_endpos;
- vector old_trace1_plane_normal = trace_plane_normal;
- if (trace_fraction < 1 && trace_plane_normal_z == 0)
+ trace1_endpos = trace_endpos;
+ trace1_fraction = trace_fraction;
+ trace1_plane_normal = trace_plane_normal;
+ if(trace1_fraction < 1 && trace1_plane_normal_z == 0)
{
// may be a step or wall, try stepping up
// first move forward at a higher level
- vector currentorigin2 = self.origin;
+ currentorigin2 = self.origin;
currentorigin2_z += PHYS_STEPHEIGHT;
- vector neworigin2 = neworigin;
- neworigin2_z = self.origin_z + PHYS_STEPHEIGHT;
+ neworigin2 = neworigin;
+ neworigin2_z += PHYS_STEPHEIGHT;
tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
- if (!trace_startsolid)
+ trace2_endpos = trace_endpos;
+ trace2_fraction = trace_fraction;
+ trace2_plane_normal = trace_plane_normal;
+ if(!trace_startsolid)
{
// then move down from there
- currentorigin2 = trace_endpos;
- neworigin2 = trace_endpos;
+ currentorigin2 = trace2_endpos;
+ neworigin2 = trace2_endpos;
neworigin2_z = self.origin_z;
- float old_trace2_fraction = trace_fraction;
- vector old_trace2_plane_normal = trace_plane_normal;
tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
+ trace3_endpos = trace_endpos;
+ trace3_fraction = trace_fraction;
+ trace3_plane_normal = trace_plane_normal;
// accept the new trace if it made some progress
- if (fabs(trace_endpos_x - old_trace1_endpos_x) >= 0.03125 || fabs(trace_endpos_y - old_trace1_endpos_y) >= 0.03125)
- {
- trace_fraction = old_trace2_fraction;
- trace_endpos = trace_endpos;
- trace_plane_normal = old_trace2_plane_normal;
- }
- else
+ if(fabs(trace3_endpos_x - trace1_endpos_x) >= 0.03125 || fabs(trace3_endpos_y - trace1_endpos_y) >= 0.03125)
{
- trace_fraction = old_trace1_fraction;
- trace_endpos = old_trace1_endpos;
- trace_plane_normal = old_trace1_plane_normal;
+ trace1_endpos = trace2_endpos;
+ trace1_fraction = trace2_fraction;
+ trace1_plane_normal = trace2_plane_normal;
+ trace1_endpos = trace3_endpos;
}
}
}
// check if it moved at all
- if (trace_fraction >= 0.001)
- setorigin(self, trace_endpos);
+ if(trace1_fraction >= 0.001)
+ setorigin(self, trace1_endpos);
// check if it moved all the way
- if (trace_fraction == 1)
+ if(trace1_fraction == 1)
break;
// this is only really needed for nogravityonground combined with gravityunaffectedbyticrate
// <LordHavoc> I'm pretty sure I commented it out solely because it seemed redundant
// this got commented out in a change that supposedly makes the code match QW better
- // so if this is broken, maybe put it in an if (cls.protocol != PROTOCOL_QUAKEWORLD) block
- if (trace_plane_normal_z > 0.7)
+ // so if this is broken, maybe put it in an if(cls.protocol != PROTOCOL_QUAKEWORLD) block
+ if(trace1_plane_normal_z > 0.7)
SET_ONGROUND(self);
- t -= t * trace_fraction;
+ t -= t * trace1_fraction;
- float f = self.velocity * trace_plane_normal;
- self.velocity -= f * trace_plane_normal;
+ f = (self.velocity * trace1_plane_normal);
+ self.velocity = self.velocity + -f * trace1_plane_normal;
}
- if (pmove_waterjumptime > 0)
+ if(pmove_waterjumptime > 0)
self.velocity = primalvelocity;
#endif
}
void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
{
- float k = 32 * (2 * IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), 0) - 1);
+ float k = 32 * (2 * IsMoveInDirection(self.movement, 0) - 1);
if (k <= 0)
return;
returns true if handled
=============
*/
-float PlayerJump (void)
+bool PlayerJump (void)
{
if (PHYS_FROZEN(self))
return true; // no jumping in freezetag when frozen
return true; // no jumping while blocked
#endif
- float doublejump = false;
+ bool doublejump = false;
float mjumpheight = PHYS_JUMPVELOCITY;
player_multijump = doublejump;
if (!WAS_ONGROUND(self))
{
+#ifdef SVQC
if(autocvar_speedmeter)
dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+#endif
if(self.lastground < time - 0.3)
{
self.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
self.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
}
+#ifdef SVQC
if(self.jumppadcount > 1)
dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
self.jumppadcount = 0;
+#endif
}
self.velocity_z += mjumpheight;
void CheckWaterJump()
{
// check for a jump-out-of-water
- makevectors(PHYS_INPUT_ANGLES(self));
+ makevectors(self.v_angle);
vector start = self.origin;
start_z += 8;
v_forward_z = 0;
if (trace_fraction == 1)
{ // open at eye level
self.velocity_z = 225;
-#ifdef SVQC
self.flags |= FL_WATERJUMP;
SET_JUMP_HELD(self);
+#ifdef SVQC
self.teleport_time = time + 2; // safety net
+#elif defined(CSQC)
+ pmove_waterjumptime = time + 2;
#endif
}
}
float was_flying = ITEMS(self) & IT_USING_JETPACK;
#endif
if (JETPACK_JUMP(self) < 2)
-#ifdef SVQC
ITEMS(self) &= ~IT_USING_JETPACK;
-#endif
if(PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self))
{
-#ifdef SVQC
float air_jump = !PlayerJump() || self.multijump_count > 0; // PlayerJump() has important side effects
float activate = JETPACK_JUMP(self) && air_jump && PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self);
- float has_fuel = !autocvar_g_jetpack_fuel || self.ammo_fuel || ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO;
-#else
- PlayerJump(); // Client only
- float has_fuel = true; // TODO
-#endif
+ float has_fuel = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) || ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO;
+
if (!(ITEMS(self) & IT_JETPACK)) { }
else if (self.jetpack_stopped) { }
else if (!has_fuel)
Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
#endif
self.jetpack_stopped = true;
-#ifdef SVQC
ITEMS(self) &= ~IT_USING_JETPACK;
-#endif
}
-#ifdef SVQC
else if (activate && !PHYS_FROZEN(self))
ITEMS(self) |= IT_USING_JETPACK;
-#endif
}
else
{
self.jetpack_stopped = false;
-#ifdef SVQC
ITEMS(self) &= ~IT_USING_JETPACK;
-#endif
}
if (!PHYS_INPUT_BUTTON_JUMP(self))
UNSET_JUMP_HELD(self);
vector rigvel;
vector angles_save = self.angles;
- float accel = bound(-1, PHYS_INPUT_MOVEVALUES(self).x / PHYS_MAXSPEED(self), 1);
- float steer = bound(-1, PHYS_INPUT_MOVEVALUES(self).y / PHYS_MAXSPEED(self), 1);
+ float accel = bound(-1, self.movement.x / PHYS_MAXSPEED(self), 1);
+ float steer = bound(-1, self.movement.y / PHYS_MAXSPEED(self), 1);
if (g_bugrigs_reverse_speeding)
{
if (self.nickspamcount >= autocvar_g_nick_flood_penalty_yellow)
{
// slight annoyance for nick change scripts
- PHYS_INPUT_MOVEVALUES(self) = -1 * PHYS_INPUT_MOVEVALUES(self);
+ self.movement = -1 * self.movement;
self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
if (self.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
{
- PHYS_INPUT_ANGLES(self)_x = random() * 360;
- PHYS_INPUT_ANGLES(self)_y = random() * 360;
+ self.v_angle_x = random() * 360;
+ self.v_angle_y = random() * 360;
// at least I'm not forcing retardedview by also assigning to angles_z
self.fixangle = true;
}
#endif
)
{
- PHYS_INPUT_MOVEVALUES(self)_x = bound(-5, PHYS_INPUT_MOVEVALUES(self).x, 5);
- PHYS_INPUT_MOVEVALUES(self)_y = bound(-5, PHYS_INPUT_MOVEVALUES(self).y, 5);
- PHYS_INPUT_MOVEVALUES(self)_z = bound(-5, PHYS_INPUT_MOVEVALUES(self).z, 5);
+ self.movement_x = bound(-5, self.movement.x, 5);
+ self.movement_y = bound(-5, self.movement.y, 5);
+ self.movement_z = bound(-5, self.movement.z, 5);
}
else
- PHYS_INPUT_MOVEVALUES(self) = '0 0 0';
+ self.movement = '0 0 0';
vector midpoint = ((self.absmin + self.absmax) * 0.5);
if (pointcontents(midpoint) == CONTENT_WATER)
#ifdef SVQC
if (!self.player_blocked)
return;
- PHYS_INPUT_MOVEVALUES(self) = '0 0 0';
+ self.movement = '0 0 0';
self.disableclientprediction = 1;
#endif
}
UNSET_ONGROUND(self);
self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
- makevectors(PHYS_INPUT_ANGLES(self));
- //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
- vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
- + v_right * PHYS_INPUT_MOVEVALUES(self).y
- + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
+ makevectors(self.v_angle);
+ //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z;
+ vector wishvel = v_forward * self.movement.x
+ + v_right * self.movement.y
+ + '0 0 1' * self.movement.z;
// acceleration
vector wishdir = normalize(wishvel);
float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
+#ifdef SVQC
if (time >= self.teleport_time)
+#endif
PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
+ PM_ClientMovement_Move();
}
void PM_swim(float maxspd_mod)
// this mimics quakeworld code
if (jump && self.waterlevel == WATERLEVEL_SWIMMING && self.velocity_z >= -180)
{
- vector yawangles = '0 1 0' * PHYS_INPUT_ANGLES(self).y;
+ vector yawangles = '0 1 0' * self.v_angle.y;
makevectors(yawangles);
vector forward = v_forward;
vector spot = self.origin + 24 * forward;
}
}
}
- makevectors(PHYS_INPUT_ANGLES(self));
- //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
- vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
- + v_right * PHYS_INPUT_MOVEVALUES(self).y
- + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z;
+ makevectors(self.v_angle);
+ //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z;
+ vector wishvel = v_forward * self.movement.x
+ + v_right * self.movement.y
+ + '0 0 1' * self.movement.z;
if (wishvel == '0 0 0')
wishvel = '0 0 -60'; // drift towards bottom
#endif
}
}
- PM_ClientMovement_Move();
// water acceleration
PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
+ PM_ClientMovement_Move();
}
void PM_ladder(float maxspd_mod)
}
self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION);
- makevectors(PHYS_INPUT_ANGLES(self));
- //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z;
- vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self)_x
- + v_right * PHYS_INPUT_MOVEVALUES(self)_y
- + '0 0 1' * PHYS_INPUT_MOVEVALUES(self)_z;
+ makevectors(self.v_angle);
+ //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z;
+ vector wishvel = v_forward * self.movement_x
+ + v_right * self.movement_y
+ + '0 0 1' * self.movement_z;
self.velocity_z += g;
if (self.ladder_entity.classname == "func_water")
{
// acceleration
vector wishdir = normalize(wishvel);
float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod);
- PM_ClientMovement_Move();
#ifdef SVQC
if (time >= self.teleport_time)
#endif
// water acceleration
PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
+ PM_ClientMovement_Move();
}
void PM_jetpack(float maxspd_mod)
{
- //makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
- makevectors(PHYS_INPUT_ANGLES(self));
- vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self)_x
- + v_right * PHYS_INPUT_MOVEVALUES(self)_y;
+ //makevectors(self.v_angle.y * '0 1 0');
+ makevectors(self.v_angle);
+ vector wishvel = v_forward * self.movement_x
+ + v_right * self.movement_y;
// add remaining speed as Z component
float maxairspd = PHYS_MAXAIRSPEED * max(1, maxspd_mod);
// fix speedhacks :P
self.velocity_z -= g * 0.5;
#endif
}
-#ifdef SVQC
-void SV_WalkMove ()
-{
- // if PHYS_INPUT_TIMELENGTH is 0 (due to client sending the same timestamp twice),
- // don't move
- if (PHYS_INPUT_TIMELENGTH <= 0)
- return;
-
-// if (autocvar_sv_gameplayfix_unstickplayers)
-// SV_CheckStuck (self);
-
-// applygravity = !SV_CheckWater(self) && self.movetype == MOVETYPE_WALK && !(self.flags & FL_WATERJUMP);
-// hitsupercontentsmask = SV_GenericHitSuperContentsMask(self);
-
-// SV_CheckVelocity(self);
-
- // do a regular slide move unless it looks like you ran into a step
-// float oldonground = self.flags & FL_ONGROUND;
-
- vector start_origin = self.origin;
- vector start_velocity = self.velocity;
-
- float clip = 0;
-// clip = SV_FlyMove (self, PHYS_INPUT_TIMELENGTH, applygravity, NULL, hitsupercontentsmask, sv_gameplayfix_stepmultipletimes.integer ? sv_stepheight.value : 0);
-
-// if(sv_gameplayfix_downtracesupportsongroundflag.integer)
-// if(!(clip & 1))
- {
- // only try this if there was no floor in the way in the trace (no,
- // this check seems to be not REALLY necessary, because if clip & 1,
- // our trace will hit that thing too)
- vector upmove = self.origin;
- upmove_z++;
- vector downmove = self.origin;
- upmove_z--;
- float type;
- if (self.movetype == MOVETYPE_FLYMISSILE)
- type = MOVE_MISSILE;
- else if (self.movetype == MOVETYPE_FLY_WORLDONLY)
- type = MOVE_WORLDONLY;
- else if (self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT)
- type = MOVE_NOMONSTERS; // only clip against bmodels
- else
- type = MOVE_NORMAL;
- vector entmins = self.mins;
- vector entmaxs = self.maxs;
- tracebox(upmove, entmins, entmaxs, downmove, type, self);
- if(trace_fraction < 1 && trace_plane_normal_z > 0.7)
- clip |= 1; // but we HAVE found a floor
- }
-
- // if the move did not hit the ground at any point, we're not on ground
-// if(!(clip & 1))
-// self.flags = self.flags & ~FL_ONGROUND;
-
-// SV_CheckVelocity(self);
-// SV_LinkEdict(self);
-// SV_LinkEdict_TouchAreaGrid(self);
-
- if(clip & 8) // teleport
- return;
-
- if (self.flags & FL_WATERJUMP)
- return;
-
-// if (autocvar_sv_nostep)
-// return;
-
- vector originalmove_origin = self.origin;
- vector originalmove_velocity = self.velocity;
- float originalmove_flags = self.flags;
- entity originalmove_groundentity = self.groundentity;
-
- // if move didn't block on a step, return
- if (clip & 2)
- {
- // if move was not trying to move into the step, return
- if (fabs(start_velocity_x) < 0.03125 && fabs(start_velocity_y) < 0.03125)
- return;
-
- if (self.movetype != MOVETYPE_FLY)
- {
- // return if gibbed by a trigger
- if (self.movetype != MOVETYPE_WALK)
- return;
-
- // return if attempting to jump while airborn (unless sv_jumpstep)
-// if (!autocvar_sv_jumpstep)
-// if (!oldonground && PRVM_serveredictfloat(self, waterlevel) == 0)
-// return;
- }
-
- // try moving up and forward to go up a step
- // back to start pos
- setorigin(self, start_origin);
- self.velocity = start_velocity;
-
- // move up
- vector upmove = '0 0 0';
- upmove_z = autocvar_sv_stepheight;
-// if(!SV_PushEntity(&trace, self, upmove, true))
-// {
-// // we got teleported when upstepping... must abort the move
-// return;
-// }
-
- // move forward
- self.velocity_z = 0;
-// clip = SV_FlyMove (self, PHYS_INPUT_TIMELENGTH, applygravity, stepnormal, hitsupercontentsmask, 0);
- self.velocity_z += start_velocity_z;
-// if(clip & 8)
-// {
-// // we got teleported when upstepping... must abort the move
-// // note that z velocity handling may not be what QC expects here, but we cannot help it
-// return;
-// }
-
-// SV_CheckVelocity(self);
-// SV_LinkEdict(self);
-// SV_LinkEdict_TouchAreaGrid(self);
-
- // check for stuckness, possibly due to the limited precision of floats
- // in the clipping hulls
- if (clip
- && fabs(originalmove_origin_y - self.origin_y < 0.03125)
- && fabs(originalmove_origin_x - self.origin_x < 0.03125))
- {
- //Con_Printf("wall\n");
- // stepping up didn't make any progress, revert to original move
- setorigin(self, originalmove_origin);
- self.velocity = originalmove_velocity;
- self.flags = originalmove_flags;
- self.groundentity = originalmove_groundentity;
- return;
- }
-
- //Con_Printf("step - ");
-
- // extra friction based on view angle
-// if (clip & 2 && sv_wallfriction.integer)
-// SV_WallFriction (self, stepnormal);
- }
- // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
-// else if (!autocvar_sv_gameplayfix_stepdown || self.waterlevel >= 3 || start_velocity_z >= (1.0 / 32.0) || !oldonground || (self.flags & FL_ONGROUND))
-// return;
-
- // move down
- vector downmove = '0 0 0';
- downmove_z = -autocvar_sv_stepheight + start_velocity_z*PHYS_INPUT_TIMELENGTH;
-// if(!SV_PushEntity (&downtrace, self, downmove, true))
-// {
-// // we got teleported when downstepping... must abort the move
-// return;
-// }
-
- if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
- {
- // this has been disabled so that you can't jump when you are stepping
- // up while already jumping (also known as the Quake2 double jump bug)
- }
- else
- {
- //Con_Printf("slope\n");
- // if the push down didn't end up on good ground, use the move without
- // the step up. This happens near wall / slope combinations, and can
- // cause the player to hop up higher on a slope too steep to climb
- setorigin(self, originalmove_origin);
- self.velocity = originalmove_velocity;
- self.flags = originalmove_flags;
- self.groundentity = originalmove_groundentity;
- }
-
-// SV_CheckVelocity(self);
-// SV_LinkEdict(self);
-// SV_LinkEdict_TouchAreaGrid(self);
-}
-#endif
void PM_walk(float buttons_prev, float maxspd_mod)
{
if (!WAS_ONGROUND(self))
{
+#ifdef SVQC
if (autocvar_speedmeter)
dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
+#endif
if (self.lastground < time - 0.3)
self.velocity *= (1 - PHYS_FRICTION_ONLAND);
+#ifdef SVQC
if (self.jumppadcount > 1)
dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
self.jumppadcount = 0;
+#endif
}
+
// walking
- makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
- vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
- + v_right * PHYS_INPUT_MOVEVALUES(self).y;
+ makevectors(self.v_angle.y * '0 1 0');
+ vector wishvel = v_forward * self.movement.x
+ + v_right * self.movement.y;
// acceleration
vector wishdir = normalize(wishvel);
float wishspeed = vlen(wishvel);
void PM_air(float buttons_prev, float maxspd_mod)
{
- makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
- vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
- + v_right * PHYS_INPUT_MOVEVALUES(self).y;
+ makevectors(self.v_angle.y * '0 1 0');
+ vector wishvel = v_forward * self.movement.x
+ + v_right * self.movement.y;
// acceleration
vector wishdir = normalize(wishvel);
float wishspeed = vlen(wishvel);
// dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
// log dv/dt = logaccel + logmaxspeed (when slow)
// log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
- float strafity = IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), -90) + IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), +90); // if one is nonzero, other is always zero
+ float strafity = IsMoveInDirection(self.movement, -90) + IsMoveInDirection(self.movement, +90); // if one is nonzero, other is always zero
if (PHYS_MAXAIRSTRAFESPEED)
wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod));
if (PHYS_AIRSTRAFEACCELERATE)
(1 - GeomLerp(1 - fabs(PHYS_AIRACCEL_QW(self)), strafity, 1 - fabs(PHYS_AIRSTRAFEACCEL_QW(self))));
// !CPM
- if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && PHYS_INPUT_MOVEVALUES(self).y == 0 && PHYS_INPUT_MOVEVALUES(self).x != 0)
+ if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && self.movement.y == 0 && self.movement.x != 0)
PM_AirAccelerate(wishdir, wishspeed2);
else
PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(self), PHYS_AIRACCEL_SIDEWAYS_FRICTION / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(self));
void PM_Main()
{
- float buttons = PHYS_INPUT_BUTTON_MASK(self);
+ int buttons = PHYS_INPUT_BUTTON_MASK(self);
#ifdef CSQC
+ self.items = getstati(STAT_ITEMS, 0, 24);
+
+ self.movement = PHYS_INPUT_MOVEVALUES(self);
+
+ self.v_angle = PHYS_INPUT_ANGLES(self);
+ self.angles = PHYS_WORLD_ANGLES(self);
+
self.team = myteam + 1; // is this correct?
if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
UNSET_JUMP_HELD(self); // canjump = true
#ifdef SVQC
if (sv_maxidle > 0)
{
- if (buttons != self.buttons_old || PHYS_INPUT_MOVEVALUES(self) != self.movement_old || PHYS_INPUT_ANGLES(self) != self.v_angle_old)
+ if (buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
self.parm_idlesince = time;
}
#endif
- float buttons_prev = self.buttons_old;
+ int buttons_prev = self.buttons_old;
self.buttons_old = buttons;
- self.movement_old = PHYS_INPUT_MOVEVALUES(self);
- self.v_angle_old = PHYS_INPUT_ANGLES(self);
+ self.movement_old = self.movement;
+ self.v_angle_old = self.v_angle;
PM_check_nickspam();
self.race_penalty = 0;
#endif
- float not_allowed_to_move = 0;
+ bool not_allowed_to_move = false;
#ifdef SVQC
if (self.race_penalty)
- not_allowed_to_move = 1;
+ not_allowed_to_move = true;
#endif
#ifdef SVQC
if (time < game_starttime)
- not_allowed_to_move = 1;
+ not_allowed_to_move = true;
#endif
if (not_allowed_to_move)
#ifdef SVQC
if (!IS_PLAYER(self))
{
- maxspeed_mod *= autocvar_sv_spectator_speed_multiplier;
+ maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
if (!self.spectatorspeed)
self.spectatorspeed = maxspeed_mod;
if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229))
} // otherwise just clear
self.impulse = 0;
}
- maxspeed_mod *= self.spectatorspeed;
+ maxspeed_mod = self.spectatorspeed;
+ }
+
+ float spd = max(PHYS_MAXSPEED(self), PHYS_MAXAIRSPEED) * maxspeed_mod;
+ if(self.speed != spd)
+ {
+ self.speed = spd;
+ string temps = ftos(spd);
+ stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
+ stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
+ stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
+ stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
}
#endif
#ifdef SVQC
if (!self.fixangle && !g_bugrigs)
- self.angles = '0 1 0' * PHYS_INPUT_ANGLES(self).y;
+ self.angles = '0 1 0' * self.v_angle.y;
#endif
PM_check_hitground();
if (IS_PLAYER(self))
CheckPlayerJump();
- if (self.flags & /* FL_WATERJUMP */ 2048)
+ if (self.flags & FL_WATERJUMP)
{
self.velocity_x = self.movedir_x;
self.velocity_y = self.movedir_y;
if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
{
- self.flags &= ~/* FL_WATERJUMP */ 2048;
+ self.flags &= ~FL_WATERJUMP;
self.teleport_time = 0;
}
}
RaceCarPhysics();
#endif
- else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)
+ else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY || (BUFFS(self) & BUFF_FLIGHT))
PM_fly(maxspeed_mod);
else if (self.waterlevel >= WATERLEVEL_SWIMMING)
if(self.conveyor.state)
self.velocity += self.conveyor.movedir;
- self.lastflags = FLAGS(self);
+ self.lastflags = self.flags;
self.lastclassname = self.classname;
}
PM_Main();
#ifdef CSQC
- pmove_org = self.origin;
- pmove_vel = self.velocity;
+ self.pmove_flags =
+ ((self.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
+ (!(self.flags & FL_JUMPRELEASED) ? 0 : PMF_JUMP_HELD) |
+ ((self.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
#endif
}