]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/bot/havocbot/vore_ai.qc
Team healing AI now working as intended, but not ready yet. Also fix another tiny...
[voretournament/voretournament.git] / data / qcsrc / server / bot / havocbot / vore_ai.qc
index aa0efddfcd045f6691c8d40d13d8b2685762efbe..174c428029c7947cb64907608c89f02b93ce2bba 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,49 @@ 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.flagcarried)
+       {
+               self.status_teamhealing = 0;
+               return;
+       }
 
        // 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)
+                               {
+                                       self.status_teamhealing = 2;
+                                       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
 }
 
 .float swallow_retry, decide_delay1, decide_delay2;
@@ -94,6 +118,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: