cp_ufo.c File Reference

UFOs on geoscape. More...

#include "../cl_shared.h"
#include "cp_campaign.h"
#include "cp_map.h"
#include "cp_ufo.h"
#include "cp_aircraft.h"
#include "cp_mapfightequip.h"
Include dependency graph for cp_ufo.c:

Go to the source code of this file.

Functions

aircraft_tUFO_GetByIDX (const int idx)
 returns the UFO on the geoscape with a certain index
const technology_tUFO_GetTechnologyFromType (const ufoType_t type)
 Get the technology for a given UFO type.
const aircraft_tUFO_GetByType (const ufoType_t type)
 Get the aircraft template for a given UFO type.
qboolean UFO_ShouldAppearOnGeoscape (const ufoType_t type)
 Some UFOs may only appear if after some interest level in the current running campaign is reached.
const char * UFO_TypeToName (ufoType_t type)
 Translate UFO type to name.
const char * UFO_AircraftToIDOnGeoscape (const aircraft_t *ufocraft)
 Returns names of the UFO is UFO has been researched.
const char * UFO_MissionResultToString (void)
 Returns a status string for recovered ufo used to be displayed in uforecovery and mission result overview.
void UFO_SetRandomDest (aircraft_t *ufocraft)
 Give a random destination to the given UFO, and make him to move there.
void UFO_SetRandomDestAround (aircraft_t *ufocraft, vec2_t pos)
 Give a random destination to the given UFO close to a position, and make him to move there.
static void UFO_SetRandomPos (aircraft_t *ufocraft)
 Give a random position to the given UFO.
static int UFO_IsTargetOfBase (const aircraft_t const *ufo, const base_t const *base)
 Check if a UFO is the target of a base.
static int UFO_IsTargetOfInstallation (const aircraft_t const *ufo, const installation_t const *installation)
 Check if a UFO is the target of an installation.
static void UFO_UpdateAlienInterestForOneBase (const aircraft_t const *ufo, base_t *base)
 Update alien interest for one PHALANX base.
static void UFO_UpdateAlienInterestForOneInstallation (const aircraft_t const *ufo, installation_t *installation)
 Update alien interest for one PHALANX installation (radar tower, SAM, ...).
void UFO_UpdateAlienInterestForAllBasesAndInstallations (void)
 Update alien interest for all PHALANX bases.
static void UFO_SearchAircraftTarget (aircraft_t *ufo)
 Check if the ufo can shoot at a PHALANX aircraft.
qboolean UFO_SendPursuingAircraft (aircraft_t *ufo, aircraft_t *aircraft)
 Make the specified UFO pursue a phalanx aircraft.
void UFO_SendToDestination (aircraft_t *ufo, vec2_t dest)
 Make the specified UFO go to destination.
void UFO_CheckShootBack (aircraft_t *ufo, aircraft_t *phalanxAircraft)
 Check if the ufo can shoot back at phalanx aircraft.
void UFO_CampaignRunUFOs (int deltaTime)
 Make the UFOs run.
aircraft_tUFO_AddToGeoscape (ufoType_t ufoType, vec2_t destination, mission_t *mission)
 Add a UFO to geoscape.
void UFO_RemoveFromGeoscape (aircraft_t *ufo)
 Remove the specified ufo from geoscape.
void UFO_DetectNewUFO (aircraft_t *ufocraft)
 Perform actions when a new UFO is detected.
qboolean UFO_CampaignCheckEvents (void)
 Check events for UFOs: Appears or disappears on radars.
void UFO_NotifyPhalanxAircraftRemoved (const aircraft_t *const aircraft)
 Notify to UFOs that a Phalanx aircraft has been destroyed.
qboolean UFO_IsUFOSeenOnGeoscape (const aircraft_t const *ufo)
 Check if an aircraft should be seen on geoscape.
void UFO_InitStartup (void)

Variables

static const float MAX_DETECTING_RANGE = 25.0f

Detailed Description

UFOs on geoscape.

