]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/tturrets.qc
Remove direct server #includes from client
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / tturrets.qc
1 #include "tturrets.qh"
2
3 #include "autocvars.qh"
4 #include "defs.qh"
5 #include "hud.qh"
6 #include "main.qh"
7 #include "miscfunctions.qh"
8 #include "movelib.qh"
9 #include "movetypes.qh"
10 #include "prandom.qh"
11 #include "teamradar.qh"
12 #include "waypointsprites.qh"
13
14 #include "../common/teams.qh"
15
16 #include "../server/tturrets/include/turrets_early.qh"
17
18 #include "../warpzonelib/anglestransform.qh"
19 #include "../warpzonelib/mathlib.qh"
20
21 .vector colormod;
22 .float cnt;
23 .float alpha;
24 .float gravity;
25
26 string tid2info_base;
27 string tid2info_head;
28 string tid2info_name;
29 vector  tid2info_min;
30 vector  tid2info_max;
31
32 void turret_tid2info(float _tid);
33 void turret_precache(float _tid);
34 float turret_is_precache[TID_LAST];
35
36 void turrets_precache()
37 {
38     turret_precache(TID_COMMON);
39 }
40
41 void turret_precache(int _tid)
42 {
43     if (!turret_is_precache[TID_COMMON])
44     {
45         precache_sound ("weapons/rocket_impact.wav");
46         precache_model ("models/turrets/base-gib1.md3");
47         precache_model ("models/turrets/base-gib2.md3");
48         precache_model ("models/turrets/base-gib3.md3");
49         precache_model ("models/turrets/base-gib4.md3");
50         precache_model ("models/turrets/head-gib1.md3");
51         precache_model ("models/turrets/head-gib2.md3");
52         precache_model ("models/turrets/head-gib3.md3");
53         precache_model ("models/turrets/head-gib4.md3");
54         precache_model ("models/turrets/base.md3");
55         precache_model ("models/turrets/rocket.md3");
56     }
57     turret_tid2info(_tid);
58     if(turret_is_precache[_tid])
59         return;
60
61     switch(_tid)
62     {
63         case TID_EWHEEL:
64             precache_model ("models/turrets/ewheel-base2.md3");
65             precache_model ("models/turrets/ewheel-gun1.md3");
66             break;
67         case TID_FLAC:
68             precache_model ("models/turrets/flac.md3");
69             break;
70         case TID_FUSION:
71             precache_model ("models/turrets/reactor.md3");
72             break;
73         case TID_HELLION:
74             precache_model ("models/turrets/hellion.md3");
75             break;
76         case TID_HK:
77             precache_model ("models/turrets/hk.md3");
78             break;
79         case TID_MACHINEGUN:
80             precache_model ("models/turrets/machinegun.md3");
81             precache_sound ("weapons/uzi_fire.wav");
82             break;
83         case TID_MLRS:
84             precache_model ("models/turrets/mlrs.md3");
85             break;
86         case TID_PHASER:
87             precache_model ("models/turrets/phaser.md3");
88             precache_model ("models/turrets/phaser_beam.md3");
89             precache_sound ("turrets/phaser.wav");
90             break;
91         case TID_PLASMA:
92             precache_model ("models/turrets/plasma.md3");
93             break;
94         case TID_PLASMA_DUAL:
95             precache_model ("models/turrets/plasmad.md3");
96             break;
97         case TID_TESLA:
98             precache_model ("models/turrets/tesla_head.md3");
99             precache_model ("models/turrets/tesla_base.md3");
100             break;
101         case TID_WALKER:
102             precache_model ("models/turrets/walker_head_minigun.md3");
103             precache_model ("models/turrets/walker_body.md3");
104             precache_sound ("weapons/uzi_fire.wav");
105             break;
106     }
107     turret_is_precache[_tid] = true;
108 }
109
110 void turret_tid2info(float _tid)
111 {
112     tid2info_base = "models/turrets/base.md3";
113     tid2info_min = '-32 -32 0';
114     tid2info_max = '32 32 64';
115
116     switch(_tid)
117     {
118         case TID_EWHEEL:
119             tid2info_base = "models/turrets/ewheel-base2.md3";
120             tid2info_head = "models/turrets/ewheel-gun1.md3";
121             tid2info_name = "eWheel";
122             break;
123         case TID_FLAC:
124             tid2info_head = "models/turrets/flac.md3";
125             tid2info_name = "Flac Cannon";
126             break;
127         case TID_FUSION:
128             tid2info_head = "models/turrets/reactor.md3";
129             tid2info_name = "Fusion Reactor";
130             tid2info_min = '-34 -34 0';
131             tid2info_max = '34 34 90';
132             break;
133         case TID_HELLION:
134             tid2info_head = "models/turrets/hellion.md3";
135             tid2info_name = "Hellion";
136             break;
137         case TID_HK:
138             tid2info_head = "models/turrets/hk.md3";
139             tid2info_name = "Hunter-Killer";
140             break;
141         case TID_MACHINEGUN:
142             tid2info_head = "models/turrets/machinegun.md3";
143             tid2info_name = "Machinegun";
144             break;
145         case TID_MLRS:
146             tid2info_head = "models/turrets/mlrs.md3";
147             tid2info_name = "MLRS";
148             break;
149         case TID_PHASER:
150             tid2info_head = "models/turrets/phaser.md3";
151             tid2info_name = "Phaser";
152             break;
153         case TID_PLASMA:
154             tid2info_head = "models/turrets/plasma.md3";
155             tid2info_name = "Plasma";
156             break;
157         case TID_PLASMA_DUAL:
158             tid2info_head = "models/turrets/plasmad.md3";
159             tid2info_name = "Dual Plasma";
160             break;
161         case TID_TESLA:
162             tid2info_base = "models/turrets/tesla_base.md3";
163             tid2info_head = "models/turrets/tesla_head.md3";
164             tid2info_name = "Tesla coil";
165             tid2info_min = '-60 -60 0';
166             tid2info_max  ='60 60 128';
167             break;
168         case TID_WALKER:
169             tid2info_base = "models/turrets/walker_body.md3";
170             tid2info_head = "models/turrets/walker_head_minigun.md3";
171             tid2info_name = "Walker";
172             tid2info_min = '-70 -70 0';
173             tid2info_max = '70 70 95';
174             break;
175     }
176 }
177
178 void turret_remove()
179 {
180     remove(self.tur_head);
181     //remove(self.enemy);
182     self.tur_head = world;
183 }
184
185 class(Turret) .vector glowmod;
186 void turret_changeteam()
187 {
188         switch(self.team - 1)
189         {
190         case NUM_TEAM_1: // Red
191             self.glowmod = '2 0 0';
192             self.teamradar_color = '1 0 0';
193             break;
194
195         case NUM_TEAM_2: // Blue
196             self.glowmod = '0 0 2';
197             self.teamradar_color = '0 0 1';
198             break;
199
200         case NUM_TEAM_3: // Yellow
201             self.glowmod = '1 1 0';
202             self.teamradar_color = '1 1 0';
203             break;
204
205         case NUM_TEAM_4: // Pink
206             self.glowmod = '1 0 1';
207             self.teamradar_color = '1 0 1';
208             break;
209         }
210
211         if(self.team)
212         self.colormap = 1024 + (self.team - 1) * 17;
213
214         self.tur_head.colormap = self.colormap;
215         self.tur_head.glowmod = self.glowmod;
216
217 }
218
219 void turret_head_draw()
220 {
221     self.drawmask = MASK_NORMAL;
222 }
223
224 void turret_draw()
225 {
226     float dt;
227
228     dt = time - self.move_time;
229     self.move_time = time;
230     if(dt <= 0)
231         return;
232
233     self.tur_head.angles += dt * self.tur_head.move_avelocity;
234
235     if (self.health < 127)
236     {
237         dt = random();
238
239         if(dt < 0.03)
240             te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
241     }
242
243     if(self.health < 85)
244     if(dt < 0.01)
245         pointparticles(particleeffectnum("smoke_large"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
246
247     if(self.health < 32)
248     if(dt < 0.015)
249         pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
250
251 }
252
253 void turret_draw2d()
254 {
255         if(self.netname == "")
256             return;
257
258         if(!autocvar_g_waypointsprite_turrets)
259                 return;
260
261     if(autocvar_cl_hidewaypoints)
262         return;
263
264         float dist = vlen(self.origin - view_origin);
265     float t = (GetPlayerColor(player_localnum) + 1);
266
267         vector o;
268         string txt;
269
270         if(autocvar_cl_vehicles_hud_tactical)
271         if(dist < 10240 && t != self.team)
272         {
273         // TODO: Vehicle tactical hud
274         o = project_3d_to_2d(self.origin + '0 0 32');
275         if(o.z < 0
276         || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
277         || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
278         || o.x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
279         || o.y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
280             return; // Dont draw wp's for turrets out of view
281         o.z = 0;
282         if(hud != HUD_NORMAL)
283         {
284             switch(hud)
285             {
286                 case HUD_SPIDERBOT:
287                 case HUD_WAKIZASHI:
288                 case HUD_RAPTOR:
289                 case HUD_BUMBLEBEE:
290                     if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
291                         txt = "gfx/vehicles/vth-mover.tga";
292                     else
293                         txt = "gfx/vehicles/vth-stationary.tga";
294
295                     vector pz = drawgetimagesize(txt) * 0.25;
296                     drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.75, DRAWFLAG_NORMAL);
297                     break;
298             }
299         }
300         }
301
302         if(dist > self.maxdistance)
303         return;
304
305         string spriteimage = self.netname;
306         float a = self.alpha * autocvar_hud_panel_fg_alpha;
307         vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
308
309
310         if(self.maxdistance > waypointsprite_normdistance)
311                 a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
312         else if(self.maxdistance > 0)
313                 a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
314
315         if(rgb == '0 0 0')
316         {
317                 self.teamradar_color = '1 0 1';
318                 printf("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
319         }
320
321         txt = self.netname;
322         if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
323                 txt = _("Spam");
324         else
325                 txt = spritelookuptext(spriteimage);
326
327         if(time - floor(time) > 0.5 && t == self.team)
328         {
329                 if(self.helpme && time < self.helpme)
330                 {
331                     a *= SPRITE_HELPME_BLINK;
332                     txt = sprintf(_("%s under attack!"), txt);
333                 }
334                 else
335                         a *= spritelookupblinkvalue(spriteimage);
336         }
337
338         if(autocvar_g_waypointsprite_uppercase)
339                 txt = strtoupper(txt);
340
341         if(a > 1)
342         {
343                 rgb *= a;
344                 a = 1;
345         }
346
347         if(a <= 0)
348             return;
349
350         rgb = fixrgbexcess(rgb);
351
352         o = project_3d_to_2d(self.origin + '0 0 64');
353         if(o.z < 0
354         || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
355         || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
356         || o.x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
357         || o.y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
358             return; // Dont draw wp's for turrets out of view
359
360         o.z = 0;
361
362         float edgedistance_min, crosshairdistance;
363                 edgedistance_min = min((o.y - (vid_conheight * waypointsprite_edgeoffset_top)),
364         (o.x - (vid_conwidth * waypointsprite_edgeoffset_left)),
365         (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x,
366         (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y);
367
368         float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
369
370         crosshairdistance = sqrt( pow(o.x - vid_conwidth/2, 2) + pow(o.y - vid_conheight/2, 2) );
371
372         t = waypointsprite_scale * vidscale;
373         a *= waypointsprite_alpha;
374
375         {
376                 a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
377                 t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
378         }
379         if (edgedistance_min < waypointsprite_edgefadedistance) {
380                 a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
381                 t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
382         }
383         if(crosshairdistance < waypointsprite_crosshairfadedistance) {
384                 a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
385                 t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
386         }
387
388         o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t);
389     o = drawspritetext(o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
390     drawhealthbar(
391             o,
392             0,
393             self.health / 255,
394             '0 0 0',
395             '0 0 0',
396             0.5 * SPRITE_HEALTHBAR_WIDTH * t,
397             0.5 * SPRITE_HEALTHBAR_HEIGHT * t,
398             SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize,
399             SPRITE_HEALTHBAR_BORDER * t,
400             0,
401             rgb,
402             a * SPRITE_HEALTHBAR_BORDERALPHA,
403             rgb,
404             a * SPRITE_HEALTHBAR_HEALTHALPHA,
405             DRAWFLAG_NORMAL
406             );
407 }
408
409 void turret_walker_draw()
410 {
411     float dt;
412
413     dt = time - self.move_time;
414     self.move_time = time;
415     if(dt <= 0)
416         return;
417
418     fixedmakevectors(self.angles);
419     movelib_groundalign4point(300, 100, 0.25, 45);
420     setorigin(self, self.origin + self.velocity * dt);
421     self.tur_head.angles += dt * self.tur_head.move_avelocity;
422     self.angles_y = self.move_angles.y;
423
424     if (self.health < 127)
425     if(random() < 0.15)
426         te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
427 }
428
429 void turret_ewheel_draw()
430 {
431     float dt;
432
433     dt = time - self.move_time;
434     self.move_time = time;
435     if(dt <= 0)
436         return;
437
438     fixedmakevectors(self.angles);
439     setorigin(self, self.origin + self.velocity * dt);
440     self.tur_head.angles += dt * self.tur_head.move_avelocity;
441     self.angles_y = self.move_angles.y;
442
443     if (self.health < 127)
444     if(random() < 0.05)
445         te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
446 }
447
448 void turret_construct()
449 {
450     if(self.tur_head == world)
451         self.tur_head = spawn();
452
453     turret_tid2info(self.turret_type);
454     self.netname = tid2info_name;
455
456     setorigin(self, self.origin);
457     setmodel(self, tid2info_base);
458     setmodel(self.tur_head, tid2info_head);
459     setsize(self, tid2info_min, tid2info_max);
460     setsize(self.tur_head, '0 0 0', '0 0 0');
461
462     if(self.turret_type == TID_EWHEEL)
463         setattachment(self.tur_head, self, "");
464     else
465         setattachment(self.tur_head, self, "tag_head");
466
467     self.tur_head.classname     = "turret_head";
468     self.tur_head.owner         = self;
469     self.tur_head.move_movetype = MOVETYPE_NOCLIP;
470     self.move_movetype          = MOVETYPE_NOCLIP;
471     self.tur_head.angles        = self.angles;
472     self.health                 = 255;
473     self.solid                  = SOLID_BBOX;
474     self.tur_head.solid         = SOLID_NOT;
475     self.movetype               = MOVETYPE_NOCLIP;
476     self.tur_head.movetype      = MOVETYPE_NOCLIP;
477     self.draw                   = turret_draw;
478     self.entremove              = turret_remove;
479     self.drawmask               = MASK_NORMAL;
480     self.tur_head.drawmask      = MASK_NORMAL;
481     self.anim_start_time        = 0;
482     self.draw2d = turret_draw2d;
483     self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
484     self.teamradar_color = '1 0 0';
485     self.alpha = 1;
486
487     if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
488     {
489         self.gravity            = 1;
490         self.movetype           = MOVETYPE_BOUNCE;
491         self.move_movetype      = MOVETYPE_BOUNCE;
492         self.move_origin        = self.origin;
493         self.move_time          = time;
494         switch(self.turret_type)
495         {
496             case TID_EWHEEL:
497                 self.draw               = turret_ewheel_draw;
498                 break;
499             case TID_WALKER:
500                 self.draw               = turret_walker_draw;
501                 break;
502
503         }
504     }
505 }
506
507 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
508 void turret_gibboom();
509 void turret_gib_draw()
510 {
511     Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
512
513     self.drawmask = MASK_NORMAL;
514
515         if(self.cnt)
516         {
517             if(time >= self.nextthink)
518             {
519             turret_gibboom();
520             remove(self);
521             }
522         }
523         else
524         {
525         self.alpha = bound(0, self.nextthink - time, 1);
526         if(self.alpha < ALPHA_MIN_VISIBLE)
527             remove(self);
528         }
529 }
530
531 void turret_gibboom()
532 {
533     float i;
534
535     sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
536     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
537
538     for (i = 1; i < 5; i = i + 1)
539         turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', false);
540 }
541
542 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
543 {
544     entity gib;
545
546     traceline(_from, _to, MOVE_NOMONSTERS, world);
547     if(trace_startsolid)
548         return world;
549
550     gib = spawn();
551     setorigin(gib, _from);
552     setmodel(gib, _model);
553     gib.colormod    = _cmod;
554         gib.solid       = SOLID_CORPSE;
555     gib.draw        = turret_gib_draw;
556     gib.cnt         = _explode;
557     setsize(gib, '-1 -1 -1', '1 1 1');
558     if(_explode)
559     {
560         gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
561         gib.effects = EF_FLAME;
562     }
563     else
564         gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
565
566     gib.gravity         = 1;
567         gib.move_movetype   = MOVETYPE_BOUNCE;
568         gib.move_origin     = _from;
569         setorigin(gib,        _from);
570         gib.move_velocity   = _to;
571         gib.move_avelocity  = prandomvec() * 32;
572         gib.move_time       = time;
573         gib.damageforcescale = 1;
574         gib.classname = "turret_gib";
575
576         return gib;
577 }
578
579 void turret_die()
580 {
581
582     sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
583     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
584     turret_tid2info(self.turret_type);
585     if (!autocvar_cl_nogibs)
586     {
587         // Base
588         if(self.turret_type == TID_EWHEEL)
589             turret_gibtoss(tid2info_base, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', true);
590         else if (self.turret_type == TID_WALKER)
591             turret_gibtoss(tid2info_base, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', true);
592         else if (self.turret_type == TID_TESLA)
593             turret_gibtoss(tid2info_base, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
594         else
595         {
596             if (random() > 0.5)
597             {
598                 turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
599                 turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
600                 turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
601             }
602             else
603                 turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 8', '0 0 0', '0 0 0', true);
604
605             entity headgib = turret_gibtoss(tid2info_head, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', true);
606             if(headgib)
607             {
608                 headgib.angles = headgib.move_angles = self.tur_head.angles;
609                 headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
610                 headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity.y * 5;
611                 headgib.gravity = 0.5;
612             }
613         }
614     }
615
616     setmodel(self, "null");
617     setmodel(self.tur_head, "null");
618 }
619
620 void ent_turret()
621 {
622     int sf = ReadByte();
623
624         if(sf & TNSF_SETUP)
625         {
626             self.turret_type = ReadByte();
627
628             self.origin_x = ReadCoord();
629             self.origin_y = ReadCoord();
630             self.origin_z = ReadCoord();
631             setorigin(self, self.origin);
632
633             self.angles_x = ReadAngle();
634             self.angles_y = ReadAngle();
635
636             turret_precache(self.turret_type);
637             turret_construct();
638             self.colormap = 1024;
639             self.glowmod = '0 1 1';
640             self.tur_head.colormap = self.colormap;
641             self.tur_head.glowmod = self.glowmod;
642     }
643
644     if(sf & TNSF_ANG)
645     {
646         if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
647             self.tur_head = spawn();
648
649         self.tur_head.move_angles_x = ReadShort();
650         self.tur_head.move_angles_y = ReadShort();
651         //self.tur_head.angles = self.angles + self.tur_head.move_angles;
652         self.tur_head.angles = self.tur_head.move_angles;
653     }
654
655     if(sf & TNSF_AVEL)
656     {
657         if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
658             self.tur_head = spawn();
659
660         self.tur_head.move_avelocity_x = ReadShort();
661         self.tur_head.move_avelocity_y = ReadShort();
662     }
663
664     if(sf & TNSF_MOVE)
665     {
666         self.origin_x = ReadShort();
667         self.origin_y = ReadShort();
668         self.origin_z = ReadShort();
669         setorigin(self, self.origin);
670
671         self.velocity_x = ReadShort();
672         self.velocity_y = ReadShort();
673         self.velocity_z = ReadShort();
674
675         self.move_angles_y = ReadShort();
676
677         self.move_time     = time;
678         self.move_velocity = self.velocity;
679         self.move_origin   = self.origin;
680     }
681
682     if(sf & TNSF_ANIM)
683     {
684         self.frame1time = ReadCoord();
685         self.frame      = ReadByte();
686     }
687
688     if(sf & TNSF_STATUS)
689     {
690         int _tmp = ReadByte();
691         if(_tmp != self.team)
692         {
693             self.team = _tmp;
694             turret_changeteam();
695         }
696
697         _tmp = ReadByte();
698         if(_tmp == 0 && self.health != 0)
699             turret_die();
700         else if(self.health && self.health != _tmp)
701             self.helpme = servertime + 10;
702
703         self.health = _tmp;
704     }
705     //self.enemy.health = self.health / 255;
706 }