]> de.git.xonotic.org Git - voretournament/voretournament.git/commitdiff
One more step in the teamhealing AI
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Tue, 7 Sep 2010 15:37:25 +0000 (18:37 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Tue, 7 Sep 2010 15:37:25 +0000 (18:37 +0300)
data/qcsrc/server/bot/havocbot/vore_ai.qc

index aa0efddfcd045f6691c8d40d13d8b2685762efbe..f7bceae0356d66f03a2de01154792d499864e5f9 100644 (file)
@@ -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: