Ding ding. The bell has rung, and we're back in class. Your second homework assignment is due. I'm ready to dole out discipline to any class clowns who aren't prepared.
Your project was to create bot orders, particularly camping and roaming. If you could get the first one, then you could get the second. And they were both pretty simple.
Let's do this in logical order. Of course you would need input from the player. That always comes from the subroutine ImpulseCommands() in player.qc. There, you would need to insert lines like this:
if (self.impulse = 150) order_bot_camp(); if (self.impulse = 151) order_bot_roam();Simply enough. We can now take two typed impulses from the player. But we called two subs that we don't yet have. The fastest place to put them is right before ImpulseCommands(). There, you would paste the following:
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void() order_bot_camp = // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { local entity bot; local float found_bot; if (teamplay == 0) { bprint("teamplay not active\n"); return; } found_bot = FALSE; bot = findradius(self.origin, 1500); while(bot) { if (bot.classname == "bot" && bot.team == self.team && bot.health > 0 && bot.enemy.health <= 0 && visible(bot)) { bot.think = bot.th_stand; bot.nextthink = time + 0.1; bot.pausetime = time + 60; bprint(bot.netname); bprint(" will camp\n"); found_bot = TRUE; } bot = bot.chain; } if (found_bot == FALSE) bprint("no bot around you\n"); };Purdy darn cool. First, if teamplay is zero, we leave. Two, we check all entities in a 1500-unit radius. Third, if we find a visible bot who is alive and on our team and not fighting anyone, we tell him to stand for the next sixty seconds. Next, we print a fancy little message and go onto the next entity in the radius.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void() order_bot_roam = // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { local entity bot; local float found_bot; if (teamplay == 0) { bprint("teamplay not active\n"); return; } found_bot = FALSE; bot = findradius(self.origin, 1500); while(bot) { if (bot.classname == "bot" && bot.team == self.team && bot.health > 0 && bot.enemy.health <= 0 && visible(bot)) { bot.think = bot.th_walk; bot.nextthink = time + 0.1; bot.pausetime = 0; bprint(bot.netname); bprint(" will roam\n"); found_bot = TRUE; } bot = bot.chain; } if (found_bot == FALSE) bprint("no bot around you\n"); };All I did was copy and paste the camp routine, rename it, and changed a couple of lines. I told him to walk instead of stand. That's it.