示例#1
0
static void SP_misc_camera (Edict* ent)
{
	/* only used in single player */
	if (G_IsMultiPlayer()) {
		G_FreeEdict(ent);
		return;
	}

	const bool rotate = ent->spawnflags & CAMERA_ROTATE;
	G_InitCamera(ent, CAMERA_STATIONARY, ent->angle, rotate);
}
示例#2
0
/**
 * @brief info_human_start (1 0 0) (-16 -16 -24) (16 16 32)
 * Starting point for a single player human.
 */
static void SP_human_start (Edict* ent)
{
	/* only used in single player */
	if (G_IsMultiPlayer()) {
		G_FreeEdict(ent);
		return;
	}
	ent->team = TEAM_PHALANX;
	ent->STUN = 0;
	ent->HP = INITIAL_HP;
	G_ActorSpawn(ent);
}
示例#3
0
文件: g_main.cpp 项目: yason/ufoai
/**
 * @sa SV_RunGameFrame
 * @sa G_MatchEndTrigger
 * @sa AI_Run
 * @return true if game reaches its end - false otherwise
 */
static bool G_RunFrame (void)
{
	level.framenum++;
	/* server is running at 10 fps */
	level.time = level.framenum * SERVER_FRAME_SECONDS;

	/* this doesn't belong here, but it works */
	if (!level.routed) {
		level.routed = true;
		G_CompleteRecalcRouting();
	}

	/* still waiting for other players */
	if (!G_MatchIsRunning()) {
		if (sv_maxteams->modified) {
			/* inform the client */
			gi.ConfigString(CS_MAXTEAMS, "%i", sv_maxteams->integer);
			sv_maxteams->modified = false;
		}
	}

	if (G_IsMultiPlayer()) {
		if (sv_roundtimelimit->modified) {
			/* some played around here - restart the count down */
			level.roundstartTime = level.time;
			/* don't allow smaller values here */
			if (sv_roundtimelimit->integer < 30 && sv_roundtimelimit->integer > 0) {
				gi.DPrintf("The minimum value for sv_roundtimelimit is 30\n");
				gi.Cvar_Set("sv_roundtimelimit", "30");
			}
			sv_roundtimelimit->modified = false;
		}
		G_CheckForceEndRound();
	}

	/* end this game? */
	if (G_MatchDoEnd())
		return true;

	CheckNeedPass();

	/* run ai */
	AI_Run();

	/* not all teams are spawned or game has already ended */
	if (G_MatchIsRunning())
		G_EdictsThink();

	G_SendBoundingBoxes();

	return false;
}
示例#4
0
/**
 * @brief info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32)
 * Starting point for a civilian.
 */
static void SP_civilian_start (Edict* ent)
{
	/* deactivateable in multiplayer */
	if (G_IsMultiPlayer() && !ai_numcivilians->integer) {
		G_FreeEdict(ent);
		return;
	}
	ent->team = TEAM_CIVILIAN;
	/* set stats */
	ent->STUN = 99;	/** @todo Does anybody know _why_ this is set to 99? */
	ent->HP = INITIAL_HP;
	ent->count = 100; /* current waypoint */
	G_ActorSpawn(ent);
}
示例#5
0
/**
 * @brief info_alien_start (1 0 0) (-16 -16 -24) (16 16 32)
 * Starting point for a single player alien.
 */
static void SP_alien_start (Edict* ent)
{
	/* deactivateable in multiplayer */
	if (G_IsMultiPlayer() && !ai_multiplayeraliens->integer) {
		G_FreeEdict(ent);
		return;
	}
	ent->team = TEAM_ALIEN;
	/* set stats */
	ent->STUN = 0;
	ent->HP = INITIAL_HP;

	G_ActorSpawn(ent);
}
示例#6
0
/**
 * @brief Spawns the world entity
 *
 * Only used for the world.
 * "sounds"	music cd track number
 * "maxlevel"	max. level to use in the map
 * "maxteams"	max team amount for multiplayergames for the current map
 */
