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