25 #include "../../cl_shared.h"
52 assert(lastUFO < endOfUFOs);
72 ||
cgi->Cvar_GetInteger(
"debug_showufos")
117 cgi->Com_Error(
ERR_DROP,
"No ufo with type %i found", type);
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;
284 Vector2Set(dest, pos[0] + rand1, pos[1] + rand2);
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--) {
651 static void UFO_DestroyUFOs_f (
void)
665 static void UFO_ListOnGeoscape_f (
void)
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");
745 if (ufoTemplate ==
nullptr)
779 if (ufoTemplate ==
nullptr)
820 const ptrdiff_t num = (ptrdiff_t) (ufo -
ccs.
ufos);
831 static 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}
1014 cgi->Cmd_TableAddList(ufoDebugCallbacks);
1026 cgi->Cmd_TableRemoveList(ufoDebugCallbacks);
aircraft_t ufos[MAX_UFOONGEOSCAPE]
void GEO_UpdateGeoscapeDock(void)
Will add missions and UFOs to the geoscape dock panel.
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT
int UFO_GetOneAvailableUFOForMission(const interestCategory_t missionType, bool checkInterest)
Get a suitable UFO for the mission type.
#define MAX_UFOONGEOSCAPE
void UFO_InitCallbacks(void)
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 UFO_SetRandomDest(aircraft_t *ufocraft)
Give a random destination to the given UFO, and make him to move there.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
A installation with all it's data.
QGL_EXTERN GLint GLenum type
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
bool CP_CheckNextStageDestination(const campaign_t *campaign, aircraft_t *ufocraft)
Check if a stage mission is over when UFO reached destination.
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...
static const cmdList_t ufoDebugCallbacks[]
aircraft_t * UFO_GetNext(aircraft_t *lastUFO)
Iterates through the UFOs.
void AII_UpdateAircraftStats(aircraft_t *aircraft)
Update the value of stats array of an aircraft.
static void UFO_SetRandomPos(aircraft_t *ufocraft)
Give a random position to the given UFO.
void UFO_CampaignRunUFOs(const campaign_t *campaign, int deltaTime)
Make the UFOs run.
bool UFO_IsUFOSeenOnGeoscape(const aircraft_t *ufo)
Check if an aircraft should be seen on geoscape.
void GEO_NotifyUFODisappear(const aircraft_t *ufo)
Notify that a UFO disappears on radars.
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.
#define REMOVE_ELEM_ADJUST_IDX(array, index, n)
ufoType_t getUfoType() const
static void UFO_UpdateAlienInterestForOneInstallation(const aircraft_t *ufo, installation_t *installation)
Update alien interest for one PHALANX installation (radar tower, SAM, ...)
aircraft_t * UFO_AddToGeoscape(ufoType_t ufoType, const vec2_t destination, mission_t *mission)
Add a UFO to geoscape.
bool GEO_IsRadarOverlayActivated(void)
const char * UFO_GetName(const aircraft_t *ufocraft)
Returns name of the UFO if UFO has been researched.
aircraft_t * UFO_GetNextOnGeoscape(aircraft_t *lastUFO)
void UFO_Shutdown(void)
Closing actions for ufo-subsystem.
void AIRFIGHT_ExecuteActions(const campaign_t *campaign, aircraft_t *shooter, aircraft_t *target)
Decide what an attacking aircraft can do.
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...
struct mission_s * mission
A base with all it's data.
const linkedList_t *IMPORT * LIST_ContainsString(const linkedList_t *list, const char *string)
linkedList_t * missionTypes
bool UFO_SendPursuingAircraft(aircraft_t *ufo, aircraft_t *aircraft)
Make the specified UFO pursue a phalanx aircraft.
struct technology_s * tech
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.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void AII_ReloadAircraftWeapons(aircraft_t *aircraft)
Reload the weapons of an aircraft.
bool UFO_CanDoMission(const ufoType_t uType, const char *mType)
Check if the UFO type is available for the given mission type.
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.
const aircraft_t * UFO_GetTemplate(ufoType_t ufoType)
Get the template data for the given ufo type.
int UFO_GetAvailableUFOsForMission(const interestCategory_t missionType, ufoType_t *ufoTypes, bool checkInterest)
Fill an array with available UFOs for the mission type.
const aircraft_t * UFO_GetByType(const ufoType_t type)
Get the aircraft template for a given UFO type.
#define Vector2Set(v, x, y)
static int UFO_IsTargetOfInstallation(const aircraft_t *ufo, const installation_t *installation)
Check if a UFO is the target of an installation.
Campaign missions headers.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
const cgame_import_t * cgi
void UFO_NotifyPhalanxAircraftRemoved(const aircraft_t *const aircraft)
Notify to UFOs that a Phalanx aircraft has been destroyed.
const char *IMPORT * Com_UFOTypeToShortName(ufoType_t type)
struct aircraft_s * aircraftTarget
const char * UFO_TypeToName(const ufoType_t type)
Translate UFO type to name.
This is the technology parsed from research.ufo.
int ufoInterestOnGeoscape
static const aircraft_t * UFO_GetTemplateForGeoscape(ufoType_t ufoType)
Get the template data for the given ufo type.
aircraft_t * UFO_CreateFromTemplate(const aircraft_t *ufoTemplate)
Creates a new ufo on the geoscape from the given aircraft template.
static int UFO_IsTargetOfBase(const aircraft_t *ufo, const base_t *base)
Check if a UFO is the target of a base.
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)...
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
bool UFO_CampaignCheckEvents(void)
Check events for UFOs: Appears or disappears on radars.
aircraft_t aircraftTemplates[MAX_AIRCRAFT]
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
Header for Geoscape management.
cvar_t *IMPORT * Cvar_Get(const char *varName, const char *value, int flags, const char *desc)
QGL_EXTERN GLenum GLuint * dest
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.
union mission_s::missionData_t data
baseWeapon_t batteries[MAX_BASE_SLOT]
vec2_t point[LINE_MAXPTS]
void gaussrand(float *gauss1, float *gauss2)
generate two gaussian distributed random numbers with median at 0 and stdev of 1
aircraft_t * UFO_GetByIDX(const int idx)
returns the UFO on the geoscape with a certain index
static void UFO_UpdateAlienInterestForOneBase(const aircraft_t *ufo, base_t *base)
Update alien interest for one PHALANX base.
void UFO_UpdateAlienInterestForAllBasesAndInstallations(void)
Update alien interest for all PHALANX bases.
enum interestCategory_s interestCategory_t
void CP_GetRandomPosOnGeoscape(vec2_t pos, bool noWater)
Determines a random position on geoscape.
Header file for aircraft stuff.
void UFO_ShutdownCallbacks(void)
#define AIR_IsUFO(aircraft)
Header for slot management related stuff.
Header file for menu related console command callbacks.
void GEO_CheckPositionBoundaries(float *pos)
Check that a position (in latitude / longitude) is within boundaries.
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...
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.
void UFO_DetectNewUFO(aircraft_t *ufocraft)
Perform actions when a new UFO is detected.
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
#define Vector2Copy(src, dest)
Header file for single player campaign control.
void AIRFIGHT_ActionsAfterAirfight(const campaign_t *campaign, aircraft_t *shooter, aircraft_t *aircraft, bool phalanxWon)
Actions to execute when a fight is done.
void UFO_SendToDestination(aircraft_t *ufo, const vec2_t dest)
Make the specified UFO go to destination.
baseWeapon_t lasers[MAX_BASE_SLOT]
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
#define AIR_Foreach(var)
iterates trough all aircraft
An aircraft with all it's data.
void UFO_InitStartup(void)
Init actions for ufo-subsystem.
const technology_t * UFO_GetTechnologyFromType(const ufoType_t type)
Get the technology for a given UFO type.
void GEO_SetOverlay(const char *overlayID, int status)
Turn overlay on/off.
void UFO_RemoveFromGeoscape(aircraft_t *ufo)
Remove the specified ufo from geoscape.
bool UFO_ShouldAppearOnGeoscape(const ufoType_t type)
Some UFOs may only appear if after some interest level in the current running campaign is reached...
static const float MAX_DETECTING_RANGE
baseWeapon_t batteries[MAX_INSTALLATION_BATTERIES]
void UFO_CheckShootBack(const campaign_t *campaign, aircraft_t *ufo, aircraft_t *phalanxAircraft)
Check if the ufo can shoot back at phalanx aircraft.
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
bool AIR_AircraftMakeMove(int dt, aircraft_t *aircraft)
Moves given aircraft.
void RADAR_DeactivateRadarOverlay(void)
Deactivate Radar overlay if there is no more UFO on geoscape.