self.deadflag = DEAD_DEAD;
self.tur_head.deadflag = self.deadflag;
-
+
sound (self, CHAN_PLAYER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
org2 = self.origin + '0 0 40';
self.solid = SOLID_NOT;
self.tur_head.solid = self.solid;
- self.alpha = -1;
- self.tur_head.alpha = self.alpha;
- self.customizeentityforclient = SUB_False;
- self.tur_head.customizeentityforclient = SUB_False;
-
self.event_damage = SUB_Null;
self.takedamage = DAMAGE_NO;
- self.effects = 0;
- self.tur_head.effects = self.effects;
+ self.effects = EF_NODRAW;
self.health = 0;
// Trow fake parts arround
}
}
-var const float SUB_NullFloat();
void turret_stdproc_respawn()
{
// Make sure all parts belong to the same team since
// this function doubles as "teamchange" function.
self.tur_head.team = self.team;
- self.colormod = '0 0 0';
-
- switch(self.team)
- {
- case COLOR_TEAM1: // Red
- self.colormod = '1.4 0.8 0.8';
- break;
-
- case COLOR_TEAM2: // Blue
- self.colormod = '0.8 0.8 1.4';
- break;
-
- case COLOR_TEAM3: // Yellow
- self.colormod = '1.4 1.4 0.6';
- break;
-
- case COLOR_TEAM4: // Pink
- self.colormod = '1.4 0.6 1.4';
- break;
- }
+ self.effects &~= EF_NODRAW;
self.deadflag = DEAD_NO;
self.effects = EF_LOWPRECISION;
- self.tur_head.effects = self.effects;
self.solid = SOLID_BBOX;
- self.alpha = 1;
- self.tur_head.alpha = self.alpha;
- self.customizeentityforclient = SUB_NullFloat;
- self.tur_head.customizeentityforclient = SUB_NullFloat;
-
self.takedamage = DAMAGE_AIM;
self.event_damage = turret_stdproc_damage;
self.nextthink = time + self.ticrate;
- if(self.SendEntity)
- {
- self.SendFlags = TNSF_FULL_UPDATE;
- self.think = turret_link; // CSQC?
- }
-
- else
- self.think = turret_think; // Or not?
+ self.SendFlags = TNSF_FULL_UPDATE;
+ self.think = turret_link; // CSQC?
if (self.turret_respawnhook)
self.turret_respawnhook();
self.tur_head.angles_x = self.tur_head.angles_x + (-0.5 + random()) * damage;
self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
- if(self.SendEntity)
- self.SendFlags |= TNSF_ANG;
+ self.SendFlags |= TNSF_ANG;
}
}
// CSQC
- if(self.SendEntity)
- self.SendFlags |= TNSF_STATUS;
+ self.SendFlags |= TNSF_STATUS;
}
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)
{
}
// 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;
+ 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;
+
+ 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;
+ 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;
+ self.SendFlags |= TNSF_ANG;
}
}
- if(self.SendEntity)
+ self.SendFlags |= TNSF_AVEL;
+
+ // Force a angle update every 10'th frame
+ self.turret_framecounter += 1;
+ if(self.turret_framecounter >= 10)
{
- self.SendFlags |= TNSF_AVEL;
-
- // Push a angle update every 10'th frame
- self.turret_framecounter += 1;
- if(self.turret_framecounter >= 10)
- {
- self.SendFlags |= TNSF_ANG;
- self.turret_framecounter = 0;
- }
+ self.SendFlags |= TNSF_ANG;
+ self.turret_framecounter = 0;
}
}
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
if (self.turrcaps_flags & TFL_TURRCAPS_SUPPORT)
{
float TFL_TARGETSELECT_OWNTEAM = 512;
*/
-float turret_stdproc_targetscore_support(entity e_turret,entity e_target)
+float turret_stdproc_targetscore_support(entity _turret,entity _target)
{
float score; // Total score
float s_score,d_score;
- if (e_turret.enemy == e_target) s_score = 1;
+ if (_turret.enemy == _target) s_score = 1;
- d_score = min(e_turret.target_range_optimal,tvt_dist) / max(e_turret.target_range_optimal,tvt_dist);
+ d_score = min(_turret.target_range_optimal,tvt_dist) / max(_turret.target_range_optimal,tvt_dist);
- score = (d_score * e_turret.target_select_rangebias) +
- (s_score * e_turret.target_select_samebias);
+ score = (d_score * _turret.target_select_rangebias) +
+ (s_score * _turret.target_select_samebias);
return score;
}
/*
* Generic bias aware score system.
*/
-float turret_stdproc_targetscore_generic(entity e_turret, entity e_target)
+float turret_stdproc_targetscore_generic(entity _turret, entity _target)
{
//vector v_tmp;
float d_dist; // Defendmode Distance
float a_score; // Angular score
float m_score; // missile score
float p_score; // player score
- //float da_score; // Distance from aimpoint score
-
float ikr; // ideal kill range
- /*
- if(!e_target)
- return 0;
- */
-
- if (e_turret.tur_defend)
+ if (_turret.tur_defend)
{
- d_dist = vlen(real_origin(e_target) - e_turret.tur_defend.origin);
- ikr = vlen(e_turret.origin - e_turret.tur_defend.origin);
- d_score = 1 - d_dist / e_turret.target_range;
+ d_dist = vlen(real_origin(_target) - _turret.tur_defend.origin);
+ ikr = vlen(_turret.origin - _turret.tur_defend.origin);
+ d_score = 1 - d_dist / _turret.target_range;
}
else
{
// Make a normlized value base on the targets distance from our optimal killzone
- ikr = e_turret.target_range_optimal;
+ ikr = _turret.target_range_optimal;
d_score = min(ikr,tvt_dist) / max(ikr,tvt_dist);
}
/*
// Determine the maximum time it could take this turrent to aim at someting.
- max_aim_delay = (max(e_turret.aim_maxrot,e_turret.aim_maxpitch) / e_turret.aim_speed * 2);
+ max_aim_delay = (max(_turret.aim_maxrot,_turret.aim_maxpitch) / _turret.aim_speed * 2);
// Find out how long it would take to aim at this taget.
- aim_delay = (thadf+0.01) / e_turret.aim_speed;
+ aim_delay = (thadf+0.01) / _turret.aim_speed;
// Turn this info into a normalized value.
aim_delay = (min(max_aim_delay,aim_delay) / max_aim_delay);
a_score = 1 - aim_delay;
*/
- //a_score = 1 - (tvt_thadf / max(e_turret.aim_maxrot,e_turret.aim_maxpitch));
- a_score = 1 - tvt_thadf / e_turret.aim_maxrot;
+ //a_score = 1 - (tvt_thadf / max(_turret.aim_maxrot,_turret.aim_maxpitch));
+ a_score = 1 - tvt_thadf / _turret.aim_maxrot;
- if ((e_turret.target_select_missilebias > 0) && (e_target.flags & FL_PROJECTILE))
+ if ((_turret.target_select_missilebias > 0) && (_target.flags & FL_PROJECTILE))
m_score = 1;
- if ((e_turret.target_select_playerbias > 0) && (e_target.flags & FL_CLIENT))
+ if ((_turret.target_select_playerbias > 0) && (_target.flags & FL_CLIENT))
p_score = 1;
d_score = max(d_score, 0);
m_score = max(m_score, 0);
p_score = max(p_score, 0);
- score = (d_score * e_turret.target_select_rangebias) +
- (a_score * e_turret.target_select_anglebias) +
- (m_score * e_turret.target_select_missilebias) +
- (p_score * e_turret.target_select_playerbias);
+ score = (d_score * _turret.target_select_rangebias) +
+ (a_score * _turret.target_select_anglebias) +
+ (m_score * _turret.target_select_missilebias) +
+ (p_score * _turret.target_select_playerbias);
- if(e_turret.target_range < vlen(e_turret.tur_shotorg - real_origin(e_target)))
+ if(_turret.target_range < vlen(_turret.tur_shotorg - real_origin(_target)))
{
dprint("Wtf?\n");
score *= 0.001;
string sdt,sat,smt,spt;
sd = ftos(d_score);
- d_score *= e_turret.target_select_rangebias;
+ d_score *= _turret.target_select_rangebias;
sdt = ftos(d_score);
//sv = ftos(v_score);
- //v_score *= e_turret.target_select_samebias;
+ //v_score *= _turret.target_select_samebias;
//svt = ftos(v_score);
sa = ftos(a_score);
- a_score *= e_turret.target_select_anglebias;
+ a_score *= _turret.target_select_anglebias;
sat = ftos(a_score);
sm = ftos(m_score);
- m_score *= e_turret.target_select_missilebias;
+ m_score *= _turret.target_select_missilebias;
smt = ftos(m_score);
sp = ftos(p_score);
- p_score *= e_turret.target_select_playerbias;
+ p_score *= _turret.target_select_playerbias;
spt = ftos(p_score);
ss = ftos(score);
- bprint("^3Target scores^7 \[ ",e_turret.netname, " \] ^3for^7 \[ ", e_target.netname," \]\n");
+ bprint("^3Target scores^7 \[ ",_turret.netname, " \] ^3for^7 \[ ", _target.netname," \]\n");
bprint("^5Range:\[ ",sd, " \]^2+bias:\[ ",sdt," \]\n");
bprint("^5Angle:\[ ",sa, " \]^2+bias:\[ ",sat," \]\n");
bprint("^5Missile:\[ ",sm," \]^2+bias:\[ ",smt," \]\n");
}
/*
-float turret_stdproc_targetscore_close(entity e_turret,entity e_target)
+float turret_stdproc_targetscore_close(entity _turret,entity _target)
{
- return 1 - (tvt_dist / e_turret.target_range);
+ return 1 - (tvt_dist / _turret.target_range);
}
-float turret_stdproc_targetscore_far (entity e_turret,entity e_target)
+float turret_stdproc_targetscore_far (entity _turret,entity _target)
{
- return tvt_dist / e_turret.target_range;
+ return tvt_dist / _turret.target_range;
}
-float turret_stdproc_targetscore_optimal(entity e_turret,entity e_target)
+float turret_stdproc_targetscore_optimal(entity _turret,entity _target)
{
- return min(e_turret.target_range_optimal,tvt_dist) / max(e_turret.target_range_optimal,tvt_dist);
+ return min(_turret.target_range_optimal,tvt_dist) / max(_turret.target_range_optimal,tvt_dist);
}
-float turret_stdproc_score_angular(entity e_turret,entity e_target)
+float turret_stdproc_score_angular(entity _turret,entity _target)
{
- return 1 - (tvt_thadf / e_turret.aim_maxrot);
+ return 1 - (tvt_thadf / _turret.aim_maxrot);
}
-float turret_stdproc_targetscore_defend(entity e_turret,entity e_target)
+float turret_stdproc_targetscore_defend(entity _turret,entity _target)
{
return 0;
- //min(e_target.origin,e_turret.tur_defend.origin) / max(e_target.origin,e_turret.tur_defend.origin);
+ //min(_target.origin,_turret.tur_defend.origin) / max(_target.origin,_turret.tur_defend.origin);
}
*/