From: MirceaKitsune Date: Tue, 7 Sep 2010 15:37:25 +0000 (+0300) Subject: One more step in the teamhealing AI X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=65e0b6c95a40cfa63e8c34e90795c0703cb8317c;p=voretournament%2Fvoretournament.git One more step in the teamhealing AI --- diff --git a/data/qcsrc/server/bot/havocbot/vore_ai.qc b/data/qcsrc/server/bot/havocbot/vore_ai.qc index aa0efddf..f7bceae0 100644 --- a/data/qcsrc/server/bot/havocbot/vore_ai.qc +++ b/data/qcsrc/server/bot/havocbot/vore_ai.qc @@ -1,3 +1,5 @@ +.float status_teamhealing; // 0 = can't team heal, 1 = can team heal, 2 = team healing currently + entity Swallow_distance_check_bot(entity e) { // check if we can swallow a player instead of firing our weapon @@ -25,27 +27,48 @@ float Swallow_condition_check_bot(entity prey) void Vore_AI_Teamheal(entity prey) { + // allows bots to take advantage of the teamheal feature in team games, and use this feature to heal damaged team mates + if not(teamplay) return; - // check if we can heal a damaged team mate we came across, and if so swallow them - if(prey.classname == "player" && prey.team == self.team) - if(Swallow_condition_check_bot(prey)) - if(prey.health < cvar("g_balance_vore_teamheal_stable")) - self.BUTTON_ATCK = TRUE; // swallow + self.status_teamhealing = 1; // start from the premise we can teamheal until proven otherwise + if(self.deadflag != DEAD_NO || self.eater.classname == "player") + self.status_teamhealing = 0; // if we are holding a team mate that's been healed to the max, we can release them + // also use this check to not go any further if someone from the enemy team is in our stomach entity head; if(self.stomach_load) { FOR_EACH_PLAYER(head) { if(head.eater.classname == "player") - if(head.team == self.team) - if(head.health >= cvar("g_balance_vore_teamheal_stable")) - self.BUTTON_REGURGITATE = TRUE; + { + if(head.team == self.team) + { + if(head.health >= cvar("g_balance_vore_teamheal_stable")) + self.BUTTON_REGURGITATE = TRUE; // release the team mate + } + else + { + self.status_teamhealing = 0; // someone from the enemy team is in our belly, which means we can't be teamhealing any more + return; + } + } } } + + // check if we can heal a damaged team mate we came across, and if so swallow them + if(self.status_teamhealing) + if(prey.classname == "player" && prey.team == self.team) + if not(prey.flagcarried) // don't eat the flag carrier and ruin his job + if(Swallow_condition_check_bot(prey)) + if(prey.health < cvar("g_balance_vore_teamheal_stable")) + { + self.BUTTON_ATCK = TRUE; // swallow + self.status_teamhealing = 2; + } } .float swallow_retry, decide_delay1, decide_delay2; @@ -94,6 +117,8 @@ void Vore_AI() } Vore_AI_Teamheal(prey); + if(self.status_teamhealing > 1) // if we are teamhealing, there's nothing to do from here on + return; // deciding what to do with a victim: