2 #include "../dpdefs/csprogsdefs.qh"
3 #include "../common/buffs.qh"
4 #include "../csqcmodellib/interpolate.qh"
6 #include "../csqcmodellib/cl_model.qh"
12 // a laser goes from origin in direction angles
13 // it has color 'colormod'
14 // and stops when something is in the way
16 class(Laser) .int cnt; // end effect
17 class(Laser) .vector colormod;
18 class(Laser) .int state; // on-off
19 class(Laser) .int count; // flags for the laser
20 class(Laser) .vector velocity;
21 class(Laser) .float alpha;
22 class(Laser) .float scale; // scaling factor of the thickness
23 class(Laser) .float modelscale; // scaling factor of the dlight
29 InterpolateOrigin_Do();
34 trace_endpos = self.velocity;
35 trace_dphitq3surfaceflags = 0;
38 traceline(self.origin, self.velocity, 0, self);
44 makevectors(self.angles);
45 trace_endpos = self.origin + v_forward * 1048576;
46 trace_dphitq3surfaceflags = Q3SURFACEFLAG_SKY;
50 makevectors(self.angles);
51 traceline(self.origin, self.origin + v_forward * 32768, 0, self);
52 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
53 trace_endpos = self.origin + v_forward * 1048576;
60 Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL, view_origin);
64 Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin);
67 if (!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
70 pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000);
71 if(self.colormod != '0 0 0' && self.modelscale != 0)
72 adddynamiclight(trace_endpos + trace_plane_normal * 1, self.modelscale, self.colormod * 5);
78 InterpolateOrigin_Undo();
80 // 30 bytes, or 13 bytes for just moving
82 self.count = (f & 0xF0);
85 self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
87 self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
91 self.origin_x = ReadCoord();
92 self.origin_y = ReadCoord();
93 self.origin_z = ReadCoord();
94 setorigin(self, self.origin);
98 self.colormod_x = ReadByte() / 255.0;
99 self.colormod_y = ReadByte() / 255.0;
100 self.colormod_z = ReadByte() / 255.0;
102 self.alpha = ReadByte() / 255.0;
106 self.modelscale = 50;
109 self.scale *= ReadByte() / 16.0; // beam radius
110 self.modelscale *= ReadByte() / 16.0; // dlight radius
112 if((f & 0x80) || !(f & 0x10))
113 self.cnt = ReadShort() - 1; // effect number
121 self.velocity_x = ReadCoord();
122 self.velocity_y = ReadCoord();
123 self.velocity_z = ReadCoord();
127 self.angles_x = ReadAngle();
128 self.angles_y = ReadAngle();
132 self.state = ReadByte();
133 InterpolateOrigin_Note();
134 self.draw = Draw_Laser;