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

Alien base related functions. More...

#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_alienbase.h"
#include "cp_geoscape.h"
#include "cp_missions.h"
#include "save/save_alienbase.h"

Go to the source code of this file.

Macros

#define MAPDEF_ALIENBASE   "alienbase"
 

Functions

void AB_SetAlienBasePosition (vec2_t pos)
 Set new base position. More...
 
alienBase_tAB_BuildBase (const vec2_t pos)
 Build a new alien base. More...
 
void AB_DestroyBase (alienBase_t *base)
 Destroy an alien base. More...
 
alienBase_tAB_GetByIDX (int baseIDX)
 Get Alien Base per Idx. More...
 
void CP_SpawnAlienBaseMission (alienBase_t *alienBase)
 Spawn a new alien base mission after it has been discovered. More...
 
static void AB_UpdateStealthForOneBase (const aircraft_t *aircraft, alienBase_t *base)
 Update stealth value of one alien base due to one aircraft. More...
 
void AB_UpdateStealthForAllBase (void)
 Update stealth value of every base for every aircraft. More...
 
void AB_BaseSearchedByNations (void)
 Nations help in searching alien base. More...
 
bool AB_CheckSupplyMissionPossible (void)
 Check if a supply mission is possible. More...
 
alienBase_tAB_ChooseBaseToSupply (void)
 Choose Alien Base that should be supplied. More...
 
void AB_SupplyBase (alienBase_t *base, bool decreaseStealth)
 Supply a base. More...
 
int AB_GetAlienBaseNumber (void)
 Check number of alien bases. More...
 
bool AB_LoadXML (xmlNode_t *p)
 Load callback for alien base data. More...
 
bool AB_SaveXML (xmlNode_t *p)
 Save callback for alien base data. More...
 
void AB_InitStartup (void)
 Init actions for alienbase-subsystem. More...
 
void AB_Shutdown (void)
 Closing actions for alienbase-subsystem. More...
 

Variables

static const cmdList_t debugAlienBaseCmds []
 

Detailed Description

Alien base related functions.

Definition in file cp_alienbase.cpp.

Macro Definition Documentation

#define MAPDEF_ALIENBASE   "alienbase"

Definition at line 32 of file cp_alienbase.cpp.

Referenced by CP_SpawnAlienBaseMission().

Function Documentation

void AB_BaseSearchedByNations ( void  )

Nations help in searching alien base.

Note
called once per day, but will update stealth only every daysPerWeek day
See also
CP_CampaignRun

< delay (in days) between base stealth update

< base probability, will be modified below

< xviInfection value of nation that will divide probability to find alien base by 2

Definition at line 232 of file cp_alienbase.cpp.

References AB_Foreach, ccs, ccs_s::date, date_s::day, GEO_GetNation(), NAT_GetCurrentMonthInfo(), and nationInfo_s::xviInfection.

Referenced by CP_CampaignRun().

alienBase_t* AB_BuildBase ( const vec2_t  pos)

Build a new alien base.

Parameters
[in]posPosition of the new base.
Returns
Pointer to the base that has been built.

< How hard PHALANX will find the base

Definition at line 90 of file cp_alienbase.cpp.

References ccs_s::alienBases, stats_s::alienBasesBuilt, ccs_s::campaignStats, ccs, alienBase_s::idx, LIST_Add(), OBJZERO, alienBase_s::pos, alienBase_s::stealth, and Vector2Copy.

Referenced by CP_BuildBaseSetUpBase().

bool AB_CheckSupplyMissionPossible ( void  )

Check if a supply mission is possible.

Returns
True if there is at least one base to supply.

Definition at line 264 of file cp_alienbase.cpp.

References AB_Exists.

Referenced by CP_SupplyGoToBase(), CP_SupplyMissionCreate(), and CP_SupplySetStayAtBase().

alienBase_t* AB_ChooseBaseToSupply ( void  )

Choose Alien Base that should be supplied.

Returns
Pointer to the base.

Definition at line 273 of file cp_alienbase.cpp.

References AB_Foreach, AB_GetAlienBaseNumber(), cgi, and i.

Referenced by CP_SupplyGoToBase().

void AB_DestroyBase ( alienBase_t base)

Destroy an alien base.

Parameters
[in]basePointer to the alien base.

Definition at line 107 of file cp_alienbase.cpp.

References AB_Exists, ccs_s::alienBases, ccs, cgi, ccs_s::interest, and INTERESTCATEGORY_SUPPLY.

Referenced by CP_BuildBaseMissionBaseDestroyed().

