3 void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
4 void() SUB_CalcMoveDone;
5 void() SUB_CalcAngleMoveDone;
6 //void() SUB_UseTargets;
20 void SUB_Remove (void)
29 Makes client invisible or removes non-client
32 void SUB_VanishOrRemove (entity ent)
34 if (ent.flags & FL_CLIENT)
49 void SUB_SetFade_Think (void)
51 self.think = SUB_SetFade_Think;
52 self.nextthink = self.fade_time;
53 self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
54 if (self.alpha < 0.01)
55 SUB_VanishOrRemove(self);
56 self.alpha = bound(0.01, self.alpha, 1);
63 Fade 'ent' out when time >= 'when'
66 void SUB_SetFade (entity ent, float when, float fadetime)
68 //if (ent.flags & FL_CLIENT) // && ent.deadflag != DEAD_NO)
71 ent.fade_rate = 1/fadetime;
73 ent.think = SUB_SetFade_Think;
81 calculate self.velocity and self.nextthink to reach dest from
82 self.origin traveling at speed
85 void SUB_CalcMoveDone (void)
87 // After moving, set origin to exact final destination
89 setorigin (self, self.finaldest);
90 self.velocity = '0 0 0';
96 void SUB_CalcMove (vector tdest, float tspeed, void() func)
102 objerror ("No speed is defined!");
105 self.finaldest = tdest;
106 self.think = SUB_CalcMoveDone;
108 if (tdest == self.origin)
110 self.velocity = '0 0 0';
111 self.nextthink = self.ltime + 0.1;
115 delta = tdest - self.origin;
116 traveltime = vlen (delta) / tspeed;
118 if (traveltime < 0.1)
120 self.velocity = '0 0 0';
121 self.nextthink = self.ltime + 0.1;
125 self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
127 self.nextthink = self.ltime + traveltime;
130 void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeed, void() func)
137 SUB_CalcMove (tdest, tspeed, func);
146 calculate self.avelocity and self.nextthink to reach destangle from
149 The calling function should make sure self.think is valid
152 void SUB_CalcAngleMoveDone (void)
154 // After rotating, set angle to exact final angle
155 self.angles = self.finalangle;
156 self.avelocity = '0 0 0';
162 void SUB_CalcAngleMove (vector destangle, float tspeed, void() func)
168 objerror ("No speed is defined!");
170 delta = destangle = self.angles;
171 traveltime = vlen (delta) / tspeed;
173 self.avelocity = delta * (1 / traveltime);
176 self.finalangle = destangle;
178 self.think = SUB_CalcAngleMoveDone;
179 self.nextthink = self.ltime + traveltime;
182 void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeed, void() func)
189 SUB_CalcAngleMove (destangle, tspeed, func);
198 unused but required by the engine
212 Play a sound at the given location
215 void PointSound (vector org, string snd, float vol, float attn)
220 setorigin (speaker, org);
221 sound (speaker, CHAN_BODY, snd, vol, attn);
231 A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE things with a trace attack
234 void traceline_hitcorpse (entity source, vector v1, vector v2, float nomonst, entity forent)
238 oldsolid = source.solid;
239 source.solid = SOLID_BBOX;
241 traceline (v1, v2, nomonst, forent);
243 source.solid = oldsolid;
250 Returns a point at least 12 units away from walls
251 (useful for explosion animations, although the blast is performed where it really happened)
255 vector findbetterlocation (vector org)
259 traceline (org, org - '12 0 0', TRUE, world);
260 if (trace_fraction < 1)
263 traceline (loc, loc + '12 0 0', TRUE, world);
264 if (trace_fraction >= 1)
265 org = loc + '12 0 0';
268 traceline (org, org - '-12 0 0', TRUE, world);
269 if (trace_fraction < 1)
272 traceline (loc, loc + '-12 0 0', TRUE, world);
273 if (trace_fraction >= 1)
274 org = loc + '-12 0 0';
277 traceline (org, org - '0 12 0' , TRUE, world);
278 if (trace_fraction < 1)
281 traceline (loc, loc + '0 12 0', TRUE, world);
282 if (trace_fraction >= 1)
283 org = loc + '0 12 0';
286 traceline (org, org - '0 -12 0', TRUE, world);
287 if (trace_fraction < 1)
290 traceline (loc, loc + '0 -12 0', TRUE, world);
291 if (trace_fraction >= 1)
292 org = loc + '0 -12 0';
295 traceline (org, org - '0 0 12' , TRUE, world);
296 if (trace_fraction < 1)
299 traceline (loc, loc + '0 0 12', TRUE, world);
300 if (trace_fraction >= 1)
301 org = loc + '0 0 12';
304 traceline (org, org - '0 0 -12', TRUE, world);
305 if (trace_fraction < 1)
308 traceline (loc, loc + '0 0 -12', TRUE, world);
309 if (trace_fraction >= 1)
310 org = loc + '0 0 -12';
320 Returns a random number between -1.0 and 1.0
325 return 2 * (random () - 0.5);
330 Angc used for animations
335 float angc (float a1, float a2)
367 if (self.movedir != '0 0 0')
368 self.movedir = normalize(self.movedir);
371 if (self.angles == '0 -1 0')
372 self.movedir = '0 0 1';
373 else if (self.angles == '0 -2 0')
374 self.movedir = '0 0 -1';
377 makevectors (self.angles);
378 self.movedir = v_forward;
382 self.angles = '0 0 0';
387 // trigger angles are used for one-way touches. An angle of 0 is assumed
388 // to mean no restrictions, so use a yaw of 360 instead.
389 if (self.movedir == '0 0 0')
390 if (self.angles != '0 0 0')
392 self.solid = SOLID_TRIGGER;
393 setmodel (self, self.model); // set size and link into world
394 self.movetype = MOVETYPE_NONE;
399 void() InitSolidBSPTrigger =
401 // trigger angles are used for one-way touches. An angle of 0 is assumed
402 // to mean no restrictions, so use a yaw of 360 instead.
403 if (self.movedir == '0 0 0')
404 if (self.angles != '0 0 0')
406 self.solid = SOLID_BSP;
407 setmodel (self, self.model); // set size and link into world
408 self.movetype = MOVETYPE_PUSH;
409 // self.modelindex = 0;