static void SP_worldspawn (Edict* ent)
{
	ent->solid = SOLID_BSP;
	/* since the world doesn't use G_Spawn() */
	ent->inuse = true;
	ent->classname = "worldspawn";

	level.noEquipment = spawnTemp.noEquipment;
	level.noRandomSpawn = spawnTemp.noRandomSpawn;

	gi.ConfigString(CS_MAXCLIENTS, "%i", sv_maxclients->integer);

	/* only used in multi player */
	if (G_IsMultiPlayer()) {
		gi.ConfigString(CS_MAXSOLDIERSPERTEAM, "%i", sv_maxsoldiersperteam->integer);
		gi.ConfigString(CS_MAXSOLDIERSPERPLAYER, "%i", sv_maxsoldiersperplayer->integer);
		gi.ConfigString(CS_ENABLEMORALE, "%i", sv_enablemorale->integer);
		gi.ConfigString(CS_MAXTEAMS, "%s", sv_maxteams->string);
	}
}
示例#7
0
/**
 * @brief info_2x2_start (1 1 0) (-32 -32 -24) (32 32 32)
 * Starting point for a 2x2 unit.
 */
static void SP_2x2_start (Edict* ent)
{
	/* no 2x2 unit in multiplayer */
	if (G_IsMultiPlayer()) {
		G_FreeEdict(ent);
		return;
	}
	/* set stats */
	ent->STUN = 0;
	ent->HP = INITIAL_HP;

	if (!ent->team)
		ent->team = TEAM_PHALANX;

	/* these units are bigger */
	VectorSet(ent->maxs, PLAYER_WIDTH * 2, PLAYER_WIDTH * 2, PLAYER_STAND);
	VectorSet(ent->mins, -(PLAYER_WIDTH * 2), -(PLAYER_WIDTH * 2), PLAYER_MIN);

	/* spawn singleplayer 2x2 unit */
	G_Actor2x2Spawn(ent);
}
示例#8
0
/**
 * @brief Rescue trigger to mark an actor to be in the rescue
 * zone. Aborting a game would not kill the actors inside this
 * trigger area.
 * @note Called once for every step
 * @sa Touch_RescueTrigger
 */
void SP_trigger_rescue (Edict* ent)
{
	/* only used in single player */
	if (G_IsMultiPlayer()) {
		G_FreeEdict(ent);
		return;
	}

	ent->classname = "trigger_rescue";
	ent->type = ET_TRIGGER_RESCUE;

	ent->solid = SOLID_TRIGGER;
	gi.SetModel(ent, ent->model);

	if (ent->spawnflags == 0)
		ent->spawnflags |= 0xFF;
	ent->setTouch(Touch_RescueTrigger);
	ent->reset = Reset_RescueTrigger;
	ent->setChild(nullptr);

	gi.LinkEdict(ent);
}
示例#9
0
void SP_trigger_nextmap (Edict* ent)
{
	/* only used in single player */
	if (G_IsMultiPlayer()) {
		G_FreeEdict(ent);
		return;
	}

	if (!ent->particle) {
		gi.DPrintf("particle isn't set for %s\n", ent->classname);
		G_FreeEdict(ent);
		return;
	}
	if (!ent->nextmap) {
		gi.DPrintf("nextmap isn't set for %s\n", ent->classname);
		G_FreeEdict(ent);
		return;
	}

	if (Q_streq(ent->nextmap, level.mapname)) {
		gi.DPrintf("nextmap loop detected\n");
		G_FreeEdict(ent);
		return;
	}

	ent->classname = "trigger_nextmap";
	ent->type = ET_TRIGGER_NEXTMAP;

	ent->solid = SOLID_TRIGGER;
	gi.SetModel(ent, ent->model);

	ent->reset = nullptr;
	ent->setChild(nullptr);

	gi.LinkEdict(ent);
}