UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_missions.cpp File Reference

Campaign missions code. More...

Include dependency graph for cp_missions.cpp:

Go to the source code of this file.

Enumerations

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

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.

Enumeration Type Documentation

◆ missionDetectionStatus_t

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 55 of file cp_missions.cpp.

Function Documentation

◆ BATTLE_SetVars()

void BATTLE_SetVars ( const battleParam_t * battleParameters)

Set some needed cvars from a battle definition.

Parameters
[in]battleParametersbattle definition pointer with the needed data to set the cvars to
See also
CP_StartSelectedMission

Definition at line 79 of file cp_missions.cpp.

References alienTeamGroup_t::alienChrTemplates, battleParam_t::alienEquipment, battleParam_t::aliens, battleParam_t::alienTeamGroup, alienTeamGroup_t::alienTeams, cgi, battleParam_t::civilians, battleParam_t::civTeam, i, MAX_TEAMS_PER_MISSION, and alienTeamGroup_t::numAlienTeams.

Referenced by CP_StartSelectedMission().

◆ BATTLE_Start()

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 107 of file cp_missions.cpp.

References B_AssembleMap(), mission_t::missionData_t::base, mission_t::category, ccs, cgi, mission_t::crashed, mission_t::data, ERR_DROP, GEO_IsNight(), mission_t::id, INTERESTCATEGORY_BASE_ATTACK, mission_t::mapDef, mapDef_t::mapTheme, battleParam_t::param, mapDef_t::params, base_t::pos, mission_t::pos, and battleParam_t::zoneType.

Referenced by CP_StartSelectedMission().

◆ CP_CheckMissionLimitedInTime()

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 905 of file cp_missions.cpp.

References mission_t::finalDate, and DateTime::getDateAsDays().

Referenced by CP_CheckMissionEnd(), and CP_EndRescueMission().

◆ CP_CheckMissionVisibleOnGeoscape()

◆ CP_CheckNewMissionDetectedOnGeoscape()

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 770 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().

◆ CP_CheckNextStageDestination()

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 1302 of file cp_missions.cpp.

References CP_MissionStageEnd(), aircraft_t::mission, mission_t::stage, STAGE_COME_FROM_ORBIT, STAGE_MISSION_GOTO, and STAGE_RETURN_TO_ORBIT.

Referenced by UFO_CampaignRunUFOs().

◆ CP_ChooseMap()

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 996 of file cp_missions.cpp.

References mission_t::category, cgi, CP_MapIsSelectable(), cp_missiontest, mission_t::crashed, DEBUG_CLIENT, ERR_DROP, GEO_GetColor(), aircraft_t::getUfoType(), mapDef_t::id, INTERESTCATEGORY_RESCUE, mission_t::mapDef, MapDef_ForeachSingleplayerCampaign, MapIsWater, MAPTYPE_TERRAIN, mapDef_t::timesAlreadyUsed, and mission_t::ufo.

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

◆ CP_CountMissionOnGeoscape()

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 567 of file cp_missions.cpp.

References MIS_Foreach.

Referenced by GEO_GetGeoscapeAngle().

◆ CP_CreateBattleParameters()

void CP_CreateBattleParameters ( mission_t * mission,
battleParam_t * param,
const aircraft_t * aircraft )

◆ CP_CreateCivilianTeam()

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 310 of file cp_missions.cpp.

References battleParam_t::civilians, battleParam_t::civTeam, mapDef_t::civTeam, GEO_GetCivilianNumberByPosition(), GEO_GetNation(), nation_t::id, mission_t::mapDef, battleParam_t::nation, mission_t::pos, mission_t::posAssigned, and Q_strncpyz().

Referenced by CP_CreateBattleParameters().

◆ CP_CreateNewMission()

◆ CP_GetMissionByID()

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 433 of file cp_missions.cpp.

References cgi, and CP_GetMissionByIDSilent().

Referenced by AIR_PostLoadInitMissions().

◆ CP_GetMissionByIDSilent()

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 415 of file cp_missions.cpp.

References MIS_Foreach, and Q_streq.

Referenced by CP_GetMissionByID(), and CP_SetMissionName().

◆ CP_InitializeSpawningDelay()

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, and DELAY_BETWEEN_MISSION_SPAWNING.

Referenced by CP_CampaignInit().

◆ CP_IsAlienEquipmentSelectable()

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 221 of file cp_missions.cpp.

References equipDef_t::id, mission_t::initialOverallInterest, LIST_Foreach, equipDef_t::maxInterest, equipDef_t::minInterest, name, and Q_strstart().

Referenced by CP_SetAlienEquipmentByInterest().

