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