From 2ebc3fdd3b08052acbcf69ac7c55591e2676de1e Mon Sep 17 00:00:00 2001 From: mand1nga Date: Fri, 5 Jun 2009 23:24:22 +0000 Subject: [PATCH] CTF ai: Improved defense role. Switch to offense if there is only one bot on the team. Other minor changes git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6875 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/havocbot_ctf.qc | 73 ++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/data/qcsrc/server/havocbot_ctf.qc b/data/qcsrc/server/havocbot_ctf.qc index 5037535ca..e9e43ada6 100644 --- a/data/qcsrc/server/havocbot_ctf.qc +++ b/data/qcsrc/server/havocbot_ctf.qc @@ -465,7 +465,7 @@ void havocbot_role_ctf_retriever() } if (!self.havocbot_role_timeout) - self.havocbot_role_timeout = time + random() * 30 + 60; + self.havocbot_role_timeout = time + 20; if (time > self.havocbot_role_timeout) { @@ -483,7 +483,7 @@ void havocbot_role_ctf_retriever() havocbot_goalrating_ctf_ourstolenflag(50000); havocbot_goalrating_ctf_droppedflags(40000, self.origin, radius); havocbot_goalrating_ctf_enemybase(30000); - havocbot_goalrating_items(5000, self.origin, radius); + havocbot_goalrating_items(500, self.origin, radius); navigation_goalrating_end(); } }; @@ -521,13 +521,18 @@ void havocbot_role_ctf_middle() } if (self.bot_strategytime < time) - { + { + local vector org; + + org = havocbot_ctf_middlepoint; + org_z = self.origin_z; + self.bot_strategytime = time + cvar("bot_ai_strategyinterval"); navigation_goalrating_start(); havocbot_goalrating_ctf_ourstolenflag(50000); havocbot_goalrating_ctf_droppedflags(30000, self.origin, 10000); - havocbot_goalrating_enemyplayers(10000, havocbot_ctf_middlepoint, havocbot_ctf_middlepoint_radius * 0.5); - havocbot_goalrating_items(5000, havocbot_ctf_middlepoint, havocbot_ctf_middlepoint_radius * 0.5); + havocbot_goalrating_enemyplayers(10000, org, havocbot_ctf_middlepoint_radius * 0.5); + havocbot_goalrating_items(5000, org, havocbot_ctf_middlepoint_radius * 0.5); havocbot_goalrating_items(2500, self.origin, 10000); havocbot_goalrating_ctf_enemybase(2500); navigation_goalrating_end(); @@ -554,9 +559,7 @@ void havocbot_role_ctf_defense() mf = havocbot_ctf_find_flag(self); if(mf.cnt!=FLAG_BASE) { - // And its located as far as about half the distance between the two bases - if(vlen(self.origin-mf.origin)1000) + if(checkpvs(self.origin,closestplayer)||random()<0.5) + havocbot_goalrating_ctf_ourbase(30000); + + havocbot_goalrating_ctf_ourstolenflag(20000); + havocbot_goalrating_ctf_droppedflags(20000, org, radius); + havocbot_goalrating_enemyplayers(15000, org, radius); + havocbot_goalrating_items(10000, org, radius); + havocbot_goalrating_items(5000, self.origin, 10000); navigation_goalrating_end(); } }; @@ -608,7 +636,8 @@ void havocbot_calculate_middlepoint() void havocbot_ctf_reset_role(entity bot) { local float cdefense, cmiddle, coffense; - local entity mf, ef; + local entity mf, ef, head; + local float c; if(self.deadflag != DEAD_NO) return; @@ -633,12 +662,24 @@ void havocbot_ctf_reset_role(entity bot) return; } - // Go to the middle to intercept pursuers + // If enemy flag is taken go to the middle to intercept pursuers if(ef.cnt!=FLAG_BASE) { havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_MIDDLE); return; - } + } + + // if there is only me on the team switch to offense + c = 0; + FOR_EACH_PLAYER(head) + if(head.team==self.team) + ++c; + + if(c==1) + { + havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_OFFENSE); + return; + } // Evaluate best position to take // Count mates on middle position -- 2.39.2