]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/physics/movetypes/movetypes.qc
Fix prediction of SOLID_NOT on triggers (also fixes projectiles bouncing in corners...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / movetypes / movetypes.qc
1 #include "../player.qh"
2
3 #if defined(CSQC)
4         #include <client/defs.qh>
5         #include <common/stats.qh>
6         #include <common/util.qh>
7         #include "movetypes.qh"
8         #include <lib/csqcmodel/common.qh>
9         #include <common/t_items.qh>
10 #elif defined(MENUQC)
11 #elif defined(SVQC)
12         #include <server/autocvars.qh>
13 #endif
14
15 void _Movetype_WallFriction(entity this, vector stepnormal)  // SV_WallFriction
16 {
17         /*float d, i;
18         vector into, side;
19         makevectors(this.v_angle);
20         d = (stepnormal * v_forward) + 0.5;
21
22         if(d < 0)
23         {
24             i = (stepnormal * this.move_velocity);
25             into = i * stepnormal;
26             side = this.move_velocity - into;
27             this.move_velocity_x = side.x * (1 * d);
28             this.move_velocity_y = side.y * (1 * d);
29         }*/
30 }
31
32 vector planes[MAX_CLIP_PLANES];
33 int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
34 {
35         int blocked = 0, bumpcount;
36         int i, j, numplanes = 0;
37         float time_left = dt, grav = 0;
38         vector push;
39         vector primal_velocity, original_velocity, restore_velocity;
40
41         for(i = 0; i < MAX_CLIP_PLANES; ++i)
42                 planes[i] = '0 0 0';
43
44         if(applygravity)
45         {
46                 this.move_didgravity = 1;
47                 grav = dt * (PHYS_ENTGRAVITY(this) ? PHYS_ENTGRAVITY(this) : 1) * PHYS_GRAVITY(this);
48
49                 if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(this.move_flags & FL_ONGROUND))
50                 {
51                         if(GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
52                                 this.move_velocity_z -= grav * 0.5;
53                         else
54                                 this.move_velocity_z -= grav;
55                 }
56         }
57
58         original_velocity = primal_velocity = restore_velocity = this.move_velocity;
59
60         for(bumpcount = 0;bumpcount < MAX_CLIP_PLANES;bumpcount++)
61         {
62                 if(this.move_velocity == '0 0 0')
63                         break;
64
65                 push = this.move_velocity * time_left;
66                 _Movetype_PushEntity(this, push, true);
67                 if(trace_startsolid)
68                 {
69                         // we got teleported by a touch function
70                         // let's abort the move
71                         blocked |= 8;
72                         break;
73                 }
74
75                 // this code is used by MOVETYPE_WALK and MOVETYPE_STEP and SV_UnstickEntity
76                 // abort move if we're stuck in the world (and didn't make it out)
77                 if(trace_startsolid && trace_allsolid)
78                 {
79                         this.move_velocity = restore_velocity;
80                         return 3;
81                 }
82
83                 if(trace_fraction == 1)
84                         break;
85
86                 float my_trace_fraction = trace_fraction;
87                 vector my_trace_plane_normal = trace_plane_normal;
88
89                 if(trace_plane_normal.z)
90                 {
91                         if(trace_plane_normal.z > 0.7)
92                         {
93                                 // floor
94                                 blocked |= 1;
95
96                                 if(!trace_ent)
97                                 {
98                                         //dprint("_Movetype_FlyMove: !trace_ent\n");
99                                         trace_ent = world;
100                                 }
101
102                                 this.move_flags |= FL_ONGROUND;
103                                 this.move_groundentity = trace_ent;
104                         }
105                 }
106                 else if(stepheight)
107                 {
108                         // step - handle it immediately
109                         vector org = this.move_origin;
110                         vector steppush = '0 0 1' * stepheight;
111
112                         _Movetype_PushEntity(this, steppush, true);
113                         if(trace_startsolid)
114                         {
115                                 blocked |= 8;
116                                 break;
117                         }
118                         _Movetype_PushEntity(this, push, true);
119                         if(trace_startsolid)
120                         {
121                                 blocked |= 8;
122                                 break;
123                         }
124                         float trace2_fraction = trace_fraction;
125                         steppush = '0 0 1' * (org_z - this.move_origin_z);
126                         _Movetype_PushEntity(this, steppush, true);
127                         if(trace_startsolid)
128                         {
129                                 blocked |= 8;
130                                 break;
131                         }
132
133                         // accept the new position if it made some progress...
134                         if(fabs(this.move_origin_x - org_x) >= 0.03125 || fabs(this.move_origin_y - org_y) >= 0.03125)
135                         {
136                                 trace_endpos = this.move_origin;
137                                 time_left *= 1 - trace2_fraction;
138                                 numplanes = 0;
139                                 continue;
140                         }
141                         else
142                                 this.move_origin = org;
143                 }
144                 else
145                 {
146                         // step - return it to caller
147                         blocked |= 2;
148                         // save the trace for player extrafriction
149                         if(stepnormal)
150                                 stepnormal = trace_plane_normal;
151                 }
152
153                 if(my_trace_fraction >= 0.001)
154                 {
155                         // actually covered some distance
156                         original_velocity = this.move_velocity;
157                         numplanes = 0;
158                 }
159
160                 time_left *= 1 - my_trace_fraction;
161
162                 // clipped to another plane
163                 if(numplanes >= MAX_CLIP_PLANES)
164                 {
165                         // this shouldn't really happen
166                         this.move_velocity = '0 0 0';
167                         blocked = 3;
168                         break;
169                 }
170
171                 planes[numplanes] = my_trace_plane_normal;
172                 numplanes++;
173
174                 // modify original_velocity so it parallels all of the clip planes
175                 vector new_velocity = '0 0 0';
176                 for (i = 0;i < numplanes;i++)
177                 {
178                         new_velocity = _Movetype_ClipVelocity(original_velocity, planes[i], 1);
179                         for (j = 0;j < numplanes;j++)
180                         {
181                                 if(j != i)
182                                 {
183                                         // not ok
184                                         if((new_velocity * planes[j]) < 0)
185                                                 break;
186                                 }
187                         }
188                         if(j == numplanes)
189                                 break;
190                 }
191
192                 if(i != numplanes)
193                 {
194                         // go along this plane
195                         this.move_velocity = new_velocity;
196                 }
197                 else
198                 {
199                         // go along the crease
200                         if(numplanes != 2)
201                         {
202                                 this.move_velocity = '0 0 0';
203                                 blocked = 7;
204                                 break;
205                         }
206                         vector dir = cross(planes[0], planes[1]);
207                         // LordHavoc: thanks to taniwha of QuakeForge for pointing out this fix for slowed falling in corners
208                         float ilength = sqrt((dir * dir));
209                         if(ilength)
210                                 ilength = 1.0 / ilength;
211                         dir.x *= ilength;
212                         dir.y *= ilength;
213                         dir.z *= ilength;
214                         float d = (dir * this.move_velocity);
215                         this.move_velocity = dir * d;
216                 }
217
218                 // if current velocity is against the original velocity,
219                 // stop dead to avoid tiny occilations in sloping corners
220                 if((this.move_velocity * primal_velocity) <= 0)
221                 {
222                         this.move_velocity = '0 0 0';
223                         break;
224                 }
225         }
226
227         // LordHavoc: this came from QW and allows you to get out of water more easily
228         if(GAMEPLAYFIX_EASIERWATERJUMP(this) && (this.move_flags & FL_WATERJUMP) && !(blocked & 8))
229                 this.move_velocity = primal_velocity;
230
231         if(applygravity)
232         {
233                 if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(this.move_flags & FL_ONGROUND))
234                 {
235                         if(GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
236                                 this.move_velocity_z -= grav * 0.5f;
237                 }
238         }
239
240         return blocked;
241 }
242
243 void _Movetype_CheckVelocity(entity this)  // SV_CheckVelocity
244 {
245         // if(vlen(this.move_velocity) < 0.0001)
246         // this.move_velocity = '0 0 0';
247 }
248
249 bool _Movetype_CheckWater(entity this)  // SV_CheckWater
250 {
251         vector point = this.move_origin;
252         point.z += this.mins.z + 1;
253
254         int nativecontents = pointcontents(point);
255         if(this.move_watertype && this.move_watertype != nativecontents)
256         {
257                 // dprintf("_Movetype_CheckWater(): Original: '%d', New: '%d'\n", this.move_watertype, nativecontents);
258                 if(this.contentstransition)
259                         this.contentstransition(this.move_watertype, nativecontents);
260         }
261
262         this.move_waterlevel = WATERLEVEL_NONE;
263         this.move_watertype = CONTENT_EMPTY;
264
265         int supercontents = Mod_Q1BSP_SuperContentsFromNativeContents(nativecontents);
266         if(supercontents & DPCONTENTS_LIQUIDSMASK)
267         {
268                 this.move_watertype = nativecontents;
269                 this.move_waterlevel = WATERLEVEL_WETFEET;
270                 point.z = this.move_origin.z + (this.mins.z + this.maxs.z) * 0.5;
271                 if(Mod_Q1BSP_SuperContentsFromNativeContents(pointcontents(point)) & DPCONTENTS_LIQUIDSMASK)
272                 {
273                         this.move_waterlevel = WATERLEVEL_SWIMMING;
274                         point.z = this.move_origin.z + this.view_ofs.z;
275                         if(Mod_Q1BSP_SuperContentsFromNativeContents(pointcontents(point)) & DPCONTENTS_LIQUIDSMASK)
276                                 this.move_waterlevel = WATERLEVEL_SUBMERGED;
277                 }
278         }
279
280         return this.move_waterlevel > 1;
281 }
282
283 void _Movetype_CheckWaterTransition(entity ent)  // SV_CheckWaterTransition
284 {
285         int contents = pointcontents(ent.move_origin);
286
287         if(!ent.move_watertype)
288         {
289                 // just spawned here
290                 if(!autocvar_cl_gameplayfix_fixedcheckwatertransition)
291                 {
292                         ent.move_watertype = contents;
293                         ent.move_waterlevel = 1;
294                         return;
295                 }
296         }
297         else if(ent.move_watertype != contents)
298         {
299                 // dprintf("_Movetype_CheckWaterTransition(): Origin: %s, Direct: '%d', Original: '%d', New: '%d'\n", vtos(ent.move_origin), pointcontents(ent.move_origin), ent.move_watertype, contents);
300                 if(ent.contentstransition)
301                         ent.contentstransition(ent.move_watertype, contents);
302         }
303
304         if(contents <= CONTENT_WATER)
305         {
306                 ent.move_watertype = contents;
307                 ent.move_waterlevel = 1;
308         }
309         else
310         {
311                 ent.move_watertype = CONTENT_EMPTY;
312                 ent.move_waterlevel = (autocvar_cl_gameplayfix_fixedcheckwatertransition ? 0 : contents);
313         }
314 }
315
316 void _Movetype_Impact(entity this, entity oth)  // SV_Impact
317 {
318         entity oldother = other;
319
320         if(this.move_touch)
321         {
322                 other = oth;
323
324                 WITH(entity, self, this, this.move_touch());
325
326                 other = oldother;
327         }
328
329         if(oth.move_touch)
330         {
331                 other = this;
332
333                 WITH(entity, self, oth, oth.move_touch());
334
335                 other = oldother;
336         }
337 }
338
339 void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGrid
340 {
341         if(this.solid == SOLID_NOT)
342                 return;
343
344         entity oldother = other;
345
346         for (entity e = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); e; e = e.chain)
347         {
348                 if(e.solid == SOLID_TRIGGER && e != this)
349                 if(e.move_nomonsters != MOVE_NOMONSTERS && e.move_nomonsters != MOVE_WORLDONLY)
350                 if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
351                 {
352                         other = this;
353
354                         trace_allsolid = false;
355                         trace_startsolid = false;
356                         trace_fraction = 1;
357                         trace_inwater = false;
358                         trace_inopen = true;
359                         trace_endpos = e.move_origin;
360                         trace_plane_normal = '0 0 1';
361                         trace_plane_dist = 0;
362                         trace_ent = this;
363
364                         WITH(entity, self, e, e.move_touch());
365                 }
366         }
367
368         other = oldother;
369 }
370
371 void _Movetype_LinkEdict(entity this, bool touch_triggers)  // SV_LinkEdict
372 {
373         vector mi, ma;
374         if(this.solid == SOLID_BSP)
375         {
376                 // TODO set the absolute bbox
377                 mi = this.mins;
378                 ma = this.maxs;
379         }
380         else
381         {
382                 mi = this.mins;
383                 ma = this.maxs;
384         }
385         mi += this.move_origin;
386         ma += this.move_origin;
387
388         if(this.move_flags & FL_ITEM)
389         {
390                 mi.x -= 15;
391                 mi.y -= 15;
392                 mi.z -= 1;
393                 ma.x += 15;
394                 ma.y += 15;
395                 ma.z += 1;
396         }
397         else
398         {
399                 mi.x -= 1;
400                 mi.y -= 1;
401                 mi.z -= 1;
402                 ma.x += 1;
403                 ma.y += 1;
404                 ma.z += 1;
405         }
406
407         this.absmin = mi;
408         this.absmax = ma;
409
410         if(touch_triggers)
411                 _Movetype_LinkEdict_TouchAreaGrid(this);
412 }
413
414 bool _Movetype_TestEntityPosition(entity this, vector ofs)  // SV_TestEntityPosition
415 {
416 //      vector org = this.move_origin + ofs;
417
418         int cont = this.dphitcontentsmask;
419         this.dphitcontentsmask = DPCONTENTS_SOLID;
420         tracebox(this.move_origin, this.mins, this.maxs, this.move_origin, ((this.move_movetype == MOVETYPE_FLY_WORLDONLY) ? MOVE_WORLDONLY : MOVE_NOMONSTERS), this);
421         this.dphitcontentsmask = cont;
422
423         if(trace_startsolid)
424                 return true;
425
426         if(vdist(trace_endpos - this.move_origin, >, 0.0001))
427                 this.move_origin = trace_endpos;
428         return false;
429 }
430
431 bool _Movetype_UnstickEntity(entity this)  // SV_UnstickEntity
432 {
433         if(!_Movetype_TestEntityPosition(this, '0 0 0')) return true;
434         if(!_Movetype_TestEntityPosition(this, '-1 0 0')) goto success;
435         if(!_Movetype_TestEntityPosition(this, '1 0 0')) goto success;
436         if(!_Movetype_TestEntityPosition(this, '0 -1 0')) goto success;
437         if(!_Movetype_TestEntityPosition(this, '0 1 0')) goto success;
438         if(!_Movetype_TestEntityPosition(this, '-1 -1 0')) goto success;
439         if(!_Movetype_TestEntityPosition(this, '1 -1 0')) goto success;
440         if(!_Movetype_TestEntityPosition(this, '-1 1 0')) goto success;
441         if(!_Movetype_TestEntityPosition(this, '1 1 0')) goto success;
442         for (int i = 1; i <= 17; ++i)
443         {
444                 if(!_Movetype_TestEntityPosition(this, '0 0 -1' * i)) goto success;
445                 if(!_Movetype_TestEntityPosition(this, '0 0 1' * i)) goto success;
446         }
447         LOG_DEBUGF("Can't unstick an entity (edict: %d, classname: %s, origin: %s)\n",
448                 etof(this), this.classname, vtos(this.move_origin));
449         return false;
450         : success;
451         LOG_DEBUGF("Sucessfully unstuck an entity (edict: %d, classname: %s, origin: %s)\n",
452                 etof(this), this.classname, vtos(this.move_origin));
453         _Movetype_LinkEdict(this, true);
454         return true;
455 }
456
457 vector _Movetype_ClipVelocity(vector vel, vector norm, float f)  // SV_ClipVelocity
458 {
459         vel -= ((vel * norm) * norm) * f;
460
461         if(vel.x > -0.1 && vel.x < 0.1) vel.x = 0;
462         if(vel.y > -0.1 && vel.y < 0.1) vel.y = 0;
463         if(vel.z > -0.1 && vel.z < 0.1) vel.z = 0;
464
465         return vel;
466 }
467
468 void _Movetype_PushEntityTrace(entity this, vector push)
469 {
470         vector end = this.move_origin + push;
471         int type;
472         if(this.move_nomonsters)
473                 type = max(0, this.move_nomonsters);
474         else if(this.move_movetype == MOVETYPE_FLYMISSILE)
475                 type = MOVE_MISSILE;
476         else if(this.move_movetype == MOVETYPE_FLY_WORLDONLY)
477                 type = MOVE_WORLDONLY;
478         else if(this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
479                 type = MOVE_NOMONSTERS;
480         else
481                 type = MOVE_NORMAL;
482
483         tracebox(this.move_origin, this.mins, this.maxs, end, type, this);
484 }
485
486 float _Movetype_PushEntity(entity this, vector push, bool failonstartsolid)  // SV_PushEntity
487 {
488         _Movetype_PushEntityTrace(this, push);
489
490         if(trace_startsolid && failonstartsolid)
491                 return trace_fraction;
492
493         this.move_origin = trace_endpos;
494
495         if(trace_fraction < 1)
496                 if(this.solid >= SOLID_TRIGGER && (!(this.move_flags & FL_ONGROUND) || (this.move_groundentity != trace_ent)))
497                         _Movetype_Impact(this, trace_ent);
498
499         return trace_fraction;
500 }
501
502
503 .float ltime;
504 .void() blocked;
505 // matrix version of makevectors, sets v_forward, v_right and v_up
506 void makevectors_matrix(vector myangles)  // AngleVectorsFLU
507 {
508         v_forward = v_right = v_up = '0 0 0';
509
510         float y = myangles.y * (M_PI * 2 / 360);
511         float sy = sin(y);
512         float cy = cos(y);
513         float p = myangles.x * (M_PI * 2 / 360);
514         float sp = sin(p);
515         float cp = cos(p);
516         if(v_forward)
517         {
518                 v_forward.x = cp * cy;
519                 v_forward.y = cp * sy;
520                 v_forward.z = -sp;
521         }
522         if(v_right || v_up)
523         {
524                 if(myangles.z)
525                 {
526                         float r = myangles.z * (M_PI * 2 / 360);
527                         float sr = sin(r);
528                         float cr = cos(r);
529                         if(v_right)
530                         {
531                                 v_right.x = sr * sp * cy + cr * -sy;
532                                 v_right.y = sr * sp * sy + cr * cy;
533                                 v_right.z = sr * cp;
534                         }
535                         if(v_up)
536                         {
537                                 v_up.x = cr * sp * cy + -sr * -sy;
538                                 v_up.y = cr * sp * sy + -sr * cy;
539                                 v_up.z = cr * cp;
540                         }
541                 }
542                 else
543                 {
544                         if(v_right)
545                         {
546                                 v_right.x = -sy;
547                                 v_right.y = cy;
548                                 v_right.z = 0;
549                         }
550                         if(v_up)
551                         {
552                                 v_up.x = sp * cy;
553                                 v_up.y = sp * sy;
554                                 v_up.z = cp;
555                         }
556                 }
557         }
558 }
559
560 void _Movetype_Physics_Frame(entity this, float movedt)
561 {
562         this.move_didgravity = -1;
563         switch (this.move_movetype)
564         {
565                 case MOVETYPE_PUSH:
566                 case MOVETYPE_FAKEPUSH:
567                         _Movetype_Physics_Pusher(this, movedt);
568                         break;
569                 case MOVETYPE_NONE:
570                         break;
571                 case MOVETYPE_FOLLOW:
572                         _Movetype_Physics_Follow(this);
573                         break;
574                 case MOVETYPE_NOCLIP:
575                         _Movetype_CheckWater(this);
576                         this.move_origin = this.move_origin + TICRATE * this.move_velocity;
577                         this.move_angles = this.move_angles + TICRATE * this.move_avelocity;
578                         _Movetype_LinkEdict(this, false);
579                         break;
580                 case MOVETYPE_STEP:
581                         _Movetype_Physics_Step(this, movedt);
582                         break;
583                 case MOVETYPE_WALK:
584                         _Movetype_Physics_Walk(this, movedt);
585                         break;
586                 case MOVETYPE_TOSS:
587                 case MOVETYPE_BOUNCE:
588                 case MOVETYPE_BOUNCEMISSILE:
589                 case MOVETYPE_FLYMISSILE:
590                 case MOVETYPE_FLY:
591                 case MOVETYPE_FLY_WORLDONLY:
592                         _Movetype_Physics_Toss(this, movedt);
593                         _Movetype_LinkEdict(this, true);
594                         break;
595                 case MOVETYPE_PHYSICS:
596                         break;
597         }
598 }
599
600 void _Movetype_Physics_ClientFrame(entity this, float movedt)
601 {
602         this.move_didgravity = -1;
603         switch (this.move_movetype)
604         {
605                 case MOVETYPE_PUSH:
606                 case MOVETYPE_FAKEPUSH:
607                         _Movetype_Physics_Pusher(this, movedt);
608                         break;
609                 case MOVETYPE_NONE:
610                         break;
611                 case MOVETYPE_FOLLOW:
612                         _Movetype_Physics_Follow(this);
613                         break;
614                 case MOVETYPE_NOCLIP:
615                         _Movetype_CheckWater(this);
616                         this.move_origin = this.move_origin + TICRATE * this.move_velocity;
617                         this.move_angles = this.move_angles + TICRATE * this.move_avelocity;
618                         _Movetype_LinkEdict(this, false);
619                         break;
620                 case MOVETYPE_STEP:
621                         _Movetype_Physics_Step(this, movedt);
622                         break;
623                 case MOVETYPE_WALK:
624                 case MOVETYPE_FLY:
625                 case MOVETYPE_FLY_WORLDONLY:
626                         _Movetype_Physics_Walk(this, movedt);
627                         break;
628                 case MOVETYPE_TOSS:
629                 case MOVETYPE_BOUNCE:
630                 case MOVETYPE_BOUNCEMISSILE:
631                 case MOVETYPE_FLYMISSILE:
632                         _Movetype_Physics_Toss(this, movedt);
633                         break;
634                 case MOVETYPE_PHYSICS:
635                         break;
636         }
637 }
638
639 void Movetype_Physics_NoMatchServer(entity this)  // optimized
640 {
641         float movedt = time - this.move_time;
642         this.move_time = time;
643
644         _Movetype_Physics_Frame(this, movedt);
645         if(wasfreed(this))
646                 return;
647
648         this.avelocity = this.move_avelocity;
649         this.velocity = this.move_velocity;
650         this.angles = this.move_angles;
651         setorigin(this, this.move_origin);
652 }
653
654 void Movetype_Physics_MatchServer(entity this, bool sloppy)
655 {
656         Movetype_Physics_MatchTicrate(this, TICRATE, sloppy);
657 }
658
659 void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy)  // SV_Physics_Entity
660 {
661         if(tr <= 0)
662         {
663                 Movetype_Physics_NoMatchServer(this);
664                 return;
665         }
666
667         float dt = time - this.move_time;
668
669         int n = max(0, floor(dt / tr));
670         dt -= n * tr;
671         this.move_time += n * tr;
672
673         if(!this.move_didgravity)
674                 this.move_didgravity = ((this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS) && !(this.move_flags & FL_ONGROUND));
675
676         for (int i = 0; i < n; ++i)
677         {
678                 _Movetype_Physics_Frame(this, tr);
679                 if(wasfreed(this))
680                         return;
681         }
682
683         this.avelocity = this.move_avelocity;
684
685         if(dt > 0 && this.move_movetype != MOVETYPE_NONE && !(this.move_flags & FL_ONGROUND))
686         {
687                 // now continue the move from move_time to time
688                 this.velocity = this.move_velocity;
689
690                 if(this.move_didgravity > 0)
691                 {
692                         this.velocity_z -= (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1)
693                             * dt
694                             * (this.gravity ? this.gravity : 1)
695                             * PHYS_GRAVITY(this);
696                 }
697
698                 this.angles = this.move_angles + dt * this.avelocity;
699
700                 if(sloppy || this.move_movetype == MOVETYPE_NOCLIP)
701                 {
702                         setorigin(this, this.move_origin + dt * this.velocity);
703                 }
704                 else
705                 {
706                         _Movetype_PushEntityTrace(this, dt * this.velocity);
707                         if(!trace_startsolid)
708                                 setorigin(this, trace_endpos);
709                 }
710
711                 if(this.move_didgravity > 0 && GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
712                         this.velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
713         }
714         else
715         {
716                 this.velocity = this.move_velocity;
717                 this.angles = this.move_angles;
718                 setorigin(this, this.move_origin);
719         }
720 }