int AB_GetAlienBaseNumber ( void  )

Check number of alien bases.

Returns
number of alien bases.

Definition at line 313 of file cp_alienbase.cpp.

References ccs_s::alienBases, ccs, and cgi.

Referenced by AB_ChooseBaseToSupply(), CP_ReconMissionIsSuccess(), and CP_SpawnNewMissions().

alienBase_t* AB_GetByIDX ( int  baseIDX)

Get Alien Base per Idx.

Parameters
[in]baseIDXThe unique IDX of the alien Base.
Returns
Pointer to the base.

Definition at line 123 of file cp_alienbase.cpp.

References AB_Foreach.

Referenced by MIS_LoadXML().

void AB_InitStartup ( void  )

Init actions for alienbase-subsystem.

See also
UI_InitStartup

Definition at line 413 of file cp_alienbase.cpp.

References cgi.

Referenced by CP_InitStartup().

bool AB_LoadXML ( xmlNode_t p)
bool AB_SaveXML ( xmlNode_t p)

Save callback for alien base data.

Parameters
[out]pXML Node structure, where we write the information to
See also
AB_LoadXML

Definition at line 387 of file cp_alienbase.cpp.

References AB_Foreach, cgi, SAVE_ALIENBASE_ALIENBASES, SAVE_ALIENBASE_BASE, SAVE_ALIENBASE_IDX, SAVE_ALIENBASE_POS, SAVE_ALIENBASE_STEALTH, SAVE_ALIENBASE_SUPPLY, cgame_import_s::XML_AddNode(), and xmlNode_t.

Referenced by SAV_Init().

void AB_SetAlienBasePosition ( vec2_t  pos)

Set new base position.

Parameters
[out]posPosition of the new base.
Note
This function generates maxLoopPosition random positions, and select among those the one that is the farthest from every other alien bases. This is intended to get a rather uniform distribution of alien bases, while still keeping a random base localisation.

< distance between current selected alien base

< Number of random position among which the final one will be selected

Definition at line 41 of file cp_alienbase.cpp.

References AB_Exists, AB_Foreach, CP_GetRandomPosOnGeoscape(), GEO_PositionCloseToBase(), GetDistanceOnGlobe(), and Vector2Copy.

Referenced by CP_BuildBaseGoToBase().

void AB_Shutdown ( void  )

Closing actions for alienbase-subsystem.

Definition at line 421 of file cp_alienbase.cpp.

References ccs_s::alienBases, ccs, and cgi.

Referenced by CP_Shutdown().

void AB_SupplyBase ( alienBase_t base,
bool  decreaseStealth 
)

Supply a base.

Parameters
[in]basePointer to the supplied base.
[in]decreaseStealthIf the stealth level of the base should be decreased.

< How much stealth is reduced because Supply UFO was seen

Definition at line 298 of file cp_alienbase.cpp.

References alienBase_s::stealth, and alienBase_s::supply.

Referenced by CP_SupplySetStayAtBase().

void AB_UpdateStealthForAllBase ( void  )

Update stealth value of every base for every aircraft.

Note
Called every DETECTION_INTERVAL
See also
CP_CampaignRun
UFO_UpdateAlienInterestForOneBase

Definition at line 212 of file cp_alienbase.cpp.

References AB_Foreach, AB_UpdateStealthForOneBase(), AIR_ForeachFromBase, AIR_IsAircraftOnGeoscape(), and B_GetNext().

Referenced by CP_CampaignFunctionPeriodicCall().

static void AB_UpdateStealthForOneBase ( const aircraft_t aircraft,
alienBase_t base 
)
static

Update stealth value of one alien base due to one aircraft.

Parameters
[in]aircraftPointer to the aircraft_t.
[in]basePointer to the alien base.
Note
base stealth decreases if it is inside an aircraft radar range, and even more if it's inside radarratio times radar range.
See also
UFO_UpdateAlienInterestForOneBase

< base probability, will be modified below

< stealth decreases faster if base is inside radarratio times radar range

< factor applied when outside radarratio times radar range

Definition at line 171 of file cp_alienbase.cpp.

References CP_SpawnAlienBaseMission(), DETECTION_INTERVAL, GetDistanceOnGlobe(), alienBase_s::pos, aircraft_s::pos, aircraft_s::radar, radar_s::range, alienBase_s::stealth, and alienBase_s::supply.

Referenced by AB_UpdateStealthForAllBase().

Variable Documentation

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

Definition at line 402 of file cp_alienbase.cpp.