3 void _Movetype_Physics_Walk(entity this, float dt) // SV_WalkMove
5 // if frametime is 0 (due to client sending the same timestamp twice), don't move
9 if (GAMEPLAYFIX_UNSTICKPLAYERS(this) == 1)
10 _Movetype_CheckStuck(this);
12 bool applygravity = (!_Movetype_CheckWater(this) && this.move_movetype == MOVETYPE_WALK && !(this.flags & FL_WATERJUMP));
14 _Movetype_CheckVelocity(this);
16 // do a regular slide move unless it looks like you ran into a step
17 bool oldonground = IS_ONGROUND(this);
19 vector start_origin = this.origin;
20 vector start_velocity = this.velocity;
22 if(PHYS_WALLCLIP(this) && this.pm_time)
24 if(dt >= this.pm_time || (this.flags & FL_WATERJUMP))
30 int clip = _Movetype_FlyMove(this, dt, applygravity, false, GAMEPLAYFIX_STEPMULTIPLETIMES(this) ? PHYS_STEPHEIGHT(this) : 0);
32 if (GAMEPLAYFIX_DOWNTRACEONGROUND(this) && !(clip & 1))
34 // only try this if there was no floor in the way in the trace (no,
35 // this check seems to be not REALLY necessary, because if clip & 1,
36 // our trace will hit that thing too)
37 vector upmove = this.origin + '0 0 1';
38 vector downmove = this.origin - '0 0 1';
40 if (this.move_movetype == MOVETYPE_FLYMISSILE)
42 else if (this.move_movetype == MOVETYPE_FLY_WORLDONLY)
43 type = MOVE_WORLDONLY;
44 else if (this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
45 type = MOVE_NOMONSTERS;
46 else type = MOVE_NORMAL;
47 tracebox(upmove, this.mins, this.maxs, downmove, type, this);
48 if (trace_fraction < 1 && trace_plane_normal.z > 0.7)
49 clip |= 1; // but we HAVE found a floor
52 // if the move did not hit the ground at any point, we're not on ground
55 else if(PHYS_WALLCLIP(this) && !this.groundentity && (PHYS_WALLCLIP(this) == 2 || start_velocity.z < -200)) // don't do landing time if we were just going down a slope
58 _Movetype_CheckVelocity(this);
59 _Movetype_LinkEdict(this, true);
61 if (clip & 8) // teleport
64 if (this.flags & FL_WATERJUMP)
67 if (PHYS_NOSTEP(this))
70 vector originalorigin = this.origin;
71 vector originalvelocity = this.velocity;
72 // originalmove_clip = clip;
73 int originalflags = this.flags;
74 entity originalmove_groundentity = this.groundentity;
76 // if move didn't block on a step, return
79 // if move was not trying to move into the step, return
80 if (fabs(start_velocity.x) < 0.03125 && fabs(start_velocity.y) < 0.03125)
83 if (this.move_movetype != MOVETYPE_FLY)
85 // return if gibbed by a trigger
86 if (this.move_movetype != MOVETYPE_WALK)
89 // return if attempting to jump while airborn (unless sv_jumpstep)
90 if (!PHYS_JUMPSTEP(this))
91 if (!oldonground && this.waterlevel == 0)
95 // try moving up and forward to go up a step
97 this.origin = start_origin;
98 this.velocity = start_velocity;
101 vector upmove = '0 0 1' * PHYS_STEPHEIGHT(this);
102 if(!_Movetype_PushEntity(this, upmove, true, true))
104 // we got teleported when upstepping... must abort the move
110 clip = _Movetype_FlyMove(this, dt, applygravity, true, 0);
111 this.velocity_z += start_velocity.z;
114 // we got teleported when upstepping... must abort the move
115 // note that z velocity handling may not be what QC expects here, but we cannot help it
119 _Movetype_CheckVelocity(this);
120 _Movetype_LinkEdict(this, true);
122 // check for stuckness, possibly due to the limited precision of floats
123 // in the clipping hulls
125 && fabs(originalorigin.y - this.origin.y) < 0.03125
126 && fabs(originalorigin.x - this.origin.x) < 0.03125)
128 // Con_Printf("wall\n");
129 // stepping up didn't make any progress, revert to original move
130 this.origin = originalorigin;
131 this.velocity = originalvelocity;
132 // clip = originalmove_clip;
133 this.flags = originalflags;
134 this.groundentity = originalmove_groundentity;
135 // now try to unstick if needed
136 // clip = SV_TryUnstick (ent, oldvel);
140 // Con_Printf("step - ");
142 // extra friction based on view angle
143 if ((clip & 2) && PHYS_WALLFRICTION(this))
144 _Movetype_WallFriction(this, move_stepnormal);
146 // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
147 else if (!GAMEPLAYFIX_STEPDOWN(this) || this.waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0)
148 || !oldonground || IS_ONGROUND(this) || (GAMEPLAYFIX_STEPDOWN_MAXSPEED(this) && vdist(start_velocity, >=, GAMEPLAYFIX_STEPDOWN_MAXSPEED(this)) && !IS_ONSLICK(this)))
154 vector downmove = '0 0 0';
155 downmove.z = -PHYS_STEPHEIGHT(this) + start_velocity.z * dt;
156 if(!_Movetype_PushEntity(this, downmove, true, true))
158 // we got teleported when downstepping... must abort the move
162 if (trace_fraction < 1 && trace_plane_normal.z > 0.7)
164 // this has been disabled so that you can't jump when you are stepping
165 // up while already jumping (also known as the Quake2 double jump bug)
166 // LordHavoc: disabled this check so you can walk on monsters/players
167 //if (PRVM_serveredictfloat(ent, solid) == SOLID_BSP)
168 if(GAMEPLAYFIX_STEPDOWN(this) == 2)
171 this.groundentity = trace_ent;
176 // Con_Printf("slope\n");
177 // if the push down didn't end up on good ground, use the move without
178 // the step up. This happens near wall / slope combinations, and can
179 // cause the player to hop up higher on a slope too steep to climb
180 this.origin = originalorigin;
181 this.velocity = originalvelocity;
182 this.flags = originalflags;
183 this.groundentity = originalmove_groundentity;
186 _Movetype_CheckVelocity(this);
187 _Movetype_LinkEdict(this, true);