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