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.

116 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #include "cbase.h"
  7. #include "weapon_sdkbase.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. // the 1 / 2 / 3 respectively are all identical in our template mod to start, I've made the base ones (pc_class1, pc_class2, pc_class3) and then duplicated them for the teams.
  11. //Tony; for our template we have two versions.
  12. #if defined ( SDK_USE_PLAYERCLASSES ) && defined ( SDK_USE_TEAMS )
  13. const char *pszTeamBlueClasses[] =
  14. {
  15. "blue_class1",
  16. "blue_class2",
  17. "blue_class3",
  18. NULL
  19. };
  20. const char *pszTeamRedClasses[] =
  21. {
  22. "red_class1",
  23. "red_class2",
  24. "red_class3",
  25. NULL
  26. };
  27. ConVar mp_limit_blue_class1( "mp_limit_blue_class1", "-1", FCVAR_REPLICATED, "Class limit for Blue class 1" );
  28. ConVar mp_limit_blue_class2( "mp_limit_blue_class2", "-1", FCVAR_REPLICATED, "Class limit for Blue class 2" );
  29. ConVar mp_limit_blue_class3( "mp_limit_blue_class3", "-1", FCVAR_REPLICATED, "Class limit for Blue class 3" );
  30. ConVar mp_limit_red_class1( "mp_limit_red_class1", "-1", FCVAR_REPLICATED, "Class limit for Red class 1" );
  31. ConVar mp_limit_red_class2( "mp_limit_red_class2", "-1", FCVAR_REPLICATED, "Class limit for Red class 2" );
  32. ConVar mp_limit_red_class3( "mp_limit_red_class3", "-1", FCVAR_REPLICATED, "Class limit for Red class 3" );
  33. //Tony; not using teams, but we are using classes
  34. #elif defined ( SDK_USE_PLAYERCLASSES ) && !defined( SDK_USE_TEAMS )
  35. const char *pszPlayerClasses[] =
  36. {
  37. "pc_class1",
  38. "pc_class2",
  39. "pc_class3",
  40. NULL
  41. };
  42. ConVar mp_limit_pc_class1( "mp_limit_pc_class1", "-1", FCVAR_REPLICATED, "Class limit for class 1" );
  43. ConVar mp_limit_pc_class2( "mp_limit_pc_class2", "-1", FCVAR_REPLICATED, "Class limit for class 2" );
  44. ConVar mp_limit_pc_class3( "mp_limit_pc_class3", "-1", FCVAR_REPLICATED, "Class limit for class 3" );
  45. #endif
  46. const char *pszTeamNames[] =
  47. {
  48. "#SDK_Team_Unassigned",
  49. "#SDK_Team_Spectator",
  50. #if defined ( SDK_USE_TEAMS )
  51. "#SDK_Team_Blue",
  52. "#SDK_Team_Red",
  53. #endif
  54. };
  55. //Tony; We need to precache all possible player models that we're going to use
  56. const char *pszPossiblePlayerModels[] =
  57. {
  58. SDK_PLAYER_MODEL,
  59. "models/player/american_rifleman.mdl",
  60. "models/player/german_rifleman.mdl",
  61. NULL
  62. };
  63. // ----------------------------------------------------------------------------- //
  64. // Global Weapon Definitions
  65. // ----------------------------------------------------------------------------- //
  66. //--------------------------------------------------------------------------------------------------------
  67. static const char * s_WeaponAliasInfo[] =
  68. {
  69. "none", // WEAPON_NONE
  70. "mp5", // SDK_WEAPON_MP5
  71. "shotgun", // SDK_WEAPON_SHOTGUN
  72. "grenade", // SDK_WEAPON_GRENADE
  73. "pistol", // SDK_WEAPON_PISTOL
  74. "crowbar", // SDK_WEAPON_CROWBAR
  75. NULL, // WEAPON_NONE
  76. };
  77. //--------------------------------------------------------------------------------------------------------
  78. //
  79. // Given an alias, return the associated weapon ID
  80. //
  81. int AliasToWeaponID( const char *alias )
  82. {
  83. if (alias)
  84. {
  85. for( int i=0; s_WeaponAliasInfo[i] != NULL; ++i )
  86. if (!Q_stricmp( s_WeaponAliasInfo[i], alias ))
  87. return i;
  88. }
  89. return WEAPON_NONE;
  90. }
  91. //--------------------------------------------------------------------------------------------------------
  92. //
  93. // Given a weapon ID, return its alias
  94. //
  95. const char *WeaponIDToAlias( int id )
  96. {
  97. if ( (id >= WEAPON_MAX) || (id < 0) )
  98. return NULL;
  99. return s_WeaponAliasInfo[id];
  100. }