]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bring it back (apparently, pmove_flags is not set by QC yet)
authorMario <zacjardine@y7mail.com>
Tue, 9 Dec 2014 12:52:13 +0000 (23:52 +1100)
committerMario <zacjardine@y7mail.com>
Tue, 9 Dec 2014 12:53:52 +0000 (23:53 +1100)
qcsrc/common/physics.qc

index 095467186a320e7b8521379f396016ac54f19ed5..6a55d6969531e3ff30b1c387d2e24ca5f588101f 100644 (file)
@@ -186,6 +186,81 @@ void CSQC_ClientMovement_Unstick()
        }
 }
 
+void CSQC_ClientMovement_UpdateStatus()
+{
+       // make sure player is not stuck
+       CSQC_ClientMovement_Unstick();
+
+       // set crouched
+       if (PHYS_INPUT_BUTTONS(self) & 16)
+       {
+               // wants to crouch, this always works..
+               if (!IS_DUCKED(self))
+                       SET_DUCKED(self);
+       }
+       else
+       {
+               // wants to stand, if currently crouching we need to check for a
+               // low ceiling first
+               if (IS_DUCKED(self))
+               {
+                       tracebox(self.origin, PL_MIN, PL_MAX, self.origin, MOVE_NORMAL, self);
+                       if (!trace_startsolid)
+                               UNSET_DUCKED(self);
+               }
+       }
+       if (IS_DUCKED(self))
+       {
+               self.mins = PL_CROUCH_MIN;
+               self.maxs = PL_CROUCH_MAX;
+       }
+       else
+       {
+               self.mins = PL_MIN;
+               self.maxs = PL_MAX;
+       }
+
+       // set onground
+       vector origin1 = self.origin + '0 0 1';
+       vector origin2 = self.origin - '0 0 1';
+
+       tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self);
+       if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
+       {
+               SET_ONGROUND(self);
+
+               // this code actually "predicts" an impact; so let's clip velocity first
+               float f = dotproduct(self.velocity, trace_plane_normal);
+               if (f < 0) // only if moving downwards actually
+                       self.velocity -= f * trace_plane_normal;
+       }
+       else
+               UNSET_ONGROUND(self);
+
+       // set watertype/waterlevel
+       origin1 = self.origin;
+       origin1_z += self.mins_z + 1;
+       self.waterlevel = WATERLEVEL_NONE;
+       // TODO: convert
+//     self.watertype = CL_TracePoint(origin1, MOVE_NOMONSTERS, s, 0, true, false, NULL, false).startsupercontents & SUPERCONTENTS_LIQUIDSMASK;
+//     if (self.watertype)
+//     {
+//             self.waterlevel = WATERLEVEL_WETFEET;
+//             origin1[2] = self.origin[2] + (self.mins[2] + self.maxs[2]) * 0.5f;
+//             if (CL_TracePoint(origin1, MOVE_NOMONSTERS, s, 0, true, false, NULL, false).startsupercontents & SUPERCONTENTS_LIQUIDSMASK)
+//             {
+//                     self.waterlevel = WATERLEVEL_SWIMMING;
+//                     origin1[2] = self.origin[2] + 22;
+//                     if (CL_TracePoint(origin1, MOVE_NOMONSTERS, s, 0, true, false, NULL, false).startsupercontents & SUPERCONTENTS_LIQUIDSMASK)
+//                             self.waterlevel = WATERLEVEL_SUBMERGED;
+//             }
+//     }
+//
+//     // water jump prediction
+//     if (IS_ONGROUND(self) || self.velocity_z <= 0 || pmove_waterjumptime <= 0)
+//             pmove_waterjumptime = 0;
+}
+
 void CSQC_ClientMovement_Move()
 {
        float t = PHYS_INPUT_TIMELENGTH;