This lesson is pretty darn straight-forward: the bot will learn how to flee when injured. The catch is that bots aren't really good at fleeing. That is, they are not good at getting from room to room easily. If you have spent any time observing bots, you know what I mean.
Anyway, we will give it a try. This is a decent subroutine. And of course, you can spend all the time you want tweaking it. Go ahead and open up tutor.qc and scroll down to the subroutine bot_run(), which looks kind of like so:
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void() bot_run = // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { // his fighting thoughts. after a short while, he'll give up // on his enemy, but if he can see him, he'll always attack if (!(self.flags & FL_ONGROUND)) return; check_for_water(); if (visible(self.enemy)) self.search_time = time + 6; if (time > self.search_time || self.enemy.health <= 0) { self.goalentity = world; self.enemy = world; self.pausetime = time + 4; self.th_stand(); return; }As you know, this is his main attack routine, his combat brain. If his health is under a certain value, we want him to turn around and get the hell outta Dodge. Very simple to do. After the previous code, add this:
if (self.health < 25) { self.angles_y = vectoyaw(self.origin - self.enemy.origin); if (walkmove(self.angles_y, 20) == FALSE) bot_run_slide(); return; }Ahem, that's it. I might not be know across the world as a great coder, but I'm sure one of the briefest. A fleeing routine in seven lines. Not bad.