UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_mapfightequip.cpp File Reference

contains everything related to equiping slots of aircraft or base More...

#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_missions.h"
#include "cp_mapfightequip.h"
#include "cp_ufo.h"
#include "save/save_fightequip.h"
Include dependency graph for cp_mapfightequip.cpp:

Go to the source code of this file.

Macros

#define UFO_RELOAD_DELAY_MULTIPLIER   2
#define AIRCRAFT_RELOAD_DELAY_MULTIPLIER   2
#define BASE_RELOAD_DELAY_MULTIPLIER   2
#define INSTALLATION_RELOAD_DELAY_MULTIPLIER   2

Functions

technology_t ** AII_GetCraftitemTechsByType (aircraftItemType_t type)
 Returns a list of craftitem technologies for the given type.
itemWeight_t AII_GetItemWeightBySize (const objDef_t *od)
 Returns craftitem weight based on size.
bool AIM_SelectableCraftItem (const aircraftSlot_t *slot, const technology_t *tech)
 Check if an aircraft item should or should not be displayed in airequip menu.
bool AIM_PilotAssignedAircraft (const base_t *base, const Employee *pilot)
 Checks to see if the pilot is in any aircraft at this base.
void BDEF_AddBattery (basedefenceType_t basedefType, base_t *base)
 Adds a defence system to base.
void BDEF_RemoveBattery (base_t *base, basedefenceType_t basedefType, int idx)
 Remove a base defence sytem from base.
void BDEF_InitialiseBaseSlots (base_t *base)
 Initialise all values of base slot defence.
void BDEF_InitialiseInstallationSlots (installation_t *installation)
 Initialise all values of installation slot defence.
static void AII_UpdateOneInstallationDelay (base_t *base, installation_t *installation, aircraft_t *aircraft, aircraftSlot_t *slot)
 Update the installation delay of one slot.
void AII_UpdateInstallationDelay (void)
 Update the installation delay of all slots of a given aircraft.
void AII_AutoAddAmmo (aircraftSlot_t *slot)
 Auto add ammo corresponding to weapon, if there is enough in storage.
void AII_RemoveItemFromSlot (base_t *base, aircraftSlot_t *slot, bool ammo)
 Remove the item from the slot (or optionally its ammo only) and put it the base storage.
void AII_RemoveNextItemFromSlot (base_t *base, aircraftSlot_t *slot, bool ammo)
 Cancel replacing item, move nextItem (or optionally its ammo only) back to the base storage.
bool AII_ReloadWeapon (aircraftSlot_t *slot)
 Reloads an aircraft/defence-system weapon.
void AII_ReloadAircraftWeapons (aircraft_t *aircraft)
 Reload the weapons of an aircraft.
bool AII_AddAmmoToSlot (base_t *base, const technology_t *tech, aircraftSlot_t *slot)
 Add an ammo to an aircraft weapon slot.
bool AII_AddItemToSlot (base_t *base, const technology_t *tech, aircraftSlot_t *slot, bool nextItem)
 Add an item to an aircraft slot.
void AIM_AutoEquipAircraft (aircraft_t *aircraft)
 Auto Add weapon and ammo to an aircraft.
void AII_InitialiseSlot (aircraftSlot_t *slot, aircraft_t *aircraftTemplate, base_t *base, installation_t *installation, aircraftItemType_t type)
 Initialise values of one slot of an aircraft or basedefence common to all types of items.
static bool AII_CheckUpdateAircraftStats (const aircraftSlot_t *slot, int stat)
 Check if item in given slot should change one aircraft stat.
aircraftSlot_tBDEF_GetBaseSlotByIDX (base_t *base, aircraftItemType_t type, int idx)
 returns the aircraftSlot of a base at an index or the first free slot
aircraftSlot_tBDEF_GetInstallationSlotByIDX (installation_t *installation, aircraftItemType_t type, int idx)
 returns the aircraftSlot of an installaion at an index or the first free slot
aircraftSlot_tAII_GetAircraftSlotByIDX (aircraft_t *aircraft, aircraftItemType_t type, int idx)
 returns the aircraftSlot of an aircraft at an index or the first free slot
