25 #include "../../cl_shared.h"
32 #define MAPDEF_ALIENBASE "alienbase"
45 float minDistance = 0.0f;
46 const int maxLoopPosition = 6;
49 while (counter < maxLoopPosition) {
50 float distance = 0.0f;
68 if (distance < currentDistance) {
69 distance = currentDistance;
74 if (minDistance < distance) {
76 minDistance = distance;
81 if (counter == maxLoopPosition)
93 const float initialStealthValue = 50.0f;
97 base.
stealth = initialStealthValue;
126 if (base->idx == baseIDX)
141 cgi->Com_Printf(
"CP_SpawnAlienBaseMission: Could not add mission, abort\n");
174 float probability = 0.0001f;
175 const float radarratio = 0.4f;
176 const float decreasingFactor = 5.0f;
188 probability *= base->
supply;
191 if (distance > aircraft->
radar.
range * radarratio)
192 probability /= decreasingFactor;
215 while ((base =
B_GetNext(base)) !=
nullptr) {
234 const int daysPerWeek = 7;
235 float probability = 1.0f;
236 const float xviLevel = 20.0f;
254 probability *= base->supply;
256 base->stealth -= probability;
277 if (baseCount <= 0) {
278 cgi->Com_Printf(
"AB_ChooseBaseToSupply: no bases exists (basecount: %d)\n", baseCount);
282 const int selected = rand() % baseCount;
300 const float decreasedStealthValue = 5.0f;
305 if (decreaseStealth && base->
stealth >= 0.0f)
306 base->
stealth -= decreasedStealthValue;
322 static void AB_AlienBaseDiscovered_f (
void)
325 base->stealth = -10.0f;
334 static void AB_AlienBaseList_f (
void)
337 cgi->Com_Printf(
"Alien Base: %i\n", base->idx);
338 cgi->Com_Printf(
"...pos: (%f, %f)\n", base->pos[0], base->pos[1]);
339 cgi->Com_Printf(
"...supply: %i\n", base->supply);
340 if (base->stealth < 0)
341 cgi->Com_Printf(
"...base discovered\n");
343 cgi->Com_Printf(
"...stealth: %f\n", base->stealth);
367 cgi->Com_Printf(
"Invalid or no IDX defined for Alienbase %d.\n", i);
371 cgi->Com_Printf(
"Position is invalid for Alienbase (idx %d)\n", base.
idx);
404 {
"debug_listalienbase", AB_AlienBaseList_f,
"Print Alien Bases information to game console"},
405 {
"debug_alienbasevisible", AB_AlienBaseDiscovered_f,
"Set all alien bases to discovered"},
407 {
nullptr,
nullptr,
nullptr}
415 cgi->Cmd_TableAddList(debugAlienBaseCmds);
425 cgi->Cmd_TableRemoveList(debugAlienBaseCmds);
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
void AB_Shutdown(void)
Closing actions for alienbase-subsystem.
void AB_SetAlienBasePosition(vec2_t pos)
Set new base position.
#define SAVE_ALIENBASE_STEALTH
void AB_BaseSearchedByNations(void)
Nations help in searching alien base.
static const cmdList_t debugAlienBaseCmds[]
#define SAVE_ALIENBASE_BASE
void AB_InitStartup(void)
Init actions for alienbase-subsystem.
int AB_GetAlienBaseNumber(void)
Check number of alien bases.
#define SAVE_ALIENBASE_SUPPLY
A base with all it's data.
bool AB_LoadXML(xmlNode_t *p)
Load callback for alien base data.
static void AB_UpdateStealthForOneBase(const aircraft_t *aircraft, alienBase_t *base)
Update stealth value of one alien base due to one aircraft.
#define SAVE_ALIENBASE_ALIENBASES
bool AB_CheckSupplyMissionPossible(void)
Check if a supply mission is possible.
alienBase_t * AB_ChooseBaseToSupply(void)
Choose Alien Base that should be supplied.
#define SAVE_ALIENBASE_POS
mapDef_t *IMPORT * Com_GetMapDefinitionByID(const char *mapDefID)
base_t * GEO_PositionCloseToBase(const vec2_t pos)
Check if given pos is close to an existing base.
Campaign missions headers.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
const cgame_import_t * cgi
void CP_MissionAddToGeoscape(mission_t *mission, bool force)
Add a mission to geoscape: make it visible and stop time.
XML tag constants for savegame.
void AB_UpdateStealthForAllBase(void)
Update stealth value of every base for every aircraft.
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
Header for Geoscape management.
bool AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft)
Checks whether given aircraft is on geoscape.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
union mission_s::missionData_t data
xmlNode_t *IMPORT * XML_GetPos2(xmlNode_t *parent, const char *name, vec2_t pos)
void CP_GetRandomPosOnGeoscape(vec2_t pos, bool noWater)
Determines a random position on geoscape.
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
alienBase_t * AB_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.
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
alienBase_t * AB_BuildBase(const vec2_t pos)
Build a new alien base.
#define Vector2Copy(src, dest)
Header file for single player campaign control.
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
void AB_SupplyBase(alienBase_t *base, bool decreaseStealth)
Supply a base.
An aircraft with all it's data.
linkedList_t * alienBases
void AB_DestroyBase(alienBase_t *base)
Destroy an alien base.
void CP_MissionDisableTimeLimit(mission_t *mission)
Disable time limit for given mission.
nation_t * GEO_GetNation(const vec2_t pos)
Translate nation map color to nation.
#define SAVE_ALIENBASE_IDX
bool AB_SaveXML(xmlNode_t *p)
Save callback for alien base data.
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
mission_t * CP_CreateNewMission(interestCategory_t category, bool beginNow)
Create a new mission of given category.
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
int interest[INTERESTCATEGORY_MAX]
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...