9 void turret_changeteam()
11 self.glowmod = Team_ColorRGB(self.team - 1) * 2;
12 self.teamradar_color = Team_ColorRGB(self.team - 1);
15 self.colormap = 1024 + (self.team - 1) * 17;
17 self.tur_head.colormap = self.colormap;
18 self.tur_head.glowmod = self.glowmod;
22 void turret_head_draw()
24 self.drawmask = MASK_NORMAL;
31 dt = time - self.move_time;
32 self.move_time = time;
36 self.tur_head.angles += dt * self.tur_head.move_avelocity;
38 if (self.health < 127)
43 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
48 pointparticles(particleeffectnum(EFFECT_SMOKE_LARGE), (self.origin + (randomvec() * 80)), '0 0 0', 1);
52 pointparticles(particleeffectnum(EFFECT_SMOKE_SMALL), (self.origin + (randomvec() * 80)), '0 0 0', 1);
58 if(self.netname == "")
61 if(!autocvar_g_waypointsprite_turrets)
64 if(autocvar_cl_hidewaypoints)
67 float dist = vlen(self.origin - view_origin);
68 float t = (GetPlayerColor(player_localnum) + 1);
73 if(autocvar_cl_vehicles_hud_tactical)
74 if(dist < 10240 && t != self.team)
76 // TODO: Vehicle tactical hud
77 o = project_3d_to_2d(self.origin + '0 0 32');
79 || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
80 || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
81 || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
82 || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
83 return; // Dont draw wp's for turrets out of view
87 if((get_turretinfo(self.turretid)).spawnflags & TUR_FLAG_MOVE)
88 txt = "gfx/vehicles/turret_moving.tga";
90 txt = "gfx/vehicles/turret_stationary.tga";
92 vector pz = drawgetimagesize(txt) * autocvar_cl_vehicles_crosshair_size;
93 drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.7, DRAWFLAG_NORMAL);
97 if(dist > self.maxdistance)
100 string spriteimage = self.netname;
101 float a = self.alpha * autocvar_hud_panel_fg_alpha;
102 vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
105 if(self.maxdistance > waypointsprite_normdistance)
106 a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
107 else if(self.maxdistance > 0)
108 a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
112 self.teamradar_color = '1 0 1';
113 LOG_INFOF("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
117 if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
120 txt = spritelookuptext(spriteimage);
122 if(time - floor(time) > 0.5 && t == self.team)
124 if(self.helpme && time < self.helpme)
126 a *= SPRITE_HELPME_BLINK;
127 txt = sprintf(_("%s under attack!"), txt);
130 a *= spritelookupblinkvalue(spriteimage);
133 if(autocvar_g_waypointsprite_uppercase)
134 txt = strtoupper(txt);
145 rgb = fixrgbexcess(rgb);
147 o = project_3d_to_2d(self.origin + '0 0 64');
149 || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
150 || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
151 || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
152 || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
153 return; // Dont draw wp's for turrets out of view
157 float edgedistance_min, crosshairdistance;
158 edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
159 (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
160 (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
161 (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
163 float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
165 crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
167 t = waypointsprite_scale * vidscale;
168 a *= waypointsprite_alpha;
171 a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
172 t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
174 if (edgedistance_min < waypointsprite_edgefadedistance) {
175 a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
176 t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
178 if(crosshairdistance < waypointsprite_crosshairfadedistance) {
179 a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
180 t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
183 o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t);
184 o = drawspritetext(o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
191 0.5 * SPRITE_HEALTHBAR_WIDTH * t,
192 0.5 * SPRITE_HEALTHBAR_HEIGHT * t,
193 SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize,
194 SPRITE_HEALTHBAR_BORDER * t,
197 a * SPRITE_HEALTHBAR_BORDERALPHA,
199 a * SPRITE_HEALTHBAR_HEALTHALPHA,
204 void turret_construct()
206 entity tur = get_turretinfo(self.turretid);
208 if(self.tur_head == world)
209 self.tur_head = spawn();
211 self.netname = TUR_NAME(self.turretid);
213 setorigin(self, self.origin);
214 _setmodel(self, tur.model);
215 _setmodel(self.tur_head, tur.head_model);
216 setsize(self, tur.mins, tur.maxs);
217 setsize(self.tur_head, '0 0 0', '0 0 0');
219 if(self.turretid == TUR_EWHEEL)
220 setattachment(self.tur_head, self, "");
222 setattachment(self.tur_head, self, "tag_head");
224 self.tur_head.classname = "turret_head";
225 self.tur_head.owner = self;
226 self.tur_head.move_movetype = MOVETYPE_NOCLIP;
227 self.move_movetype = MOVETYPE_NOCLIP;
228 self.tur_head.angles = self.angles;
230 self.solid = SOLID_BBOX;
231 self.tur_head.solid = SOLID_NOT;
232 self.movetype = MOVETYPE_NOCLIP;
233 self.tur_head.movetype = MOVETYPE_NOCLIP;
234 self.draw = turret_draw;
235 self.entremove = turret_remove;
236 self.drawmask = MASK_NORMAL;
237 self.tur_head.drawmask = MASK_NORMAL;
238 self.anim_start_time = 0;
239 self.draw2d = turret_draw2d;
240 self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
241 self.teamradar_color = '1 0 0';
244 TUR_ACTION(self.turretid, TR_SETUP);
247 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
248 void turret_gibboom();
249 void turret_gib_draw()
251 Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
253 self.drawmask = MASK_NORMAL;
257 if(time >= self.nextthink)
265 self.alpha = bound(0, self.nextthink - time, 1);
266 if(self.alpha < ALPHA_MIN_VISIBLE)
271 void turret_gibboom()
275 sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
276 pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
278 for (i = 1; i < 5; i = i + 1)
279 turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', false);
282 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
286 traceline(_from, _to, MOVE_NOMONSTERS, world);
291 setorigin(gib, _from);
292 _setmodel(gib, _model);
293 gib.colormod = _cmod;
294 gib.solid = SOLID_CORPSE;
295 gib.draw = turret_gib_draw;
297 setsize(gib, '-1 -1 -1', '1 1 1');
300 gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
301 gib.effects = EF_FLAME;
304 gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
307 gib.move_movetype = MOVETYPE_BOUNCE;
308 gib.move_origin = _from;
309 setorigin(gib, _from);
310 gib.move_velocity = _to;
311 gib.move_avelocity = prandomvec() * 32;
312 gib.move_time = time;
313 gib.damageforcescale = 1;
314 gib.classname = "turret_gib";
321 sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
322 pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
323 if (!autocvar_cl_nogibs)
326 if(self.turretid == TUR_EWHEEL)
327 turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', true);
328 else if (self.turretid == TUR_WALKER)
329 turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', true);
330 else if (self.turretid == TUR_TESLA)
331 turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
336 turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
337 turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
338 turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
341 turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 8', '0 0 0', '0 0 0', true);
343 entity headgib = turret_gibtoss((get_turretinfo(self.turretid)).head_model, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', true);
346 headgib.angles = headgib.move_angles = self.tur_head.angles;
347 headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
348 headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
349 headgib.gravity = 0.5;
354 setmodel(self, MDL_Null);
355 setmodel(self.tur_head, MDL_Null);
365 self.turretid = ReadByte();
367 self.origin_x = ReadCoord();
368 self.origin_y = ReadCoord();
369 self.origin_z = ReadCoord();
370 setorigin(self, self.origin);
372 self.angles_x = ReadAngle();
373 self.angles_y = ReadAngle();
376 self.colormap = 1024;
377 self.glowmod = '0 1 1';
378 self.tur_head.colormap = self.colormap;
379 self.tur_head.glowmod = self.glowmod;
384 if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
385 self.tur_head = spawn();
387 self.tur_head.move_angles_x = ReadShort();
388 self.tur_head.move_angles_y = ReadShort();
389 //self.tur_head.angles = self.angles + self.tur_head.move_angles;
390 self.tur_head.angles = self.tur_head.move_angles;
395 if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
396 self.tur_head = spawn();
398 self.tur_head.move_avelocity_x = ReadShort();
399 self.tur_head.move_avelocity_y = ReadShort();
404 self.origin_x = ReadShort();
405 self.origin_y = ReadShort();
406 self.origin_z = ReadShort();
407 setorigin(self, self.origin);
409 self.velocity_x = ReadShort();
410 self.velocity_y = ReadShort();
411 self.velocity_z = ReadShort();
413 self.move_angles_y = ReadShort();
415 self.move_time = time;
416 self.move_velocity = self.velocity;
417 self.move_origin = self.origin;
422 self.frame1time = ReadCoord();
423 self.frame = ReadByte();
430 if(_tmp != self.team)
437 if(_tmp == 0 && self.health != 0)
439 else if(self.health && self.health != _tmp)
440 self.helpme = servertime + 10;
444 //self.enemy.health = self.health / 255;