1 void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
2 void() SUB_CalcMoveDone;
3 void() SUB_CalcAngleMoveDone;
5 //void() SUB_UseTargets;
32 void SUB_Remove (void)
37 void SUB_SetFade_Think (void)
39 if (self.alpha < 0.06) // don't let it reach 0, lest it become fully visible again
42 self.alpha = self.alpha - 0.05;
44 self.think = SUB_SetFade_Think;
45 self.nextthink = time + 0.1;
52 Fade 'ent' out when time >= 'when'
55 void SUB_SetFade (entity ent, float when)
65 ent.think = SUB_SetFade_Think;
73 calculate self.velocity and self.nextthink to reach dest from
74 self.origin traveling at speed
77 void SUB_CalcMoveDone (void)
79 // After moving, set origin to exact final destination
81 setorigin (self, self.finaldest);
82 self.velocity = '0 0 0';
88 void SUB_CalcMove (vector tdest, float tspeed, void() func)
94 objerror ("No speed is defined!");
97 self.finaldest = tdest;
98 self.think = SUB_CalcMoveDone;
100 if (tdest == self.origin)
102 self.velocity = '0 0 0';
103 self.nextthink = self.ltime + 0.1;
107 delta = tdest - self.origin;
108 traveltime = vlen (delta) / tspeed;
110 if (traveltime < 0.1)
112 self.velocity = '0 0 0';
113 self.nextthink = self.ltime + 0.1;
117 self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
119 self.nextthink = self.ltime + traveltime;
122 void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeed, void() func)
129 SUB_CalcMove (tdest, tspeed, func);
138 calculate self.avelocity and self.nextthink to reach destangle from
141 The calling function should make sure self.think is valid
144 void SUB_CalcAngleMoveDone (void)
146 // After rotating, set angle to exact final angle
147 self.angles = self.finalangle;
148 self.avelocity = '0 0 0';
154 void SUB_CalcAngleMove (vector destangle, float tspeed, void() func)
160 objerror ("No speed is defined!");
162 delta = destangle = self.angles;
163 traveltime = vlen (delta) / tspeed;
165 self.avelocity = delta * (1 / traveltime);
168 self.finalangle = destangle;
170 self.think = SUB_CalcAngleMoveDone;
171 self.nextthink = self.ltime + traveltime;
174 void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeed, void() func)
181 SUB_CalcAngleMove (destangle, tspeed, func);
190 unused but required by the engine
204 Play a sound at the given location
207 void PointSound (vector org, string snd, float vol, float attn)
212 setorigin (speaker, org);
213 sound (speaker, CHAN_BODY, snd, vol, attn);
223 A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE things with a trace attack
226 void traceline_hitcorpse (entity source, vector v1, vector v2, float nomonst, entity forent)
230 oldsolid = source.solid;
231 source.solid = SOLID_BBOX;
233 traceline (v1, v2, nomonst, forent);
235 source.solid = oldsolid;
242 Returns a point at least 12 units away from walls
243 (useful for explosion animations, although the blast is performed where it really happened)
247 vector findbetterlocation (vector org)
251 traceline (org, org - '12 0 0', TRUE, world);
252 if (trace_fraction < 1)
255 traceline (loc, loc + '12 0 0', TRUE, world);
256 if (trace_fraction >= 1)
257 org = loc + '12 0 0';
260 traceline (org, org - '-12 0 0', TRUE, world);
261 if (trace_fraction < 1)
264 traceline (loc, loc + '-12 0 0', TRUE, world);
265 if (trace_fraction >= 1)
266 org = loc + '-12 0 0';
269 traceline (org, org - '0 12 0' , TRUE, world);
270 if (trace_fraction < 1)
273 traceline (loc, loc + '0 12 0', TRUE, world);
274 if (trace_fraction >= 1)
275 org = loc + '0 12 0';
278 traceline (org, org - '0 -12 0', TRUE, world);
279 if (trace_fraction < 1)
282 traceline (loc, loc + '0 -12 0', TRUE, world);
283 if (trace_fraction >= 1)
284 org = loc + '0 -12 0';
287 traceline (org, org - '0 0 12' , TRUE, world);
288 if (trace_fraction < 1)
291 traceline (loc, loc + '0 0 12', TRUE, world);
292 if (trace_fraction >= 1)
293 org = loc + '0 0 12';
296 traceline (org, org - '0 0 -12', TRUE, world);
297 if (trace_fraction < 1)
300 traceline (loc, loc + '0 0 -12', TRUE, world);
301 if (trace_fraction >= 1)
302 org = loc + '0 0 -12';
312 Returns a random number between -1.0 and 1.0
317 return 2 * (random () - 0.5);
326 Plays an impact effect
330 void ImpactEffect (entity ent, float weapontype)
333 org2 = findbetterlocation (ent.origin);
335 if (weapontype == IT_ROCKET_LAUNCHER)
338 effect (org2, "models/sprites/dpexplosion.spr32", 0, 20, 30);
339 sound (ent, CHAN_BODY, "weapons/Rocket_Impact.wav", 1, ATTN_NORM);
341 else if (weapontype == IT_GRENADE_LAUNCHER)
344 effect (org2, "models/sprites/dpexplosion.spr32", 0, 20, 30);
345 sound (ent, CHAN_BODY, "weapons/Grenade_Impact.wav", 1, ATTN_NORM);
347 else if (weapontype == IT_HAGAR)
349 effect (org2, "models/sprites/dpexplosion.spr32", 0, 20, 40);
350 sound (ent, CHAN_BODY, "weapons/Rocket_Impact.wav", 1, ATTN_NORM);
352 else if (weapontype == IT_ELECTRO) // Secondary fire
354 effect (org2, "models/sprites/plasmahitwall.spr32", 0, 20, 50);
355 sound (ent, CHAN_BODY, "weapons/Plasma_Hit.wav", 1, ATTN_NORM);