26 #include "../../cl_shared.h"
27 #include "../cl_game.h"
29 #include "../../ui/ui_data.h"
61 cgi->Cvar_SetValue(
"ai_numcivilians", 8);
65 cgi->
Cvar_Set(
"ai_civilianteam",
"europe");
88 if (cgi->GAME_IsTeamEmpty()) {
89 cgi->GAME_LoadDefaultTeam(
false);
92 if (cgi->GAME_IsTeamEmpty()) {
94 const char* ugvTeamDefID =
"phalanx_ugv_phoenix";
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");
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")) {
155 Com_sprintf(cvarBuf,
sizeof(cvarBuf),
"%sname", cvarName);
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."),
208 enemiesKilled, numSpawned[
TEAM_ALIEN], enemiesStunned, numAlive[TEAM_ALIEN],
209 numAlive[team], numSpawned[team], ownLost, ownFriendlyFire,
210 numAlive[
TEAM_CIVILIAN], numSpawned[TEAM_CIVILIAN], civLost, civFriendlyFire);
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");
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");
259 cgi->UI_ExecuteConfunc(
"skirmish_hide_ufos false");
261 cgi->
Cvar_Set(
"rm_crashed",
"%s",
"");
270 cgi->GAME_SwitchCurrentSelectedMap(step ? step : 1);
272 cgi->Com_Error(
ERR_DROP,
"no singleplayer map found");
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++) {
303 for (
int i = 0;
i < ufoIdsNum;
i++) {
309 const int maxDropShips = cgi->Com_GetDropShipIdsNum();
310 for (
int i = 0;
i < maxDropShips;
i++) {
323 {
nullptr,
nullptr,
nullptr}
328 cl_equip = cgi->
Cvar_Get(
"cl_equip",
"multiplayer_initial", 0,
"Equipment that is used for skirmish mode games");
330 cgi->Cmd_TableAddList(skirmishCmds);
337 cgi->Cmd_TableRemoveList(skirmishCmds);
344 cgi->SV_Shutdown(
"Quitting server.",
false);
347 #ifndef HARD_LINKED_CGAME
357 e.
name =
"Skirmish mode";
static const cgame_import_t * cgi
QGL_EXTERN GLint GLenum type
static void GAME_SK_ChangeEquip_f(void)
Changed the given cvar to the next/prev equipment definition.
short humanAircraftType_t
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
void *IMPORT * LIST_GetRandom(linkedList_t *list)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
static void GAME_SK_Restart_f(void)
static void GAME_InitMenuOptions(void)
const char *IMPORT * Com_DropShipTypeToShortName(humanAircraftType_t type)
static void GAME_SK_HideUFOs(const linkedList_t *ufos)
Hide the ufo selection or show it with the ufos given in the parameter.
#define CGAME_HARD_LINKED_FUNCTIONS
const char *IMPORT * Cvar_GetString(const char *varName)
#define Q_strvalid(string)
const char *IMPORT * Com_UFOCrashedTypeToShortName(ufoType_t type)
const teamDef_t * alienTeams[MAX_TEAMS_PER_MISSION]
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 ...
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
linkedList_t * equipmentList
const equipDef_t *IMPORT * GAME_ChangeEquip(const linkedList_t *equipmentList, changeEquipType_t changeType, const char *equipID)
const equipDef_t *IMPORT * INV_GetEquipmentDefinitionByID(const char *name)
const mapDef_t *EXPORT * MapInfo(int step)
const char *IMPORT * Com_UFOTypeToShortName(ufoType_t type)
static const char * GAME_SK_GetRandomMapAssemblyNameForCraft(const char *name)
static void GAME_SK_InitStartup(void)
teamDef_t teamDef[MAX_TEAMDEFS]
Atomic structure used to define most of the UI.
cvar_t *IMPORT * Cvar_Get(const char *varName, const char *value, int flags, const char *desc)
const mapDef_t *IMPORT * GAME_GetCurrentSelectedMap(void)
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_Shutdown(void)
const char *IMPORT * Com_GetRandomMapAssemblyNameForCraft(const char *craftID)
Skirmish game type headers.
uiNode_t *IMPORT * UI_GetOption(int dataId)
const cgame_export_t * GetCGameAPI(const cgame_import_t *import)
const cgameType_t * cgameType
static void GAME_SK_Start_f(void)
Starts a new skirmish game.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
#define MAX_TEAMS_PER_MISSION
static const mapDef_t * GAME_SK_MapInfo(int step)
const chrTemplate_t * alienChrTemplates[MAX_TEAMS_PER_MISSION]
static CGAME_HARD_LINKED_FUNCTIONS void GAME_SK_InitMissionBriefing(const char **title, linkedList_t **victoryConditionsMsgIDs, linkedList_t **missionBriefingMsgIDs)
const char uiNode_t *IMPORT * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
static const cmdList_t skirmishCmds[]
const char *IMPORT * Cmd_Argv(int n)
cvar_t *IMPORT * Cvar_ForceSet(const char *varName, const char *value)
static void GAME_SK_HideDropships(const linkedList_t *dropships)
Hide the dropship selection or show it with the dropship given in the parameter.