]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/tturrets/units/turret_unit_common.qc
CTF!
[divverent/nexuiz.git] / data / qcsrc / server / tturrets / units / turret_unit_common.qc
1 float turret_tag_setup(float linked)\r
2 {\r
3     vector v;\r
4     float f;\r
5 \r
6     // Laters dooz\r
7     if(linked)\r
8         return 0;\r
9 \r
10     f = gettagindex(self,"tag_head");\r
11     v = gettaginfo(self,f);\r
12     v = v + self.origin;\r
13     setorigin(self.tur_head,v);\r
14 \r
15     f = gettagindex(self.tur_head,"tag_fire");\r
16     v = gettaginfo(self.tur_head,f) + (self.tur_head.origin - self.origin);\r
17     v_y *= -1;\r
18     self.tur_shotorg = v;\r
19 \r
20     f = gettagindex(self.tur_head,"tag_aim");\r
21     v = gettaginfo(self.tur_head,f) + (self.tur_head.origin - self.origin);\r
22     self.tur_aimorg  = v;\r
23 \r
24     return 1;\r
25 }\r
26 \r
27 float turret_tag_fire_update()\r
28 {\r
29     vector v;\r
30     float f;\r
31 \r
32     f = gettagindex(self.tur_head,"tag_fire");\r
33     v = gettaginfo(self.tur_head,f) + (self.tur_head.origin - self.origin);\r
34     v_y *= -1;\r
35     self.tur_shotorg = v;\r
36 \r
37     f = gettagindex(self.tur_head,"tag_aim");\r
38     v = gettaginfo(self.tur_head,f) + (self.tur_head.origin - self.origin);\r
39     self.tur_aimorg  = v;\r
40 \r
41     return 1;\r
42 }\r
43 \r
44 void FireImoBeam (vector start,vector end,vector smin,vector smax,\r
45                   float bforce,float f_dmg,float f_velfactor, float deathtype)\r
46 \r
47 {\r
48         local vector hitloc, force, endpoint, dir;\r
49         local entity ent;\r
50 \r
51         dir = normalize(end - start);\r
52         force = dir * bforce;\r
53 \r
54         // go a little bit into the wall because we need to hit this wall later\r
55         end = end + dir;\r
56 \r
57         // trace multiple times until we hit a wall, each obstacle will be made unsolid.\r
58         // note down which entities were hit so we can damage them later\r
59         while (1)\r
60         {\r
61         tracebox(start, smin, smax, end, FALSE, self);\r
62 \r
63                 // if it is world we can't hurt it so stop now\r
64                 if (trace_ent == world || trace_fraction == 1)\r
65                         break;\r
66 \r
67                 if (trace_ent.solid == SOLID_BSP)\r
68             break;\r
69 \r
70                 // make the entity non-solid so we can hit the next one\r
71                 trace_ent.railgunhit = TRUE;\r
72                 trace_ent.railgunhitloc = end;\r
73                 trace_ent.railgunhitsolidbackup = trace_ent.solid;\r
74 \r
75                 // stop if this is a wall\r
76 \r
77 \r
78                 // make the entity non-solid\r
79                 trace_ent.solid = SOLID_NOT;\r
80         }\r
81 \r
82         endpoint = trace_endpos;\r
83 \r
84         // find all the entities the railgun hit and restore their solid state\r
85         ent = findfloat(world, railgunhit, TRUE);\r
86         while (ent)\r
87         {\r
88                 // restore their solid type\r
89                 ent.solid = ent.railgunhitsolidbackup;\r
90                 ent = findfloat(ent, railgunhit, TRUE);\r
91         }\r
92 \r
93         // find all the entities the railgun hit and hurt them\r
94         ent = findfloat(world, railgunhit, TRUE);\r
95         while (ent)\r
96         {\r
97                 // get the details we need to call the damage function\r
98                 hitloc = ent.railgunhitloc;\r
99                 ent.railgunhitloc = '0 0 0';\r
100                 ent.railgunhitsolidbackup = SOLID_NOT;\r
101                 ent.railgunhit = FALSE;\r
102 \r
103                 // apply the damage\r
104                 if (ent.takedamage)\r
105                 {\r
106                         Damage (ent, self, self, f_dmg, deathtype, hitloc, force);\r
107             ent.velocity = ent.velocity * f_velfactor;\r
108             //ent.alpha = 0.25 + random() * 0.75;\r
109                 }\r
110 \r
111                 // advance to the next entity\r
112                 ent = findfloat(ent, railgunhit, TRUE);\r
113         }\r
114         trace_endpos = endpoint;\r
115 }\r
116 \r