laser: internally allow changes to origin
[divverent/nexuiz.git] / data / qcsrc / client / laser.qc
1 // a laser goes from origin in direction angles
2 // it has color 'colormod'
3 // and stops when something is in the way
4 .float cnt; // end effect
5 .vector colormod;
6 .float state; // on-off
7
8 void Draw_Laser()
9 {
10         if(!self.state)
11                 return;
12         makevectors(self.angles);
13         traceline(self.origin, self.origin + v_forward * 32768, 0, self);
14         Draw_CylindricLine(self.origin, trace_endpos, 2, "particles/laserbeam", 1, self.colormod, DRAWFLAG_ADDITIVE); // TODO make a texture to make the laser look smoother
15         pointparticles(self.cnt, trace_endpos, trace_plane_normal, 256 * drawframetime);
16 }
17
18 void Ent_Laser()
19 {
20         float f;
21         // 30 bytes, or 13 bytes for just moving
22         f = ReadByte();
23         if(f & 1)
24         {
25                 self.origin_x = ReadCoord();
26                 self.origin_y = ReadCoord();
27                 self.origin_z = ReadCoord();
28         }
29         if(f & 8)
30         {
31                 self.colormod_x = ReadByte() / 255.0;
32                 self.colormod_y = ReadByte() / 255.0;
33                 self.colormod_z = ReadByte() / 255.0;
34                 self.cnt = ReadShort(); // effect number
35         }
36         if(f & 2)
37         {
38                 self.angles_x = ReadCoord();
39                 self.angles_y = ReadCoord();
40         }
41         if(f & 4)
42                 self.state = ReadByte();
43         self.draw = Draw_Laser;
44 }