]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics/movetypes/push.qc
Swim down with crouch, swim up at full speed (to match +moveup)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / movetypes / push.qc
index 3b3c648f1e9145c3029bf5608f85a5e90cb02832..5a0426edce7ffba41c69eb48b8c293a1b5c07b46 100644 (file)
@@ -1,5 +1,3 @@
-#include "push.qh"
-
 void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
 {
        if (this.move_velocity == '0 0 0' && this.move_avelocity == '0 0 0')
@@ -55,9 +53,8 @@ void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
 
        if (this.move_movetype != MOVETYPE_FAKEPUSH)
        {
-               for (entity check = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); check; check = check.chain)
-               {
-                       switch (check.move_movetype)
+           FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
+                       switch (it.move_movetype)
                        {
                                case MOVETYPE_NONE:
                                case MOVETYPE_PUSH:
@@ -69,17 +66,17 @@ void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
                                        break;
                        }
 
-                       if (check.owner == this)
+                       if (it.owner == this)
                                continue;
 
-                       if (this.owner == check)
+                       if (this.owner == it)
                                continue;
 
-                       vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
+                       vector pivot = it.mins + 0.5 * (it.maxs - it.mins);
                        vector move;
                        if (rotated)
                        {
-                               vector org = (check.move_origin - this.move_origin) + pivot;
+                               vector org = (it.move_origin - this.move_origin) + pivot;
                                vector org2;
                                org2.x = org * v_forward;
                                org2.y = org * v_right;
@@ -92,36 +89,34 @@ void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
                        }
 
                        // physics objects need better collisions than this code can do
-                       if (check.move_movetype == 32)  // MOVETYPE_PHYSICS
+                       if (it.move_movetype == 32)  // MOVETYPE_PHYSICS
                        {
-                               check.move_origin = check.move_origin + move;
-                               WITH(entity, this, check, _Movetype_LinkEdict(this, true));
+                               it.move_origin = it.move_origin + move;
+                               _Movetype_LinkEdict(it, true);
                                continue;
                        }
 
                        // try moving the contacted entity
                        this.solid = SOLID_NOT;
                        bool flag = false;
-                       WITH(entity, this, check, {
-                               flag = _Movetype_PushEntity(this, move, true);
-                       });
+                       flag = _Movetype_PushEntity(it, move, true);
                        if (!flag)
                        {
-                               // entity "check" got teleported
-                               check.move_angles_y += trace_fraction * moveangle.y;
+                               // entity "it" got teleported
+                               it.move_angles_y += trace_fraction * moveangle.y;
                                this.solid = savesolid;
                                continue;  // pushed enough
                        }
                        // FIXME: turn players specially
-                       check.move_angles_y += trace_fraction * moveangle.y;
+                       it.move_angles_y += trace_fraction * moveangle.y;
                        this.solid = savesolid;
 
                        // this trace.fraction < 1 check causes items to fall off of pushers
                        // if they pass under or through a wall
                        // the groundentity check causes items to fall off of ledges
-                       if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != this))
-                               check.move_flags &= ~FL_ONGROUND;
-               }
+                       if (it.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || it.move_groundentity != this))
+                               it.move_flags &= ~FL_ONGROUND;
+        });
        }
 
        this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
@@ -153,7 +148,6 @@ void _Movetype_Physics_Pusher(entity this, float dt)  // SV_Physics_Pusher
        {
                this.move_nextthink = 0;
                this.move_time = time;
-               other = world;
-               WITH(entity, self, this, this.move_think());
+               this.move_think(this);
        }
 }