float turret_send(entity to, float sf)
{
- WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
-
+ dprint("Sending update\n");
+ WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
WriteByte(MSG_ENTITY, sf);
if(sf & TNSF_SETUP)
{
}
if(sf & TNSF_ANG)
- {
- WriteAngle(MSG_ENTITY, self.tur_head.angles_x);
- WriteAngle(MSG_ENTITY, self.tur_head.angles_y);
+ {
+ WriteShort(MSG_ENTITY, rint(self.tur_head.angles_x));
+ WriteShort(MSG_ENTITY, rint(self.tur_head.angles_y));
}
if(sf & TNSF_AVEL)
{
- WriteAngle(MSG_ENTITY, self.tur_head.avelocity_x);
- WriteAngle(MSG_ENTITY, self.tur_head.avelocity_y);
+ WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_x));
+ WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_y));
}
if(sf & TNSF_STATUS)
{
WriteByte(MSG_ENTITY, self.team);
- WriteByte(MSG_ENTITY, rint((self.health / self.tur_health) * 255));
+ WriteByte(MSG_ENTITY, rint((self.health / self.tur_health) * 255)); // Send health as 0-255 insted of real value, where 255 = 100%
}
return TRUE;
}
// CSQC
- if(self.SendEntity)
- self.SendFlags = TNSF_ANG;
+ self.SendFlags = TNSF_ANG;
return;
self.tur_head.avelocity_x = 0;
self.tur_head.angles_x = self.aim_maxpitch;
- if(self.SendEntity)
- self.SendFlags |= TNSF_ANG | TNSF_AVEL;
+ self.SendFlags |= TNSF_ANG;
}
if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) < -self.aim_maxpitch)
{
self.tur_head.avelocity_x = 0;
self.tur_head.angles_x = -self.aim_maxpitch;
-
- if(self.SendEntity)
- self.SendFlags |= TNSF_ANG | TNSF_AVEL;
+
+ self.SendFlags |= TNSF_ANG;
}
}
self.tur_head.avelocity_y = 0;
self.tur_head.angles_y = self.aim_maxrot;
- if(self.SendEntity)
- self.SendFlags |= TNSF_ANG | TNSF_AVEL;
+ self.SendFlags |= TNSF_ANG;
}
if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) < -self.aim_maxrot)
self.tur_head.avelocity_y = 0;
self.tur_head.angles_y = -self.aim_maxrot;
- if(self.SendEntity)
- self.SendFlags |= TNSF_ANG | TNSF_AVEL;
+ self.SendFlags |= TNSF_ANG;
}
}
+
+ self.SendFlags |= TNSF_AVEL;
- if(self.SendEntity)
+ // Force a angle update every 10'th frame
+ self.turret_framecounter += 1;
+ if(self.turret_framecounter >= 10)
{
- self.turret_framecounter += 1;
- if(self.turret_framecounter >= 4)
- {
- self.SendFlags |= TNSF_ANG | TNSF_AVEL;
- self.turret_framecounter = 0;
- }
- else
- self.SendFlags |= TNSF_AVEL;
- }
-
-
+ self.SendFlags |= TNSF_ANG;
+ self.turret_framecounter = 0;
+ }
}
entity e;
self.nextthink = time + self.ticrate;
- self.SendFlags = TNSF_UPDATE | TNSF_STATUS | TNSF_ANG | TNSF_AVEL;
+ //self.SendFlags = TNSF_UPDATE | TNSF_STATUS | TNSF_ANG | TNSF_AVEL;
// ONS uses somewhat backwards linking.
- if (teams_matter)
+ if (teamplay)
{
if not (g_onslaught)
if (self.target)
if not (self.spawnflags & TSF_NO_AMMO_REGEN)
if (self.ammo < self.ammo_max)
self.ammo = min(self.ammo + self.ammo_recharge, self.ammo_max);
-
- if (self.health < (self.tur_health * 0.5))
- if(random() < 0.25)
- te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
// Inactive turrets needs to run the think loop,
// So they can handle animation and wake up if need be.
Net_LinkEntity(self, TRUE, 0, turret_send);
self.think = turret_think;
self.nextthink = time;
+ self.tur_head.effects = EF_NODRAW;
}
void turrets_manager_think()
* (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)
{
if not (self.team)
self.team = 14; // Assume turrets are on the defending side if not explicitly set otehrwize
}
- else if not (teams_matter)
+ else if not (teamplay)
self.team = MAX_SHOT_DISTANCE; // Group all turrets into the same team, so they dont kill eachother.
else if(g_onslaught && self.targetname)
{
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;
else
self.idle_aim = '0 0 0';
- // Team color
- if (self.team == COLOR_TEAM1) self.colormod = '1.4 0.8 0.8';
- if (self.team == COLOR_TEAM2) self.colormod = '0.8 0.8 1.4';
-
// 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_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;
}