+void Vore_AI_Teamheal(entity prey)
+{
+ // allows bots to take advantage of the teamheal feature, and use it to heal damaged team mates
+ // the prey entity is only used when it's available (a player is detected in-range), otherwise the rest of the code executes as expected
+
+ // if a teamheal is ongoing, decide whether or not to abandon it when seeing a foe that we can attack instead
+ // this only causes the bot to regurgitate their team mate when seeing an enemy, with the hope that this enemy will still be there once we can swallow again
+ // the higher the skill, the greater the chance a bot will abandon a team heal for an enemy
+ if(self.status_teamhealing > 1)
+ if(Swallow_condition_check_bot(prey))
+ if(prey.team != self.team)
+ if(random() * 10 < cvar("bot_ai_vore_teamhealabandon") * skill / self.bot_voreteamheal) // there are 10 bot skill steps
+ self.BUTTON_REGURGITATE = TRUE; // release the team mate
+
+ entity head;
+
+ if not(teams_matter && cvar("g_balance_vore_teamheal"))
+ return;
+ if(self.deadflag != DEAD_NO || self.predator.classname == "player" || self.flagcarried || self.digesting) // a flag carrier can't waste time on team healing
+ {
+ self.status_teamhealing = 0;
+ return;
+ }
+
+ // decide if we can teamheal or not
+ if(self.stomach_load)
+ {
+ self.status_teamhealing = 2; // consider a team mate is in our stomach and therefore we are teamhealing, until proven otherwise below
+
+ FOR_EACH_PLAYER(head)
+ {
+ if(head.predator == self)
+ if(head.team != self.team)
+ {
+ self.status_teamhealing = 0; // there's a foe in our stomach, we can't teamheal now
+ return;
+ }
+ }
+ }
+ else
+ self.status_teamhealing = 1; // if our stomach is empty, it means we can decide to teamheal
+
+ // now that we're decided if we can teamheal or not, lets go ahead and do so:
+
+ // if we are holding a team mate that's been healed to the maximum amount, we can release them
+ // not sure if this should be merged with the FOR_EACH_PLAYER check above. That would save an extra loop, but would be less correct
+ FOR_EACH_PLAYER(head)
+ {
+ if(head.predator == self) // head is automatically a team mate, or we wouldn't be reaching this part of the code
+ if(head.health >= cvar("g_balance_vore_teamheal_stable"))
+ self.BUTTON_REGURGITATE = TRUE; // release the team mate
+ }
+
+ // 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(prey.health < cvar("g_balance_vore_teamheal_stable"))
+ if not(prey.digesting) // if our team mate is digesting someone, he likely wouldn't want us ruining his frag
+ if not(prey.flagcarried) // don't eat the flag carrier and ruin his job
+ if(Swallow_condition_check_bot(prey))
+ self.BUTTON_ATCK = TRUE; // swallow
+}
+