1 .float status_teamhealing; // 0 = can't team heal, 1 = can team heal, 2 = team healing currently
3 entity Swallow_distance_check_bot(entity e)
5 // check if we can swallow a player instead of firing our weapon
6 vector w_shotorg, w_shotdir;
7 w_shotorg = self.origin + self.view_ofs;
10 WarpZone_traceline_antilag(e, w_shotorg, w_shotorg + w_shotdir * cvar("g_balance_vore_swallow_range"), FALSE, e, ANTILAG_LATENCY(e));
11 if(trace_fraction < 1)
12 if(trace_ent.classname == "player")
17 float Swallow_condition_check_bot(entity prey)
19 // checks the necessary conditions for a bot to swallow another player
20 if(prey != self && prey.classname == "player" && prey.eater.classname != "player" && prey.deadflag == DEAD_NO && !prey.BUTTON_CHAT) // we can't swallow someone who's already in someone else's stomach
21 if(self.eater.classname != "player" && self.stomach_load < cvar("g_balance_vore_swallow_limit") && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves
22 if not(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load)
23 if(self.health > cvar("g_balance_vore_kick_damage_max")) // explained below
28 void Vore_AI_Teamheal(entity prey)
30 // allows bots to take advantage of the teamheal feature, and use it to heal damaged team mates
34 if not(teams_matter && cvar("g_balance_vore_teamheal"))
36 if(self.deadflag != DEAD_NO || self.eater.classname == "player" || self.flagcarried || self.digesting) // a flag carrier can't waste time on team healing
38 self.status_teamhealing = 0;
42 // decide if we can teamheal or not
45 self.status_teamhealing = 2; // consider a team mate is in our stomach and therefore we are teamhealing, until proven otherwise below
49 if(head.eater == self)
50 if(head.team != self.team)
52 self.status_teamhealing = 0; // there's a foe in our stomach, we can't teamheal now
58 self.status_teamhealing = 1; // if our stomach is empty, it means we can decide to teamheal
60 // now that we're decided if we can teamheal or not, lets go ahead and do so:
62 // if we are holding a team mate that's been healed to the maximum amount, we can release them
63 // not sure if this should be merged with the FOR_EACH_PLAYER check above. That would save an extra loop, but would be less correct
66 if(head.eater == self) // head is automatically a team mate, or we wouldn't be reaching this part of the code
67 if(head.health >= cvar("g_balance_vore_teamheal_stable"))
68 self.BUTTON_REGURGITATE = TRUE; // release the team mate
71 // check if we can heal a damaged team mate we came across, and if so swallow them
72 if(prey.classname == "player" && prey.team == self.team)
73 if(prey.health < cvar("g_balance_vore_teamheal_stable"))
74 if not(prey.flagcarried) // don't eat the flag carrier and ruin his job
75 if(Swallow_condition_check_bot(prey))
76 self.BUTTON_ATCK = TRUE; // swallow
79 .float swallow_retry, decide_delay1, decide_delay2;
82 if(cvar("bot_nofire") || !skill)
85 // --------------------------------
86 // Predator bot behavior:
87 // --------------------------------
89 // finding and swallowing a victim:
91 // aim toward the nearest possible victim. The greater the skill the quicker the aim. This only does the aiming, checking and swallowing is handled below
93 scan = findradius(self.origin, cvar("g_balance_vore_swallow_range"));
94 if(Swallow_condition_check_bot(scan))
95 bot_aimdir(scan.origin + scan.view_ofs - self.origin - self.view_ofs, -1);
97 // now do the actual checking and swallowing
100 float decide_prey, decide_pred;
102 prey = Swallow_distance_check_bot(self);
104 // check if we should run the Teamhealing AI rather than continuing with the normal vore
105 Vore_AI_Teamheal(prey);
106 if(self.status_teamhealing > 1) // if we are teamhealing, there's nothing to do from here on
109 random_try = random() * 10; // there are 10 bot skill steps
110 if(prey.items & IT_STRENGTH) // avoid eating bots that have the Strenght powerup
111 random_try /= cvar("bot_ai_vore_decide_fear");
112 if(prey.items & IT_INVINCIBLE) // avoid eating bots that have the Invincible powerup
113 random_try /= cvar("bot_ai_vore_decide_fear");
114 decide_prey = cvar("bot_ai_vore_decide_prey") / (skill * 2 + 1);
115 decide_pred = cvar("bot_ai_vore_decide_pred") / (skill * 2 + 1);
117 if(time > self.swallow_retry)
118 if(Swallow_condition_check_bot(prey))
120 // the greater the skill, the higher the chance bots will swallow someone each attempt
121 if(skill >= random_try)
122 if not(teams_matter && prey.team == self.team)
124 self.BUTTON_ATCK = TRUE; // swallow
125 self.decide_delay1 = time + decide_pred; // time before the bot decides what to do with their prey
127 self.swallow_retry = time + 0.5; // bots retry swallowing every 0.5 seconds, otherwise each frame would be random chance
130 // deciding what to do with a victim:
132 if(self.stomach_load > 0 && time > self.decide_delay1)
134 // if the predator's health is smaller than the maximum amount of damage a stomach kick can do, regurgitate the player(s)
135 // otherwise the predator is putting himself at risk by keeping someone inside
136 if(self.health <= cvar("g_balance_vore_kick_damage_max"))
137 self.BUTTON_REGURGITATE = TRUE;
139 else if(!self.digesting)
141 // the higher the skill, the faster bots will start to digest you
142 if(skill >= random_try)
143 self.BUTTON_DIGEST = TRUE; // digest
145 self.decide_delay1 = time + decide_pred; // time before the bot decides what to do with their prey
149 // --------------------------------
150 // Prey bot behavior:
151 // --------------------------------
153 // 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
154 if(self.eater.classname == "player" && time > self.decide_delay2)
156 if not(teams_matter && self.team == self.eater.team)
158 // the higher the skill, the more the bot will kick in your stomack
159 if(skill >= random_try)
160 if not(teams_matter && prey.team == self.team) // if someone from the same team somehow made it in the belly, don't kick the eater
161 self.BUTTON_ATCK = TRUE; // kick
164 // if a bot can willingly leave the predator, do so unless there's a reason not to
165 if(self.stat_canleave)
166 if not(teams_matter && self.team == self.eater.team && cvar("g_balance_vore_teamheal") && self.health < cvar("g_balance_vore_teamheal_stable")) // we are being team healed, don't leave
167 self.BUTTON_JUMP = TRUE;
169 self.decide_delay2 = time + decide_prey; // time before the bot decides what to do with their predator