Man is this an overdue lesson.
I've been meaning to write this one for months now. It is rather fundamental, and important as well. This will allow your bots to "win games." That is, if he reaches the fraglimit set through the console then the Quake will exit to the intermission screen, just like regular servers.
Lucky for us, this tutorial is butt-simple. In fact, it doesn't even require a new subroutine. All we have to do is call the player routine named CheckRules(), which is found in client.qc. This of course checks the player's frags and the time. Here, it looks like this:
/* ============ CheckRules Exit deathmatch games upon conditions ============ */ void() CheckRules = { local float timelimit; local float fraglimit; if (gameover) // someone else quit the game already return; timelimit = cvar("timelimit") * 60; fraglimit = cvar("fraglimit"); if (timelimit && time >= timelimit) { NextLevel (); return; } if (fraglimit && self.frags >= fraglimit) { NextLevel (); return; } };I believe this is self-explanatory. The cool thing about this routine is that it contains no is player-only code. This allows the bot to use it. Cool.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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;Add the following after that:
CheckRules();Done. You may elect to call this routine more often. You could even call it from the routine bot_walk(), which means it would be called during every one of the bot's frames. I think this works fine. Oh, and remember to set the variabes "fraglimit" or "timelimit" through the console.