#define cvar_base "g_turrets_unit_"
+.float clientframe;
+void turrets_setframe(float _frame, float client_only)
+{
+ if((client_only ? self.clientframe : self.frame ) != _frame)
+ {
+ self.SendFlags |= TNSF_ANIM;
+ self.anim_start_time = time;
+ }
+
+ if(client_only)
+ self.clientframe = _frame;
+ else
+ self.frame = _frame;
+
+}
float turret_send(entity to, float sf)
{
- dprint("Sending update\n");
+
WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
WriteByte(MSG_ENTITY, sf);
if(sf & TNSF_SETUP)
WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_y));
}
+ if(sf & TNSF_MOVE)
+ {
+ WriteShort(MSG_ENTITY, rint(self.origin_x));
+ WriteShort(MSG_ENTITY, rint(self.origin_y));
+ WriteShort(MSG_ENTITY, rint(self.origin_z));
+
+ WriteShort(MSG_ENTITY, rint(self.velocity_x));
+ WriteShort(MSG_ENTITY, rint(self.velocity_y));
+ WriteShort(MSG_ENTITY, rint(self.velocity_z));
+
+ WriteShort(MSG_ENTITY, rint(self.angles_y));
+ }
+
+ if(sf & TNSF_ANIM)
+ {
+ WriteCoord(MSG_ENTITY, self.anim_start_time);
+ WriteByte(MSG_ENTITY, self.frame);
+ }
+
if(sf & TNSF_STATUS)
{
WriteByte(MSG_ENTITY, self.team);
- WriteByte(MSG_ENTITY, rint((self.health / self.tur_health) * 255)); // Send health as 0-255 insted of real value, where 255 = 100%
+ if(self.health <= 0)
+ WriteByte(MSG_ENTITY, 0);
+ else
+ WriteByte(MSG_ENTITY, rint((self.health / self.tur_health) * 255)); // Send health as 0-255 insted of real value, where 255 = 100%
}
return TRUE;
self.tur_head.angles_y = anglemods(self.tur_head.angles_y);
// Find the diffrence between where we currently aim and where we want to aim
- move_angle = target_angle - (self.angles + self.tur_head.angles);
+ //move_angle = target_angle - (self.angles + self.tur_head.angles);
+ move_angle = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(self.angles), AnglesTransform_FromAngles(target_angle))) - self.tur_head.angles;
+
move_angle = shortangle_vxy(move_angle,(self.angles + self.tur_head.angles));
switch(self.track_type)
* (unless you have a very good reason not to)
* if the return value is 0, the turret should be removed.
*/
-float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base, string head, float _turret_type)
+float turret_stdproc_init (string cvar_base_name, string base, string head, float _turret_type)
{
entity e, ee;
e.think = turrets_manager_think;
e.nextthink = time + 2;
}
-#ifndef TTURRETS_CSQC
- csqc_shared = 0;
-#endif
+
/*
if(csqc_shared)
{
self.cvar_basename = cvar_base_name;
load_unit_settings(self, self.cvar_basename, 0);
+ self.effects = EF_NODRAW;
+
// Handle turret teams.
if (autocvar_g_assault != 0)
{
self.target_validate_flags = self.target_select_flags;
-
// Ammo stuff
if not (self.ammo_max)
self.ammo_max = self.shot_dmg * 10;
// Offsets & origins
if (!self.tur_shotorg) self.tur_shotorg = '50 0 50';
+
+ if (!self.health)
+ self.health = 150;
-// Gane hooks
+// Game hooks
if(MUTATOR_CALLHOOK(TurretSpawn))
return 0;
setorigin(self.tur_head, '0 0 0');
setattachment(self.tur_head, self, "tag_head");
- if (!self.health)
- self.health = 150;
-
self.tur_health = self.health;
self.solid = SOLID_BBOX;
self.tur_head.solid = SOLID_NOT;
self.idle_aim = '0 0 0';
// Attach stdprocs. override when and what needed
+ self.turret_firecheckfunc = turret_stdproc_firecheck;
+ self.turret_firefunc = turret_stdproc_fire;
+ self.event_damage = turret_stdproc_damage;
+
if (self.turrcaps_flags & TFL_TURRCAPS_SUPPORT)
- {
self.turret_score_target = turret_stdproc_targetscore_support;
- self.turret_firecheckfunc = turret_stdproc_firecheck;
- self.turret_firefunc = turret_stdproc_fire;
- self.event_damage = turret_stdproc_damage;
- }
else
- {
self.turret_score_target = turret_stdproc_targetscore_generic;
- self.turret_firecheckfunc = turret_stdproc_firecheck;
- self.turret_firefunc = turret_stdproc_fire;
- self.event_damage = turret_stdproc_damage;
- }
self.use = turret_stdproc_use;
self.bot_attack = TRUE;
self.use();
}
- Net_LinkEntity(self, TRUE, 0, turret_send);
+ turret_link();
turret_stdproc_respawn();
-
- // Initiate the main AI loop
- /*self.nextthink = time;
- if(csqc_shared)
- self.think = turret_link;
- else
- self.think = turret_think;
- */
+
+ if (!turret_tag_fire_update())
+ dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");
+
return 1;
}