]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/gamec/g_casings.c
add g_navnodeedit
[divverent/nexuiz.git] / data / qcsrc / gamec / g_casings.c
1 void() casingtouch =
2 {
3         if (other.solid == SOLID_BSP)
4         if (vlen(self.velocity) >= 50)
5         if (time >= self.attack_finished)
6         sound (self, CHAN_IMPACT, "weapons/tink1.ogg", 0.5, ATTN_NORM);
7         self.attack_finished = time + 0.2;
8         //self.touch = SUB_Null; // one tink is enough
9         //self.dest = self.origin - self.groundentity.origin;
10 };
11
12 void() casingthink =
13 {
14         local   float   p;
15         self.nextthink = time + 0.1;
16         if (self.flags & FL_ONGROUND)
17         {
18         // just keep the yaw angle
19                 self.angles_x = 0;
20                 self.angles_z = 0;
21                 self.flags = self.flags - FL_ONGROUND;
22                 self.nextthink = time + 0.5;
23         }
24         p = pointcontents(self.origin);
25         if (p == CONTENT_SOLID || p == CONTENT_LAVA || p == CONTENT_SKY)
26         {
27                 removedecor(self);
28                 return;
29         }
30         if (time > self.cnt)
31         {
32                 self.nextthink = time;
33                 self.alpha = self.alpha - frametime;
34                 if (self.alpha < 0.0625)
35                         removedecor(self);
36         }
37 };
38
39 // knock loose the casing when disturbed
40 void() casingknockedloosefunc =
41 {
42         self.movetype = MOVETYPE_BOUNCE;
43         self.flags = self.flags - (self.flags & FL_ONGROUND);
44         self.avelocity = randomvec() * 300;
45         self.nextthink = time + 0.1;
46         self.touch = casingtouch;
47 };
48
49 void(vector org, vector vel, float randomvel, vector ang, vector avel, float randomavel, float casingtype) SpawnCasing =
50 {
51         local entity e;
52         if (cvar("temp1") & 2048)
53                 return;
54
55         e = newdecor();
56         //e.isdecor = TRUE;
57         e.alpha = 1;
58         //e.forcescale = 15;
59         e.movetype = MOVETYPE_BOUNCE;
60         e.solid = SOLID_TRIGGER;
61         e.velocity = vel + randomvec() * randomvel;
62         e.angles = ang;
63         e.avelocity = avel + randomvec() * randomavel;
64         e.nextthink = time;
65         e.think = casingthink;
66         e.touch = casingtouch;
67         //e.knockedloosefunc = casingknockedloosefunc;
68         e.effects = EF_LOWPRECISION;
69         e.createdtime = time;
70         if (casingtype == 1)
71         {
72                 setmodel (e, "models/casing_shell.mdl");
73                 e.cnt = time + 30;
74                 // bias to make these be considered more important than other things
75                 e.createdtime = time + 1;
76         }
77         else if (casingtype == 2)
78         {
79                 setmodel (e, "models/casing_steel.mdl");
80                 e.cnt = time + 10;
81         }
82         else
83         {
84                 setmodel (e, "models/casing_bronze.mdl");
85                 e.cnt = time + 10;
86         }
87         if (maxclients == 1)
88                 e.cnt = time + 3000;
89         setsize (e, '0 0 -1', '0 0 -1');
90         setorigin (e, org);
91 };