UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_missions.cpp File Reference

Campaign missions code. More...

Go to the source code of this file.

Typedefs

typedef enum
missionDetectionStatus_s 
missionDetectionStatus_t
 possible mission detection status More...
 

Enumerations

enum  missionDetectionStatus_s { MISDET_CANT_BE_DETECTED, MISDET_ALWAYS_DETECTED, MISDET_MAY_BE_DETECTED }
 possible mission detection status More...
 

Functions

void BATTLE_SetVars (const battleParam_t *battleParameters)
 Set some needed cvars from a battle definition. More...
 
void BATTLE_Start (mission_t *mission, const battleParam_t *battleParameters)
 Select the mission type and start the map from mission definition. More...
 
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. More...
 
static void CP_SetAlienTeamByInterest (mission_t *mission, battleParam_t *battleParameters)
 Sets the alien races used for a mission. More...
 
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. More...
 
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) More...
 
static void MIS_CreateAlienTeam (mission_t *mission, battleParam_t *battleParam)
 Set number of aliens in mission. More...
 
static void CP_CreateCivilianTeam (const mission_t *mission, battleParam_t *param)
 Create civilian team. More...
 
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 the mission. More...
 
mission_tCP_GetMissionByIDSilent (const char *missionId)
 Get a mission in ccs.missions by Id without error messages. More...
 
mission_tCP_GetMissionByID (const char *missionId)
 Get a mission in ccs.missions by Id. More...
 
mission_tMIS_GetByIdx (int id)
 Find mission corresponding to idx. More...
 
int MIS_GetIdx (const mission_t *mis)
 Find idx corresponding to mission. More...
 
const char * MIS_GetName (const mission_t *mission)
 Returns a short translated name for a mission. More...
 
int CP_CountMissionOnGeoscape (void)
 Count the number of mission active and displayed on geoscape. More...
 
const char * MIS_GetModel (const mission_t *mission)
 Get mission model that should be shown on the geoscape. More...
 
static missionDetectionStatus_t CP_CheckMissionVisibleOnGeoscape (const mission_t *mission)
 Check if a mission should be visible on geoscape. More...
 
void CP_MissionRemoveFromGeoscape (mission_t *mission)
 Removes a mission from geoscape: make it non visible and call notify functions. More...
 
static messageType_t CP_MissionGetMessageLevel (const mission_t *mission)
 Decides which message level to take for the given mission. More...
 
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. More...
 
void CP_MissionAddToGeoscape (mission_t *mission, bool force)
 Add a mission to geoscape: make it visible and stop time. More...
 
bool CP_CheckNewMissionDetectedOnGeoscape (void)
 Check if mission has been detected by radar. More...
 
void CP_UpdateMissionVisibleOnGeoscape (void)
 Update all mission visible on geoscape (in base radar range). More...
 
void CP_UFORemoveFromGeoscape (mission_t *mission, bool destroyed)
 Removes (temporarily or permanently) a UFO from geoscape: make it land and call notify functions. More...
 
void CP_MissionRemove (mission_t *mission)
 Removes a mission from mission global array. More...
 
void CP_MissionDisableTimeLimit (mission_t *mission)
 Disable time limit for given mission. More...
 
bool CP_CheckMissionLimitedInTime (const mission_t *mission)
 Check if mission should end because of limited time. More...
 
void CP_MissionNotifyBaseDestroyed (const base_t *base)
 Notify that a base has been removed. More...
 
void CP_MissionNotifyInstallationDestroyed (const installation_t *installation)
 Notify missions that an installation has been destroyed. More...
 
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. More...
 
bool CP_ChooseMap (mission_t *mission, const vec2_t pos)
 Choose a map for given mission. More...
 
void CP_MissionStageEnd (const campaign_t *campaign, mission_t *mission)
 Determine what action should be performed when a mission stage ends. More...
 
void CP_MissionIsOver (mission_t *mission)
 Mission is finished because Phalanx team won it. More...
 
void CP_MissionIsOverByUFO (aircraft_t *ufocraft)
 Mission is finished because Phalanx team ended it. More...
 
void CP_MissionEndActions (mission_t *mission, aircraft_t *aircraft, bool won)
 Actions to be done after mission finished. More...
 
void CP_MissionEnd (const campaign_t *campaign, mission_t *mission, const battleParam_t *battleParameters, bool won)
 Closing actions after fighting a battle. More...
 
bool CP_CheckNextStageDestination (const campaign_t *campaign, aircraft_t *ufocraft)
 Check if a stage mission is over when UFO reached destination. More...
 
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). More...
 
