Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Holds defintion for game ammo types
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef AI_AMMODEF_H
  10. #define AI_AMMODEF_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. class ConVar;
  15. struct Ammo_t
  16. {
  17. char *pName;
  18. int nDamageType;
  19. int eTracerType;
  20. float physicsForceImpulse;
  21. int nMinSplashSize;
  22. int nMaxSplashSize;
  23. int nFlags;
  24. // Values for player/NPC damage and carrying capability
  25. // If the integers are set, they override the CVars
  26. int pPlrDmg; // CVar for player damage amount
  27. int pNPCDmg; // CVar for NPC damage amount
  28. int pMaxCarry; // CVar for maximum number can carry
  29. const ConVar* pPlrDmgCVar; // CVar for player damage amount
  30. const ConVar* pNPCDmgCVar; // CVar for NPC damage amount
  31. const ConVar* pMaxCarryCVar; // CVar for maximum number can carry
  32. };
  33. // Used to tell AmmoDef to use the cvars, not the integers
  34. #define USE_CVAR -1
  35. // Ammo is infinite
  36. #define INFINITE_AMMO -2
  37. enum AmmoTracer_t
  38. {
  39. TRACER_NONE,
  40. TRACER_LINE,
  41. TRACER_RAIL,
  42. TRACER_BEAM,
  43. TRACER_LINE_AND_WHIZ,
  44. };
  45. enum AmmoFlags_t
  46. {
  47. AMMO_FORCE_DROP_IF_CARRIED = 0x1,
  48. AMMO_INTERPRET_PLRDAMAGE_AS_DAMAGE_TO_PLAYER = 0x2,
  49. };
  50. #include "shareddefs.h"
  51. //=============================================================================
  52. // >> CAmmoDef
  53. //=============================================================================
  54. class CAmmoDef
  55. {
  56. public:
  57. int m_nAmmoIndex;
  58. Ammo_t m_AmmoType[MAX_AMMO_TYPES];
  59. Ammo_t *GetAmmoOfIndex(int nAmmoIndex);
  60. int Index(const char *psz);
  61. int PlrDamage(int nAmmoIndex);
  62. int NPCDamage(int nAmmoIndex);
  63. int MaxCarry(int nAmmoIndex);
  64. int DamageType(int nAmmoIndex);
  65. int TracerType(int nAmmoIndex);
  66. float DamageForce(int nAmmoIndex);
  67. int MinSplashSize(int nAmmoIndex);
  68. int MaxSplashSize(int nAmmoIndex);
  69. int Flags(int nAmmoIndex);
  70. void AddAmmoType(char const* name, int damageType, int tracerType, int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
  71. void AddAmmoType(char const* name, int damageType, int tracerType, char const* plr_cvar, char const* npc_var, char const* carry_cvar, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
  72. CAmmoDef(void);
  73. virtual ~CAmmoDef( void );
  74. private:
  75. bool AddAmmoType(char const* name, int damageType, int tracerType, int nFlags, int minSplashSize, int maxSplashSize );
  76. };
  77. // Get the global ammodef object. This is usually implemented in each mod's game rules file somewhere,
  78. // so the mod can setup custom ammo types.
  79. CAmmoDef* GetAmmoDef();
  80. #endif // AI_AMMODEF_H