inv_shared.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 
00026 #ifndef GAME_INV_SHARED_H
00027 #define GAME_INV_SHARED_H
00028 
00029 struct csi_s;
00030 
00032 typedef enum {
00033     DROPSHIP_FIREBIRD,
00034     DROPSHIP_HERAKLES,
00035     DROPSHIP_RAPTOR,
00036 
00037     INTERCEPTOR_STILETTO,
00038     INTERCEPTOR_SARACEN,
00039     INTERCEPTOR_DRAGON,
00040     INTERCEPTOR_STARCHASER,
00041     INTERCEPTOR_STINGRAY,
00042 
00043     AIRCRAFTTYPE_MAX
00044 } humanAircraftType_t;
00045 
00046 /* this is the absolute max for now */
00047 #define MAX_OBJDEFS     128     /* Remember to adapt the "NONE" define (and similar) if this gets changed. */
00048 #define MAX_MAPDEFS     128
00049 #define MAX_WEAPONS_PER_OBJDEF 4
00050 #define MAX_AMMOS_PER_OBJDEF 4
00051 #define MAX_FIREDEFS_PER_WEAPON 8
00052 #define WEAPON_BALANCE 0.5f
00053 #define SKILL_BALANCE 1.0f
00054 #define INJURY_BALANCE 0.2f
00055 #define INJURY_THRESHOLD 0.5f /* HP / maxHP > INJURY_THRESHOLD no penalty is incurred */
00056 
00057 typedef int32_t containerIndex_t;
00058 
00060 typedef enum {
00061     IA_NONE,            
00063     IA_MOVE,            
00064     IA_ARMOUR,          
00065     IA_RELOAD,          
00066     IA_RELOAD_SWAP,     
00068     IA_NOTIME,          
00069     IA_NORELOAD         
00070 } inventory_action_t;
00071 
00072 typedef int32_t weaponFireDefIndex_t;
00073 typedef int32_t fireDefIndex_t;
00074 
00076 typedef struct fireDef_s {
00077     char name[MAX_VAR];         
00078     char projectile[MAX_VAR];   
00079     char impact[MAX_VAR];       
00080     char hitBody[MAX_VAR];      
00081     char fireSound[MAX_VAR];    
00082     char impactSound[MAX_VAR];  
00083     char hitBodySound[MAX_VAR]; 
00084     float fireAttenuation;      
00085     float impactAttenuation;        
00086     char bounceSound[MAX_VAR];  
00088     /* These values are created in Com_ParseItem and Com_AddObjectLinks.
00089      * They are used for self-referencing the firedef. */
00090     struct objDef_s *obj;       
00091     weaponFireDefIndex_t weapFdsIdx;    
00095     fireDefIndex_t fdIdx;       
00097     qboolean soundOnce;     
00098     qboolean gravity;       
00099     qboolean launched;      
00100     qboolean rolled;        
00101     qboolean reaction;      
00102     int throughWall;        
00103     byte dmgweight;         
00104     float speed;            
00106     vec2_t shotOrg;         
00107     vec2_t spread;          
00108     int delay;          
00110     int bounce;         
00111     float bounceFac;        
00112     float crouch;           
00113     float range;            
00114     int shots;          
00115     int ammo;           
00116     float delayBetweenShots;    
00118     int time;           
00119     vec2_t damage;          
00121     vec2_t spldmg;          
00122     float splrad;           
00123     int weaponSkill;        
00124     int irgoggles;          
00125 } fireDef_t;
00126 
00135 #define SHAPE_SMALL_MAX_WIDTH 8
00136 #define SHAPE_SMALL_MAX_HEIGHT 4
00137 
00147 #define SHAPE_BIG_MAX_HEIGHT 16
00148 
00149 #define SHAPE_BIG_MAX_WIDTH 32
00150 
00156 typedef enum {
00157     /* weapons */
00158     AC_ITEM_BASE_MISSILE,   
00159     AC_ITEM_BASE_LASER,     
00160     AC_ITEM_WEAPON,         
00162     /* misc */
00163     AC_ITEM_SHIELD,         
00164     AC_ITEM_ELECTRONICS,    
00166     /* Crew */
00167     AC_ITEM_PILOT,
00168 
00169     /* ammos */
00170     AC_ITEM_AMMO,           
00171     AC_ITEM_AMMO_MISSILE,   
00172     AC_ITEM_AMMO_LASER,     
00174     MAX_ACITEMS
00175 } aircraftItemType_t;
00176 
00184 typedef enum {
00185     AIR_STATS_SPEED,    
00186     AIR_STATS_MAXSPEED, 
00187     AIR_STATS_SHIELD,   
00188     AIR_STATS_ECM,      
00189     AIR_STATS_DAMAGE,   
00190     AIR_STATS_ACCURACY, 
00191     AIR_STATS_FUELSIZE, 
00192     AIR_STATS_WRANGE,   
00194     AIR_STATS_ANTIMATTER,   
00196     AIR_STATS_MAX,
00197 } aircraftParams_t;
00198 
00205 typedef struct craftitem_s {
00206     aircraftItemType_t type;        
00207     float stats[AIR_STATS_MAX]; 
00208     float weaponDamage;         
00209     float weaponSpeed;          
00210     float weaponDelay;          
00211     int installationTime;       
00212     qboolean bullets;           
00213     qboolean beam;              
00214     vec4_t beamColor;
00215 } craftitem_t;
00216 
00217 #define MAX_DAMAGETYPES 64
00218 
00223 typedef struct objDef_s {
00224     /* Common */
00225     int idx;    
00226     char name[MAX_VAR];     
00227     char id[MAX_VAR];       
00228     char model[MAX_VAR];        
00229     char image[MAX_VAR];        
00230     char type[MAX_VAR];     
00231     char armourPath[MAX_VAR];
00232     uint32_t shape;         
00234     float scale;            
00235     vec3_t center;          
00236     qboolean weapon;        
00237     qboolean holdTwoHanded;     
00238     qboolean fireTwoHanded;     
00239     qboolean extension;     
00240     qboolean headgear;      
00241     qboolean thrown;        
00242     qboolean isVirtual; 
00243     qboolean isPrimary;
00244     qboolean isSecondary;
00245     qboolean isHeavy;
00246     qboolean isMisc;
00247     qboolean isUGVitem;
00248     qboolean isDummy;
00249 
00250     /* Weapon specific. */
00251     int ammo;           
00254     int reload;         
00255     qboolean oneshot;   
00257     qboolean deplete;   
00260     int useable;        
00263     struct objDef_s *ammos[MAX_AMMOS_PER_OBJDEF];       
00264     int numAmmos;           
00266     /* Firemodes (per weapon). */
00267     struct objDef_s *weapons[MAX_WEAPONS_PER_OBJDEF];       
00270     fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON];  
00271     fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]; 
00273     int numWeapons;     
00277     /* Armour specific */
00278     short protection[MAX_DAMAGETYPES];  
00279     short ratings[MAX_DAMAGETYPES];     
00281     byte dmgtype;
00282     byte sx, sy;            
00283     char animationIndex;    
00285     /**** @todo move into campaign only structure ****/
00286     /* Aircraft specific */
00287     craftitem_t craftitem;
00288     int price;          
00289     int size;           
00290     qboolean notOnMarket;       
00291 } objDef_t;
00292 
00297 enum {
00298     INV_DOES_NOT_FIT        = 0,    
00299     INV_FITS                = 1,    
00300     INV_FITS_ONLY_ROTATED   = 2,    
00301     INV_FITS_BOTH           = 3     
00302 };
00303 
00304 #define MAX_INVDEFS 16
00305 
00307 typedef struct invDef_s {
00308     char name[MAX_VAR]; 
00309     containerIndex_t id;                
00311     qboolean single;    
00312     qboolean armour;    
00313     qboolean extension; 
00314     qboolean headgear;  
00315     qboolean all;       
00316     qboolean temp;      
00317     uint32_t shape[SHAPE_BIG_MAX_HEIGHT];   
00318     int in, out;    
00321     qboolean scroll;    
00322 } invDef_t;
00323 
00324 #define MAX_CONTAINERS  MAX_INVDEFS
00325 
00332 typedef struct item_s {
00333     int a;          
00334     objDef_t *m;    
00335     objDef_t *t;    
00336     int amount;     
00337     int rotated;    
00340 } item_t;
00341 
00343 typedef struct invList_s {
00344     item_t item;    
00345     int x, y;       
00348     struct invList_s *next;     
00349 } invList_t;
00350 
00352 typedef struct inventory_s {
00353     invList_t *c[MAX_CONTAINERS];
00354 } inventory_t;
00355 
00356 #define MAX_EQUIPDEFS   64
00357 
00358 typedef struct equipDef_s {
00359     char name[MAX_VAR];     
00360     int numItems[MAX_OBJDEFS];  
00361     byte numItemsLoose[MAX_OBJDEFS];    
00362     int numAircraft[AIRCRAFTTYPE_MAX];
00363     int minInterest;        
00364     int maxInterest;        
00365 } equipDef_t;
00366 
00367 /* Maximum number of alien teams per alien group */
00368 #define MAX_TEAMS_PER_MISSION 4
00369 #define MAX_TERRAINS 8
00370 #define MAX_CULTURES 8
00371 #define MAX_POPULATIONS 8
00372 
00373 typedef struct damageType_s {
00374     char id[MAX_VAR];
00375     qboolean showInMenu;    
00376 } damageType_t;
00377 
00379 typedef enum {
00380     ACTOR_HAND_NOT_SET = 0,
00381     ACTOR_HAND_RIGHT = 1,
00382     ACTOR_HAND_LEFT = 2,
00383 
00384     ACTOR_HAND_ENSURE_32BIT = 0x7FFFFFFF
00385 } actorHands_t;
00386 
00387 #define ACTOR_GET_INV(actor, hand) (((hand) == ACTOR_HAND_RIGHT) ? RIGHT(actor) : (((hand) == ACTOR_HAND_LEFT) ? LEFT(actor) : NULL))
00388 
00389 #define ACTOR_SWAP_HAND(hand) ((hand) == ACTOR_HAND_RIGHT ? ACTOR_HAND_LEFT : ACTOR_HAND_RIGHT)
00390 
00391 qboolean INV_IsFloorDef(const invDef_t* invDef);
00392 qboolean INV_IsRightDef(const invDef_t* invDef);
00393 qboolean INV_IsLeftDef(const invDef_t* invDef);
00394 qboolean INV_IsEquipDef(const invDef_t* invDef);
00395 qboolean INV_IsArmourDef(const invDef_t* invDef);
00396 
00397 /* ================================ */
00398 /*  INVENTORY MANAGEMENT FUNCTIONS  */
00399 /* ================================ */
00400 
00401 invList_t* INVSH_HasArmour(const inventory_t *inv);
00402 void INVSH_InitCSI(struct csi_s * import) __attribute__((nonnull));
00403 int INVSH_CheckToInventory(const inventory_t* const i, const objDef_t *ob, const invDef_t * container, const int x, const int y, const invList_t *ignoredItem);
00404 qboolean INVSH_CompareItem(item_t *item1, item_t *item2);
00405 void INVSH_GetFirstShapePosition(const invList_t *ic, int* const x, int* const y);
00406 qboolean INVSH_ExistsInInventory(const inventory_t* const inv, const invDef_t * container, item_t item);
00407 invList_t *INVSH_SearchInInventory(const inventory_t* const i, const invDef_t * container, const int x, const int y) __attribute__((nonnull(1)));
00408 void INVSH_FindSpace(const inventory_t* const inv, const item_t *item, const invDef_t * container, int * const px, int * const py, const invList_t *ignoredItem) __attribute__((nonnull(1)));
00409 qboolean INV_IsCraftItem(const objDef_t *obj);
00410 qboolean INV_IsBaseDefenceItem(const objDef_t *item);
00411 
00412 objDef_t *INVSH_GetItemByID(const char *id);
00413 objDef_t *INVSH_GetItemByIDX(int index);
00414 objDef_t *INVSH_GetItemByIDSilent(const char *id);
00415 qboolean INVSH_LoadableInWeapon(const objDef_t *od, const objDef_t *weapon);
00416 
00417 invDef_t *INVSH_GetInventoryDefinitionByID(const char *id);
00418 
00419 #define THIS_FIREMODE(fm, HAND, fdIdx)  ((fm)->hand == (HAND) && (fm)->fmIdx == (fdIdx))
00420 #define SANE_FIREMODE(fm)   (((fm)->hand > ACTOR_HAND_NOT_SET && (fm)->fmIdx >= 0 && (fm)->fmIdx < MAX_FIREDEFS_PER_WEAPON))
00421 
00422 #define INV_IsArmour(od)    (!strcmp((od)->type, "armour"))
00423 #define INV_IsAmmo(od)      (!strcmp((od)->type, "ammo"))
00424 
00425 /* =============================== */
00426 /*  FIREMODE MANAGEMENT FUNCTIONS  */
00427 /* =============================== */
00428 
00429 const fireDef_t* FIRESH_GetFiredef(const objDef_t *obj, const weaponFireDefIndex_t weapFdsIdx, const fireDefIndex_t fdIdx);
00430 const fireDef_t *FIRESH_FiredefForWeapon(const item_t *item);
00431 #define FIRESH_IsMedikit(firedef) ((firedef)->damage[0] < 0)
00432 void INVSH_MergeShapes(uint32_t *shape, const uint32_t itemShape, const int x, const int y);
00433 qboolean INVSH_CheckShape(const uint32_t *shape, const int x, const int y);
00434 int INVSH_ShapeSize(const uint32_t shape);
00435 uint32_t INVSH_ShapeRotate(const uint32_t shape);
00436 
00437 const objDef_t* INVSH_HasReactionFireEnabledWeapon(const invList_t *invList);
00438 
00440 #define INV_INVENTORY_BYTES 11
00441 
00442 #endif /* GAME_INV_SHARED_H */

Generated by  doxygen 1.6.2