Exemplo n.º 1
0
/*
===========
SelectSpawnPoint
 
Chooses a player start, deathmatch start, coop start, etc
============
*/
void	SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles){
	edict_t	*spot = NULL;
	
	if(deathmatch->value)
		spot = SelectDeathmatchSpawnPoint();
	else if(coop->value)
		spot = SelectCoopSpawnPoint(ent);
		
	// find a single player start spot
	if(!spot){
		while((spot = G_Find(spot, FOFS(classname), "info_player_start")) != NULL){
			if(!game.spawnpoint[0] && !spot->targetname)
				break;
				
			if(!game.spawnpoint[0] || !spot->targetname)
				continue;
				
			if(Q_stricmp(game.spawnpoint, spot->targetname) == 0)
				break;
		}
		
		if(!spot){
			if(!game.spawnpoint[0]){	// there wasn't a spawnpoint without a target, so use any
				spot = G_Find(spot, FOFS(classname), "info_player_start");
			}
			if(!spot)
				gi.error("Couldn't find spawn point %s\n", game.spawnpoint);
		}
	}
	
	VectorCopy(spot->s.origin, origin);
	origin[2] += 9;
	VectorCopy(spot->s.angles, angles);
}
Exemplo n.º 2
0
/*
 * Chooses a player start, deathmatch start, coop start, etc
 */
void
SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles)
{
	edict_t *spot = NULL;
	edict_t *coopspot = NULL;
	int index;
	int counter = 0;
	vec3_t d;

	if (!ent)
	{
		return;
	}

	if (deathmatch->value)
	{
		spot = SelectDeathmatchSpawnPoint();
	}
	else if (coop->value)
	{
		spot = SelectCoopSpawnPoint(ent);
	}

	/* find a single player start spot */
	if (!spot)
	{
		while ((spot = G_Find(spot, FOFS(classname), "info_player_start")) != NULL)
		{
			if (!game.spawnpoint[0] && !spot->targetname)
			{
				break;
			}

			if (!game.spawnpoint[0] || !spot->targetname)
			{
				continue;
			}

			if (Q_stricmp(game.spawnpoint, spot->targetname) == 0)
			{
				break;
			}
		}

		if (!spot)
		{
			if (!game.spawnpoint[0])
			{
				/* there wasn't a spawnpoint without a target, so use any */
				spot = G_Find(spot, FOFS(classname), "info_player_start");
			}

			if (!spot)
			{
				gi.error("Couldn't find spawn point %s\n", game.spawnpoint);
			}
		}
	}

	/* If we are in coop and we didn't find a coop
	   spawnpoint due to map bugs (not correctly
	   connected or the map was loaded via console
	   and thus no previously map is known to the
	   client) use one in 550 units radius. */
	if (coop->value)
	{
		index = ent->client - game.clients;

		if (Q_stricmp(spot->classname, "info_player_start") == 0 && index != 0)
		{
			while(counter < 3)
			{
				coopspot = G_Find(coopspot, FOFS(classname), "info_player_coop");

				if (!coopspot)
				{
					break;
				}

				VectorSubtract(coopspot->s.origin, spot->s.origin, d);

				if ((VectorLength(d) < 550))
				{
					if (index == counter)
					{
						spot = coopspot;
						break;
					}
					else
					{
						counter++;
					}
				}
			}
		}
	}

	VectorCopy(spot->s.origin, origin);
	origin[2] += 9;
	VectorCopy(spot->s.angles, angles);
}