]> de.git.xonotic.org Git - voretournament/voretournament.git/commitdiff
Tweak bot AI and make bots able to play with the slow swallowing feature
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 9 Jul 2011 14:38:37 +0000 (17:38 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 9 Jul 2011 14:38:37 +0000 (17:38 +0300)
data/qcsrc/server/bot/havocbot/vore_ai.qc

index 306107551d3c301dd64ab4ac0f0478392c0cffae..8f413afff4cc4c3e1cc53d74833fc23fbf6b7042 100644 (file)
@@ -1,4 +1,5 @@
 .float status_teamhealing; // 0 = can't team heal, 1 = can team heal, 2 = team healing right now
+.float hold_BUTTON_ATCK; // marks the bot holding the fire button after having decided on his prey
 
 float Swallow_condition_check_bot(entity prey)
 {
@@ -73,12 +74,16 @@ void Vore_AI_Teamheal(entity prey)
        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 not(prey.BUTTON_ATCK || prey.BUTTON_ATCK2) // our team mate wouldn't want us eating him while he's firing
-       if(time > self.decide_swallow)
        {
-               if(skill >= random() * 10) // there are 10 bot skill steps
-                       self.BUTTON_ATCK = TRUE; // swallow the team mate
-               self.decide_swallow = time + cvar("bot_ai_vore_decide_swallow") / self.bot_vorethinkpred; // this is needed to take a proper decision, otherwise the code would execute each frame and return TRUE quickly
+               if(time > self.decide_swallow)
+               {
+                       if(skill >= random() * 10) // there are 10 bot skill steps
+                               self.hold_BUTTON_ATCK = TRUE; // swallow the team mate
+                       self.decide_swallow = time + cvar("bot_ai_vore_decide_swallow") / self.bot_vorethinkpred; // this is needed to take a proper decision, otherwise the code would execute each frame and return TRUE quickly
+               }
        }
+       else
+               self.hold_BUTTON_ATCK = FALSE;
 }
 
 void Vore_AI()
@@ -131,18 +136,26 @@ void Vore_AI()
                fear += self.stomach_load; // the bigger our stomach, the less we want to put someone else in there
                decide_pred_time = cvar("bot_ai_vore_decide_pred") / skill / self.bot_vorethinkpred;
 
-               if(time > self.decide_swallow)
                if(Swallow_condition_check_bot(prey))
                {
-                       // the greater the skill, the higher the chance bots will swallow someone each attempt
-                       if(skill / fear >= randomtry)
-                       if not(teams_matter && prey.team == self.team)
+                       if(time > self.decide_swallow)
                        {
-                               self.BUTTON_ATCK = TRUE; // swallow
-                               self.decide_pred = time + decide_pred_time; // time before the bot decides what to do with his prey
+                               // the greater the skill, the higher the chance bots will swallow someone each attempt
+                               if(skill / fear >= randomtry)
+                               if not(teams_matter && prey.team == self.team)
+                               {
+                                       self.hold_BUTTON_ATCK = TRUE; // swallow
+                                       self.decide_pred = time + decide_pred_time; // time before the bot decides what to do with his prey
+                               }
+                               self.decide_swallow = time + cvar("bot_ai_vore_decide_swallow") / self.bot_vorethinkpred; // this is needed to take a proper decision, otherwise the code would execute each frame and return TRUE quickly
                        }
-                       self.decide_swallow = time + cvar("bot_ai_vore_decide_swallow") / self.bot_vorethinkpred; // this is needed to take a proper decision, otherwise the code would execute each frame and return TRUE quickly
                }
+               else
+                       self.hold_BUTTON_ATCK = FALSE;
+
+               // if the bot is holding the firing button, apply that to the actual fire key
+               if(self.hold_BUTTON_ATCK)
+                       self.BUTTON_ATCK = TRUE;
 
                // deciding what to do with a victim: