11 void turret_changeteam()
13 self.glowmod = Team_ColorRGB(self.team - 1) * 2;
14 self.teamradar_color = Team_ColorRGB(self.team - 1);
17 self.colormap = 1024 + (self.team - 1) * 17;
19 self.tur_head.colormap = self.colormap;
20 self.tur_head.glowmod = self.glowmod;
24 void turret_head_draw()
26 self.drawmask = MASK_NORMAL;
33 dt = time - self.move_time;
34 self.move_time = time;
38 self.tur_head.angles += dt * self.tur_head.move_avelocity;
40 if (self.health < 127)
45 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
50 pointparticles(particleeffectnum(EFFECT_SMOKE_LARGE), (self.origin + (randomvec() * 80)), '0 0 0', 1);
54 pointparticles(particleeffectnum(EFFECT_SMOKE_SMALL), (self.origin + (randomvec() * 80)), '0 0 0', 1);
60 if(self.netname == "")
63 if(!autocvar_g_waypointsprite_turrets)
66 if(autocvar_cl_hidewaypoints)
69 float dist = vlen(self.origin - view_origin);
70 float t = (GetPlayerColor(player_localnum) + 1);
75 if(autocvar_cl_vehicles_hud_tactical)
76 if(dist < 10240 && t != self.team)
78 // TODO: Vehicle tactical hud
79 o = project_3d_to_2d(self.origin + '0 0 32');
81 || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
82 || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
83 || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
84 || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
85 return; // Dont draw wp's for turrets out of view
89 if((get_turretinfo(self.turretid)).spawnflags & TUR_FLAG_MOVE)
90 txt = "gfx/vehicles/turret_moving.tga";
92 txt = "gfx/vehicles/turret_stationary.tga";
94 vector pz = drawgetimagesize(txt) * autocvar_cl_vehicles_crosshair_size;
95 drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.7, DRAWFLAG_NORMAL);
99 if(dist > self.maxdistance)
102 string spriteimage = self.netname;
103 float a = self.alpha * autocvar_hud_panel_fg_alpha;
104 vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
107 if(self.maxdistance > waypointsprite_normdistance)
108 a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
109 else if(self.maxdistance > 0)
110 a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
114 self.teamradar_color = '1 0 1';
115 LOG_INFOF("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
119 if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
122 txt = spritelookuptext(spriteimage);
124 if(time - floor(time) > 0.5 && t == self.team)
126 if(self.helpme && time < self.helpme)
128 a *= SPRITE_HELPME_BLINK;
129 txt = sprintf(_("%s under attack!"), txt);
132 a *= spritelookupblinkvalue(spriteimage);
135 if(autocvar_g_waypointsprite_uppercase)
136 txt = strtoupper(txt);
147 rgb = fixrgbexcess(rgb);
149 o = project_3d_to_2d(self.origin + '0 0 64');
151 || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
152 || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
153 || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
154 || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
155 return; // Dont draw wp's for turrets out of view
159 float edgedistance_min, crosshairdistance;
160 edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
161 (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
162 (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
163 (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
165 float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
167 crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
169 t = waypointsprite_scale * vidscale;
170 a *= waypointsprite_alpha;
173 a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
174 t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
176 if (edgedistance_min < waypointsprite_edgefadedistance) {
177 a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
178 t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
180 if(crosshairdistance < waypointsprite_crosshairfadedistance) {
181 a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
182 t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
185 o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t);
186 o = drawspritetext(o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
193 0.5 * SPRITE_HEALTHBAR_WIDTH * t,
194 0.5 * SPRITE_HEALTHBAR_HEIGHT * t,
195 SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize,
196 SPRITE_HEALTHBAR_BORDER * t,
199 a * SPRITE_HEALTHBAR_BORDERALPHA,
201 a * SPRITE_HEALTHBAR_HEALTHALPHA,
206 void turret_construct()
208 entity tur = get_turretinfo(self.turretid);
210 if(self.tur_head == world)
211 self.tur_head = spawn();
213 self.netname = TUR_NAME(self.turretid);
215 setorigin(self, self.origin);
216 _setmodel(self, tur.model);
217 _setmodel(self.tur_head, tur.head_model);
218 setsize(self, tur.mins, tur.maxs);
219 setsize(self.tur_head, '0 0 0', '0 0 0');
221 if(self.turretid == TUR_EWHEEL.m_id)
222 setattachment(self.tur_head, self, "");
224 setattachment(self.tur_head, self, "tag_head");
226 self.tur_head.classname = "turret_head";
227 self.tur_head.owner = self;
228 self.tur_head.move_movetype = MOVETYPE_NOCLIP;
229 self.move_movetype = MOVETYPE_NOCLIP;
230 self.tur_head.angles = self.angles;
232 self.solid = SOLID_BBOX;
233 self.tur_head.solid = SOLID_NOT;
234 self.movetype = MOVETYPE_NOCLIP;
235 self.tur_head.movetype = MOVETYPE_NOCLIP;
236 self.draw = turret_draw;
237 self.entremove = turret_remove;
238 self.drawmask = MASK_NORMAL;
239 self.tur_head.drawmask = MASK_NORMAL;
240 self.anim_start_time = 0;
241 self.draw2d = turret_draw2d;
242 self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
243 self.teamradar_color = '1 0 0';
246 TUR_ACTION(self.turretid, TR_SETUP);
249 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
250 void turret_gibboom();
251 void turret_gib_draw()
253 Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
255 self.drawmask = MASK_NORMAL;
259 if(time >= self.nextthink)
267 self.alpha = bound(0, self.nextthink - time, 1);
268 if(self.alpha < ALPHA_MIN_VISIBLE)
273 void turret_gibboom()
277 sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
278 pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
280 for (i = 1; i < 5; i = i + 1)
281 turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', false);
284 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
288 traceline(_from, _to, MOVE_NOMONSTERS, world);
293 setorigin(gib, _from);
294 _setmodel(gib, _model);
295 gib.colormod = _cmod;
296 gib.solid = SOLID_CORPSE;
297 gib.draw = turret_gib_draw;
299 setsize(gib, '-1 -1 -1', '1 1 1');
302 gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
303 gib.effects = EF_FLAME;
306 gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
309 gib.move_movetype = MOVETYPE_BOUNCE;
310 gib.move_origin = _from;
311 setorigin(gib, _from);
312 gib.move_velocity = _to;
313 gib.move_avelocity = prandomvec() * 32;
314 gib.move_time = time;
315 gib.damageforcescale = 1;
316 gib.classname = "turret_gib";
323 sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
324 pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
325 if (!autocvar_cl_nogibs)
328 if(self.turretid == TUR_EWHEEL.m_id)
329 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);
330 else if (self.turretid == TUR_WALKER.m_id)
331 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);
332 else if (self.turretid == TUR_TESLA.m_id)
333 turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
338 turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
339 turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
340 turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
343 turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 8', '0 0 0', '0 0 0', true);
345 entity headgib = turret_gibtoss((get_turretinfo(self.turretid)).head_model, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', true);
348 headgib.angles = headgib.move_angles = self.tur_head.angles;
349 headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
350 headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
351 headgib.gravity = 0.5;
356 setmodel(self, MDL_Null);
357 setmodel(self.tur_head, MDL_Null);
367 self.turretid = ReadByte();
369 self.origin_x = ReadCoord();
370 self.origin_y = ReadCoord();
371 self.origin_z = ReadCoord();
372 setorigin(self, self.origin);
374 self.angles_x = ReadAngle();
375 self.angles_y = ReadAngle();
378 self.colormap = 1024;
379 self.glowmod = '0 1 1';
380 self.tur_head.colormap = self.colormap;
381 self.tur_head.glowmod = self.glowmod;
386 if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
387 self.tur_head = spawn();
389 self.tur_head.move_angles_x = ReadShort();
390 self.tur_head.move_angles_y = ReadShort();
391 //self.tur_head.angles = self.angles + self.tur_head.move_angles;
392 self.tur_head.angles = self.tur_head.move_angles;
397 if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
398 self.tur_head = spawn();
400 self.tur_head.move_avelocity_x = ReadShort();
401 self.tur_head.move_avelocity_y = ReadShort();
406 self.origin_x = ReadShort();
407 self.origin_y = ReadShort();
408 self.origin_z = ReadShort();
409 setorigin(self, self.origin);
411 self.velocity_x = ReadShort();
412 self.velocity_y = ReadShort();
413 self.velocity_z = ReadShort();
415 self.move_angles_y = ReadShort();
417 self.move_time = time;
418 self.move_velocity = self.velocity;
419 self.move_origin = self.origin;
424 self.frame1time = ReadCoord();
425 self.frame = ReadByte();
432 if(_tmp != self.team)
439 if(_tmp == 0 && self.health != 0)
441 else if(self.health && self.health != _tmp)
442 self.helpme = servertime + 10;
446 //self.enemy.health = self.health / 255;