◆ CP_IsAlienTeamForCategory()

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 162 of file cp_missions.cpp.

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

Referenced by CP_SetAlienTeamByInterest().

◆ CP_MapIsSelectable()

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 960 of file cp_missions.cpp.

References cgi, mission_t::crashed, mapDef_t::cultures, GEO_PositionFitsTCPNTypes(), aircraft_t::getUfoType(), mapDef_t::populations, mapDef_t::storyRelated, mapDef_t::terrains, type, mission_t::ufo, and mapDef_t::ufos.

Referenced by CP_ChooseMap().

◆ CP_MissionAddToGeoscape()

◆ CP_MissionBegin()

bool CP_MissionBegin ( mission_t * mission)

mission begins: UFO arrive on earth.

Parameters
[in]missionThe mission to change the state for
Note
Stage 0 – This function is common to several mission category.
See also
CP_MissionChooseUFO
Returns
true if mission was created, false else.

Definition at line 1537 of file cp_missions.cpp.

References ccs, cgi, CP_MissionChooseUFO(), CP_MissionDisableTimeLimit(), CP_MissionRemove(), mission_t::finalDate, mission_t::id, mission_t::idx, MIS_IsSpawnedFromGround(), mission_t::stage, STAGE_COME_FROM_ORBIT, mission_t::ufo, UFO_AddToGeoscape(), and UFO_NONE.

Referenced by CP_BaseAttackMissionNextStage(), CP_BuildBaseMissionNextStage(), CP_HarvestMissionNextStage(), CP_InterceptNextStage(), CP_ReconMissionNextStage(), CP_TerrorMissionNextStage(), and CP_XVIMissionNextStage().

◆ CP_MissionChooseUFO()

◆ CP_MissionDisableTimeLimit()

◆ CP_MissionEnd()

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 1250 of file cp_missions.cpp.

References AIR_IsEmployeeInAircraft(), base_t::aircraftCurrent, mission_t::missionData_t::base, ccs, cgi, CHAR_UpdateData(), CHAR_UpdateStats(), CP_CheckLostCondition(), CP_ExecuteMissionTrigger(), CP_HandleNationData(), CP_MissionEndActions(), mission_t::data, DEBUG_CLIENT, E_DeleteEmployee(), E_Foreach, EMPL_SOLDIER, GEO_GetMissionAircraft, aircraft_t::homebase, campaign_t::minhappiness, mission_t::missionResults, battleParam_t::nation, mission_t::stage, STAGE_BASE_ATTACK, and base_t::storage.

Referenced by GAME_CP_Results_f().

◆ CP_MissionEndActions()

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 1215 of file cp_missions.cpp.

References _, AIR_AircraftReturnToBase(), B_DumpAircraftToHomeBase(), mission_t::category, Com_sprintf(), CP_BaseAttackMissionDestroyBase(), CP_BaseAttackMissionIsFailure(), CP_EndRescueMission(), cp_messageBuffer, CP_MissionIsOver(), aircraft_t::homebase, INTERESTCATEGORY_RESCUE, MS_AddNewMessage(), mission_t::stage, and STAGE_BASE_ATTACK.

Referenced by CP_MissionEnd().

◆ CP_MissionGetMessage()

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 721 of file cp_missions.cpp.

References _, mission_t::missionData_t::aircraft, mission_t::category, Com_sprintf(), cp_messageBuffer, mission_t::data, GEO_GetNation(), INTERESTCATEGORY_RESCUE, aircraft_t::name, nation_t::name, and mission_t::pos.

Referenced by CP_MissionAddToGeoscape().

◆ CP_MissionGetMessageLevel()

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 700 of file cp_missions.cpp.

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

Referenced by CP_MissionAddToGeoscape().

◆ CP_MissionIsOver()

◆ CP_MissionIsOverByUFO()

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 1203 of file cp_missions.cpp.

References CP_MissionIsOver(), and aircraft_t::mission.

Referenced by AIRFIGHT_ActionsAfterAirfight().

◆ CP_MissionNotifyBaseDestroyed()

void CP_MissionNotifyBaseDestroyed ( const base_t * base)

Notify that a base has been removed.

Definition at line 920 of file cp_missions.cpp.

References CP_BaseAttackMissionLeave(), INTERESTCATEGORY_BASE_ATTACK, and MIS_Foreach.

Referenced by B_Destroy().

◆ CP_MissionNotifyInstallationDestroyed()

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 937 of file cp_missions.cpp.

References CP_InterceptMissionLeave(), INTERESTCATEGORY_INTERCEPT, and MIS_Foreach.

