6 #include "../common/buffs.qh"
8 #include "../csqcmodellib/cl_model.qh"
9 #include "../csqcmodellib/interpolate.qh"
11 #include "../dpdefs/csprogsdefs.qh"
14 // a laser goes from origin in direction angles
15 // it has color 'colormod'
16 // and stops when something is in the way
18 class(Laser) .int cnt; // end effect
19 class(Laser) .vector colormod;
20 class(Laser) .int state; // on-off
21 class(Laser) .int count; // flags for the laser
22 class(Laser) .vector velocity;
23 class(Laser) .float alpha;
24 class(Laser) .float scale; // scaling factor of the thickness
25 class(Laser) .float modelscale; // scaling factor of the dlight
31 InterpolateOrigin_Do();
36 trace_endpos = self.velocity;
37 trace_dphitq3surfaceflags = 0;
40 traceline(self.origin, self.velocity, 0, self);
46 makevectors(self.angles);
47 trace_endpos = self.origin + v_forward * 1048576;
48 trace_dphitq3surfaceflags = Q3SURFACEFLAG_SKY;
52 makevectors(self.angles);
53 traceline(self.origin, self.origin + v_forward * 32768, 0, self);
54 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
55 trace_endpos = self.origin + v_forward * 1048576;
62 Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL, view_origin);
66 Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin);
69 if (!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
72 pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000);
73 if(self.colormod != '0 0 0' && self.modelscale != 0)
74 adddynamiclight(trace_endpos + trace_plane_normal * 1, self.modelscale, self.colormod * 5);
80 InterpolateOrigin_Undo();
82 // 30 bytes, or 13 bytes for just moving
84 self.count = (f & 0xF0);
87 self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
89 self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
93 self.origin_x = ReadCoord();
94 self.origin_y = ReadCoord();
95 self.origin_z = ReadCoord();
96 setorigin(self, self.origin);
100 self.colormod_x = ReadByte() / 255.0;
101 self.colormod_y = ReadByte() / 255.0;
102 self.colormod_z = ReadByte() / 255.0;
104 self.alpha = ReadByte() / 255.0;
108 self.modelscale = 50;
111 self.scale *= ReadByte() / 16.0; // beam radius
112 self.modelscale *= ReadByte() / 16.0; // dlight radius
114 if((f & 0x80) || !(f & 0x10))
115 self.cnt = ReadShort() - 1; // effect number
123 self.velocity_x = ReadCoord();
124 self.velocity_y = ReadCoord();
125 self.velocity_z = ReadCoord();
129 self.angles_x = ReadAngle();
130 self.angles_y = ReadAngle();
134 self.state = ReadByte();
135 InterpolateOrigin_Note();
136 self.draw = Draw_Laser;