54 if (
cgi->Cmd_Argc() < 2) {
55 cgi->Com_Printf(
"Usage: %s <won:true|false> [retry:true|false]\n",
cgi->Cmd_Argv(0));
60 if (
cgi->Cmd_Argc() >= 3 &&
cgi->Com_ParseBoolean(
cgi->Cmd_Argv(2))) {
66 cgi->Com_Printf(
"Battle cannot be retried!\n");
81 return _(
"Chicken-hearted");
83 return _(
"Very Easy");
93 return _(
"Very Hard");
97 cgi->Com_Error(
ERR_DROP,
"Unknown difficulty id %i", difficulty);
106 cgi->UI_ExecuteConfunc(
"ui_clear_campaigns");
107 for (
int i = 0;
i <
ccs.numCampaigns;
i++) {
114#define MAXCAMPAIGNTEXT 4096
121 const char* racetype;
125 if (
ccs.numCampaigns > 0)
126 campaign = &
ccs.campaigns[0];
134 cgi->Com_Printf(
"Invalid Campaign id: %s\n",
cgi->Cmd_Argv(1));
139 racetype =
_(
"Human");
141 racetype =
_(
"Aliens");
143 const char* text =
cgi->CL_Translate(campaign->
text);
145 "Credits: %ic\nDifficulty: %s\n"
146 "Min. happiness of nations: %i %%\n"
147 "Max. allowed debts: %ic\n"
148 "%s\n"),
_(campaign->
name), racetype,
170 cgi->Com_Printf(
"Invalid Campaign id: %s\n",
cgi->Cmd_Argv(1));
175 cgi->Cmd_ExecuteString(
"game_exit");
176 cgi->Cmd_ExecuteString(
"game_setmode campaign");
181 cgi->Cbuf_AddText(
"seq_start intro\n");
203 int ownSurvived, ownKilled, ownStunned;
204 int aliensSurvived, aliensKilled, aliensStunned;
205 int civiliansSurvived, civiliansKilled, civiliansStunned;
206 const int currentTeam =
cgi->GAME_GetCurrentTeam();
207 const bool won = (winner == currentTeam);
208 const bool draw = (winner == -1 || winner == 0);
214 ownSurvived = ownKilled = ownStunned = 0;
215 aliensSurvived = aliensKilled = aliensStunned = 0;
216 civiliansSurvived = civiliansKilled = civiliansStunned = 0;
219 if (
i == currentTeam)
220 ownSurvived = numAlive[
i];
222 civiliansSurvived = numAlive[
i];
224 aliensSurvived += numAlive[
i];
226 if (j == currentTeam) {
227 ownKilled += numKilled[
i][j];
228 ownStunned += numStunned[
i][j]++;
230 civiliansKilled += numKilled[
i][j];
231 civiliansStunned += numStunned[
i][j]++;
233 aliensKilled += numKilled[
i][j];
234 aliensStunned += numStunned[
i][j]++;
239 ownSurvived += ownStunned;
248 civiliansSurvived += civiliansStunned;
250 civiliansKilled += civiliansStunned;
258 ccs.aliensKilled += aliensKilled;
268 results->
ownKilled += ownKilled - numKilled[currentTeam][currentTeam] - numKilled[
TEAM_CIVILIAN][currentTeam];
291 results->
ownKilled = ownKilled - numKilled[currentTeam][currentTeam] - numKilled[
TEAM_CIVILIAN][currentTeam];
300 if (
ccs.missionResultCallback) {
301 ccs.missionResultCallback(results);
304 cgi->UI_InitStack(
"geoscape",
"campaign_main");
307 cgi->UI_PushWindow(
"won");
309 cgi->UI_PushWindow(
"draw");
311 cgi->UI_PushWindow(
"lost");
314 cgi->UI_ExecuteConfunc(
"enable_retry");
316 cgi->CL_Disconnect();
317 cgi->SV_Shutdown(
"Mission end",
false);
328 cgi->LIST_AddPointer(chrList, (
void*)&employee->chr);
353 if (!
ccs.teamDefTechs[teamDef->
idx])
354 cgi->Com_Error(
ERR_DROP,
"Could not find tech for teamdef '%s'", teamDef->
id);
367 return &employee->
chr;
374 cgi->UI_InitStack(
"geoscape",
"campaign_main");
376 cgi->SV_Shutdown(
"Mission end",
false);
377 cgi->CL_Disconnect();
403 cgi->UI_DrawTooltip(base->
name, x, y, 250);
411 int y = y1 + padding;
412 for (
int row = 0; row <
BASE_SIZE; row++) {
413 int x = x1 + padding;
414 for (
int col = 0; col <
BASE_SIZE; col++) {
416 cgi->UI_DrawFill(x, y, w, h, bgcolor);
420 cgi->UI_DrawFill(x, y, w, h, color);
430 const int team =
ccs.curCampaign->team;
431 return cgi->Com_ValueToStr(&team,
V_TEAM, 0);
443 cgi->LIST_AddString(missionBriefingMsgIDs,
"*msgid:mission_briefing_crashsite");
460 const int teamSize =
cgi->LIST_Count(team);
463 cgi->NET_WriteByte(msg, teamSize);
466 cgi->NET_WriteShort(msg, chr->ucn);
467 cgi->NET_WriteShort(msg, chr->state);
468 cgi->NET_WriteShort(msg, chr->RFmode.getHand());
469 cgi->NET_WriteShort(msg, chr->RFmode.getFmIdx());
470 cgi->NET_WriteShort(msg, chr->RFmode.getWeapon() !=
nullptr ? chr->RFmode.getWeapon()->idx :
NONE);
476 return &
ccs.eMission;
484 cgi->Cvar_Set(
"mn_chrrank",
_(
"Rank: %s"),
_(rank->
name));
485 cgi->Cvar_Set(
"mn_chrrank_img",
"%s", rank->
image);
486 cgi->Cvar_Set(
"mn_chrrankprefix",
"%s ",
_(rank->
shortname));
488 cgi->Cvar_Set(
"mn_chrrank_img",
"");
489 cgi->Cvar_Set(
"mn_chrrank",
"");
490 cgi->Cvar_Set(
"mn_chrrankprefix",
"");
503 assert(aircraft->
tech);
504 return aircraft->
tech->mdl;
518 {
nullptr,
nullptr,
nullptr}
523#ifndef HARD_LINKED_CGAME
531 cgi->Cvar_ForceSet(
"sv_maxclients",
"1");
532 cgi->Cvar_ForceSet(
"sv_ai",
"1");
550 cgi->SV_Shutdown(
"Quitting server.",
false);
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
Header file for keyboard handler.
Share stuff between the different cgame implementations.
void AII_CollectingItems(aircraft_t *aircraft, int won)
Collect items from the battlefield.
const aircraft_t * AIR_GetAircraftSilent(const char *name)
Searches the global array of aircraft types for a given aircraft.
bool AL_AddAlienTypeToAircraftCargo(aircraft_t *aircraft, const teamDef_t *teamDef, int amount, bool dead)
Adds an alientype to an aircraft cargo.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
base_t * B_GetBaseByIDX(int baseIdx)
Array bound check for the base index. Will also return unfounded bases as long as the index is in the...
#define B_IsTileBlocked(base, x, y)
#define B_GetBuildingAt(base, x, y)
Header file for menu related console command callbacks.
void CP_ResetCampaignData(void)
Will clear most of the parsed singleplayer data.
void CP_Shutdown(void)
Campaign closing actions.
bool CP_OnGeoscape(void)
Returns if we are currently on the Geoscape.
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
void CP_CampaignRun(campaign_t *campaign, float secondsSinceLastFrame)
Called every frame when we are in geoscape view.
void CP_InitStartup(void)
void CP_StartSelectedMission(void)
Starts a selected mission.
void CP_CampaignInit(campaign_t *campaign, bool load)
Called at new game and load game.
campaign_t * CP_GetCampaign(const char *name)
Returns the campaign pointer from global campaign array.
Header file for single player campaign control.
const cgame_import_t * cgi
void CP_ParseCampaignData(void)
Read the data for campaigns.
static void GAME_CP_GetCampaigns_f(void)
Fill the campaign list with available campaigns.
void GAME_CP_DrawBaseLayout(int baseIdx, int x1, int y1, int totalMarge, int w, int h, int padding, const vec4_t bgcolor, const vec4_t color)
static void GAME_CP_CampaignDescription_f(void)
Script function to show description of the selected a campaign.
void GAME_CP_CharacterCvars(const character_t *chr)
const char * GAME_CP_GetTeamDef(void)
void GAME_CP_InitStartup(void)
character_t * GAME_CP_GetSelectedChr(void)
Returns the currently selected character.
equipDef_t * GAME_CP_GetEquipmentDefinition(void)
static void GAME_CP_Results_f(void)
static void GAME_CP_Start_f(void)
Starts a new single-player game.
void GAME_CP_Shutdown(void)
static const cmdList_t cgameCallbacks[]
const char * GAME_CP_GetItemModel(const char *string)
void GAME_CP_InitMissionBriefing(const char **title, linkedList_t **victoryConditionsMsgIDs, linkedList_t **missionBriefingMsgIDs)
void GAME_CP_Frame(float secondsSinceLastFrame)
static char campaignDesc[MAXCAMPAIGNTEXT]
void GAME_CP_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 const char * CP_ToDifficultyName(const int difficulty)
Translate the difficulty int to a translated string.
bool GAME_CP_Spawn(linkedList_t **chrList)
bool GAME_CP_TeamIsKnown(const teamDef_t *teamDef)
Checks whether the team is known at this stage already.
static void AL_AddAlienTypeToAircraftCargo_(void *data, const teamDef_t *teamDef, int amount, bool dead)
void GAME_CP_InitializeBattlescape(dbuffer *msg, const linkedList_t *team)
Changes some actor states for a campaign game.
void GAME_CP_DrawBaseLayoutTooltip(int baseIdx, int x, int y)
Draws basename as tooltip for baselayout widget.
bool GAME_CP_ItemIsUseable(const objDef_t *od)
void CHAR_ParseData(dbuffer *msg, linkedList_t **updateCharacters)
Parses the character data which was send by G_MatchSendResults using G_SendCharacterData.
Header file for character (soldier, alien) related campaign functions.
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id).
Header for Geoscape management.
#define GEO_GetMissionAircraft()
#define GEO_GetSelectedMission()
void MIS_InitResultScreen(const missionResults_t *results)
Updates mission result menu text with appropriate values.
header file UI callbacks for missions.
Campaign mission triggers.
void CP_MissionEnd(const campaign_t *campaign, mission_t *mission, const battleParam_t *battleParameters, bool won)
Closing actions after fighting a battle.
Campaign missions headers.
rank_t * CL_GetRankByIdx(const int index)
Returns a rank at an index.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
void SAV_InitCallbacks(void)
Register UI callbacks for the savegame-subsystem.
void SAV_ShutdownCallbacks(void)
UnregisterUI callbacks for the savegame-subsystem.
Header file for Savegame UI callbacks.
void CP_CleanTempInventory(base_t *base)
Clears all containers that are temp containers (see script definition).
Team management for the campaign gametype headers.
#define ngettext(x, y, cnt)
void INVSH_InitCSI(const csi_t *import)
Initializes client server shared data pointer. This works because the client and the server are both ...
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
QGL_EXTERN GLsizei const GLvoid * data
#define Q_strvalid(string)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
An aircraft with all it's data.
struct technology_s * tech
A base with all it's data.
struct mission_s * mission
int negativeCreditsUntilLost
Describes a character with all its attributes.
int kills[KILLED_NUM_TYPES]
Structure with mission info needed to create results summary at menu won.
int civiliansKilledFriendlyFire
const struct mission_s * mission
int ownKilledFriendlyFire
Defines all attributes of objects used in the inventory.
Describes a rank that a recruit can gain.
This is the technology parsed from research.ufo.