51 assert(lastUFO >=
ccs.ufos);
52 assert(lastUFO < endOfUFOs);
72 ||
cgi->Cvar_GetInteger(
"debug_showufos")
88 return &
ccs.ufos[idx];
99 const char*
id =
cgi->Com_UFOTypeToShortName(
type);
111 for (
int i = 0;
i <
ccs.numAircraftTemplates;
i++) {
157 const short ufoIdsNum =
cgi->Com_GetUFOIdsNum();
158 for (
int i = 0;
i < ufoIdsNum;
i++) {
160 switch (missionType) {
205 ufoTypes[num++] = uType;
221 return numTypes ? ufoTypes[0] :
UFO_NONE;
235 return _(tech->
name);
236 cgi->Com_Error(
ERR_DROP,
"UFO_TypeToName(): Unknown UFO type %i\n",
type);
277 const float spread = 2.0f;
357 const float decreasingDistance = 10.0f;
359 const float decreasingFactor = 5.0f;
372 probability = 0.001f;
375 probability = 0.0001f;
380 if (distance > decreasingDistance)
381 probability /= decreasingFactor;
399 const float decreasingDistance = 10.0f;
401 const float decreasingFactor = 5.0f;
414 probability = 0.001f;
417 probability = 0.0001f;
422 if (distance > decreasingDistance)
423 probability /= decreasingFactor;
450 while ((base =
B_GetNext(base)) !=
nullptr)
463 float distance = 999999.;
490 if (dist > maxDetectionRange)
493 if (dist < distance) {
509 const float polarCoordinatesOffset = 1.0f;
516 dest[0] += polarCoordinatesOffset;
517 dest[1] += polarCoordinatesOffset;
604 for (
int ufoIdx =
ccs.numUFOs - 1; ufoIdx >= 0; ufoIdx--) {
627 if (ufoIdx ==
ccs.numUFOs)
651static void UFO_DestroyUFOs_f (
void)
656 for (ufo =
ccs.ufos; ufo <
ccs.ufos +
ccs.numUFOs; ufo++) {
665static void UFO_ListOnGeoscape_f (
void)
667 cgi->Com_Printf(
"There are %i UFOs in game\n",
ccs.numUFOs);
669 cgi->Com_Printf(
"..%s (%s) - status: %i - pos: %.0f:%0.f\n", ufo->
name, ufo->
id, ufo->
status, ufo->
pos[0], ufo->
pos[1]);
670 cgi->Com_Printf(
"...route length: %i (current: %i), time: %i, distance: %.2f, speed: %i\n",
672 cgi->Com_Printf(
"...linked to mission '%s'\n", ufo->
mission ? ufo->
mission->id :
"no mission");
673 cgi->Com_Printf(
"... UFO is %s and %s\n", ufo->
landed ?
"landed" :
"flying", ufo->
detected ?
"detected" :
"undetected");
674 cgi->Com_Printf(
"... damage: %i\n", ufo->
damage);
680 "(loaded)" :
"(unloaded)";
681 cgi->Com_Printf(
"%s %s / ", w->
item->
id, state);
683 cgi->Com_Printf(
"empty / ");
685 cgi->Com_Printf(
"\n");
699 for (newUFONum = 0; newUFONum <
ccs.numAircraftTemplates; newUFONum++) {
706 if (newUFONum ==
ccs.numAircraftTemplates)
709 return &
ccs.aircraftTemplates[newUFONum];
722 for (newUFONum = 0; newUFONum <
ccs.numAircraftTemplates; newUFONum++) {
729 if (newUFONum ==
ccs.numAircraftTemplates)
732 return &
ccs.aircraftTemplates[newUFONum];
745 if (ufoTemplate ==
nullptr)
779 if (ufoTemplate ==
nullptr)
820 const ptrdiff_t num = (ptrdiff_t) (ufo -
ccs.ufos);
831static void UFO_RemoveFromGeoscape_f (
void)
872 newDetection =
false;
878 float minDistance = -1;
881 bool detected =
false;
900 if (minDistance < 0 || minDistance > distance) {
901 minDistance = distance;
902 Q_strncpyz(detectedBy, aircraft->name,
sizeof(detectedBy));
909 while ((base =
B_GetNext(base)) !=
nullptr) {
917 if (minDistance < 0 || minDistance > distance) {
918 minDistance = distance;
931 if (minDistance < 0 || minDistance > distance) {
932 minDistance = distance;
933 Q_strncpyz(detectedBy, installation->name,
sizeof(detectedBy));
952 }
else if (!detected) {
976 for (
int ufoIdx = 0; ufoIdx <
ccs.numUFOs; ufoIdx++) {
994 cgi->Com_Error(
ERR_DROP,
"UFO_IsUFOSeenOnGeoscape: ufo %s can't be used on geoscape", ufo->
id);
1001 {
"debug_destroyufos", UFO_DestroyUFOs_f,
"Destroys all UFOs on the geoscape"},
1002 {
"debug_listufo", UFO_ListOnGeoscape_f,
"Print UFO information to game console"},
1003 {
"debug_removeufo", UFO_RemoveFromGeoscape_f,
"Remove a UFO from geoscape"},
1005 {
nullptr,
nullptr,
nullptr}
1016 cgi->Cvar_Get(
"debug_showufos",
"0",
CVAR_DEVELOPER,
"Show all UFOs on geoscape");
Share stuff between the different cgame implementations.
#define REMOVE_ELEM_ADJUST_IDX(array, index, n)
bool AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft)
Checks whether given aircraft is on geoscape.
void AIR_AircraftsUFODisappear(const aircraft_t *const ufo)
Notify that a UFO disappear from radars.
void AIR_GetDestinationWhilePursuing(const aircraft_t *shooter, const aircraft_t *target, vec2_t dest)
Calculates the point where aircraft should go to intecept a moving target.
bool AIR_AircraftMakeMove(int dt, aircraft_t *aircraft)
Moves given aircraft.
Header file for aircraft stuff.
#define AIR_Foreach(var)
iterates trough all aircraft
#define AIR_IsUFO(aircraft)
void AIRFIGHT_ExecuteActions(const campaign_t *campaign, aircraft_t *shooter, aircraft_t *target)
Decide what an attacking aircraft can do.
int AIRFIGHT_ChooseWeapon(const aircraftSlot_t *slot, int maxSlot, const vec2_t pos, const vec2_t targetPos)
Choose the weapon an attacking aircraft will use to fire on a target.
void AIRFIGHT_ActionsAfterAirfight(const campaign_t *campaign, aircraft_t *shooter, aircraft_t *aircraft, bool phalanxWon)
Actions to execute when a fight is done.
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT
@ INTERESTCATEGORY_BASE_ATTACK
@ INTERESTCATEGORY_INTERCEPTBOMBING
@ INTERESTCATEGORY_BUILDING
@ INTERESTCATEGORY_SUBVERT
@ INTERESTCATEGORY_SUPPLY
@ INTERESTCATEGORY_TERROR_ATTACK
@ INTERESTCATEGORY_INTERCEPT
@ INTERESTCATEGORY_HARVEST
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
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.
void GEO_SetOverlay(const char *overlayID, int status)
Turn overlay on/off.
bool GEO_IsRadarOverlayActivated(void)
void GEO_UpdateGeoscapeDock(void)
Will add missions and UFOs to the geoscape dock panel.
void GEO_CalcLine(const vec2_t start, const vec2_t end, mapline_t *line)
Calculate the shortest way to go from start to end on a sphere.
void CP_GetRandomPosOnGeoscape(vec2_t pos, bool noWater)
Determines a random position on geoscape.
void GEO_NotifyUFODisappear(const aircraft_t *ufo)
Notify that a UFO disappears on radars.
void GEO_CheckPositionBoundaries(float *pos)
Check that a position (in latitude / longitude) is within boundaries.
Header for Geoscape management.
void AII_ReloadAircraftWeapons(aircraft_t *aircraft)
Reload the weapons of an aircraft.
void AII_UpdateAircraftStats(aircraft_t *aircraft)
Update the value of stats array of an aircraft.
Header for slot management related stuff.
uiMessageListNodeMessage_t * MSO_CheckAddNewMessage(const notify_t messagecategory, const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup)
Adds a new message to message stack. It uses message settings to verify whether sound should be playe...
void CP_UFOProceedMission(const campaign_t *campaign, aircraft_t *ufo)
Make UFO proceed with its mission when the fight with another aircraft is over (and UFO survived).
bool CP_CheckNextStageDestination(const campaign_t *campaign, aircraft_t *ufocraft)
Check if a stage mission is over when UFO reached destination.
Campaign missions headers.
void RADAR_DeactivateRadarOverlay(void)
Deactivate Radar overlay if there is no more UFO on geoscape.
bool RADAR_CheckUFOSensored(radar_t *radar, const vec2_t posRadar, const aircraft_t *ufo, bool detected)
Check if the specified UFO is inside the sensor range of the given radar.
#define MAX_UFOONGEOSCAPE
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
void UFO_NotifyPhalanxAircraftRemoved(const aircraft_t *const aircraft)
Notify to UFOs that a Phalanx aircraft has been destroyed.
static const float MAX_DETECTING_RANGE
aircraft_t * UFO_GetByIDX(const int idx)
returns the UFO on the geoscape with a certain index
void UFO_CampaignRunUFOs(const campaign_t *campaign, int deltaTime)
Make the UFOs run.
void UFO_SendToDestination(aircraft_t *ufo, const vec2_t dest)
Make the specified UFO go to destination.
void UFO_SetRandomDestAround(aircraft_t *ufocraft, const vec2_t pos)
Give a random destination to the given UFO close to a position, and make him to move there.
void UFO_CheckShootBack(const campaign_t *campaign, aircraft_t *ufo, aircraft_t *phalanxAircraft)
Check if the ufo can shoot back at phalanx aircraft.
static int UFO_IsTargetOfInstallation(const aircraft_t *ufo, const installation_t *installation)
Check if a UFO is the target of an installation.
int UFO_GetOneAvailableUFOForMission(const interestCategory_t missionType, bool checkInterest)
Get a suitable UFO for the mission type.
const char * UFO_TypeToName(const ufoType_t type)
Translate UFO type to name.
bool UFO_CampaignCheckEvents(void)
Check events for UFOs: Appears or disappears on radars.
const char * UFO_GetName(const aircraft_t *ufocraft)
Returns name of the UFO if UFO has been researched.
void UFO_InitStartup(void)
Init actions for ufo-subsystem.
static void UFO_UpdateAlienInterestForOneBase(const aircraft_t *ufo, base_t *base)
Update alien interest for one PHALANX base.
static const aircraft_t * UFO_GetTemplateForGeoscape(ufoType_t ufoType)
Get the template data for the given ufo type.
void UFO_DetectNewUFO(aircraft_t *ufocraft)
Perform actions when a new UFO is detected.
const aircraft_t * UFO_GetByType(const ufoType_t type)
Get the aircraft template for a given UFO type.
void UFO_UpdateAlienInterestForAllBasesAndInstallations(void)
Update alien interest for all PHALANX bases.
bool UFO_IsUFOSeenOnGeoscape(const aircraft_t *ufo)
Check if an aircraft should be seen on geoscape.
bool UFO_CanDoMission(const ufoType_t uType, const char *mType)
Check if the UFO type is available for the given mission type.
aircraft_t * UFO_AddToGeoscape(ufoType_t ufoType, const vec2_t destination, mission_t *mission)
Add a UFO to geoscape.
aircraft_t * UFO_CreateFromTemplate(const aircraft_t *ufoTemplate)
Creates a new ufo on the geoscape from the given aircraft template.
static void UFO_SearchAircraftTarget(const campaign_t *campaign, aircraft_t *ufo, float maxDetectionRange=MAX_DETECTING_RANGE)
Check if the ufo can shoot at a PHALANX aircraft and whether it should follow another ufo.
void UFO_Shutdown(void)
Closing actions for ufo-subsystem.
const technology_t * UFO_GetTechnologyFromType(const ufoType_t type)
Get the technology for a given UFO type.
void UFO_SetRandomDest(aircraft_t *ufocraft)
Give a random destination to the given UFO, and make him to move there.
bool UFO_ShouldAppearOnGeoscape(const ufoType_t type)
Some UFOs may only appear if after some interest level in the current running campaign is reached.
aircraft_t * UFO_GetNext(aircraft_t *lastUFO)
Iterates through the UFOs.
const aircraft_t * UFO_GetTemplate(ufoType_t ufoType)
Get the template data for the given ufo type.
static void UFO_SetRandomPos(aircraft_t *ufocraft)
Give a random position to the given UFO.
aircraft_t * UFO_GetNextOnGeoscape(aircraft_t *lastUFO)
static const cmdList_t ufoDebugCallbacks[]
static int UFO_IsTargetOfBase(const aircraft_t *ufo, const base_t *base)
Check if a UFO is the target of a base.
int UFO_GetAvailableUFOsForMission(const interestCategory_t missionType, ufoType_t *ufoTypes, bool checkInterest)
Fill an array with available UFOs for the mission type.
bool UFO_SendPursuingAircraft(aircraft_t *ufo, aircraft_t *aircraft)
Make the specified UFO pursue a phalanx aircraft.
void UFO_RemoveFromGeoscape(aircraft_t *ufo)
Remove the specified ufo from geoscape.
static void UFO_UpdateAlienInterestForOneInstallation(const aircraft_t *ufo, installation_t *installation)
Update alien interest for one PHALANX installation (radar tower, SAM, ...).
@ UFO_IS_TARGET_OF_MISSILE
void UFO_InitCallbacks(void)
void UFO_ShutdownCallbacks(void)
Header file for menu related console command callbacks.
void gaussrand(float *gauss1, float *gauss2)
generate two gaussian distributed random numbers with median at 0 and stdev of 1
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
QGL_EXTERN GLenum GLuint * dest
QGL_EXTERN GLint GLenum type
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
An aircraft with all it's data.
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
struct aircraft_s * aircraftTarget
int ufoInterestOnGeoscape
struct mission_s * mission
class DateTime lastSpotted
linkedList_t * missionTypes
ufoType_t getUfoType() const
struct technology_s * tech
A base with all it's data.
baseWeapon_t batteries[MAX_BASE_SLOT]
baseWeapon_t lasers[MAX_BASE_SLOT]
A installation with all it's data.
baseWeapon_t batteries[MAX_INSTALLATION_BATTERIES]
vec2_t point[LINE_MAXPTS]
This is the technology parsed from research.ufo.
#define Vector2Set(v, x, y)
#define Vector2Copy(src, dest)