Referenced by INS_DestroyInstallation().

◆ CP_MissionRemove()

◆ CP_MissionRemoveFromGeoscape()

void CP_MissionRemoveFromGeoscape ( mission_t * mission)

◆ CP_MissionStageEnd()

◆ CP_SelectNewMissionType()

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, int(), and INTERESTCATEGORY_MAX.

Referenced by CP_SpawnNewMissions().

◆ CP_SetAlienEquipmentByInterest()

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 243 of file cp_missions.cpp.

References battleParam_t::alienEquipment, cgi, Com_sprintf(), CP_IsAlienEquipmentSelectable(), DEBUG_CLIENT, ERR_DROP, i, equipDef_t::id, and mission_t::id.

Referenced by MIS_CreateAlienTeam().

◆ CP_SetAlienTeamByInterest()

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 177 of file cp_missions.cpp.

References battleParam_t::alienTeamGroup, alienTeamCategory_t::alienTeamGroups, mission_t::category, ccs, cgi, CP_IsAlienTeamForCategory(), CP_MissionRemove(), ERR_DROP, i, mission_t::id, mission_t::initialOverallInterest, alienTeamGroup_t::maxInterest, alienTeamGroup_t::minInterest, and alienTeamCategory_t::numAlienTeamGroups.

Referenced by MIS_CreateAlienTeam().

◆ CP_SetMissionName()

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 1645 of file cp_missions.cpp.

References mission_t::category, ccs, cgi, Com_sprintf(), CP_GetMissionByIDSilent(), mission_t::id, and mission_t::initialOverallInterest.

Referenced by CP_CreateNewMission().

◆ CP_SpawnCrashSiteMission()

void CP_SpawnCrashSiteMission ( aircraft_t * ufo)

◆ CP_SpawnNewMissions()

◆ CP_SpawnRescueMission()

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 1395 of file cp_missions.cpp.

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

Referenced by AIRFIGHT_ActionsAfterAirfight(), and B_MoveAircraftOnGeoscapeToOtherBases().

◆ CP_UFOProceedMission()

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).

Parameters
[in]campaignThe campaign data structure
[in]ufoPointer to the ufo that should proceed a mission.

Definition at line 1328 of file cp_missions.cpp.

References AIR_TRANSIT, AIRFIGHT_ChooseWeapon(), AIRFIGHT_WEAPON_CAN_NEVER_SHOOT, CP_MissionStageEnd(), INTERESTCATEGORY_INTERCEPT, aircraft_t::maxWeapons, aircraft_t::mission, aircraft_t::pos, STAGE_MISSION_GOTO, STAGE_RETURN_TO_ORBIT, aircraft_t::status, UFO_SendToDestination(), UFO_SetRandomDest(), and aircraft_t::weapons.

Referenced by AIRFIGHT_ActionsAfterAirfight(), AIRFIGHT_ExecuteActions(), and UFO_CheckShootBack().

◆ CP_UFORemoveFromGeoscape()

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 828 of file cp_missions.cpp.

References AIR_AircraftsNotifyUFORemoved(), AIRFIGHT_RemoveProjectileAimingAircraft(), aircraft_t::detected, GEO_NotifyUFORemoved(), aircraft_t::landed, MIS_Foreach, aircraft_t::pos, RADAR_CheckRadarSensored(), RADAR_NotifyUFORemoved(), mission_t::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().

◆ CP_UpdateMissionVisibleOnGeoscape()

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 807 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().

◆ MIS_CreateAlienTeam()

void MIS_CreateAlienTeam ( mission_t * mission,
battleParam_t * battleParam )
static

Set number of aliens in mission.

Parameters
[in,out]missionPointer to the mission that generates the battle.
[in,out]battleParamThe battlescape parameter container
See also
CP_SetAlienTeamByInterest

Definition at line 283 of file cp_missions.cpp.

References battleParam_t::aliens, battleParam_t::alienTeamGroup, alienTeamGroup_t::categoryIdx, ccs, CP_SetAlienEquipmentByInterest(), CP_SetAlienTeamByInterest(), mission_t::mapDef, alienTeamGroup_t::maxAlienCount, mapDef_t::maxAliens, aircraft_t::maxTeamSize, alienTeamGroup_t::minAlienCount, mission_t::posAssigned, and mission_t::ufo.

Referenced by CP_CreateBattleParameters().

◆ MIS_GetByIdx()

mission_t * MIS_GetByIdx ( int id)

Find mission corresponding to idx.

Definition at line 448 of file cp_missions.cpp.

References MIS_Foreach.

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

◆ MIS_GetIdx()

int MIS_GetIdx ( const mission_t * mis)