Definition in file cp_ufo.c.


Function Documentation

aircraft_t* UFO_AddToGeoscape ( ufoType_t  ufoType,
vec2_t  destination,
mission_t mission 
)

Add a UFO to geoscape.

Parameters:
[in] ufoType The type of ufo (fighter, scout, ...).
[in] destination Position where the ufo should go. NULL is randomly chosen
[in] mission Pointer to the mission the UFO is involved in
See also:
UFO_RemoveFromGeoscape
UFO_RemoveFromGeoscape_f

Definition at line 585 of file cp_ufo.c.

References AII_ReloadAircraftWeapons(), AII_UpdateAircraftStats(), AIR_STATS_DAMAGE, AIRCRAFT_UFO, ccs_s::aircraftTemplates, ccs, Com_DPrintf(), Com_Printf(), aircraft_s::damage, DEBUG_CLIENT, aircraft_s::detected, aircraft_s::id, aircraft_s::idx, aircraft_s::landed, MAX_UFOONGEOSCAPE, aircraft_s::mission, aircraft_s::notOnGeoscape, ccs_s::numAircraftTemplates, ccs_s::numUFOs, qfalse, aircraft_s::stats, aircraft_s::type, UFO_GetByIDX(), UFO_MAX, UFO_SendToDestination(), UFO_SetRandomDest(), UFO_SetRandomPos(), and aircraft_s::ufotype.

Referenced by CP_MissionBegin(), and CP_SupplyMissionCreate().

const char* UFO_AircraftToIDOnGeoscape ( const aircraft_t ufocraft  ) 

Returns names of the UFO is UFO has been researched.

Parameters:
[in] ufocraft Pointer to the UFO.

Definition at line 106 of file cp_ufo.c.

References _, aircraft_s::detectionIdx, aircraft_s::name, RS_IsResearched_ptr(), aircraft_s::tech, and va().

Referenced by BDEF_BaseDefenceMenuUpdate_f(), MAP_GetUFOText(), MAP_MapClick(), and UFO_MissionResultToString().

qboolean UFO_CampaignCheckEvents ( void   ) 
void UFO_CampaignRunUFOs ( int  deltaTime  ) 
void UFO_CheckShootBack ( aircraft_t ufo,
aircraft_t phalanxAircraft 
)

Check if the ufo can shoot back at phalanx aircraft.

Definition at line 455 of file cp_ufo.c.

References AIR_IsAircraftOnGeoscape(), aircraft_s::aircraftTarget, AIRFIGHT_ExecuteActions(), CP_UFOProceedMission(), and UFO_SendPursuingAircraft().

Referenced by AIRFIGHT_ExecuteActions(), and UFO_SearchAircraftTarget().

void UFO_DetectNewUFO ( aircraft_t ufocraft  ) 

Perform actions when a new UFO is detected.

Parameters:
[in] ufocraft Pointer to the UFO that has just been detected.

Definition at line 673 of file cp_ufo.c.

References ccs_s::campaignStats, ccs, ccs_s::date, aircraft_s::detected, aircraft_s::detectionIdx, aircraft_s::lastSpotted, MAP_IsRadarOverlayActivated(), MAP_SetOverlay(), MAP_UpdateGeoscapeDock(), qtrue, and stats_s::ufosDetected.

Referenced by AIRFIGHT_ExecuteActions(), and UFO_CampaignCheckEvents().

aircraft_t* UFO_GetByIDX ( const int  idx  ) 

returns the UFO on the geoscape with a certain index

Parameters:
[in] idx Index of the UFO

Definition at line 39 of file cp_ufo.c.

References ccs, MAX_UFOONGEOSCAPE, and ccs_s::ufos.

Referenced by AIR_LoadXML(), AIR_PostLoadInitMissions(), AIR_SaveXML(), B_LoadBaseSlotsXML(), RADAR_SetRadarAfterLoading(), UFO_AddToGeoscape(), UFO_CampaignRunUFOs(), UFO_NotifyPhalanxAircraftRemoved(), and UFO_UpdateAlienInterestForAllBasesAndInstallations().

