]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/laser.qc
iapply the vid_conwidth/height ratio for the sprites
[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 .float count; // flags for the laser
8 .vector velocity;
9 .float alpha;
10
11 // TODO move these into a heade file
12 float trace_dphitq3surfaceflags;
13 float Q3SURFACEFLAG_SKY = 4; // sky surface (also has NOIMPACT and NOMARKS set)
14 float Q3SURFACEFLAG_NOIMPACT = 16; // projectiles should remove themselves on impact (this is set on sky)
15
16 void Draw_Laser()
17 {
18         if(!self.state)
19                 return;
20         InterpolateOrigin_Do();
21         if(self.count & 0x80)
22         {
23                 traceline(self.origin, self.velocity, 0, self);
24         }
25         else
26         {
27                 makevectors(self.angles);
28                 traceline(self.origin, self.origin + v_forward * 32768, 0, self);
29                 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
30                         trace_endpos = self.origin + v_forward * 1048576;
31         }
32         if(self.alpha)
33         {
34                 Draw_CylindricLine(self.origin, trace_endpos, 2, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL); // TODO make a texture to make the laser look smoother
35         }
36         else
37         {
38                 Draw_CylindricLine(self.origin, trace_endpos, 2, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE); // TODO make a texture to make the laser look smoother
39         }
40         if not(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT))
41         {
42                 if(self.cnt >= 0)
43                         pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000);
44                 if(self.colormod != '0 0 0')
45                         R_AddDynamicLight(trace_endpos + trace_plane_normal * 1, 50, self.colormod * 5);
46         }
47 }
48
49 void Ent_Laser()
50 {
51         float f;
52         InterpolateOrigin_Undo();
53
54         // 30 bytes, or 13 bytes for just moving
55         f = ReadByte();
56         self.count = (f & 0xC0);
57
58         if(self.count & 0x80)
59                 self.iflags = IFLAG_VELOCITY;
60         else
61                 self.iflags = IFLAG_ANGLES;
62
63         if(f & 1)
64         {
65                 self.origin_x = ReadCoord();
66                 self.origin_y = ReadCoord();
67                 self.origin_z = ReadCoord();
68         }
69         if(f & 8)
70         {
71                 self.colormod_x = ReadByte() / 255.0;
72                 self.colormod_y = ReadByte() / 255.0;
73                 self.colormod_z = ReadByte() / 255.0;
74                 if(f & 0x40)
75                         self.alpha = ReadByte() / 255.0;
76                 else
77                         self.alpha = 0;
78                 self.cnt = ReadShort() - 1; // effect number
79         }
80         if(f & 2)
81         {
82                 if(f & 0x80)
83                 {
84                         self.velocity_x = ReadCoord();
85                         self.velocity_y = ReadCoord();
86                         self.velocity_z = ReadCoord();
87                 }
88                 else
89                 {
90                         self.angles_x = ReadCoord();
91                         self.angles_y = ReadCoord();
92                 }
93         }
94         if(f & 4)
95                 self.state = ReadByte();
96         InterpolateOrigin_Note();
97         self.draw = Draw_Laser;
98 }