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