cp_alienbase.c File Reference

Alien base related functions. More...

#include "../cl_shared.h"
#include "cp_campaign.h"
#include "cp_alienbase.h"
#include "cp_map.h"
#include "cp_missions.h"
#include "save/save_alienbase.h"
Include dependency graph for cp_alienbase.c:

Go to the source code of this file.

Defines

#define MAPDEF_ALIENBASE   "alienbase"
#define ALIENBASE_DISCOVERED_TECH   "rs_alien_base_discovered_event"

Functions

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

Detailed Description

Alien base related functions.

Definition in file cp_alienbase.c.


Define Documentation

#define ALIENBASE_DISCOVERED_TECH   "rs_alien_base_discovered_event"

Definition at line 34 of file cp_alienbase.c.

Referenced by CP_SpawnAlienBaseMission().

#define MAPDEF_ALIENBASE   "alienbase"

Definition at line 33 of file cp_alienbase.c.

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:
CL_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 258 of file cp_alienbase.c.

References AB_GetNext(), ccs, ccs_s::date, date_s::day, MAP_GetNation(), alienBase_s::pos, nation_s::stats, alienBase_s::stealth, alienBase_s::supply, and nationInfo_s::xviInfection.

Referenced by CL_CampaignRun().

alienBase_t* AB_BuildBase ( const vec2_t  pos  ) 

Build a new alien base.

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

< How hard PHALANX will find the base

Definition at line 93 of file cp_alienbase.c.

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

Referenced by CP_BuildBaseSetUpBase().

qboolean AB_CheckSupplyMissionPossible ( void   ) 

Check if a supply mission is possible.

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

Definition at line 288 of file cp_alienbase.c.

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 297 of file cp_alienbase.c.

References AB_GetAlienBaseNumber(), and AB_GetByIDX().

Referenced by CP_SupplyGoToBase().

void AB_DestroyBase ( alienBase_t base  ) 

Destroy an alien base.

Parameters:
[in] base Pointer to the alien base.

Definition at line 110 of file cp_alienbase.c.

References AB_Exists, ccs_s::alienBases, ccs, ccs_s::interest, INTERESTCATEGORY_SUPPLY, and LIST_Remove().

Referenced by CP_BuildBaseMissionBaseDestroyed().

int AB_GetAlienBaseNumber ( void   ) 

Check number of alien bases.

Returns:
number of alien bases.

Definition at line 323 of file cp_alienbase.c.

References ccs_s::alienBases, ccs, and LIST_Count().

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

alienBase_t* AB_GetByIDX ( int  baseIDX  ) 

Get Alien Base per Idx.

Parameters:
[in] baseIDX The unique IDX of the alien Base.
Returns:
Pointer to the base.

Definition at line 135 of file cp_alienbase.c.

References AB_GetNext(), and alienBase_s::idx.

Referenced by AB_ChooseBaseToSupply(), and CP_LoadMissionsXML().

alienBase_t* AB_GetNext ( alienBase_t lastBase  ) 

Iterates through the alien bases.

Parameters:
[in] lastBase Pointer of the alien base to iterate from. call with NULL to get the first one.

Definition at line 125 of file cp_alienbase.c.

References ccs_s::alienBases, ccs, and LIST_GetNext().

Referenced by AB_BaseSearchedByNations(), AB_GetByIDX(), AB_SaveXML(), AB_SetAlienBasePosition(), and AB_UpdateStealthForAllBase().

void AB_InitStartup ( void   ) 
See also:
UI_InitStartup

Definition at line 365 of file cp_alienbase.c.

References Cmd_AddCommand().

Referenced by CP_InitStartup().

qboolean AB_LoadXML ( mxml_node_t p  ) 

Load callback for alien base data.

Parameters:
[in] p XML Node structure, where we get the information from
See also:
AB_SaveXML

<

Todo:
this is for old saves now only

Definition at line 378 of file cp_alienbase.c.

References ccs_s::alienBases, ccs, Com_Printf(), i, alienBase_s::idx, LIST_Add(), mxml_GetFloat(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetPos2(), alienBase_s::pos, qfalse, qtrue, SAVE_ALIENBASE_ALIENBASES, SAVE_ALIENBASE_BASE, SAVE_ALIENBASE_IDX, SAVE_ALIENBASE_POS, SAVE_ALIENBASE_STEALTH, SAVE_ALIENBASE_SUPPLY, alienBase_s::stealth, and alienBase_s::supply.

Referenced by SAV_Init().

qboolean AB_SaveXML ( mxml_node_t p  ) 
void AB_SetAlienBasePosition ( vec2_t  pos  ) 

Set new base position.

Parameters:
[out] pos Position 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 43 of file cp_alienbase.c.

References AB_Exists, AB_GetNext(), CP_GetRandomPosOnGeoscape(), GetDistanceOnGlobe(), MAP_PositionCloseToBase(), alienBase_s::pos, qtrue, and Vector2Copy.

Referenced by CP_BuildBaseGoToBase().

void AB_SupplyBase ( alienBase_t base,
qboolean  decreaseStealth 
)

Supply a base.

Parameters:
[in] base Pointer to the supplied base.
[in] decreaseStealth If the stealth level of the base should be decreased.

< How much stealth is reduced because Supply UFO was seen

Definition at line 308 of file cp_alienbase.c.

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:
CL_CampaignRun
UFO_UpdateAlienInterestForOneBase

Definition at line 231 of file cp_alienbase.c.

References AB_GetNext(), AB_UpdateStealthForOneBase(), AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), B_GetFoundedBaseByIDX(), and MAX_BASES.

Referenced by CL_CampaignFunctionPeriodicCall().

static void AB_UpdateStealthForOneBase ( const aircraft_t const *  aircraft,
alienBase_t base 
) [static]

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

Parameters:
[in] aircraft Pointer to the aircraft_t.
[in] base Pointer 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 190 of file cp_alienbase.c.

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

void CP_SpawnAlienBaseMission ( alienBase_t alienBase  ) 

Generated by  doxygen 1.6.2