Find idx corresponding to mission.

Definition at line 461 of file cp_missions.cpp.

References mission_t::idx.

Referenced by GEO_Click().

◆ MIS_GetModel()

◆ MIS_GetName()

◆ MIS_InitStartup()

void MIS_InitStartup ( void )

Init actions for missions-subsystem.

See also
UI_InitStartup

Definition at line 2226 of file cp_missions.cpp.

References cgi, debugMissionCmds, and MIS_InitCallbacks().

Referenced by CP_InitStartup().

◆ MIS_IsSpawnedFromGround()

bool MIS_IsSpawnedFromGround ( const mission_t * mission)
static

◆ MIS_LoadXML()

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_t::active, AIR_AircraftGetFromIDX(), mission_t::missionData_t::aircraft, mission_t::missionData_t::alienBase, B_GetBaseByIDX(), B_IsUnderAttack, mission_t::missionData_t::base, mission_t::category, ccs, cgi, mission_t::missionData_t::city, CITY_GetByPos(), CP_BasemissionIsSubvertingGovernmentMission(), mission_t::crashed, mission_t::data, mission_t::finalDate, mission_t::id, alienBase_t::idx, base_t::idx, mission_t::idx, mission_t::initialIndividualInterest, mission_t::initialOverallInterest, INS_GetByIDX(), mission_t::missionData_t::installation, INTERESTCATEGORY_ALIENBASE, INTERESTCATEGORY_BASE_ATTACK, INTERESTCATEGORY_BUILDING, INTERESTCATEGORY_INTERCEPT, INTERESTCATEGORY_RESCUE, INTERESTCATEGORY_SUPPLY, INTERESTCATEGORY_TERROR_ATTACK, LIST_Add(), mission_t::mapDef, MIS_Foreach, base_t::name, name, OBJZERO, mission_t::onGeoscape, mission_t::onlose, mission_t::onwin, mission_t::pos, mission_t::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, mission_t::stage, STAGE_BASE_ATTACK, STAGE_BUILD_BASE, STAGE_INTERCEPT, STAGE_MISSION_GOTO, STAGE_TERROR_MISSION, mission_t::startDate, and xmlNode_t.

Referenced by SAV_Init().

◆ MIS_SaveXML()

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_t::active, mission_t::missionData_t::aircraft, mission_t::missionData_t::alienBase, mission_t::missionData_t::base, mission_t::category, cgi, mission_t::crashed, mission_t::data, mission_t::finalDate, DateTime::getDateAsDays(), DateTime::getTimeAsSeconds(), mapDef_t::id, mission_t::id, aircraft_t::idx, alienBase_t::idx, base_t::idx, installation_t::idx, mission_t::idx, mission_t::initialIndividualInterest, mission_t::initialOverallInterest, mission_t::missionData_t::installation, INTERESTCATEGORY_ALIENBASE, INTERESTCATEGORY_BASE_ATTACK, INTERESTCATEGORY_BUILDING, INTERESTCATEGORY_INTERCEPT, INTERESTCATEGORY_RESCUE, INTERESTCATEGORY_SUPPLY, mission_t::mapDef, MIS_Foreach, mission_t::onGeoscape, mission_t::onlose, mission_t::onwin, mission_t::pos, mission_t::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, mission_t::stage, STAGE_BASE_ATTACK, STAGE_INTERCEPT, STAGE_MISSION_GOTO, mission_t::startDate, and xmlNode_t.

Referenced by SAV_Init().

◆ MIS_Shutdown()

void MIS_Shutdown ( void )

Closing actions for missions-subsystem.

Definition at line 2235 of file cp_missions.cpp.

References ccs, cgi, debugMissionCmds, and MIS_ShutdownCallbacks().

Referenced by CP_Shutdown().

Variable Documentation

◆ debugMissionCmds

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

Definition at line 2212 of file cp_missions.cpp.

Referenced by MIS_InitStartup(), and MIS_Shutdown().

◆ MAX_CRASHEDUFO_CONDITION

const float MAX_CRASHEDUFO_CONDITION = 0.81f
static

Definition at line 66 of file cp_missions.cpp.

Referenced by CP_CreateBattleParameters().

◆ MAX_POS_LOOP

const int MAX_POS_LOOP = 10

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

Definition at line 62 of file cp_missions.cpp.

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

◆ MIN_CRASHEDUFO_CONDITION

const float MIN_CRASHEDUFO_CONDITION = 0.2f
static

Condition limits for crashed UFOs - used for disassemlies

Definition at line 65 of file cp_missions.cpp.

Referenced by CP_CreateBattleParameters().