void CP_SpawnCrashSiteMission (aircraft_t *ufo)
 Spawn a new crash site after a UFO has been destroyed. More...
 
void CP_SpawnRescueMission (aircraft_t *aircraft, aircraft_t *ufo)
 Spawn a new rescue mission for a crashed (phalanx) aircraft. More...
 
static bool MIS_IsSpawnedFromGround (const mission_t *mission)
 Decides if the mission should be spawned from the ground (without UFO) More...
 
bool CP_MissionBegin (mission_t *mission)
 mission begins: UFO arrive on earth. More...
 
ufoType_t CP_MissionChooseUFO (const mission_t *mission)
 Choose UFO type for a given mission category. More...
 
static void CP_SetMissionName (mission_t *mission)
 Set mission name. More...
 
mission_tCP_CreateNewMission (interestCategory_t category, bool beginNow)
 Create a new mission of given category. More...
 
static interestCategory_t CP_SelectNewMissionType (void)
 Select new mission type. More...
 
void CP_SpawnNewMissions (void)
 Spawn new missions. More...
 
void CP_InitializeSpawningDelay (void)
 Initialize spawning delay. More...
 
bool MIS_SaveXML (xmlNode_t *parent)
 Save callback for savegames in XML Format. More...
 
bool MIS_LoadXML (xmlNode_t *parent)
 Load callback for savegames in XML Format. More...
 
void MIS_InitStartup (void)
 Init actions for missions-subsystem. More...
 
void MIS_Shutdown (void)
 Closing actions for missions-subsystem. More...
 

Variables

const int MAX_POS_LOOP = 10
 
static const float MIN_CRASHEDUFO_CONDITION = 0.2f
 
static const float MAX_CRASHEDUFO_CONDITION = 0.81f
 
static const cmdList_t debugMissionCmds []
 

Detailed Description

Campaign missions code.

Definition in file cp_missions.cpp.

Typedef Documentation

possible mission detection status

Enumeration Type Documentation

possible mission detection status

Enumerator
MISDET_CANT_BE_DETECTED 

Mission can't be seen on geoscape

MISDET_ALWAYS_DETECTED 

Mission is seen on geoscape, whatever it's position

MISDET_MAY_BE_DETECTED 

Mission may be seen on geoscape, if a probability test is done

Definition at line 54 of file cp_missions.cpp.

Function Documentation

void BATTLE_SetVars ( const battleParam_t battleParameters)
void BATTLE_Start ( mission_t mission,
const battleParam_t battleParameters 
)

Select the mission type and start the map from mission definition.

Parameters
[in]missionMission definition to start the map from
[in]battleParametersContext data of the battle
See also
CP_StartSelectedMission
Note
Also sets the terrain textures
See also
Mod_LoadTexinfo
B_AssembleMap_f

Definition at line 106 of file cp_missions.cpp.

References B_AssembleMap(), mission_s::missionData_t::base, mission_s::category, ccs, cgi, mission_s::crashed, ccs_s::curCampaign, cgame_import_s::Cvar_Set(), mission_s::data, campaign_s::difficulty, ERR_DROP, GEO_IsNight(), mission_s::id, INTERESTCATEGORY_BASE_ATTACK, cgame_import_s::LIST_GetRandom(), mission_s::mapDef, mapDef_s::mapTheme, battleParam_s::param, mapDef_s::params, base_s::pos, mission_s::pos, and battleParam_s::zoneType.

Referenced by CP_StartSelectedMission().

bool CP_CheckMissionLimitedInTime ( const mission_t mission)

Check if mission should end because of limited time.

Note
This function is used for better readibility.
See also
CP_MissionDisableTimeLimit
Returns
true if function should end after finalDate

Definition at line 904 of file cp_missions.cpp.

References date_s::day, and mission_s::finalDate.

Referenced by CP_CheckMissionEnd(), and CP_EndRescueMission().

bool CP_CheckNewMissionDetectedOnGeoscape ( void  )

Check if mission has been detected by radar.

Note
called every DETECTION_INTERVAL.
See also
RADAR_CheckUFOSensored
Returns
True if a new mission was detected.

Definition at line 769 of file cp_missions.cpp.

References CP_CheckMissionVisibleOnGeoscape(), CP_MissionAddToGeoscape(), DETECTION_INTERVAL, frand(), MIS_Foreach, MISDET_MAY_BE_DETECTED, and UFO_DetectNewUFO().

Referenced by CP_CampaignFunctionPeriodicCall().

bool CP_CheckNextStageDestination ( const campaign_t campaign,
aircraft_t ufocraft 
)

Check if a stage mission is over when UFO reached destination.

