1 void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
2 void() SUB_CalcMoveDone;
3 void() SUB_CalcAngleMoveDone;
5 //void() SUB_UseTargets;
28 void SUB_Remove (void)
33 void SUB_SetFade_Think (void)
35 if (self.alpha < 0.06) // don't let it reach 0, lest it become fully visible again
38 self.alpha = self.alpha - 0.05;
40 self.think = SUB_SetFade_Think;
41 self.nextthink = time + 0.1;
48 Fade 'ent' out when time >= 'when'
51 void SUB_SetFade (entity ent, float when)
61 ent.think = SUB_SetFade_Think;
69 calculate self.velocity and self.nextthink to reach dest from
70 self.origin traveling at speed
73 void SUB_CalcMoveDone (void)
75 // After moving, set origin to exact final destination
77 setorigin (self, self.finaldest);
78 self.velocity = '0 0 0';
84 void SUB_CalcMove (vector tdest, float tspeed, void() func)
90 objerror ("No speed is defined!");
93 self.finaldest = tdest;
94 self.think = SUB_CalcMoveDone;
96 if (tdest == self.origin)
98 self.velocity = '0 0 0';
99 self.nextthink = self.ltime + 0.1;
103 delta = tdest - self.origin;
104 traveltime = vlen (delta) / tspeed;
106 if (traveltime < 0.1)
108 self.velocity = '0 0 0';
109 self.nextthink = self.ltime + 0.1;
113 self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
115 self.nextthink = self.ltime + traveltime;
118 void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeed, void() func)
125 SUB_CalcMove (tdest, tspeed, func);
134 calculate self.avelocity and self.nextthink to reach destangle from
137 The calling function should make sure self.think is valid
140 void SUB_CalcAngleMoveDone (void)
142 // After rotating, set angle to exact final angle
143 self.angles = self.finalangle;
144 self.avelocity = '0 0 0';
150 void SUB_CalcAngleMove (vector destangle, float tspeed, void() func)
156 objerror ("No speed is defined!");
158 delta = destangle = self.angles;
159 traveltime = vlen (delta) / tspeed;
161 self.avelocity = delta * (1 / traveltime);
164 self.finalangle = destangle;
166 self.think = SUB_CalcAngleMoveDone;
167 self.nextthink = self.ltime + traveltime;
170 void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeed, void() func)
177 SUB_CalcAngleMove (destangle, tspeed, func);
186 unused but required by the engine
200 Play a sound at the given location
203 void PointSound (vector org, string snd, float vol, float attn)
208 setorigin (speaker, org);
209 sound (speaker, CHAN_BODY, snd, vol, attn);
219 A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE things with a trace attack
222 void traceline_hitcorpse (entity source, vector v1, vector v2, float nomonst, entity forent)
226 oldsolid = source.solid;
227 source.solid = SOLID_BBOX;
229 traceline (v1, v2, nomonst, forent);
231 source.solid = oldsolid;
238 Returns a point at least 12 units away from walls
239 (useful for explosion animations, although the blast is performed where it really happened)
243 vector findbetterlocation (vector org)
247 traceline (org, org - '12 0 0', TRUE, world);
248 if (trace_fraction < 1)
251 traceline (loc, loc + '12 0 0', TRUE, world);
252 if (trace_fraction >= 1)
253 org = loc + '12 0 0';
256 traceline (org, org - '-12 0 0', TRUE, world);
257 if (trace_fraction < 1)
260 traceline (loc, loc + '-12 0 0', TRUE, world);
261 if (trace_fraction >= 1)
262 org = loc + '-12 0 0';
265 traceline (org, org - '0 12 0' , TRUE, world);
266 if (trace_fraction < 1)
269 traceline (loc, loc + '0 12 0', TRUE, world);
270 if (trace_fraction >= 1)
271 org = loc + '0 12 0';
274 traceline (org, org - '0 -12 0', TRUE, world);
275 if (trace_fraction < 1)
278 traceline (loc, loc + '0 -12 0', TRUE, world);
279 if (trace_fraction >= 1)
280 org = loc + '0 -12 0';
283 traceline (org, org - '0 0 12' , TRUE, world);
284 if (trace_fraction < 1)
287 traceline (loc, loc + '0 0 12', TRUE, world);
288 if (trace_fraction >= 1)
289 org = loc + '0 0 12';
292 traceline (org, org - '0 0 -12', TRUE, world);
293 if (trace_fraction < 1)
296 traceline (loc, loc + '0 0 -12', TRUE, world);
297 if (trace_fraction >= 1)
298 org = loc + '0 0 -12';
308 Returns a random number between -1.0 and 1.0
313 return 2 * (random () - 0.5);
322 Plays an explosion effect
325 void Explosion (entity ent, string snd, float fps)
329 org2 = findbetterlocation (ent.origin);
332 effect (org2, "models/dpexplosion.spr32", 0, 20, fps);
333 sound (ent, CHAN_BODY, snd, 1, ATTN_NORM);