From 1a0c8573481fa13e790e7af6f5f9cc6f5ba86e0a Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Tue, 7 Sep 2010 18:09:42 +0300 Subject: [PATCH] First step in teaching bots to use the teamheal feature in team games. Not ready yet. --- data/qcsrc/server/bot/havocbot/vore_ai.qc | 31 +++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/data/qcsrc/server/bot/havocbot/vore_ai.qc b/data/qcsrc/server/bot/havocbot/vore_ai.qc index 6676c881..aa0efddf 100644 --- a/data/qcsrc/server/bot/havocbot/vore_ai.qc +++ b/data/qcsrc/server/bot/havocbot/vore_ai.qc @@ -19,11 +19,35 @@ float Swallow_condition_check_bot(entity prey) if(self.eater.classname != "player" && self.stomach_load < cvar("g_balance_vore_swallow_limit") && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves if not(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load) if(self.health > cvar("g_balance_vore_kick_damage_max")) // explained below - if not(teamplay && prey.team == self.team) return TRUE; return FALSE; } +void Vore_AI_Teamheal(entity prey) +{ + 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 + + // if we are holding a team mate that's been healed to the max, we can release them + 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; + } + } +} + .float swallow_retry, decide_delay1, decide_delay2; void Vore_AI() { @@ -56,11 +80,12 @@ void Vore_AI() decide_prey = cvar("bot_ai_vore_decide_prey") / (skill * 2 + 1); decide_pred = cvar("bot_ai_vore_decide_pred") / (skill * 2 + 1); - if(Swallow_condition_check_bot(prey)) if(time > self.swallow_retry) + if(Swallow_condition_check_bot(prey)) { // the greater the skill, the higher the chance bots will swallow someone each attempt if(skill >= random_try) + if not(teamplay && prey.team == self.team) { self.BUTTON_ATCK = TRUE; // swallow self.decide_delay1 = time + decide_pred; // time before the bot decides what to do with their prey @@ -68,6 +93,8 @@ void Vore_AI() self.swallow_retry = time + 0.5; // bots retry swallowing every 0.5 seconds, otherwise each frame would be random chance } + Vore_AI_Teamheal(prey); + // deciding what to do with a victim: if(self.stomach_load > 0 && time > self.decide_delay1) -- 2.39.2