const aircraft_t* UFO_GetByType ( const ufoType_t  type  ) 

Get the aircraft template for a given UFO type.

Parameters:
type The UFO type to get the template for
Returns:
The aircraft template of the UFO - always returns a value

Definition at line 63 of file cp_ufo.c.

References ccs_s::aircraftTemplates, ccs, Com_Error(), ERR_DROP, i, ccs_s::numAircraftTemplates, and aircraft_s::ufotype.

Referenced by UFO_ShouldAppearOnGeoscape().

const technology_t* UFO_GetTechnologyFromType ( const ufoType_t  type  ) 

Get the technology for a given UFO type.

Parameters:
type UFO type to get the technology for
Returns:
The technology for the given UFO. If no technology was found for the UFO id this might return NULL.

Definition at line 51 of file cp_ufo.c.

References Com_UFOTypeToShortName(), and RS_GetTechByProvided().

Referenced by UFO_TypeToName().

void UFO_InitStartup ( void   ) 
See also:
UI_InitStartup

Definition at line 835 of file cp_ufo.c.

References Cmd_AddCommand(), CVAR_DEVELOPER, and Cvar_Get().

Referenced by CP_InitStartup().

static int UFO_IsTargetOfBase ( const aircraft_t const *  ufo,
const base_t const *  base 
) [static]

Check if a UFO is the target of a base.

Parameters:
[in] ufo The UFO to check
[in] base Pointer to the base
Returns:
0 if ufo is not a target, 1 if target of a missile, 2 if target of a laser

Definition at line 187 of file cp_ufo.c.

References base_s::batteries, i, base_s::lasers, base_s::numBatteries, base_s::numLasers, baseWeapon_s::target, UFO_IS_NO_TARGET, UFO_IS_TARGET_OF_LASER, and UFO_IS_TARGET_OF_MISSILE.

Referenced by UFO_UpdateAlienInterestForOneBase().

static int UFO_IsTargetOfInstallation ( const aircraft_t const *  ufo,
const installation_t const *  installation 
) [static]

Check if a UFO is the target of an installation.

Parameters:
[in] ufo The UFO to check
[in] installation Pointer to the installation
Returns:
UFO_IS_NO_TARGET if ufo is not a target, UFO_IS_TARGET_OF_MISSILE if target of a missile

Definition at line 210 of file cp_ufo.c.

References installation_s::batteries, i, installation_s::numBatteries, baseWeapon_s::target, UFO_IS_NO_TARGET, and UFO_IS_TARGET_OF_MISSILE.

Referenced by UFO_UpdateAlienInterestForOneInstallation().

qboolean UFO_IsUFOSeenOnGeoscape ( const aircraft_t const *  ufo  ) 

Check if an aircraft should be seen on geoscape.

Returns:
true or false wether UFO should be seen or not on geoscape.

Definition at line 823 of file cp_ufo.c.

References Com_Error(), aircraft_s::detected, ERR_DROP, aircraft_s::id, aircraft_s::landed, and aircraft_s::notOnGeoscape.

Referenced by AIRFIGHT_BaseShoot(), AIRFIGHT_InstallationShoot(), BDEF_AutoTarget(), MAP_DrawMapMarkers(), MAP_GetGeoscapeAngle(), MAP_GetUFOAngle(), MAP_MapClick(), MAP_UpdateGeoscapeDock(), RADAR_DrawInMap(), and UFO_SearchAircraftTarget().

const char* UFO_MissionResultToString ( void   ) 

Returns a status string for recovered ufo used to be displayed in uforecovery and mission result overview.

Note:
this actually relies on valid mission results.

Definition at line 121 of file cp_ufo.c.

References _, AIR_GetAircraft(), ccs, Com_UFOTypeToShortName(), missionResults_s::crashsite, ccs_s::missionResults, UFO_AircraftToIDOnGeoscape(), missionResults_s::ufoCondition, missionResults_s::ufotype, and va().

