24 #include "../../cl_shared.h"
25 #include "../../input/cl_keys.h"
26 #include "../../ui/ui_dataids.h"
34 #include "../../battlescape/cl_hud.h"
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");
110 cgi->UI_ExecuteConfunc(
"ui_add_campaign %s \"%s\" \"%s\"", c->
id, c->
name, c->
defaultCampaign ?
"default" :
"");
114 #define MAXCAMPAIGNTEXT 4096
121 const char* racetype;
134 cgi->Com_Printf(
"Invalid Campaign id: %s\n", cgi->
Cmd_Argv(1));
139 racetype =
_(
"Human");
141 racetype =
_(
"Aliens");
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];
223 else if (
i < MAX_TEAMS)
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;
268 results->
ownKilled += ownKilled - numKilled[currentTeam][currentTeam] - numKilled[
TEAM_CIVILIAN][currentTeam];
291 results->
ownKilled = ownKilled - numKilled[currentTeam][currentTeam] - numKilled[
TEAM_CIVILIAN][currentTeam];
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);
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);
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);
488 cgi->
Cvar_Set(
"mn_chrrank_img",
"");
490 cgi->
Cvar_Set(
"mn_chrrankprefix",
"");
503 assert(aircraft->
tech);
518 {
nullptr,
nullptr,
nullptr}
523 #ifndef HARD_LINKED_CGAME
526 cgi->Cmd_TableAddList(cgameCallbacks);
544 cgi->Cmd_TableRemoveList(cgameCallbacks);
550 cgi->SV_Shutdown(
"Quitting server.",
false);
static void GAME_CP_Results_f(void)
void GAME_CP_InitMissionBriefing(const char **title, linkedList_t **victoryConditionsMsgIDs, linkedList_t **missionBriefingMsgIDs)
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
bool CP_OnGeoscape(void)
Returns if we are currently on the Geoscape.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
Header file for character (soldier, alien) related campaign functions.
void AII_CollectingItems(aircraft_t *aircraft, int won)
Collect items from the battlefield.
Describes a rank that a recruit can gain.
static void GAME_CP_CampaignDescription_f(void)
Script function to show description of the selected a campaign.
header file UI callbacks for missions.
void SAV_InitCallbacks(void)
Register UI callbacks for the savegame-subsystem.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
void SAV_ShutdownCallbacks(void)
UnregisterUI callbacks for the savegame-subsystem.
void CP_Shutdown(void)
Campaign closing actions.
const aircraft_t * AIR_GetAircraftSilent(const char *name)
Searches the global array of aircraft types for a given aircraft.
void CP_ResetCampaignData(void)
Will clear most of the parsed singleplayer data.
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
Header file for Savegame UI callbacks.
rank_t * CL_GetRankByIdx(const int index)
Returns a rank at an index.
Defines all attributes of objects used in the inventory.
A base with all it's data.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
technology_t * teamDefTechs[MAX_TEAMDEFS]
Header file for menu related console command callbacks.
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.
#define Q_strvalid(string)
void CP_StartSelectedMission(void)
Starts a selected mission.
struct technology_s * tech
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
void CP_CampaignInit(campaign_t *campaign, bool load)
Called at new game and load game.
#define ngettext(x, y, cnt)
struct mission_s * mission
Campaign mission triggers.
bool AL_AddAlienTypeToAircraftCargo(aircraft_t *aircraft, const teamDef_t *teamDef, int amount, bool dead)
Adds an alientype to an aircraft cargo.
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)
battleParam_t battleParameters
void CP_CampaignRun(campaign_t *campaign, float secondsSinceLastFrame)
Called every frame when we are in geoscape view.
int kills[KILLED_NUM_TYPES]
Campaign missions headers.
void CP_ParseCampaignData(void)
Read the data for campaigns.
void CHAR_ParseData(dbuffer *msg, linkedList_t **updateCharacters)
Parses the character data which was send by G_MatchSendResults using G_SendCharacterData.
This is the technology parsed from research.ufo.
campaign_t * CP_GetCampaign(const char *name)
Returns the campaign pointer from global campaign array.
void GAME_CP_Frame(float secondsSinceLastFrame)
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 CP_MissionEnd(const campaign_t *campaign, mission_t *mission, const battleParam_t *battleParameters, bool won)
Closing actions after fighting a battle.
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...
bool GAME_CP_Spawn(linkedList_t **chrList)
Header for Geoscape management.
const char * GAME_CP_GetTeamDef(void)
equipDef_t * GAME_CP_GetEquipmentDefinition(void)
int ownKilledFriendlyFire
static void GAME_CP_GetCampaigns_f(void)
Fill the campaign list with available campaigns.
void GAME_CP_InitStartup(void)
#define GEO_GetMissionAircraft()
bool GAME_CP_TeamIsKnown(const teamDef_t *teamDef)
Checks whether the team is known at this stage already.
void GAME_CP_CharacterCvars(const character_t *chr)
linkedList_t * updateCharacters
int civiliansKilledFriendlyFire
const char * GAME_CP_GetItemModel(const char *string)
#define B_GetBuildingAt(base, x, y)
bool GAME_CP_ItemIsUseable(const objDef_t *od)
static const char * CP_ToDifficultyName(const int difficulty)
Translate the difficulty int to a translated string.
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id)
void CP_InitStartup(void)
void GAME_CP_Shutdown(void)
#define GEO_GetSelectedMission()
missionResults_t missionResults
#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 ...
static void GAME_CP_Start_f(void)
Starts a new single-player game.
Header file for single player campaign control.
const char *IMPORT * CL_Translate(const char *t)
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
void GAME_CP_DrawBaseLayoutTooltip(int baseIdx, int x, int y)
Draws basename as tooltip for baselayout widget.
GLsizei const GLvoid * data
void CP_CleanTempInventory(base_t *base)
Clears all containers that are temp containers (see script definition).
void INVSH_InitCSI(const csi_t *import)
Initializes client server shared data pointer. This works because the client and the server are both ...
An aircraft with all it's data.
Team management for the campaign gametype headers.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
missionResultFunction_t missionResultCallback
const cgame_import_t * cgi
int negativeCreditsUntilLost
#define B_IsTileBlocked(base, x, y)
Structure with mission info needed to create results summary at menu won.
const char *IMPORT * Cmd_Argv(int n)
campaign_t campaigns[MAX_CAMPAIGNS]
cvar_t *IMPORT * Cvar_ForceSet(const char *varName, const char *value)
static char campaignDesc[MAXCAMPAIGNTEXT]
static const cmdList_t cgameCallbacks[]
character_t * GAME_CP_GetSelectedChr(void)
Returns the currently selected character.
const struct mission_s * mission
const char *IMPORT * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
void MIS_InitResultScreen(const missionResults_t *results)
Updates mission result menu text with appropriate values.
Describes a character with all its attributes.