From f89e8bc78817e5f9e7118080e601f730cd587041 Mon Sep 17 00:00:00 2001 From: mand1nga Date: Sun, 31 May 2009 17:25:40 +0000 Subject: [PATCH] Added teamcount() function, will be used to improve the ctf ai git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6830 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/bots.qc | 20 ++++++++++++++++---- data/qcsrc/server/havocbot_roles.qc | 26 +++++++++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/data/qcsrc/server/bots.qc b/data/qcsrc/server/bots.qc index 2019a394b..ef11efefd 100644 --- a/data/qcsrc/server/bots.qc +++ b/data/qcsrc/server/bots.qc @@ -218,10 +218,22 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float } else { - #ifdef DEBUG_TRACEWALK - debugnodestatus(trace_endpos, DEBUG_NODE_FAIL); - #endif - return FALSE; // failed + // Check if we can jump over the obstacle + local vector jumpheight; + // this is an estimate, a proper calculation should involve the cvars sv_jumpvelocity and sv_gravity + jumpheight = (PL_VIEW_OFS_z + PL_MIN_z) * '0 0 1'; + tracebox(org + jumpheight, m1, m2, move + jumpheight, movemode, e); + + if (trace_fraction < 1) + { + #ifdef DEBUG_TRACEWALK + debugnodestatus(trace_endpos, DEBUG_NODE_FAIL); + #endif + return FALSE; // failed + } + // Here we will avoid the trace down because we jumped + org = trace_endpos; + continue; } } else diff --git a/data/qcsrc/server/havocbot_roles.qc b/data/qcsrc/server/havocbot_roles.qc index fff9a51e0..1a8b02d18 100644 --- a/data/qcsrc/server/havocbot_roles.qc +++ b/data/qcsrc/server/havocbot_roles.qc @@ -4,11 +4,6 @@ .void() havocbot_role; float bot_ignore_bots; -float canreach(entity e) -{ - return vlen(self.origin - e.origin) < 1500; -} - .float max_armorvalue; float havocbot_pickupevalfunc(entity item) { @@ -307,6 +302,27 @@ void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradi } }; +// Functions for CTF + +float canreach(entity e) +{ + return vlen(self.origin - e.origin) < 1500; +} + +float teamcount() +{ + if not(teams_matter) + return 0; + + float c; + entity head; + + FOR_EACH_PLAYER(head) + if(head.team==self.team) + ++c; + + return c; +} void() havocbot_role_ctf_middle; void() havocbot_role_ctf_defense; -- 2.39.2