3 void _Movetype_PushMove(entity this, float dt) // SV_PushMove
5 if (this.move_velocity == '0 0 0' && this.move_avelocity == '0 0 0')
13 // LordHavoc: valid pusher types
17 case SOLID_CORPSE: // LordHavoc: this would be weird...
19 // LordHavoc: no collisions
22 this.move_origin = this.move_origin + dt * this.move_velocity;
23 this.move_angles = this.move_angles + dt * this.move_avelocity;
24 this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
25 this.move_angles_y -= 360.0 * floor(this.move_angles.y * (1.0 / 360.0));
26 this.move_angles_z -= 360.0 * floor(this.move_angles.z * (1.0 / 360.0));
27 this.move_ltime += dt;
28 _Movetype_LinkEdict(this, true);
31 LOG_TRACEF("_Movetype_PushMove: entity %e, unrecognized solid type %d\n", this, this.solid);
35 bool rotated = (this.move_angles * this.move_angles) + (this.move_avelocity * this.move_avelocity) > 0;
37 vector move1 = this.move_velocity * dt;
38 vector moveangle = this.move_avelocity * dt;
40 makevectors_matrix(-moveangle);
42 // vector pushorig = this.move_origin;
43 // vector pushang = this.move_angles;
44 // float pushltime = this.move_ltime;
46 // move the pusher to its final position
48 this.move_origin = this.move_origin + dt * this.move_velocity;
49 this.move_angles = this.move_angles + dt * this.move_avelocity;
51 this.move_ltime += dt;
52 _Movetype_LinkEdict(this, true);
54 int savesolid = this.solid;
56 if (this.move_movetype != MOVETYPE_FAKEPUSH)
58 for (entity check = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); check; check = check.chain)
60 switch (check.move_movetype)
66 case MOVETYPE_FLY_WORLDONLY:
72 if (check.owner == this)
75 if (this.owner == check)
78 vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
82 vector org = (check.move_origin - this.move_origin) + pivot;
84 org2.x = org * v_forward;
85 org2.y = org * v_right;
87 move = (org2 - org) + move1;
94 // physics objects need better collisions than this code can do
95 if (check.move_movetype == 32) // MOVETYPE_PHYSICS
97 check.move_origin = check.move_origin + move;
98 WITH(entity, this, check, _Movetype_LinkEdict(this, true));
102 // try moving the contacted entity
103 this.solid = SOLID_NOT;
105 WITH(entity, this, check, {
106 flag = _Movetype_PushEntity(this, move, true);
110 // entity "check" got teleported
111 check.move_angles_y += trace_fraction * moveangle.y;
112 this.solid = savesolid;
113 continue; // pushed enough
115 // FIXME: turn players specially
116 check.move_angles_y += trace_fraction * moveangle.y;
117 this.solid = savesolid;
119 // this trace.fraction < 1 check causes items to fall off of pushers
120 // if they pass under or through a wall
121 // the groundentity check causes items to fall off of ledges
122 if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != this))
123 check.move_flags &= ~FL_ONGROUND;
127 this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
128 this.move_angles_y -= 360.0 * floor(this.move_angles.y * (1.0 / 360.0));
129 this.move_angles_z -= 360.0 * floor(this.move_angles.z * (1.0 / 360.0));
132 void _Movetype_Physics_Pusher(entity this, float dt) // SV_Physics_Pusher
134 float oldltime = this.move_ltime;
135 float thinktime = this.move_nextthink;
137 if (thinktime < this.move_ltime + dt)
139 movetime = thinktime - this.move_ltime;
149 // advances this.move_ltime if not blocked
150 _Movetype_PushMove(this, movetime);
152 if (thinktime > oldltime && thinktime <= this.move_ltime)
154 this.move_nextthink = 0;
155 this.move_time = time;
157 WITH(entity, self, this, this.move_think());