]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/bot/havocbot/vore_ai.qc
Make bots jump while being swallowed, to make it even harder to eat them. They should...
[voretournament/voretournament.git] / data / qcsrc / server / bot / havocbot / vore_ai.qc
index 30a5d1960cc3bd7168215b5de4b77810cddb312c..b8e7d308f84d8ab3419f6c4d9f1e961f4ec86fba 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)
 {
@@ -22,7 +23,7 @@ void Vore_AI_Teamheal(entity prey)
 
        if not(teams_matter && cvar("g_balance_vore_teamheal") && cvar("g_vore_teamvore"))
                return;
-       if(self.deadflag != DEAD_NO || self.predator.classname == "player" || self.flagcarried || self.digesting) // a flag carrier can't waste time on team healing
+       if(self.deadflag != DEAD_NO || self.stat_eaten || self.flagcarried || self.digesting) // a flag carrier can't waste time on team healing
        {
                self.status_teamhealing = 0;
                return;
@@ -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()
@@ -87,14 +92,17 @@ void Vore_AI()
 
        if(!cvar("g_vore")) // the vore system is disabled
                return;
-       if(cvar("bot_nofire") || !skill || (g_rpg && cvar("g_rpg_botattack") < 1))
+       if(self.deadflag != DEAD_NO || cvar("bot_nofire") || !skill || (g_rpg && cvar("g_rpg_botattack") < 1))
                return;
 
+       float randomtry;
+       randomtry = random() * 10; // there are 10 bot skill steps
+
 // --------------------------------
 // Predator bot behavior:
 // --------------------------------
 
-       if(self.predator.classname != "player")
+       if(!self.stat_eaten)
        {
                // finding and swallowing a player
 
@@ -111,8 +119,7 @@ void Vore_AI()
 
                // now do the actual checking and swallowing
                entity prey;
-               float randomtry, fear;
-               float decide_pred_time, decide_prey_time;
+               float decide_pred_time, fear;
 
                prey = Swallow_player_check();
                fear = 1;
@@ -122,27 +129,33 @@ void Vore_AI()
                if(self.status_teamhealing > 1) // if we are teamhealing, there's nothing to do from here on
                        return;
 
-               randomtry = random() * 10; // there are 10 bot skill steps
                if(prey.items & IT_STRENGTH) // avoid eating bots that have the Strenght powerup
                        fear += cvar("bot_ai_vore_fear") * self.bot_vorefear;
                if(prey.items & IT_INVINCIBLE) // avoid eating bots that have the Invincible powerup
                        fear += cvar("bot_ai_vore_fear") * self.bot_vorefear;
                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;
-               decide_prey_time = cvar("bot_ai_vore_decide_prey") / skill / self.bot_vorethinkprey;
 
-               if(time > self.decide_swallow && cvar("g_vore_digestion"))
                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 their 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:
 
@@ -150,17 +163,18 @@ void Vore_AI()
                {
                        // if the predator's health is smaller than the maximum damage a stomach kick can do, regurgitate the player(s)
                        // otherwise the predator is putting himself at risk by keeping you inside
+                       // TODO: make bots also know the amount of damage boost a melee attack can do
                        if(self.health <= cvar("g_balance_vore_kick_damage_max"))
                                self.BUTTON_REGURGITATE = TRUE;
 
                        else if(!self.digesting && cvar("g_vore_digestion"))
                        {
-                               // the higher the skill, the faster bots will start to digest you
+                               // the higher the skill, the faster bots will start to digest
                                if not(g_rpg && cvar("g_rpg_botattack") < 2)
                                if(skill >= randomtry)
                                        self.BUTTON_DIGEST = TRUE; // digest
 
-                               self.decide_pred = time + decide_pred_time; // time before the bot decides what to do with their prey
+                               self.decide_pred = time + decide_pred_time; // time before the bot decides what to do with his prey
                        }
                }
        }
@@ -169,10 +183,19 @@ void Vore_AI()
 // Prey bot behavior:
 // --------------------------------
 
-       if(self.predator.classname == "player" && time > self.decide_prey)
+       // while being swallowed, smart bots know to keep jumping to make it harder to be caught
+       // TODO: Don't do this if the predator is a team mate
+       if(self.swallow_progress_prey)
+       if(self.swallow_progress_prey * 10 >= 10 - skill) // 10 skill steps
+               self.BUTTON_JUMP = TRUE;
+
+       if(self.stat_eaten && time > self.decide_prey)
        {
                // all we can do in the stomach is kick and do some damage / try to escape, or leave if the circumstances allow it and we should
 
+               float decide_prey_time;
+               decide_prey_time = cvar("bot_ai_vore_decide_prey") / skill / self.bot_vorethinkprey;
+
                if(cvar("g_vore_kick"))
                if not(g_rpg && cvar("g_rpg_botattack") < 2)
                if not(teams_matter && self.team == self.predator.team)