UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_airfight.h File Reference

Header file for airfights. More...

Go to the source code of this file.

Data Structures

struct  aircraftProjectile_s
 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
 

Typedefs

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

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

#define AIRFIGHT_BASE_CAN_T_FIRE   -1

Definition at line 40 of file cp_airfight.h.

#define AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT   -1
#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.

Referenced by AIRFIGHT_CheckWeapon(), AIRFIGHT_ChooseWeapon(), and AIRFIGHT_ExecuteActions().

#define BULLETS_PER_SHOT   1

Definition at line 28 of file cp_airfight.h.

#define MAX_MULTIPLE_PROJECTILES   10

Definition at line 29 of file cp_airfight.h.

Referenced by AIRFIGHT_LoadXML().

Typedef Documentation

projectile used during fight between two or more aircraft

Function Documentation

void AIRFIGHT_ActionsAfterAirfight ( const struct campaign_s campaign,
aircraft_t shooter,
aircraft_t aircraft,
bool  phalanxWon 
)
bool AIRFIGHT_BaseCanTargetUFO ( const struct base_s base,
const aircraft_t ufo 
)
void AIRFIGHT_CampaignRunProjectiles ( const struct campaign_s campaign,
int  dt 
)
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 200 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_s::ammo, aircraftSlot_s::ammoLeft, objDef_s::craftitem, aircraftSlot_s::delayNextShot, aircraftSlot_s::installationTime, aircraftSlot_s::item, and craftitem_s::stats.

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

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 234 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().

void AIRFIGHT_ExecuteActions ( const struct campaign_s campaign,
aircraft_t air,
aircraft_t ufo 
)
void AIRFIGHT_InitStartup ( void  )
See also
UI_InitStartup

Definition at line 997 of file cp_airfight.cpp.

References cgi.

Referenced by CP_InitStartup().

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 413 of file cp_airfight.cpp.

References aircraftProjectile_s::aimedAircraft, AIR_AircraftReturnToBase(), AIR_IsUFO, AIRFIGHT_MissTarget(), aircraftProjectile_s::attackingAircraft, ccs, aircraft_s::homebase, ccs_s::numProjectiles, and ccs_s::projectiles.

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