1 void _Movetype_PushMove(float dt) // SV_PushMove
3 if (self.move_velocity == '0 0 0' && self.move_avelocity == '0 0 0')
11 // LordHavoc: valid pusher types
15 case SOLID_CORPSE: // LordHavoc: this would be weird...
17 // LordHavoc: no collisions
20 self.move_origin = self.move_origin + dt * self.move_velocity;
21 self.move_angles = self.move_angles + dt * self.move_avelocity;
22 self.move_angles_x -= 360.0 * floor(self.move_angles.x * (1.0 / 360.0));
23 self.move_angles_y -= 360.0 * floor(self.move_angles.y * (1.0 / 360.0));
24 self.move_angles_z -= 360.0 * floor(self.move_angles.z * (1.0 / 360.0));
25 self.move_ltime += dt;
26 _Movetype_LinkEdict(true);
29 dprintf("_Movetype_PushMove: entity %e, unrecognized solid type %d\n", self, self.solid);
33 bool rotated = (self.move_angles * self.move_angles) + (self.move_avelocity * self.move_avelocity) > 0;
35 vector move1 = self.move_velocity * dt;
36 vector moveangle = self.move_avelocity * dt;
38 makevectors_matrix(-moveangle);
40 // vector pushorig = self.move_origin;
41 // vector pushang = self.move_angles;
42 // float pushltime = self.move_ltime;
44 // move the pusher to its final position
46 self.move_origin = self.move_origin + dt * self.move_velocity;
47 self.move_angles = self.move_angles + dt * self.move_avelocity;
49 self.move_ltime += dt;
50 _Movetype_LinkEdict(true);
52 int savesolid = self.solid;
54 if (self.move_movetype != MOVETYPE_FAKEPUSH)
56 for (entity check = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); check; check = check.chain)
58 switch (check.move_movetype)
64 case MOVETYPE_FLY_WORLDONLY:
70 if (check.owner == self)
73 if (self.owner == check)
76 vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
80 vector org = (check.move_origin - self.move_origin) + pivot;
82 org2.x = org * v_forward;
83 org2.y = org * v_right;
85 move = (org2 - org) + move1;
92 // physics objects need better collisions than this code can do
93 if (check.move_movetype == 32) // MOVETYPE_PHYSICS
95 check.move_origin = check.move_origin + move;
96 entity oldself = self;
98 _Movetype_LinkEdict(true);
103 // try moving the contacted entity
104 self.solid = SOLID_NOT;
105 entity oldself = self;
107 if (!_Movetype_PushEntity(move, true))
110 // entity "check" got teleported
111 check.move_angles_y += trace_fraction * moveangle.y;
112 self.solid = savesolid;
113 continue; // pushed enough
116 // FIXME: turn players specially
117 check.move_angles_y += trace_fraction * moveangle.y;
118 self.solid = savesolid;
120 // this trace.fraction < 1 check causes items to fall off of pushers
121 // if they pass under or through a wall
122 // the groundentity check causes items to fall off of ledges
123 if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != self))
124 check.move_flags &= ~FL_ONGROUND;
128 self.move_angles_x -= 360.0 * floor(self.move_angles.x * (1.0 / 360.0));
129 self.move_angles_y -= 360.0 * floor(self.move_angles.y * (1.0 / 360.0));
130 self.move_angles_z -= 360.0 * floor(self.move_angles.z * (1.0 / 360.0));
133 void _Movetype_Physics_Pusher(float dt) // SV_Physics_Pusher
135 float oldltime = self.move_ltime;
136 float thinktime = self.move_nextthink;
138 if (thinktime < self.move_ltime + dt)
140 movetime = thinktime - self.move_ltime;
150 // advances self.move_ltime if not blocked
151 _Movetype_PushMove(movetime);
153 if (thinktime > oldltime && thinktime <= self.move_ltime)
155 self.move_nextthink = 0;
156 self.move_time = time;