From: Rudolf Polzer Date: Mon, 20 Jun 2011 08:28:50 +0000 (+0200) Subject: Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic-data.pk3dir X-Git-Tag: xonotic-v0.5.0~199^2~13^2~3 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=8fd199794a4136325f14dfff5b1d0d44da32f3cb;hp=94cf38e5a76dfe79cecd83f75d974de2361788b3;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic-data.pk3dir Conflicts: qcsrc/server/bot/havocbot/havocbot.qc qcsrc/server/bot/havocbot/roles.qc --- diff --git a/qcsrc/server/bot/aim.qc b/qcsrc/server/bot/aim.qc index 9300ac721..63e971b17 100644 --- a/qcsrc/server/bot/aim.qc +++ b/qcsrc/server/bot/aim.qc @@ -1,4 +1,5 @@ +entity ka_ball; // traces multiple trajectories to find one that will impact the target // 'end' vector is the place it aims for, // returns TRUE only if it hit targ (don't target non-solid entities) @@ -113,6 +114,12 @@ float bot_shouldattack(entity e) if(e.freezetag_frozen) return FALSE; + // If neither player has ball then don't attack unless the ball is on the + // ground. + if (g_keepaway) + if (!e.ballcarried && !self.ballcarried && ka_ball.owner) + return FALSE; + if(teamplay) { if(e.team==0) diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 265731f69..7c2f98634 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -3,6 +3,7 @@ #include "role_onslaught.qc" #include "role_keyhunt.qc" #include "role_freezetag.qc" +#include "role_keepaway.qc" #include "roles.qc" void havocbot_ai() diff --git a/qcsrc/server/bot/havocbot/role_keepaway.qc b/qcsrc/server/bot/havocbot/role_keepaway.qc new file mode 100644 index 000000000..30d96499a --- /dev/null +++ b/qcsrc/server/bot/havocbot/role_keepaway.qc @@ -0,0 +1,82 @@ +void() havocbot_role_ka_carrier; +void() havocbot_role_ka_collector; +void() havocbot_chooserole_ka; + +entity ka_ball; + +// Keepaway +// If you don't have the ball, get it; if you do, kill people. + +void havocbot_goalrating_ball(float ratingscale, vector org) +{ + local float t, distance; + local entity ball_owner; + ball_owner = ka_ball.owner; + + if (ball_owner == self) + return; + + // If ball is carried by player then hunt them down. + if (ball_owner) + { + t = (self.health + self.armorvalue) / (ball_owner.health + ball_owner.armorvalue); + navigation_routerating(ball_owner, t * ratingscale, 2000); + } + + // Ball has been dropped so collect. + navigation_routerating(ka_ball, ratingscale, 2000); +}; + +void havocbot_role_ka_carrier() +{ + if (self.deadflag != DEAD_NO) + return; + + if (time > self.bot_strategytime) + { + self.bot_strategytime = time + autocvar_bot_ai_strategyinterval; + + navigation_goalrating_start(); + havocbot_goalrating_items(10000, self.origin, 10000); + havocbot_goalrating_enemyplayers(20000, self.origin, 10000); + //havocbot_goalrating_waypoints(1, self.origin, 1000); + navigation_goalrating_end(); + } + + if (!self.ballcarried) + { + self.havocbot_role = havocbot_role_ka_collector; + self.bot_strategytime = 0; + } +}; + +void havocbot_role_ka_collector() +{ + if (self.deadflag != DEAD_NO) + return; + + if (time > self.bot_strategytime) + { + self.bot_strategytime = time + autocvar_bot_ai_strategyinterval; + + navigation_goalrating_start(); + havocbot_goalrating_items(10000, self.origin, 10000); + havocbot_goalrating_enemyplayers(1000, self.origin, 10000); + havocbot_goalrating_ball(20000, self.origin); + navigation_goalrating_end(); + } + + if (self.ballcarried) + { + self.havocbot_role = havocbot_role_ka_carrier; + self.bot_strategytime = 0; + } +}; + +void havocbot_chooserole_ka() +{ + if (self.ballcarried) + self.havocbot_role = havocbot_role_ka_carrier; + else + self.havocbot_role = havocbot_role_ka_collector; +}; diff --git a/qcsrc/server/bot/havocbot/roles.qc b/qcsrc/server/bot/havocbot/roles.qc index 96c901f9e..ac52c698f 100644 --- a/qcsrc/server/bot/havocbot/roles.qc +++ b/qcsrc/server/bot/havocbot/roles.qc @@ -277,24 +277,6 @@ void havocbot_role_race() } }; -// Keepaway -// If you don't have the ball, get it; if you do, kill people. -void havocbot_role_ka() -{ - if(self.deadflag != DEAD_NO) - return; - - if (self.bot_strategytime < time) - { - self.bot_strategytime = time + autocvar_bot_ai_strategyinterval; - navigation_goalrating_start(); - havocbot_goalrating_items(10000, self.origin, 10000); - havocbot_goalrating_enemyplayers(20000, self.origin, 10000); - //havocbot_goalrating_waypoints(1, self.origin, 1000); - navigation_goalrating_end(); - } -} - void havocbot_chooserole_dm() { self.havocbot_role = havocbot_role_dm; @@ -310,11 +292,6 @@ void havocbot_chooserole_dom() self.havocbot_role = havocbot_role_dom; }; -void havocbot_chooserole_ka() -{ - self.havocbot_role = havocbot_role_ka; -}; - void havocbot_chooserole() { dprint("choosing a role...\n"); diff --git a/qcsrc/server/mutators/gamemode_keepaway.qc b/qcsrc/server/mutators/gamemode_keepaway.qc index 85a29031a..1d091b115 100644 --- a/qcsrc/server/mutators/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/gamemode_keepaway.qc @@ -4,6 +4,8 @@ void ka_RespawnBall(void); void ka_DropEvent(entity); void ka_TimeScoring(void); +entity ka_ball; + float ka_ballcarrier_waypointsprite_visible_for_player(entity); void ka_Initialize() // run at the start of a match, initiates game mode @@ -50,6 +52,7 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star e.reset = ka_Reset; e.touch = ka_TouchEvent; e.owner = world; + ka_ball = e; InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So. }