]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/bot/havocbot/vore_ai.qc
Make bots much smarter :)
[voretournament/voretournament.git] / data / qcsrc / server / bot / havocbot / vore_ai.qc
index b8e7d308f84d8ab3419f6c4d9f1e961f4ec86fba..b46f5a2f55d8884bb251358205787d9a986484c6 100644 (file)
@@ -5,10 +5,18 @@ float Swallow_condition_check_bot(entity prey)
 {
        // checks the necessary conditions for a bot to swallow a player
 
+       float kick_dmg;
+       if(cvar("g_vore_kick") && skill >= 7)
+       {
+               kick_dmg = cvar("g_balance_vore_kick_damage");
+               if(cvar("g_healthsize"))
+                       kick_dmg *= pow(prey.scale / self.scale, cvar("g_balance_vore_kick_scalediff")); // based on the damage the prey can do to us at his size
+       }
+
        if(Swallow_condition_check(prey)) // check the normal conditions of the vore system
        if(time >= prey.spawnshieldtime) // spawn shield means you are invincible
        if not(prey.BUTTON_CHAT) // don't eat players who are chatting
-       if(self.health > cvar("g_balance_vore_kick_damage_max")) // explained below
+       if(self.health > kick_dmg)
                return TRUE;
        return FALSE;
 }
@@ -77,7 +85,8 @@ void Vore_AI_Teamheal(entity prey)
        {
                if(time > self.decide_swallow)
                {
-                       if(skill >= random() * 10) // there are 10 bot skill steps
+                       // base the decision around HOW damaged the team mate is, centered around 100 health
+                       if(skill * (100 / prey.health) >= 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
                }
@@ -129,11 +138,27 @@ void Vore_AI()
                if(self.status_teamhealing > 1) // if we are teamhealing, there's nothing to do from here on
                        return;
 
-               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
+               if(!cvar("g_vore_reversescoring")) // when reverse scoring is on, it's in the interest of the prey to get eaten, so the predator has nothing to fear
+               {
+                       if(skill >= 3) // make bots aware of this from skill 3 and up
+                               fear *= 1 + self.stomach_load; // the bigger our stomach, the less we want to put someone else in there
+                       if(skill >= 5) // make bots aware of this from skill 5 and up
+                               fear *= 1 + prey.stomach_load; // predators fear prey that have a large stomach
+
+                       if(cvar("g_healthsize"))
+                               fear *= (prey.scale / self.scale); // predators fear larger prey and are courageous toward smaller prey
+                       if(prey.items & IT_STRENGTH) // avoid eating bots that have the Strenght powerup
+                               fear *= 2;
+                       if(prey.items & IT_INVINCIBLE) // avoid eating bots that have the Invincible powerup
+                               fear *= 2;
+
+                       // when a bot is being swallowed, he will try to swallow the enemy back in defense, forgetting about fear
+                       if(self.swallow_progress_prey)
+                               fear /= self.swallow_progress_prey * skill;
+
+                       fear *= cvar("bot_ai_vore_fear") * self.bot_vorefear;
+               }
+
                decide_pred_time = cvar("bot_ai_vore_decide_pred") / skill / self.bot_vorethinkpred;
 
                if(Swallow_condition_check_bot(prey))
@@ -161,10 +186,24 @@ void Vore_AI()
 
                if(self.stomach_load && time > self.decide_pred)
                {
-                       // if the predator's health is smaller than the maximum damage a stomach kick can do, regurgitate the player(s)
+                       // if the predator's health is smaller than the 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"))
+                       float kick_dmg;
+                       if(cvar("g_vore_kick") && skill >= 7) // such awareness comes from skill level 7 and up
+                       {
+                               kick_dmg = cvar("g_balance_vore_kick_damage");
+                               if(cvar("g_healthsize"))
+                               {
+                                       entity e;
+                                       FOR_EACH_PLAYER(e) // count the size of all players in the stomach for accounting the danger level
+                                       {
+                                               if(e.predator == self)
+                                               if not(teamplay && e.team == self.team) // don't count team mates
+                                                       kick_dmg *= pow(e.scale / self.scale, cvar("g_balance_vore_kick_scalediff")); // based on the damage the prey can do to us at his size
+                                       }
+                               }
+                       }
+                       if(self.health <= kick_dmg)
                                self.BUTTON_REGURGITATE = TRUE;
 
                        else if(!self.digesting && cvar("g_vore_digestion"))
@@ -183,6 +222,9 @@ void Vore_AI()
 // Prey bot behavior:
 // --------------------------------
 
+       if(cvar("g_vore_reversescoring")) // if reverse scoring is on, it's in the interest of the prey to get eaten, so don't fight back
+               return;
+
        // 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)
@@ -211,7 +253,7 @@ void Vore_AI()
                {
                        if(self.predator.digesting) // our predator is digesting, so get out of him regardless of who he is
                                self.BUTTON_JUMP = TRUE; // leave
-                       else if not(g_rpg && cvar("g_rpg_botattack") < 2)
+                       else if not((g_rpg && cvar("g_rpg_botattack") < 2) || !cvar("g_vore_digestion")) // don't leave when gentle vore is enabled
                        {
                                if not(teams_matter && self.team == self.predator.team && cvar("g_balance_vore_teamheal") && self.health < cvar("g_balance_vore_teamheal_stable")) // we are being team healed, don't leave
                                if not(teams_matter && self.team == self.predator.team && cvar("bot_ai_vore_stayinstomach")) // bots are not supposed to leave a team mate's stomach automatically