if not(teamplay)
return 0;
- float c;
+ float c = 0;
entity head;
FOR_EACH_PLAYER(head)
mf = havocbot_ctf_find_flag(self);
- if(mf.cnt == FLAG_BASE)
+ if(mf.ctf_status == FLAG_BASE)
return;
if(mf.tag_entity)
while (head)
{
// flag is out in the field
- if(head.cnt != FLAG_BASE)
+ if(head.ctf_status != FLAG_BASE)
if(head.tag_entity==world) // dropped
{
if(radius)
// If enemy flag is back on the base switch to previous role
ef = havocbot_ctf_find_enemy_flag(self);
- if(ef.cnt==FLAG_BASE)
+ if(ef.ctf_status==FLAG_BASE)
{
self.havocbot_role = self.havocbot_previous_role;
self.havocbot_role_timeout = 0;
// If the flag carrier reached the base switch to defense
mf = havocbot_ctf_find_flag(self);
- if(mf.cnt!=FLAG_BASE)
+ if(mf.ctf_status!=FLAG_BASE)
if(vlen(ef.origin - mf.dropped_origin) < 300)
{
havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_DEFENSE);
ef = havocbot_ctf_find_enemy_flag(self);
// Own flag stolen
- if(mf.cnt!=FLAG_BASE)
+ if(mf.ctf_status!=FLAG_BASE)
{
if(mf.tag_entity)
pos = mf.tag_entity.origin;
}
// Escort flag carrier
- if(ef.cnt!=FLAG_BASE)
+ if(ef.ctf_status!=FLAG_BASE)
{
if(ef.tag_entity)
pos = ef.tag_entity.origin;
// If flag is back on the base switch to previous role
mf = havocbot_ctf_find_flag(self);
- if(mf.cnt==FLAG_BASE)
+ if(mf.ctf_status==FLAG_BASE)
{
havocbot_ctf_reset_role(self);
return;
}
mf = havocbot_ctf_find_flag(self);
- if(mf.cnt!=FLAG_BASE)
+ if(mf.ctf_status!=FLAG_BASE)
{
havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
return;
// If own flag was captured
mf = havocbot_ctf_find_flag(self);
- if(mf.cnt!=FLAG_BASE)
+ if(mf.ctf_status!=FLAG_BASE)
{
havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
return;
navigation_goalrating_start();
// if enemies are closer to our base, go there
- entity head, closestplayer;
- float distance, bestdistance;
- distance = 10000;
+ entity head, closestplayer = world;
+ float distance, bestdistance = 10000;
FOR_EACH_PLAYER(head)
{
if(head.deadflag!=DEAD_NO)
void havocbot_calculate_middlepoint()
{
entity f;
- vector p1, p2;
+ vector s = '0 0 0';
+ vector fo = '0 0 0';
+ float n = 0;
f = ctf_worldflaglist;
while (f)
{
- if(p1)
- p2 = f.origin;
- else
- p1 = f.origin;
-
+ fo = f.origin;
+ s = s + fo;
f = f.ctf_worldflagnext;
}
- havocbot_ctf_middlepoint = p1 + ((p2-p1) * 0.5);
- havocbot_ctf_middlepoint_radius = vlen(p2-p1) * 0.5;
+ if(!n)
+ return;
+ havocbot_ctf_middlepoint = s * (1.0 / n);
+ havocbot_ctf_middlepoint_radius = vlen(fo - havocbot_ctf_middlepoint);
}
void havocbot_ctf_reset_role(entity bot)
ef = havocbot_ctf_find_enemy_flag(bot);
// Retrieve stolen flag
- if(mf.cnt!=FLAG_BASE)
+ if(mf.ctf_status!=FLAG_BASE)
{
havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_RETRIEVER);
return;
}
// If enemy flag is taken go to the middle to intercept pursuers
- if(ef.cnt!=FLAG_BASE)
+ if(ef.ctf_status!=FLAG_BASE)
{
havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_MIDDLE);
return;