2 #include "../dpdefs/csprogsdefs.qh"
3 #include "../common/buffs.qh"
4 #include "../csqcmodellib/interpolate.qh"
7 #include "../csqcmodellib/cl_model.qh"
13 // a laser goes from origin in direction angles
14 // it has color 'colormod'
15 // and stops when something is in the way
17 class(Laser) .int cnt; // end effect
18 class(Laser) .vector colormod;
19 class(Laser) .int state; // on-off
20 class(Laser) .int count; // flags for the laser
21 class(Laser) .vector velocity;
22 class(Laser) .float alpha;
23 class(Laser) .float scale; // scaling factor of the thickness
24 class(Laser) .float modelscale; // scaling factor of the dlight
30 InterpolateOrigin_Do();
35 trace_endpos = self.velocity;
36 trace_dphitq3surfaceflags = 0;
39 traceline(self.origin, self.velocity, 0, self);
45 makevectors(self.angles);
46 trace_endpos = self.origin + v_forward * 1048576;
47 trace_dphitq3surfaceflags = Q3SURFACEFLAG_SKY;
51 makevectors(self.angles);
52 traceline(self.origin, self.origin + v_forward * 32768, 0, self);
53 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
54 trace_endpos = self.origin + v_forward * 1048576;
61 Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL, view_origin);
65 Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin);
68 if (!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
71 pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000);
72 if(self.colormod != '0 0 0' && self.modelscale != 0)
73 adddynamiclight(trace_endpos + trace_plane_normal * 1, self.modelscale, self.colormod * 5);
79 InterpolateOrigin_Undo();
81 // 30 bytes, or 13 bytes for just moving
83 self.count = (f & 0xF0);
86 self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
88 self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
92 self.origin_x = ReadCoord();
93 self.origin_y = ReadCoord();
94 self.origin_z = ReadCoord();
95 setorigin(self, self.origin);
99 self.colormod_x = ReadByte() / 255.0;
100 self.colormod_y = ReadByte() / 255.0;
101 self.colormod_z = ReadByte() / 255.0;
103 self.alpha = ReadByte() / 255.0;
107 self.modelscale = 50;
110 self.scale *= ReadByte() / 16.0; // beam radius
111 self.modelscale *= ReadByte() / 16.0; // dlight radius
113 if((f & 0x80) || !(f & 0x10))
114 self.cnt = ReadShort() - 1; // effect number
122 self.velocity_x = ReadCoord();
123 self.velocity_y = ReadCoord();
124 self.velocity_z = ReadCoord();
128 self.angles_x = ReadAngle();
129 self.angles_y = ReadAngle();
133 self.state = ReadByte();
134 InterpolateOrigin_Note();
135 self.draw = Draw_Laser;