g_vehicles.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. #ifndef __G_VEHICLES_H
  2. #define __G_VEHICLES_H
  3. #include "q_shared.h"
  4. #include "g_public.h"
  5. typedef enum
  6. {
  7. VH_NONE = 0,
  8. VH_WALKER, //something you ride inside of, it walks like you, like an AT-ST
  9. VH_FIGHTER, //something you fly inside of, like an X-Wing or TIE fighter
  10. VH_SPEEDER, //something you ride on that hovers, like a speeder or swoop
  11. VH_ANIMAL, //animal you ride on top of that walks, like a tauntaun
  12. VH_FLIER, //animal you ride on top of that flies, like a giant mynoc?
  13. VH_NUM_VEHICLES
  14. } vehicleType_t;
  15. enum EWeaponPose
  16. {
  17. WPOSE_NONE = 0,
  18. WPOSE_BLASTER,
  19. WPOSE_SABERLEFT,
  20. WPOSE_SABERRIGHT,
  21. };
  22. extern stringID_table_t VehicleTable[VH_NUM_VEHICLES+1];
  23. #define NO_PILOT_DIE_TIME 10000
  24. //===========================================================================================================
  25. //START VEHICLE WEAPONS
  26. //===========================================================================================================
  27. typedef struct
  28. {
  29. //*** IMPORTANT!!! *** the number of variables in the vehWeaponStats_t struct (including all elements of arrays) must be reflected by NUM_VWEAP_PARMS!!!
  30. //*** IMPORTANT!!! *** vWeapFields table correponds to this structure!
  31. char *name;
  32. qboolean bIsProjectile; //traceline or entity?
  33. qboolean bHasGravity; //if a projectile, drops
  34. qboolean bIonWeapon;//disables ship shields and sends them out of control
  35. qboolean bSaberBlockable;//lightsabers can deflect this projectile
  36. int iMuzzleFX; //index of Muzzle Effect
  37. int iModel; //handle to the model used by this projectile
  38. int iShotFX; //index of Shot Effect
  39. int iImpactFX; //index of Impact Effect
  40. int iG2MarkShaderHandle; //index of shader to use for G2 marks made on other models when hit by this projectile
  41. float fG2MarkSize;//size (diameter) of the ghoul2 mark
  42. int iLoopSound; //index of loopSound
  43. float fSpeed; //speed of projectile/range of traceline
  44. float fHoming; //0.0 = not homing, 0.5 = half vel to targ, half cur vel, 1.0 = all vel to targ
  45. int iLockOnTime; //0 = no lock time needed, else # of ms needed to lock on
  46. int iDamage; //damage done when traceline or projectile directly hits target
  47. int iSplashDamage;//damage done to ents in splashRadius of end of traceline or projectile origin on impact
  48. float fSplashRadius;//radius that ent must be in to take splashDamage (linear fall-off)
  49. int iAmmoPerShot; //how much "ammo" each shot takes
  50. int iHealth; //if non-zero, projectile can be shot, takes this much damage before being destroyed
  51. float fWidth; //width of traceline or bounding box of projecile (non-rotating!)
  52. float fHeight; //height of traceline or bounding box of projecile (non-rotating!)
  53. int iLifeTime; //removes itself after this amount of time
  54. qboolean bExplodeOnExpire; //when iLifeTime is up, explodes rather than simply removing itself
  55. } vehWeaponInfo_t;
  56. //NOTE: this MUST stay up to date with the number of variables in the vehFields table!!!
  57. #define NUM_VWEAP_PARMS 24
  58. #define VWFOFS(x) ((int)&(((vehWeaponInfo_t *)0)->x))
  59. #define MAX_VEH_WEAPONS 16 //sigh... no more than 16 different vehicle weapons
  60. #define VEH_WEAPON_BASE 0
  61. #define VEH_WEAPON_NONE -1
  62. extern vehWeaponInfo_t g_vehWeaponInfo[MAX_VEH_WEAPONS];
  63. extern int numVehicleWeapons;
  64. //===========================================================================================================
  65. //END VEHICLE WEAPONS
  66. //===========================================================================================================
  67. // The maximum number of muzzles a vehicle may have.
  68. #define MAX_VEHICLE_MUZZLES 10
  69. // The maximum number of exhausts a vehicle may have.
  70. #define MAX_VEHICLE_EXHAUSTS 4
  71. // The maxiumum number of different weapons a vehicle may have
  72. #define MAX_VEHICLE_WEAPONS 2
  73. #define MAX_VEHICLE_TURRETS 2
  74. #define MAX_VEHICLE_TURRET_MUZZLES 2
  75. typedef struct
  76. {
  77. int iWeapon; //what vehWeaponInfo index to use
  78. int iDelay; //delay between turret muzzle shots
  79. int iAmmoMax; //how much ammo it has
  80. int iAmmoRechargeMS; //how many MS between every point of recharged ammo
  81. char *yawBone; //bone on ship that this turret uses to yaw
  82. char *pitchBone; //bone on ship that this turret uses to pitch
  83. int yawAxis; //axis on yawBone to which we should to apply the yaw angles
  84. int pitchAxis; //axis on pitchBone to which we should to apply the pitch angles
  85. float yawClampLeft; //how far the turret is allowed to turn left
  86. float yawClampRight; //how far the turret is allowed to turn right
  87. float pitchClampUp; //how far the turret is allowed to title up
  88. float pitchClampDown; //how far the turret is allowed to tilt down
  89. int iMuzzle[MAX_VEHICLE_TURRET_MUZZLES];//iMuzzle-1 = index of ship's muzzle to fire this turret's 1st and 2nd shots from
  90. char *gunnerViewTag;//Where to put the view origin of the gunner (name)
  91. float fTurnSpeed; //how quickly the turret can turn
  92. qboolean bAI; //whether or not the turret auto-targets enemies when it's not manned
  93. qboolean bAILead;//whether
  94. float fAIRange; //how far away the AI will look for enemies
  95. int passengerNum;//which passenger, if any, has control of this turret (overrides AI)
  96. } turretStats_t;
  97. typedef struct
  98. {
  99. //*** IMPORTANT!!! *** See note at top of next structure!!! ***
  100. // Weapon stuff.
  101. int ID;//index into the weapon data
  102. // The delay between shots for each weapon.
  103. int delay;
  104. // Whether or not all the muzzles for each weapon can be linked together (linked delay = weapon delay * number of muzzles linked!)
  105. int linkable;
  106. // Whether or not to auto-aim the projectiles/tracelines at the thing under the crosshair when we fire
  107. qboolean aimCorrect;
  108. //maximum ammo
  109. int ammoMax;
  110. //ammo recharge rate - milliseconds per unit (minimum of 100, which is 10 ammo per second)
  111. int ammoRechargeMS;
  112. //sound to play when out of ammo (plays default "no ammo" sound if none specified)
  113. int soundNoAmmo;
  114. } vehWeaponStats_t;
  115. // Compiler pre-define.
  116. struct Vehicle_t;
  117. typedef struct
  118. {
  119. //*** IMPORTANT!!! *** vehFields table correponds to this structure!
  120. char *name; //unique name of the vehicle
  121. //general data
  122. vehicleType_t type; //what kind of vehicle
  123. int numHands; //if 2 hands, no weapons, if 1 hand, can use 1-handed weapons, if 0 hands, can use 2-handed weapons
  124. float lookPitch; //How far you can look up and down off the forward of the vehicle
  125. float lookYaw; //How far you can look left and right off the forward of the vehicle
  126. float length; //how long it is - used for body length traces when turning/moving?
  127. float width; //how wide it is - used for body length traces when turning/moving?
  128. float height; //how tall it is - used for body length traces when turning/moving?
  129. vec3_t centerOfGravity;//offset from origin: {forward, right, up} as a modifier on that dimension (-1.0f is all the way back, 1.0f is all the way forward)
  130. //speed stats
  131. float speedMax; //top speed
  132. float turboSpeed; //turbo speed
  133. float speedMin; //if < 0, can go in reverse
  134. float speedIdle; //what speed it drifts to when no accel/decel input is given
  135. float accelIdle; //if speedIdle > 0, how quickly it goes up to that speed
  136. float acceleration; //when pressing on accelerator
  137. float decelIdle; //when giving no input, how quickly it drops to speedIdle
  138. float throttleSticks; //if true, speed stays at whatever you accel/decel to, unless you turbo or brake
  139. float strafePerc; //multiplier on current speed for strafing. If 1.0f, you can strafe at the same speed as you're going forward, 0.5 is half, 0 is no strafing
  140. //handling stats
  141. float bankingSpeed; //how quickly it pitches and rolls (not under player control)
  142. float rollLimit; //how far it can roll to either side
  143. float pitchLimit; //how far it can roll forward or backward
  144. float braking; //when pressing on decelerator
  145. float mouseYaw; // The mouse yaw override.
  146. float mousePitch; // The mouse pitch override.
  147. float turningSpeed; //how quickly you can turn
  148. qboolean turnWhenStopped;//whether or not you can turn when not moving
  149. float traction; //how much your command input affects velocity
  150. float friction; //how much velocity is cut on its own
  151. float maxSlope; //the max slope that it can go up with control
  152. qboolean speedDependantTurning;//vehicle turns faster the faster it's going
  153. //durability stats
  154. int mass; //for momentum and impact force (player mass is 10)
  155. int armor; //total points of damage it can take
  156. int shields; //energy shield damage points
  157. int shieldRechargeMS;//energy shield milliseconds per point recharged
  158. float toughness; //modifies incoming damage, 1.0 is normal, 0.5 is half, etc. Simulates being made of tougher materials/construction
  159. int malfunctionArmorLevel;//when armor drops to or below this point, start malfunctioning
  160. int surfDestruction; //can parts of this thing be torn off on impact? -rww
  161. //individual "area" health -rww
  162. int health_front;
  163. int health_back;
  164. int health_right;
  165. int health_left;
  166. //visuals & sounds
  167. char *model; //what model to use - if make it an NPC's primary model, don't need this?
  168. char *skin; //what skin to use - if make it an NPC's primary model, don't need this?
  169. int g2radius; //render radius for the ghoul2 model
  170. int riderAnim; //what animation the rider uses
  171. int radarIconHandle;//what icon to show on radar in MP
  172. char *droidNPC; //NPC to attach to *droidunit tag (if it exists in the model)
  173. int soundOn; //sound to play when get on it
  174. int soundOff; //sound to play when get off
  175. int soundLoop; //sound to loop while riding it
  176. int soundTakeOff; //sound to play when ship takes off
  177. int soundEngineStart;//sound to play when ship's thrusters first activate
  178. int soundSpin; //sound to loop while spiraling out of control
  179. int soundTurbo; //sound to play when turbo/afterburner kicks in
  180. int soundHyper; //sound to play when ship lands
  181. int soundLand; //sound to play when ship lands
  182. int soundFlyBy; //sound to play when they buzz you
  183. int soundFlyBy2; //alternate sound to play when they buzz you
  184. int soundShift1; //sound to play when accelerating
  185. int soundShift2; //sound to play when accelerating
  186. int soundShift3; //sound to play when decelerating
  187. int soundShift4; //sound to play when decelerating
  188. int iExhaustFX; //exhaust effect, played from "*exhaust" bolt(s)
  189. int iTurboFX; //turbo exhaust effect, played from "*exhaust" bolt(s) when ship is in "turbo" mode
  190. int iTurboStartFX; //turbo begin effect, played from "*exhaust" bolts when "turbo" mode begins
  191. int iTrailFX; //trail effect, played from "*trail" bolt(s)
  192. int iImpactFX; //impact effect, for when it bumps into something
  193. int iExplodeFX; //explosion effect, for when it blows up (should have the sound built into explosion effect)
  194. int iWakeFX; //effect it makes when going across water
  195. int iDmgFX; //effect to play on damage from a weapon or something
  196. int iArmorLowFX; //played when armor is less than 30% of full
  197. int iArmorGoneFX; //played when on armor is completely gone
  198. //Weapon stats
  199. vehWeaponStats_t weapon[MAX_VEHICLE_WEAPONS];
  200. // Which weapon a muzzle fires (has to match one of the weapons this vehicle has). So 1 would be weapon 1,
  201. // 2 would be weapon 2 and so on.
  202. int weapMuzzle[MAX_VEHICLE_MUZZLES];
  203. //turrets (if any) on the vehicle
  204. turretStats_t turret[MAX_VEHICLE_TURRETS];
  205. // The max height before this ship (?) starts (auto)landing.
  206. float landingHeight;
  207. //other misc stats
  208. int gravity; //normal is 800
  209. float hoverHeight; //if 0, it's a ground vehicle
  210. float hoverStrength; //how hard it pushes off ground when less than hover height... causes "bounce", like shocks
  211. qboolean waterProof; //can drive underwater if it has to
  212. float bouyancy; //when in water, how high it floats (1 is neutral bouyancy)
  213. int fuelMax; //how much fuel it can hold (capacity)
  214. int fuelRate; //how quickly is uses up fuel
  215. int turboDuration; //how long turbo lasts
  216. int turboRecharge; //how long turbo takes to recharge
  217. int visibility; //for sight alerts
  218. int loudness; //for sound alerts
  219. float explosionRadius;//range of explosion
  220. int explosionDamage;//damage of explosion
  221. int maxPassengers; // The max number of passengers this vehicle may have (Default = 0).
  222. qboolean hideRider; // rider (and passengers?) should not be drawn
  223. qboolean killRiderOnDeath;//if rider is on vehicle when it dies, they should die
  224. qboolean flammable; //whether or not the vehicle should catch on fire before it explodes
  225. int explosionDelay; //how long the vehicle should be on fire/dying before it explodes
  226. //camera stuff
  227. qboolean cameraOverride; //whether or not to use all of the following 3rd person camera override values
  228. float cameraRange; //how far back the camera should be - normal is 80
  229. float cameraVertOffset;//how high over the vehicle origin the camera should be - normal is 16
  230. float cameraHorzOffset;//how far to left/right (negative/positive) of of the vehicle origin the camera should be - normal is 0
  231. float cameraPitchOffset;//a modifier on the camera's pitch (up/down angle) to the vehicle - normal is 0
  232. float cameraFOV; //third person camera FOV, default is 80
  233. float cameraAlpha; //fade out the vehicle to this alpha (0.1-1.0f) if it's in the way of the crosshair
  234. qboolean cameraPitchDependantVertOffset;//use the hacky AT-ST pitch dependant vertical offset
  235. //NOTE: some info on what vehicle weapon to use? Like ATST or TIE bomber or TIE fighter or X-Wing...?
  236. //===VEH_PARM_MAX========================================================================
  237. //*** IMPORTANT!!! *** vehFields table correponds to this structure!
  238. //THE FOLLOWING FIELDS are not in the vehFields table because they are internal variables, not read in from the .veh file
  239. int modelIndex; //set internally, not until this vehicle is spawned into the level
  240. // NOTE: Please note that most of this stuff has been converted from C++ classes to generic C.
  241. // This part of the structure is used to simulate inheritance for vehicles. The basic idea is that all vehicle use
  242. // this vehicle interface since they declare their own functions and assign the function pointer to the
  243. // corresponding function. Meanwhile, the base logic can still call the appropriate functions. In C++ talk all
  244. // of these functions (pointers) are pure virtuals and this is an abstract base class (although it cannot be
  245. // inherited from, only contained and reimplemented (through an object and a setup function respectively)). -AReis
  246. // Makes sure that the vehicle is properly animated.
  247. void (*AnimateVehicle)( Vehicle_t *pVeh );
  248. // Makes sure that the rider's in this vehicle are properly animated.
  249. void (*AnimateRiders)( Vehicle_t *pVeh );
  250. // Determine whether this entity is able to board this vehicle or not.
  251. bool (*ValidateBoard)( Vehicle_t *pVeh, gentity_t *pEnt );
  252. // Set the parent entity of this Vehicle NPC.
  253. void (*SetParent)( Vehicle_t *pVeh, gentity_t *pParentEntity );
  254. // Add a pilot to the vehicle.
  255. void (*SetPilot)( Vehicle_t *pVeh, gentity_t *pPilot );
  256. // Add a passenger to the vehicle (false if we're full).
  257. bool (*AddPassenger)( Vehicle_t *pVeh );
  258. // Animate the vehicle and it's riders.
  259. void (*Animate)( Vehicle_t *pVeh );
  260. // Board this Vehicle (get on). The first entity to board an empty vehicle becomes the Pilot.
  261. bool (*Board)( Vehicle_t *pVeh, gentity_t *pEnt );
  262. // Eject an entity from the vehicle.
  263. bool (*Eject)( Vehicle_t *pVeh, gentity_t *pEnt, qboolean forceEject );
  264. // Eject all the inhabitants of this vehicle.
  265. bool (*EjectAll)( Vehicle_t *pVeh );
  266. // Start a delay until the vehicle dies.
  267. void (*StartDeathDelay)( Vehicle_t *pVeh, int iDelayTime );
  268. // Update death sequence.
  269. void (*DeathUpdate)( Vehicle_t *pVeh );
  270. // Register all the assets used by this vehicle.
  271. void (*RegisterAssets)( Vehicle_t *pVeh );
  272. // Initialize the vehicle (should be called by Spawn?).
  273. bool (*Initialize)( Vehicle_t *pVeh );
  274. // Like a think or move command, this updates various vehicle properties.
  275. bool (*Update)( Vehicle_t *pVeh, const usercmd_t *pUcmd );
  276. // Update the properties of a Rider (that may reflect what happens to the vehicle).
  277. //
  278. // [return] bool True if still in vehicle, false if otherwise.
  279. bool (*UpdateRider)( Vehicle_t *pVeh, gentity_t *pRider, usercmd_t *pUcmd );
  280. // ProcessMoveCommands the Vehicle.
  281. void (*ProcessMoveCommands)( Vehicle_t *pVeh );
  282. // ProcessOrientCommands the Vehicle.
  283. void (*ProcessOrientCommands)( Vehicle_t *pVeh );
  284. // Attachs all the riders of this vehicle to their appropriate position/tag (*driver, *pass1, *pass2, whatever...).
  285. void (*AttachRiders)( Vehicle_t *pVeh );
  286. // Make someone invisible and un-collidable.
  287. void (*Ghost)( Vehicle_t *pVeh, gentity_t *pEnt );
  288. // Make someone visible and collidable.
  289. void (*UnGhost)( Vehicle_t *pVeh, gentity_t *pEnt );
  290. // Get the pilot of this vehicle.
  291. const gentity_t *(*GetPilot)( Vehicle_t *pVeh );
  292. // Whether this vehicle is currently inhabited (by anyone) or not.
  293. bool (*Inhabited)( Vehicle_t *pVeh );
  294. } vehicleInfo_t;
  295. #define VFOFS(x) ((int)&(((vehicleInfo_t *)0)->x))
  296. #define MAX_VEHICLES 16 //sigh... no more than 64 individual vehicles
  297. extern vehicleInfo_t g_vehicleInfo[MAX_VEHICLES];
  298. extern int numVehicles;
  299. // Load the function pointers for a vehicle into this shared vehicle info structure.
  300. extern void G_SetSpeederVehicleFunctions( vehicleInfo_t *pVehInfo );
  301. extern void G_SetAnimalVehicleFunctions( vehicleInfo_t *pVehInfo );
  302. extern void G_SetFighterVehicleFunctions( vehicleInfo_t *pVehInfo );
  303. extern void G_SetWalkerVehicleFunctions( vehicleInfo_t *pVehInfo );
  304. // Setup the shared functions (one's that all vehicles would generally use).
  305. extern void G_SetSharedVehicleFunctions( vehicleInfo_t *pVehInfo );
  306. // Create/Allocate a new Animal Vehicle (initializing it as well).
  307. extern void G_CreateSpeederNPC( Vehicle_t **pVeh, const char *strType );
  308. extern void G_CreateAnimalNPC( Vehicle_t **pVeh, const char *strType );
  309. extern void G_CreateFighterNPC( Vehicle_t **pVeh, const char *strType );
  310. extern void G_CreateWalkerNPC( Vehicle_t **pVeh, const char *strType );
  311. #define VEH_DEFAULT_SPEED_MAX 800.0f
  312. #define VEH_DEFAULT_ACCEL 10.0f
  313. #define VEH_DEFAULT_DECEL 10.0f
  314. #define VEH_DEFAULT_STRAFE_PERC 0.5f
  315. #define VEH_DEFAULT_BANKING_SPEED 0.5f
  316. #define VEH_DEFAULT_ROLL_LIMIT 60.0f
  317. #define VEH_DEFAULT_PITCH_LIMIT 90.0f
  318. #define VEH_DEFAULT_BRAKING 10.0f
  319. #define VEH_DEFAULT_TURNING_SPEED 1.0f
  320. #define VEH_DEFAULT_TRACTION 8.0f
  321. #define VEH_DEFAULT_FRICTION 1.0f
  322. #define VEH_DEFAULT_MAX_SLOPE 0.85f
  323. #define VEH_DEFAULT_MASS 200
  324. #define VEH_DEFAULT_MAX_ARMOR 200
  325. #define VEH_DEFAULT_TOUGHNESS 2.5f
  326. #define VEH_DEFAULT_GRAVITY 800
  327. #define VEH_DEFAULT_HOVER_HEIGHT 64.0f
  328. #define VEH_DEFAULT_HOVER_STRENGTH 10.0f
  329. #define VEH_DEFAULT_VISIBILITY 0
  330. #define VEH_DEFAULT_LOUDNESS 0
  331. #define VEH_DEFAULT_EXP_RAD 400.0f
  332. #define VEH_DEFAULT_EXP_DMG 1000
  333. #define VEH_MAX_PASSENGERS 10
  334. #define VEH_MOUNT_THROW_LEFT -5
  335. #define VEH_MOUNT_THROW_RIGHT -6
  336. #define MAX_STRAFE_TIME 2000.0f//FIXME: extern?
  337. #define MIN_LANDING_SPEED 200//equal to or less than this and close to ground = auto-slow-down to land
  338. #define MIN_LANDING_SLOPE 0.8f//must be pretty flat to land on the surf
  339. #define VEHICLE_BASE 0
  340. #define VEHICLE_NONE -1
  341. enum
  342. {
  343. VEH_EJECT_LEFT,
  344. VEH_EJECT_RIGHT,
  345. VEH_EJECT_FRONT,
  346. VEH_EJECT_REAR,
  347. VEH_EJECT_TOP,
  348. VEH_EJECT_BOTTOM
  349. };
  350. // Vehicle flags.
  351. enum
  352. {
  353. VEH_NONE = 0, VEH_FLYING = 0x00000001, VEH_CRASHING = 0x00000002,
  354. VEH_LANDING = 0x00000004, VEH_BUCKING = 0x00000010, VEH_WINGSOPEN = 0x00000020,
  355. VEH_GEARSOPEN = 0x00000040, VEH_SLIDEBREAKING = 0x00000080, VEH_SPINNING = 0x00000100,
  356. VEH_OUTOFCONTROL = 0x00000200,
  357. VEH_SABERINLEFTHAND = 0x00000400,
  358. VEH_STRAFERAM = 0x00000800,
  359. VEH_ACCELERATORON = 0x00001000,
  360. VEH_ARMORLOW = 0x00002000,
  361. VEH_ARMORGONE = 0x00004000
  362. };
  363. //externed functions
  364. //extern void G_DriveVehicle( gentity_t *ent, gentity_t *vehEnt, char *vehicleName );
  365. /*extern void G_VehicleStartExplosionDelay( gentity_t *self );
  366. extern void VehicleExplosionDelay( gentity_t *self );
  367. extern void G_VehicleRegisterAssets( int vehicleIndex );
  368. extern void G_DriveATST( gentity_t *ent, gentity_t *atst );
  369. extern void G_VehicleInitialize( gentity_t *vehEnt );*/
  370. extern void G_VehicleSpawn( gentity_t *self );
  371. // A vehicle weapon muzzle.
  372. struct Muzzle
  373. {
  374. // These are updated every frame and represent the current position and direction for the specific muzzle.
  375. vec3_t m_vMuzzlePos;
  376. vec3_t m_vMuzzleDir;
  377. // This is how long to wait before being able to fire a specific muzzle again. This is based on the firing rate
  378. // so that a firing rate of 10 rounds/sec would make this value initially 100 miliseconds.
  379. int m_iMuzzleWait;
  380. // whether this Muzzle was just fired or not (reset at muzzle flash code).
  381. bool m_bFired;
  382. };
  383. //defines for impact damage surface stuff
  384. #define SHIPSURF_FRONT 1
  385. #define SHIPSURF_BACK 2
  386. #define SHIPSURF_RIGHT 3
  387. #define SHIPSURF_LEFT 4
  388. #define SHIPSURF_DAMAGE_FRONT_LIGHT 1
  389. #define SHIPSURF_DAMAGE_BACK_LIGHT 2
  390. #define SHIPSURF_DAMAGE_RIGHT_LIGHT 3
  391. #define SHIPSURF_DAMAGE_LEFT_LIGHT 4
  392. #define SHIPSURF_DAMAGE_FRONT_HEAVY 5
  393. #define SHIPSURF_DAMAGE_BACK_HEAVY 6
  394. #define SHIPSURF_DAMAGE_RIGHT_HEAVY 7
  395. #define SHIPSURF_DAMAGE_LEFT_HEAVY 8
  396. //generic part bits
  397. #define SHIPSURF_BROKEN_A (1<<0) //gear 1
  398. #define SHIPSURF_BROKEN_B (1<<1) //gear 1
  399. #define SHIPSURF_BROKEN_C (1<<2) //wing 1
  400. #define SHIPSURF_BROKEN_D (1<<3) //wing 2
  401. #define SHIPSURF_BROKEN_E (1<<4) //wing 3
  402. #define SHIPSURF_BROKEN_F (1<<5) //wing 4
  403. typedef struct
  404. {
  405. //linked firing mode
  406. qboolean linked;//weapon 1's muzzles are in linked firing mode
  407. //current weapon ammo
  408. int ammo;
  409. //debouncer for ammo recharge
  410. int lastAmmoInc;
  411. //which muzzle will fire next
  412. int nextMuzzle;
  413. } vehWeaponStatus_t;
  414. typedef struct
  415. {
  416. //current weapon ammo
  417. int ammo;
  418. //debouncer for ammo recharge
  419. int lastAmmoInc;
  420. //which muzzle will fire next
  421. int nextMuzzle;
  422. //which entity they're after
  423. int enemyEntNum;
  424. //how long to hold on to our current enemy
  425. int enemyHoldTime;
  426. } vehTurretStatus_t;
  427. // This is the implementation of the vehicle interface and any of the other variables needed. This
  428. // is what actually represents a vehicle. -AReis.
  429. // !!!!!!!!!!!!!!!!!! loadsave affecting structure !!!!!!!!!!!!!!!!!!!!!!!
  430. struct Vehicle_t
  431. {
  432. // The entity who pilots/drives this vehicle.
  433. // NOTE: This is redundant (since m_pParentEntity->owner _should_ be the pilot). This makes things clearer though.
  434. gentity_t *m_pPilot;
  435. int m_iPilotTime; //if spawnflag to die without pilot and this < level.time then die.
  436. qboolean m_bHasHadPilot; //qtrue once the vehicle gets its first pilot
  437. //the droid unit NPC for this vehicle, if any
  438. gentity_t *m_pDroidUnit;
  439. // The entity from which this NPC comes from.
  440. gentity_t *m_pParentEntity;
  441. // If not zero, how long to wait before we can do anything with the vehicle (we're getting on still).
  442. // -1 = board from left, -2 = board from right, -3 = jump/quick board. -4 & -5 = throw off existing pilot
  443. int m_iBoarding;
  444. // Used to check if we've just started the boarding process
  445. bool m_bWasBoarding;
  446. // The speed the vehicle maintains while boarding occurs (often zero)
  447. vec3_t m_vBoardingVelocity;
  448. // Time modifier (must only be used in ProcessMoveCommands() and ProcessOrientCommands() and is updated in Update()).
  449. float m_fTimeModifier;
  450. // Ghoul2 Animation info.
  451. // NOTE: Since each vehicle has their own model instance, these bolts must be local to each vehicle as well.
  452. int m_iLeftWingBone;
  453. int m_iRightWingBone;
  454. //int m_iDriverTag;
  455. int m_iExhaustTag[MAX_VEHICLE_EXHAUSTS];
  456. int m_iMuzzleTag[MAX_VEHICLE_MUZZLES];
  457. int m_iDroidUnitTag;
  458. int m_iGunnerViewTag[MAX_VEHICLE_TURRETS];//Where to put the view origin of the gunner (index)
  459. // This vehicles weapon muzzles.
  460. Muzzle m_Muzzles[MAX_VEHICLE_MUZZLES];
  461. // The user commands structure.
  462. usercmd_t m_ucmd;
  463. // The direction an entity will eject from the vehicle towards.
  464. int m_EjectDir;
  465. // Flags that describe the vehicles behavior.
  466. unsigned long m_ulFlags;
  467. // NOTE: Vehicle Type ID, Orientation, and Armor MUST be transmitted over the net.
  468. // Current angles of this vehicle.
  469. vec3_t m_vOrientation;
  470. // How long you have strafed left or right (increments every frame that you strafe to right, decrements every frame you strafe left)
  471. int m_fStrafeTime;
  472. // Previous angles of this vehicle.
  473. vec3_t m_vPrevOrientation;
  474. // When control is lost on a speeder, current angular velocity is stored here and applied until landing
  475. float m_vAngularVelocity;
  476. vec3_t m_vFullAngleVelocity;
  477. // Current armor and shields of your vehicle (explodes if armor to 0).
  478. int m_iArmor; //hull strength - STAT_HEALTH on NPC
  479. int m_iShields; //energy shielding - STAT_ARMOR on NPC
  480. // Timer for all cgame-FX...? ex: exhaust?
  481. int m_iLastFXTime;
  482. // When to die.
  483. int m_iDieTime;
  484. // This pointer is to a valid VehicleInfo (which could be an animal, speeder, fighter, whatever). This
  485. // contains the functions actually used to do things to this specific kind of vehicle as well as shared
  486. // information (max speed, type, etc...).
  487. vehicleInfo_t *m_pVehicleInfo;
  488. // This trace tells us if we're within landing height.
  489. trace_t m_LandTrace;
  490. //bitflag of surfaces that have broken off
  491. int m_iRemovedSurfaces;
  492. // the last time this vehicle fired a turbo burst
  493. int m_iTurboTime;
  494. //how long it should drop like a rock for after freed from SUSPEND
  495. int m_iDropTime;
  496. int m_iSoundDebounceTimer;
  497. //last time we incremented the shields
  498. int lastShieldInc;
  499. //so we don't hold it down and toggle it back and forth
  500. qboolean linkWeaponToggleHeld;
  501. //info about our weapons (linked, ammo, etc.)
  502. vehWeaponStatus_t weaponStatus[MAX_VEHICLE_WEAPONS];
  503. vehTurretStatus_t turretStatus[MAX_VEHICLE_TURRETS];
  504. //the guy who was previously the pilot
  505. gentity_t* m_pOldPilot;
  506. // don't need these in mp
  507. int m_safeJumpMountTime;
  508. float m_safeJumpMountRightDot;
  509. bool alreadyCleaned;
  510. };
  511. extern int BG_VehicleGetIndex( const char *vehicleName );
  512. #endif // __G_VEHICLES_H