cp_aircraft.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018 See the GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00024 */
00025 #ifndef CLIENT_CL_AIRCRAFT_H
00026 #define CLIENT_CL_AIRCRAFT_H
00027 
00028 #define MAX_CARGO       32
00029 #define MAX_AIRCRAFT    64
00030 #define LINE_MAXSEG 64
00031 #define LINE_MAXPTS (LINE_MAXSEG + 2)
00032 #define LINE_DPHI   (M_PI / LINE_MAXSEG)
00033 
00035 #define AIRCRAFT_INVALID -1
00036 
00037 #define AIRCRAFT_INBASE_INVALID -1
00038 
00040 #define AIRCRAFT_REFUEL_FACTOR 16
00041 
00042 #define AIR_IsUFO(aircraft) ((aircraft)->ufotype != UFO_MAX)
00043 
00045 typedef struct mapline_s {
00046     int numPoints;      
00047     float distance;     
00049     vec2_t point[LINE_MAXPTS]; 
00050 } mapline_t;
00051 
00053 typedef enum {
00054     AIRCRAFT_TRANSPORTER,
00055     AIRCRAFT_INTERCEPTOR,
00056     AIRCRAFT_UFO
00057 } aircraftType_t;
00058 
00059 #define MAX_HUMAN_AIRCRAFT_TYPE AIRCRAFT_INTERCEPTOR
00060 
00062 typedef enum {
00063     AIRCRAFT_SMALL = 1,
00064     AIRCRAFT_LARGE = 2
00065 } aircraftSize_t;
00066 
00070 typedef enum {
00071     AIRCRAFT_HANGAR_NONE = 0,
00072     AIRCRAFT_HANGAR_SMALL = 1,
00073     AIRCRAFT_HANGAR_BIG = 2,
00074 
00075     AIRCRAFT_HANGAR_ERROR
00076 } aircraftHangarType_t;
00077 
00080 typedef enum {
00081     ITEM_LIGHT,
00082     ITEM_MEDIUM,
00083     ITEM_HEAVY
00084 } itemWeight_t;
00085 
00086 #define MAX_AIRCRAFTITEMS 64
00087 
00089 typedef enum {
00090     AIR_NOSE_LEFT,
00091     AIR_NOSE_CENTER,
00092     AIR_NOSE_RIGHT,
00093     AIR_WING_LEFT,
00094     AIR_WING_RIGHT,
00095     AIR_REAR_LEFT,
00096     AIR_REAR_CENTER,
00097     AIR_REAR_RIGHT,
00098 
00099     AIR_POSITIONS_MAX
00100 } itemPos_t;
00101 
00103 typedef enum {
00104     AIR_CANNOT_REFUEL,
00105 
00106     MAX_AIR_NOTIFICATIONS
00107 } aircraft_notifications_t;
00108 
00110 typedef struct aliensTmp_s {
00111     const teamDef_t* teamDef;       
00112     int amountAlive;        
00113     int amountDead;     
00114 } aliensTmp_t;
00115 
00116 #define MAX_AIRCRAFTSLOT 4
00117 
00119 typedef struct aircraftSlot_s {
00120     int idx;                    
00121     struct base_s *base;        
00122     struct installation_s *installation;    
00123     struct aircraft_s *aircraft;    
00124     aircraftItemType_t type;    
00126     const objDef_t *item;       
00127     const objDef_t *ammo;       
00128     itemWeight_t size;          
00129     int ammoLeft;               
00130     int delayNextShot;          
00131     int installationTime;       
00133     const objDef_t *nextItem;   
00135     const objDef_t *nextAmmo;   
00136     itemPos_t pos;              
00137 } aircraftSlot_t;
00138 
00139 
00141 typedef struct itemsTmp_s {
00142     const objDef_t *item;       
00143     int amount;                 
00144 } itemsTmp_t;
00145 
00147 typedef enum aircraftStatus_s {
00148     AIR_NONE,
00149     AIR_REFUEL,         
00150     AIR_HOME,           
00151     AIR_IDLE,           
00152     AIR_TRANSIT,        
00153     AIR_MISSION,        
00154     AIR_UFO,            
00155     AIR_DROP,           
00156     AIR_INTERCEPT,      
00157     AIR_TRANSFER,       
00158     AIR_CRASHED,        
00159     AIR_RETURNING       
00160 } aircraftStatus_t;
00161 
00163 typedef struct aircraft_s {
00164     int idx;            
00170     struct aircraft_s *tpl; 
00171     char *id;           
00172     char name[MAX_VAR];         
00173     char *defaultName;  
00174     char *image;        
00175     char *model;        
00176     aircraftType_t type;
00177     ufoType_t ufotype;  
00178     aircraftStatus_t status;            
00180     int price;          
00181     int fuel;           
00182     int damage;         
00183     int size;           
00184     vec3_t pos;         
00185     vec3_t direction;   
00186     vec3_t projectedPos;    
00187     vec3_t oldDrawPos;  
00188     qboolean hasMoved;       
00189     int numInterpolationPoints; 
00190     int point;          
00191     int time;           
00192     int hangar;         
00195     int maxTeamSize;    
00196     linkedList_t *acTeam;           
00198     struct employee_s *pilot;           
00200     aircraftSlot_t weapons[MAX_AIRCRAFTSLOT];   
00201     int maxWeapons;                 
00202     aircraftSlot_t shield;          
00203     aircraftSlot_t electronics[MAX_AIRCRAFTSLOT];       
00204     int maxElectronics;             
00206     mapline_t route;
00207     struct base_s *homebase;            
00208     itemsTmp_t itemcargo[MAX_CARGO];    
00209     int itemTypes;                      
00211     char *building;     
00213     struct mission_s* mission;  
00215     char *missionID;            
00217     struct aircraft_s *aircraftTarget;      
00218     struct radar_s radar;               
00219     int stats[AIR_STATS_MAX];   
00222     technology_t* tech;     
00224     qboolean notifySent[MAX_AIR_NOTIFICATIONS]; /* stores if a notification was already sent */
00225 
00226     qboolean detected;      
00228     qboolean landed;        
00230     qboolean notOnGeoscape; 
00231     int ufoInterestOnGeoscape;  
00232     int detectionIdx;       
00233     date_t lastSpotted;     
00234     aliensTmp_t alienCargo[MAX_CARGO];  
00235     int alienCargoTypes;                        
00236 } aircraft_t;
00237 
00238 /* script functions */
00239 
00240 #ifdef DEBUG
00241 void AIR_ListAircraft_f(void);
00242 void AIR_ListAircraftSamples_f(void);
00243 void AIR_ListCraftIndexes_f(void);
00244 #endif
00245 
00246 aircraft_t *AIR_Add(struct base_s *base, const aircraft_t *aircraftTemplate);
00247 qboolean AIR_Delete(struct base_s *base, const aircraft_t *aircraft);
00248 
00249 aircraft_t* AIR_GetNextFromBase(const struct base_s *base, aircraft_t *lastAircraft);
00250 aircraft_t* AIR_GetByIDX(int idx);
00251 
00252 qboolean AIR_BaseHasAircraft(const struct base_s *base);
00253 int AIR_GetAircraftIDXInBase(const aircraft_t* aircraft);
00254 aircraft_t *AIR_GetAircraftFromBaseByIDXSafe(struct base_s *base, int index);
00255 const char *AIR_AircraftStatusToName(const aircraft_t *aircraft);
00256 qboolean AIR_IsAircraftInBase(const aircraft_t *aircraft);
00257 qboolean AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft);
00258 
00259 void AIR_DeleteAircraft(aircraft_t *aircraft);
00260 void AIR_DestroyAircraft(aircraft_t *aircraft);
00261 qboolean AIR_MoveAircraftIntoNewHomebase(aircraft_t *aircraft, struct base_s *base);
00262 
00263 void AIR_ResetAircraftTeam(aircraft_t *aircraft);
00264 qboolean AIR_AddToAircraftTeam(aircraft_t *aircraft, struct employee_s* employee);
00265 qboolean AIR_RemoveFromAircraftTeam(aircraft_t *aircraft, const struct employee_s* employee);
00266 qboolean AIR_IsInAircraftTeam(const aircraft_t *aircraft, const struct employee_s* employee);
00267 int AIR_GetTeamSize(const aircraft_t *aircraft);
00268 
00269 void CL_CampaignRunAircraft(int dt, qboolean updateRadarOverlay);
00270 aircraft_t *AIR_GetAircraftSilent(const char *name);
00271 aircraft_t *AIR_GetAircraft(const char *name);
00272 aircraft_t* AIR_AircraftGetFromIDX(int idx);
00273 qboolean AIR_AircraftMakeMove(int dt, aircraft_t* aircraft);
00274 void AIR_ParseAircraft(const char *name, const char **text, qboolean assignAircraftItems);
00275 qboolean AIR_AircraftHasEnoughFuel(const aircraft_t *aircraft, const vec2_t destination);
00276 qboolean AIR_AircraftHasEnoughFuelOneWay(const aircraft_t *aircraft, const vec2_t destination);
00277 void AIR_AircraftReturnToBase(aircraft_t *aircraft);
00278 qboolean AIR_SendAircraftToMission(aircraft_t* aircraft, struct mission_s* mission);
00279 void AIR_GetDestinationWhilePursuing(const aircraft_t const *shooter, const aircraft_t const *target, vec2_t *dest);
00280 qboolean AIR_SendAircraftPursuingUFO(aircraft_t* aircraft, aircraft_t* ufo);
00281 void AIR_AircraftsNotifyUFORemoved(const aircraft_t *const ufo, qboolean destroyed);
00282 void AIR_AircraftsUFODisappear(const aircraft_t *const ufo);
00283 void AIR_UpdateHangarCapForAll(struct base_s *base);
00284 qboolean AIR_ScriptSanityCheck(void);
00285 int AIR_CalculateHangarStorage(const aircraft_t *aircraft, const struct base_s *base, int used) __attribute__((nonnull (1, 2)));
00286 int CL_AircraftMenuStatsValues(const int value, const int stat);
00287 int AIR_CountTypeInBase(const struct base_s *base, aircraftType_t aircraftType);
00288 const char *AIR_GetAircraftString(aircraftType_t aircraftType);
00289 
00290 int AIR_GetAircraftWeaponRanges(const aircraftSlot_t *slot, int maxSlot, float *weaponRanges);
00291 int AIR_GetCapacityByAircraftWeight(const aircraft_t *aircraft);
00292 
00293 const char *AIR_CheckMoveIntoNewHomebase(const aircraft_t *aircraft, const struct base_s* base, const int capacity);
00294 
00295 void AII_CollectItem(aircraft_t *aircraft, const objDef_t *item, int amount);
00296 void AII_CollectingItems(aircraft_t *aircraft, int won);
00297 
00298 void AIR_AutoAddPilotToAircraft(struct base_s* base, struct employee_s* pilot);
00299 void AIR_RemovePilotFromAssignedAircraft(struct base_s* base, const struct employee_s* pilot);
00300 void AIR_RemoveEmployees(aircraft_t* aircraft);
00301 qboolean AIR_RemoveEmployee(struct employee_s *employee, aircraft_t* aircraft);
00302 const aircraft_t *AIR_IsEmployeeInAircraft(const struct employee_s *employee, const aircraft_t* aircraft);
00303 void AIR_MoveEmployeeInventoryIntoStorage(const aircraft_t *aircraft, equipDef_t *equip);
00304 
00305 void AIM_AddEmployeeFromMenu(aircraft_t *aircraft, const int num);
00306 void AIR_AssignInitial(aircraft_t *aircraft);
00307 
00308 qboolean AIR_CanIntercept(const aircraft_t *aircraft);
00309 
00310 int AIR_GetOperationRange(const aircraft_t *aircraft);
00311 int AIR_GetRemainingRange(const aircraft_t *aircraft);
00312 
00313 #endif

Generated by  doxygen 1.6.2