UFO: Alien Invasion
cp_airfight.h File Reference

Header file for airfights. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  aircraftProjectile_t
 projectile used during fight between two or more aircraft More...
 

Macros

#define BULLETS_PER_SHOT   1
 
#define MAX_MULTIPLE_PROJECTILES   10
 
#define AIRFIGHT_WEAPON_CAN_SHOOT   0
 
#define AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT   -1
 
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT   -2
 
#define AIRFIGHT_BASE_CAN_T_FIRE   -1
 

Functions

void AIRFIGHT_ExecuteActions (const struct campaign_s *campaign, aircraft_t *air, aircraft_t *ufo)
 
void AIRFIGHT_ActionsAfterAirfight (const struct campaign_s *campaign, aircraft_t *shooter, aircraft_t *aircraft, bool phalanxWon)
 
void AIRFIGHT_CampaignRunProjectiles (const struct campaign_s *campaign, int dt)
 
void AIRFIGHT_CampaignRunBaseDefence (int dt)
 Run base defences. More...
 
int AIRFIGHT_CheckWeapon (const aircraftSlot_t *slot, float distance)
 Check if the selected weapon can shoot. More...
 
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. More...
 
bool AIRFIGHT_BaseCanTargetUFO (const struct base_s *base, const aircraft_t *ufo)
 
void AIRFIGHT_RemoveProjectileAimingAircraft (const aircraft_t *aircraft)
 Set all projectile aiming a given aircraft to an idle destination. More...
 
bool AIRFIGHT_SaveXML (xmlNode_t *parent)
 Save callback for savegames in XML Format. More...
 
bool AIRFIGHT_LoadXML (xmlNode_t *parent)
 Load callback for savegames in XML Format. More...
 
void AIRFIGHT_InitStartup (void)
 

Detailed Description

Header file for airfights.

Definition in file cp_airfight.h.

Macro Definition Documentation

◆ AIRFIGHT_BASE_CAN_T_FIRE

#define AIRFIGHT_BASE_CAN_T_FIRE   -1

Definition at line 40 of file cp_airfight.h.

◆ AIRFIGHT_WEAPON_CAN_NEVER_SHOOT

#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT   -2

Definition at line 38 of file cp_airfight.h.

◆ AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT

#define AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT   -1

Definition at line 37 of file cp_airfight.h.

◆ AIRFIGHT_WEAPON_CAN_SHOOT

#define AIRFIGHT_WEAPON_CAN_SHOOT   0
Note
0 if the weapon can shoot
-1 if it can't shoot atm
-2 if it will never be able to shoot

Definition at line 36 of file cp_airfight.h.

◆ BULLETS_PER_SHOT

#define BULLETS_PER_SHOT   1

Definition at line 28 of file cp_airfight.h.

◆ MAX_MULTIPLE_PROJECTILES

#define MAX_MULTIPLE_PROJECTILES   10

Definition at line 29 of file cp_airfight.h.

Function Documentation

◆ AIRFIGHT_ActionsAfterAirfight()

void AIRFIGHT_ActionsAfterAirfight ( const struct campaign_s *  campaign,
aircraft_t shooter,
aircraft_t aircraft,
bool  phalanxWon 
)

◆ AIRFIGHT_BaseCanTargetUFO()

bool AIRFIGHT_BaseCanTargetUFO ( const struct base_s *  base,
const aircraft_t ufo 
)

◆ AIRFIGHT_CampaignRunBaseDefence()

◆ AIRFIGHT_CampaignRunProjectiles()

void AIRFIGHT_CampaignRunProjectiles ( const struct campaign_s *  campaign,
int  dt 
)

◆ AIRFIGHT_CheckWeapon()

int AIRFIGHT_CheckWeapon ( const aircraftSlot_t slot,
float  distance 
)

Check if the selected weapon can shoot.

Parameters
[in]slotPointer to the weapon slot to shoot with.
[in]distancedistance between the weapon and the target.
Returns
0 AIRFIGHT_WEAPON_CAN_SHOOT if the weapon can shoot, -1 AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT if it can't shoot atm, -2 AIRFIGHT_WEAPON_CAN_NEVER_SHOOT if it will never be able to shoot.

Definition at line 201 of file cp_airfight.cpp.

References AIR_STATS_WRANGE, AIRFIGHT_WEAPON_CAN_NEVER_SHOOT, AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT, AIRFIGHT_WEAPON_CAN_SHOOT, aircraftSlot_t::ammo, aircraftSlot_t::ammoLeft, objDef_t::craftitem, aircraftSlot_t::delayNextShot, aircraftSlot_t::installationTime, aircraftSlot_t::item, and craftItem::stats.

Referenced by AII_WeaponsCanShoot(), AIRFIGHT_BaseShoot(), AIRFIGHT_ChooseWeapon(), AIRFIGHT_InstallationShoot(), and BDEF_AutoTarget().

◆ AIRFIGHT_ChooseWeapon()

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.

Parameters
[in]slotPointer to the first weapon slot of attacking base or aircraft.
[in]maxSlotmaximum number of weapon slots in attacking base or aircraft.
[in]posposition of attacking base or aircraft.
[in]targetPosPointer to the aimed aircraft.
Returns
indice of the slot to use (in array weapons[]), -1 AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT no weapon to use atm, -2 AIRFIGHT_WEAPON_CAN_NEVER_SHOOT if no weapon to use at all.
See also
AIRFIGHT_CheckWeapon

Definition at line 235 of file cp_airfight.cpp.

References AIRFIGHT_CheckWeapon(), AIRFIGHT_WEAPON_CAN_NEVER_SHOOT, AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT, AIRFIGHT_WEAPON_CAN_SHOOT, GetDistanceOnGlobe(), and i.

Referenced by AIRFIGHT_ExecuteActions(), CL_DisplayPopupInterceptUFO(), CP_InterceptNextStage(), CP_UFOProceedMission(), and UFO_SendPursuingAircraft().

◆ AIRFIGHT_ExecuteActions()

void AIRFIGHT_ExecuteActions ( const struct campaign_s *  campaign,
aircraft_t air,
aircraft_t ufo 
)

◆ AIRFIGHT_InitStartup()

void AIRFIGHT_InitStartup ( void  )
See also
UI_InitStartup

Definition at line 998 of file cp_airfight.cpp.

References cgi.

Referenced by CP_InitStartup().

◆ AIRFIGHT_LoadXML()

◆ AIRFIGHT_RemoveProjectileAimingAircraft()

void AIRFIGHT_RemoveProjectileAimingAircraft ( const aircraft_t aircraft)

Set all projectile aiming a given aircraft to an idle destination.

Parameters
[in]aircraftPointer to the aimed aircraft.
Note
This function is called when aircraft is destroyed.
See also
AIRFIGHT_ActionsAfterAirfight

Definition at line 414 of file cp_airfight.cpp.

References aircraftProjectile_t::aimedAircraft, AIR_AircraftReturnToBase(), AIR_IsUFO, AIRFIGHT_MissTarget(), aircraftProjectile_t::attackingAircraft, ccs, aircraft_t::homebase, ccs_t::numProjectiles, and ccs_t::projectiles.

Referenced by AIRFIGHT_ActionsAfterAirfight(), B_AircraftReturnedToHomeBase(), and CP_UFORemoveFromGeoscape().

◆ AIRFIGHT_SaveXML()