bool BotHeadTowardWaypoint( bot_t *pBot ) { // You could do other stuff here if you needed to. // This would probably be a good place to check to see how close to a // the current waypoint the bot is, and if the bot is close enough to // the desired waypoint then call BotFindWaypoint to find the next one. if (BotFindWaypoint(pBot)) return TRUE; else return FALSE; }
/* =================== BotMatch_CheckPoint =================== */ void BotMatch_CheckPoint(bot_state_t *bs, bot_match_t *match, gentity_t *sender) { int area; char netname[MAX_MESSAGE_SIZE]; char buf[MAX_MESSAGE_SIZE]; vec3_t position; bot_waypoint_t *cp; qboolean addressed; // The bot only confirms checkpoints if the messages were directly sent to this bot addressed = BotAddresseeMatch(bs, match); // Determine the checkpoint's location and area trap_BotMatchVariable(match, POSITION, buf, MAX_MESSAGE_SIZE); VectorClear(position); sscanf(buf, "%f %f %f", &position[0], &position[1], &position[2]); position[2] += 0.5; area = LevelAreaPoint(position); // Check for invalid checkpoints if (!area) { // Complain about an invalid checkpoint if (addressed) { Bot_InitialChat(bs, "checkpoint_invalid", NULL); trap_BotEnterChat(bs->cs, sender->s.number, CHAT_TELL); } return; } // If the bot has another checkpoint with this name, delete it trap_BotMatchVariable(match, NAME, buf, MAX_MESSAGE_SIZE); cp = BotFindWaypoint(bs, buf); if (cp) { if (cp->next) cp->next->prev = cp->prev; if (cp->prev) cp->prev->next = cp->next; else bs->checkpoints = cp->next; cp->inuse = qfalse; } // Create a new checkpoint cp = BotCreateWaypoint(buf); if (!cp) return; // Construct the waypoint goal GoalLocationArea(&cp->goal, position, area); // Add the checkpoint to the bot's checkpoint list cp->next = bs->checkpoints; if (bs->checkpoints) bs->checkpoints->prev = cp; bs->checkpoints = cp; // Confirm creation of the checkpoint if (addressed) { Bot_InitialChat(bs, "checkpoint_confirm", cp->name, GoalNameFast(&cp->goal), NULL); trap_BotEnterChat(bs->cs, sender->s.number, CHAT_TELL); } }