34#define UFO_RELOAD_DELAY_MULTIPLIER 2
35#define AIRCRAFT_RELOAD_DELAY_MULTIPLIER 2
36#define BASE_RELOAD_DELAY_MULTIPLIER 2
37#define INSTALLATION_RELOAD_DELAY_MULTIPLIER 2
49 for (
int i = 0;
i <
cgi->csi->numODs;
i++) {
59 cgi->Com_Printf(
"AII_GetCraftitemTechsByType: MAX_TECHNOLOGIES limit hit.\n");
64 techList[j] =
nullptr;
80 else if (od->
size < 100)
112 if (weapon ==
nullptr)
116 for (k = 0; k < weapon->
numAmmos; k++) {
118 if (usable && item->
idx == usable->
idx)
147 }
else if (slot->
base) {
188 switch (basedefType) {
191 cgi->Com_Printf(
"BDEF_AddBattery: too many missile batteries in base\n");
204 cgi->Com_Printf(
"BDEF_AddBattery: too many laser batteries in base\n");
217 cgi->Com_Printf(
"BDEF_AddBattery: unknown type of air defence system.\n");
235 switch (basedefType) {
275 cgi->Com_Printf(
"BDEF_RemoveBattery_f: unknown type of air defence system.\n");
291 battery->
target =
nullptr;
306 battery->
target =
nullptr;
322 assert(base || installation);
336 _(
"%s was successfully installed into aircraft %s at %s."),
338 }
else if (installation) {
352 if (aircraft && aircraft->
homebase != base)
353 Sys_Error(
"AII_UpdateOneInstallationDelay: aircraft->homebase and base pointers are out of sync\n");
362 _(
"%s was successfully removed from aircraft %s at %s."),
367 _ (
"%s was successfully removed, starting installation of %s into aircraft %s at %s"),
371 }
else if (!slot->
item) {
374 _(
"%s was successfully removed from installation %s."),
398 for (k = 0; k < installation->installationTemplate->maxBatteries; k++)
403 while ((base =
B_GetNext(base)) !=
nullptr) {
415 for (k = 0; k < aircraft->maxElectronics; k++)
418 for (k = 0; k < aircraft->maxWeapons; k++)
452 for (
int k = 0; k < item->
numAmmos; k++) {
493 slot->
ammo =
nullptr;
497 }
else if (slot->
item) {
515 slot->
item =
nullptr;
518 slot->
ammo =
nullptr;
597 slot->
ammo =
nullptr;
607 }
else if (slot->
base) {
621 cgi->Com_Error(
ERR_DROP,
"AII_ReloadWeapon: AircraftSlot not linked anywhere (aircraft/base/installation)!\n");
649 if (slot ==
nullptr || slot->
item ==
nullptr)
656 cgi->Com_Printf(
"AII_AddAmmoToSlot: Could not add item (%s) to slot\n", tech->
provides);
664 for (k = 0; k < item->
numAmmos; k++) {
666 if (usable && ammo->
idx == usable->
idx)
676 cgi->Com_Printf(
"AII_AddAmmoToSlot: No more ammo of this type to equip (%s)\n", ammo->
id);
731 cgi->Com_Printf(
"AII_AddItemToSlot: Could not add item (%s) to slot\n", tech->
provides);
740 cgi->Com_Printf(
"AII_AddItemToSlot: Type of the item to install (%s) should be a weapon, a shield, or electronics (no ammo)\n", item->
id);
747 cgi->Com_Printf(
"AII_AddItemToSlot: Type of the item to install (%s -- %i) doesn't match type of the slot (%i)\n", item->
id, item->
craftitem.
type, slot->
type);
753 cgi->Com_Printf(
"AII_AddItemToSlot: No more item of this type to equip (%s)\n", item->
id);
770 cgi->Com_Printf(
"AII_AddItemToSlot: Could not add item '%s' to slot %i (slot-size: %i - item-weight: %i)\n",
792 cgi->Com_Error(
ERR_DROP,
"Could not get tech rs_craft_weapon_sparrowhawk");
816 cgi->Com_Error(
ERR_DROP,
"Could not get tech rs_craft_weapon_shiva");
850 assert((!base && aircraftTemplate) || (base && !aircraftTemplate) || (installation && !aircraftTemplate));
852 assert((!base && installation) || (base && !installation) || (!base && !installation));
858 slot->
item =
nullptr;
859 slot->
ammo =
nullptr;
911 }
else if (idx < base->numBatteries)
922 }
else if (idx < base->numLasers)
948 }
else if (idx < installation->numBatteries)
974 }
else if (idx < aircraft->maxWeapons)
975 return &aircraft->
weapons[idx];
988 }
else if (idx < aircraft->maxElectronics)
1011 for (
int i = 0;
i < maxSlot;
i++) {
1039 while ((base =
B_GetNext(base)) !=
nullptr) {
1043 const int REPAIR_PER_HOUR = std::max(1,
int(round(aircraft->stats[
AIR_STATS_DAMAGE] / 100)));
1045 aircraft->name, REPAIR_PER_HOUR, aircraft->damage, aircraft->stats[
AIR_STATS_DAMAGE]);
1046 aircraft->damage = std::min(aircraft->damage + REPAIR_PER_HOUR, aircraft->stats[
AIR_STATS_DAMAGE]);
1062 for (
int currentStat = 0; currentStat <
AIR_STATS_MAX; currentStat++) {
1068 aircraft->
stats[currentStat] = source->
stats[currentStat];
1136 for (
int i = 0;
i < numWeapons;
i++) {
1175 assert(installation);
1193 if (maxWeapons <= 0)
1203 }
else if (slot->
base) {
1207 cgi->Com_Error(
ERR_DROP,
"BDEF_AutoSelectTarget: slot doesn't belong to any base or installation");
1211 float minCraftDistance = -1;
1213 float minAttackerDistance = -1;
1217 if (minCraftDistance < 0 || minCraftDistance > distance) {
1218 minCraftDistance = distance;
1221 if ((minAttackerDistance < 0 || minAttackerDistance > distance) && ufo->
mission
1224 minAttackerDistance = distance;
1225 closestAttacker = ufo;
1230 for (
int i = 0;
i < maxWeapons;
i++) {
1232 slot = &weapon->
slot;
1247 if (closestAttacker) {
1252 weapon->
target = closestAttacker;
1253 }
else if (closestCraft) {
1258 weapon->
target = closestCraft;
1271 while ((base =
B_GetNext(base)) !=
nullptr) {
1289 return _(
"Light weight");
1292 return _(
"Medium weight");
1295 return _(
"Heavy weight");
1298 return _(
"Unknown weight");
1337 if (
name[0] !=
'\0') {
Share stuff between the different cgame implementations.
#define REMOVE_ELEM(array, index, n)
Employee * AIR_GetPilot(const aircraft_t *aircraft)
Get pilot of an aircraft.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
itemWeight_t
different weight for aircraft items
#define AIR_Foreach(var)
iterates trough all aircraft
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
#define AIR_IsUFO(aircraft)
int AIRFIGHT_CheckWeapon(const aircraftSlot_t *slot, float distance)
Check if the selected weapon can shoot.
#define AIRFIGHT_WEAPON_CAN_NOT_SHOOT_AT_THE_MOMENT
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT
@ INTERESTCATEGORY_BASE_ATTACK
@ INTERESTCATEGORY_INTERCEPT
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
bool B_BaseHasItem(const base_t *base, const objDef_t *item)
Check if an item is available on a base.
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Header file for single player campaign control.
const cgame_import_t * cgi
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
void BDEF_AddBattery(basedefenceType_t basedefType, base_t *base)
Adds a defence system to base.
float AIR_GetMaxAircraftWeaponRange(const aircraftSlot_t *slot, int maxSlot)
Get the maximum weapon range of aircraft.
bool AII_ReloadWeapon(aircraftSlot_t *slot)
Reloads an aircraft/defence-system weapon.
void AII_RepairAircraft(void)
Repair aircraft.
void BDEF_InitialiseInstallationSlots(installation_t *installation)
Initialise all values of installation slot defence.
#define INSTALLATION_RELOAD_DELAY_MULTIPLIER
void BDEF_RemoveBattery(base_t *base, basedefenceType_t basedefType, int idx)
Remove a base defence sytem from base.
static bool AII_CheckUpdateAircraftStats(const aircraftSlot_t *slot, int stat)
Check if item in given slot should change one aircraft stat.
static void AII_UpdateOneInstallationDelay(base_t *base, installation_t *installation, aircraft_t *aircraft, aircraftSlot_t *slot)
Update the installation delay of one slot.
void AIM_AutoEquipAircraft(aircraft_t *aircraft)
Auto Add weapon and ammo to an aircraft.
void AII_LoadOneSlotXML(xmlNode_t *node, aircraftSlot_t *slot, bool weapon)
Loads one slot (base, installation or aircraft).
void AII_UpdateInstallationDelay(void)
Update the installation delay of all slots of a given aircraft.
#define BASE_RELOAD_DELAY_MULTIPLIER
itemWeight_t AII_GetItemWeightBySize(const objDef_t *od)
Returns craftitem weight based on size.
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
static bool AII_WeaponsCanShoot(const baseWeapon_t *weapons, int numWeapons)
Check if base or installation weapon can shoot.
#define UFO_RELOAD_DELAY_MULTIPLIER
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_AutoAddAmmo(aircraftSlot_t *slot)
Auto add ammo corresponding to weapon, if there is enough in storage.
#define AIRCRAFT_RELOAD_DELAY_MULTIPLIER
const char * AII_WeightToName(itemWeight_t weight)
Translate a weight int to a translated string.
void AII_ReloadAircraftWeapons(aircraft_t *aircraft)
Reload the weapons of an aircraft.
void AII_UpdateAircraftStats(aircraft_t *aircraft)
Update the value of stats array of an aircraft.
technology_t ** AII_GetCraftitemTechsByType(aircraftItemType_t type)
Returns a list of craftitem technologies for the given type.
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
bool AII_AddItemToSlot(base_t *base, const technology_t *tech, aircraftSlot_t *slot, bool nextItem)
Add an item to an aircraft slot.
bool AII_AddAmmoToSlot(base_t *base, const technology_t *tech, aircraftSlot_t *slot)
Add an ammo to an aircraft weapon slot.
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.
void BDEF_AutoSelectTarget(void)
Chooses target for all base defences and sam sites.
void BDEF_InitialiseBaseSlots(base_t *base)
Initialise all values of base slot defence.
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.
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.
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.
bool AIM_PilotAssignedAircraft(const base_t *base, const Employee *pilot)
Checks to see if the pilot is in any aircraft at this base.
void AII_SaveOneSlotXML(xmlNode_t *p, const aircraftSlot_t *slot, bool weapon)
Save callback for savegames in XML Format.
static void BDEF_AutoTarget(baseWeapon_t *weapons, int maxWeapons)
Chooses a target for surface to air defences automatically.
Header for slot management related stuff.
basedefenceType_t
The different possible types of base defence systems.
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...
@ NT_INSTALLATION_INSTALLED
@ NT_INSTALLATION_REPLACE
@ NT_INSTALLATION_REMOVED
char cp_messageBuffer[MAX_MESSAGE_TEXT]
Campaign missions headers.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
aircraft_t * UFO_GetNextOnGeoscape(aircraft_t *lastUFO)
void Sys_Error(const char *error,...)
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
aircraftItemType_t
All different types of craft items.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
XML tag constants for savegame.
#define SAVE_SLOT_INSTALLATIONTIME
#define SAVE_SLOT_NEXTITEMID
#define SAVE_SLOT_DELAYNEXTSHOT
#define SAVE_SLOT_NEXTAMMOID
#define SAVE_SLOT_AMMOLEFT
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
An aircraft with all it's data.
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
struct mission_s * mission
aircraftSlot_t electronics[MAX_AIRCRAFTSLOT]
const objDef_t * nextAmmo
struct installation_s * installation
struct aircraft_s * aircraft
const objDef_t * nextItem
A base with all it's data.
baseWeapon_t batteries[MAX_BASE_SLOT]
baseWeapon_t lasers[MAX_BASE_SLOT]
float stats[AIR_STATS_MAX]
A installation with all it's data.
const installationTemplate_t * installationTemplate
baseWeapon_t batteries[MAX_INSTALLATION_BATTERIES]
installationStatus_t installationStatus
Defines all attributes of objects used in the inventory.
const struct objDef_s * ammos[MAX_AMMOS_PER_OBJDEF]
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
This is the technology parsed from research.ufo.