38 const mapDef_t* md =
cgi->GAME_GetCurrentSelectedMap();
52 return cgi->Com_GetRandomMapAssemblyNameForCraft(
name);
61 cgi->Cvar_SetValue(
"ai_numcivilians", 8);
63 cgi->Cvar_Set(
"ai_civilianteam",
"%s", md->
civTeam);
65 cgi->Cvar_Set(
"ai_civilianteam",
"europe");
67 cgi->Cvar_Set(
"sv_hurtaliens",
"0");
71 cgi->csi->numAlienTeams = 0;
72 for (
int i = 0;
i <
cgi->csi->numTeamDefs;
i++) {
75 cgi->csi->alienChrTemplates[
cgi->csi->numAlienTeams] =
nullptr;
76 cgi->csi->alienTeams[
cgi->csi->numAlienTeams++] = td;
88 if (
cgi->GAME_IsTeamEmpty()) {
89 cgi->GAME_LoadDefaultTeam(
false);
92 if (
cgi->GAME_IsTeamEmpty()) {
94 const char* ugvTeamDefID =
"phalanx_ugv_phoenix";
95 const char*
name =
cgi->Cvar_GetString(
"cl_equip");
97 const size_t size =
cgi->GAME_GetCharacterArraySize();
98 uint32_t maxSoldiers =
cgi->Cvar_GetInteger(
"sv_maxsoldiersperplayer");
99 uint32_t ugvs =
cgi->Cvar_GetInteger(
"cl_ugvs");
101 if (maxSoldiers <= 0)
104 ugvs = std::min(ugvs, (uint32_t)(
size - maxSoldiers));
105 cgi->Com_Printf(
"Starting skirmish with %i soldiers and %i ugvs\n", maxSoldiers, ugvs);
106 cgi->GAME_AutoTeam(
name, maxSoldiers);
107 for (
unsigned int i = 0;
i < ugvs;
i++)
108 cgi->GAME_AppendTeamMember(
i + maxSoldiers, ugvTeamDefID, ed);
110 cgi->Com_Printf(
"Using already loaded team\n");
113 const mapDef_t* md =
cgi->GAME_GetCurrentSelectedMap();
121 cgi->Cbuf_AddText(
"map %s %s %s;",
cgi->Cvar_GetInteger(
"mn_serverday") ?
"day" :
"night", md->
mapTheme, md->
params ? (
const char*)
cgi->LIST_GetRandom(md->
params) :
"");
126 cgi->GAME_ReloadMode();
135 if (
cgi->Cmd_Argc() < 2) {
136 cgi->Com_Printf(
"Usage: %s <cvarname>\n",
cgi->Cmd_Argv(0));
140 const char* command =
cgi->Cmd_Argv(0);
141 const char* cvarName =
cgi->Cmd_Argv(1);
144 if (
Q_streq(command,
"sk_prevequip")) {
146 }
else if (
Q_streq(command,
"sk_nextequip")) {
152 const equipDef_t* ed =
cgi->GAME_ChangeEquip(
cgi->cgameType->equipmentList,
type,
cgi->Cvar_GetString(cvarName));
155 Com_sprintf(cvarBuf,
sizeof(cvarBuf),
"%sname", cvarName);
157 cgi->Cvar_Set(cvarName,
"%s", ed->
id);
158 cgi->Cvar_Set(cvarBuf,
"_%s", ed->
name);
179 cgi->UI_InitStack(
"main",
"");
182 cgi->UI_Popup(
_(
"Game Drawn!"),
"%s\n",
_(
"The game was a draw!\n\nEnemies escaped."));
187 cgi->UI_Popup(
_(
"Game Drawn!"),
"%s\n",
_(
"The game was a draw!\n\nNo survivors left on any side."));
191 const int team =
cgi->GAME_GetCurrentTeam();
192 const int ownFriendlyFire = numKilled[team][team] + numKilled[
TEAM_CIVILIAN][team];
193 const int ownLost = numSpawned[team] - numAlive[team] - ownFriendlyFire;
197 int enemiesStunned = 0;
203 char resultText[1024];
205 _(
"\n%i of %i enemies killed, %i stunned, %i survived.\n"
206 "%i of %i team members survived, %i lost in action, %i friendly fire loses.\n"
207 "%i of %i civilians saved, %i civilian loses, %i friendly fire loses."),
209 numAlive[team], numSpawned[team], ownLost, ownFriendlyFire,
211 if (winner == team) {
212 cgi->UI_Popup(
_(
"Congratulations"),
"%s\n%s\n",
_(
"You won the game!"), resultText);
214 cgi->UI_Popup(
_(
"Better luck next time"),
"%s\n%s\n",
_(
"You've lost the game!"), resultText);
218 cgi->Cbuf_AddText(
"game_exit");
228 const bool hide = (dropships ==
nullptr);
230 cgi->UI_ExecuteConfunc(
"skirmish_hide_dropships true");
231 cgi->Cvar_Set(
"rm_drop",
"%s",
"");
234 cgi->Cvar_Set(
"rm_drop",
"%s", rma);
238 cgi->UI_ExecuteConfunc(
"skirmish_hide_dropships false");
249 const bool hide = (ufos ==
nullptr);
251 cgi->UI_ExecuteConfunc(
"skirmish_hide_ufos true");
252 cgi->Cvar_Set(
"rm_ufo",
"%s",
"");
255 cgi->Cvar_Set(
"rm_ufo",
"%s", rma);
259 cgi->UI_ExecuteConfunc(
"skirmish_hide_ufos false");
261 cgi->Cvar_Set(
"rm_crashed",
"%s",
"");
268 while (!
cgi->GAME_GetCurrentSelectedMap()->singleplayer) {
270 cgi->GAME_SwitchCurrentSelectedMap(step ? step : 1);
272 cgi->Com_Error(
ERR_DROP,
"no singleplayer map found");
275 const mapDef_t* md =
cgi->GAME_GetCurrentSelectedMap();
277 cgi->Cvar_SetValue(
"ai_singleplayeraliens", md->
maxAliens);
296 uiNode_t* aircraftOptions =
nullptr;
298 const short ufoIdsNum =
cgi->Com_GetUFOIdsNum();
299 for (
int i = 0;
i < ufoIdsNum;
i++) {
300 const char* shortName =
cgi->Com_UFOTypeToShortName((
ufoType_t)
i);
303 for (
int i = 0;
i < ufoIdsNum;
i++) {
304 const char* shortName =
cgi->Com_UFOCrashedTypeToShortName((
ufoType_t)
i);
309 const int maxDropShips =
cgi->Com_GetDropShipIdsNum();
310 for (
int i = 0;
i < maxDropShips;
i++) {
323 {
nullptr,
nullptr,
nullptr}
327 cgi->Cvar_ForceSet(
"sv_maxclients",
"1");
328 cl_equip =
cgi->Cvar_Get(
"cl_equip",
"multiplayer_initial", 0,
"Equipment that is used for skirmish mode games");
339 cgi->Cvar_ForceSet(
"g_endlessaliens",
"0");
344 cgi->SV_Shutdown(
"Quitting server.",
false);
347#ifndef HARD_LINKED_CGAME
357 e.
name =
"Skirmish mode";
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
Shared game type headers.
#define CGAME_HARD_LINKED_FUNCTIONS
static void GAME_SK_ChangeEquip_f(void)
Changed the given cvar to the next/prev equipment definition.
static void GAME_SK_Results(dbuffer *msg, int winner, int *numSpawned, int *numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap)
After a mission was finished this function is called.
static void GAME_SK_Restart_f(void)
static void GAME_SK_HideDropships(const linkedList_t *dropships)
Hide the dropship selection or show it with the dropship given in the parameter.
static void GAME_SK_Start_f(void)
Starts a new skirmish game.
static void GAME_SK_Shutdown(void)
static const mapDef_t * GAME_SK_MapInfo(int step)
static void GAME_SK_InitStartup(void)
static void GAME_SK_HideUFOs(const linkedList_t *ufos)
Hide the ufo selection or show it with the ufos given in the parameter.
static void GAME_InitMenuOptions(void)
static const cmdList_t skirmishCmds[]
static const char * GAME_SK_GetRandomMapAssemblyNameForCraft(const char *name)
static void GAME_SK_SetMissionParameters(const mapDef_t *md)
Register some data in the shared client/server structs to ensure that e.g. every known alien race is ...
static CGAME_HARD_LINKED_FUNCTIONS void GAME_SK_InitMissionBriefing(const char **title, linkedList_t **victoryConditionsMsgIDs, linkedList_t **missionBriefingMsgIDs)
const cgame_export_t * GetCGameAPI(const cgame_import_t *import)
Skirmish game type headers.
Share stuff between the different cgame implementations.
const cgame_import_t * cgi
#define MAX_TEAMS_PER_MISSION
short humanAircraftType_t
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
#define Q_strvalid(string)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const mapDef_t *EXPORT * MapInfo(int step)
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Atomic structure used to define most of the UI.
Data and interface to share data.