Referenced by CP_InitMissionResults(), UR_DialogInit_f(), and UR_DialogInitStore_f().

void UFO_NotifyPhalanxAircraftRemoved ( const aircraft_t *const   aircraft  ) 

Notify to UFOs that a Phalanx aircraft has been destroyed.

Parameters:
[in] aircraft Pointer to the Phalanx aircraft that has been removed.

Definition at line 805 of file cp_ufo.c.

References aircraft_s::aircraftTarget, ccs, ccs_s::numUFOs, and UFO_GetByIDX().

Referenced by AIRFIGHT_ActionsAfterAirfight().

void UFO_RemoveFromGeoscape ( aircraft_t ufo  ) 

Remove the specified ufo from geoscape.

See also:
CP_MissionRemove
Note:
Keep in mind that you have to update the ufo pointers after you called this function

Definition at line 648 of file cp_ufo.c.

References ccs, Com_DPrintf(), DEBUG_CLIENT, aircraft_s::id, ccs_s::numUFOs, REMOVE_ELEM_ADJUST_IDX, and ccs_s::ufos.

Referenced by AIR_LoadXML(), and CP_UFORemoveFromGeoscape().

static void UFO_SearchAircraftTarget ( aircraft_t ufo  )  [static]
qboolean UFO_SendPursuingAircraft ( aircraft_t ufo,
aircraft_t aircraft 
)

Make the specified UFO pursue a phalanx aircraft.

Parameters:
[in] ufo Pointer to the UFO.
[in] aircraft Pointer to the target aircraft.
See also:
UFO_SendAttackBase

Definition at line 410 of file cp_ufo.c.

References AIR_GetDestinationWhilePursuing(), AIR_TRANSIT, AIR_UFO, aircraft_s::aircraftTarget, AIRFIGHT_ChooseWeapon(), AIRFIGHT_WEAPON_CAN_NEVER_SHOOT, dest, MAP_MapCalcLine(), aircraft_s::maxWeapons, aircraft_s::point, aircraft_s::pos, qfalse, qtrue, aircraft_s::route, aircraft_s::status, aircraft_s::time, and aircraft_s::weapons.

Referenced by AIRFIGHT_ExecuteActions(), UFO_CheckShootBack(), and UFO_SearchAircraftTarget().

void UFO_SendToDestination ( aircraft_t ufo,
vec2_t  dest 
)
void UFO_SetRandomDest ( aircraft_t ufocraft  ) 

Give a random destination to the given UFO, and make him to move there.

Parameters:
[in] ufocraft Pointer to the UFO which destination will be changed.
See also:
UFO_SetRandomPos

Definition at line 137 of file cp_ufo.c.

References CP_GetRandomPosOnGeoscape(), pos, qfalse, and UFO_SendToDestination().

Referenced by CP_BaseAttackMissionLeave(), CP_BuildBaseGovernmentLeave(), CP_BuildBaseMissionLeave(), CP_InterceptMissionLeave(), CP_ReconMissionLeave(), CP_SupplyMissionLeave(), CP_UFOProceedMission(), UFO_AddToGeoscape(), and UFO_CampaignRunUFOs().

void UFO_SetRandomDestAround ( aircraft_t ufocraft,
vec2_t  pos 
)

Give a random destination to the given UFO close to a position, and make him to move there.

Parameters:
[in] ufocraft Pointer to the UFO which destination will be changed.
[in] pos The position the UFO should around.
See also:
UFO_SetRandomPos

Definition at line 152 of file cp_ufo.c.

References dest, gaussrand(), UFO_SendToDestination(), and Vector2Set.

Referenced by CP_InterceptAttackInstallation(), and UFO_CampaignRunUFOs().

static void UFO_SetRandomPos ( aircraft_t ufocraft  )  [static]

Give a random position to the given UFO.

Parameters:
[in] ufocraft Pointer to the UFO which position will be changed.
See also:
UFO_SetRandomDest

