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;
98 base.
idx =
ccs.campaignStats.alienBasesBuilt++;
111 cgi->LIST_Remove(&
ccs.alienBases, (
void*)base);
126 if (base->idx == baseIDX)
141 if (mission->data.alienBase == alienBase)
147 cgi->Com_Printf(
"CP_SpawnAlienBaseMission: Could not add mission, abort\n");
180 float probability = 0.0001f;
181 const float radarratio = 0.4f;
182 const float decreasingFactor = 5.0f;
190 if (distance > aircraft->
radar.range)
194 probability *= base->
supply;
197 if (distance > aircraft->
radar.range * radarratio)
198 probability /= decreasingFactor;
221 while ((base =
B_GetNext(base)) !=
nullptr) {
240 const int daysPerWeek = 7;
241 float probability = 1.0f;
242 const float xviLevel = 20.0f;
246 if (
ccs.date.getDateAsDays() % daysPerWeek)
260 probability *= base->supply;
262 base->stealth -= probability;
263 if (base->stealth < 0) {
264 base->stealth = -10.0f;
287 if (baseCount <= 0) {
288 cgi->Com_Printf(
"AB_ChooseBaseToSupply: no bases exists (basecount: %d)\n", baseCount);
292 const int selected = rand() % baseCount;
310 const float decreasedStealthValue = 5.0f;
315 if (decreaseStealth && base->
stealth >= 0.0f)
316 base->
stealth -= decreasedStealthValue;
325 return cgi->LIST_Count(
ccs.alienBases);
332static void AB_AlienBaseDiscovered_f (
void)
335 base->stealth = -10.0f;
344static void AB_AlienBaseList_f (
void)
347 cgi->Com_Printf(
"Alien Base: %i\n", base->idx);
348 cgi->Com_Printf(
"...pos: (%f, %f)\n", base->pos[0], base->pos[1]);
349 cgi->Com_Printf(
"...supply: %i\n", base->supply);
350 if (base->stealth < 0)
351 cgi->Com_Printf(
"...base discovered\n");
353 cgi->Com_Printf(
"...stealth: %f\n", base->stealth);
377 cgi->Com_Printf(
"Invalid or no IDX defined for Alienbase %d.\n",
i);
381 cgi->Com_Printf(
"Position is invalid for Alienbase (idx %d)\n", base.
idx);
414 {
"debug_listalienbase", AB_AlienBaseList_f,
"Print Alien Bases information to game console"},
415 {
"debug_alienbasevisible", AB_AlienBaseDiscovered_f,
"Set all alien bases to discovered"},
417 {
nullptr,
nullptr,
nullptr}
433 cgi->LIST_Delete(&
ccs.alienBases);
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
Share stuff between the different cgame implementations.
bool AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft)
Checks whether given aircraft is on geoscape.
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
@ INTERESTCATEGORY_ALIENBASE
@ INTERESTCATEGORY_SUPPLY
bool AB_CheckSupplyMissionPossible(void)
Check if a supply mission is possible.
void AB_SupplyBase(alienBase_t *base, bool decreaseStealth)
Supply a base.
int AB_GetAlienBaseNumber(void)
Check number of alien bases.
void AB_SetAlienBasePosition(vec2_t pos)
Set new base position.
void CP_SpawnAlienBaseMission(alienBase_t *alienBase)
Spawn a new alien base mission after it has been discovered.
bool AB_SaveXML(xmlNode_t *p)
Save callback for alien base data.
void AB_InitStartup(void)
Init actions for alienbase-subsystem.
void AB_DestroyBase(alienBase_t *base)
Destroy an alien base.
void AB_Shutdown(void)
Closing actions for alienbase-subsystem.
static void AB_UpdateStealthForOneBase(const aircraft_t *aircraft, alienBase_t *base)
Update stealth value of one alien base due to one aircraft.
static const cmdList_t debugAlienBaseCmds[]
void AB_UpdateStealthForAllBase(void)
Update stealth value of every base for every aircraft.
alienBase_t * AB_ChooseBaseToSupply(void)
Choose Alien Base that should be supplied.
alienBase_t * AB_BuildBase(const vec2_t pos)
Build a new alien base.
void AB_BaseSearchedByNations(void)
Nations help in searching alien base.
bool AB_LoadXML(xmlNode_t *p)
Load callback for alien base data.
alienBase_t * AB_GetByIDX(int baseIDX)
Get Alien Base per Idx.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
Header file for single player campaign control.
const cgame_import_t * cgi
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
nation_t * GEO_GetNation(const vec2_t pos)
Translate nation map color to nation.
base_t * GEO_PositionCloseToBase(const vec2_t pos)
Check if given pos is close to an existing base.
void CP_GetRandomPosOnGeoscape(vec2_t pos, bool noWater)
Determines a random position on geoscape.
Header for Geoscape management.
mission_t * CP_CreateNewMission(interestCategory_t category, bool beginNow)
Create a new mission of given category.
void CP_MissionAddToGeoscape(mission_t *mission, bool force)
Add a mission to geoscape: make it visible and stop time.
void CP_MissionDisableTimeLimit(mission_t *mission)
Disable time limit for given mission.
Campaign missions headers.
#define MIS_Foreach(var)
iterates through missions
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
XML tag constants for savegame.
#define SAVE_ALIENBASE_ALIENBASES
#define SAVE_ALIENBASE_IDX
#define SAVE_ALIENBASE_STEALTH
#define SAVE_ALIENBASE_SUPPLY
#define SAVE_ALIENBASE_POS
#define SAVE_ALIENBASE_BASE
An aircraft with all it's data.
A base with all it's data.
union mission_t::missionData_t data
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
#define Vector2Copy(src, dest)