float AIR_GetMaxAircraftWeaponRange (const aircraftSlot_t *slot, int maxSlot)
 Get the maximum weapon range of aircraft.
void AII_RepairAircraft (void)
 Repair aircraft.
void AII_UpdateAircraftStats (aircraft_t *aircraft)
 Update the value of stats array of an aircraft.
static bool AII_WeaponsCanShoot (const baseWeapon_t *weapons, int numWeapons)
 Check if base or installation weapon can shoot.
int AII_BaseCanShoot (const base_t *base)
 Check if the base has weapon and ammo.
bool AII_InstallationCanShoot (const installation_t *installation)
 Check if the installation has a weapon and ammo.
static void BDEF_AutoTarget (baseWeapon_t *weapons, int maxWeapons)
 Chooses a target for surface to air defences automatically.
void BDEF_AutoSelectTarget (void)
 Chooses target for all base defences and sam sites.
const char * AII_WeightToName (itemWeight_t weight)
 Translate a weight int to a translated string.
void AII_SaveOneSlotXML (xmlNode_t *p, const aircraftSlot_t *slot, bool weapon)
 Save callback for savegames in XML Format.
void AII_LoadOneSlotXML (xmlNode_t *node, aircraftSlot_t *slot, bool weapon)
 Loads one slot (base, installation or aircraft).

Detailed Description

contains everything related to equiping slots of aircraft or base

Note
Base defence functions prefix: BDEF_
Aircraft items slots functions prefix: AII_

Definition in file cp_mapfightequip.cpp.

Macro Definition Documentation

◆ AIRCRAFT_RELOAD_DELAY_MULTIPLIER

#define AIRCRAFT_RELOAD_DELAY_MULTIPLIER   2

Definition at line 35 of file cp_mapfightequip.cpp.

Referenced by AII_ReloadWeapon().

◆ BASE_RELOAD_DELAY_MULTIPLIER

#define BASE_RELOAD_DELAY_MULTIPLIER   2

Definition at line 36 of file cp_mapfightequip.cpp.

Referenced by AII_ReloadWeapon().

◆ INSTALLATION_RELOAD_DELAY_MULTIPLIER

#define INSTALLATION_RELOAD_DELAY_MULTIPLIER   2

Definition at line 37 of file cp_mapfightequip.cpp.

Referenced by AII_ReloadWeapon().

◆ UFO_RELOAD_DELAY_MULTIPLIER

#define UFO_RELOAD_DELAY_MULTIPLIER   2

Definition at line 34 of file cp_mapfightequip.cpp.

Referenced by AII_ReloadWeapon().

Function Documentation

◆ AII_AddAmmoToSlot()

bool AII_AddAmmoToSlot ( base_t * base,
const technology_t * tech,
aircraftSlot_t * slot )

Add an ammo to an aircraft weapon slot.