Definition at line 172 of file cp_ufo.c.

References CP_GetRandomPosOnGeoscape(), aircraft_s::pos, pos, qfalse, and Vector2Copy.

Referenced by UFO_AddToGeoscape().

qboolean UFO_ShouldAppearOnGeoscape ( const ufoType_t  type  ) 

Some UFOs may only appear if after some interest level in the current running campaign is reached.

Parameters:
type The UFO type to check the interest level for
Returns:
true if the UFO may appear on geoscape, false otherwise

Definition at line 81 of file cp_ufo.c.

References ccs, ccs_s::overallInterest, UFO_GetByType(), and aircraft_s::ufoInterestOnGeoscape.

Referenced by CP_BaseAttackMissionAvailableUFOs(), CP_TerrorMissionAvailableUFOs(), and CP_XVIMissionAvailableUFOs().

const char* UFO_TypeToName ( ufoType_t  type  ) 

Translate UFO type to name.

Parameters:
[in] type UFO type in ufoType_t.
Returns:
Translated UFO name.
See also:
Com_UFOTypeToShortName
Com_UFOShortNameToID

Definition at line 95 of file cp_ufo.c.

References _, Com_Error(), ERR_DROP, technology_s::name, and UFO_GetTechnologyFromType().

Referenced by BaseSummary_Init(), PR_DisassemblingFrame(), PR_DisassemblyInfo(), PR_UpdateProductionList(), UR_DialogStartSell_f(), UR_DialogStartStore_f(), and UR_ProcessActive().

void UFO_UpdateAlienInterestForAllBasesAndInstallations ( void   ) 
static void UFO_UpdateAlienInterestForOneBase ( const aircraft_t const *  ufo,
base_t base 
) [static]

Update alien interest for one PHALANX base.

Parameters:
[in] ufo Pointer to the aircraft_t
[in] base Pointer to the base
Note:
This function will be called quite often (every DETECTION_INTERVAL), so it must stay simple. it must not depend on dt , otherwise alien interest will depend on time scale.
this function will only be used to determine WHICH base will be attacked, and not IF a base will be attacked.
See also:
UFO_UpdateAlienInterestForAllBases
AB_UpdateStealthForOneBase

< above this distance, probability to detect base will decrease by decreasingFactor

Definition at line 233 of file cp_ufo.c.

References base_s::alienInterest, DETECTION_INTERVAL, GetDistanceOnGlobe(), MAX_DETECTING_RANGE, base_s::pos, aircraft_s::pos, UFO_IS_TARGET_OF_LASER, UFO_IS_TARGET_OF_MISSILE, and UFO_IsTargetOfBase().

Referenced by UFO_UpdateAlienInterestForAllBasesAndInstallations().

static void UFO_UpdateAlienInterestForOneInstallation ( const aircraft_t const *  ufo,
installation_t installation 
) [static]

Update alien interest for one PHALANX installation (radar tower, SAM, ...).

Parameters:
[in] ufo Pointer to the aircraft_t
[in] installation Pointer to the installation
See also:
UFO_UpdateAlienInterestForOneBase

< above this distance, probability to detect base will decrease by decreasingFactor

Definition at line 275 of file cp_ufo.c.

References installation_s::alienInterest, DETECTION_INTERVAL, GetDistanceOnGlobe(), MAX_DETECTING_RANGE, installation_s::pos, aircraft_s::pos, UFO_IS_TARGET_OF_LASER, UFO_IS_TARGET_OF_MISSILE, and UFO_IsTargetOfInstallation().

Referenced by UFO_UpdateAlienInterestForAllBasesAndInstallations().


Variable Documentation

const float MAX_DETECTING_RANGE = 25.0f [static]

range to detect and fire at phalanx aircraft

Definition at line 33 of file cp_ufo.c.

Referenced by UFO_SearchAircraftTarget(), UFO_UpdateAlienInterestForOneBase(), and UFO_UpdateAlienInterestForOneInstallation().


Generated by  doxygen 1.6.2