Counter Strike : Global Offensive Source Code
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.

304 lines
12 KiB

  1. //====== Copyright 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef CSTRIKE15_ITEM_CONSTANTS_H
  7. #define CSTRIKE15_ITEM_CONSTANTS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. //-----------------------------------------------------------------------------
  12. // Purpose: Slots for items within loadouts
  13. // NOTE: Explicitly numbered slots are for shipped features with the number saved in the database, do not renumber.
  14. // Some legacy entries in the enum are still here and some game code uses them, but are not yet shipped and would be
  15. // safe to renumber or remove if needed
  16. //-----------------------------------------------------------------------------
  17. enum loadout_positions_t
  18. {
  19. LOADOUT_POSITION_INVALID = -1,
  20. LOADOUT_POSITION_MELEE = 0,
  21. LOADOUT_POSITION_C4 = 1,
  22. LOADOUT_POSITION_FIRST_AUTO_BUY_WEAPON = LOADOUT_POSITION_MELEE,
  23. LOADOUT_POSITION_LAST_AUTO_BUY_WEAPON = LOADOUT_POSITION_C4,
  24. LOADOUT_POSITION_SECONDARY0 = 2,
  25. LOADOUT_POSITION_SECONDARY1 = 3,
  26. LOADOUT_POSITION_SECONDARY2 = 4,
  27. LOADOUT_POSITION_SECONDARY3 = 5,
  28. LOADOUT_POSITION_SECONDARY4 = 6,
  29. LOADOUT_POSITION_SECONDARY5 = 7, // Unused, no instances in database yet
  30. LOADOUT_POSITION_SMG0 = 8,
  31. LOADOUT_POSITION_SMG1 = 9,
  32. LOADOUT_POSITION_SMG2 = 10,
  33. LOADOUT_POSITION_SMG3 = 11,
  34. LOADOUT_POSITION_SMG4 = 12,
  35. LOADOUT_POSITION_SMG5 = 13, // Unused, no instances in database yet
  36. LOADOUT_POSITION_RIFLE0 = 14,
  37. LOADOUT_POSITION_RIFLE1 = 15,
  38. LOADOUT_POSITION_RIFLE2 = 16,
  39. LOADOUT_POSITION_RIFLE3 = 17,
  40. LOADOUT_POSITION_RIFLE4 = 18,
  41. LOADOUT_POSITION_RIFLE5 = 19,
  42. LOADOUT_POSITION_HEAVY0 = 20,
  43. LOADOUT_POSITION_HEAVY1 = 21,
  44. LOADOUT_POSITION_HEAVY2 = 22,
  45. LOADOUT_POSITION_HEAVY3 = 23,
  46. LOADOUT_POSITION_HEAVY4 = 24,
  47. LOADOUT_POSITION_HEAVY5 = 25, // Unused, no instances in database yet
  48. LOADOUT_POSITION_FIRST_WHEEL_WEAPON = LOADOUT_POSITION_SECONDARY0,
  49. LOADOUT_POSITION_LAST_WHEEL_WEAPON = LOADOUT_POSITION_HEAVY5,
  50. // Grenade slots not yet saved in db
  51. LOADOUT_POSITION_FIRST_WHEEL_GRENADE,
  52. LOADOUT_POSITION_GRENADE0 = LOADOUT_POSITION_FIRST_WHEEL_GRENADE,
  53. LOADOUT_POSITION_GRENADE1,
  54. LOADOUT_POSITION_GRENADE2,
  55. LOADOUT_POSITION_GRENADE3,
  56. LOADOUT_POSITION_GRENADE4,
  57. LOADOUT_POSITION_GRENADE5,
  58. LOADOUT_POSITION_LAST_WHEEL_GRENADE = LOADOUT_POSITION_GRENADE5,
  59. // Equipment slots not yet saved in db
  60. LOADOUT_POSITION_EQUIPMENT0,
  61. LOADOUT_POSITION_EQUIPMENT1,
  62. LOADOUT_POSITION_EQUIPMENT2,
  63. LOADOUT_POSITION_EQUIPMENT3,
  64. LOADOUT_POSITION_EQUIPMENT4,
  65. LOADOUT_POSITION_EQUIPMENT5,
  66. LOADOUT_POSITION_FIRST_WHEEL_EQUIPMENT = LOADOUT_POSITION_EQUIPMENT0,
  67. LOADOUT_POSITION_LAST_WHEEL_EQUIPMENT = LOADOUT_POSITION_EQUIPMENT5,
  68. // Only glove slot saved in db
  69. LOADOUT_POSITION_CLOTHING_APPEARANCE,
  70. LOADOUT_POSITION_CLOTHING_TORSO,
  71. LOADOUT_POSITION_CLOTHING_LOWERBODY,
  72. LOADOUT_POSITION_CLOTHING_HANDS = 41, // ALREADY SHIPPED, idx must == 41
  73. LOADOUT_POSITION_CLOTHING_HAT,
  74. LOADOUT_POSITION_CLOTHING_FACEMASK,
  75. LOADOUT_POSITION_CLOTHING_EYEWEAR,
  76. LOADOUT_POSITION_CLOTHING_CUSTOMHEAD,
  77. LOADOUT_POSITION_CLOTHING_CUSTOMPLAYER,
  78. LOADOUT_POSITION_MISC0,
  79. LOADOUT_POSITION_MISC1,
  80. LOADOUT_POSITION_MISC2,
  81. LOADOUT_POSITION_MISC3,
  82. LOADOUT_POSITION_MISC4,
  83. LOADOUT_POSITION_MISC5,
  84. LOADOUT_POSITION_MISC6,
  85. LOADOUT_POSITION_FIRST_COSMETIC = LOADOUT_POSITION_CLOTHING_APPEARANCE,
  86. LOADOUT_POSITION_LAST_COSMETIC = LOADOUT_POSITION_MISC6,
  87. // ^^^ Warning: CLOTHING COSEMTIC amount of enum entries doesn't match released enum, so must be shuffled before shipping to match public SQL!
  88. LOADOUT_POSITION_MUSICKIT = 54,
  89. LOADOUT_POSITION_FLAIR0 = 55,
  90. LOADOUT_POSITION_SPRAY0 = 56,
  91. LOADOUT_POSITION_FIRST_ALL_CHARACTER = LOADOUT_POSITION_MUSICKIT,
  92. LOADOUT_POSITION_LAST_ALL_CHARACTER = LOADOUT_POSITION_SPRAY0,
  93. LOADOUT_POSITION_COUNT,
  94. };
  95. #define LOADOUT_POSITION_NUM_AUTOBUY_WEAPONS ( ( LOADOUT_POSITION_LAST_AUTO_BUY_WEAPON - LOADOUT_POSITION_FIRST_AUTO_BUY_WEAPON) + 1 )
  96. #define LOADOUT_POSITION_NUM_COSMETICS ( ( LOADOUT_POSITION_LAST_COSMETIC - LOADOUT_POSITION_FIRST_COSMETIC ) + 1 )
  97. #define LOADOUT_POSITION_NUM_WHEEL_WEAPONS ( ( LOADOUT_POSITION_LAST_WHEEL_WEAPON - LOADOUT_POSITION_FIRST_WHEEL_WEAPON ) + 1 )
  98. #define LOADOUT_POSITION_NUM_WHEEL_GRENADE ( ( LOADOUT_POSITION_LAST_WHEEL_GRENADE - LOADOUT_POSITION_FIRST_WHEEL_GRENADE ) + 1 )
  99. #define LOADOUT_POSITION_NUM_WHEEL_EQUIPMENT ( ( LOADOUT_POSITION_LAST_WHEEL_EQUIPMENT - LOADOUT_POSITION_FIRST_WHEEL_EQUIPMENT ) + 1 )
  100. #define LOADOUT_POSITION_NUM_ALL_CHARACTER ( ( LOADOUT_POSITION_LAST_ALL_CHARACTER - LOADOUT_POSITION_FIRST_ALL_CHARACTER ) + 1 )
  101. #define LOADOUT_NUM_PANELS ( LOADOUT_POSITION_NUM_AUTOBUY_WEAPONS + LOADOUT_POSITION_NUM_COSMETICS + LOADOUT_POSITION_NUM_WHEEL_WEAPONS + LOADOUT_POSITION_NUM_ALL_CHARACTER )
  102. // We use this to determine the maximum number of wearable instances we'll send from the server down to connected clients.
  103. // This hardcoded because of the way RecvPropUtlVector works we can't easily change this
  104. // without doing some kludgy work and breaking network/demo compatibility.
  105. // Make sure this is up to date before shipping with enough overhead and don't change it without serious consideration.
  106. #define LOADOUT_MAX_WEARABLES_COUNT ( 1 /*LOADOUT_POSITION_NUM_COSMETICS*/ )
  107. inline bool IsWearableSlot( int iSlot )
  108. {
  109. return ( iSlot >= LOADOUT_POSITION_FIRST_COSMETIC && iSlot <= LOADOUT_POSITION_LAST_COSMETIC );
  110. }
  111. inline bool SlotContainsBaseItems( int iSlot )
  112. {
  113. // Primary wheel 2 has 6 base item slots... all the rest have 5 and one empty
  114. if ( iSlot < LOADOUT_POSITION_MELEE )
  115. {
  116. return false;
  117. }
  118. if ( iSlot >= LOADOUT_POSITION_FIRST_WHEEL_WEAPON && iSlot <= LOADOUT_POSITION_LAST_WHEEL_WEAPON )
  119. {
  120. switch( iSlot )
  121. {
  122. case LOADOUT_POSITION_SECONDARY5:
  123. case LOADOUT_POSITION_SMG5:
  124. case LOADOUT_POSITION_HEAVY5:
  125. return false;
  126. }
  127. return true;
  128. }
  129. if ( iSlot >= LOADOUT_POSITION_FIRST_WHEEL_GRENADE && iSlot <= LOADOUT_POSITION_LAST_WHEEL_GRENADE )
  130. {
  131. // switch( iSlot )
  132. // {
  133. // case LOADOUT_POSITION_GRENADE5:
  134. // return false;
  135. // }
  136. return true;
  137. }
  138. if ( iSlot >= LOADOUT_POSITION_FIRST_WHEEL_EQUIPMENT && iSlot <= LOADOUT_POSITION_LAST_WHEEL_EQUIPMENT )
  139. {
  140. switch( iSlot )
  141. {
  142. case LOADOUT_POSITION_EQUIPMENT0:
  143. case LOADOUT_POSITION_EQUIPMENT1:
  144. case LOADOUT_POSITION_EQUIPMENT3:
  145. case LOADOUT_POSITION_EQUIPMENT4:
  146. case LOADOUT_POSITION_EQUIPMENT5:
  147. return false;
  148. }
  149. return true;
  150. }
  151. if ( iSlot >= LOADOUT_POSITION_FIRST_COSMETIC && iSlot <= LOADOUT_POSITION_LAST_COSMETIC )
  152. {
  153. switch( iSlot )
  154. {
  155. case LOADOUT_POSITION_CLOTHING_APPEARANCE:
  156. case LOADOUT_POSITION_CLOTHING_TORSO:
  157. case LOADOUT_POSITION_CLOTHING_LOWERBODY:
  158. case LOADOUT_POSITION_CLOTHING_HANDS:
  159. case LOADOUT_POSITION_CLOTHING_HAT:
  160. case LOADOUT_POSITION_CLOTHING_FACEMASK:
  161. case LOADOUT_POSITION_CLOTHING_EYEWEAR:
  162. case LOADOUT_POSITION_CLOTHING_CUSTOMHEAD:
  163. case LOADOUT_POSITION_CLOTHING_CUSTOMPLAYER:
  164. return true;
  165. }
  166. return false;
  167. }
  168. if ( iSlot == LOADOUT_POSITION_MUSICKIT )
  169. return true;
  170. if ( iSlot >= LOADOUT_POSITION_FIRST_ALL_CHARACTER && iSlot <= LOADOUT_POSITION_LAST_ALL_CHARACTER )
  171. {
  172. return false;
  173. }
  174. return true;
  175. }
  176. // The total number of loadouts to track for each player.
  177. #define LOADOUT_COUNT (2+2) // these are the number of skins (2 valid + 2 invalid)
  178. //-----------------------------------------------------------------------------
  179. // The maximum number of presets per class - CS doesn't actually use all 10
  180. // right now, though.
  181. //-----------------------------------------------------------------------------
  182. #define MAX_LOADOUT_PRESET_COUNT 10
  183. enum xp_category_t
  184. {
  185. kXPCategory_None = 0,
  186. kXPCategory_ContributionScore = 1, // Server can send ContributionScore (mutually exclusive with CompetitiveRoundWins)
  187. kXPCategory_CompetitiveRoundWins = 2, // Server can send CompetitiveRoundWins (mutually exclusive with ContributionScore)
  188. kXPCategory_BonusBoost = 3, // GC rewards this weekly boost
  189. kXPCategory_Overwatch = 4, // GC rewards Overwatch XP in post SQL-transaction
  190. kXPCategory_OverwatchBonusBoost = 5, // GC rewards Overwatch Bonus XP in post SQL-transaction
  191. kXPCategory_QuestReward = 6, // Server sends evaluated quest points, and GC rewards Quest XP from coin progress
  192. kXPCategory_QuestBonus = 7, // Server sends evaluated quest bonus points, and GC rewards Quest XP from coin progress
  193. kXPCategory_QuestEvent = 8, // Server sends quest event XP, GC relays it to client
  194. // kXPCategory_Headshots, etc
  195. // GC can also use reduced XP reasons -
  196. kXPCategory_ContributionScoreReduced = 51, // ContributionScore remapped by GC for client display
  197. kXPCategory_CompetitiveRoundWinsReduced = 52, // CompetitiveRoundWins remapped by GC for client display
  198. kXPCategory_OverwatchReduced = 54, // Overwatch XP reason remapped by GC for client display
  199. kXPCategory_QuestEventReduced = 58, // QuestEvent XP reason remapped by GC for client display
  200. // GC can also use introductory XP reasons -
  201. kXPCategory_ContributionScoreIntroductory = 81, // ContributionScore remapped by GC for client display
  202. kXPCategory_CompetitiveRoundWinsIntroductory = 82, // CompetitiveRoundWins remapped by GC for client display
  203. kXPCategory_QuestEventIntroductory = 88, // QuestEvent XP reason remapped by GC for client display
  204. // NEW ENTRIES MUST BE ADDED AT THE BOTTOM
  205. };
  206. const uint32 k_nCSGOXpPerLevel = 5000;
  207. const uint32 k_nCSGOXpMaxLevel = 40;
  208. // Prime status
  209. const uint32 k_nCSGOMinLevelForPrimeStatus = 21;
  210. inline uint32 CSGOXpPointsToLevel( uint32 unExperiencePoints ) { return Min( k_nCSGOXpMaxLevel, 1 + ( unExperiencePoints / k_nCSGOXpPerLevel ) ); }
  211. inline uint32 CSGOXpPointsToXpPoints( uint32 unExperiencePoints ) { return unExperiencePoints % k_nCSGOXpPerLevel; }
  212. inline uint32 CSGOXpPointsToXpWirePoints( uint32 unExperiencePoints )
  213. {
  214. COMPILE_TIME_ASSERT( k_nCSGOXpPerLevel < 0xFFFF );
  215. Assert( unExperiencePoints <= 0xFFFF );
  216. return ( ( unExperiencePoints ) & 0xFFFF ) | ( ( k_nCSGOXpPerLevel & 0xFFFF ) << 16 );
  217. }
  218. inline uint32 CSGOXpPointsFromXpWirePoints( uint32 unXpWirePoints )
  219. {
  220. COMPILE_TIME_ASSERT( k_nCSGOXpPerLevel < 0xFFFF );
  221. uint32 const unWireBase = ( unXpWirePoints >> 16 ) & 0xFFFF;
  222. if ( !unWireBase || ( unWireBase == k_nCSGOXpPerLevel ) )
  223. return unXpWirePoints & 0xFFFF;
  224. else
  225. return uint32( ( double( unXpWirePoints & 0xFFFF ) / double( unWireBase ) ) * double( k_nCSGOXpPerLevel ) );
  226. }
  227. // STORED IN DATABASE! Do not renumber
  228. enum
  229. {
  230. kCSXpBonusFlags_EarnedXpThisPeriod = 1 << 0,
  231. kCSXpBonusFlags_FirstReward = 1 << 1,
  232. kCSXpBonusFlags_Msg_YourReportGotConvicted = 1 << 2,
  233. kCSXpBonusFlags_Msg_YouPartiedWithCheaters = 1 << 3,
  234. kCSXpBonusFlags_PrestigeEarned = 1 << 4,
  235. // ===$CHINAGOVERNMENTCERT$===
  236. kCSXpBonusFlags_ChinaGovernmentCert = 1 << 5,
  237. // ===$CHINAGOVERNMENTCERT$===
  238. // Client-facing bits not backed by SQL
  239. kCSXpBonusFlags_OverwatchBonus = 1 << 28,
  240. kCSXpBonusFlags_BonusBoostConsumed = 1 << 29,
  241. kCSXpBonusFlags_ReducedGain = 1 << 30,
  242. kCSXpBonusFlagsMask_SQLBacked_TimeBased = ( kCSXpBonusFlags_EarnedXpThisPeriod | kCSXpBonusFlags_FirstReward ),
  243. kCSXpBonusFlagsMask_SQLBacked_Notifications = ( kCSXpBonusFlags_Msg_YourReportGotConvicted | kCSXpBonusFlags_Msg_YouPartiedWithCheaters ),
  244. kCSXpBonusFlagsMask_SQLBacked_Permanent = ( kCSXpBonusFlagsMask_SQLBacked_Notifications | kCSXpBonusFlags_PrestigeEarned
  245. | kCSXpBonusFlags_ChinaGovernmentCert // ===$CHINAGOVERNMENTCERT$===
  246. ),
  247. kCSXpBonusFlagsMask_SQLBacked = ( kCSXpBonusFlagsMask_SQLBacked_TimeBased | kCSXpBonusFlagsMask_SQLBacked_Permanent ),
  248. kCSXpBonusFlagsMask_Client_Permanent = ( kCSXpBonusFlags_OverwatchBonus ),
  249. kCSXpBonusFlagsMask_Client_TimeBased = ( kCSXpBonusFlags_BonusBoostConsumed | kCSXpBonusFlags_ReducedGain ),
  250. };
  251. // Used in scoreboard to show other players the reason for the drop. Standard weekly drops are of type 'None'.
  252. enum
  253. {
  254. kCSGODropReason_None = 0,
  255. kCSGODropReason_Quest = 1,
  256. kCSGODropReason_LevelUp = 2,
  257. };
  258. #endif // CSTRIKE15_ITEM_CONSTANTS_H