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