UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_aircraft.h
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23*/
24
25#pragma once
26
27#include "../../DateTime.h"
28#include "cp_capacity.h"
29#include "cp_radar.h"
30
31#define MAX_AIRCRAFT 64
32#define LINE_MAXSEG 64
33#define LINE_MAXPTS (LINE_MAXSEG + 2)
34
36#define AIRCRAFT_REFUEL_FACTOR 16
37
39typedef struct mapline_s {
41 float distance;
44} mapline_t;
45
53
67
74
75#define MAX_AIRCRAFTSLOT 8
76
78typedef struct aircraftSlot_s {
79 int idx;
80 struct base_s* base;
81 struct installation_s* installation;
82 struct aircraft_s* aircraft;
84
85 const objDef_t* item;
86 const objDef_t* ammo;
97
113
115typedef struct aircraft_s {
116 int idx;
119 struct aircraft_s* tpl;
120 char* id;
121 char name[MAX_VAR];
123 char* image;
124 char* model;
127
128 int price;
130 int fuel;
131 int damage;
136 int point;
137 int time;
138
141
143
149
150 struct base_s* homebase;
151 const char* building;
152
153 struct mission_s* mission;
155 char* missionID;
157 struct aircraft_s* aircraftTarget;
158 bool leader;
159 struct radar_s radar;
162
163 struct technology_s* tech;
164
165 bool notifySent[MAX_AIR_NOTIFICATIONS]; /* stores if a notification was already sent */
166
167 bool detected;
169 bool landed;
176
179
180 inline ufoType_t getUfoType() const {
181 return ufotype;
182 }
183 inline void setUfoType(ufoType_t ufoT) {
184 ufotype = ufoT;
185 }
186} aircraft_t;
187
188
193#define AIR_Foreach(var) LIST_Foreach(ccs.aircraft, aircraft_t, var)
194
195#define AIR_IsAircraftOfBase(aircraft, base) ((aircraft)->homebase == (base) && (aircraft)->status != AIR_CRASHED)
196
202#define AIR_ForeachFromBase(var, base) \
203 AIR_Foreach(var) \
204 if (!AIR_IsAircraftOfBase(var, (base))) continue; else
205
206#define AIR_IsUFO(aircraft) ((aircraft)->getUfoType() != UFO_NONE)
207
208
209aircraft_t* AIR_NewAircraft(struct base_s* base, const aircraft_t* aircraftTemplate);
210aircraft_t* AIR_Add(struct base_s* base, const aircraft_t* aircraftTemplate);
211bool AIR_Delete(struct base_s* base, aircraft_t* aircraft);
212void AIR_DeleteAircraft(aircraft_t* aircraft);
213void AIR_DestroyAircraft(aircraft_t* aircraft, bool killPilot = true);
214
215const aircraft_t* AIR_GetAircraftSilent(const char* name);
216const aircraft_t* AIR_GetAircraft(const char* name);
217
218aircraft_t* AIR_GetFirstFromBase(const struct base_s* base);
219bool AIR_BaseHasAircraft(const struct base_s* base);
220int AIR_BaseCountAircraft(const struct base_s* base);
221aircraft_t* AIR_GetAircraftFromBaseByIDXSafe(const struct base_s* base, int index);
222
224
225const char* AIR_AircraftStatusToName(const aircraft_t* aircraft);
226bool AIR_IsAircraftInBase(const aircraft_t* aircraft);
227bool AIR_IsAircraftOnGeoscape(const aircraft_t* aircraft);
228
229void AIR_ResetAircraftTeam(aircraft_t* aircraft);
230bool AIR_AddToAircraftTeam(aircraft_t* aircraft, class Employee* employee);
231bool AIR_IsInAircraftTeam(const aircraft_t* aircraft, const class Employee* employee);
232int AIR_GetTeamSize(const aircraft_t* aircraft);
233
234void AIR_CampaignRun(const struct campaign_s* campaign, int dt, bool updateRadarOverlay);
235bool AIR_AircraftMakeMove(int dt, aircraft_t* aircraft);
236
237void AIR_ParseAircraft(const char* name, const char** text, bool assignAircraftItems);
238
239bool AIR_AircraftHasEnoughFuel(const aircraft_t* aircraft, const vec2_t destination);
240bool AIR_AircraftHasEnoughFuelOneWay(const aircraft_t* aircraft, const vec2_t destination);
241
243bool AIR_SendAircraftToMission(aircraft_t* aircraft, struct mission_s* mission);
244
245void AIR_AircraftsNotifyMissionRemoved(const struct mission_s* mission);
246void AIR_AircraftsNotifyUFORemoved(const aircraft_t* const ufo, bool destroyed);
247
248void AIR_GetDestinationWhilePursuing(const aircraft_t* shooter, const aircraft_t* target, vec2_t dest);
250void AIR_AircraftsUFODisappear(const aircraft_t* const ufo);
251bool AIR_ScriptSanityCheck(void);
252int AIR_AircraftMenuStatsValues(const int value, const int stat);
253int AIR_CountInBaseByTemplate(const struct base_s* base, const aircraft_t* aircraftTemplate);
254
255int AIR_GetAircraftWeaponRanges(const aircraftSlot_t* slot, int maxSlot, float* weaponRanges);
257
258const char* AIR_CheckMoveIntoNewHomebase(const aircraft_t* aircraft, const struct base_s* base);
259void AIR_MoveAircraftIntoNewHomebase(aircraft_t* aircraft, struct base_s* base);
260
261void AII_CollectItem(aircraft_t* aircraft, const objDef_t* item, int amount);
262void AII_CollectingItems(aircraft_t* aircraft, int won);
263
264bool AIR_SetPilot(aircraft_t* aircraft, class Employee* pilot);
265Employee* AIR_GetPilot(const aircraft_t* aircraft);
266
267bool AIR_PilotSurvivedCrash(const aircraft_t* aircraft);
268
269bool AIR_AddEmployee(Employee* employee, aircraft_t* aircraft);
270void AIR_RemoveEmployees(aircraft_t& aircraft);
271bool AIR_RemoveEmployee(Employee* employee, aircraft_t* aircraft);
272
273const aircraft_t* AIR_IsEmployeeInAircraft(const class Employee* employee, const aircraft_t* aircraft);
274
275void AIR_AutoAddPilotToAircraft(const struct base_s* base, class Employee* pilot);
276void AIR_RemovePilotFromAssignedAircraft(const struct base_s* base, const class Employee* pilot);
277
279
280void AIR_AssignInitial(aircraft_t* aircraft);
281
282bool AIR_CanIntercept(const aircraft_t* aircraft);
283
284int AIR_GetOperationRange(const aircraft_t* aircraft);
285int AIR_GetRemainingRange(const aircraft_t* aircraft);
286
287void AIR_InitStartup(void);
288void AIR_Shutdown(void);
DateTime class definition.
Alien cargo class.
Definition aliencargo.h:41
Class describing a point of time.
Definition DateTime.h:31
Item cargo class.
Definition itemcargo.h:41
void AIR_AssignInitial(aircraft_t *aircraft)
Assigns initial team of soldiers to aircraft.
void AIR_AircraftReturnToBase(aircraft_t *aircraft)
Calculates the way back to homebase for given aircraft and returns it.
itemWeight_t
different weight for aircraft items
Definition cp_aircraft.h:48
@ ITEM_HEAVY
Definition cp_aircraft.h:51
@ ITEM_MEDIUM
Definition cp_aircraft.h:50
@ ITEM_LIGHT
Definition cp_aircraft.h:49
bool AIR_CanIntercept(const aircraft_t *aircraft)
bool AIR_BaseHasAircraft(const struct base_s *base)
int AIR_BaseCountAircraft(const struct base_s *base)
Employee * AIR_GetPilot(const aircraft_t *aircraft)
Get pilot of an aircraft.
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
bool AIR_Delete(struct base_s *base, aircraft_t *aircraft)
const char * AIR_AircraftStatusToName(const aircraft_t *aircraft)
Translates the aircraft status id to a translatable string.
#define LINE_MAXPTS
Definition cp_aircraft.h:33
void AIR_ParseAircraft(const char *name, const char **text, bool assignAircraftItems)
Parses all aircraft that are defined in our UFO-scripts.
bool AIR_AircraftHasEnoughFuel(const aircraft_t *aircraft, const vec2_t destination)
check if aircraft has enough fuel to go to destination, and then come back home
const char * AIR_CheckMoveIntoNewHomebase(const aircraft_t *aircraft, const struct base_s *base)
void AIR_CampaignRun(const struct campaign_s *campaign, int dt, bool updateRadarOverlay)
aircraft_t * AIR_GetAircraftFromBaseByIDXSafe(const struct base_s *base, int index)
void AII_CollectingItems(aircraft_t *aircraft, int won)
Collect items from the battlefield.
void AIR_RemovePilotFromAssignedAircraft(const struct base_s *base, const class Employee *pilot)
int AIR_GetOperationRange(const aircraft_t *aircraft)
Calculates the range an aircraft can fly on the geoscape.
void AIR_AircraftsNotifyUFORemoved(const aircraft_t *const ufo, bool destroyed)
Notify that a UFO has been removed.
bool AIR_SetPilot(aircraft_t *aircraft, class Employee *pilot)
Assign a pilot to an aircraft.
int AIR_GetAircraftWeaponRanges(const aircraftSlot_t *slot, int maxSlot, float *weaponRanges)
Get the all the unique weapon ranges of this aircraft.
aircraft_t * AIR_GetFirstFromBase(const struct base_s *base)
int AIR_GetRemainingRange(const aircraft_t *aircraft)
Calculates the remaining range the aircraft can fly.
bool AIR_AircraftHasEnoughFuelOneWay(const aircraft_t *aircraft, const vec2_t destination)
check if aircraft has enough fuel to go to destination
void AII_CollectItem(aircraft_t *aircraft, const objDef_t *item, int amount)
Add an item to aircraft inventory.
void AIR_AutoAddPilotToAircraft(const struct base_s *base, class Employee *pilot)
int AIR_AircraftMenuStatsValues(const int value, const int stat)
Some of the aircraft values needs special calculations when they are shown in the menus.
bool AIR_PilotSurvivedCrash(const aircraft_t *aircraft)
Determine if an aircraft's pilot survived a crash, based on his piloting skill (and a bit of randomne...
void AIR_DestroyAircraft(aircraft_t *aircraft, bool killPilot=true)
Removes an aircraft from its base and the game.
bool AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft)
Checks whether given aircraft is on geoscape.
bool AIR_SendAircraftPursuingUFO(aircraft_t *aircraft, aircraft_t *ufo)
Make the specified aircraft purchasing a UFO.
const aircraft_t * AIR_IsEmployeeInAircraft(const class Employee *employee, const aircraft_t *aircraft)
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
void AIR_ResetAircraftTeam(aircraft_t *aircraft)
Resets team in given aircraft.
#define MAX_AIRCRAFTSLOT
Definition cp_aircraft.h:75
int AIR_GetTeamSize(const aircraft_t *aircraft)
Counts the number of soldiers in given aircraft.
bool AIR_ScriptSanityCheck(void)
Checks the parsed aircraft for errors.
aircraft_t * AIR_NewAircraft(struct base_s *base, const aircraft_t *aircraftTemplate)
bool AIR_SendAircraftToMission(aircraft_t *aircraft, struct mission_s *mission)
aircraftStatus_t
Definition cp_aircraft.h:99
@ AIR_MISSION
@ AIR_HOME
@ AIR_RETURNING
@ AIR_DROP
@ AIR_REFUEL
@ AIR_UFO
@ AIR_IDLE
@ AIR_NONE
@ AIR_INTERCEPT
@ AIR_TRANSIT
@ AIR_CRASHED
@ AIR_TRANSFER
bool AIR_AddEmployee(Employee *employee, aircraft_t *aircraft)
Assigns a soldier to an aircraft.
void AIR_AircraftsUFODisappear(const aircraft_t *const ufo)
Notify that a UFO disappear from radars.
aircraft_t * AIR_Add(struct base_s *base, const aircraft_t *aircraftTemplate)
void AIR_MoveAircraftIntoNewHomebase(aircraft_t *aircraft, struct base_s *base)
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
void AIR_GetDestinationWhilePursuing(const aircraft_t *shooter, const aircraft_t *target, vec2_t dest)
Calculates the point where aircraft should go to intecept a moving target.
void AIR_InitStartup(void)
Init actions for aircraft-subsystem.
itemPos_t
different positions for aircraft items
Definition cp_aircraft.h:55
@ AIR_NOSE_RIGHT
Definition cp_aircraft.h:58
@ AIR_REAR_RIGHT
Definition cp_aircraft.h:63
@ AIR_REAR_LEFT
Definition cp_aircraft.h:61
@ AIR_WING_RIGHT
Definition cp_aircraft.h:60
@ AIR_REAR_CENTER
Definition cp_aircraft.h:62
@ AIR_WING_LEFT
Definition cp_aircraft.h:59
@ AIR_NOSE_LEFT
Definition cp_aircraft.h:56
@ AIR_NOSE_CENTER
Definition cp_aircraft.h:57
@ AIR_POSITIONS_MAX
Definition cp_aircraft.h:65
aircraft_notifications_t
notification signals for aircraft events
Definition cp_aircraft.h:69
@ AIR_CANNOT_REFUEL
Definition cp_aircraft.h:70
@ MAX_AIR_NOTIFICATIONS
Definition cp_aircraft.h:72
void AIR_MoveEmployeeInventoryIntoStorage(const aircraft_t &aircraft, equipDef_t &equip)
Move all the equipment carried by the team on the aircraft into the given equipment.
bool AIR_AddToAircraftTeam(aircraft_t *aircraft, class Employee *employee)
Adds given employee to given aircraft.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
const aircraft_t * AIR_GetAircraftSilent(const char *name)
Searches the global array of aircraft types for a given aircraft.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
void AIR_AircraftsNotifyMissionRemoved(const struct mission_s *mission)
int AIR_CountInBaseByTemplate(const struct base_s *base, const aircraft_t *aircraftTemplate)
aircraft_t * AIR_AircraftGetFromIDX(int idx)
Returns aircraft for a given global index.
void AIR_Shutdown(void)
Closing actions for aircraft-subsystem.
bool AIR_IsInAircraftTeam(const aircraft_t *aircraft, const class Employee *employee)
bool AIR_AircraftMakeMove(int dt, aircraft_t *aircraft)
Moves given aircraft.
void AIR_RemoveEmployees(aircraft_t &aircraft)
Removes all soldiers from an aircraft.
baseCapacities_t
All possible capacities in base.
Definition cp_capacity.h:27
@ AIR_STATS_MAX
Definition inv_shared.h:237
aircraftItemType_t
All different types of craft items.
Definition inv_shared.h:197
QGL_EXTERN GLenum GLuint * dest
Definition r_gl.h:101
QGL_EXTERN GLuint index
Definition r_gl.h:110
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
short ufoType_t
Definition scripts.h:145
#define MAX_VAR
Definition shared.h:36
An aircraft with all it's data.
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
int maxElectronics
bool notOnGeoscape
struct aircraft_s * aircraftTarget
int ufoInterestOnGeoscape
class AlienCargo * alienCargo
struct base_s * homebase
aircraftStatus_t status
const char * building
vec3_t projectedPos
int productionCost
int stats[AIR_STATS_MAX]
char * image
aircraftSlot_t shield
char * missionID
struct mission_s * mission
class DateTime lastSpotted
mapline_t route
linkedList_t * acTeam
ufoType_t ufotype
class Employee * pilot
class ItemCargo * itemCargo
void setUfoType(ufoType_t ufoT)
struct aircraft_s * tpl
char name[MAX_VAR]
char * model
linkedList_t * missionTypes
struct radar_s radar
ufoType_t getUfoType() const
aircraftSlot_t electronics[MAX_AIRCRAFTSLOT]
struct technology_s * tech
bool notifySent[MAX_AIR_NOTIFICATIONS]
vec3_t direction
char * defaultName
slot of aircraft
Definition cp_aircraft.h:78
const objDef_t * item
Definition cp_aircraft.h:85
const objDef_t * nextAmmo
Definition cp_aircraft.h:94
const objDef_t * ammo
Definition cp_aircraft.h:86
struct installation_s * installation
Definition cp_aircraft.h:81
struct aircraft_s * aircraft
Definition cp_aircraft.h:82
itemPos_t pos
Definition cp_aircraft.h:95
struct base_s * base
Definition cp_aircraft.h:80
itemWeight_t size
Definition cp_aircraft.h:87
aircraftItemType_t type
Definition cp_aircraft.h:83
const objDef_t * nextItem
Definition cp_aircraft.h:92
A path on the map described by 2D points.
Definition cp_aircraft.h:39
float distance
Definition cp_aircraft.h:41
vec2_t point[LINE_MAXPTS]
Definition cp_aircraft.h:43
int numPoints
Definition cp_aircraft.h:40
Defines all attributes of objects used in the inventory.
Definition inv_shared.h:264
vec_t vec3_t[3]
Definition ufotypes.h:39
vec_t vec2_t[2]
Definition ufotypes.h:38