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

Campaign missions headers. More...

#include "../../DateTime.h"
#include "cp_campaign.h"
Include dependency graph for cp_missions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  missionResults_t
 Structure with mission info needed to create results summary at menu won. More...
struct  mission_t
 mission definition More...
union  mission_t::missionData_t

Macros

#define MIS_Foreach(var)
 iterates through missions

Enumerations

enum  missionStage_t {
  STAGE_NOT_ACTIVE , STAGE_COME_FROM_ORBIT , STAGE_RECON_AIR , STAGE_MISSION_GOTO ,
  STAGE_RECON_GROUND , STAGE_TERROR_MISSION , STAGE_BUILD_BASE , STAGE_BASE_ATTACK ,
  STAGE_SUBVERT_GOV , STAGE_SUPPLY , STAGE_SPREAD_XVI , STAGE_INTERCEPT ,
  STAGE_BASE_DISCOVERED , STAGE_HARVEST , STAGE_RETURN_TO_ORBIT , STAGE_OVER
}
enum  missionState_t { WON , DRAW , LOST }

Functions

const char * MIS_GetName (const mission_t *mission)
 Returns a short translated name for a mission.
void BATTLE_SetVars (const battleParam_t *battleParameters)
 Set some needed cvars from a battle definition.
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.
void BATTLE_Start (mission_t *mission, const battleParam_t *battleParameters)
 Select the mission type and start the map from mission definition.
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.
int MIS_GetIdx (const mission_t *mis)
 Find idx corresponding to mission.
mission_tMIS_GetByIdx (int id)
 Find mission corresponding to idx.
mission_tCP_CreateNewMission (interestCategory_t category, bool beginNow)
 Create a new mission of given category.
void CP_UFOProceedMission (const struct campaign_s *campaign, struct aircraft_s *ufocraft)
void CP_MissionRemove (mission_t *mission)
 Removes a mission from mission global array.
bool CP_MissionBegin (mission_t *mission)
 mission begins: UFO arrive on earth.
bool CP_CheckNewMissionDetectedOnGeoscape (void)
 Check if mission has been detected by radar.
bool CP_CheckMissionLimitedInTime (const mission_t *mission)
 Check if mission should end because of limited time.
void CP_MissionDisableTimeLimit (mission_t *mission)
 Disable time limit for given mission.
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.
const char * MIS_GetModel (const mission_t *mission)
 Get mission model that should be shown on the geoscape.
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_UFORemoveFromGeoscape (mission_t *mission, bool destroyed)
 Removes (temporarily or permanently) a UFO from geoscape: make it land and call notify functions.
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.
ufoType_t CP_MissionChooseUFO (const mission_t *mission)
 Choose UFO type for a given mission category.
void CP_MissionStageEnd (const campaign_t *campaign, mission_t *mission)
 Determine what action should be performed when a mission stage ends.
void CP_InitializeSpawningDelay (void)
 Initialize spawning delay.
void CP_SpawnNewMissions (void)
 Spawn new missions.
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_MissionEnd (const campaign_t *campaign, mission_t *mission, const battleParam_t *battleParameters, bool won)
 Closing actions after fighting a battle.
void CP_MissionEndActions (mission_t *mission, aircraft_t *aircraft, bool won)
 Actions to be done after mission finished.
bool CP_ChooseMap (mission_t *mission, const vec2_t pos)
 Choose a map for given mission.
bool CP_CheckNextStageDestination (const struct campaign_s *campaign, struct aircraft_s *ufo)
int CP_CountMissionOnGeoscape (void)
 Count the number of mission active and displayed on geoscape.
void CP_UpdateMissionVisibleOnGeoscape (void)
 Update all mission visible on geoscape (in base radar range).
void MIS_InitStartup (void)
 Init actions for missions-subsystem.
void MIS_Shutdown (void)
 Closing actions for missions-subsystem.

Variables

const int MAX_POS_LOOP

Detailed Description

Campaign missions headers.

Definition in file cp_missions.h.

Macro Definition Documentation

◆ MIS_Foreach

Enumeration Type Documentation

◆ missionStage_t

possible stage for campaign missions (i.e. possible actions for UFO)

Enumerator
STAGE_NOT_ACTIVE 

mission did not begin yet

STAGE_COME_FROM_ORBIT 

UFO is arriving

STAGE_RECON_AIR 

Aerial Recon

STAGE_MISSION_GOTO 

Going to a new position

STAGE_RECON_GROUND 

Ground Recon

STAGE_TERROR_MISSION 

Terror mission

STAGE_BUILD_BASE 

Building a base

STAGE_BASE_ATTACK 

Base attack

STAGE_SUBVERT_GOV 

Subvert government

STAGE_SUPPLY 

Supply already existing base

STAGE_SPREAD_XVI 

Spreading XVI Virus

STAGE_INTERCEPT 

UFO attacks any encountered PHALANX aircraft or attack an installation

STAGE_BASE_DISCOVERED 

PHALANX discovered the base

STAGE_HARVEST 

Harvesting

STAGE_RETURN_TO_ORBIT 

UFO is going back to base

STAGE_OVER 

Mission is over

Definition at line 34 of file cp_missions.h.

◆ missionState_t

Enumerator
WON 
DRAW 
LOST 

Definition at line 56 of file cp_missions.h.

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_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 struct campaign_s * campaign,
struct aircraft_s * ufo )

◆ 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_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_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_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_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 struct campaign_s * campaign,
struct aircraft_s * ufocraft )

◆ 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_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_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

◆ MAX_POS_LOOP

const int MAX_POS_LOOP
extern

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