Note
No check for the type of item is done here, so it must be done before.
Parameters
[in]basePointer to the base which provides items (nullptr if items shouldn't be removed of storage)
[in]techPointer to the tech to add to slot
[in]slotPointer to the slot where you want to add ammos
See also
AII_AddItemToSlot

Definition at line 647 of file cp_mapfightequip.cpp.

References AC_ITEM_AMMO, AII_ReloadWeapon(), AII_RemoveItemFromSlot(), AII_RemoveNextItemFromSlot(), aircraftSlot_t::ammo, objDef_t::ammos, B_AddToStorage(), B_BaseHasItem(), cgi, objDef_t::craftitem, objDef_t::id, objDef_t::idx, INVSH_GetItemByID(), aircraftSlot_t::item, aircraftSlot_t::nextAmmo, aircraftSlot_t::nextItem, objDef_t::numAmmos, technology_t::provides, and craftItem::type.

Referenced by AII_AutoAddAmmo(), AII_LoadOneSlotXML(), and AIM_AircraftEquipAddItem_f().

◆ AII_AddItemToSlot()

bool AII_AddItemToSlot ( base_t * base,
const technology_t * tech,
aircraftSlot_t * slot,
bool nextItem )

Add an item to an aircraft slot.

Parameters
[in]basePointer to the base where item will be removed (nullptr for ufos, virtual ammos or while loading game)
[in]techPointer to the tech that will be added in this slot.
[in]slotPointer to the aircraft, base, or installation slot.
[in]nextItemFalse if we are changing current item in slot, true if this is the item to install after current removal is over.
Note
No check for the type of item is done here.
See also
AII_UpdateOneInstallationDelay
AII_AddAmmoToSlot

Definition at line 722 of file cp_mapfightequip.cpp.

References AC_ITEM_AMMO, AII_GetItemWeightBySize(), B_AddToStorage(), B_BaseHasItem(), cgi, objDef_t::craftitem, objDef_t::id, aircraftSlot_t::idx, aircraftSlot_t::installationTime, craftItem::installationTime, INVSH_GetItemByID(), aircraftSlot_t::item, aircraftSlot_t::nextItem, technology_t::provides, aircraftSlot_t::size, objDef_t::size, aircraftSlot_t::type, and craftItem::type.

Referenced by AII_LoadOneSlotXML(), AIM_AircraftEquipAddItem_f(), AIM_AutoEquipAircraft(), and BDEF_AddItem_f().

◆ AII_AutoAddAmmo()

◆ AII_BaseCanShoot()

int AII_BaseCanShoot ( const base_t * base)

Check if the base has weapon and ammo.

Parameters
[in]basePointer to the base you want to check (may not be nullptr)
Returns
true if the base can shoot, qflase else
See also
AII_AircraftCanShoot

Definition at line 1150 of file cp_mapfightequip.cpp.

References AII_WeaponsCanShoot(), B_DEFENCE_LASER, B_DEFENCE_MISSILE, B_GetBuildingStatus(), base_t::batteries, base_t::lasers, base_t::numBatteries, and base_t::numLasers.

Referenced by AIRFIGHT_CampaignRunBaseDefence(), CL_DisplayPopupInterceptUFO(), CL_PopupInterceptBaseClick_f(), and GEO_DrawMapOneBase().

◆ AII_CheckUpdateAircraftStats()

bool AII_CheckUpdateAircraftStats ( const aircraftSlot_t * slot,
int stat )
static

Check if item in given slot should change one aircraft stat.

Parameters
[in]slotPointer to the slot containing the item
[in]statthe stat that should be checked
Returns
true if the item should change the stat.

Definition at line 875 of file cp_mapfightequip.cpp.

References objDef_t::craftitem, aircraftSlot_t::installationTime, aircraftSlot_t::item, and craftItem::stats.

Referenced by AII_UpdateAircraftStats(), and AIR_GetMaxAircraftWeaponRange().

◆ AII_GetAircraftSlotByIDX()

aircraftSlot_t * AII_GetAircraftSlotByIDX ( aircraft_t * aircraft,
aircraftItemType_t type,
int idx )

returns the aircraftSlot of an aircraft at an index or the first free slot

Parameters
[in]aircraftPointer to aircraft
[in]typebase defence type, see aircraftItemType_t
[in]idxindex of aircraftslot
Returns
the aircraftSlot at the index idx if idx non-negative the first free slot otherwise

Definition at line 964 of file cp_mapfightequip.cpp.

References AC_ITEM_ELECTRONICS, AC_ITEM_SHIELD, AC_ITEM_WEAPON, aircraft_t::electronics, i, aircraftSlot_t::item, aircraft_t::maxElectronics, aircraft_t::maxWeapons, aircraftSlot_t::nextItem, aircraft_t::shield, type, and aircraft_t::weapons.

◆ AII_GetCraftitemTechsByType()

technology_t ** AII_GetCraftitemTechsByType ( aircraftItemType_t type)

Returns a list of craftitem technologies for the given type.

Note
This list is terminated by a nullptr pointer.
Parameters
[in]typeType of the craft-items to return.

Definition at line 44 of file cp_mapfightequip.cpp.

References cgi, objDef_t::craftitem, i, INVSH_GetItemByIDX(), MAX_TECHNOLOGIES, RS_GetTechForItem(), craftItem::type, and type.

Referenced by AIM_UpdateAircraftItemList(), BDEF_AddItem_f(), BDEF_SelectItem_f(), and BDEF_UpdateAircraftItemList().

◆ AII_GetItemWeightBySize()

itemWeight_t AII_GetItemWeightBySize ( const objDef_t * od)

Returns craftitem weight based on size.

Parameters
[in]odPointer to objDef_t object being craftitem.
Returns
itemWeight_t
See also
AII_WeightToName

Definition at line 74 of file cp_mapfightequip.cpp.

References ITEM_HEAVY, ITEM_LIGHT, ITEM_MEDIUM, and objDef_t::size.

Referenced by AII_AddItemToSlot(), AIM_AutoEquipAircraft(), AIM_CheckTechnologyIntoSlot(), AIM_SelectableCraftItem(), AIR_ScriptSanityCheck(), and UP_AircraftItemDescription().

◆ AII_InitialiseSlot()

void AII_InitialiseSlot ( aircraftSlot_t * slot,
aircraft_t * aircraftTemplate,
base_t * base,
installation_t * installation,
aircraftItemType_t type )

Initialise values of one slot of an aircraft or basedefence common to all types of items.

Parameters
[in]slotPointer to the slot to initialize.
[in]aircraftTemplateTemplate Pointer to aircraft template.
[in]basePointer to base.
[in]installationPointer to the thing being installed.
[in]typeThe type of item that can fit in this slot.

sa BDEF_AddBattery: it needs to be AMMO_STATUS_NOT_SET and not 0

See also
B_SaveBaseSlots

Definition at line 847 of file cp_mapfightequip.cpp.

References aircraftSlot_t::aircraft, aircraftSlot_t::ammo, AMMO_STATUS_NOT_SET, aircraftSlot_t::ammoLeft, aircraftSlot_t::base, aircraftSlot_t::installation, aircraftSlot_t::installationTime, aircraftSlot_t::item, ITEM_HEAVY, aircraftSlot_t::nextAmmo, aircraftSlot_t::nextItem, OBJZERO, aircraftSlot_t::size, aircraftSlot_t::type, and type.

Referenced by AII_InitialiseAircraftSlots(), BDEF_InitialiseBaseSlots(), BDEF_InitialiseInstallationSlots(), and BDEF_RemoveBattery().

◆ AII_InstallationCanShoot()

bool AII_InstallationCanShoot ( const installation_t * installation)

Check if the installation has a weapon and ammo.

Parameters
[in]installationPointer to the installation you want to check (may not be nullptr)
Returns
true if the installation can shoot, qflase else
See also
AII_AircraftCanShoot

Definition at line 1173 of file cp_mapfightequip.cpp.

References AII_WeaponsCanShoot(), installation_t::batteries, INSTALLATION_WORKING, installation_t::installationStatus, installation_t::installationTemplate, and installationTemplate_t::maxBatteries.

Referenced by AIRFIGHT_CampaignRunBaseDefence(), CL_DisplayPopupInterceptUFO(), CL_PopupInterceptBaseClick_f(), and GEO_DrawMapOneInstallation().

◆ AII_LoadOneSlotXML()

void AII_LoadOneSlotXML ( xmlNode_t * node,
aircraftSlot_t * slot,
bool weapon )

Loads one slot (base, installation or aircraft).

Parameters
[in]nodeXML Node structure, where we get the information from
[out]slotPointer to the slot where item should be added.
[in]weaponTrue if the slot is a weapon slot.
See also
B_Load
B_SaveAircraftSlots

Definition at line 1333 of file cp_mapfightequip.cpp.

References AII_AddAmmoToSlot(), AII_AddItemToSlot(), aircraftSlot_t::ammoLeft, cgi, aircraftSlot_t::delayNextShot, aircraftSlot_t::installationTime, name, RS_GetTechByProvided(), SAVE_SLOT_AMMOID, SAVE_SLOT_AMMOLEFT, SAVE_SLOT_DELAYNEXTSHOT, SAVE_SLOT_INSTALLATIONTIME, SAVE_SLOT_ITEMID, SAVE_SLOT_NEXTAMMOID, SAVE_SLOT_NEXTITEMID, and xmlNode_t.

Referenced by AIR_LoadAircraftSlotsXML(), and B_LoadBaseSlotsXML().

◆ AII_ReloadAircraftWeapons()

void AII_ReloadAircraftWeapons ( aircraft_t * aircraft)

Reload the weapons of an aircraft.

Parameters
[in,out]aircraftPointer to the aircraft to reload

Definition at line 630 of file cp_mapfightequip.cpp.

References AII_ReloadWeapon(), i, aircraft_t::maxWeapons, and aircraft_t::weapons.

Referenced by AIM_AircraftStart_f(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), B_AircraftReturnedToHomeBase(), and UFO_AddToGeoscape().

◆ AII_ReloadWeapon()

◆ AII_RemoveItemFromSlot()

void AII_RemoveItemFromSlot ( base_t * base,
aircraftSlot_t * slot,
bool ammo )

Remove the item from the slot (or optionally its ammo only) and put it the base storage.

Note
if there is another item to install after removal, begin this installation.
virtual items cannot be removed!
Parameters
[in]baseThe base to add the item to (may be nullptr if item shouldn't be removed from any base).
[in]slotThe slot to remove the item from.
[in]ammotrue if we want to remove only ammo. false if the whole item should be removed.
See also
AII_AddItemToSlot
AII_AddAmmoToSlot
AII_RemoveNextItemFromSlot

Definition at line 482 of file cp_mapfightequip.cpp.

References AII_RemoveItemFromSlot(), aircraftSlot_t::ammo, objDef_t::ammo, aircraftSlot_t::ammoLeft, B_AddToStorage(), objDef_t::craftitem, aircraftSlot_t::installationTime, craftItem::installationTime, objDef_t::isVirtual, aircraftSlot_t::item, aircraftSlot_t::nextAmmo, and aircraftSlot_t::nextItem.

Referenced by AII_AddAmmoToSlot(), AII_RemoveItemFromSlot(), AII_UpdateOneInstallationDelay(), AIM_AircraftEquipAddItem_f(), AIM_AircraftEquipRemoveItem_f(), AIR_DeleteAircraft(), BDEF_AddItem_f(), and BDEF_RemoveItem_f().

◆ AII_RemoveNextItemFromSlot()

void AII_RemoveNextItemFromSlot ( base_t * base,
aircraftSlot_t * slot,
bool ammo )

Cancel replacing item, move nextItem (or optionally its ammo only) back to the base storage.

Parameters
[in]baseThe base to add the item to (may be nullptr if item shouldn't be removed from any base).
[in]slotThe slot to remove the item from.
[in]ammotrue if we want to remove only ammo. false if the whole item should be removed.
See also
AII_AddItemToSlot
AII_AddAmmoToSlot
AII_RemoveItemFromSlot

Definition at line 535 of file cp_mapfightequip.cpp.

References AII_RemoveNextItemFromSlot(), B_AddToStorage(), objDef_t::isVirtual, aircraftSlot_t::nextAmmo, and aircraftSlot_t::nextItem.

Referenced by AII_AddAmmoToSlot(), AII_RemoveNextItemFromSlot(), AIM_AircraftEquipAddItem_f(), and AIM_AircraftEquipRemoveItem_f().

◆ AII_RepairAircraft()

void AII_RepairAircraft ( void )

Repair aircraft.

Note
Hourly called.
Repairs 1% of a craft's max damage capacity.

< Number of damage points repaired per hour: 1% of aircraft max damage value

Definition at line 1035 of file cp_mapfightequip.cpp.

References AIR_ForeachFromBase, AIR_IsAircraftInBase(), AIR_STATS_DAMAGE, B_GetNext(), cgi, and DEBUG_CLIENT.

Referenced by CP_CampaignRun().

◆ AII_SaveOneSlotXML()

void AII_SaveOneSlotXML ( xmlNode_t * p,
const aircraftSlot_t * slot,
bool weapon )

Save callback for savegames in XML Format.

Parameters
[out]pXML Node structure, where we write the information to
[in]slotThe aircraftslot to save
[in]weaponTrue if this is a weapon slot

Definition at line 1309 of file cp_mapfightequip.cpp.

References aircraftSlot_t::ammo, aircraftSlot_t::ammoLeft, cgi, aircraftSlot_t::delayNextShot, objDef_t::id, aircraftSlot_t::installationTime, aircraftSlot_t::item, aircraftSlot_t::nextAmmo, aircraftSlot_t::nextItem, SAVE_SLOT_AMMOID, SAVE_SLOT_AMMOLEFT, SAVE_SLOT_DELAYNEXTSHOT, SAVE_SLOT_INSTALLATIONTIME, SAVE_SLOT_ITEMID, SAVE_SLOT_NEXTAMMOID, SAVE_SLOT_NEXTITEMID, and xmlNode_t.

Referenced by AIR_SaveAircraftSlotsXML(), and B_SaveBaseSlotsXML().

◆ AII_UpdateAircraftStats()

◆ AII_UpdateInstallationDelay()

void AII_UpdateInstallationDelay ( void )

Update the installation delay of all slots of a given aircraft.

Note
hourly called
See also
CP_CampaignRun
AII_UpdateOneInstallationDelay

Definition at line 392 of file cp_mapfightequip.cpp.

References AII_UpdateOneInstallationDelay(), AIR_Foreach, AIR_IsAircraftInBase(), B_GetNext(), base_t::batteries, INS_Foreach, base_t::lasers, base_t::numBatteries, base_t::numLasers, and baseWeapon_t::slot.

Referenced by CP_CampaignRun().

◆ AII_UpdateOneInstallationDelay()

void AII_UpdateOneInstallationDelay ( base_t * base,
installation_t * installation,
aircraft_t * aircraft,
aircraftSlot_t * slot )
static

Update the installation delay of one slot.

Parameters
[in]basePointer to the base to update the storage and capacity for
[in]installationPointer to the installation being installed.
[in]aircraftPointer to the aircraft (nullptr if a base is updated)
[in]slotPointer to the slot to update
See also
AII_AddItemToSlot

Definition at line 320 of file cp_mapfightequip.cpp.

References _, AII_RemoveItemFromSlot(), AII_UpdateAircraftStats(), Com_sprintf(), cp_messageBuffer, aircraft_t::homebase, aircraftSlot_t::installationTime, aircraftSlot_t::item, lengthof, MSO_CheckAddNewMessage(), aircraft_t::name, base_t::name, installation_t::name, objDef_t::name, NT_INSTALLATION_INSTALLED, NT_INSTALLATION_REMOVED, NT_INSTALLATION_REPLACE, and Sys_Error().

Referenced by AII_UpdateInstallationDelay().

◆ AII_WeaponsCanShoot()

bool AII_WeaponsCanShoot ( const baseWeapon_t * weapons,
int numWeapons )
static

Check if base or installation weapon can shoot.

Parameters
[in]weaponsPointer to the weapon array of the base.
[in]numWeaponsPointer to the number of weapon in this base.
Returns
true if the base can fight, false else
See also
AII_BaseCanShoot

Definition at line 1134 of file cp_mapfightequip.cpp.

References AIRFIGHT_CheckWeapon(), AIRFIGHT_WEAPON_CAN_NEVER_SHOOT, and i.

Referenced by AII_BaseCanShoot(), and AII_InstallationCanShoot().

◆ AII_WeightToName()

const char * AII_WeightToName ( itemWeight_t weight)

Translate a weight int to a translated string.

See also
itemWeight_t
AII_GetItemWeightBySize

Definition at line 1285 of file cp_mapfightequip.cpp.

References _, ITEM_HEAVY, ITEM_LIGHT, and ITEM_MEDIUM.

Referenced by AIM_AircraftEquipMenuUpdate(), and UP_AircraftItemDescription().

◆ AIM_AutoEquipAircraft()

void AIM_AutoEquipAircraft ( aircraft_t * aircraft)

Auto Add weapon and ammo to an aircraft.

Parameters
[in]aircraftPointer to the aircraft
Note
This is used to auto equip interceptor of first base.
See also
B_SetUpBase
Todo
Eliminate hardcoded techs here.

Definition at line 784 of file cp_mapfightequip.cpp.

References AII_AddItemToSlot(), AII_AutoAddAmmo(), AII_GetItemWeightBySize(), AII_UpdateAircraftStats(), B_BaseHasItem(), cgi, ERR_DROP, aircraft_t::homebase, i, aircraftSlot_t::installationTime, INVSH_GetItemByID(), aircraftSlot_t::item, aircraft_t::maxWeapons, technology_t::provides, RS_GetTechByID(), aircraftSlot_t::size, and aircraft_t::weapons.

Referenced by B_SetUpFirstBase().

◆ AIM_PilotAssignedAircraft()

bool AIM_PilotAssignedAircraft ( const base_t * base,
const Employee * pilot )

Checks to see if the pilot is in any aircraft at this base.

Parameters
[in]baseWhich base has the aircraft to search for the employee in.
[in]pilotWhich employee to search for.
Returns
true or false depending on if the employee was found on the base aircraft.

Definition at line 166 of file cp_mapfightequip.cpp.

References AIR_ForeachFromBase, and AIR_GetPilot().

◆ AIM_SelectableCraftItem()

bool AIM_SelectableCraftItem ( const aircraftSlot_t * slot,
const technology_t * tech )

Check if an aircraft item should or should not be displayed in airequip menu.

Parameters
[in]slotPointer to an aircraft slot (can be base/installation too)
[in]techPointer to the technology to test
Returns
true if the craft item should be displayed, false else
Todo
maybe this isn't working, aircraft slot type can't be an AMMO
Todo
This only works for ammo that is usable in exactly one weapon check the weap_idx array and not only the first value

Definition at line 92 of file cp_mapfightequip.cpp.

References AC_ITEM_AMMO, AII_GetItemWeightBySize(), aircraftSlot_t::aircraft, objDef_t::ammos, B_BaseHasItem(), aircraftSlot_t::base, objDef_t::craftitem, objDef_t::idx, craftItem::installationTime, INVSH_GetItemByID(), aircraftSlot_t::item, aircraftSlot_t::nextItem, objDef_t::numAmmos, technology_t::provides, RS_IsResearched_ptr(), aircraftSlot_t::size, aircraftSlot_t::type, craftItem::type, and objDef_t::weapons.

Referenced by AII_AutoAddAmmo(), AIM_UpdateAircraftItemList(), BDEF_AddItem_f(), BDEF_SelectItem_f(), and BDEF_UpdateAircraftItemList().

◆ AIR_GetMaxAircraftWeaponRange()

float AIR_GetMaxAircraftWeaponRange ( const aircraftSlot_t * slot,
int maxSlot )

Get the maximum weapon range of aircraft.

Parameters
[in]slotPointer to the aircrafts weapon slot list.
[in]maxSlotmaximum number of weapon slots in aircraft.
Returns
Maximum weapon range for this aircaft as an angle.

Definition at line 1004 of file cp_mapfightequip.cpp.

References AII_CheckUpdateAircraftStats(), AIR_STATS_WRANGE, aircraftSlot_t::ammo, objDef_t::craftitem, i, and craftItem::stats.

Referenced by AII_UpdateAircraftStats().

◆ BDEF_AddBattery()

void BDEF_AddBattery ( basedefenceType_t basedefType,
base_t * base )

Adds a defence system to base.

Parameters
[in]basedefTypeBase defence type (see basedefenceType_t)
[in]basePointer to the base in which the battery will be added
See also
BDEF_RemoveBattery

Definition at line 186 of file cp_mapfightequip.cpp.

References AMMO_STATUS_NOT_SET, aircraftSlot_t::ammoLeft, baseWeapon_t::autofire, BASEDEF_LASER, BASEDEF_MISSILE, base_t::batteries, cgi, base_t::lasers, MAX_BASE_SLOT, base_t::numBatteries, base_t::numLasers, and baseWeapon_t::slot.

Referenced by BDEF_AddBattery_f().

◆ BDEF_AutoSelectTarget()

void BDEF_AutoSelectTarget ( void )

Chooses target for all base defences and sam sites.

Definition at line 1266 of file cp_mapfightequip.cpp.

References B_GetNext(), base_t::batteries, BDEF_AutoTarget(), INS_Foreach, base_t::lasers, base_t::numBatteries, and base_t::numLasers.

Referenced by CP_CampaignRun().

◆ BDEF_AutoTarget()

void BDEF_AutoTarget ( baseWeapon_t * weapons,
int maxWeapons )
static

◆ BDEF_GetBaseSlotByIDX()

aircraftSlot_t * BDEF_GetBaseSlotByIDX ( base_t * base,
aircraftItemType_t type,
int idx )

returns the aircraftSlot of a base at an index or the first free slot

Parameters
[in]basePointer to base
[in]typedefence type, see aircraftItemType_t
[in]idxindex of aircraftslot
Returns
the aircraftSlot at the index idx if idx non-negative the first free slot otherwise

Definition at line 900 of file cp_mapfightequip.cpp.

References AC_ITEM_BASE_LASER, AC_ITEM_BASE_MISSILE, base_t::batteries, i, aircraftSlot_t::item, base_t::lasers, aircraftSlot_t::nextItem, base_t::numBatteries, base_t::numLasers, baseWeapon_t::slot, and type.

Referenced by BDEF_AddItem_f(), BDEF_RemoveItem_f(), and BDEF_SelectItem_f().

◆ BDEF_GetInstallationSlotByIDX()

aircraftSlot_t * BDEF_GetInstallationSlotByIDX ( installation_t * installation,
aircraftItemType_t type,
int idx )

returns the aircraftSlot of an installaion at an index or the first free slot

Parameters
[in]installationPointer to the installation
[in]typedefence type, see aircraftItemType_t
[in]idxindex of aircraftslot
Returns
the aircraftSlot at the index idx if idx non-negative the first free slot otherwise

Definition at line 938 of file cp_mapfightequip.cpp.

References AC_ITEM_BASE_MISSILE, installation_t::batteries, i, aircraftSlot_t::item, aircraftSlot_t::nextItem, installation_t::numBatteries, baseWeapon_t::slot, and type.

Referenced by BDEF_AddItem_f(), BDEF_RemoveItem_f(), and BDEF_SelectItem_f().

◆ BDEF_InitialiseBaseSlots()

void BDEF_InitialiseBaseSlots ( base_t * base)

Initialise all values of base slot defence.

Parameters
[in]basePointer to the base which needs initalisation of its slots.

Definition at line 283 of file cp_mapfightequip.cpp.

References AC_ITEM_BASE_LASER, AC_ITEM_BASE_MISSILE, AII_InitialiseSlot(), baseWeapon_t::autofire, base_t::batteries, i, base_t::lasers, MAX_BASE_SLOT, baseWeapon_t::slot, and baseWeapon_t::target.

Referenced by B_Build(), and B_LoadXML().

◆ BDEF_InitialiseInstallationSlots()

void BDEF_InitialiseInstallationSlots ( installation_t * installation)

Initialise all values of installation slot defence.

Parameters
[in]installationPointer to the installation which needs initialisation of its slots.

Definition at line 301 of file cp_mapfightequip.cpp.

References AC_ITEM_BASE_MISSILE, AII_InitialiseSlot(), baseWeapon_t::autofire, installation_t::batteries, i, installation_t::installationTemplate, installationTemplate_t::maxBatteries, baseWeapon_t::slot, and baseWeapon_t::target.

Referenced by INS_FinishInstallation(), and INS_LoadXML().

◆ BDEF_RemoveBattery()

void BDEF_RemoveBattery ( base_t * base,
basedefenceType_t basedefType,
int idx )

Remove a base defence sytem from base.

Parameters
[in]baseThe base that is affected
[in]basedefType(see basedefenceType_t)
[in]idxindex of the battery to destroy
Note
if idx is negative the function looks for an empty battery to remove, it removes the last one if every one equipped
See also
BDEF_AddBattery

Definition at line 230 of file cp_mapfightequip.cpp.

References AC_ITEM_BASE_LASER, AC_ITEM_BASE_MISSILE, AII_InitialiseSlot(), BASEDEF_LASER, BASEDEF_MISSILE, base_t::batteries, cgi, i, aircraftSlot_t::item, base_t::lasers, base_t::numBatteries, base_t::numLasers, REMOVE_ELEM, and baseWeapon_t::slot.

Referenced by BDEF_RemoveBattery_f().