Parameters
[in]campaignThe campaign data structure
[in]ufocraftPointer to the ufo that reached destination.
See also
UFO_CampaignRunUFOs
Returns
True if UFO is removed from global array (and therefore pointer ufocraft can't be used anymore).

Definition at line 1301 of file cp_missions.cpp.

References CP_MissionStageEnd(), aircraft_s::mission, mission_s::stage, STAGE_COME_FROM_ORBIT, STAGE_MISSION_GOTO, and STAGE_RETURN_TO_ORBIT.

Referenced by UFO_CampaignRunUFOs().

bool CP_ChooseMap ( mission_t mission,
const vec2_t  pos 
)

Choose a map for given mission.

Parameters
[in,out]missionPointer to the mission where a new map should be added
[in]posposition of the mission (nullptr if the position will be chosen afterwards)
Returns
false if could not set mission

< Number of maps fulfilling mission conditions and appeared less often during game.

Definition at line 995 of file cp_missions.cpp.

References mission_s::category, cgi, cgame_import_s::Com_GetMapDefinitionByID(), cgame_import_s::Com_UFOTypeToShortName(), CP_MapIsSelectable(), cp_missiontest, mission_s::crashed, DEBUG_CLIENT, ERR_DROP, GEO_GetColor(), aircraft_s::getUfoType(), mapDef_s::id, cvar_s::integer, INTERESTCATEGORY_RESCUE, mission_s::mapDef, MapDef_ForeachSingleplayerCampaign, MapIsWater, MAPTYPE_TERRAIN, mapDef_s::timesAlreadyUsed, and mission_s::ufo.

Referenced by CP_HarvestMissionGo(), CP_ReconMissionGroundGo(), CP_SpawnCrashSiteMission(), CP_SpawnRescueMission(), CP_TerrorMissionGo(), and TEST_F().

int CP_CountMissionOnGeoscape ( void  )

Count the number of mission active and displayed on geoscape.

Returns
Number of active mission visible on geoscape

Definition at line 566 of file cp_missions.cpp.

References MIS_Foreach.

Referenced by GEO_GetGeoscapeAngle().

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 the mission.

Parameters
[in]missionPointer to the mission that generates the battle
[out]paramThe battle parameters to set
[in]aircraftthe aircraft to go to the mission with
See also
CP_CreateAlienTeam
CP_CreateCivilianTeam

Definition at line 338 of file cp_missions.cpp.

References _, mission_s::missionData_t::aircraft, mapDef_s::aircraft, mission_s::category, cgi, cgame_import_s::Com_GetRandomMapAssemblyNameForCraft(), cgame_import_s::Com_GetRandomMapAssemblyNameForCrashedCraft(), Com_sprintf(), cgame_import_s::Com_UFOCrashedTypeToShortName(), cgame_import_s::Com_UFOTypeToShortName(), cp_campaignPool, CP_CreateCivilianTeam(), mission_s::crashed, cgame_import_s::csi, cgame_import_s::Cvar_Set(), mission_s::data, frand(), GEO_GetColor(), TerrainDefs::getTerrainName(), aircraft_s::getUfoType(), TerrainDefs::getWeather(), aircraft_s::id, mapDef_s::id, INTERESTCATEGORY_ALIENBASE, INTERESTCATEGORY_RESCUE, cgame_import_s::LIST_ContainsString(), mission_s::mapDef, mapDef_s::mapTheme, MAPTYPE_TERRAIN, MAX_CRASHEDUFO_CONDITION, MIN_CRASHEDUFO_CONDITION, MIS_CreateAlienTeam(), battleParam_s::mission, aircraft_s::model, mission_s::onwin, battleParam_s::param, cgame_import_s::PoolStrDup(), mission_s::pos, mission_s::posAssigned, Q_streq, battleParam_s::retriable, csi_s::terrainDefs, mission_s::ufo, UFO_GetName(), mapDef_s::ufos, and battleParam_s::zoneType.

Referenced by AM_Go_f(), CP_StartSelectedMission(), and TEST_F().

static void CP_CreateCivilianTeam ( const mission_t mission,
battleParam_t param 
)
static

Create civilian team.

Parameters
[in]missionPointer to the mission that generates the battle
[out]paramThe battlescape parameter container
Todo:
There should always be a nation, no? Otherwise the mission was placed wrong.

Definition at line 309 of file cp_missions.cpp.

References battleParam_s::civilians, battleParam_s::civTeam, mapDef_s::civTeam, GEO_GetCivilianNumberByPosition(), GEO_GetNation(), nation_s::id, mission_s::mapDef, battleParam_s::nation, mission_s::pos, mission_s::posAssigned, and Q_strncpyz().

Referenced by CP_CreateBattleParameters().

mission_t* CP_GetMissionByID ( const char *  missionId)

Get a mission in ccs.missions by Id.

Parameters
[in]missionIdUnique string id for the mission
Returns
pointer to the mission or nullptr if Id was nullptr or mission not found

Definition at line 432 of file cp_missions.cpp.

References cgi, and CP_GetMissionByIDSilent().

Referenced by AIR_PostLoadInitMissions().

mission_t* CP_GetMissionByIDSilent ( const char *  missionId)

Get a mission in ccs.missions by Id without error messages.

Parameters
[in]missionIdUnique string id for the mission
Returns
pointer to the mission or nullptr if Id was nullptr or mission not found

Definition at line 414 of file cp_missions.cpp.

References MIS_Foreach, and Q_streq.

Referenced by CP_GetMissionByID(), and CP_SetMissionName().

void CP_InitializeSpawningDelay ( void  )

Initialize spawning delay.

See also
CP_SpawnNewMissions
Note
only called when new game is started, in order to spawn new event on the beginning of the game.

Definition at line 1786 of file cp_missions.cpp.

References ccs, DELAY_BETWEEN_MISSION_SPAWNING, ccs_s::lastMissionSpawnedDelay, and ccs_s::missionSpawnCallback.

Referenced by CP_CampaignInit().

static bool CP_IsAlienEquipmentSelectable ( const mission_t mission,
const equipDef_t equip,
linkedList_t equipPack 
)
static

Check if an alien equipment may be used with a mission.

Parameters
[in]missionPointer to the mission.
[in]equipPointer to the alien equipment to check.
[in]equipPackEquipment definitions that may be used
Returns
True if equipment definition is selectable.

Definition at line 220 of file cp_missions.cpp.

References equipDef_s::id, mission_s::initialOverallInterest, LIST_Foreach, equipDef_s::maxInterest, equipDef_s::minInterest, name, and Q_strstart().

Referenced by CP_SetAlienEquipmentByInterest().

static bool CP_IsAlienTeamForCategory ( const alienTeamCategory_t cat,
const interestCategory_t  missionCat 
)
static

Check if an alien team category may be used for a mission category.

Parameters
[in]catPointer to the alien team category.
[in]missionCatMission category to check.
Returns
True if alien Category may be used for this mission category.

Definition at line 161 of file cp_missions.cpp.

References i, alienTeamCategory_s::missionCategories, and alienTeamCategory_s::numMissionCategories.

Referenced by CP_SetAlienTeamByInterest().

static bool CP_MapIsSelectable ( const mission_t mission,
const mapDef_t md,
const vec2_t  pos 
)
static

Check if a map may be selected for mission.

Parameters
[in]missionPointer to the mission where mapDef should be added
[in]posposition of the mission (nullptr if the position will be chosen afterwards)
[in]mdThe map description data (what it is suitable for)
Returns
false if map is not selectable

Definition at line 959 of file cp_missions.cpp.

References cgi, cgame_import_s::Com_UFOCrashedTypeToShortName(), cgame_import_s::Com_UFOTypeToShortName(), mission_s::crashed, mapDef_s::cultures, GEO_PositionFitsTCPNTypes(), aircraft_s::getUfoType(), cgame_import_s::LIST_ContainsString(), mapDef_s::populations, mapDef_s::storyRelated, mapDef_s::terrains, type, mission_s::ufo, and mapDef_s::ufos.

Referenced by CP_ChooseMap().

bool CP_MissionBegin ( mission_t mission)
void CP_MissionEnd ( const campaign_t campaign,
mission_t mission,
const battleParam_t battleParameters,
bool  won 
)

Closing actions after fighting a battle.

Parameters
[in]campaignThe campaign we play
[in,out]missionThe mission the battle was on
[in]battleParametersParameters of the battle
[in]wonif PHALANX won
Note
both manual and automatic missions call this through won/lost UI screen
Todo:
replace HP check with some CHRSH->IsDead() function

Definition at line 1249 of file cp_missions.cpp.

References AIR_IsEmployeeInAircraft(), base_s::aircraftCurrent, mission_s::missionData_t::base, ccs_s::campaignStats, ccs, cgi, CHAR_UpdateData(), CHAR_UpdateStats(), CP_CheckLostCondition(), CP_ExecuteMissionTrigger(), CP_HandleNationData(), CP_MissionEndActions(), mission_s::data, DEBUG_CLIENT, E_DeleteEmployee(), E_Foreach, ccs_s::eMission, EMPL_SOLDIER, GEO_GetMissionAircraft, aircraft_s::homebase, campaign_s::minhappiness, mission_s::missionResults, stats_s::missionsLost, stats_s::missionsWon, battleParam_s::nation, mission_s::stage, STAGE_BASE_ATTACK, base_s::storage, and ccs_s::updateCharacters.

Referenced by GAME_CP_Results_f().

void CP_MissionEndActions ( mission_t mission,
aircraft_t aircraft,
bool  won 
)

Actions to be done after mission finished.

Parameters
[in,out]missionPointer to the finished mission
[in,out]aircraftPointer to the dropship done the mission
[in]wonBoolean flag if thew mission was successful (from PHALANX's PoV)

Definition at line 1214 of file cp_missions.cpp.

References _, AIR_AircraftReturnToBase(), B_DumpAircraftToHomeBase(), mission_s::category, Com_sprintf(), CP_BaseAttackMissionDestroyBase(), CP_BaseAttackMissionIsFailure(), CP_EndRescueMission(), cp_messageBuffer, CP_MissionIsOver(), aircraft_s::homebase, INTERESTCATEGORY_RESCUE, MS_AddNewMessage(), base_s::name, mission_s::stage, and STAGE_BASE_ATTACK.

Referenced by CP_MissionEnd().

static const char* CP_MissionGetMessage ( const mission_t mission)
inlinestatic

Assembles a message that is send to the gamer once the given mission is added to geoscape.

Parameters
[in]missionThe mission that was added to the geoscape and for that a message should be created
Returns
The pointer to the static buffer that holds the message.

Definition at line 720 of file cp_missions.cpp.

References _, mission_s::missionData_t::aircraft, mission_s::category, Com_sprintf(), cp_messageBuffer, mission_s::data, GEO_GetNation(), INTERESTCATEGORY_RESCUE, nation_s::name, aircraft_s::name, and mission_s::pos.

Referenced by CP_MissionAddToGeoscape().

static messageType_t CP_MissionGetMessageLevel ( const mission_t mission)
inlinestatic

Decides which message level to take for the given mission.

Parameters
[in]missionThe mission to chose the message level for
Returns
The message level

Definition at line 699 of file cp_missions.cpp.

References mission_s::crashed, MSG_BASEATTACK, MSG_CRASHSITE, MSG_STANDARD, MSG_TERRORSITE, mission_s::stage, STAGE_BASE_ATTACK, and STAGE_TERROR_MISSION.

Referenced by CP_MissionAddToGeoscape().

void CP_MissionIsOverByUFO ( aircraft_t ufocraft)

Mission is finished because Phalanx team ended it.

Parameters
[in]ufocraftPointer to the UFO involved in this mission

Definition at line 1202 of file cp_missions.cpp.

References CP_MissionIsOver(), and aircraft_s::mission.

Referenced by AIRFIGHT_ActionsAfterAirfight().

void CP_MissionNotifyBaseDestroyed ( const base_t base)

Notify that a base has been removed.

Definition at line 919 of file cp_missions.cpp.

References CP_BaseAttackMissionLeave(), INTERESTCATEGORY_BASE_ATTACK, and MIS_Foreach.

Referenced by B_Destroy().

void CP_MissionNotifyInstallationDestroyed ( const installation_t installation)

Notify missions that an installation has been destroyed.

Parameters
[in]installationPointer to the installation that has been destroyed.

Definition at line 936 of file cp_missions.cpp.

References CP_InterceptMissionLeave(), INTERESTCATEGORY_INTERCEPT, and MIS_Foreach.

Referenced by INS_DestroyInstallation().

void CP_MissionRemove ( mission_t mission)
void CP_MissionRemoveFromGeoscape ( mission_t mission)
static interestCategory_t CP_SelectNewMissionType ( void  )
static

Select new mission type.

See also
CP_SpawnNewMissions

Definition at line 1717 of file cp_missions.cpp.

References ccs, frand(), i, ccs_s::interest, and INTERESTCATEGORY_MAX.

Referenced by CP_SpawnNewMissions().

static void CP_SetAlienEquipmentByInterest ( const mission_t mission,
linkedList_t equipPack,
battleParam_t battleParameters 
)
static

Set alien equipment for a mission (depends on the interest values)

Note
This function is used to know which equipment pack described in equipment_missions.ufo should be used
Precondition
Alien team must be already chosen
Parameters
[in]missionPointer to the mission that generates the battle.
[in]equipPackEquipment definitions that may be used
[in]battleParametersContext data of the battle
See also
CP_SetAlienTeamByInterest

Definition at line 242 of file cp_missions.cpp.

References battleParam_s::alienEquipment, cgi, Com_sprintf(), CP_IsAlienEquipmentSelectable(), cgame_import_s::csi, DEBUG_CLIENT, csi_s::eds, ERR_DROP, i, mission_s::id, equipDef_s::id, and csi_s::numEDs.

Referenced by MIS_CreateAlienTeam().

static void CP_SetAlienTeamByInterest ( mission_t mission,
battleParam_t battleParameters 
)
static

Sets the alien races used for a mission.

Parameters
[in]missionPointer to the mission.
[out]battleParametersThe battlescape parameter the alien team is stored in

Definition at line 176 of file cp_missions.cpp.

References ccs_s::alienCategories, battleParam_s::alienTeamGroup, alienTeamCategory_s::alienTeamGroups, mission_s::category, ccs, cgi, CP_IsAlienTeamForCategory(), CP_MissionRemove(), ERR_DROP, i, mission_s::id, mission_s::initialOverallInterest, alienTeamGroup_s::maxInterest, alienTeamGroup_s::minInterest, ccs_s::numAlienCategories, and alienTeamCategory_s::numAlienTeamGroups.

Referenced by MIS_CreateAlienTeam().

static void CP_SetMissionName ( mission_t mission)
inlinestatic

Set mission name.

Note
that mission name must be unique in mission global array
Parameters
[out]missionThe mission to set the name for
See also
CP_CreateNewMission

Definition at line 1644 of file cp_missions.cpp.

References mission_s::category, ccs, cgi, Com_sprintf(), CP_GetMissionByIDSilent(), mission_s::id, mission_s::initialOverallInterest, and ccs_s::missions.

Referenced by CP_CreateNewMission().

void CP_SpawnCrashSiteMission ( aircraft_t ufo)
void CP_SpawnRescueMission ( aircraft_t aircraft,
aircraft_t ufo 
)

Spawn a new rescue mission for a crashed (phalanx) aircraft.

Parameters
[in]aircraftThe crashed aircraft to spawn the rescue mission for.
[in]ufoThe UFO that shot down the phalanx aircraft, can also be nullptr if the UFO was destroyed.
Note
Don't use ufo's old mission pointer after this call! It might have been removed.
Todo:
Don't spawn rescue mission every time! It should depend on pilot's manoeuvring (piloting) skill
Todo:
don't "kill" everyone - this should depend on luck and a little bit on the skills
Todo:
find out what to do in this case

Definition at line 1394 of file cp_missions.cpp.

References aircraft_s::acTeam, AIR_CRASHED, AIR_DestroyAircraft(), AIR_GetFirstFromBase(), AIR_GetHangarCapacityType(), AIR_GetPilot(), AIR_PilotSurvivedCrash(), mission_s::missionData_t::aircraft, base_s::aircraftCurrent, CAP_AddCurrent(), cgi, CP_ChooseMap(), CP_CreateNewMission(), CP_MissionDisableTimeLimit(), CP_MissionRemove(), mission_s::data, E_DeleteEmployee(), ERR_DROP, GEO_IsAircraftSelected, GEO_SetSelectedAircraft, aircraft_s::homebase, mission_s::id, INTERESTCATEGORY_RESCUE, LIST_Foreach, mission_s::mapDef, MAX_CAP, aircraft_s::mission, mission_s::pos, aircraft_s::pos, character_s::score, mission_s::stage, STAGE_MISSION_GOTO, aircraft_s::status, mission_s::ufo, and Vector2Copy.

Referenced by AIRFIGHT_ActionsAfterAirfight(), and B_MoveAircraftOnGeoscapeToOtherBases().

void CP_UFOProceedMission ( const campaign_t campaign,
aircraft_t ufo 
)
void CP_UFORemoveFromGeoscape ( mission_t mission,
bool  destroyed 
)

Removes (temporarily or permanently) a UFO from geoscape: make it land and call notify functions.

Parameters
[in]missionPointer to mission.
[in]destroyedTrue if the UFO has been destroyed, false if it's only landed.
Note
We don't destroy the UFO if mission is not deleted because we can use it later, e.g. if it takes off.
See also
UFO_RemoveFromGeoscape
Todo:
remove me once the ufo list is a linked list

Definition at line 827 of file cp_missions.cpp.

References AIR_AircraftsNotifyUFORemoved(), AIRFIGHT_RemoveProjectileAimingAircraft(), aircraft_s::detected, GEO_NotifyUFORemoved(), aircraft_s::landed, MIS_Foreach, aircraft_s::pos, RADAR_CheckRadarSensored(), RADAR_NotifyUFORemoved(), mission_s::ufo, and UFO_RemoveFromGeoscape().

Referenced by CP_BaseAttackStartMission(), CP_BuildBaseSetUpBase(), CP_BuildBaseSubvertGovernment(), CP_HarvestMissionStart(), CP_MissionRemove(), CP_ReconMissionGround(), CP_SpawnCrashSiteMission(), CP_SupplySetStayAtBase(), CP_TerrorMissionStart(), and CP_XVIMissionStart().

void CP_UpdateMissionVisibleOnGeoscape ( void  )

Update all mission visible on geoscape (in base radar range).

Note
you can't see a mission with aircraft radar.
See also
CP_CheckMissionAddToGeoscape

Definition at line 806 of file cp_missions.cpp.

References CP_CheckMissionVisibleOnGeoscape(), CP_MissionAddToGeoscape(), CP_MissionRemoveFromGeoscape(), MIS_Foreach, MISDET_ALWAYS_DETECTED, and MISDET_CANT_BE_DETECTED.

Referenced by RADAR_UpdateBaseRadarCoverage_f(), and RADAR_UpdateInstallationRadarCoverage().

static void MIS_CreateAlienTeam ( mission_t mission,
battleParam_t battleParam 
)
static
mission_t* MIS_GetByIdx ( int  id)

Find mission corresponding to idx.

Definition at line 447 of file cp_missions.cpp.

References MIS_Foreach.

Referenced by AIR_SendAircraftToMission_f(), GEO_GetMissionAngle(), and MIS_GeoSelectMission_f().

int MIS_GetIdx ( const mission_t mis)

Find idx corresponding to mission.

Definition at line 460 of file cp_missions.cpp.

References mission_s::idx.

Referenced by GEO_Click().

void MIS_InitStartup ( void  )

Init actions for missions-subsystem.

See also
UI_InitStartup

Definition at line 2210 of file cp_missions.cpp.

References cgi, and MIS_InitCallbacks().

Referenced by CP_InitStartup().

static bool MIS_IsSpawnedFromGround ( const mission_t mission)
static
bool MIS_LoadXML ( xmlNode_t parent)

Load callback for savegames in XML Format.

Parameters
[in]parentXML Node structure, where we get the information from

Definition at line 2064 of file cp_missions.cpp.

References AB_GetByIDX(), mission_s::active, AIR_AircraftGetFromIDX(), mission_s::missionData_t::aircraft, mission_s::missionData_t::alienBase, B_GetBaseByIDX(), B_IsUnderAttack, mission_s::missionData_t::base, mission_s::category, ccs, cgi, mission_s::missionData_t::city, CITY_GetByPos(), cgame_import_s::Com_GetMapDefinitionByID(), CP_BasemissionIsSubvertingGovernmentMission(), mission_s::crashed, mission_s::data, date_s::day, mission_s::finalDate, mission_s::id, base_s::idx, mission_s::idx, mission_s::initialIndividualInterest, mission_s::initialOverallInterest, INS_GetByIDX(), mission_s::missionData_t::installation, INTERESTCATEGORY_ALIENBASE, INTERESTCATEGORY_BASE_ATTACK, INTERESTCATEGORY_BUILDING, INTERESTCATEGORY_INTERCEPT, INTERESTCATEGORY_RESCUE, INTERESTCATEGORY_SUPPLY, INTERESTCATEGORY_TERROR_ATTACK, LIST_Add(), mission_s::mapDef, ccs_s::missions, base_s::name, name, OBJZERO, mission_s::onGeoscape, mission_s::onlose, mission_s::onwin, mission_s::pos, mission_s::posAssigned, Q_strncpyz(), SAVE_INTERESTCAT_NAMESPACE, SAVE_MISSIONS, SAVE_MISSIONS_ACTIVE, SAVE_MISSIONS_ALIENBASEINDEX, SAVE_MISSIONS_BASEINDEX, SAVE_MISSIONS_CATEGORY, SAVE_MISSIONS_CRASHED, SAVE_MISSIONS_CRASHED_AIRCRAFT, SAVE_MISSIONS_FINALDATE, SAVE_MISSIONS_ID, SAVE_MISSIONS_INITIALINDIVIDUALINTEREST, SAVE_MISSIONS_INITIALOVERALLINTEREST, SAVE_MISSIONS_INSTALLATIONINDEX, SAVE_MISSIONS_MAPDEF_ID, SAVE_MISSIONS_MISSION, SAVE_MISSIONS_MISSION_IDX, SAVE_MISSIONS_ONGEOSCAPE, SAVE_MISSIONS_ONLOSE, SAVE_MISSIONS_ONWIN, SAVE_MISSIONS_POS, SAVE_MISSIONS_POSASSIGNED, SAVE_MISSIONS_STAGE, SAVE_MISSIONS_STARTDATE, SAVE_MISSIONSTAGE_NAMESPACE, saveInterestConstants, saveMissionConstants, date_s::sec, mission_s::stage, STAGE_BASE_ATTACK, STAGE_BUILD_BASE, STAGE_INTERCEPT, STAGE_MISSION_GOTO, STAGE_TERROR_MISSION, mission_s::startDate, cgame_import_s::XML_GetDate(), cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetPos2(), cgame_import_s::XML_GetString(), and xmlNode_t.

Referenced by SAV_Init().

bool MIS_SaveXML ( xmlNode_t parent)

Save callback for savegames in XML Format.

Parameters
[out]parentXML Node structure, where we write the information to

Definition at line 1992 of file cp_missions.cpp.

References mission_s::active, mission_s::missionData_t::aircraft, mission_s::missionData_t::alienBase, mission_s::missionData_t::base, mission_s::category, cgi, cgame_import_s::Com_GetConstVariable(), mission_s::crashed, mission_s::data, date_s::day, mission_s::finalDate, mission_s::id, mapDef_s::id, alienBase_s::idx, installation_s::idx, base_s::idx, mission_s::idx, aircraft_s::idx, mission_s::initialIndividualInterest, mission_s::initialOverallInterest, mission_s::missionData_t::installation, INTERESTCATEGORY_ALIENBASE, INTERESTCATEGORY_BASE_ATTACK, INTERESTCATEGORY_BUILDING, INTERESTCATEGORY_INTERCEPT, INTERESTCATEGORY_RESCUE, INTERESTCATEGORY_SUPPLY, mission_s::mapDef, MIS_Foreach, mission_s::onGeoscape, mission_s::onlose, mission_s::onwin, mission_s::pos, mission_s::posAssigned, SAVE_INTERESTCAT_NAMESPACE, SAVE_MISSIONS, SAVE_MISSIONS_ACTIVE, SAVE_MISSIONS_ALIENBASEINDEX, SAVE_MISSIONS_BASEINDEX, SAVE_MISSIONS_CATEGORY, SAVE_MISSIONS_CRASHED, SAVE_MISSIONS_CRASHED_AIRCRAFT, SAVE_MISSIONS_FINALDATE, SAVE_MISSIONS_ID, SAVE_MISSIONS_INITIALINDIVIDUALINTEREST, SAVE_MISSIONS_INITIALOVERALLINTEREST, SAVE_MISSIONS_INSTALLATIONINDEX, SAVE_MISSIONS_MAPDEF_ID, SAVE_MISSIONS_MISSION, SAVE_MISSIONS_MISSION_IDX, SAVE_MISSIONS_ONGEOSCAPE, SAVE_MISSIONS_ONLOSE, SAVE_MISSIONS_ONWIN, SAVE_MISSIONS_POS, SAVE_MISSIONS_POSASSIGNED, SAVE_MISSIONS_STAGE, SAVE_MISSIONS_STARTDATE, SAVE_MISSIONSTAGE_NAMESPACE, saveInterestConstants, saveMissionConstants, date_s::sec, mission_s::stage, STAGE_BASE_ATTACK, STAGE_INTERCEPT, STAGE_MISSION_GOTO, mission_s::startDate, cgame_import_s::XML_AddNode(), and xmlNode_t.

Referenced by SAV_Init().

void MIS_Shutdown ( void  )

Closing actions for missions-subsystem.

Definition at line 2219 of file cp_missions.cpp.

References ccs, cgi, MIS_ShutdownCallbacks(), and ccs_s::missions.

Referenced by CP_Shutdown().

Variable Documentation

const cmdList_t debugMissionCmds[]
static
Initial value:
= {
{nullptr, nullptr, nullptr}
}

Definition at line 2196 of file cp_missions.cpp.

const float MAX_CRASHEDUFO_CONDITION = 0.81f
static

Definition at line 65 of file cp_missions.cpp.

Referenced by CP_CreateBattleParameters().

const int MAX_POS_LOOP = 10

Maximum number of loops to choose a mission position (to avoid infinite loops)

Definition at line 61 of file cp_missions.cpp.

Referenced by CP_HarvestMissionGo(), CP_ReconMissionGroundGo(), and CP_TerrorMissionGo().

const float MIN_CRASHEDUFO_CONDITION = 0.2f
static

Condition limits for crashed UFOs - used for disassemlies

Definition at line 64 of file cp_missions.cpp.

Referenced by CP_CreateBattleParameters().