]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/func.qc
Moved some functions to func.qc
[divverent/nexuiz.git] / qcsrc / func.qc
1
2 /*
3 ==================
4 SUB_Null
5
6 Do nothing
7 ==================
8 */
9 void SUB_Null (void)
10 {
11         
12 }
13
14 /*
15 ==================
16 SUB_Remove
17
18 Remove self
19 ==================
20 */
21 void SUB_Remove (void)
22 {
23         remove (self);
24 }
25
26 void SUB_SetFade_Think (void)
27 {
28         if (self.alpha < 0.06)  // don't let it reach 0, lest it become fully visible again
29                 remove (self);
30
31         self.alpha = self.alpha - 0.05;
32
33         self.think = SUB_SetFade_Think;
34         self.nextthink = time + 0.1;
35 }
36
37 /*
38 ==================
39 SUB_SetFade
40
41 Fade 'ent' out when time >= 'when'
42 ==================
43 */
44 void SUB_SetFade (entity ent, float when)
45 {
46         if (when < time)
47         {
48                         ent.think = SUB_Null;
49                         return;
50         }
51         
52         ent.alpha = 1.0;
53
54         ent.think = SUB_SetFade_Think;
55         ent.nextthink = when;
56 }
57
58 /*
59 ==================
60 main
61
62 unused but required by the engine
63 ==================
64 */
65 void main (void)
66 {
67         
68 }
69
70 // Sound functions
71
72 /*
73 ==================
74 PointSound
75
76 Play a sound at the given location
77 ==================
78 */
79 void PointSound (vector org, string snd, float vol, float attn)
80 {
81         entity  speaker;
82         
83         speaker = spawn ();
84         setorigin (speaker, org);
85         sound (speaker, CHAN_BODY, snd, vol, attn);
86         remove (speaker);
87 }
88
89 // Misc
90
91 /*
92 ==================
93 traceline_hitcorpse
94
95 A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE things with a trace attack
96 ==================
97 */
98 void traceline_hitcorpse (entity source, vector v1, vector v2, float nomonst, entity forent)
99 {
100         float   oldsolid;
101         
102         oldsolid = source.solid;
103         source.solid = SOLID_BBOX;
104         
105         traceline (v1, v2, nomonst, forent);
106         
107         source.solid = oldsolid;
108 }
109
110 /*
111 ==================
112 crandom
113
114 Returns a random number between -1.0 and 1.0
115 ==================
116 */
117 float crandom (void)
118 {
119         return 2 * (random () - 0.5);
120 }