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