55typedef enum missionDetectionStatus_s {
81 cgi->Cvar_SetValue(
"ai_singleplayeraliens", battleParameters->
aliens);
82 cgi->Cvar_SetValue(
"ai_numcivilians", battleParameters->
civilians);
83 cgi->Cvar_Set(
"ai_civilianteam",
"%s", battleParameters->
civTeam);
88 cgi->csi->numAlienTeams = 0;
92 cgi->csi->numAlienTeams++;
115 cgi->Cvar_Set(
"sv_mapzone",
"%s", battleParameters->
zoneType);
118 cgi->Cmd_ExecuteString(
"game_quicksave");
121 cgi->Cvar_Set(
"sv_hurtaliens",
"1");
123 cgi->Cvar_Set(
"sv_hurtaliens",
"0");
125 cgi->Cvar_Set(
"r_overridematerial",
"");
132 cgi->Com_Printf(
"Baseattack map on non-baseattack mission! (id=%s, category=%d)\n", mission->
id, mission->
category);
135 cgi->Com_Error(
ERR_DROP,
"Baseattack map without base!");
139 B_AssembleMap(maps,
sizeof(maps), coords,
sizeof(coords), base);
140 cgi->Cvar_Set(
"r_overridematerial",
"baseattack");
141 cgi->Cbuf_AddText(
"map %s \"%s\" \"%s\"\n", (
GEO_IsNight(base->
pos) ?
"night" :
"day"), maps, coords);
147 assert(
ccs.curCampaign);
148 cgi->Cvar_Delete(
"g_difficulty");
149 cgi->Cvar_SetValue(
"g_difficulty",
ccs.curCampaign->difficulty);
151 const char* param = battleParameters->
param ? battleParameters->
param : (
const char*)
cgi->LIST_GetRandom(mission->
mapDef->
params);
152 cgi->Cbuf_AddText(
"map %s %s %s\n", (
GEO_IsNight(mission->
pos) ?
"night" :
"day"),
179 const int MAX_AVAILABLE_GROUPS = 4;
181 int numAvailableGroup = 0;
184 for (
int i = 0;
i <
ccs.numAlienCategories;
i++) {
201 if (!numAvailableGroup) {
203 cgi->Com_Error(
ERR_DROP,
"CP_SetAlienTeamByInterest: no available alien team for mission '%s': interest = %i -- category = %i",
208 int pick = rand() % numAvailableGroup;
245 int i, availableEquipDef = 0;
250 for (
i = 0;
i <
cgi->csi->numEDs;
i++) {
256 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CP_SetAlienEquipmentByInterest: %i available equipment packs for mission %s\n", availableEquipDef, mission->
id);
258 if (!availableEquipDef)
259 cgi->Com_Error(
ERR_DROP,
"CP_SetAlienEquipmentByInterest: no available alien equipment for mission '%s'", mission->
id);
262 const int randomNum = rand() % availableEquipDef;
264 availableEquipDef = 0;
265 for (
i = 0;
i <
cgi->csi->numEDs;
i++) {
268 if (availableEquipDef == randomNum) {
294 const int diff = max - min;
296 numAliens = min + rand() % (diff + 1);
297 numAliens = std::max(1, numAliens);
302 battleParam->
aliens = numAliens;
349 param->
param =
nullptr;
352 cgi->Cvar_Set(
"rm_ufo",
"");
353 cgi->Cvar_Set(
"rm_drop",
"");
354 cgi->Cvar_Set(
"rm_crashed",
"");
358 param->
zoneType =
cgi->csi->terrainDefs.getTerrainName(color);
361 cgi->Cvar_Set(
"r_weather",
"0");
363 cgi->Cvar_Set(
"r_weather",
"%s",
cgi->csi->terrainDefs.getWeather(color));
368 const char* shortUFOType;
372 shortUFOType =
cgi->Com_UFOCrashedTypeToShortName(ufo->
getUfoType());
381 shortUFOType =
cgi->Com_UFOTypeToShortName(ufo->
getUfoType());
385 Com_sprintf(mission->
onwin,
sizeof(mission->
onwin),
"ui_push popup_uforecovery \"%s\" \"%s\" \"%s\" \"%s\" %3.2f",
390 cgi->Cvar_Set(
"rm_ufo",
"%s",
cgi->Com_GetRandomMapAssemblyNameForCraft(shortUFOType));
397 cgi->Cvar_Set(
"rm_crashed",
"%s",
cgi->Com_GetRandomMapAssemblyNameForCrashedCraft(mission->
data.
aircraft->
id));
400 cgi->Cvar_Set(
"rm_drop",
"%s",
cgi->Com_GetRandomMapAssemblyNameForCraft(aircraft->
id));
421 if (
Q_streq(mission->id, missionId))
438 cgi->Com_Printf(
"CP_GetMissionByID: missionId was nullptr!\n");
440 cgi->Com_Printf(
"CP_GetMissionByID: Could not find mission %s\n", missionId);
451 if (mission->idx ==
id)
479 switch (mission->
stage) {
484 return _(
"Alien terror");
489 return _(
"Base attack");
492 return va(
_(
"Alien base in %s"),
_(nation->
name));
494 return _(
"Alien base");
511 return va(
_(
"Alien activity in %s"),
_(nation->
name));
513 return _(
"Alien activity");
521static const char* CP_MissionStageToName (
const missionStage_t stage)
525 return "Not active yet";
527 return "UFO coming from orbit";
529 return "Aerial recon underway";
531 return "Going to mission position";
533 return "Ground recon mission underway";
535 return "Terror mission underway";
537 return "Building base";
539 return "Attacking a base";
541 return "Subverting a government";
545 return "Spreading XVI";
547 return "Intercepting or attacking installation";
549 return "Leaving earth";
551 return "Base visible";
555 return "Mission over";
569 int counterVisibleMission = 0;
572 if (mission->onGeoscape) {
573 counterVisibleMission++;
577 return counterVisibleMission;
596 return "geoscape/ufocrash";
599 return "geoscape/icon_story";
604 return "geoscape/icon_rescue";
607 return "geoscape/icon_build_alien_base";
610 return "geoscape/alienbase";
612 return "geoscape/icon_recon";
614 return "geoscape/icon_xvi";
616 return "geoscape/icon_harvest";
618 return "geoscape/icon_ufocarrier";
620 return "geoscape/icon_terror";
623 return "geoscape/base2";
631 cgi->Com_Error(
ERR_DROP,
"Unknown mission interest category");
654 switch (mission->
stage) {
702 switch (mission->
stage) {
751 if (mission->
ufo && ((fabs(mission->
ufo->
pos[0] - mission->
pos[0]) > 1.0f) || (fabs(mission->
ufo->
pos[1] - mission->
pos[1]) > 1.0f))) {
752 cgi->Com_Printf(
"Error: mission (stage: %s) spawned is not at the same location as UFO\n", CP_MissionStageToName(mission->
stage));
776 bool newDetection =
false;
786 assert(!mission->ufo || !mission->ufo->detected);
788 if (
frand() <= missionDetectionProbability) {
830 assert(mission->
ufo);
847 if (removedMission->ufo && (removedMission->ufo > mission->
ufo))
848 removedMission->ufo--;
852 mission->
ufo =
nullptr;
878 if (mission ==
ccs.battleParameters.mission)
879 ccs.battleParameters.mission =
nullptr;
884 if (!
cgi->LIST_Remove(&
ccs.missions, mission))
885 cgi->Com_Error(
ERR_DROP,
"CP_MissionRemove: Could not find mission '%s' to remove.\n", mission->
id);
925 if (base == mission->data.base) {
941 if (mission->data.installation == installation)
967 if (!
cgi->LIST_IsEmpty(md->
ufos))
969 }
else if (!
cgi->LIST_IsEmpty(md->
ufos)) {
976 ufoID =
cgi->Com_UFOCrashedTypeToShortName(
type);
978 ufoID =
cgi->Com_UFOTypeToShortName(
type);
980 if (!
cgi->LIST_ContainsString(md->
ufos, ufoID))
1001 int countMinimal = 0;
1002 int minMapDefAppearance = -1;
1009 if (minMapDefAppearance < 0 || md->timesAlreadyUsed < minMapDefAppearance) {
1019 if (countMinimal == 0) {
1023 mission->
mapDef =
cgi->Com_GetMapDefinitionByID(
"rescue");
1025 cgi->Com_Error(
ERR_DROP,
"Could not find mapdef: rescue");
1031 mission->
mapDef =
cgi->Com_GetMapDefinitionByID(
"ufocrash");
1033 cgi->Com_Error(
ERR_DROP,
"Could not find mapdef: ufocrash");
1038 cgi->Com_Printf(
"CP_ChooseMap: Could not find map with required conditions:\n");
1039 cgi->Com_Printf(
" ufo: %s -- pos: ", mission->
ufo ?
cgi->Com_UFOTypeToShortName(mission->
ufo->
getUfoType()) :
"none");
1043 cgi->Com_Printf(
"(%.02f, %.02f)\n", pos[0], pos[1]);
1045 cgi->Com_Printf(
"none\n");
1050 int randomNum = rand() % countMinimal;
1061 if (randomNum == 0) {
1072 cgi->Com_Printf(
"Selected map '%s' (among %i possible maps)\n", mission->
mapDef->
id, countMinimal);
1074 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Selected map '%s' (among %i possible maps)\n", mission->
mapDef->
id, countMinimal);
1086 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Ending mission category %i, stage %i (time: %i day, %i sec)\n",
1087 mission->
category, mission->
stage,
ccs.date.getDateAsDays(),
ccs.date.getTimeAsSeconds());
1131 cgi->Com_Printf(
"CP_MissionStageEnd: Invalid type of mission (%i), remove mission '%s'\n", mission->
category, mission->
id);
1193 cgi->Com_Printf(
"CP_MissionIsOver: Invalid type of mission (%i), remove mission\n", mission->
category);
1254 int numberOfSoldiers = 0;
1269 won ?
ccs.campaignStats.missionsWon++ :
ccs.campaignStats.missionsLost++;
1276 cgi->LIST_Delete(&
ccs.updateCharacters);
1286 if (employee->isHiredInBase(base) && (employee->chr.HP <= 0))
1289 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CP_MissionEnd - num %i\n", numberOfSoldiers);
1309 switch (mission->
stage) {
1357 const DateTime minCrashDelay(7, 0);
1358 const DateTime maxCrashDelay(14, 0);
1363 cgi->Com_Error(
ERR_DROP,
"CP_SpawnCrashSiteMission: No mission correspond to ufo '%s'", ufo->
id);
1368 mission->
mapDef =
nullptr;
1370 cgi->Com_Printf(
"CP_SpawnCrashSiteMission: No map found, remove mission.\n");
1405 if (!pilotSurvived) {
1427 if (aircraft->
homebase->aircraftCurrent == aircraft)
1440 cgi->Com_Printf(
"CP_SpawnRescueMission: UFO was also destroyed.\n");
1446 if (survivors == 0) {
1454 cgi->Com_Error(
ERR_DROP,
"CP_SpawnRescueMission: mission could not be created");
1457 mission->
mapDef =
nullptr;
1459 cgi->Com_Printf(
"CP_SpawnRescueMission: Cannot set mapDef for mission %s, removing.\n", mission->
id);
1468 oldMission->
ufo =
nullptr;
1515 cgi->Com_Error(
ERR_DROP,
"MIS_IsSpawnedFromGround: Wrong mission category %i", mission->
category);
1519 const float XVI_PARAM = 10.0f;
1520 float groundProbability;
1521 float randNumber =
frand();
1525 groundProbability = std::max(0.1f, groundProbability);
1527 return randNumber < groundProbability;
1542 mission->
ufo =
nullptr;
1552 if (!mission->
ufo) {
1553 cgi->Com_Printf(
"CP_MissionBegin: Could not add UFO '%s', remove mission %s\n",
1554 cgi->Com_UFOTypeToShortName(ufoType), mission->
id);
1562 mission->
idx = ++
ccs.campaignStats.missions;
1617 cgi->Com_Error(
ERR_DROP,
"CP_MissionChooseUFO: Wrong mission category %i", mission->
category);
1620 const short ufoIdsNum =
cgi->Com_GetUFOIdsNum();
1621 if (numTypes > ufoIdsNum)
1622 cgi->Com_Error(
ERR_DROP,
"CP_MissionChooseUFO: Too many values UFOs (%i/%i)", numTypes, ufoIdsNum);
1628 const float randNumber =
frand();
1631 int idx = (
int) (numTypes * randNumber);
1632 if (idx >= numTypes) {
1636 return ufoTypes[idx];
1654 if (
cgi->LIST_IsEmpty(
ccs.missions))
1677 const DateTime minNextSpawningDate(0, 0);
1678 const DateTime maxNextSpawningDate(3, 0);
1691 mission.
ufo =
nullptr;
1697 mission.
idx = ++
ccs.campaignStats.missions;
1720 int i, randomNumber;
1723 sum +=
ccs.interest[
i];
1725 randomNumber = (
int) (
frand() * (
float) sum);
1727 for (
i = 0; randomNumber >= 0;
i++)
1728 randomNumber -=
ccs.interest[
i];
1741 ccs.lastMissionSpawnedDelay++;
1745 spawn_delay = (
int) (spawn_delay / 3);
1748 if (
ccs.lastMissionSpawnedDelay > spawn_delay) {
1749 float nonOccurrence;
1758 nonOccurrence =
ccs.curCampaign->ufoReductionRate;
1769 cgi->Com_DPrintf(
DEBUG_CLIENT,
"interest = %d, new missions = %d\n",
ccs.overallInterest, newMissionNum);
1770 for (
int i = 0;
i < newMissionNum;
i++) {
1771 if (
frand() > nonOccurrence) {
1777 ccs.lastMissionSpawnedDelay -= spawn_delay;
1790 ccs.missionSpawnCallback();
1804static void MIS_SpawnNewMissions_f (
void)
1809 if (
cgi->Cmd_Argc() < 2) {
1810 cgi->Com_Printf(
"Usage: %s <category> [<type>]\n",
cgi->Cmd_Argv(0));
1813 cgi->Com_Printf(
"...%i: %s", category, INT_InterestCategoryToName(category));
1815 cgi->Com_Printf(
" <0:Random, 1:Aerial, 2:Ground>");
1817 cgi->Com_Printf(
" <0:Subverse Government, 1:Build Base>");
1819 cgi->Com_Printf(
" <0:Intercept aircraft, 1:Attack installation>");
1820 cgi->Com_Printf(
"\n");
1825 if (
cgi->Cmd_Argc() >= 3)
1826 type = atoi(
cgi->Cmd_Argv(2));
1840 cgi->Com_Printf(
"CP_BuildBaseSetUpBase: could not create base\n");
1849 cgi->Com_Printf(
"No base yet\n");
1855 cgi->Com_Printf(
"No aircraft in base\n");
1864 cgi->Com_Printf(
"CP_SpawnNewMissions_f: Could not add mission, abort\n");
1874 if (
type == 1 && mission->
ufo)
1898 cgi->Com_Printf(
"Type is not implemented for this category.\n");
1901 cgi->Com_Printf(
"Spawned mission with id '%s'\n", mission->
id);
1907static void MIS_MissionSetMap_f (
void)
1911 if (
cgi->Cmd_Argc() < 3) {
1912 cgi->Com_Printf(
"Usage: %s <missionid> <mapdef>\n",
cgi->Cmd_Argv(0));
1916 mapDef =
cgi->Com_GetMapDefinitionByID(
cgi->Cmd_Argv(2));
1917 if (mapDef ==
nullptr) {
1918 cgi->Com_Printf(
"Could not find mapdef for %s\n",
cgi->Cmd_Argv(2));
1921 mission->
mapDef = mapDef;
1928static void MIS_MissionList_f (
void)
1930 bool noMission =
true;
1933 cgi->Com_Printf(
"mission: '%s'\n", mission->
id);
1934 cgi->Com_Printf(
"...category %i. '%s' -- stage %i. '%s'\n", mission->
category,
1935 INT_InterestCategoryToName(mission->
category), mission->
stage, CP_MissionStageToName(mission->
stage));
1936 cgi->Com_Printf(
"...mapDef: '%s'\n", mission->
mapDef ? mission->
mapDef->
id :
"No mapDef defined");
1937 cgi->Com_Printf(
"...start (day = %i, sec = %i), ends (day = %i, sec = %i)\n",
1939 cgi->Com_Printf(
"...pos (%.02f, %.02f)%s -- mission %son Geoscape\n", mission->
pos[0], mission->
pos[1], mission->
posAssigned ?
"(assigned Pos)" :
"", mission->
onGeoscape ?
"" :
"not ");
1941 cgi->Com_Printf(
"...UFO: %s (%i/%i)\n", mission->
ufo->
id, (
int) (mission->
ufo -
ccs.ufos),
ccs.numUFOs - 1);
1943 cgi->Com_Printf(
"...UFO: no UFO\n");
1947 cgi->Com_Printf(
"No mission currently in game.\n");
1954static void MIS_DeleteMissions_f (
void)
1960 if (
ccs.numUFOs != 0) {
1961 cgi->Com_Printf(
"CP_DeleteMissions_f: Error, there are still %i UFO in game afer removing all missions. Force removal.\n",
ccs.numUFOs);
1971static void MIS_DeleteMission_f (
void)
1975 if (
cgi->Cmd_Argc() < 2) {
1976 cgi->Com_Printf(
"Usage: %s <missionid>\n",
cgi->Cmd_Argv(0));
2076 bool defaultAssigned =
false;
2084 if (mission.
idx <= 0) {
2085 cgi->Com_Printf(
"mission has invalid or no index\n");
2093 cgi->Com_Printf(
"Warning: mapdef \"%s\" for mission \"%s\" doesn't exist. Removing mission!\n",
name, mission.
id);
2097 mission.
mapDef =
nullptr;
2101 cgi->Com_Printf(
"Invalid mission category '%s'\n", categoryId);
2106 cgi->Com_Printf(
"Invalid mission stage '%s'\n", stageId);
2126 cgi->Com_Printf(
"......warning: base %i (%s) is supposedly under attack but base status doesn't match!\n", base->
idx, base->
name);
2129 cgi->Com_Printf(
"......warning: Missing BaseIndex\n");
2141 cgi->Com_Printf(
"Error while loading rescue mission (missionidx %i, aircraftidx: %i, category: %i, stage: %i)\n",
2161 if (previousMission->category != mission.
category)
2163 if (previousMission->data.alienBase == alienBase) {
2164 duplicate = previousMission;
2169 cgi->Com_Printf(
"Error loading Alien Base mission (missionidx %i, baseidx: %i, category: %i, stage: %i): is the same as mission (missionidx %i, baseidx: %i, category: %i, stage: %i)\n",
2178 cgi->Com_Printf(
"Error loading Alien Base mission (missionidx %i, baseidx: %i, category: %i, stage: %i): no such base\n",
2200 if (mission.
pos[0] > 0.001 || mission.
pos[1] > 0.001)
2201 defaultAssigned =
true;
2214 {
"debug_missionsetmap", MIS_MissionSetMap_f,
"Changes the map for a spawned mission"},
2215 {
"debug_missionadd", MIS_SpawnNewMissions_f,
"Add a new mission"},
2216 {
"debug_missiondeleteall", MIS_DeleteMissions_f,
"Remove all missions from global array"},
2217 {
"debug_missiondelete", MIS_DeleteMission_f,
"Remove mission by a given name"},
2218 {
"debug_missionlist", MIS_MissionList_f,
"Debug function to show all missions"},
2220 {
nullptr,
nullptr,
nullptr}
2237 cgi->LIST_Delete(&
ccs.missions);
DateTime class definition.
Shared game type headers.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
Share stuff between the different cgame implementations.
#define MapDef_ForeachSingleplayerCampaign(var)
Class describing a point of time.
int getTimeAsSeconds() const
Return the time part of the DateTime as seconds.
int getDateAsDays() const
Return the date part of the DateTime as days.
void AIR_AircraftReturnToBase(aircraft_t *aircraft)
Calculates the way back to homebase for given aircraft and returns it.
Employee * AIR_GetPilot(const aircraft_t *aircraft)
Get pilot of an aircraft.
void AIR_AircraftsNotifyUFORemoved(const aircraft_t *const ufo, bool destroyed)
Notify that a UFO has been removed.
void AIR_AircraftsNotifyMissionRemoved(const mission_t *const mission)
Notify aircraft that a mission has been removed.
bool AIR_PilotSurvivedCrash(const aircraft_t *aircraft)
Determine if an aircraft's pilot survived a crash, based on his piloting skill (and a bit of randomne...
void AIR_DestroyAircraft(aircraft_t *aircraft, bool killPilot)
Removes an aircraft from its base and the game.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
const aircraft_t * AIR_IsEmployeeInAircraft(const Employee *employee, const aircraft_t *aircraft)
Tells you if an employee is assigned to an aircraft.
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
int AIRFIGHT_ChooseWeapon(const aircraftSlot_t *slot, int maxSlot, const vec2_t pos, const vec2_t targetPos)
Choose the weapon an attacking aircraft will use to fire on a target.
void AIRFIGHT_RemoveProjectileAimingAircraft(const aircraft_t *aircraft)
Set all projectile aiming a given aircraft to an idle destination.
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT
void INT_ChangeIndividualInterest(float interestFactor, interestCategory_t category)
Change individual interest value.
@ INTERESTCATEGORY_BASE_ATTACK
@ INTERESTCATEGORY_INTERCEPTBOMBING
@ INTERESTCATEGORY_ALIENBASE
@ INTERESTCATEGORY_BUILDING
@ INTERESTCATEGORY_SUBVERT
@ INTERESTCATEGORY_SUPPLY
@ INTERESTCATEGORY_UFOCARRIER
@ INTERESTCATEGORY_TERROR_ATTACK
@ INTERESTCATEGORY_INTERCEPT
@ INTERESTCATEGORY_RESCUE
@ INTERESTCATEGORY_HARVEST
int AB_GetAlienBaseNumber(void)
Check number of alien bases.
void AB_SetAlienBasePosition(vec2_t pos)
Set new base position.
void CP_SpawnAlienBaseMission(alienBase_t *alienBase)
Spawn a new alien base mission after it has been discovered.
alienBase_t * AB_BuildBase(const vec2_t pos)
Build a new alien base.
alienBase_t * AB_GetByIDX(int baseIDX)
Get Alien Base per Idx.
void B_DumpAircraftToHomeBase(aircraft_t *aircraft)
Will unload all cargo to the homebase.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
bool B_AssembleMap(char *maps, size_t mapsLength, char *coords, size_t coordsLength, const base_t *base)
Perform the base assembling in case of an alien attack.
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_IsUnderAttack(base)
memPool_t * cp_campaignPool
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
void CP_CheckLostCondition(const campaign_t *campaign)
Checks whether the player has lost the campaign.
Header file for single player campaign control.
const cgame_import_t * cgi
#define DELAY_BETWEEN_MISSION_SPAWNING
The length of a single mission spawn cycle.
#define FINAL_OVERALL_INTEREST
#define EARLY_UFO_RUSH_INTEREST
Determines the early game period during which DELAY_BETWEEN_MISSION_SPAWNING is halved.
void CAP_AddCurrent(base_t *base, baseCapacities_t capacity, int value)
Changes the current (used) capacity on a base.
baseCapacities_t
All possible capacities in base.
void CHAR_UpdateData(linkedList_t *updateCharacters)
Transforms the battlescape values to the character.
void CHAR_UpdateStats(const base_t *base, const aircraft_t *aircraft)
Update employees stats after mission.
Header file for character (soldier, alien) related campaign functions.
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
#define E_Foreach(employeeType, var)
bool GEO_IsNight(const vec2_t pos)
Check whether given position is Day or Night.
bool GEO_PositionFitsTCPNTypes(const vec2_t pos, const linkedList_t *terrainTypes, const linkedList_t *cultureTypes, const linkedList_t *populationTypes, const linkedList_t *nations)
Checks for a given location, if it fulfills all criteria given via parameters (terrain,...
nation_t * GEO_GetNation(const vec2_t pos)
Translate nation map color to nation.
void GEO_NotifyUFORemoved(const aircraft_t *ufo, bool destroyed)
Notify that a UFO has been removed.
const byte * GEO_GetColor(const vec2_t pos, mapType_t type, bool *coast)
Returns the color value from geoscape of a certain mask (terrain, culture or population) at a given p...
void GEO_UpdateGeoscapeDock(void)
Will add missions and UFOs to the geoscape dock panel.
int GEO_GetCivilianNumberByPosition(const vec2_t pos)
Get number of civilian on a map at given position.
void GEO_NotifyMissionRemoved(const mission_t *mission)
Notify that a mission has been removed.
Header for Geoscape management.
#define GEO_GetMissionAircraft()
#define GEO_IsAircraftSelected(aircraft)
#define GEO_SetSelectedAircraft(aircraft)
#define MapIsWater(color)
installation_t * INS_GetByIDX(int idx)
Get installation by it's index.
uiMessageListNodeMessage_t * MS_AddNewMessage(const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup, bool playSound)
Adds a new message to message stack.
char cp_messageBuffer[MAX_MESSAGE_TEXT]
void CP_BaseAttackMissionIsSuccess(mission_t *mission)
Base attack mission is over and is a success (from an alien point of view): change interest values.
void CP_BaseAttackMissionOnSpawn(void)
Run when the mission is spawned.
void CP_BaseAttackMissionLeave(mission_t *mission)
Base attack mission ends: UFO leave earth.
void CP_BaseAttackMissionDestroyBase(mission_t *mission)
Base attack mission ends: UFO leave earth.
void CP_BaseAttackMissionNextStage(mission_t *mission)
Determine what action should be performed when a Base Attack mission stage ends.
void CP_BaseAttackMissionIsFailure(mission_t *mission)
Base attack mission is over and is a failure (from an alien point of view): change interest values.
Campaign mission headers.
void CP_BuildBaseMissionBaseDestroyed(mission_t *mission)
Alien base has been destroyed: change interest values.
void CP_BuildBaseMissionNextStage(const campaign_t *campaign, mission_t *mission)
Determine what action should be performed when a Build Base mission stage ends.
void CP_BuildBaseMissionOnSpawn(void)
Run when the mission is spawned.
void CP_BuildBaseMissionIsSuccess(mission_t *mission)
Build Base mission is over and is a success (from an alien point of view): change interest values.
void CP_BuildBaseMissionIsFailure(mission_t *mission)
Build Base mission is over and is a failure (from an alien point of view): change interest values.
bool CP_BasemissionIsSubvertingGovernmentMission(const mission_t *mission)
void MIS_InitCallbacks(void)
Init UI callbacks for missions-subsystem.
void MIS_ShutdownCallbacks(void)
Close UI callbacks for missions-subsystem.
header file UI callbacks for missions.
void CP_HarvestMissionNextStage(mission_t *mission)
Determine what action should be performed when a Harvesting mission stage ends.
void CP_HarvestMissionIsFailure(mission_t *mission)
Harvesting mission is over and is a failure: change interest values.
Campaign mission headers.
void CP_InterceptMissionIsFailure(mission_t *mission)
Intercept mission is over and is a failure: change interest values.
void CP_InterceptNextStage(mission_t *mission)
Determine what action should be performed when a Intercept mission stage ends.
void CP_InterceptMissionIsSuccess(mission_t *mission)
Intercept mission is over and is a success: change interest values.
void CP_InterceptGoToInstallation(mission_t *mission)
Set Intercept mission: UFO chooses an installation an flies to it.
void CP_InterceptAircraftMissionSet(mission_t *mission)
Set Intercept mission: UFO looks for new aircraft target.
void CP_InterceptMissionLeave(mission_t *mission, bool destroyed)
Intercept mission ends: UFO leave earth.
Campaign mission headers.
void CP_ReconMissionAerial(mission_t *mission)
Set aerial mission.
void CP_ReconMissionNextStage(mission_t *mission)
Determine what action should be performed when a Recon mission stage ends.
void CP_ReconMissionIsFailure(mission_t *mission)
Recon mission is over and is a failure: change interest values.
void CP_ReconMissionGroundGo(mission_t *mission)
Set ground mission, and go to ground mission pos.
Campaign mission headers.
void CP_RescueNextStage(mission_t *mission)
Determine what action should be performed when a Rescue mission stage ends.
void CP_EndRescueMission(mission_t *mission, aircraft_t *aircraft, bool won)
Actions to be done when rescue mission finished/expired.
Campaign mission headers.
void CP_SupplyMissionIsFailure(mission_t *mission)
Supply mission is over and is a failure (from an alien point of view): change interest values.
void CP_SupplyMissionNextStage(mission_t *mission)
Determine what action should be performed when a Supply mission stage ends.
void CP_SupplyMissionIsSuccess(mission_t *mission)
Supply mission is over and is a success (from an alien point of view): change interest values.
Campaign mission headers.
void CP_TerrorMissionIsFailure(mission_t *mission)
Terror attack mission is over and is a failure: change interest values.
void CP_TerrorMissionOnSpawn(void)
Run when the mission is spawned.
void CP_TerrorMissionNextStage(mission_t *mission)
Determine what action should be performed when a Terror attack mission stage ends.
Campaign mission headers.
void CP_ExecuteMissionTrigger(const mission_t *mission, bool won)
Executes console commands after a mission.
Campaign mission triggers.
void CP_UFOCarrierNextStage(mission_t *mission)
Determine what action should be performed when a UFOCarriering mission stage ends.
Campaign mission headers.
void CP_XVIMissionIsFailure(mission_t *mission)
XVI Spreading mission is over and is a failure: change interest values.
void CP_XVIMissionNextStage(mission_t *mission)
Determine what action should be performed when a XVI Spreading mission stage ends.
void CP_XVIMissionIsSuccess(mission_t *mission)
XVI Spreading mission is over and is a success: change interest values.
bool MIS_SaveXML(xmlNode_t *parent)
Save callback for savegames in XML Format.
void MIS_InitStartup(void)
Init actions for missions-subsystem.
void CP_InitializeSpawningDelay(void)
Initialize spawning delay.
void BATTLE_Start(mission_t *mission, const battleParam_t *battleParameters)
Select the mission type and start the map from mission definition.
static void CP_SetAlienTeamByInterest(mission_t *mission, battleParam_t *battleParameters)
Sets the alien races used for a mission.
static bool CP_IsAlienTeamForCategory(const alienTeamCategory_t *cat, const interestCategory_t missionCat)
Check if an alien team category may be used for a mission category.
static const float MAX_CRASHEDUFO_CONDITION
void CP_MissionNotifyBaseDestroyed(const base_t *base)
Notify that a base has been removed.
static void CP_SetAlienEquipmentByInterest(const mission_t *mission, linkedList_t *equipPack, battleParam_t *battleParameters)
Set alien equipment for a mission (depends on the interest values).
int MIS_GetIdx(const mission_t *mis)
Find idx corresponding to mission.
static bool MIS_IsSpawnedFromGround(const mission_t *mission)
Decides if the mission should be spawned from the ground (without UFO).
void CP_CreateBattleParameters(mission_t *mission, battleParam_t *param, const aircraft_t *aircraft)
Create parameters needed for battle. This is the data that is used for starting the tactical part of ...
int CP_CountMissionOnGeoscape(void)
Count the number of mission active and displayed on geoscape.
static interestCategory_t CP_SelectNewMissionType(void)
Select new mission type.
void CP_MissionNotifyInstallationDestroyed(const installation_t *installation)
Notify missions that an installation has been destroyed.
void MIS_Shutdown(void)
Closing actions for missions-subsystem.
bool CP_CheckMissionLimitedInTime(const mission_t *mission)
Check if mission should end because of limited time.
static void MIS_CreateAlienTeam(mission_t *mission, battleParam_t *battleParam)
Set number of aliens in mission.
mission_t * CP_GetMissionByID(const char *missionId)
Get a mission in ccs.missions by Id.
bool MIS_LoadXML(xmlNode_t *parent)
Load callback for savegames in XML Format.
static const float MIN_CRASHEDUFO_CONDITION
static void CP_SetMissionName(mission_t *mission)
Set mission name.
static void CP_CreateCivilianTeam(const mission_t *mission, battleParam_t *param)
Create civilian team.
void CP_UpdateMissionVisibleOnGeoscape(void)
Update all mission visible on geoscape (in base radar range).
void BATTLE_SetVars(const battleParam_t *battleParameters)
Set some needed cvars from a battle definition.
void CP_MissionEndActions(mission_t *mission, aircraft_t *aircraft, bool won)
Actions to be done after mission finished.
static const char * CP_MissionGetMessage(const mission_t *mission)
Assembles a message that is send to the gamer once the given mission is added to geoscape.
static messageType_t CP_MissionGetMessageLevel(const mission_t *mission)
Decides which message level to take for the given mission.
void CP_SpawnRescueMission(aircraft_t *aircraft, aircraft_t *ufo)
Spawn a new rescue mission for a crashed (phalanx) aircraft.
bool CP_MissionBegin(mission_t *mission)
mission begins: UFO arrive on earth.
const char * MIS_GetModel(const mission_t *mission)
Get mission model that should be shown on the geoscape.
void CP_UFORemoveFromGeoscape(mission_t *mission, bool destroyed)
Removes (temporarily or permanently) a UFO from geoscape: make it land and call notify functions.
static missionDetectionStatus_t CP_CheckMissionVisibleOnGeoscape(const mission_t *mission)
Check if a mission should be visible on geoscape.
void CP_MissionRemove(mission_t *mission)
Removes a mission from mission global array.
static const cmdList_t debugMissionCmds[]
void CP_MissionIsOverByUFO(aircraft_t *ufocraft)
Mission is finished because Phalanx team ended it.
static bool CP_MapIsSelectable(const mission_t *mission, const mapDef_t *md, const vec2_t pos)
Check if a map may be selected for mission.
mission_t * CP_CreateNewMission(interestCategory_t category, bool beginNow)
Create a new mission of given category.
bool CP_ChooseMap(mission_t *mission, const vec2_t pos)
Choose a map for given mission.
bool CP_CheckNewMissionDetectedOnGeoscape(void)
Check if mission has been detected by radar.
void CP_MissionEnd(const campaign_t *campaign, mission_t *mission, const battleParam_t *battleParameters, bool won)
Closing actions after fighting a battle.
void CP_MissionRemoveFromGeoscape(mission_t *mission)
Removes a mission from geoscape: make it non visible and call notify functions.
void CP_MissionAddToGeoscape(mission_t *mission, bool force)
Add a mission to geoscape: make it visible and stop time.
void CP_MissionIsOver(mission_t *mission)
Mission is finished because Phalanx team won it.
const char * MIS_GetName(const mission_t *mission)
Returns a short translated name for a mission.
void CP_MissionStageEnd(const campaign_t *campaign, mission_t *mission)
Determine what action should be performed when a mission stage ends.
void CP_SpawnCrashSiteMission(aircraft_t *ufo)
Spawn a new crash site after a UFO has been destroyed.
void CP_UFOProceedMission(const campaign_t *campaign, aircraft_t *ufo)
Make UFO proceed with its mission when the fight with another aircraft is over (and UFO survived).
static bool CP_IsAlienEquipmentSelectable(const mission_t *mission, const equipDef_t *equip, linkedList_t *equipPack)
Check if an alien equipment may be used with a mission.
ufoType_t CP_MissionChooseUFO(const mission_t *mission)
Choose UFO type for a given mission category.
bool CP_CheckNextStageDestination(const campaign_t *campaign, aircraft_t *ufocraft)
Check if a stage mission is over when UFO reached destination.
mission_t * CP_GetMissionByIDSilent(const char *missionId)
Get a mission in ccs.missions by Id without error messages.
missionDetectionStatus_t
possible mission detection status
@ MISDET_CANT_BE_DETECTED
void CP_MissionDisableTimeLimit(mission_t *mission)
Disable time limit for given mission.
mission_t * MIS_GetByIdx(int id)
Find mission corresponding to idx.
void CP_SpawnNewMissions(void)
Spawn new missions.
Campaign missions headers.
#define MIS_Foreach(var)
iterates through missions
city_t * CITY_GetByPos(vec2_t pos)
Finds a city by it's geoscape coordinates.
void CP_HandleNationData(float minHappiness, mission_t *mis, const nation_t *affectedNation, const missionResults_t *results, bool won)
Updates each nation's happiness. Should be called at the completion or expiration of every mission....
void RADAR_NotifyUFORemoved(const aircraft_t *ufo, bool destroyed)
Notify to every radar that the specified ufo has been removed from geoscape.
bool RADAR_CheckRadarSensored(const vec2_t pos)
Check if the specified position is within base radar range.
void CP_GameTimeStop(void)
Stop game time speed.
DateTime Date_Random(const DateTime &minFrame, const DateTime &maxFrame)
Return a random relative date which lies between a lower and upper limit.
Campaign geoscape time header.
void UFO_SendToDestination(aircraft_t *ufo, const vec2_t dest)
Make the specified UFO go to destination.
int UFO_GetOneAvailableUFOForMission(const interestCategory_t missionType, bool checkInterest)
Get a suitable UFO for the mission type.
const char * UFO_GetName(const aircraft_t *ufocraft)
Returns name of the UFO if UFO has been researched.
void UFO_DetectNewUFO(aircraft_t *ufocraft)
Perform actions when a new UFO is detected.
aircraft_t * UFO_AddToGeoscape(ufoType_t ufoType, const vec2_t destination, mission_t *mission)
Add a UFO to geoscape.
void UFO_SetRandomDest(aircraft_t *ufocraft)
Give a random destination to the given UFO, and make him to move there.
int UFO_GetAvailableUFOsForMission(const interestCategory_t missionType, ufoType_t *ufoTypes, bool checkInterest)
Fill an array with available UFOs for the mission type.
void UFO_RemoveFromGeoscape(aircraft_t *ufo)
Remove the specified ufo from geoscape.
int CP_GetAverageXVIRate(void)
Return the average XVI rate.
#define MAX_TEAMS_PER_MISSION
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#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 ...
float frand(void)
Return random values between 0 and 1.
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
XML tag constants for savegame.
static const constListEntry_t saveInterestConstants[]
#define SAVE_INTERESTCAT_NAMESPACE
XML tag constants for savegame.
#define SAVE_MISSIONS_MISSION_IDX
#define SAVE_MISSIONS_ACTIVE
#define SAVE_MISSIONS_MAPDEF_ID
#define SAVE_MISSIONSTAGE_NAMESPACE
#define SAVE_MISSIONS_FINALDATE
static const constListEntry_t saveMissionConstants[]
#define SAVE_MISSIONS_STARTDATE
#define SAVE_MISSIONS_INSTALLATIONINDEX
#define SAVE_MISSIONS_MISSION
#define SAVE_MISSIONS_CATEGORY
#define SAVE_MISSIONS_STAGE
#define SAVE_MISSIONS_ONGEOSCAPE
#define SAVE_MISSIONS_CRASHED_AIRCRAFT
#define SAVE_MISSIONS_INITIALOVERALLINTEREST
#define SAVE_MISSIONS_POSASSIGNED
#define SAVE_MISSIONS_INITIALINDIVIDUALINTEREST
#define SAVE_MISSIONS_BASEINDEX
#define SAVE_MISSIONS_ONWIN
#define SAVE_MISSIONS_POS
#define SAVE_MISSIONS_ALIENBASEINDEX
#define SAVE_MISSIONS_ONLOSE
#define SAVE_MISSIONS_CRASHED
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
An aircraft with all it's data.
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
struct mission_s * mission
void setUfoType(ufoType_t ufoT)
ufoType_t getUfoType() const
alien team category definition
interestCategory_t missionCategories[INTERESTCATEGORY_MAX]
alienTeamGroup_t alienTeamGroups[MAX_ALIEN_GROUP_PER_CATEGORY]
alien team group definition.
const chrTemplate_t * alienChrTemplates[MAX_TEAMS_PER_MISSION]
const teamDef_t * alienTeams[MAX_TEAMS_PER_MISSION]
A base with all it's data.
aircraft_t * aircraftCurrent
alienTeamGroup_t * alienTeamGroup
char alienEquipment[MAX_VAR]
struct mission_s * mission
Describes a character with all its attributes.
Structure of all stats collected for an actor over time.
A installation with all it's data.
linkedList_t * populations
missionResults_t missionResults
int initialOverallInterest
interestCategory_t category
union mission_t::missionData_t data
int initialIndividualInterest
installation_t * installation
#define Vector2Copy(src, dest)