Beispiel #1
0
/*
=======================================================================================================================================
BotMatch_CheckPoint
=======================================================================================================================================
*/
void BotMatch_CheckPoint(bot_state_t *bs, bot_match_t *match) {
	int areanum;
	char buf[MAX_MESSAGE_SIZE];
	vec3_t position;
	bot_waypoint_t *cp;

	if (!TeamPlayIsOn()) {
		return;
	}

	trap_BotMatchVariable(match, POSITION, buf, MAX_MESSAGE_SIZE);
	VectorClear(position);
	// BotGPSToPosition(buf, position);
	sscanf(buf, "%f %f %f", &position[0], &position[1], &position[2]);
	position[2] += 0.5;
	areanum = BotPointAreaNum(position);

	if (!areanum) {
		if (BotAddressedToBot(bs, match)) {
			BotAI_BotInitialChat(bs, "checkpoint_invalid", NULL);
			trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
		}

		return;
	}

	trap_BotMatchVariable(match, NAME, buf, MAX_MESSAGE_SIZE);
	// check if there already exists a checkpoint with this name
	cp = BotFindWayPoint(bs->checkpoints, 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 check point
	cp = BotCreateWayPoint(buf, position, areanum);
	// add the check point to the bot's known chech points
	cp->next = bs->checkpoints;

	if (bs->checkpoints) {
		bs->checkpoints->prev = cp;
	}

	bs->checkpoints = cp;

	if (BotAddressedToBot(bs, match)) {
		Com_sprintf(buf, sizeof(buf), "%1.0f %1.0f %1.0f", cp->goal.origin[0], cp->goal.origin[1], cp->goal.origin[2]);

		BotAI_BotInitialChat(bs, "checkpoint_confirm", cp->name, buf, NULL);
		trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);
	}
}
Beispiel #2
0
/*
==================
BotGetMessageTeamGoal
==================
*/
int BotGetMessageTeamGoal(bot_state_t *bs, char *goalname, bot_goal_t *goal) {
	bot_waypoint_t *cp;

	if (BotGetItemTeamGoal(goalname, goal)) return qtrue;

	cp = BotFindWayPoint(bs->checkpoints, goalname);
	if (cp) {
		memcpy(goal, &cp->goal, sizeof(bot_goal_t));
		return qtrue;
	}
	return qfalse;
}