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.

4170 lines
155 KiB

  1. //====== Copyright �, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: EconItemSchema: Defines a schema for econ items
  4. //
  5. //=============================================================================
  6. #ifndef ECONITEMSCHEMA_H
  7. #define ECONITEMSCHEMA_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. // Valve code doesn't play nicely with standard headers on some platforms sometimes.
  12. #ifdef min
  13. #undef min
  14. #endif
  15. #ifdef max
  16. #undef max
  17. #endif
  18. #include <string>
  19. #include "steam/steamtypes.h" // needed for RTime32
  20. #include "keyvalues.h"
  21. #include "tier1/utldict.h"
  22. #include "econ_item_constants.h"
  23. #include "tier1/utlhashmaplarge.h"
  24. #include "UtlStringMap.h"
  25. #include "item_selection_criteria.h"
  26. #include "bitvec.h"
  27. #include "language.h"
  28. #include "smartptr.h"
  29. #include "vstdlib/random.h"
  30. #include "materialsystem/imaterialsystem.h"
  31. #include "mathlib/expressioncalculator.h"
  32. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  33. #include "weapon_parse.h"
  34. #include "engine/ivmodelinfo.h"
  35. #include "engine/ivmodelrender.h"
  36. #endif
  37. class CEconItem;
  38. #include "game/shared/econ/iecon_item_system.h"
  39. #ifdef SOURCE1
  40. #include "gamestringpool.h"
  41. #endif
  42. class CEconItemSchema;
  43. class CEconSharedObjectCache;
  44. class CSOItemRecipe;
  45. class CStickerList;
  46. class CTimedItemRewardDefinition;
  47. void Helper_TemporaryBuildCopyOfLootlistForQuestDrop( CTimedItemRewardDefinition &build, const CTimedItemRewardDefinition *pDescReward, char const *szGameModeExclude );
  48. #define MAX_PAINT_DATA_NAME 128
  49. #define MAX_STICKER_DATA_PATH 128
  50. #define DEFAULT_EMBROIDER_NCOLORS 10
  51. #define DEFAULT_EMBROIDER_GAMMA 0.8
  52. enum CraftFilter_t
  53. {
  54. CRAFT_FILTER_TRADEUP = -3,
  55. CRAFT_FILTER_COLLECT = -2,
  56. };
  57. enum EQuestVar_t
  58. {
  59. /** Removed for partner depot **/
  60. k_EQuestVar_First,
  61. k_EQuestVar_Last
  62. };
  63. //-----------------------------------------------------------------------------
  64. // CEconItemRarityDefinition
  65. //-----------------------------------------------------------------------------
  66. class CEconItemRarityDefinition
  67. {
  68. public:
  69. CEconItemRarityDefinition( void );
  70. CEconItemRarityDefinition( const CEconItemRarityDefinition &that );
  71. CEconItemRarityDefinition &operator=( const CEconItemRarityDefinition& rhs );
  72. ~CEconItemRarityDefinition( void ) { }
  73. bool BInitFromKV( KeyValues *pKVItem, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  74. int32 GetDBValue( void ) const { return m_nValue; }
  75. const char *GetName( void ) const { return !m_strName.IsEmpty() ? m_strName.String() : "unknown"; }
  76. const char *GetLocKey( void ) const { return m_strLocKey.String(); }
  77. const char *GetWepLocKey( void ) const { return m_strWepLocKey.String(); }
  78. const char *GetLootList( void ) const { return m_strLootList.String(); }
  79. const char *GetRecycleLootList( void ) const { return m_strRecycleLootList.String(); }
  80. const char *GetDropSound( void ) const { return m_strDropSound.String(); }
  81. attrib_colors_t GetAttribColor( void ) const { return m_iAttribColor; }
  82. const char *GetNextRarity( void ) const { return m_strNextRarity.String(); }
  83. int GetWhiteCount( void ) const { return m_iWhiteCount; }
  84. int GetBlackCount( void ) const { return m_iBlackCount; }
  85. float GetWeight( void ) const { return m_flWeight; }
  86. private:
  87. // The value that the game/DB will know this rarity by
  88. int32 m_nValue;
  89. attrib_colors_t m_iAttribColor;
  90. // The English name of the rarity
  91. CUtlString m_strName;
  92. // The localization key for this rarity.
  93. CUtlString m_strLocKey;
  94. // The localization key for this rarity, for weapons.
  95. CUtlString m_strWepLocKey;
  96. // The loot list name associated with this rarity.
  97. CUtlString m_strLootList;
  98. CUtlString m_strRecycleLootList;
  99. CUtlString m_strDropSound;
  100. CUtlString m_strNextRarity;
  101. int m_iWhiteCount;
  102. int m_iBlackCount;
  103. float m_flWeight;
  104. };
  105. typedef int econ_tag_handle_t;
  106. typedef uint16 equipped_class_t;
  107. typedef uint16 equipped_slot_t;
  108. typedef uint8 equipped_preset_t;
  109. #define INVALID_ECON_TAG_HANDLE ((econ_tag_handle_t)-1)
  110. #define INVALID_EQUIPPED_SLOT ((equipped_slot_t)-1)
  111. #define INVALID_EQUIPPED_SLOT_BITPACKED 0x3F
  112. #define INVALID_STYLE_INDEX ((style_index_t)-1)
  113. #define INVALID_PRESET_INDEX ((equipped_preset_t)-1)
  114. union attribute_data_union_t
  115. {
  116. float asFloat;
  117. uint32 asUint32;
  118. byte *asBlobPointer;
  119. };
  120. struct static_attrib_t
  121. {
  122. static_attrib_t()
  123. {
  124. iDefIndex = 0;
  125. m_value.asBlobPointer = NULL;
  126. m_bForceGCToGenerate = false;
  127. }
  128. attrib_definition_index_t iDefIndex;
  129. attribute_data_union_t m_value;
  130. bool m_bForceGCToGenerate;
  131. // Parses a single subsection from a multi-line attribute block that looks like:
  132. //
  133. // "attributes"
  134. // {
  135. // "cannot trade"
  136. // {
  137. // "attribute_class" "cannot_trade"
  138. // "value" "1"
  139. // }
  140. // "kill eater"
  141. // {
  142. // "attribute_class" "kill_eater"
  143. // "force_gc_to_generate" "1"
  144. // "use_custom_logic" "gifts_given_out"
  145. // }
  146. // }
  147. //
  148. // The "force_gc_to_generate" and "use_custom_logic" fields will only be parsed on the GC. Will return
  149. // true/false based on whether the whole attribute and value parsed successfully.
  150. bool BInitFromKV_MultiLine( const char *pszContext, KeyValues *pKVAttribute, CUtlVector<CUtlString> *pVecErrors );
  151. // Parses a single subsection from a single-line attribute block that looks like:
  152. //
  153. // CharacterAttributes
  154. // {
  155. // "increase buff duration" 9.0
  156. // "damage bonus" 2.0
  157. // }
  158. //
  159. // It's impossible to specify GC-generated attributes in this format. Will return true/false based on
  160. // whether the whole attribute and value parsed successfully.
  161. bool BInitFromKV_SingleLine( const char *pszContext, KeyValues *pKVAttribute, CUtlVector<CUtlString> *pVecErrors );
  162. // Data access helper.
  163. const class CEconItemAttributeDefinition *GetAttributeDefinition() const;
  164. };
  165. enum EWebResourceStatus
  166. {
  167. kWebResource_InvalidName,
  168. kWebResource_NotLoaded,
  169. kWebResource_Loading,
  170. kWebResource_Loaded,
  171. };
  172. struct WeaponPaintableMaterial_t
  173. {
  174. char m_szName[ MAX_PAINT_DATA_NAME ];
  175. char m_szOriginalMaterialName[ MAX_PAINT_DATA_NAME ];
  176. char m_szFolderName[ MAX_PAINT_DATA_NAME ];
  177. int m_nViewModelSize; // texture size
  178. int m_nWorldModelSize; // texture size
  179. float m_flWeaponLength;
  180. float m_flUVScale;
  181. bool m_bBaseTextureOverride;
  182. bool m_bMirrorPattern;
  183. };
  184. struct InventoryImageData_t
  185. {
  186. QAngle *m_pCameraAngles;
  187. Vector *m_pCameraOffset;
  188. float m_cameraFOV;
  189. LightDesc_t *m_pLightDesc[ MATERIAL_MAX_LIGHT_COUNT ];
  190. bool m_bOverrideDefaultLight;
  191. };
  192. struct StickerData_t
  193. {
  194. char m_szStickerModelPath[ MAX_STICKER_DATA_PATH ];
  195. char m_szStickerMaterialPath[ MAX_STICKER_DATA_PATH ];
  196. Vector m_vWorldModelProjectionStart;
  197. Vector m_vWorldModelProjectionEnd;
  198. char m_szStickerBoneParentName[ 32 ];
  199. };
  200. //-----------------------------------------------------------------------------
  201. // CEconItemQualityDefinition
  202. //-----------------------------------------------------------------------------
  203. class CEconItemQualityDefinition
  204. {
  205. public:
  206. CEconItemQualityDefinition( void );
  207. CEconItemQualityDefinition( const CEconItemQualityDefinition &that );
  208. CEconItemQualityDefinition &operator=( const CEconItemQualityDefinition& rhs );
  209. ~CEconItemQualityDefinition( void ) { }
  210. bool BInitFromKV( KeyValues *pKVItem, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  211. int32 GetDBValue( void ) const { return m_nValue; }
  212. const char *GetName( void ) const { return !m_strName.IsEmpty() ? m_strName.Get() : "unknown"; }
  213. uint32 GetWeight( void ) const { return m_unWeight; }
  214. bool GetRequiresExplicitMatches( void ) const { return m_bExplicitMatchesOnly; }
  215. bool CanSupportSet( void ) const { return m_bCanSupportSet; }
  216. const char *GetHexColor( void ) const { return !m_strHexColor.IsEmpty() ? m_strHexColor.Get() : "B2B2B2"; }
  217. private:
  218. // The value that the game/DB will know this quality by
  219. int32 m_nValue;
  220. // The English name of the quality
  221. CUtlConstString m_strName;
  222. // The weight used for choosing the quality. The higher the weight, the more likely it will be chosen.
  223. uint32 m_unWeight;
  224. // Whether or not items chosen to be of this quality only match item definitions that are explicitly defined as being of this quality
  225. bool m_bExplicitMatchesOnly;
  226. // if this is true the support tool is allowed to set this quality level on any item
  227. bool m_bCanSupportSet;
  228. // A hex string representing the color this quality should display as. Used primarily for display on the Web.
  229. CUtlConstString m_strHexColor;
  230. };
  231. //-----------------------------------------------------------------------------
  232. // CEconColorDefinition
  233. //-----------------------------------------------------------------------------
  234. class CEconColorDefinition
  235. {
  236. public:
  237. bool BInitFromKV( KeyValues *pKVColor, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  238. const char *GetName( void ) const { return m_strName.Get(); }
  239. const char *GetColorName( void ) const { return m_strColorName.Get(); } // meant for passing into VGUI styles, etc.
  240. const char *GetHexColor( void ) const { return m_strHexColor.Get(); }
  241. private:
  242. // The English name of this color. Only used for lookup.
  243. CUtlConstString m_strName;
  244. // The VGUI name of the color in our schema. This will be used to set values
  245. // for VGUI controls.
  246. CUtlConstString m_strColorName;
  247. // The hex string value of this color. This will be used for Web display.
  248. CUtlConstString m_strHexColor;
  249. };
  250. //-----------------------------------------------------------------------------
  251. // CEconColorDefinition
  252. //-----------------------------------------------------------------------------
  253. class CEconGraffitiTintDefinition
  254. {
  255. public:
  256. bool BInitFromKV( KeyValues *pKVColor, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  257. int GetID( void ) const { return m_nID; }
  258. const char *GetColorName( void ) const { return m_strColorName.Get(); } // meant for passing into VGUI styles, etc.
  259. const char *GetHexColor( void ) const { return m_strHexColor.Get(); }
  260. uint32 GetHexColorRGB( void ) const { return m_unHexColorRGB; }
  261. private:
  262. // The ID of the color
  263. int m_nID;
  264. // The name of the color in our schema (e.g. "shark_white")
  265. CUtlConstString m_strColorName;
  266. // The hex string value of this color. This will be used for Web display. (e.g. "#ff00ff")
  267. CUtlConstString m_strHexColor;
  268. uint32 m_unHexColorRGB;
  269. };
  270. //-----------------------------------------------------------------------------
  271. // CEconMusicDefinition
  272. //-----------------------------------------------------------------------------
  273. class CEconMusicDefinition
  274. {
  275. public:
  276. bool BInitFromKV( KeyValues *pKVMusicDef, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  277. uint32 GetID( void ) const { return nID; }
  278. const char *GetName( void ) const { return m_strName.Get(); }
  279. const char *GetNameLocToken( void ) const { return m_strNameLocToken.Get(); }
  280. const char *GetDescription( void ) const { return m_strLocDescription.Get(); }
  281. const char *GetInventoryImage( void ) const { return m_strInventoryImage.Get(); }
  282. const char *GetPedestalDisplayModel( void ) const { return m_strPedestalDisplayModel.Get(); }
  283. // Icon URLs for CDN
  284. const char *GetIconURLSmall() const { return m_sIconURLSmall; }
  285. const char *GetIconURLLarge() const { return m_sIconURLLarge; }
  286. void SetIconURLSmall( const char *szURL ) { m_sIconURLSmall = szURL; }
  287. void SetIconURLLarge( const char *szURL ) { m_sIconURLLarge = szURL; }
  288. private:
  289. int nID;
  290. CUtlConstString m_strName;
  291. CUtlConstString m_strNameLocToken;
  292. CUtlConstString m_strLocDescription;
  293. CUtlConstString m_strPedestalDisplayModel;
  294. CUtlConstString m_strInventoryImage;
  295. CUtlConstString m_sIconURLSmall;
  296. CUtlConstString m_sIconURLLarge;
  297. };
  298. class CEconQuestDefinition;
  299. struct quest_event_t
  300. {
  301. quest_event_t( int nStartDay, const char * pchHHMM, int nDurationInMinutes, const char * strTimeZone, CEconQuestDefinition * pQuestDef, RTime32 start, RTime32 end ) : m_strHHMM( pchHHMM ),
  302. m_rtEventStart( start ),
  303. m_rtEventEnd( end ),
  304. m_nStartDay( nStartDay ),
  305. m_nDurationInMinutes( nDurationInMinutes ),
  306. m_pQuestDef( pQuestDef ),
  307. m_strTimeZone( strTimeZone ){}
  308. RTime32 m_rtEventStart;
  309. RTime32 m_rtEventEnd;
  310. int m_nDurationInMinutes;
  311. int m_nStartDay;
  312. CEconQuestDefinition * m_pQuestDef;
  313. CUtlConstString m_strHHMM;
  314. CUtlConstString m_strTimeZone;
  315. };
  316. typedef CUtlVector<quest_event_t*> QuestEvents_t;
  317. typedef CUtlMap< RTime32, quest_event_t*, int, CDefLess< RTime32 > > QuestEventsSchedule_t; // a map of quest events that gets resorted by start time every time it's queried
  318. //-----------------------------------------------------------------------------
  319. // CEconQuestDefinition
  320. //-----------------------------------------------------------------------------
  321. class CEconQuestDefinition
  322. {
  323. public:
  324. bool BInitFromKV( KeyValues *pKVQuestDef, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  325. uint32 GetID( void ) const { return nID; }
  326. const char * GetName( void ) const { return m_strName.Get(); }
  327. const char * GetGameMode( void ) const { return m_strGameMode.Get(); }
  328. const char * GetMapGroup( void ) const { return m_strMapGroup.Get(); }
  329. const char * GetMap( void ) const { return m_strMap.Get(); }
  330. const char * GetRewardLootList( void ) const { return m_strRewardLootList.Get(); }
  331. const char * GetQuestExpression( void ) const { return m_strExpr; }
  332. const char * GetQuestBonusExpression( void ) const { return m_strBonusExpr; }
  333. const uint32 GetDifficulty( void ) const { return m_nDifficulty; }
  334. const uint32 GetOperationalPoints( void ) const { return m_nOperationalPoints; }
  335. const uint32 GetXPReward( void ) const { return m_nXPReward; }
  336. const uint32 GetTargetTeam( void ) const { return m_nTargetTeam; }
  337. const uint32 GetXPBonusPercent( void ) const { return m_nXPBonusPercent; }
  338. const CCopyableUtlVector< uint32 >& GetQuestPoints( void ) const { return m_vecQuestPoints; }
  339. const char* GetQuestConVars( void ) const { return m_strQuestConVars.Get(); }
  340. const bool IsAnEvent( void ) const { return m_bIsAnEvent; }
  341. static void TokenizeQuestExpression( const char * szExpression, KeyValues * pKVExpressionTokens );
  342. static bool IsQuestExpressionValid( const char * pszQuestExpr );
  343. static void ZeroOutQuestExpressionVariables( CExpressionCalculator &expQuest );
  344. static void SetQuestExpressionVariable( CExpressionCalculator &expQuest, EQuestVar_t questVar, float flValue );
  345. private:
  346. int nID;
  347. CUtlConstString m_strName;
  348. CUtlConstString m_strMapGroup;
  349. CUtlConstString m_strMap;
  350. CUtlConstString m_strGameMode;
  351. CUtlConstString m_strRewardLootList;
  352. CUtlConstString m_strExpr;
  353. CUtlConstString m_strBonusExpr;
  354. CCopyableUtlVector< uint32 > m_vecQuestPoints; // how many times does the player need to do the action.
  355. // schema specifies a list of possible point requirements and
  356. // one of the options is selected when the quest is created.
  357. bool m_bIsAnEvent; //Event quests are treated slightly differently.
  358. uint32 m_nDifficulty; // quest difficulty for display purposes
  359. uint32 m_nOperationalPoints; // points towards coin leveling
  360. uint32 m_nXPReward; // xp reward for completing the quest
  361. uint32 m_nXPBonusPercent; // bonus xp percentage for completing additionally satisfying the Bonus expression
  362. uint32 m_nTargetTeam; // specific team this quest applies to (0 if not applicable)
  363. CUtlConstString m_strQuestConVars; // Cfg file to exec on the server when starting this quest
  364. //
  365. // client strings. Server and GC don't use these
  366. //
  367. #ifdef CLIENT_DLL
  368. public:
  369. const char * GetNameLocToken( void ) const { return m_strNameLocToken.Get(); }
  370. const char * GetShortNameLocToken( void ) const { return m_strShortNameLocToken.Get(); }
  371. const char * GetDescriptionLocToken( void ) const { return m_strDescriptionLocToken.Get(); }
  372. const char * GetHudDesscriptionLocToken( void ) const { return m_strHudDescriptionLocToken.Get(); }
  373. const char * GetBonusLocToken( void ) const { return m_strLocBonus.Get(); }
  374. KeyValues* GetStringTokens( void ) const { return m_kvStringTokens; }
  375. const char* GetIcon( void ) const { return m_strIcon; }
  376. static void PopulateQuestStringTokens( CEconQuestDefinition &questDef, KeyValues &kvExpressionTokens, KeyValues &kvStringTokens, bool bBonus = false );
  377. private:
  378. CUtlConstString m_strNameLocToken;
  379. CUtlConstString m_strShortNameLocToken;
  380. CUtlConstString m_strDescriptionLocToken;
  381. CUtlConstString m_strHudDescriptionLocToken;
  382. KeyValues * m_kvStringTokens;
  383. CUtlConstString m_strLocBonus;
  384. CUtlConstString m_strIcon;
  385. #endif
  386. };
  387. //-----------------------------------------------------------------------------
  388. // CEconCampaignDefinition
  389. //-----------------------------------------------------------------------------
  390. class CEconCampaignDefinition
  391. {
  392. public:
  393. class CEconCampaignNodeDefinition
  394. {
  395. public:
  396. #ifdef CLIENT_DLL
  397. class CEconCampaignNodeStoryBlockDefinition
  398. {
  399. public:
  400. bool BInitFromKV( int nCampaignIndex, int nNodeID, KeyValues * pKVCampaignNodeStoryBlockDef, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  401. const char * GetContentFile( void ) const { return m_strContentFile.Get(); }
  402. const char * GetCharacterName( void ) const { return m_strCharacterName.Get(); }
  403. const char * GetStoryBlockExpression( void ) const { return m_strExpr.Get(); }
  404. const char * GetDescription( void ) const { return m_strDescription.Get(); }
  405. float EvaluateStoryBlockExpression( CEconItemView *pCampaignCoin ) const;
  406. private:
  407. CUtlConstString m_strContentFile; // mission briefing or other content associated with this node
  408. CUtlConstString m_strCharacterName; // Character associated with campaign node
  409. CUtlConstString m_strExpr; // the first story block with a true expression will get selected
  410. CUtlConstString m_strDescription; // mission description or audio captioning.
  411. };
  412. const CUtlVector< CEconCampaignNodeStoryBlockDefinition* >& GetStoryBlocks( void ) const { return m_vecStoryBlocks; }
  413. CEconCampaignNodeStoryBlockDefinition * GetBestScoringStoryBlock( CEconItemView *pCampaignCoin ) const;
  414. private:
  415. CUtlVector< CEconCampaignNodeStoryBlockDefinition* > m_vecStoryBlocks; // vector of story blocks
  416. public:
  417. #endif
  418. bool BInitFromKV( int nCampaignIndex, KeyValues *pKVCampaignNodeDef, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  419. const uint32 GetID( void ) const { return m_nID; }
  420. const uint32 GetQuestIndex( void ) const { return m_nQuestIndex; }
  421. const CUtlVector< uint32 >& GetNextNodes( void ) const { return m_vecNextNodes; }
  422. const uint32 GetCampaignID( void ) const { return m_CampaignID; }
  423. private:
  424. uint32 m_nID; // index of this node
  425. uint32 m_nQuestIndex; // index of the quest
  426. uint32 m_CampaignID;
  427. CUtlVector< uint32 > m_vecNextNodes; // list of nodes that completion of this node unlocks
  428. };
  429. typedef CUtlMap<int, CEconCampaignNodeDefinition*, int, CDefLess<int> > CampaignNodeDefinitionsList_t;
  430. bool BInitFromKV( KeyValues *pKVCampaignDef, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  431. const uint32 GetID( void ) const { return m_nID; }
  432. const char* GetNameLocToken( void ) const { return m_strNameLocToken.Get(); }
  433. const char* GetDescription( void ) const { return m_strLocDescription.Get(); }
  434. const CampaignNodeDefinitionsList_t& GetStartNodes( void ) const { return m_mapStartNodes; }
  435. const CampaignNodeDefinitionsList_t& GetCampaignNodes( void ) const { return m_mapCampaignNodes; }
  436. uint32 GetSeasonNumber() const { return m_nSeasonNumber; }
  437. void GetAccessibleCampaignNodes( const uint32 unCampaignCompletionBitfield, CUtlVector< CEconCampaignNodeDefinition* > &vecAccessibleNodes );
  438. void Helper_RecursiveGetAccessibleCampaignNodes( const uint32 unCampaignCompletionBitfield, const CEconCampaignNodeDefinition* pNode, CUtlVector< CEconCampaignNodeDefinition* > &vecAccessibleNodes );
  439. private:
  440. int m_nID;
  441. CUtlConstString m_strName;
  442. CUtlConstString m_strNameLocToken;
  443. CUtlConstString m_strLocDescription;
  444. CampaignNodeDefinitionsList_t m_mapCampaignNodes;
  445. CampaignNodeDefinitionsList_t m_mapStartNodes;
  446. uint32 m_nSeasonNumber; // operation season this campaign applies to
  447. };
  448. bool ResolveQuestIdToCampaignAndIndex( uint16 unQuestID, uint32 &unCampaignID, uint32 &unCamapaignNodeID );
  449. void TokenizeCalculatorExpression( const char * szExpression, KeyValues * pKVExpressionTokens );
  450. struct item_list_entry_t
  451. {
  452. item_list_entry_t()
  453. {
  454. memset( this, 0, sizeof( *this ) );
  455. // -1 : random generation of attribute value
  456. // -2 : do not generate and set the attribute
  457. m_nPaintKitSeed = -2;
  458. m_flPaintKitWear = -2;
  459. }
  460. bool operator==( const item_list_entry_t other ) const
  461. {
  462. return (
  463. ( m_nItemDef == other.m_nItemDef ) &&
  464. ( m_nPaintKit == other.m_nPaintKit ) &&
  465. ( m_nPaintKitSeed == other.m_nPaintKitSeed ) &&
  466. ( m_flPaintKitWear == other.m_flPaintKitWear ) &&
  467. ( m_nStickerKit == other.m_nStickerKit ) &&
  468. ( m_nMusicKit == other.m_nMusicKit ) &&
  469. ( m_bIsNestedList == other.m_bIsNestedList ) &&
  470. ( m_bIsUnusualList == other.m_bIsUnusualList ) &&
  471. ( m_bAlreadyUsedInRecursiveCreation == m_bAlreadyUsedInRecursiveCreation )
  472. );
  473. }
  474. bool InitFromName( const char *pchName );
  475. // Item def
  476. int m_nItemDef;
  477. // Paint kit applied to it
  478. int m_nPaintKit;
  479. int m_nPaintKitSeed;
  480. float m_flPaintKitWear;
  481. // Sticker kit applied to it
  482. uint32 m_nStickerKit;
  483. // music kit applied to it
  484. uint32 m_nMusicKit;
  485. bool m_bIsNestedList;
  486. bool m_bIsUnusualList;
  487. mutable bool m_bAlreadyUsedInRecursiveCreation;
  488. };
  489. //-----------------------------------------------------------------------------
  490. // CEconItemSetDefinition
  491. // Definition of an item set
  492. //-----------------------------------------------------------------------------
  493. class CEconItemSetDefinition : public IEconItemSetDefinition
  494. {
  495. public:
  496. CEconItemSetDefinition( void );
  497. CEconItemSetDefinition( const CEconItemSetDefinition &that );
  498. CEconItemSetDefinition &operator=( const CEconItemSetDefinition& rhs );
  499. ~CEconItemSetDefinition( void ) {}
  500. virtual bool BInitFromKV( KeyValues *pKVItemSet, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  501. virtual const char* GetName( void ) const { return m_pszName; }
  502. // virtual const char* GetSetName( void ) const { return m_pszSetName; }
  503. virtual const char* GetLocKey( void ) const { return m_pszLocalizedName; }
  504. virtual const char* GetUnlocalizedName( void ) const { return m_pszUnlocalizedName; }
  505. virtual int GetBundle( void ) const { return m_iBundleItemDef; }
  506. virtual int GetItemCount( void ) const { return m_ItemEntries.Count(); }
  507. virtual int GetItemDef( int iIndex ) const { return m_ItemEntries[iIndex].m_nItemDef; }
  508. virtual int GetItemPaintKit( int iIndex ) const { return m_ItemEntries[iIndex].m_nPaintKit; }
  509. virtual int GetItemRarity( int iIndex ) const;
  510. virtual int GetHighestItemRarityValue( void ) const;
  511. virtual item_definition_index_t GetCraftReward( void ) const { return m_nCraftReward; }
  512. public:
  513. const char *m_pszName; // e.g. "set_dust"
  514. // const char *m_pszSetName; // unused
  515. const char *m_pszLocalizedName;
  516. const char *m_pszUnlocalizedName;
  517. const char *m_pszLocalizedDescription;
  518. CUtlVector<item_list_entry_t> m_ItemEntries;
  519. int m_iBundleItemDef; // Item def of the store bundle for this set, if any
  520. bool m_bIsCollection;
  521. bool m_bIsHiddenSet; // If true, this set and any bonuses will only be visible if the whole set is equipped.
  522. item_definition_index_t m_nCraftReward;
  523. struct itemset_attrib_t
  524. {
  525. int m_iAttribDefIndex;
  526. attrib_value_t m_valValue;
  527. };
  528. CUtlVector<itemset_attrib_t> m_iAttributes;
  529. };
  530. //-----------------------------------------------------------------------------
  531. // CEconLootListDefinition
  532. // Definition of a loot list
  533. //-----------------------------------------------------------------------------
  534. struct favored_lootlist_t
  535. {
  536. favored_lootlist_t()
  537. {
  538. iHeroID = 0;
  539. iBonus = 0;
  540. }
  541. favored_lootlist_t &operator=( const favored_lootlist_t& rhs )
  542. {
  543. iHeroID = rhs.iHeroID;
  544. iBonus = rhs.iBonus;
  545. return *this;
  546. }
  547. uint iHeroID;
  548. uint iBonus;
  549. };
  550. class CEconLootListDefinition : public IEconLootListDefinition
  551. {
  552. public:
  553. CEconLootListDefinition( void );
  554. CEconLootListDefinition( const CEconLootListDefinition &that );
  555. CEconLootListDefinition &operator=( const CEconLootListDefinition& rhs );
  556. ~CEconLootListDefinition( void );
  557. bool AddRandomAtrributes( KeyValues *pRandomAttributesKV, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  558. bool BInitFromKV( KeyValues *pKVLootList, KeyValues *pKVRandomAttributeTemplates, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL, bool bServerList = false );
  559. virtual const char *GetName() const { return m_pszName; }
  560. const CUtlVector<item_list_entry_t>& GetLootListContents() const { return m_ItemEntries; }
  561. virtual float GetWeight( int iIdx ) const { return m_flWeights[iIdx]; }
  562. virtual KeyValues* GenerateKeyValues() const;
  563. virtual bool IsServerList() const { return m_bServerList; }
  564. virtual bool HasUnusualLoot() const;
  565. // virtual const char *GetLocName() const { return m_pszLocName; };
  566. // Additional Drops
  567. virtual int GetAdditionalDropCount( void ) const { return m_AdditionalDrops.Count(); }
  568. virtual bool GetAdditionalDrop( int iIndex, CUtlString& strLootList, float& flChance ) const;
  569. // Random Attributes
  570. virtual int GetRandomAttributeGroupCount( void ) const { return m_RandomAttribs.Count(); }
  571. virtual bool GetRandomAttributeGroup( int iIndex, float& flChance, float& flTotalWeight ) const;
  572. virtual int GetRandomAttributeCount( int iGroup ) const;
  573. virtual bool GetRandomAttribute( int iGroup, int iIndex, float& flWeight, int& iValue, int& iDefIndex ) const;
  574. // Editable Interface
  575. virtual void PurgeItems( void );
  576. bool GetPublicListContents() const
  577. {
  578. // clients will only have access to the loot lists that are public anyway
  579. return true;
  580. }
  581. struct loot_list_additional_drop_t
  582. {
  583. float m_fChance;
  584. bool m_bPremiumOnly;
  585. const char *m_pszLootListDefName;
  586. };
  587. CUtlVector<loot_list_additional_drop_t> m_AdditionalDrops;
  588. protected:
  589. const char *m_pszName;
  590. CUtlVector<item_list_entry_t> m_ItemEntries;
  591. uint32 m_unHeroID;
  592. bool m_bPublicListContents; // do not show loot list contents to users (ie., when listing crate contents on Steam)
  593. #ifndef GC_DLL
  594. bool m_bWillProduceStatTrak; // will produce stattrak
  595. #endif
  596. float m_flTotalWeight;
  597. CUtlVector<float> m_flWeights;
  598. struct lootlist_attrib_t
  599. {
  600. static_attrib_t m_staticAttrib;
  601. float m_flWeight;
  602. float m_flRangeMin;
  603. float m_flRangeMax;
  604. CCopyableUtlVector< uint32 > m_vecValues;
  605. bool BInitFromKV( const char *pszContext, KeyValues *pKVKey, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors );
  606. };
  607. struct random_attrib_t
  608. {
  609. float m_flChanceOfRandomAttribute;
  610. float m_flTotalAttributeWeight;
  611. bool m_bPickAllAttributes;
  612. CUtlVector<lootlist_attrib_t> m_RandomAttributes;
  613. };
  614. CUtlVector<random_attrib_t*> m_RandomAttribs;
  615. bool m_bServerList;
  616. };
  617. //-----------------------------------------------------------------------------
  618. // CEconCraftingRecipeDefinition
  619. // Template Definition of an item recipe
  620. //-----------------------------------------------------------------------------
  621. class CEconCraftingRecipeDefinition
  622. {
  623. public:
  624. CEconCraftingRecipeDefinition( void );
  625. virtual ~CEconCraftingRecipeDefinition( void ) { }
  626. bool BInitFromKV( KeyValues *pKVItem, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  627. bool BInitFromSet( const IEconItemSetDefinition *pSet, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  628. virtual void CopyPolymorphic( const CEconCraftingRecipeDefinition *pSourceDef ) { *this = *pSourceDef; }
  629. void SetDefinitionIndex( uint32 iIndex ) { m_nDefIndex = iIndex; }
  630. int32 GetDefinitionIndex( void ) const { return m_nDefIndex; }
  631. const char *GetName( void ) const { return !m_strName.IsEmpty() ? m_strName.String() : "unknown"; }
  632. const char *GetName_A( void ) const { return !m_strN_A.IsEmpty() ? m_strN_A.String() : "unknown"; }
  633. const char *GetDescInputs( void ) const { return !m_strDescInputs.IsEmpty() ? m_strDescInputs.String() : "unknown"; }
  634. const char *GetDescOutputs( void ) const { return !m_strDescOutputs.IsEmpty() ? m_strDescOutputs.String() : "unknown"; }
  635. const char *GetDescI_A( void ) const { return !m_strDI_A.IsEmpty() ? m_strDI_A.String() : "unknown"; }
  636. const char *GetDescI_B( void ) const { return !m_strDI_B.IsEmpty() ? m_strDI_B.String() : "unknown"; }
  637. const char *GetDescI_C( void ) const { return !m_strDI_C.IsEmpty() ? m_strDI_C.String() : "unknown"; }
  638. const char *GetDescO_A( void ) const { return !m_strDO_A.IsEmpty() ? m_strDO_A.String() : "unknown"; }
  639. const char *GetDescO_B( void ) const { return !m_strDO_B.IsEmpty() ? m_strDO_B.String() : "unknown"; }
  640. const char *GetDescO_C( void ) const { return !m_strDO_C.IsEmpty() ? m_strDO_C.String() : "unknown"; }
  641. const wchar_t* GetLocName( void ) const { return m_wszName; }
  642. const wchar_t* GetLocDescription( void ) const { return m_wszDesc; }
  643. void SetDisabled( bool bDisabled ) { m_bDisabled = bDisabled; }
  644. bool IsDisabled( void ) const { return m_bDisabled; }
  645. bool RequiresAllSameClass( void ) { return m_bRequiresAllSameClass; }
  646. bool RequiresAllSameSlot( void ) { return m_bRequiresAllSameSlot; }
  647. bool IsAlwaysKnown( void ) const { return m_bAlwaysKnown; }
  648. bool IsPremiumAccountOnly( void ) const { return m_bPremiumAccountOnly; }
  649. recipecategories_t GetCategory( void ) const { return m_iCategory; }
  650. int GetFilter( void ) const { return m_iFilter; }
  651. void SetFilter( int nFilter ) { m_iFilter = nFilter; }
  652. int GetTotalInputItemsRequired( void ) const;
  653. int GetTotalOutputItems( void ) const { return m_OutputItemsCriteria.Count(); }
  654. // Returns true if the vector contains a set of items that matches the inputs for this recipe
  655. virtual bool ItemListMatchesInputs( const CUtlVector< CEconItem* > &vecCraftingItems, bool bAllowPartialMatch = false ) const;
  656. const CUtlVector<CItemSelectionCriteria> *GetInputItems( void ) const { return &m_InputItemsCriteria; }
  657. const CUtlVector<uint8> &GetInputItemDupeCounts( void ) const { return m_InputItemDupeCounts; }
  658. const CUtlVector<CItemSelectionCriteria> &GetOutputItems( void ) const { return m_OutputItemsCriteria; }
  659. // Serializes the criteria to and from messages
  660. bool BSerializeToMsg( CSOItemRecipe & msg ) const;
  661. bool BDeserializeFromMsg( const CSOItemRecipe & msg );
  662. private:
  663. void GenerateLocStrings( void );
  664. protected:
  665. // The number used to refer to this definition in the DB
  666. int32 m_nDefIndex;
  667. // Localization key strings
  668. CUtlString m_strName;
  669. CUtlString m_strN_A;
  670. CUtlString m_strDescInputs;
  671. CUtlString m_strDescOutputs;
  672. CUtlString m_strDI_A;
  673. CUtlString m_strDI_B;
  674. CUtlString m_strDI_C;
  675. CUtlString m_strDO_A;
  676. CUtlString m_strDO_B;
  677. CUtlString m_strDO_C;
  678. wchar_t m_wszName[ 64 ];
  679. wchar_t m_wszDesc[ 512 ];
  680. bool m_bDisabled;
  681. bool m_bRequiresAllSameClass;
  682. bool m_bRequiresAllSameSlot;
  683. int m_iCacheClassUsageForOutputFromItem;
  684. int m_iCacheSlotUsageForOutputFromItem;
  685. int m_iCacheSetForOutputFromItem;
  686. bool m_bAlwaysKnown;
  687. bool m_bPremiumAccountOnly;
  688. recipecategories_t m_iCategory;
  689. int m_iFilter;
  690. // The list of items that a required to make this recipe
  691. CUtlVector<CItemSelectionCriteria> m_InputItemsCriteria;
  692. CUtlVector<uint8> m_InputItemDupeCounts;
  693. // The list of items that are generated by this recipe
  694. CUtlVector<CItemSelectionCriteria> m_OutputItemsCriteria;
  695. };
  696. //-----------------------------------------------------------------------------
  697. // Purpose: Attribute definition details
  698. //-----------------------------------------------------------------------------
  699. enum
  700. {
  701. ATTDESCFORM_VALUE_IS_PERCENTAGE, // Printed as: ((m_flValue*100)-100.0)
  702. ATTDESCFORM_VALUE_IS_INVERTED_PERCENTAGE, // Printed as: ((m_flValue*100)-100.0) if it's > 1.0, or ((1.0-m_flModifier)*100) if it's < 1.0
  703. ATTDESCFORM_VALUE_IS_ADDITIVE, // Printed as: m_flValue
  704. ATTDESCFORM_VALUE_IS_ADDITIVE_PERCENTAGE, // Printed as: (m_flValue*100)
  705. ATTDESCFORM_VALUE_IS_OR, // Printed as: m_flValue, but results are ORd together instead of added
  706. ATTDESCFORM_VALUE_IS_DATE, // Printed as a date
  707. ATTDESCFORM_VALUE_IS_ACCOUNT_ID, // Printed as steam user name
  708. ATTDESCFORM_VALUE_IS_PARTICLE_INDEX, // Printed as a particle description
  709. ATTDESCFORM_VALUE_IS_ITEM_DEF, // Printed as item name
  710. ATTDESCFORM_VALUE_IS_COLOR, // Printed as R, G, B
  711. ATTDESCFORM_VALUE_IS_GAME_TIME, // Printed as: 00:00
  712. ATTDESCFORM_VALUE_IS_MINS_AS_HOURS, // Printed as: N hours when >2 hours or N minutes otherwise
  713. ATTDESCFORM_VALUE_IS_REPLACE, // Printed as: m_flValue
  714. };
  715. // Coloring for attribute lines
  716. enum attrib_effect_types_t
  717. {
  718. ATTRIB_EFFECT_NEUTRAL = 0,
  719. ATTRIB_EFFECT_POSITIVE,
  720. ATTRIB_EFFECT_NEGATIVE,
  721. NUM_EFFECT_TYPES,
  722. };
  723. enum EAssetClassAttrExportRule_t
  724. {
  725. k_EAssetClassAttrExportRule_Default = 0,
  726. k_EAssetClassAttrExportRule_Bucketed = ( 1 << 0 ), // attribute exports bucketed value to Steam Community
  727. k_EAssetClassAttrExportRule_Skip = ( 1 << 1 ), // attribute value is not exported to Steam Community
  728. k_EAssetClassAttrExportRule_GCOnly = ( 1 << 2 ), // attribute only lives on GC and not exported to any external request
  729. };
  730. //-----------------------------------------------------------------------------
  731. // CEconItemAttributeDefinition
  732. // Template definition of a randomly created attribute
  733. //-----------------------------------------------------------------------------
  734. class CEconItemAttributeDefinition : public IEconItemAttributeDefinition
  735. {
  736. public:
  737. CEconItemAttributeDefinition( void );
  738. CEconItemAttributeDefinition( const CEconItemAttributeDefinition &that );
  739. CEconItemAttributeDefinition &operator=( const CEconItemAttributeDefinition& rhs );
  740. ~CEconItemAttributeDefinition( void );
  741. bool BInitFromKV( KeyValues *pKVAttribute, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  742. virtual attrib_definition_index_t GetDefinitionIndex( void ) const { return m_nDefIndex; }
  743. // Attribute name referenced in the db.
  744. virtual const char *GetDefinitionName( void ) const { return m_pszDefinitionName; }
  745. virtual KeyValues *GetRawDefinition( void ) const { return m_pKVAttribute; }
  746. // Data accessing
  747. bool IsHidden( void ) const { return m_bHidden; }
  748. bool BForceWebSchemaOutput( void ) const { return m_bWebSchemaOutputForced; }
  749. bool IsStoredAsInteger( void ) const { return m_bStoredAsInteger; }
  750. bool IsStoredAsFloat( void ) const { return !m_bStoredAsInteger; }
  751. bool IsInstanceData() const { return m_bInstanceData; }
  752. EAssetClassAttrExportRule_t GetAssetClassAttrExportRule() const { return m_eAssetClassAttrExportRule; }
  753. uint32 GetAssetClassBucket() const { return m_unAssetClassBucket; }
  754. int GetDescriptionFormat( void ) const { return m_iDescriptionFormat; }
  755. int GetScore( void ) const { return m_iScore; }
  756. virtual const char *GetDescriptionString( void ) const { return m_pszDescriptionString; }
  757. const char *GetArmoryDescString( void ) const { return m_pszArmoryDesc; }
  758. virtual const char *GetAttributeClass( void ) const { return m_pszAttributeClass; }
  759. attrib_effect_types_t GetEffectType( void ) const { return m_iEffectType; }
  760. const class ISchemaAttributeType *GetAttributeType( void ) const { return m_pAttrType; }
  761. #ifndef GC_DLL
  762. void ClearStringCache( void ) const { m_iszAttributeClass = NULL_STRING; }
  763. string_t GetCachedClass( void ) const
  764. {
  765. if ( m_iszAttributeClass == NULL_STRING && m_pszAttributeClass )
  766. {
  767. m_iszAttributeClass = AllocPooledString( m_pszAttributeClass );
  768. }
  769. return m_iszAttributeClass;
  770. }
  771. #endif
  772. private:
  773. // The raw keyvalues for this attribute definition.
  774. KeyValues *m_pKVAttribute;
  775. // Required valued from m_pKVAttribute:
  776. // The number used to refer to this definition in the DB
  777. attrib_definition_index_t m_nDefIndex;
  778. // ...
  779. const class ISchemaAttributeType *m_pAttrType;
  780. // ---------------------------------------------
  781. // Display related data
  782. // ---------------------------------------------
  783. // If true, this attribute isn't shown in the item description
  784. bool m_bHidden;
  785. // If true, this attribute's description is always output in web api calls regardless of the hidden flag.
  786. bool m_bWebSchemaOutputForced;
  787. // Whether or not the value is stored as an integer in the DB.
  788. bool m_bStoredAsInteger;
  789. // If this is true the attribute is counted as "instance" data for purposes of asset class in the Steam Economy. Non-instance
  790. // properties are considered things that can differentiate items at a fundamental level (ie., definition index, quality); instance
  791. // properties are more things like additional customizations -- score for strange items, paint color, etc.
  792. bool m_bInstanceData;
  793. EAssetClassAttrExportRule_t m_eAssetClassAttrExportRule; // if this is true the attribute will not be exported for asset class
  794. uint32 m_unAssetClassBucket; // if this is set then attribute value is bucketed when exported for asset class
  795. // Overall positive/negative effect. Used to color the attribute.
  796. attrib_effect_types_t m_iEffectType;
  797. // Contains the description format & string for this attribute
  798. int m_iDescriptionFormat;
  799. const char *m_pszDescriptionString;
  800. const char *m_pszDescriptionTag;
  801. // Contains information on how to describe items with this attribute in the Armory
  802. const char *m_pszArmoryDesc;
  803. int m_iScore;
  804. // Used to allow unique items to specify attributes by name.
  805. const char *m_pszDefinitionName;
  806. // The class name of this attribute. Used in creation, and to hook the attribute into the actual code that uses it.
  807. const char *m_pszAttributeClass;
  808. #if defined(CLIENT_DLL) || defined(GAME_DLL) || defined(GC)
  809. mutable string_t m_iszAttributeClass; // Same as the above, but used for fast lookup when applying attributes.
  810. #endif
  811. };
  812. //-----------------------------------------------------------------------------
  813. // CEconSoundMaterialDefinition
  814. //-----------------------------------------------------------------------------
  815. class CEconSoundMaterialDefinition
  816. {
  817. public:
  818. CEconSoundMaterialDefinition( void );
  819. CEconSoundMaterialDefinition( const CEconSoundMaterialDefinition &that );
  820. CEconSoundMaterialDefinition &operator=( const CEconSoundMaterialDefinition& rhs );
  821. ~CEconSoundMaterialDefinition( void ) { }
  822. bool BInitFromKV( KeyValues *pKVItem, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  823. int32 GetID( void ) const { return m_nID; }
  824. const char *GetName( void ) const { return !m_strName.IsEmpty() ? m_strName.String() : "unknown"; }
  825. const char *GetStartDragSound( void ) const { return m_strStartDragSound.Get(); }
  826. const char *GetEndDragSound( void ) const { return m_strEndDragSound.Get(); }
  827. const char *GetEquipSound( void ) const { return m_strEquipSound.Get(); }
  828. private:
  829. // The value that the game/DB will know this sound material by
  830. int32 m_nID;
  831. // The English name of the sound material
  832. CUtlString m_strName;
  833. // sounds played when dragging items of this material around the backpack
  834. CUtlString m_strStartDragSound;
  835. CUtlString m_strEndDragSound;
  836. // sound played when equipping an item of this material
  837. CUtlString m_strEquipSound;
  838. };
  839. //-----------------------------------------------------------------------------
  840. // Visual data storage in item definitions
  841. //-----------------------------------------------------------------------------
  842. #define MAX_VISUALS_CUSTOM_SOUNDS 10
  843. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  844. enum
  845. {
  846. kAttachedModelDisplayFlag_WorldModel = 0x01,
  847. kAttachedModelDisplayFlag_ViewModel = 0x02,
  848. kAttachedModelDisplayFlag_MaskAll = kAttachedModelDisplayFlag_WorldModel | kAttachedModelDisplayFlag_ViewModel,
  849. };
  850. struct attachedmodel_t
  851. {
  852. const char *m_pszModelName;
  853. int m_iModelDisplayFlags;
  854. };
  855. struct attachedparticle_t
  856. {
  857. int m_iParticleIndex;
  858. int m_nStyle;
  859. };
  860. enum wearableanimplayback_t
  861. {
  862. WAP_ON_SPAWN, // Play this animation immediately on spawning the wearable
  863. WAP_START_BUILDING, // Game code will start this anim whenever a player wearing this item deploys their builder weapon.
  864. WAP_STOP_BUILDING, // Game code will start this anim whenever a player wearing this item holsters their builder weapon.
  865. NUM_WAP_TYPES,
  866. };
  867. struct animation_on_wearable_t
  868. {
  869. int iActivity;
  870. const char *pszActivity;
  871. wearableanimplayback_t iPlayback;
  872. const char *pszReplacement;
  873. int iReplacement; // Replacement activity to play. Might be set to one of kActivityLookup_Unknown/kActivityLookup_Missing.
  874. const char *pszSequence;
  875. const char *pszRequiredItem;
  876. const char *pszScene;
  877. float flFrequency;
  878. };
  879. struct sound_on_wearable_t
  880. {
  881. const char* pszSound;
  882. const char* pszReplacement;
  883. };
  884. struct particle_on_wearable_t
  885. {
  886. const char* pszParticle;
  887. const char* pszReplacement;
  888. bool bFlyingCourierEffect;
  889. };
  890. struct particlesnapshot_on_wearable_t
  891. {
  892. const char* pszParticleSnapshot;
  893. const char* pszReplacement;
  894. };
  895. struct particle_control_point_on_wearable_t
  896. {
  897. const char* pszParticle;
  898. int nParticleControlPoint;
  899. Vector vecCPValue;
  900. };
  901. struct codecontrolledbodygroupdata_t
  902. {
  903. const char *pFuncName;
  904. void *pFunc;
  905. };
  906. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  907. struct style_unlock_info
  908. {
  909. const char* pszItemName;
  910. int iPrice;
  911. int iStylePreReq;
  912. const char* pszAttrib;
  913. uint32 iAttribValue;
  914. bool IsLockable() const
  915. {
  916. return pszItemName || pszAttrib;
  917. }
  918. bool HasUnlockPrice() const
  919. {
  920. return iPrice && pszItemName;
  921. }
  922. bool HasUnlockAttrib() const
  923. {
  924. return iAttribValue && pszAttrib;
  925. }
  926. };
  927. class CEconStyleInfo
  928. {
  929. public:
  930. CEconStyleInfo()
  931. {
  932. m_iIndex = 0;
  933. m_iSkin = 0;
  934. m_iIcon = 0;
  935. m_pszName = NULL;
  936. m_pszBasePlayerModel = NULL;
  937. m_UnlockInfo.pszItemName = NULL;
  938. m_UnlockInfo.iPrice = 0;
  939. m_UnlockInfo.iStylePreReq = 0;
  940. m_UnlockInfo.pszAttrib = NULL;
  941. m_UnlockInfo.iAttribValue = 0;
  942. }
  943. virtual ~CEconStyleInfo()
  944. {
  945. //
  946. }
  947. virtual void BInitFromKV( KeyValues *pKVItem, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors );
  948. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  949. virtual void GeneratePrecacheModelStringsForStyle( CUtlVector<const char *> *out_pVecModelStrings ) const;
  950. #endif
  951. int GetSkin() const
  952. {
  953. return m_iSkin;
  954. }
  955. int GetIndex() const { return m_iIndex; }
  956. const char *GetName() const { return m_pszName; }
  957. const char *GetBasePlayerDisplayModel() const { return m_pszBasePlayerModel; }
  958. const CUtlVector<const char *>& GetAdditionalHideBodygroups() const { return m_vecAdditionalHideBodygroups; }
  959. int GetIcon() const { return m_iIcon; }
  960. const style_unlock_info* GetUnlockInfo() const { return &m_UnlockInfo; }
  961. protected:
  962. int m_iIndex;
  963. int m_iSkin;
  964. int m_iIcon;
  965. const char *m_pszName;
  966. const char *m_pszBasePlayerModel;
  967. CUtlVector<const char *> m_vecAdditionalHideBodygroups;
  968. style_unlock_info m_UnlockInfo;
  969. };
  970. struct courier_t
  971. {
  972. const char *m_pszModelName;
  973. int m_iTeam;
  974. };
  975. struct announcer_preview_t
  976. {
  977. CUtlString m_strFileName;
  978. CUtlString m_strCaption;
  979. };
  980. struct ability_icon_replacement_t
  981. {
  982. CUtlString m_strAbilityName;
  983. CUtlString m_strReplacement;
  984. };
  985. enum EAssetModifier
  986. {
  987. AM_Invalid=-1,
  988. AM_Activity,
  989. AM_Announcer,
  990. AM_AnnouncerPreview,
  991. AM_HudSkin,
  992. AM_AbilityName,
  993. AM_Sound,
  994. AM_Speech,
  995. AM_Particle,
  996. AM_ParticleSnapshot,
  997. AM_ParticleControlPoint,
  998. AM_EntityModel,
  999. AM_ViewModel,
  1000. AM_EntityScale,
  1001. AM_Icon,
  1002. AM_AbilityIcon,
  1003. AM_Courier,
  1004. AM_CourierFlying,
  1005. AM_HeroModelChange,
  1006. AM_MAX
  1007. };
  1008. struct AssetModifier
  1009. {
  1010. EAssetModifier m_Type;
  1011. CUtlString m_strAsset;
  1012. CUtlString m_strModifier;
  1013. float m_flModifier;
  1014. float m_flFrequency;
  1015. int m_iStyle;
  1016. };
  1017. struct AssetInfo
  1018. {
  1019. AssetInfo()
  1020. {
  1021. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  1022. iHideParentBodyGroup = -1;
  1023. m_ModifiedBodyGroupNames.SetLessFunc( StringLessThan );
  1024. m_CodeControlledBodyGroupNames.SetLessFunc( StringLessThan );
  1025. iSkin = 0;
  1026. bUsePerClassBodygroups = false;
  1027. m_pszMaterialOverride = NULL;
  1028. m_pszParticleEffect = NULL;
  1029. m_pszParticleSnapshot = NULL;
  1030. for ( int i = 0; i < MAX_VISUALS_CUSTOM_SOUNDS; i++ )
  1031. {
  1032. m_pszCustomSounds[i] = NULL;
  1033. }
  1034. for ( int i = 0; i < NUM_SHOOT_SOUND_TYPES; i++ )
  1035. {
  1036. m_pszWeaponSoundReplacements[i] = NULL;
  1037. }
  1038. m_iViewModelBodyGroupOverride = -1;
  1039. m_iViewModelBodyGroupStateOverride = -1;
  1040. m_iWorldModelBodyGroupOverride = -1;
  1041. m_iWorldModelBodyGroupStateOverride = -1;
  1042. m_pszSpeechConcept = NULL;
  1043. m_pszChatMessage = NULL;
  1044. m_pszAnnouncerName.Clear();
  1045. m_pszAnnouncerResource.Clear();
  1046. m_pszEntityModel = NULL;
  1047. m_pszViewModel = NULL;
  1048. m_pszEntityClass = NULL;
  1049. // m_pszHeroModelFrom = NULL;
  1050. // m_pszHeroModelTo = NULL;
  1051. m_flScaleSize = 1.f;
  1052. m_pszScaleClass = NULL;
  1053. m_bSkipModelCombine = false;
  1054. m_pszPrimaryAmmo = NULL;
  1055. m_pszWeaponTypeString = NULL;
  1056. m_pszAddonLocation = NULL;
  1057. m_pszEjectBrassEffect = NULL;
  1058. m_pszTracerEffect = NULL;
  1059. m_pszMuzzleFlashEffect1stPerson = NULL;
  1060. m_pszMuzzleFlashEffect1stPersonAlt = NULL;
  1061. m_pszMuzzleFlashEffect3rdPerson = NULL;
  1062. m_pszMuzzleFlashEffect3rdPersonAlt = NULL;
  1063. m_pszHeatEffect = NULL;
  1064. m_pszPlayerAnimationExtension = NULL;
  1065. m_pszOriginalIcon = NULL;
  1066. m_pszNewIcon = NULL;
  1067. m_mapAssetModifiers.SetLessFunc( DefLessFunc(int) );
  1068. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  1069. }
  1070. ~AssetInfo()
  1071. {
  1072. m_Styles.PurgeAndDeleteElements();
  1073. }
  1074. void AddAssetModifier( AssetModifier* newMod );
  1075. CUtlVector<AssetModifier*>* GetAssetModifiers( EAssetModifier type );
  1076. const char* GetModifierByAsset( EAssetModifier type, const char* pszAsset, int iStyle=-1 );
  1077. const char* GetAssetByModifier( EAssetModifier type, const char* pszModifier, int iStyle=-1 );
  1078. CUtlMap< int, CUtlVector<AssetModifier*>* > m_mapAssetModifiers;
  1079. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  1080. // Properties necessary for the game client/server but not for the GC.
  1081. int iHideParentBodyGroup;
  1082. CUtlMap<const char*, int> m_ModifiedBodyGroupNames; // Better method: hide multiple body groups by name.
  1083. CUtlMap<const char*, codecontrolledbodygroupdata_t> m_CodeControlledBodyGroupNames;
  1084. int iSkin;
  1085. bool bUsePerClassBodygroups;
  1086. CUtlVector<attachedmodel_t> m_AttachedModels;
  1087. CUtlVector<attachedparticle_t> m_AttachedParticles;
  1088. CUtlVector<animation_on_wearable_t> m_Animations;
  1089. CUtlVector<sound_on_wearable_t> m_Sounds;
  1090. CUtlVector<particle_on_wearable_t> m_Particles;
  1091. CUtlVector<particlesnapshot_on_wearable_t> m_ParticleSnapshots;
  1092. CUtlVector<particle_control_point_on_wearable_t> m_ParticleControlPoints;
  1093. const char *m_pszCustomSounds[MAX_VISUALS_CUSTOM_SOUNDS];
  1094. const char *m_pszMaterialOverride;
  1095. const char *m_pszMuzzleFlash;
  1096. const char *m_pszTracerEffect;
  1097. const char *m_pszParticleEffect;
  1098. const char *m_pszParticleSnapshot;
  1099. const char *m_pszWeaponSoundReplacements[NUM_SHOOT_SOUND_TYPES];
  1100. const char *m_pszPrimaryAmmo;
  1101. const char *m_pszWeaponTypeString;
  1102. const char *m_pszAddonLocation;
  1103. const char *m_pszEjectBrassEffect;
  1104. const char *m_pszMuzzleFlashEffect1stPerson;
  1105. const char *m_pszMuzzleFlashEffect1stPersonAlt;
  1106. const char *m_pszMuzzleFlashEffect3rdPerson;
  1107. const char *m_pszMuzzleFlashEffect3rdPersonAlt;
  1108. const char *m_pszHeatEffect;
  1109. const char *m_pszPlayerAnimationExtension;
  1110. int m_iViewModelBodyGroupOverride;
  1111. int m_iViewModelBodyGroupStateOverride;
  1112. int m_iWorldModelBodyGroupOverride;
  1113. int m_iWorldModelBodyGroupStateOverride;
  1114. bool m_bSkipModelCombine;
  1115. CUtlVector<const char*> m_vecAnimationModifiers;
  1116. // For custom speech events and chat messages on use.
  1117. const char *m_pszSpeechConcept;
  1118. const char *m_pszChatMessage;
  1119. // For Announcer
  1120. CUtlString m_pszAnnouncerName;
  1121. CUtlString m_pszAnnouncerResource;
  1122. CUtlVector< announcer_preview_t > m_vecAnnouncerPreview;
  1123. CUtlString m_pszHudSkinName;
  1124. // for consumables that create an in-game ability
  1125. CUtlString m_pszAbilityName;
  1126. // For Overriding Entity Base Models
  1127. const char *m_pszEntityModel;
  1128. const char *m_pszViewModel;
  1129. const char *m_pszEntityClass;
  1130. // TEMP: For interrupting hero model changes
  1131. // const char *m_pszEntityModel;
  1132. // const char *m_pszEntityClass;
  1133. // For changing an entity's size.
  1134. float m_flScaleSize;
  1135. const char *m_pszScaleClass;
  1136. //Override HUD icons
  1137. const char *m_pszOriginalIcon;
  1138. const char *m_pszNewIcon;
  1139. CUtlVector< ability_icon_replacement_t > m_vecAbilityIconReplacements;
  1140. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  1141. // The GC does care about styles.
  1142. CUtlVector<CEconStyleInfo *> m_Styles;
  1143. };
  1144. enum item_capabilities_t
  1145. {
  1146. ITEM_CAP_NONE = 0,
  1147. ITEM_CAP_PAINTABLE = 1 << 0, // some items are tagged in CS:GO schema, but we don't use it
  1148. ITEM_CAP_NAMEABLE = 1 << 1, // used in CS:GO on all weapons that can get a name tag
  1149. ITEM_CAP_DECODABLE = 1 << 2, // used in CS:GO on supply crates containers
  1150. ITEM_CAP_CAN_DELETE = 1 << 3, // used in CS:GO on supply crates containers
  1151. ITEM_CAP_CAN_CUSTOMIZE_TEXTURE = 1 << 4, // NOT USED
  1152. ITEM_CAP_USABLE = 1 << 5, // NOT USED
  1153. ITEM_CAP_USABLE_GC = 1 << 6, // some items are tagged in CS:GO schema, but we don't use it
  1154. ITEM_CAP_CAN_GIFT_WRAP = 1 << 7, // NOT USED
  1155. ITEM_CAP_USABLE_OUT_OF_GAME = 1 << 8, // some items are tagged in CS:GO schema, but we don't use it
  1156. ITEM_CAP_CAN_COLLECT = 1 << 9, // NOT USED
  1157. ITEM_CAP_CAN_CRAFT_COUNT = 1 << 10, // NOT USED
  1158. ITEM_CAP_CAN_CRAFT_MARK = 1 << 11, // NOT USED
  1159. ITEM_CAP_PAINTABLE_TEAM_COLORS = 1 << 12, // NOT USED
  1160. ITEM_CAP_CAN_BE_RESTORED = 1 << 13, // NOT USED
  1161. ITEM_CAP_CAN_USE_STRANGE_PARTS = 1 << 14, // NOT USED
  1162. ITEM_CAP_PAINTABLE_UNUSUAL = 1 << 15, // NOT USED
  1163. ITEM_CAP_CAN_INCREMENT = 1 << 16, // NOT USED
  1164. ITEM_CAP_USES_ESSENCE = 1 << 17, // NOT USED
  1165. ITEM_CAP_AUTOGRAPH = 1 << 18, // NOT USED
  1166. ITEM_CAP_RECIPE = 1 << 19, // NOT USED
  1167. ITEM_CAP_CAN_STICKER = 1 << 20, // used in CS:GO on sticker tools, primary and secondary weapons
  1168. ITEM_CAP_STATTRACK_SWAP = 1 << 21, // used in CS:GO on stattrack items
  1169. NUM_ITEM_CAPS = 22,
  1170. };
  1171. enum { ITEM_CAP_DEFAULT = ITEM_CAP_NONE }; // what are the default capabilities on an item?
  1172. enum { ITEM_CAP_TOOL_DEFAULT = ITEM_CAP_NONE }; // what are the default capabilities of a tool?
  1173. struct bundleinfo_t
  1174. {
  1175. CUtlVector <item_list_entry_t > vecItemEntries;
  1176. };
  1177. #ifdef CLIENT_DLL
  1178. namespace vgui
  1179. {
  1180. class Panel;
  1181. }
  1182. #endif // CLIENT_DLL
  1183. class IEconConsumable
  1184. {
  1185. };
  1186. class IEconItemInterface;
  1187. class IEconTool
  1188. {
  1189. friend class CEconSharedToolSupport;
  1190. public:
  1191. IEconTool( const char *pszTypeName, const char *pszUseString, const char *pszUsageRestriction, item_capabilities_t unCapabilities, KeyValues* pUsageKV )
  1192. : m_pszTypeName( pszTypeName )
  1193. , m_pszUseString( pszUseString )
  1194. , m_pszUsageRestriction( pszUsageRestriction )
  1195. , m_unCapabilities( unCapabilities )
  1196. {
  1197. if ( pUsageKV )
  1198. {
  1199. KeyValues* pBonusItemDefs = pUsageKV->FindKey( "bonus_itemdefs" );
  1200. if ( pBonusItemDefs )
  1201. {
  1202. FOR_EACH_SUBKEY( pBonusItemDefs, pBonusItemDef )
  1203. {
  1204. m_vecBonusItemDef.AddToTail( atoi( pBonusItemDef->GetName() ) );
  1205. }
  1206. }
  1207. }
  1208. }
  1209. virtual ~IEconTool() { }
  1210. // Shared code.
  1211. const char *GetUsageRestriction() const { return m_pszUsageRestriction; }
  1212. item_capabilities_t GetCapabilities() const { return m_unCapabilities; }
  1213. virtual bool CanApplyTo( const IEconItemInterface *pTool, const IEconItemInterface *pToolSubject ) const { Assert( pTool ); Assert( pToolSubject ); return true; }
  1214. virtual bool ShouldDisplayQuantity( const IEconItemInterface *pTool ) const;
  1215. virtual bool RequiresToolEscrowPeriod() const { return false; }
  1216. // We don't support throwing exceptions from tool construction so this is intended to be checked afterwards
  1217. // whenever a new tool is created. (See CreateEconToolImpl().)
  1218. virtual bool IsValid() const { return true; }
  1219. // Used by the GC only for WebAPI responses and for some weird internal code.
  1220. const char *GetTypeName() const { return m_pszTypeName; } // would like to disable on the client so we aren't tempted to check against it, but used for building a unique tool list
  1221. const char *GetUseString() const { return m_pszUseString; }
  1222. // Bonus Items
  1223. int GetBonusItemDefCount( void ) const { return m_vecBonusItemDef.Count(); }
  1224. int GetBonusItemDef( int i ) const { return m_vecBonusItemDef[i]; }
  1225. virtual IEconConsumable* CreateEconConsumable() const
  1226. {
  1227. Assert( !"IEconTool::CreateEconConsumable(): unimplemented call!" );
  1228. return NULL;
  1229. }
  1230. #ifdef CLIENT_DLL
  1231. virtual bool ShouldShowContainedItemPanel( const IEconItemInterface *pItem ) const { Assert( !"IEconTool::ShouldShowContainedItemPanel(): we don't expect this to be called on anything besides gifts!" ); return false; }
  1232. virtual const char *GetUseCommandLocalizationToken( const IEconItemInterface *pItem, const char* pszDefault="#ApplyOnItem" ) const;
  1233. // Client "do something" interface. At least one of these functions must be implemented or your tool
  1234. // won't do anything on the client. Some tools (ie., collections) will implement both because they
  1235. // have one application behavior and one client-UI behavior.
  1236. // When the client attempts to use a consumable item of any kind, this function will be called. This
  1237. // is called from the UI in response to things like using dueling pistols, using a noisemaker, etc.
  1238. // Usually this opens up some UI, sends off a GC message, etc.
  1239. //
  1240. // There is a "default" implementation of this function in ClientConsumableTool_Generic() that can
  1241. // be called if specific behavior isn't needed.
  1242. virtual void OnClientUseConsumable( class C_EconItemView *pItem ) const
  1243. {
  1244. Assert( !"IEconTool::OnClientUseConsumable(): unimplemented call!" );
  1245. }
  1246. // When the client attempts to apply a tool to a specific other item in their inventory, this function
  1247. // will be called. This is called from the UI is response to things like putting paint on an item,
  1248. // using a key to unlock a crate, etc.
  1249. virtual void OnClientApplyTool( class C_EconItemView *pTool, class C_EconItemView *pSubject ) const
  1250. {
  1251. Assert( !"IEconTool::OnClientApplyTool(): unimplemented call!" );
  1252. }
  1253. virtual void OnClientApplyCommit( class C_EconItemView *pTool, class C_EconItemView *pSubject ) const
  1254. {
  1255. Assert( !"IEconTool::OnClientApplyCommit(): unimplemented call!" );
  1256. }
  1257. #endif // CLIENT_DLL
  1258. private:
  1259. const char *m_pszTypeName;
  1260. const char *m_pszUseString;
  1261. const char *m_pszUsageRestriction;
  1262. item_capabilities_t m_unCapabilities;
  1263. CUtlVector<int> m_vecBonusItemDef;
  1264. };
  1265. enum EItemType
  1266. {
  1267. k_EItemTypeNone,
  1268. k_EItemTypeCoupon,
  1269. k_EItemTypeCampaign,
  1270. k_EItemTypeSelfOpeningPurchase,
  1271. k_EItemTypeOperationCoin,
  1272. k_EItemTypePrestigeCoin,
  1273. k_EItemTypeTool,
  1274. };
  1275. const char* PchNameFromEItemType( EItemType eType );
  1276. enum EItemSlot
  1277. {
  1278. k_EItemSlotNone,
  1279. k_EItemSlotMelee,
  1280. k_EItemSlotSecondary,
  1281. k_EItemSlotSMG,
  1282. k_EItemSlotRifle,
  1283. k_EItemSlotHeavy,
  1284. k_EItemSlotFlair,
  1285. k_EItemSlotMusicKit,
  1286. };
  1287. const char* PchNameFromEItemSlot( EItemSlot eSlot );
  1288. EItemSlot EItemSlotFromName( const char * pchName );
  1289. //-----------------------------------------------------------------------------
  1290. // CEconItemDefinition
  1291. // Template Definition of a randomly created item
  1292. //-----------------------------------------------------------------------------
  1293. class CEconItemDefinition : public IEconItemDefinition
  1294. {
  1295. public:
  1296. CEconItemDefinition( void );
  1297. virtual ~CEconItemDefinition( void );
  1298. void PurgeStaticAttributes( void );
  1299. public:
  1300. // BInitFromKV can be implemented on subclasses to parse additional values.
  1301. virtual bool BInitFromKV( KeyValues *pKVItem, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  1302. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  1303. virtual bool BInitFromTestItemKVs( int iNewDefIndex, KeyValues *pKVItem, CEconItemSchema &pschema );
  1304. virtual void GeneratePrecacheModelStrings( bool bDynamicLoad, CUtlVector<const char *> *out_pVecModelStrings ) const;
  1305. virtual void GeneratePrecacheSoundStrings( CUtlVector<const char*> *out_pVecSoundStrings ) const;
  1306. virtual void GeneratePrecacheEffectStrings( CUtlVector<const char*> *out_pVecEffectStrings ) const;
  1307. #endif
  1308. virtual void CopyPolymorphic( const CEconItemDefinition *pSourceDef ) { *this = *pSourceDef; }
  1309. bool BInitItemMappings( CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors );
  1310. virtual void BInitVisualBlockFromKV( KeyValues *pKVItem, IEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  1311. void BInitStylesBlockFromKV( KeyValues *pKVStyles, CEconItemSchema &pschema, AssetInfo *pAssetInfo, CUtlVector<CUtlString> *pVecErrors );
  1312. bool BInitAlternateIconsFromKV( KeyValues *pKVAlternateIcons, CEconItemSchema &pschema, AssetInfo *pAssetInfo, CUtlVector<CUtlString> *pVecErrors );
  1313. virtual item_definition_index_t GetDefinitionIndex( void ) const { return m_nDefIndex; }
  1314. const CUtlVector<item_definition_index_t>& GetAssociatedItemsDefIndexes() const { return m_nAssociatedItemsDefIndexes; }
  1315. virtual const char* GetPrefabName( void ) const { return m_szPrefab; }
  1316. bool BEnabled( void ) const { return m_bEnabled; }
  1317. bool BLoadOnDemand( void ) const { return m_bLoadOnDemand; }
  1318. bool BHasBeenLoaded( void ) const { return m_bHasBeenLoaded; }
  1319. const char *GetDefinitionName( void ) const { return m_pszDefinitionName; }
  1320. const char *GetItemClass( void ) const { return m_pszItemClassname; }
  1321. virtual const char *GetItemBaseName( void ) const { return m_pszItemBaseName; }
  1322. const char *GetBrassModelOverride( void ) const{ return m_pszBrassModelOverride; }
  1323. virtual const char *GetItemTypeName( void ) const { return m_pszItemTypeName; }
  1324. virtual uint32 GetItemTypeID( void ) const { return m_unItemTypeID; }
  1325. uint8 GetMinLevel( void ) const { return m_unMinItemLevel; }
  1326. uint8 GetMaxLevel( void ) const { return m_unMaxItemLevel; }
  1327. virtual uint8 GetRarity( void ) const { return m_nItemRarity; }
  1328. uint8 GetQuality( void ) const { return m_nItemQuality; }
  1329. uint8 GetForcedQuality( void ) const { return m_nForcedItemQuality; }
  1330. uint8 GetDefaultDropQuality( void ) const { return m_nDefaultDropItemQuality; }
  1331. uint8 GetDefaultDropQuantity( void ) const{ return m_nDefaultDropQuantity; }
  1332. KeyValues *GetRawDefinition( void ) const { return m_pKVItem; }
  1333. const CUtlVector<static_attrib_t> &GetStaticAttributes( void ) const { return m_vecStaticAttributes; }
  1334. uint32 GetNumConcreteItems() const { return m_unNumConcreteItems; }
  1335. int GetSoundMaterialID() const { return m_nSoundMaterialID; }
  1336. // Data accessing
  1337. bool IsHidden( void ) const { return m_bHidden; }
  1338. bool IsImported( void ) const { return m_bImported; }
  1339. bool IsOnePerAccountCDKEY( void ) const { return m_bOnePerAccountCDKEY; }
  1340. bool IsAllowedInMatch( void ) const { return m_bAllowedInThisMatch; }
  1341. virtual bool IsBaseItem( void ) const { return m_bBaseItem; }
  1342. virtual bool IsDefaultSlotItem( void ) const { return m_bDefaultSlotItem; }
  1343. virtual bool IsBundle( void ) const { return m_BundleInfo != NULL; }
  1344. bool HasProperName( void ) const { return m_bProperName; }
  1345. const char *GetClassToken( void ) const { return m_pszClassToken; }
  1346. const char *GetSlotToken( void ) const { return m_pszSlotToken; }
  1347. bool ShouldAttachToHands( void ) const { return m_bAttachToHands; }
  1348. bool ShouldAttachToHandsVMOnly( void ) const { return m_bAttachToHandsVMOnly; }
  1349. bool ShouldFlipViewmodels( void ) const { return m_bFlipViewModel; }
  1350. int GetInventoryImagePosition( int iIndex ) const { Assert( iIndex >= 0 && iIndex < 2); return m_iInventoryImagePosition[iIndex]; }
  1351. int GetInventoryImageSize( int iIndex ) const { Assert( iIndex >= 0 && iIndex < 2); return m_iInventoryImageSize[iIndex]; }
  1352. int GetDropType( void ) const { return m_iDropType; }
  1353. const char *GetHolidayRestriction( void ) const { return m_pszHolidayRestriction; }
  1354. int GetSubType( void ) const { return m_iSubType; }
  1355. item_capabilities_t GetCapabilities( void ) const { return m_iCapabilities; }
  1356. void AddItemSet( int nIndex );
  1357. const CUtlVector< int >& GetItemSets( void ) const;
  1358. int GetArmoryRemap( void ) const { return m_iArmoryRemap; }
  1359. int GetStoreRemap( void ) const { return m_iStoreRemap; }
  1360. virtual int GetLoadoutSlot( void ) const { return 0; }
  1361. virtual int GetHeroID( void ) const { return 0; }
  1362. KeyValues* GetPortraitsKV( void ) const { return m_pPortraitsKV; }
  1363. KeyValues* GetPortraitKVForModel( const char* pszModelName ) const;
  1364. AssetInfo *GetAssetInfo() const { return m_pAssetInfo; }
  1365. bool IsTool() const { return m_pTool != NULL; }
  1366. bool IsToolAndNotACrate() const { return ( IsTool() && GetEconTool() && V_strcmp( GetEconTool()->GetTypeName(), "supply_crate" ) != 0 ); }
  1367. const IEconTool *GetEconTool() const { return m_pTool; }
  1368. template < class T >
  1369. const T *GetTypedEconTool() const { return dynamic_cast<const T *>( GetEconTool() ); }
  1370. virtual bool IsPreviewableInStore() const { return true; }
  1371. const bundleinfo_t *GetBundleInfo( void ) const { return m_BundleInfo; }
  1372. virtual int GetBundleItemCount( void ) const { return m_BundleInfo ? m_BundleInfo->vecItemEntries.Count() : 0; }
  1373. virtual int GetBundleItem( int iIndex ) const { return m_BundleInfo ? m_BundleInfo->vecItemEntries[iIndex].m_nItemDef : -1; }
  1374. virtual int GetBundleItemPaintKitID( int iIndex ) const { return m_BundleInfo ? m_BundleInfo->vecItemEntries[iIndex].m_nPaintKit : -1; }
  1375. // Is this item contained in any bundles? GetContainingBundles() gets the CEconItemDefinitions for those bundles.
  1376. const CUtlVector< const CEconItemDefinition * > &GetContainingBundles() const { return m_vecContainingBundleItemDefs; }
  1377. uint32 GetContainingBundleCount() const { return m_vecContainingBundleItemDefs.Count(); }
  1378. typedef CUtlVector< uint32 > WorkshopContributorList_t;
  1379. void AddSteamWorkshopContributor( uint32 unAccountID ) { if ( m_vecSteamWorkshopContributors.InvalidIndex() == m_vecSteamWorkshopContributors.Find( unAccountID ) ) { m_vecSteamWorkshopContributors.AddToTail( unAccountID ); } }
  1380. const WorkshopContributorList_t &GetSteamWorkshopContributors() const { return m_vecSteamWorkshopContributors; }
  1381. bool BIsSteamWorkshopItem() const { return m_vecSteamWorkshopContributors.Count() > 0; }
  1382. const char *GetIconClassname( void ) const { return m_pszItemIconClassname; }
  1383. const char *GetLogClassname( void ) const { return m_pszItemLogClassname; }
  1384. const char *GetInventoryModel( void ) const { return m_pszInventoryModel; }
  1385. virtual const char *GetInventoryImage( void ) const { return m_pszInventoryImage; }
  1386. const char *GetInventoryOverlayImage( int idx ) const { if ( m_pszInventoryOverlayImages.IsValidIndex( idx ) ) return m_pszInventoryOverlayImages[idx]; else return NULL; }
  1387. int GetInventoryOverlayImageCount( void ) const { return m_pszInventoryOverlayImages.Count(); }
  1388. const char *GetIconURLSmall() const { return m_sIconURLSmall; }
  1389. const char *GetIconURLLarge() const { return m_sIconURLLarge; }
  1390. void SetIconURLSmall( const char *szURL ) { m_sIconURLSmall = szURL; }
  1391. void SetIconURLLarge( const char *szURL ) { m_sIconURLLarge = szURL; }
  1392. virtual const char *GetBasePlayerDisplayModel() const { return m_pszBaseDisplayModel; }
  1393. virtual const char *GetWorldDisplayModel() const { return m_pszWorldDisplayModel; }
  1394. virtual const char *GetWorldDroppedModel() const { return m_pszWorldDroppedModel; }
  1395. // Some weapons need a custom model for icon generation. If this value is not present, the world model is used.
  1396. virtual const char *GetIconDisplayModel() const;
  1397. // Use a custom model for the buy menu, typically to pose the model in a particular way that's different from the world, view or icon models
  1398. virtual const char *GetBuyMenuDisplayModel() const;
  1399. // Some weapons need a custom model for pedestal display. If this value is not present, the base model is used.
  1400. virtual const char *GetPedestalDisplayModel() const;
  1401. // weapons drop physical mags in the world. Most should have custom mags, but specifying the model means some can be generic
  1402. virtual const char *GetMagazineModel() const;
  1403. // mask shape for scope blur effect
  1404. virtual const char *GetScopeLensMaskModel() const;
  1405. // Weapons may feature nametags in the form of UID nameplates. This may be aesthetically different per weapon
  1406. virtual const char *GetUidModel() const;
  1407. // StatTrak weapons show their stats by merging a 'stattrak module' onto their viewmodel. This may be aesthetically different per weapon
  1408. virtual const char *GetStatTrakModelByType( uint32 nType ) const;
  1409. virtual const int GetNumSupportedStickerSlots() const;
  1410. virtual const char *GetStickerSlotModelBySlotIndex( uint32 nIndex ) const;
  1411. virtual const Vector &GetStickerSlotWorldProjectionStartBySlotIndex( uint32 nIndex ) const;
  1412. virtual const Vector &GetStickerSlotWorldProjectionEndBySlotIndex( uint32 nIndex ) const;
  1413. virtual const char *GetStickerWorldModelBoneParentNameBySlotIndex( uint32 nIndex ) const;
  1414. virtual const char *GetStickerSlotMaterialBySlotIndex( uint32 nIndex ) const;
  1415. virtual const char *GetIconDefaultImage() const { return m_pszIconDefaultImage; }
  1416. virtual const char *GetExtraWearableModel( void ) const { return m_pszWorldExtraWearableModel; }
  1417. virtual const char *GetParticleFile( void ) const { return m_pszParticleFile; }
  1418. virtual const char *GetParticleSnapshotFile( void ) const { return m_pszParticleSnapshotFile; }
  1419. const CUtlVector< WeaponPaintableMaterial_t >* GetPaintData( void ) const { return &m_PaintData; }
  1420. const InventoryImageData_t* GetInventoryImageData( void ) const { return m_pInventoryImageData; }
  1421. virtual const char *GetItemDesc( void ) const { return m_pszItemDesc; }
  1422. const char *GetArmoryDescString( void ) const { return m_pszArmoryDesc; }
  1423. RTime32 GetExpirationDate( void ) const { return m_rtExpiration; }
  1424. RTime32 GetDefCreationDate( void ) const { return m_rtDefCreation; }
  1425. bool ShouldShowInArmory( void ) const { return m_bShouldShowInArmory; }
  1426. bool IsActingAsAWearable( void ) const { return m_bActAsWearable; }
  1427. bool GetHideBodyGroupsDeployedOnly( void ) const { return m_bHideBodyGroupsDeployedOnly; }
  1428. virtual bool IsPackBundle( void ) const { return m_bIsPackBundle; }
  1429. virtual bool IsPackItem( void ) const { return NULL != m_pOwningPackBundle; }
  1430. CEconItemDefinition *GetOwningPackBundle() { return m_pOwningPackBundle; }
  1431. const CEconItemDefinition *GetOwningPackBundle() const { return m_pOwningPackBundle; }
  1432. #if ECONITEM_DATABASE_AUDIT_TABLES_FEATURE
  1433. const char *GetDatabaseAuditTableName( void ) const { return m_pszDatabaseAuditTable; }
  1434. #endif
  1435. const char* GetAlternateIcon( int iAlternateIcon ) const;
  1436. equip_region_mask_t GetEquipRegionMask( void ) const { return m_unEquipRegionMask; }
  1437. equip_region_mask_t GetEquipRegionConflictMask( void ) const { return m_unEquipRegionConflictMask; }
  1438. // Dynamic modification during gameplay
  1439. void SetAllowedInMatch( bool bAllowed ) { m_bAllowedInThisMatch = bAllowed; }
  1440. void SetHasBeenLoaded( bool bLoaded ) { m_bHasBeenLoaded = bLoaded; }
  1441. // Functions to deal with the case where an item definition is actually a proxy for
  1442. // a random selection
  1443. bool BRandomProxy( void ) const { return NULL != m_pProxyCriteria; }
  1444. CItemSelectionCriteria *PProxyCriteria( void ) const { return m_pProxyCriteria; }
  1445. // Generate and return a random level according to whatever leveling curve this definition uses.
  1446. uint32 RollItemLevel( void ) const;
  1447. const char *GetFirstSaleDate( void ) const;
  1448. virtual bool IsRecent( void ) const { return false;}
  1449. void IterateAttributes( class IEconItemAttributeIterator *pIterator ) const;
  1450. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  1451. // Visuals
  1452. // Attached models
  1453. int GetNumAttachedModels() const;
  1454. attachedmodel_t *GetAttachedModelData( int iIdx ) const;
  1455. // Attached particle systems
  1456. int GetNumAttachedParticles() const;
  1457. attachedparticlesystem_t *GetAttachedParticleData( int iIdx ) const;
  1458. bool IsAttachedParticleDataValidForStyle( int iIdx, int nStyle ) const;
  1459. // Animations
  1460. int GetNumAnimations() const;
  1461. animation_on_wearable_t *GetAnimationData( int iIdx ) const;
  1462. // Animation Modifiers
  1463. int GetNumAnimationModifiers() const;
  1464. const char* GetAnimationModifier( int iIdx ) const;
  1465. // Animation Overrides
  1466. Activity GetActivityOverride( Activity baseAct ) const;
  1467. const char *GetReplacementForActivityOverride( Activity baseAct ) const;
  1468. // Sounds
  1469. int GetNumSounds() const;
  1470. sound_on_wearable_t *GetSoundData( int iIdx ) const;
  1471. // Sound Overrides
  1472. const char *GetReplacementSound( const char* pszSoundName ) const;
  1473. // Particles
  1474. int GetNumParticles() const;
  1475. particle_on_wearable_t *GetParticleData( int iIdx ) const;
  1476. // Particle Overrides
  1477. const char *GetReplacementParticleEffect( const char* pszParticleName ) const;
  1478. // Particle Snapshots
  1479. int GetNumParticleSnapshots() const;
  1480. particlesnapshot_on_wearable_t *GetParticleSnapshotData( int iIdx ) const;
  1481. // Particle Snapshot Overrides
  1482. const char *GetReplacementParticleSnapshot( const char* pszParticleSnapshotName ) const;
  1483. // Particle ControlPoints
  1484. int GetNumParticleControlPoints() const;
  1485. particle_control_point_on_wearable_t *GetParticleControlPointData( int iIdx ) const;
  1486. // Particle Control Point Overrides
  1487. bool GetReplacementControlPoint( int nIndex, const char* pszParticleName, int &nOutputCP, Vector &nCPValue ) const;
  1488. virtual bool IsContentStreamable() const;
  1489. // Announcer Overrides
  1490. const char *GetAnnouncerName() const;
  1491. const char *GetAnnouncerResource() const;
  1492. // Entity Model Overrides
  1493. const char *GetEntityOverrideModel() const;
  1494. const char *GetViewOverrideModel() const;
  1495. const char *GetEntityOverrideClass() const;
  1496. // Hero Change Model Overrides
  1497. const char *GetHeroModelChangeModel() const;
  1498. // UI Icons Overrides
  1499. const char *GetUIOverrideIcon() const;
  1500. const char *GetUIOverrideOriginalIcon() const;
  1501. const char *GetUIOverrideAbilityIcon( const char *pszAbilityName ) const;
  1502. // Entity Scale Overrides
  1503. const char *GetScaleOverrideClass() const;
  1504. float GetScaleOverrideSize() const;
  1505. // Model Combiner
  1506. bool SkipModelCombine( void ) const;
  1507. // FX Overrides
  1508. const char *GetMuzzleFlash() const;
  1509. const char *GetTracerEffect() const;
  1510. const char *GetParticleEffect() const;
  1511. const char *GetParticleSnapshot() const;
  1512. // Materials
  1513. const char *GetMaterialOverride() const;
  1514. // Sounds
  1515. const char *GetCustomSound( int iSound ) const;
  1516. const char *GetWeaponReplacementSound( /*WeaponSound_t*/ int iSound ) const;
  1517. const char *GetPrimaryAmmo( void ) const;
  1518. const char *GetWeaponTypeString( void ) const;
  1519. const char *GetAddonLocation( void ) const;
  1520. const char *GetEjectBrassEffect( void ) const;
  1521. const char *GetMuzzleFlashEffect1stPerson( void ) const;
  1522. const char *GetMuzzleFlashEffect1stPersonAlt( void ) const;
  1523. const char *GetMuzzleFlashEffect3rdPerson( void ) const;
  1524. const char *GetMuzzleFlashEffect3rdPersonAlt( void ) const;
  1525. const char *GetHeatEffect( void ) const;
  1526. const char *GetPlayerAnimationExtension( void ) const;
  1527. // Bodygroups
  1528. int GetHiddenParentBodygroup() const;
  1529. int GetNumModifiedBodyGroups() const;
  1530. const char* GetModifiedBodyGroup( int i, int& body ) const;
  1531. bool UsesPerClassBodygroups() const;
  1532. int GetNumCodeControlledBodyGroups() const;
  1533. const char* GetCodeControlledBodyGroup( int i, struct codecontrolledbodygroupdata_t &ccbgd ) const;
  1534. int GetViewmodelBodygroupOverride() const;
  1535. int GetViewmodelBodygroupStateOverride() const;
  1536. int GetWorldmodelBodygroupOverride() const;
  1537. int GetWorldmodelBodygroupStateOverride() const;
  1538. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  1539. style_index_t GetNumStyles() const;
  1540. const CEconStyleInfo *GetStyleInfo( style_index_t unStyle ) const;
  1541. int GetPopularitySeed() const { return m_nPopularitySeed; }
  1542. bool HasEconTag( econ_tag_handle_t tag ) const { return m_vecTags.IsValidIndex( m_vecTags.Find( tag ) ); }
  1543. bool ShoulDisableStyleSelector( void ) const { return m_bDisableStyleSelection; }
  1544. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  1545. int GetStyleSkin( style_index_t unStyle ) const;
  1546. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  1547. virtual bool IsPublicItem( void ) const { return m_bPublicItem; }
  1548. virtual bool IgnoreInCollectionView( void ) const { return m_bIgnoreInCollectionView; }
  1549. const char* GetLootListName( void ) const { return m_pszLootListName; }
  1550. EItemType GetItemType() const { return m_eItemType; }
  1551. bool GetAllowPurchaseStandalone() const { return m_bAllowPurchaseStandalone; }
  1552. private:
  1553. // Pointer to the raw KeyValue definition of the item
  1554. KeyValues * m_pKVItem;
  1555. // Required values from m_pKVItem:
  1556. // The number used to refer to this definition in the DB
  1557. item_definition_index_t m_nDefIndex;
  1558. // List of associated items, such as multiple different keys for the same crate.
  1559. CUtlVector< item_definition_index_t > m_nAssociatedItemsDefIndexes;
  1560. // False if this definition has been turned off and we're not using it to generate items
  1561. bool m_bEnabled;
  1562. // The prefab used by the item.
  1563. const char* m_szPrefab;
  1564. // These values specify the range of item levels that an item based off this definition can be generated within.
  1565. uint8 m_unMinItemLevel;
  1566. uint8 m_unMaxItemLevel;
  1567. // This specifies an item's rarity.
  1568. uint8 m_nItemRarity;
  1569. // This specifies an item quality that items from this definition must be set to. Used mostly to specify unique item definitions.
  1570. uint8 m_nItemQuality;
  1571. uint8 m_nForcedItemQuality;
  1572. uint8 m_nDefaultDropItemQuality;
  1573. // Default drop quantity
  1574. uint8 m_nDefaultDropQuantity;
  1575. // Static attributes (ones that are always on these items)
  1576. CUtlVector<static_attrib_t> m_vecStaticAttributes;
  1577. // Seeds the popular item list with this number of the item when the list is reset.
  1578. uint8 m_nPopularitySeed;
  1579. // Portraits KV
  1580. KeyValues* m_pPortraitsKV;
  1581. // ---------------------------------------------
  1582. // Display related data
  1583. // ---------------------------------------------
  1584. // The base name of this item. i.e. "The Kritz-Krieg".
  1585. const char *m_pszItemBaseName;
  1586. bool m_bProperName; // If set, the name will have "The" prepended to it, unless it's got a non-unique quality
  1587. // in which case it'll have "A" prepended to the quality. i.e. A Community Kritzkrieg
  1588. // The base type of this item. i.e. "Rocket Launcher" or "Shotgun".
  1589. // This is often the same as the base name, but not always.
  1590. const char *m_pszItemTypeName;
  1591. // A unique identifier for m_pszItemTypeName
  1592. uint32 m_unItemTypeID;
  1593. // The item's non-attribute description.
  1594. const char *m_pszItemDesc;
  1595. // expiration time
  1596. RTime32 m_rtExpiration;
  1597. // item def creation time
  1598. RTime32 m_rtDefCreation;
  1599. // The .mdl file used for this item when it's displayed in inventory-style boxes.
  1600. const char *m_pszInventoryModel;
  1601. // Alternatively, the image used for this item when it's displayed in inventory-style boxes. If specified, it's used over the model.
  1602. const char *m_pszInventoryImage;
  1603. // An optional image that's overlayed over the top of the base inventory image. It'll be RGB colored by the tint color of the item.
  1604. CUtlVector<const char*> m_pszInventoryOverlayImages;
  1605. int m_iInventoryImagePosition[2];
  1606. int m_iInventoryImageSize[2];
  1607. const char *m_pszBaseDisplayModel;
  1608. bool m_bLoadOnDemand;
  1609. bool m_bHasBeenLoaded;
  1610. bool m_bHideBodyGroupsDeployedOnly;
  1611. // The .mdl file used for the world view.
  1612. // This is inferior to using a c_model, but because the geometry of the sticky bomb launcher's
  1613. // world model is significantly different from the view model the demoman pack requires
  1614. // using two separate models for now.
  1615. const char *m_pszWorldDisplayModel;
  1616. const char *m_pszWorldExtraWearableModel; // Some weapons attach an extra wearable item to the player
  1617. const char *m_pszWorldDroppedModel;
  1618. char m_szWorldDroppedModel[80];
  1619. // Sticker model paths
  1620. CUtlVector<StickerData_t> m_vStickerModels;
  1621. // This is the name of the default image used for the inventory until the generated image is ready
  1622. const char *m_pszIconDefaultImage;
  1623. // If set, we use the base hands model for a viewmodel, and bonemerge the above player model
  1624. bool m_bAttachToHands;
  1625. bool m_bAttachToHandsVMOnly;
  1626. // If set, we will force the view model to render flipped. Good for models built left handed.
  1627. bool m_bFlipViewModel;
  1628. // This is a wearable that sits in a non-wearable loadout slot
  1629. bool m_bActAsWearable;
  1630. // The possible sets this item is a member of
  1631. mutable CUtlVector< int > m_iItemSets;
  1632. // Asset Modifiers & Info
  1633. AssetInfo *m_pAssetInfo;
  1634. // Another way to group econ items with similar properties, separate from item_class.
  1635. // (items of the same class may need to have different types).
  1636. EItemType m_eItemType;
  1637. bool m_bAllowPurchaseStandalone;
  1638. // Optional override for specifying a custom shell ejection model
  1639. const char *m_pszBrassModelOverride;
  1640. IEconTool *m_pTool;
  1641. bundleinfo_t *m_BundleInfo;
  1642. item_capabilities_t m_iCapabilities;
  1643. uint32 m_unNumConcreteItems; // This is the number of items that will actually end up in a user's inventory - this can be 0 for some items (e.g. map stamps in TF), 1 for a "regular" item, or many for bundles, etc.
  1644. int m_nSoundMaterialID;
  1645. bool m_bDisableStyleSelection;
  1646. CUtlString m_sIconURLSmall;
  1647. CUtlString m_sIconURLLarge;
  1648. //particle file
  1649. const char *m_pszParticleFile; // Some items have custom particle files attached to them
  1650. const char *m_pszParticleSnapshotFile; // Some weapons override a generic effect with a custom snapshot
  1651. const char *m_pszLootListName; // Optionally specified loot list for a crate item (instead of a supply crate series).
  1652. CUtlVector<int> m_nCharacterPaintKitIndices;
  1653. protected:
  1654. CUtlVector< WeaponPaintableMaterial_t > m_PaintData;
  1655. InventoryImageData_t *m_pInventoryImageData;
  1656. private:
  1657. // ---------------------------------------------
  1658. // Creation related data
  1659. // ---------------------------------------------
  1660. // The entity classname for this item.
  1661. const char *m_pszItemClassname;
  1662. // The entity name that will be displayed in log files.
  1663. const char *m_pszItemLogClassname;
  1664. // The name of the icon used in the death notices.
  1665. const char *m_pszItemIconClassname;
  1666. // This is the script file name of this definition. Used to generate items by script name.
  1667. const char *m_pszDefinitionName;
  1668. #if ECONITEM_DATABASE_AUDIT_TABLES_FEATURE
  1669. // This is used for auditing purposes
  1670. const char *m_pszDatabaseAuditTable;
  1671. #endif
  1672. bool m_bHidden;
  1673. bool m_bShouldShowInArmory;
  1674. bool m_bBaseItem;
  1675. bool m_bDefaultSlotItem;
  1676. bool m_bImported;
  1677. bool m_bOnePerAccountCDKEY;
  1678. // A pack bundle is a bundle that contains items that are not for sale individually
  1679. bool m_bIsPackBundle;
  1680. // A pack item is an item which is not for sale individually and is only for sale as part of a pack bundle. A 'regular' bundle can only include a pack bundle by explicitly including all of the pack bundle's items individually.
  1681. // If this pointer is non-NULL, this item is considered to be a pack item (see CEconItemDefinition::IsPackItem()).
  1682. CEconItemDefinition *m_pOwningPackBundle;
  1683. // Contains information on how to describe items with this attribute in the Armory
  1684. const char *m_pszArmoryDesc;
  1685. // ---------------------------------------------
  1686. // Remapping data for armory/store
  1687. // ---------------------------------------------
  1688. int m_iArmoryRemap;
  1689. int m_iStoreRemap;
  1690. const char *m_pszArmoryRemap;
  1691. const char *m_pszStoreRemap;
  1692. // ---------------------------------------------
  1693. // Crafting related data
  1694. // ---------------------------------------------
  1695. const char *m_pszClassToken;
  1696. const char *m_pszSlotToken;
  1697. // ---------------------------------------------
  1698. // Gameplay related data
  1699. // ---------------------------------------------
  1700. // How to behave when the player wearing the item dies.
  1701. int m_iDropType;
  1702. // Holiday restriction. Item only has an appearance when the holiday is in effect.
  1703. const char *m_pszHolidayRestriction;
  1704. // Temporary. Revisit this in the engineer update. Enables an additional buildable.
  1705. int m_iSubType;
  1706. // Whitelist support for tournament mode
  1707. bool m_bAllowedInThisMatch;
  1708. // this will hold a pointer to the criteria that should be used to generate the real item
  1709. CItemSelectionCriteria *m_pProxyCriteria;
  1710. equip_region_mask_t m_unEquipRegionMask; // which equip regions does this item cover directly
  1711. equip_region_mask_t m_unEquipRegionConflictMask; // which equip regions does equipping this item prevent from having something in them
  1712. // Alternate icons.
  1713. CUtlMap<uint32, const char*>* m_pMapAlternateIcons;
  1714. CUtlVector<econ_tag_handle_t> m_vecTags;
  1715. CUtlVector<const CEconItemDefinition *> m_vecContainingBundleItemDefs; // Item definition indices for any bundles which contain this item
  1716. WorkshopContributorList_t m_vecSteamWorkshopContributors;
  1717. friend class CEconItemSchema;
  1718. bool m_bPublicItem;
  1719. bool m_bIgnoreInCollectionView;
  1720. };
  1721. //-----------------------------------------------------------------------------
  1722. // Purpose:
  1723. //-----------------------------------------------------------------------------
  1724. inline style_index_t CEconItemDefinition::GetNumStyles() const
  1725. {
  1726. const AssetInfo *pAssetInfo = GetAssetInfo();
  1727. if ( !pAssetInfo )
  1728. return 0;
  1729. // Bad things will happen if we ever get more styles than will fit in our
  1730. // style index type. Not Very Bad things, but bad things. Mostly we'll fail
  1731. // to iterate over all our styles.
  1732. return pAssetInfo->m_Styles.Count();
  1733. }
  1734. //-----------------------------------------------------------------------------
  1735. // Purpose:
  1736. //-----------------------------------------------------------------------------
  1737. inline const CEconStyleInfo *CEconItemDefinition::GetStyleInfo( style_index_t unStyle ) const
  1738. {
  1739. const AssetInfo *pAssetInfo = GetAssetInfo();
  1740. if ( !pAssetInfo || !pAssetInfo->m_Styles.IsValidIndex( unStyle ) )
  1741. return NULL;
  1742. return pAssetInfo->m_Styles[unStyle];
  1743. }
  1744. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  1745. //-----------------------------------------------------------------------------
  1746. // Purpose:
  1747. //-----------------------------------------------------------------------------
  1748. inline int CEconItemDefinition::GetNumAttachedModels() const
  1749. {
  1750. if ( !GetAssetInfo() )
  1751. return 0;
  1752. return GetAssetInfo()->m_AttachedModels.Count();
  1753. }
  1754. inline attachedmodel_t *CEconItemDefinition::GetAttachedModelData( int iIdx ) const
  1755. {
  1756. if ( !GetAssetInfo() )
  1757. return NULL;
  1758. Assert( iIdx < GetAssetInfo()->m_AttachedModels.Count() );
  1759. if ( iIdx >= GetAssetInfo()->m_AttachedModels.Count() )
  1760. return NULL;
  1761. return &GetAssetInfo()->m_AttachedModels[iIdx];
  1762. }
  1763. //-----------------------------------------------------------------------------
  1764. // Purpose:
  1765. //-----------------------------------------------------------------------------
  1766. inline int CEconItemDefinition::GetNumAnimations() const
  1767. {
  1768. if ( !GetAssetInfo() )
  1769. return 0;
  1770. return GetAssetInfo()->m_Animations.Count();
  1771. }
  1772. inline animation_on_wearable_t *CEconItemDefinition::GetAnimationData( int iIdx ) const
  1773. {
  1774. if ( !GetAssetInfo() )
  1775. return NULL;
  1776. Assert( iIdx < GetAssetInfo()->m_Animations.Count() );
  1777. if ( iIdx < 0 || iIdx >= GetAssetInfo()->m_Animations.Count() )
  1778. return NULL;
  1779. return &GetAssetInfo()->m_Animations[iIdx];
  1780. }
  1781. //-----------------------------------------------------------------------------
  1782. // Purpose:
  1783. //-----------------------------------------------------------------------------
  1784. inline int CEconItemDefinition::GetNumAnimationModifiers() const
  1785. {
  1786. if ( !GetAssetInfo() )
  1787. return 0;
  1788. return GetAssetInfo()->m_vecAnimationModifiers.Count();
  1789. }
  1790. inline const char* CEconItemDefinition::GetAnimationModifier( int iIdx ) const
  1791. {
  1792. if ( !GetAssetInfo() )
  1793. return NULL;
  1794. if ( iIdx < 0 || iIdx >= GetAssetInfo()->m_vecAnimationModifiers.Count() )
  1795. return NULL;
  1796. return GetAssetInfo()->m_vecAnimationModifiers[iIdx];
  1797. }
  1798. //-----------------------------------------------------------------------------
  1799. // Purpose:
  1800. //-----------------------------------------------------------------------------
  1801. inline const char *CEconItemDefinition::GetAnnouncerName() const
  1802. {
  1803. if ( !GetAssetInfo() )
  1804. return NULL;
  1805. return GetAssetInfo()->m_pszAnnouncerName;
  1806. }
  1807. //-----------------------------------------------------------------------------
  1808. // Purpose:
  1809. //-----------------------------------------------------------------------------
  1810. inline const char *CEconItemDefinition::GetAnnouncerResource() const
  1811. {
  1812. if ( !GetAssetInfo() )
  1813. return NULL;
  1814. return GetAssetInfo()->m_pszAnnouncerResource;
  1815. }
  1816. //-----------------------------------------------------------------------------
  1817. // Purpose:
  1818. //-----------------------------------------------------------------------------
  1819. inline const char *CEconItemDefinition::GetUIOverrideIcon() const
  1820. {
  1821. if ( !GetAssetInfo() )
  1822. return NULL;
  1823. return GetAssetInfo()->m_pszNewIcon;
  1824. }
  1825. //-----------------------------------------------------------------------------
  1826. // Purpose:
  1827. //-----------------------------------------------------------------------------
  1828. inline const char *CEconItemDefinition::GetUIOverrideOriginalIcon() const
  1829. {
  1830. if ( !GetAssetInfo() )
  1831. return NULL;
  1832. return GetAssetInfo()->m_pszOriginalIcon;
  1833. }
  1834. //-----------------------------------------------------------------------------
  1835. // Purpose:
  1836. //-----------------------------------------------------------------------------
  1837. inline const char *CEconItemDefinition::GetUIOverrideAbilityIcon( const char *pszAbilityName ) const
  1838. {
  1839. if ( !pszAbilityName )
  1840. return NULL;
  1841. if ( !GetAssetInfo() )
  1842. return NULL;
  1843. FOR_EACH_VEC( GetAssetInfo()->m_vecAbilityIconReplacements, i )
  1844. {
  1845. ability_icon_replacement_t *pszAbilityReplacement = &GetAssetInfo()->m_vecAbilityIconReplacements.Element(i);
  1846. if ( pszAbilityReplacement )
  1847. {
  1848. if ( !Q_strcmp( pszAbilityName, pszAbilityReplacement->m_strAbilityName ) )
  1849. {
  1850. return pszAbilityReplacement->m_strReplacement;
  1851. }
  1852. }
  1853. }
  1854. return NULL;
  1855. }
  1856. //-----------------------------------------------------------------------------
  1857. // Purpose:
  1858. //-----------------------------------------------------------------------------
  1859. inline const char *CEconItemDefinition::GetEntityOverrideModel() const
  1860. {
  1861. if ( !GetAssetInfo() )
  1862. return NULL;
  1863. CUtlVector<AssetModifier*>* pAssetModifierList = GetAssetInfo()->GetAssetModifiers( AM_EntityModel );
  1864. if ( pAssetModifierList && pAssetModifierList->Count() > 0 )
  1865. return pAssetModifierList->Element(0)->m_strModifier.String();
  1866. return NULL;
  1867. }
  1868. inline const char *CEconItemDefinition::GetViewOverrideModel() const
  1869. {
  1870. if ( !GetAssetInfo() )
  1871. return NULL;
  1872. CUtlVector<AssetModifier*>* pAssetModifierList = GetAssetInfo()->GetAssetModifiers( AM_ViewModel );
  1873. if ( pAssetModifierList && pAssetModifierList->Count() > 0 )
  1874. return pAssetModifierList->Element(0)->m_strModifier.String();
  1875. return NULL;
  1876. }
  1877. //-----------------------------------------------------------------------------
  1878. // Purpose:
  1879. //-----------------------------------------------------------------------------
  1880. inline const char *CEconItemDefinition::GetEntityOverrideClass() const
  1881. {
  1882. if ( !GetAssetInfo() )
  1883. return NULL;
  1884. CUtlVector<AssetModifier*>* pAssetModifierList = GetAssetInfo()->GetAssetModifiers( AM_EntityModel );
  1885. if ( pAssetModifierList && pAssetModifierList->Count() > 0 )
  1886. return pAssetModifierList->Element(0)->m_strAsset.String();
  1887. return NULL;
  1888. }
  1889. //-----------------------------------------------------------------------------
  1890. // Purpose:
  1891. //-----------------------------------------------------------------------------
  1892. inline const char *CEconItemDefinition::GetScaleOverrideClass() const
  1893. {
  1894. if ( !GetAssetInfo() )
  1895. return NULL;
  1896. return GetAssetInfo()->m_pszScaleClass;
  1897. }
  1898. //-----------------------------------------------------------------------------
  1899. // Purpose: accessor for hero_model_change asset modifier
  1900. //-----------------------------------------------------------------------------
  1901. inline const char *CEconItemDefinition::GetHeroModelChangeModel() const
  1902. {
  1903. if ( !GetAssetInfo() )
  1904. return NULL;
  1905. CUtlVector<AssetModifier*>* pAssetModifierList = GetAssetInfo()->GetAssetModifiers( AM_HeroModelChange );
  1906. if ( pAssetModifierList && pAssetModifierList->Count() > 0 )
  1907. return pAssetModifierList->Element(0)->m_strModifier.String();
  1908. return NULL;
  1909. }
  1910. //-----------------------------------------------------------------------------
  1911. // Purpose:
  1912. //-----------------------------------------------------------------------------
  1913. inline float CEconItemDefinition::GetScaleOverrideSize() const
  1914. {
  1915. if ( !GetAssetInfo() )
  1916. return 0.0f;
  1917. return GetAssetInfo()->m_flScaleSize;
  1918. }
  1919. //-----------------------------------------------------------------------------
  1920. // Purpose:
  1921. //-----------------------------------------------------------------------------
  1922. inline bool CEconItemDefinition::SkipModelCombine( void ) const
  1923. {
  1924. if ( !GetAssetInfo() )
  1925. return false;
  1926. return GetAssetInfo()->m_bSkipModelCombine;
  1927. }
  1928. //-----------------------------------------------------------------------------
  1929. // Purpose:
  1930. //-----------------------------------------------------------------------------
  1931. inline int CEconItemDefinition::GetNumSounds() const
  1932. {
  1933. if ( !GetAssetInfo() )
  1934. return 0;
  1935. return GetAssetInfo()->m_Sounds.Count();
  1936. }
  1937. inline sound_on_wearable_t *CEconItemDefinition::GetSoundData( int iIdx ) const
  1938. {
  1939. if ( !GetAssetInfo() )
  1940. return NULL;
  1941. Assert( iIdx < GetAssetInfo()->m_Sounds.Count() );
  1942. if ( iIdx >= GetAssetInfo()->m_Sounds.Count() )
  1943. return NULL;
  1944. return &GetAssetInfo()->m_Sounds[iIdx];
  1945. }
  1946. //-----------------------------------------------------------------------------
  1947. // Purpose:
  1948. //-----------------------------------------------------------------------------
  1949. inline int CEconItemDefinition::GetNumParticles() const
  1950. {
  1951. if ( !GetAssetInfo() )
  1952. return 0;
  1953. return GetAssetInfo()->m_Particles.Count();
  1954. }
  1955. inline particle_on_wearable_t *CEconItemDefinition::GetParticleData( int iIdx ) const
  1956. {
  1957. if ( !GetAssetInfo() )
  1958. return NULL;
  1959. Assert( iIdx < GetAssetInfo()->m_Particles.Count() );
  1960. if ( iIdx >= GetAssetInfo()->m_Particles.Count() )
  1961. return NULL;
  1962. return &GetAssetInfo()->m_Particles[iIdx];
  1963. }
  1964. //-----------------------------------------------------------------------------
  1965. // Purpose:
  1966. //-----------------------------------------------------------------------------
  1967. inline int CEconItemDefinition::GetNumParticleSnapshots() const
  1968. {
  1969. if ( !GetAssetInfo() )
  1970. return 0;
  1971. return GetAssetInfo()->m_ParticleSnapshots.Count();
  1972. }
  1973. inline particlesnapshot_on_wearable_t *CEconItemDefinition::GetParticleSnapshotData( int iIdx ) const
  1974. {
  1975. if ( !GetAssetInfo() )
  1976. return NULL;
  1977. Assert( iIdx < GetAssetInfo()->m_ParticleSnapshots.Count() );
  1978. if ( iIdx >= GetAssetInfo()->m_ParticleSnapshots.Count() )
  1979. return NULL;
  1980. return &GetAssetInfo()->m_ParticleSnapshots[iIdx];
  1981. }
  1982. //-----------------------------------------------------------------------------
  1983. // Purpose:
  1984. //-----------------------------------------------------------------------------
  1985. inline int CEconItemDefinition::GetNumParticleControlPoints() const
  1986. {
  1987. if ( !GetAssetInfo() )
  1988. return 0;
  1989. return GetAssetInfo()->m_ParticleControlPoints.Count();
  1990. }
  1991. inline particle_control_point_on_wearable_t *CEconItemDefinition::GetParticleControlPointData( int iIdx ) const
  1992. {
  1993. if ( !GetAssetInfo() )
  1994. return NULL;
  1995. Assert( iIdx < GetAssetInfo()->m_ParticleControlPoints.Count() );
  1996. if ( iIdx >= GetAssetInfo()->m_ParticleControlPoints.Count() )
  1997. return NULL;
  1998. return &GetAssetInfo()->m_ParticleControlPoints[iIdx];
  1999. }
  2000. //-----------------------------------------------------------------------------
  2001. // Purpose:
  2002. //-----------------------------------------------------------------------------
  2003. inline int CEconItemDefinition::GetNumAttachedParticles() const
  2004. {
  2005. if ( !GetAssetInfo() )
  2006. return 0;
  2007. return GetAssetInfo()->m_AttachedParticles.Count();
  2008. }
  2009. //-----------------------------------------------------------------------------
  2010. // Purpose:
  2011. //-----------------------------------------------------------------------------
  2012. inline const char *CEconItemDefinition::GetMaterialOverride() const
  2013. {
  2014. if ( !GetAssetInfo() )
  2015. return NULL;
  2016. return GetAssetInfo()->m_pszMaterialOverride;
  2017. }
  2018. //-----------------------------------------------------------------------------
  2019. // Purpose:
  2020. //-----------------------------------------------------------------------------
  2021. inline const char *CEconItemDefinition::GetMuzzleFlash() const
  2022. {
  2023. if ( !GetAssetInfo() )
  2024. return NULL;
  2025. return GetAssetInfo()->m_pszMuzzleFlash;
  2026. }
  2027. //-----------------------------------------------------------------------------
  2028. // Purpose:
  2029. //-----------------------------------------------------------------------------
  2030. inline const char *CEconItemDefinition::GetTracerEffect() const
  2031. {
  2032. if ( !GetAssetInfo() )
  2033. return NULL;
  2034. return GetAssetInfo()->m_pszTracerEffect;
  2035. }
  2036. //-----------------------------------------------------------------------------
  2037. // Purpose:
  2038. //-----------------------------------------------------------------------------
  2039. inline const char *CEconItemDefinition::GetParticleEffect() const
  2040. {
  2041. if ( !GetAssetInfo() )
  2042. return NULL;
  2043. return GetAssetInfo()->m_pszParticleEffect;
  2044. }
  2045. //-----------------------------------------------------------------------------
  2046. // Purpose:
  2047. //-----------------------------------------------------------------------------
  2048. inline const char *CEconItemDefinition::GetParticleSnapshot() const
  2049. {
  2050. if ( !GetAssetInfo() )
  2051. return NULL;
  2052. return GetAssetInfo()->m_pszParticleSnapshot;
  2053. }
  2054. //-----------------------------------------------------------------------------
  2055. // Purpose:
  2056. //-----------------------------------------------------------------------------
  2057. inline int CEconItemDefinition::GetHiddenParentBodygroup() const
  2058. {
  2059. if ( !GetAssetInfo() )
  2060. return -1;
  2061. return GetAssetInfo()->iHideParentBodyGroup;
  2062. }
  2063. //-----------------------------------------------------------------------------
  2064. // Purpose:
  2065. //-----------------------------------------------------------------------------
  2066. inline int CEconItemDefinition::GetNumModifiedBodyGroups() const
  2067. {
  2068. if ( !GetAssetInfo() )
  2069. return -1;
  2070. return GetAssetInfo()->m_ModifiedBodyGroupNames.Count();
  2071. }
  2072. //-----------------------------------------------------------------------------
  2073. // Purpose:
  2074. //-----------------------------------------------------------------------------
  2075. inline const char* CEconItemDefinition::GetModifiedBodyGroup( int i, int& body ) const
  2076. {
  2077. if ( !GetAssetInfo() )
  2078. return NULL;
  2079. body = GetAssetInfo()->m_ModifiedBodyGroupNames[i];
  2080. return GetAssetInfo()->m_ModifiedBodyGroupNames.Key(i);
  2081. }
  2082. //-----------------------------------------------------------------------------
  2083. // Purpose:
  2084. //-----------------------------------------------------------------------------
  2085. inline int CEconItemDefinition::GetNumCodeControlledBodyGroups() const
  2086. {
  2087. if ( !GetAssetInfo() )
  2088. return -1;
  2089. return GetAssetInfo()->m_CodeControlledBodyGroupNames.Count();
  2090. }
  2091. //-----------------------------------------------------------------------------
  2092. // Purpose:
  2093. //-----------------------------------------------------------------------------
  2094. inline const char* CEconItemDefinition::GetCodeControlledBodyGroup( int i, codecontrolledbodygroupdata_t &ccbgd ) const
  2095. {
  2096. if ( !GetAssetInfo() )
  2097. return NULL;
  2098. ccbgd = GetAssetInfo()->m_CodeControlledBodyGroupNames[i];
  2099. return GetAssetInfo()->m_CodeControlledBodyGroupNames.Key(i);
  2100. }
  2101. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  2102. //-----------------------------------------------------------------------------
  2103. // Purpose:
  2104. //-----------------------------------------------------------------------------
  2105. inline int CEconItemDefinition::GetStyleSkin( style_index_t unStyle ) const
  2106. {
  2107. const CEconStyleInfo *pStyle = GetStyleInfo( unStyle );
  2108. // Return our skin if we have a style or our default skin of -1 otherwise.
  2109. return pStyle
  2110. ? pStyle->GetSkin()
  2111. : -1;
  2112. }
  2113. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  2114. //-----------------------------------------------------------------------------
  2115. // Purpose:
  2116. //-----------------------------------------------------------------------------
  2117. inline int CEconItemDefinition::GetViewmodelBodygroupOverride() const
  2118. {
  2119. if ( !GetAssetInfo() )
  2120. return 0;
  2121. return GetAssetInfo()->m_iViewModelBodyGroupOverride;
  2122. }
  2123. //-----------------------------------------------------------------------------
  2124. // Purpose:
  2125. //-----------------------------------------------------------------------------
  2126. inline int CEconItemDefinition::GetViewmodelBodygroupStateOverride() const
  2127. {
  2128. if ( !GetAssetInfo() )
  2129. return 0;
  2130. return GetAssetInfo()->m_iViewModelBodyGroupStateOverride;
  2131. }
  2132. //-----------------------------------------------------------------------------
  2133. // Purpose:
  2134. //-----------------------------------------------------------------------------
  2135. inline int CEconItemDefinition::GetWorldmodelBodygroupOverride() const
  2136. {
  2137. if ( !GetAssetInfo() )
  2138. return 0;
  2139. return GetAssetInfo()->m_iWorldModelBodyGroupOverride;
  2140. }
  2141. //-----------------------------------------------------------------------------
  2142. // Purpose:
  2143. //-----------------------------------------------------------------------------
  2144. inline int CEconItemDefinition::GetWorldmodelBodygroupStateOverride() const
  2145. {
  2146. if ( !GetAssetInfo() )
  2147. return 0;
  2148. return GetAssetInfo()->m_iWorldModelBodyGroupStateOverride;
  2149. }
  2150. //-----------------------------------------------------------------------------
  2151. // Purpose:
  2152. //-----------------------------------------------------------------------------
  2153. inline bool CEconItemDefinition::UsesPerClassBodygroups() const
  2154. {
  2155. if ( !GetAssetInfo() )
  2156. return false;
  2157. return GetAssetInfo()->bUsePerClassBodygroups;
  2158. }
  2159. //-----------------------------------------------------------------------------
  2160. // Purpose:
  2161. //-----------------------------------------------------------------------------
  2162. inline const char *CEconItemDefinition::GetCustomSound( int iSound ) const
  2163. {
  2164. if ( !GetAssetInfo() )
  2165. return NULL;
  2166. if ( iSound < 0 || iSound >= MAX_VISUALS_CUSTOM_SOUNDS )
  2167. return NULL;
  2168. return GetAssetInfo()->m_pszCustomSounds[iSound];
  2169. }
  2170. //-----------------------------------------------------------------------------
  2171. // Purpose:
  2172. //-----------------------------------------------------------------------------
  2173. inline const char *CEconItemDefinition::GetWeaponReplacementSound( /* WeaponSound_t */ int iSound ) const
  2174. {
  2175. if ( !GetAssetInfo() )
  2176. return NULL;
  2177. if ( iSound < 0 || iSound >= NUM_SHOOT_SOUND_TYPES )
  2178. return NULL;
  2179. return GetAssetInfo()->m_pszWeaponSoundReplacements[iSound];
  2180. }
  2181. //-----------------------------------------------------------------------------
  2182. // Purpose:
  2183. //-----------------------------------------------------------------------------
  2184. inline const char *CEconItemDefinition::GetPrimaryAmmo( void ) const
  2185. {
  2186. if ( !GetAssetInfo() )
  2187. return NULL;
  2188. return GetAssetInfo()->m_pszPrimaryAmmo;
  2189. }
  2190. //-----------------------------------------------------------------------------
  2191. // Purpose:
  2192. //-----------------------------------------------------------------------------
  2193. inline const char *CEconItemDefinition::GetWeaponTypeString( void ) const
  2194. {
  2195. if ( !GetAssetInfo() )
  2196. return NULL;
  2197. return GetAssetInfo()->m_pszWeaponTypeString;
  2198. }
  2199. //-----------------------------------------------------------------------------
  2200. // Purpose:
  2201. //-----------------------------------------------------------------------------
  2202. inline const char *CEconItemDefinition::GetAddonLocation( void ) const
  2203. {
  2204. if ( !GetAssetInfo() )
  2205. return NULL;
  2206. return GetAssetInfo()->m_pszAddonLocation;
  2207. }
  2208. //-----------------------------------------------------------------------------
  2209. // Purpose:
  2210. //-----------------------------------------------------------------------------
  2211. inline const char *CEconItemDefinition::GetEjectBrassEffect( void ) const
  2212. {
  2213. if ( !GetAssetInfo() )
  2214. return NULL;
  2215. return GetAssetInfo()->m_pszEjectBrassEffect;
  2216. }
  2217. //-----------------------------------------------------------------------------
  2218. // Purpose:
  2219. //-----------------------------------------------------------------------------
  2220. inline const char *CEconItemDefinition::GetMuzzleFlashEffect1stPerson( void ) const
  2221. {
  2222. if ( !GetAssetInfo() )
  2223. return NULL;
  2224. return GetAssetInfo()->m_pszMuzzleFlashEffect1stPerson;
  2225. }
  2226. //-----------------------------------------------------------------------------
  2227. // Purpose:
  2228. //-----------------------------------------------------------------------------
  2229. inline const char *CEconItemDefinition::GetMuzzleFlashEffect1stPersonAlt( void ) const
  2230. {
  2231. if ( !GetAssetInfo() )
  2232. return NULL;
  2233. return GetAssetInfo()->m_pszMuzzleFlashEffect1stPersonAlt;
  2234. }
  2235. //-----------------------------------------------------------------------------
  2236. // Purpose:
  2237. //-----------------------------------------------------------------------------
  2238. inline const char *CEconItemDefinition::GetMuzzleFlashEffect3rdPerson( void ) const
  2239. {
  2240. if ( !GetAssetInfo() )
  2241. return NULL;
  2242. return GetAssetInfo()->m_pszMuzzleFlashEffect3rdPerson;
  2243. }
  2244. //-----------------------------------------------------------------------------
  2245. // Purpose:
  2246. //-----------------------------------------------------------------------------
  2247. inline const char *CEconItemDefinition::GetMuzzleFlashEffect3rdPersonAlt( void ) const
  2248. {
  2249. if ( !GetAssetInfo() )
  2250. return NULL;
  2251. return GetAssetInfo()->m_pszMuzzleFlashEffect3rdPersonAlt;
  2252. }
  2253. //-----------------------------------------------------------------------------
  2254. // Purpose:
  2255. //-----------------------------------------------------------------------------
  2256. inline const char *CEconItemDefinition::GetHeatEffect( void ) const
  2257. {
  2258. if ( !GetAssetInfo() )
  2259. return NULL;
  2260. return GetAssetInfo()->m_pszHeatEffect;
  2261. }
  2262. //-----------------------------------------------------------------------------
  2263. // Purpose:
  2264. //-----------------------------------------------------------------------------
  2265. inline const char *CEconItemDefinition::GetPlayerAnimationExtension( void ) const
  2266. {
  2267. if ( !GetAssetInfo() )
  2268. return NULL;
  2269. return GetAssetInfo()->m_pszPlayerAnimationExtension;
  2270. }
  2271. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  2272. //-----------------------------------------------------------------------------
  2273. // CTimedItemRewardDefinition
  2274. // Describes a periodic item reward
  2275. //-----------------------------------------------------------------------------
  2276. class CTimedItemRewardDefinition
  2277. {
  2278. public:
  2279. CTimedItemRewardDefinition( void );
  2280. CTimedItemRewardDefinition( const CTimedItemRewardDefinition &that );
  2281. CTimedItemRewardDefinition &operator=( const CTimedItemRewardDefinition& rhs );
  2282. ~CTimedItemRewardDefinition( void );
  2283. bool BInitFromKV( KeyValues *pKVTimedReward, CEconItemSchema &pschema, CUtlVector<CUtlString> *pVecErrors = NULL );
  2284. uint32 GetRandomFrequency( void ) const { return RandomFloat( m_unMinFreq, m_unMaxFreq ); }
  2285. uint32 GetMinFrequency( void ) const { return m_unMinFreq; }
  2286. uint32 GetMaxFrequency( void ) const { return m_unMaxFreq; }
  2287. float GetChance( void ) const;
  2288. RTime32 GetForcedBaselineAdjustmentTime( void ) const { return m_rtForcedBaselineAdjustment; }
  2289. RTime32 GetForcedLastDropAdjustmentTime( void ) const { return m_rtForcedLastDropTimeAdjustment; }
  2290. uint32 GetHoursInRewardPeriod( void ) const { return m_unHoursInRewardPeriod; }
  2291. uint32 GetHoursBetweenDropsRealtime( void ) const { return m_unHoursBetweenDropsRealtime; }
  2292. uint32 GetTotalPointsForPeriod( float flHoursOfPlaytimeInPeriod ) const
  2293. {
  2294. float flHours = flHoursOfPlaytimeInPeriod;
  2295. if ( flHours <= 0.0f )
  2296. return 0;
  2297. uint32 unPoints = 0;
  2298. uint32 numPointsToProrate = 0;
  2299. uint32 nHoursPlayed = ( uint32 ) flHours; // truncating hours
  2300. if ( !nHoursPlayed )
  2301. { // Crediting the first hour of the play period (prorating)
  2302. numPointsToProrate = ( m_arrTotalPointsBasedOnHoursPlayed.Count() ) ? m_arrTotalPointsBasedOnHoursPlayed.Head() : m_unPointsPerHourOverplayed;
  2303. }
  2304. else if ( uint32 numHoursToCreditFromTable = MIN( nHoursPlayed, ( uint32 ) m_arrTotalPointsBasedOnHoursPlayed.Count() ) )
  2305. { // We have a defined table, credit from it as much as we can
  2306. nHoursPlayed -= numHoursToCreditFromTable;
  2307. flHours -= numHoursToCreditFromTable;
  2308. unPoints += m_arrTotalPointsBasedOnHoursPlayed[ numHoursToCreditFromTable - 1 ];
  2309. numPointsToProrate = ( numHoursToCreditFromTable < ( uint32 ) m_arrTotalPointsBasedOnHoursPlayed.Count() )
  2310. ? ( m_arrTotalPointsBasedOnHoursPlayed[ numHoursToCreditFromTable ] - m_arrTotalPointsBasedOnHoursPlayed[ numHoursToCreditFromTable - 1 ] )
  2311. : m_unPointsPerHourOverplayed;
  2312. }
  2313. if ( nHoursPlayed )
  2314. { // We have hours that go beyond the table definition, or had no table
  2315. unPoints += nHoursPlayed * m_unPointsPerHourOverplayed;
  2316. numPointsToProrate = m_unPointsPerHourOverplayed;
  2317. flHours -= nHoursPlayed;
  2318. }
  2319. // At this point we have a fraction of an hour that we are prorating remaining
  2320. unPoints += flHours * numPointsToProrate;
  2321. return unPoints;
  2322. }
  2323. uint32 GetPointsPerPeriodRollover( void ) const { return m_unPointsPerPeriodRollover; }
  2324. const CItemSelectionCriteria &GetCriteria( void ) const { return m_criteria; }
  2325. int GetLootListCount( void ) const { return m_arrLootLists.Count(); }
  2326. const CEconLootListDefinition *GetLootList( int iLootListIdx = 0 ) const { return m_arrLootLists.IsValidIndex( iLootListIdx ) ? m_arrLootLists[iLootListIdx] : NULL; }
  2327. private:
  2328. // Frequency of how often the item is awarded
  2329. uint32 m_unMinFreq;
  2330. uint32 m_unMaxFreq;
  2331. RTime32 m_rtForcedBaselineAdjustment; // Forces all baselines to be adjusted at least beyond this mark, when tweaking drop rates and reward periods
  2332. RTime32 m_rtForcedLastDropTimeAdjustment; // Forces last drop time to be adjusted to at least this mark, when tweaking drop rates and reward periods
  2333. uint32 m_unHoursInRewardPeriod; // How many hours a reward period lasts before rolling over
  2334. uint32 m_unHoursBetweenDropsRealtime; // How many realtime hours before dropping next drop due from this series
  2335. CUtlVector< uint32 > m_arrTotalPointsBasedOnHoursPlayed; // Description table of total points a player can earn in reward period based on hours played
  2336. uint32 m_unPointsPerHourOverplayed; // Every hour beyond the points table will reward a player with so many points
  2337. uint32 m_unPointsPerPeriodRollover; // Points per period that will rollover
  2338. // The chance, between 0 and 1, that the item is rewarded
  2339. float m_flChance;
  2340. // The criteria to use to select the item to reward
  2341. CItemSelectionCriteria m_criteria;
  2342. // Alternatively, the loot_list to use instead
  2343. CUtlVector< const CEconLootListDefinition * > m_arrLootLists;
  2344. // dynamically allocated loot lists are in both vectors, but we keep this list to delete on destruct
  2345. // loot lists from the schema are in the above vector as well and are stored statically.
  2346. CUtlVector< const CEconLootListDefinition * > m_arrDynamicLootLists;
  2347. };
  2348. //-----------------------------------------------------------------------------
  2349. // CItemLevelingDefinition
  2350. //-----------------------------------------------------------------------------
  2351. class CItemLevelingDefinition
  2352. {
  2353. public:
  2354. CItemLevelingDefinition( void );
  2355. CItemLevelingDefinition( const CItemLevelingDefinition &that );
  2356. CItemLevelingDefinition &operator=( const CItemLevelingDefinition& rhs );
  2357. ~CItemLevelingDefinition( void );
  2358. bool BInitFromKV( KeyValues *pKVItemLevel, CEconItemSchema &pschema, const char *pszLevelBlockName, CUtlVector<CUtlString> *pVecErrors = NULL );
  2359. uint32 GetLevel( void ) const { return m_unLevel; }
  2360. uint32 GetRequiredScore( void ) const { return m_unRequiredScore; }
  2361. const char *GetNameLocalizationKey( void ) const { return m_pszLocalizedName_LocalStorage; }
  2362. private:
  2363. uint32 m_unLevel;
  2364. uint32 m_unRequiredScore;
  2365. char *m_pszLocalizedName_LocalStorage;
  2366. };
  2367. //-----------------------------------------------------------------------------
  2368. // AchievementAward_t
  2369. // Holds the item to give away and the Data value to audit it with ( for cross
  2370. // game achievements)
  2371. //-----------------------------------------------------------------------------
  2372. struct AchievementAward_t
  2373. {
  2374. AchievementAward_t( const AchievementAward_t & rhs )
  2375. : m_sNativeName( rhs.m_sNativeName ),
  2376. m_unSourceAppId( rhs.m_unSourceAppId ),
  2377. m_unAuditData( rhs.m_unAuditData )
  2378. {
  2379. m_vecDefIndex.CopyArray( rhs.m_vecDefIndex.Base(), rhs.m_vecDefIndex.Count() );
  2380. }
  2381. AchievementAward_t( ) {}
  2382. CUtlString m_sNativeName;
  2383. AppId_t m_unSourceAppId;
  2384. uint32 m_unAuditData;
  2385. CUtlVector<uint16> m_vecDefIndex;
  2386. };
  2387. enum eTimedRewardType
  2388. {
  2389. kTimedRewards_Reward,
  2390. kTimedRewards_PremiumTimedDrop,
  2391. kTimedRewards_Crate,
  2392. kTimedRewards_Operation,
  2393. kTimedRewards_Capsule,
  2394. kTimedRewards_Quest,
  2395. kTimedRewards_FreeSprayDropsOct2016,
  2396. kNumTimedRewards
  2397. };
  2398. struct kill_eater_score_type_t
  2399. {
  2400. // The value that the game/DB will know this rarity by
  2401. int32 m_nValue;
  2402. const char *m_pszTypeString;
  2403. const char *m_pszModelAttributeString;
  2404. const char *m_pszLevelBlockName;
  2405. bool m_bUseLevelBlock;
  2406. };
  2407. //-----------------------------------------------------------------------------
  2408. // CWebResource
  2409. //-----------------------------------------------------------------------------
  2410. class CWebResource
  2411. {
  2412. public:
  2413. CWebResource() : m_bOnDemand( false ), m_pKeyValues( NULL ), m_fnLoadCallback( NULL ) {}
  2414. CWebResource( const CWebResource& other )
  2415. {
  2416. m_strName = other.m_strName;
  2417. m_strURL = other.m_strURL;
  2418. m_bOnDemand = other.m_bOnDemand;
  2419. m_pKeyValues = other.m_pKeyValues->MakeCopy();
  2420. m_fnLoadCallback = other.m_fnLoadCallback;
  2421. }
  2422. ~CWebResource() { m_pKeyValues->deleteThis(); }
  2423. CUtlString m_strName;
  2424. CUtlString m_strURL;
  2425. bool m_bOnDemand;
  2426. KeyValues* m_pKeyValues;
  2427. void (*m_fnLoadCallback)( const char*, KeyValues* );
  2428. static bool s_Initialized;
  2429. };
  2430. //-----------------------------------------------------------------------------
  2431. // CForeignAppImports
  2432. // Defines the way a single foreign app's items are mapped into this app
  2433. //-----------------------------------------------------------------------------
  2434. class CForeignAppImports
  2435. {
  2436. public:
  2437. CForeignAppImports() : m_mapDefinitions( DefLessFunc( uint16 ) ) {}
  2438. void AddMapping( uint16 unForeignDefIndex, const CEconItemDefinition *pDefn );
  2439. const CEconItemDefinition *FindMapping( uint16 unForeignDefIndex ) const;
  2440. private:
  2441. CUtlMap< uint16, const CEconItemDefinition *> m_mapDefinitions;
  2442. };
  2443. //-----------------------------------------------------------------------------
  2444. // ISchemaAttributeType
  2445. //-----------------------------------------------------------------------------
  2446. // ISchemaAttributeType is the base interface for a "type" of attribute, where "type" is defined as
  2447. // "something that describes the memory layout, the DB layout, how to convert between them, etc.".
  2448. // Most of the low-level work done with attributes, including DB reading/writing, packing/unpacking
  2449. // for wire traffic, and other leaf code works exclusively through this interface.
  2450. //
  2451. // The class hierarchy looks like:
  2452. //
  2453. // ISchemaAttributeTypeBase< TAttribInMemoryType >:
  2454. //
  2455. // This describes a specific in-memory format for an attribute, without any association to
  2456. // a particular DB, wire format, etc. We can't template the base class because it's an
  2457. // interface. This implements about half of ISchemaAttributeType and has its own mini
  2458. // interface consisting of ConvertTypedValueToByteStream() and ConvertByteStreamToTypedValue(),
  2459. // both of which do work on statically-typed values that don't exist at higher levels.
  2460. //
  2461. // CSchemaAttributeTypeBase< TAttribSchType, TAttribInMemoryType >:
  2462. //
  2463. // This handles the schema-related functions on ISchemaAttributeType. These exist at a lower
  2464. // inheritance level than ISchemaAttributeTypeBase to allow code that needs to work type-safely
  2465. // on attributes in memory, but that doesn't know or need to know anything about databases,
  2466. // to exist. Examples of this include code that calls CEconItem::SetDynamicAttributeValue<T>().
  2467. //
  2468. // Individual implementations of custom attribute type start making sense immediately as
  2469. // subclasses of CSchemaAttributeTypeBase, for example CSchemaAttributeType_Default, which
  2470. // implements all of the old, untyped attribute system logic.
  2471. //
  2472. // CSchemaAttributeTypeProtobufBase< TAttribSchType, TProtobufValueType >
  2473. //
  2474. // An easy way of automating most of the work for making a new attribute type is to have
  2475. // the in-memory format be a protobuf object, allowing reflection, automatic network support,
  2476. // etc.
  2477. //
  2478. // Creating a new custom protobuf attribute consists of three steps:
  2479. //
  2480. // - create a new DB table that will hold your attribute data. This needs an itemid_t-sized item ID
  2481. // column named "ItemID", an attrib_definition_index_t-sized definition index column named "AttrDefIndex",
  2482. // and then whatever data you want to store.
  2483. //
  2484. // - create a new protobuf message type that will hold your custom attribute contents. This exists
  2485. // on the client and the GC in the same format.
  2486. //
  2487. // - implement a subclass of CSchemaAttributeTypeProtobufBase<>, for example:
  2488. //
  2489. // class CSchemaAttributeType_StrangeScore : public CSchemaAttributeTypeProtobufBase< GC_SCH_REFERENCE( CSchItemAttributeStrangeScore ) CAttribute_StrangeScore >
  2490. // {
  2491. // virtual void ConvertEconAttributeValueToSch( itemid_t unItemId, const CEconItemAttributeDefinition *pAttrDef, const union attribute_data_union_t& value, GCSDK::CRecordBase *out_pSchRecord ) const OVERRIDE;
  2492. // virtual void LoadSchToEconAttributeValue( CEconItem *pTargetItem, const CEconItemAttributeDefinition *pAttrDef, const GCSDK::CRecordBase *pSchRecord ) const OVERRIDE;
  2493. // };
  2494. //
  2495. // Implement these two GC-only functions to convert from the in-memory format to the DB format and
  2496. // vice versa and you're good to go.
  2497. //
  2498. // - register the new type in CEconItemSchema::BInitAttributeTypes().
  2499. //
  2500. // If the attribute type can't be silently converted to an already-existing attribute value type, a few other
  2501. // places will also fail to compile -- things like typed iteration, or compile-time type checking.
  2502. //
  2503. // Functions that start with "Convert" change the format of an attribute value (in a type-safe way wherever
  2504. // possible), copying the value from one of the passed-in parameters to the other. Functions that start with
  2505. // "Load" do a format conversion, but also add the post-conversion value to the passed-in CEconItem. This
  2506. // comes up most often when generating new items, either from the DB (LoadSch), the network (LoadByteSteam),
  2507. // or creation of a new item on the GC (LoadOrGenerate).
  2508. class ISchemaAttributeType
  2509. {
  2510. public:
  2511. virtual ~ISchemaAttributeType() { }
  2512. // Returns a unique integer describing the C++-in-memory-layout type used by this attribute type.
  2513. // For example, something that stores "int" might return 0 and "CSomeFancyWideAttributeType" might
  2514. // return 1. The actual values don't matter and can even differ between different runs of the game/GC.
  2515. // The only important thing is that during a single run the value for a single type is consistent.
  2516. virtual unsigned int GetTypeUniqueIdentifier() const = 0;
  2517. // Have this attribute type copy the data out of the value union and type-copy it onto the item. This
  2518. // is accessible on clients as well as the GC.
  2519. virtual void LoadEconAttributeValue( CEconItem *pTargetItem, const CEconItemAttributeDefinition *pAttrDef, const union attribute_data_union_t& value ) const = 0;
  2520. // ...
  2521. virtual void ConvertEconAttributeValueToByteStream( const union attribute_data_union_t& value, std::string *out_psBytes ) const = 0;
  2522. // ...
  2523. virtual bool BConvertStringToEconAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const char *pszValue, union attribute_data_union_t *out_pValue ) const = 0;
  2524. // ...
  2525. virtual void ConvertEconAttributeValueToString( const CEconItemAttributeDefinition *pAttrDef, const attribute_data_union_t& value, std::string *out_ps ) const = 0;
  2526. // Used to deserialize a byte stream, probably from an on-wire protobuf message, instead an instance
  2527. // of the attribute in memory. See ConvertByteStreamToTypedValue() for example implementation, or
  2528. // ConvertTypedValueToByteStream() for an example of the byte-stream generator code.
  2529. virtual void LoadByteStreamToEconAttributeValue( CEconItem *pTargetItem, const CEconItemAttributeDefinition *pAttrDef, const std::string& sBytes ) const = 0;
  2530. // ...
  2531. virtual void InitializeNewEconAttributeValue( attribute_data_union_t *out_pValue ) const = 0;
  2532. // Free any heap-allocated memory from this attribute value. Is not responsible for zeroing out
  2533. // pointers, etc.
  2534. virtual void UnloadEconAttributeValue( union attribute_data_union_t *out_pValue ) const = 0;
  2535. // ...
  2536. virtual bool OnIterateAttributeValue( class IEconItemAttributeIterator *pIterator, const CEconItemAttributeDefinition *pAttrDef, const attribute_data_union_t& value ) const = 0;
  2537. // This could also be called "BIsHackyMessyOldAttributeType()". This determines whether the attribute
  2538. // can be set at runtime on a CEconItemView instance, whether the gameserver can replicate the value to
  2539. // game clients, etc. It really only makes sense for value types 32 bits or smaller.
  2540. virtual bool BSupportsGameplayModificationAndNetworking() const { return false; }
  2541. };
  2542. struct CAppliedStickerInfo_t
  2543. {
  2544. int nID;
  2545. float flWearMin;
  2546. float flWearMax;
  2547. float flScale;
  2548. float flRotate;
  2549. };
  2550. class CStickerKit
  2551. {
  2552. public:
  2553. CStickerKit( const CStickerKit & rhs )
  2554. : sName( rhs.sName ),
  2555. sDescriptionString( rhs.sDescriptionString ),
  2556. sItemName( rhs.sItemName ),
  2557. sMaterialPath( rhs.sMaterialPath ),
  2558. m_strInventoryImage( rhs.m_strInventoryImage )
  2559. {
  2560. nID = rhs.nID;
  2561. nRarity = rhs.nRarity;
  2562. flRotateStart = rhs.flRotateStart;
  2563. flRotateEnd = rhs.flRotateEnd;
  2564. flScaleMin = rhs.flScaleMin;
  2565. flScaleMax = rhs.flScaleMax;
  2566. flWearMin = rhs.flWearMin;
  2567. flWearMax = rhs.flWearMax;
  2568. bMaterialPathIsAbsolute = rhs.bMaterialPathIsAbsolute;
  2569. m_nEventID = rhs.m_nEventID;
  2570. m_nEventTeamID = rhs.m_nEventTeamID;
  2571. m_nPlayerID = rhs.m_nPlayerID;
  2572. m_pKVItem = rhs.m_pKVItem ? rhs.m_pKVItem->MakeCopy() : NULL;
  2573. }
  2574. CStickerKit( void )
  2575. {
  2576. nID = 0;
  2577. nRarity = 1;
  2578. flRotateStart = 0.0f;
  2579. flRotateEnd = 0.0f;
  2580. flScaleMax = flScaleMin = 1.0f;
  2581. flWearMin = 0.0f;
  2582. flWearMax = 1.0f;
  2583. bMaterialPathIsAbsolute = false;
  2584. m_nEventID = 0;
  2585. m_nEventTeamID = 0;
  2586. m_nPlayerID = 0;
  2587. m_pKVItem = NULL;
  2588. }
  2589. ~CStickerKit()
  2590. {
  2591. if ( m_pKVItem )
  2592. m_pKVItem->deleteThis();
  2593. m_pKVItem = NULL;
  2594. }
  2595. bool InitFromKeyValues( KeyValues *pKVEntry, const CStickerKit *pDefault, CUtlVector<CUtlString> *pVecErrors = NULL );
  2596. bool GenerateStickerApplicationInfo( CAppliedStickerInfo_t *pInfo ) const;
  2597. int nID;
  2598. int nRarity;
  2599. CUtlString sName;
  2600. CUtlString sDescriptionString;
  2601. CUtlString sItemName;
  2602. CUtlString sMaterialPath;
  2603. CUtlString sMaterialPathNoDrips;
  2604. CUtlString m_strInventoryImage;
  2605. int m_nEventID;
  2606. int m_nEventTeamID;
  2607. int m_nPlayerID;
  2608. bool bMaterialPathIsAbsolute;
  2609. float flRotateStart;
  2610. float flRotateEnd;
  2611. float flScaleMin;
  2612. float flScaleMax;
  2613. float flWearMin;
  2614. float flWearMax;
  2615. const char *GetInventoryImage( void ) const { return m_strInventoryImage; }
  2616. const char *GetIconURLSmall() const { return m_sIconURLSmall; }
  2617. const char *GetIconURLLarge() const { return m_sIconURLLarge; }
  2618. void SetIconURLSmall( const char *szURL ) { m_sIconURLSmall = szURL; }
  2619. void SetIconURLLarge( const char *szURL ) { m_sIconURLLarge = szURL; }
  2620. KeyValues *GetRawDefinition( void ) const { return m_pKVItem; }
  2621. private:
  2622. CUtlString m_sIconURLSmall;
  2623. CUtlString m_sIconURLLarge;
  2624. KeyValues *m_pKVItem;
  2625. };
  2626. class CStickerList
  2627. {
  2628. public:
  2629. CStickerList( const CStickerList & rhs )
  2630. {
  2631. flWearMin = rhs.flWearMin;
  2632. flWearMax = rhs.flWearMax;
  2633. flTotalWeight = rhs.flTotalWeight;
  2634. arrElements.AddMultipleToTail( rhs.arrElements.Count(), rhs.arrElements.Base() );
  2635. }
  2636. CStickerList()
  2637. {
  2638. flWearMin = 0.0f;
  2639. flWearMax = 1.0f;
  2640. flTotalWeight = 0.0f;
  2641. }
  2642. bool InitFromKeyValues( KeyValues *pKVEntry, CUtlVector<CUtlString> *pVecErrors = NULL );
  2643. bool GenerateStickerApplicationInfo( CAppliedStickerInfo_t *pInfo ) const;
  2644. struct sticker_list_entry_t
  2645. {
  2646. const CStickerList *pList;
  2647. const CStickerKit *pKit;
  2648. float flWeight;
  2649. };
  2650. CUtlVector< sticker_list_entry_t > arrElements;
  2651. float flTotalWeight;
  2652. float flWearMin;
  2653. float flWearMax;
  2654. };
  2655. class CPaintKit
  2656. {
  2657. public:
  2658. enum { NUM_COLORS = 4 };
  2659. CPaintKit( const CPaintKit & rhs )
  2660. : sName( rhs.sName ),
  2661. sDescriptionString( rhs.sDescriptionString ),
  2662. sDescriptionTag( rhs.sDescriptionTag ),
  2663. sVmtPath( rhs.sVmtPath ),
  2664. sPattern( rhs.sPattern ),
  2665. sLogoMaterial( rhs.sLogoMaterial )
  2666. {
  2667. nID = rhs.nID;
  2668. kvVmtOverrides = rhs.kvVmtOverrides->MakeCopy();
  2669. bBaseDiffuseOverride = rhs.bBaseDiffuseOverride;
  2670. nRarity = rhs.nRarity;
  2671. nStyle = rhs.nStyle;
  2672. flWearDefault = rhs.flWearDefault;
  2673. flWearRemapMin = rhs.flWearRemapMin;
  2674. flWearRemapMax = rhs.flWearRemapMax;
  2675. nFixedSeed = rhs.nFixedSeed;
  2676. uchPhongExponent = rhs.uchPhongExponent;
  2677. uchPhongAlbedoBoost = rhs.uchPhongAlbedoBoost;
  2678. uchPhongIntensity = rhs.uchPhongIntensity;
  2679. flPatternScale = rhs.flPatternScale;
  2680. flPatternOffsetXStart = rhs.flPatternOffsetXStart;
  2681. flPatternOffsetXEnd = rhs.flPatternOffsetXEnd;
  2682. flPatternOffsetYStart = rhs.flPatternOffsetYStart;
  2683. flPatternOffsetYEnd = rhs.flPatternOffsetYEnd;
  2684. flPatternRotateStart = rhs.flPatternRotateStart;
  2685. flPatternRotateEnd = rhs.flPatternRotateEnd;
  2686. flLogoScale = rhs.flLogoScale;
  2687. flLogoOffsetX = rhs.flLogoOffsetX;
  2688. flLogoOffsetY = rhs.flLogoOffsetY;
  2689. flLogoRotation = rhs.flLogoRotation;
  2690. bIgnoreWeaponSizeScale = rhs.bIgnoreWeaponSizeScale;
  2691. nViewModelExponentOverrideSize = rhs.nViewModelExponentOverrideSize;
  2692. bOnlyFirstMaterial = rhs.bOnlyFirstMaterial;
  2693. memcpy( rgbaLogoColor, rhs.rgbaLogoColor, sizeof( rgbaLogoColor ) );
  2694. memcpy( rgbaLogoColor, rhs.rgbaLogoColor, sizeof( rgbaLogoColor ) );
  2695. }
  2696. CPaintKit( void )
  2697. {
  2698. nID = 0;
  2699. kvVmtOverrides = nullptr;
  2700. bBaseDiffuseOverride = false;
  2701. nRarity = 1;
  2702. nStyle = 0;
  2703. flWearDefault = 0.5f;
  2704. flWearRemapMin = 0.0f;
  2705. flWearRemapMax = 1.0f;
  2706. nFixedSeed = 0;
  2707. uchPhongExponent = 16;
  2708. uchPhongAlbedoBoost = 0;
  2709. uchPhongIntensity = 255;
  2710. flPatternScale = 0.5f;
  2711. flPatternOffsetXStart = 0.0f;
  2712. flPatternOffsetXEnd = 0.0f;
  2713. flPatternOffsetYStart = 0.0f;
  2714. flPatternOffsetYEnd = 0.0f;
  2715. flPatternRotateStart = 0.0f;
  2716. flPatternRotateEnd = 0.0f;
  2717. flLogoScale = 1.8f;
  2718. flLogoOffsetX = 1.0f;
  2719. flLogoOffsetY = 2.0f;
  2720. flLogoRotation = 0.0f;
  2721. bIgnoreWeaponSizeScale = false;
  2722. nViewModelExponentOverrideSize = 256;
  2723. bOnlyFirstMaterial = false;
  2724. memset( rgbaColor, 128, sizeof( rgbaColor ) );
  2725. memset( rgbaLogoColor, 128, sizeof( rgbaLogoColor ) );
  2726. }
  2727. ~CPaintKit()
  2728. {
  2729. if ( kvVmtOverrides )
  2730. {
  2731. kvVmtOverrides->deleteThis();
  2732. kvVmtOverrides = nullptr;
  2733. }
  2734. }
  2735. bool InitFromKeyValues( KeyValues *pKVEntry, const CPaintKit *pDefault, bool bHandleAbsolutePaths = false );
  2736. void FillKeyValuesForWorkshop( KeyValues *pKVToFill ) const;
  2737. // Generic fields
  2738. int nID;
  2739. CUtlString sName;
  2740. CUtlString sDescriptionString;
  2741. CUtlString sDescriptionTag;
  2742. // (Generally) Weapon paint kit fields
  2743. // Note that some fields may affect item generation for other paint kit types;
  2744. // in particular the wear settings.
  2745. CUtlString sPattern;
  2746. CUtlString sLogoMaterial;
  2747. bool bBaseDiffuseOverride;
  2748. int nRarity;
  2749. int nStyle;
  2750. Color rgbaColor[ NUM_COLORS ];
  2751. Color rgbaLogoColor[ NUM_COLORS ];
  2752. float flWearDefault;
  2753. float flWearRemapMin;
  2754. float flWearRemapMax;
  2755. unsigned char nFixedSeed;
  2756. unsigned char uchPhongExponent;
  2757. unsigned char uchPhongAlbedoBoost;
  2758. unsigned char uchPhongIntensity;
  2759. float flPatternScale;
  2760. float flPatternOffsetXStart;
  2761. float flPatternOffsetXEnd;
  2762. float flPatternOffsetYStart;
  2763. float flPatternOffsetYEnd;
  2764. float flPatternRotateStart;
  2765. float flPatternRotateEnd;
  2766. float flLogoScale;
  2767. float flLogoOffsetX;
  2768. float flLogoOffsetY;
  2769. float flLogoRotation;
  2770. bool bIgnoreWeaponSizeScale;
  2771. int nViewModelExponentOverrideSize;
  2772. bool bOnlyFirstMaterial;
  2773. // Character paint kit fields
  2774. CUtlString sVmtPath;
  2775. KeyValues* kvVmtOverrides;
  2776. };
  2777. class AlternateIconData_t
  2778. {
  2779. public:
  2780. AlternateIconData_t()
  2781. {
  2782. }
  2783. const char *GetInventoryImage( void ) const { return sSimpleName; }
  2784. const char *GetIconURLSmall() const { return m_sIconURLSmall; }
  2785. const char *GetIconURLLarge() const { return m_sIconURLLarge; }
  2786. void SetIconURLSmall( const char *szURL ) { m_sIconURLSmall = szURL; }
  2787. void SetIconURLLarge( const char *szURL ) { m_sIconURLLarge = szURL; }
  2788. CUtlString sSimpleName;
  2789. CUtlString sLargeSimpleName;
  2790. private:
  2791. CUtlString m_sIconURLSmall;
  2792. CUtlString m_sIconURLLarge;
  2793. };
  2794. class CProPlayerData
  2795. {
  2796. public:
  2797. CProPlayerData( const CProPlayerData & rhs )
  2798. {
  2799. m_nAccountID = rhs.m_nAccountID;
  2800. m_sName = rhs.m_sName;
  2801. m_sCode = rhs.m_sCode;
  2802. m_rtDOB = rhs.m_rtDOB;
  2803. m_sGeo = rhs.m_sGeo;
  2804. m_pKVItem = rhs.m_pKVItem ? rhs.m_pKVItem->MakeCopy() : NULL;
  2805. }
  2806. CProPlayerData( void )
  2807. {
  2808. m_nAccountID = 0;
  2809. m_rtDOB = 0;
  2810. m_pKVItem = NULL;
  2811. }
  2812. ~CProPlayerData()
  2813. {
  2814. if ( m_pKVItem )
  2815. m_pKVItem->deleteThis();
  2816. m_pKVItem = NULL;
  2817. }
  2818. bool BInitFromKeyValues( KeyValues *pDef, CUtlVector<CUtlString> *pVecErrors = NULL );
  2819. KeyValues *GetRawDefinition( void ) const { return m_pKVItem; }
  2820. uint32 GetAccountID() const { return m_nAccountID; }
  2821. char const * GetName() const { return m_sName; }
  2822. char const * GetCode() const { return m_sCode; }
  2823. RTime32 GetDOB() const { return m_rtDOB; }
  2824. char const * GetGeo() const { return m_sGeo; }
  2825. private:
  2826. KeyValues *m_pKVItem;
  2827. uint32 m_nAccountID;
  2828. CUtlString m_sName;
  2829. CUtlString m_sCode;
  2830. RTime32 m_rtDOB;
  2831. CUtlString m_sGeo;
  2832. };
  2833. //-----------------------------------------------------------------------------
  2834. // CEconItemSchema
  2835. // Defines the way econ items can be used in a game
  2836. //-----------------------------------------------------------------------------
  2837. typedef CUtlDict<CUtlConstString, int> ArmoryStringDict_t;
  2838. typedef CUtlDict< CUtlVector<CItemLevelingDefinition> * > LevelBlockDict_t;
  2839. typedef CUtlMap<unsigned int, kill_eater_score_type_t> KillEaterScoreMap_t;
  2840. struct attr_type_t
  2841. {
  2842. CUtlConstString m_sName;
  2843. const ISchemaAttributeType *m_pAttrType;
  2844. attr_type_t( const char *pszName, const ISchemaAttributeType *pAttrType )
  2845. : m_sName( pszName )
  2846. , m_pAttrType( pAttrType )
  2847. {
  2848. }
  2849. };
  2850. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  2851. class IDelayedSchemaData
  2852. {
  2853. public:
  2854. virtual ~IDelayedSchemaData() {}
  2855. virtual bool InitializeSchema( CEconItemSchema *pItemSchema ) = 0;
  2856. protected:
  2857. // Passing '0' as the expected version means "we weren't expecting any version in particular" and will
  2858. // skip the sanity checking.
  2859. bool InitializeSchemaInternal( CEconItemSchema *pItemSchema, CUtlBuffer& bufRawData, bool bInitAsBinary, uint32 nExpectedVersion );
  2860. };
  2861. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  2862. class CEconStorePriceSheet;
  2863. class CEconItemSchema : public IEconItemSchema
  2864. {
  2865. public:
  2866. CEconItemSchema( );
  2867. private:
  2868. CEconItemSchema( const CEconItemSchema & rhs );
  2869. CEconItemSchema &operator=( CEconItemSchema & rhs );
  2870. public:
  2871. virtual ~CEconItemSchema( void ) { Reset(); };
  2872. // Setup & parse in the item data files.
  2873. virtual bool BInit( const char *fileName, const char *pathID, CUtlVector<CUtlString> *pVecErrors = NULL );
  2874. bool BInitBinaryBuffer( CUtlBuffer &buffer, CUtlVector<CUtlString> *pVecErrors = NULL );
  2875. bool BInitTextBuffer( CUtlBuffer &buffer, CUtlVector<CUtlString> *pVecErrors = NULL );
  2876. uint32 GetVersion() const { return m_unVersion; }
  2877. uint32 GetResetCount() const { return m_unResetCount; }
  2878. static CUniformRandomStream& GetRandomStream() { return m_RandomStream; }
  2879. // Perform the computation used to calculate the schema version
  2880. static uint32 CalculateKeyValuesVersion( KeyValues *pKV );
  2881. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  2882. // This function will immediately reinitialize the schema if it's safe to do so, or store off the data
  2883. // if it isn't safe to update at the moment.
  2884. void MaybeInitFromBuffer( IDelayedSchemaData *pDelayedSchemaData );
  2885. // If there is saved schema initialization data, initialize it now. If there is no saved data, this
  2886. // will return success.
  2887. bool BInitFromDelayedBuffer();
  2888. #endif // defined(CLIENT_DLL) || defined(GAME_DLL)
  2889. // Accessors to the base properties
  2890. equipped_class_t GetFirstValidClass() const { return m_unFirstValidClass; }
  2891. equipped_class_t GetLastValidClass() const { return m_unLastValidClass; }
  2892. bool IsValidClass( equipped_class_t unClass ) { return unClass >= m_unFirstValidClass && unClass <= m_unLastValidClass; }
  2893. equipped_slot_t GetFirstValidItemSlot() const { return m_unFirstValidItemSlot; }
  2894. equipped_slot_t GetLastValidItemSlot() const { return m_unLastValidItemSlot; }
  2895. bool IsValidItemSlot( equipped_slot_t unSlot ) { return unSlot >= m_unFirstValidItemSlot && unSlot <= m_unLastValidItemSlot; }
  2896. uint32 GetNumAllowedItemPresets() const { return m_unNumItemPresets; }
  2897. bool IsValidPreset( equipped_preset_t unPreset ) const { return unPreset <= m_unNumItemPresets; }
  2898. uint32 GetMinLevel() const { return m_unMinLevel; }
  2899. uint32 GetMaxLevel() const { return m_unMaxLevel; }
  2900. uint32 GetSumQualityWeights() const { return m_unSumQualityWeights; }
  2901. // Accessors to the underlying sections
  2902. typedef CUtlHashMapLarge<int, CEconItemDefinition*> ItemDefinitionMap_t;
  2903. const ItemDefinitionMap_t &GetItemDefinitionMap() const { return m_mapItems; }
  2904. typedef CUtlMap<int, CEconItemDefinition*, int, CDefLess<int> > SortedItemDefinitionMap_t;
  2905. const SortedItemDefinitionMap_t &GetSortedItemDefinitionMap() const { return m_mapItemsSorted; }
  2906. typedef CUtlDict<CEconLootListDefinition> LootListDefinitionDict_t;
  2907. const LootListDefinitionDict_t &GetLootLists() const { return m_dictLootLists; }
  2908. typedef CUtlMap<int, const char*, int, CDefLess<int> > RevolvingLootListDefinitionMap_t;
  2909. const RevolvingLootListDefinitionMap_t &GetRevolvingLootLists() const { return m_mapRevolvingLootLists; }
  2910. const RevolvingLootListDefinitionMap_t &GetQuestRewardLootLists() const { return m_mapQuestRewardLootLists; }
  2911. typedef CUtlMap<const char*, int> BodygroupStateMap_t;
  2912. const BodygroupStateMap_t &GetDefaultBodygroupStateMap() const { return m_mapDefaultBodygroupState; }
  2913. typedef CUtlVector<CEconColorDefinition *> ColorDefinitionsList_t;
  2914. typedef CUtlMap<int, CEconMusicDefinition*, int, CDefLess<int> > MusicDefinitionsList_t;
  2915. typedef CUtlMap<int, CEconQuestDefinition*, int, CDefLess<int> > QuestDefinitionsList_t;
  2916. typedef CUtlMap<int, CEconCampaignDefinition*, int, CDefLess<int> > CampaignDefinitionsList_t;
  2917. const MusicDefinitionsList_t &GetMusicDefinitionMap() const { return m_mapMusicDefs; }
  2918. const CEconItemDefinition *GetDefaultItemDefinition() const { return m_pDefaultItemDefinition; }
  2919. IEconItemDefinition *GetDefaultItemDefinitionInterface() { return m_pDefaultItemDefinition; }
  2920. const CUtlMap<int, CEconItemQualityDefinition, int, CDefLess<int> > &GetQualityDefinitionMap() const { return m_mapQualities; }
  2921. typedef CUtlVector< CEconItemAttributeDefinition* > EconAttrDefsContainer_t;
  2922. EconAttrDefsContainer_t &GetAttributeDefinitionContainer() { return m_mapAttributesContainer; }
  2923. const EconAttrDefsContainer_t &GetAttributeDefinitionContainer() const { return m_mapAttributesContainer; }
  2924. typedef CUtlMap<int, CEconCraftingRecipeDefinition*, int, CDefLess<int> > RecipeDefinitionMap_t;
  2925. const RecipeDefinitionMap_t &GetRecipeDefinitionMap() const { return m_mapRecipes; }
  2926. const CUtlMap<const char*, CEconItemSetDefinition, int > &GetItemSets() const { return m_mapItemSets; }
  2927. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  2928. const ArmoryStringDict_t &GetArmoryDataItemClasses() const { return m_dictArmoryItemClassesDataStrings; }
  2929. const ArmoryStringDict_t &GetArmoryDataItemTypes() const { return m_dictArmoryItemTypesDataStrings; }
  2930. const ArmoryStringDict_t &GetArmoryDataItems() const { return m_dictArmoryItemDataStrings; }
  2931. const ArmoryStringDict_t &GetArmoryDataAttributes() const { return m_dictArmoryAttributeDataStrings; }
  2932. #endif
  2933. const CTimedItemRewardDefinition* GetTimedReward( eTimedRewardType type ) const;
  2934. const CEconLootListDefinition* GetLootListByName( const char* pListName, int *out_piIndex = NULL ) const;
  2935. const CEconLootListDefinition* GetLootListByIndex( int iIdx ) const { return m_dictLootLists.IsValidIndex(iIdx) ? &(m_dictLootLists[iIdx]) : NULL; }
  2936. virtual void PurgeLootLists( void ) { m_dictLootLists.Purge(); }
  2937. virtual const IEconLootListDefinition* GetLootListInterfaceByName( const char* pListName, int *out_piIndex = NULL ) { return GetLootListByName( pListName, out_piIndex ); }
  2938. virtual const IEconLootListDefinition* GetLootListInterfaceByIndex( int iIdx ) const { return GetLootListByIndex( iIdx ); }
  2939. virtual const int GetLootListIndex( const char* pListName ) { return m_dictLootLists.Find( pListName ); }
  2940. virtual const int GetLootListInterfaceCount( void ) const { return m_dictLootLists.Count(); }
  2941. const CEconItemSetDefinition* GetItemSet( const char* pSetName, int *piIndex = NULL ) const;
  2942. const CEconItemSetDefinition* GetItemSetByIndex( int iIdx ) const { return m_mapItemSets.IsValidIndex(iIdx) ? &(m_mapItemSets[iIdx]) : NULL; }
  2943. uint8 GetDefaultQuality() const { return AE_UNIQUE; }
  2944. virtual int GetItemSetCount( void ) const { return m_mapItemSets.Count(); }
  2945. virtual const IEconItemSetDefinition* GetItemSet( int iIndex ) const;
  2946. void AssignDefaultBodygroupState( const char *pszBodygroupName, int iValue );
  2947. equip_region_mask_t GetEquipRegionMaskByName( const char *pRegionName ) const;
  2948. struct EquipRegion
  2949. {
  2950. CUtlConstString m_sName;
  2951. unsigned int m_unBitIndex; // which bit are we claiming ownership over? there might be multiple equip regions with the same bit if we're in a "shared" block
  2952. equip_region_mask_t m_unMask; // full region conflict mask
  2953. };
  2954. typedef CUtlVector<EquipRegion> EquipRegionsList_t;
  2955. const EquipRegionsList_t& GetEquipRegionsList() const { return m_vecEquipRegionsList; }
  2956. virtual KeyValues *FindDefinitionPrefabByName( const char *pszPrefabName ) const;
  2957. equip_region_mask_t GetEquipRegionBitMaskByName( const char *pRegionName ) const;
  2958. CUtlVector< CEconItemDefinition * > &GetBundles() { return m_vecBundles; } // Retrieve a cached list of all bundles
  2959. private:
  2960. void SetEquipRegionConflict( int iRegion, unsigned int unBit );
  2961. int GetEquipRegionIndexByName( const char *pRegionName ) const;
  2962. public:
  2963. // Common lookup methods
  2964. bool BGetItemQualityFromName( const char *pchName, uint8 *nQuality ) const;
  2965. const CEconItemQualityDefinition *GetQualityDefinition( int nQuality ) const;
  2966. const CEconItemQualityDefinition *GetQualityDefinitionByName( const char *pszDefName ) const;
  2967. virtual int GetQualityDefinitionCount( void ) { return m_mapQualities.Count(); }
  2968. virtual const char* GetQualityName( uint8 iQuality );
  2969. virtual int GetQualityIndex( const char* pszQuality );
  2970. bool BGetItemRarityFromName( const char* pchName, uint8 *nRarity ) const;
  2971. const CEconItemRarityDefinition *GetRarityDefinitionByMapIndex( int nRarityIndex ) const;
  2972. const CEconItemRarityDefinition *GetRarityDefinition( int nRarity ) const;
  2973. const CEconItemRarityDefinition *GetRarityDefinitionByName( const char *pszDefName ) const;
  2974. virtual int GetRarityDefinitionCount( void ) const { return m_mapRarities.Count(); }
  2975. virtual const char* GetRarityName( uint8 iRarity );
  2976. virtual const char* GetRarityLocKey( uint8 iRarity );
  2977. virtual const char* GetRarityColor( uint8 iRarity );
  2978. virtual const char* GetRarityLootList( uint8 iRarity );
  2979. virtual int GetRarityIndex( const char* pszRarity );
  2980. CEconItemDefinition *GetItemDefinitionMutable( int iItemIndex, bool bNoDefault=false );
  2981. const CEconItemDefinition *GetItemDefinition( int iItemIndex, bool bNoDefault=false ) const;
  2982. const CEconItemDefinition *GetItemDefinitionByMapIndex( int iMapIndex ) const;
  2983. const CEconItemAttributeDefinition *GetAttributeDefinition( int iAttribIndex ) const;
  2984. virtual const IEconItemAttributeDefinition *GetAttributeDefinitionInterface( int iAttribIndex ) const { return GetAttributeDefinition( iAttribIndex ); }
  2985. const CEconItemAttributeDefinition *GetAttributeDefinitionByName( const char *pszDefName ) const;
  2986. const CEconCraftingRecipeDefinition *GetRecipeDefinition( int iRecipeIndex ) const;
  2987. int GetPaintKitDefinitionCount( void ) const { return m_mapPaintKits.Count(); }
  2988. void AddPaintKitDefinition( int iPaintKitID, CPaintKit *pPaintKit );
  2989. void RemovePaintKitDefinition( int iPaintKitID );
  2990. const unsigned int GetPaintKitCount() const;
  2991. const CPaintKit *GetPaintKitDefinition( int iPaintKitID ) const;
  2992. const CPaintKit *GetPaintKitDefinitionByMapIndex( int iMapIndex );
  2993. const CPaintKit *GetPaintKitDefinitionByName( const char *pchName ) const;
  2994. int GetStickerKitDefinitionCount( void ) const { return m_mapStickerKits.Count(); }
  2995. void AddStickerKitDefinition( int iStickerKitID, CStickerKit *pStickerKit );
  2996. void RemoveStickerKitDefinition( int iStickerKitID );
  2997. const CStickerKit *GetStickerKitDefinition( int iStickerKitID ) const;
  2998. const CStickerKit *GetStickerKitDefinitionByMapIndex( int iMapIndex );
  2999. const CStickerKit *GetStickerKitDefinitionByName( const char *pchName ) const;
  3000. const CStickerList *GetStickerListDefinitionByName( const char *pchName ) const;
  3001. const CEconMusicDefinition *GetMusicKitDefinitionByName( const char *pchName ) const;
  3002. const CEconColorDefinition *GetColorDefinitionByName( const char *pszDefName ) const;
  3003. int GetGraffitiTintMaxValidDefID() const { return m_nMaxValidGraffitiTintDefID; }
  3004. const CEconGraffitiTintDefinition *GetGraffitiTintDefinitionByID( int nID ) const;
  3005. const CEconGraffitiTintDefinition *GetGraffitiTintDefinitionByName( const char *pszDefName ) const;
  3006. const CEconMusicDefinition *GetMusicDefinition( uint32 unMusicID ) const;
  3007. CEconQuestDefinition *GetQuestDefinition( uint32 unQuestID ) const;
  3008. const QuestDefinitionsList_t& GetQuestDefinitionMap( void ) const { return m_mapQuestDefs; }
  3009. const QuestEventsSchedule_t& GetAndUpdateQuestEventsSchedule( void );
  3010. const QuestEvents_t& GetQuestEvents( void ) const { return m_vecQuestEvents; }
  3011. CEconCampaignDefinition *GetCampaignDefinition( uint32 unCampaignID ) const;
  3012. const CampaignDefinitionsList_t& GetCampaignDefinitionMap( void ) const { return m_mapCampaignDefs; }
  3013. virtual int GetToolType( const char *pszToolType ) const { return -1; }
  3014. virtual int GetNumPrefabs( void ) { return m_mapDefinitionPrefabs.Count(); }
  3015. virtual const char* GetPrefabName( int idx ) { return m_mapDefinitionPrefabs.Key( idx ); }
  3016. const CEconSoundMaterialDefinition *GetSoundMaterialDefinitionByID( int nSoundMaterialID ) const;
  3017. const CEconSoundMaterialDefinition *GetSoundMaterialDefinitionByName( const char *pszSoundMaterialName ) const;
  3018. virtual const char* GetSoundMaterialNameByID( int nSoundMaterialID );
  3019. virtual int GetSoundMaterialID( const char* pszSoundMaterial );
  3020. // iterating sound materials
  3021. virtual int GetSoundMaterialCount( void ) { return m_mapSoundMaterials.Count(); }
  3022. virtual int GetSoundMaterialIDByIndex( int nIndex );
  3023. #ifdef CLIENT_DLL
  3024. // Web Resources
  3025. EWebResourceStatus LoadWebResource( CUtlString pszName, void (*fnCallback)( const char*, KeyValues* ), bool bForceReload=false );
  3026. void SetWebResource( CUtlString strName, KeyValues* pResourceKV );
  3027. #endif
  3028. // Pro players data
  3029. const CProPlayerData * GetProPlayerDataByAccountID( uint32 unAccountID ) const;
  3030. const CUtlVector< const CProPlayerData * > * GetProPlayersDataForEventIDTeamID( int nEventID, int nTeamID ) const;
  3031. virtual uint32 GetHeroID( const char* pszHeroName ) { return 0; }
  3032. bool BCanGSCreateItems( uint32 unIP ) const;
  3033. const AchievementAward_t *GetAchievementRewardByDefIndex( uint16 usDefIndex ) const;
  3034. bool BHasAchievementRewards( void ) const { return (m_dictAchievementRewards.Count() > 0); }
  3035. static CUtlString ComputeAchievementName( AppId_t unAppID, const char *pchNativeAchievementName );
  3036. // Iterating over the item definitions. Game needs this to precache data.
  3037. CEconItemDefinition *GetItemDefinitionByName( const char *pszDefName );
  3038. const CEconItemDefinition *GetItemDefinitionByName( const char *pszDefName ) const;
  3039. attachedparticlesystem_t* GetAttributeControlledParticleSystem( int id );
  3040. attachedparticlesystem_t* GetAttributeControlledParticleSystemByIndex( int id );
  3041. attachedparticlesystem_t* FindAttributeControlledParticleSystem( const char *pchSystemName, int *outID = NULL );
  3042. typedef CUtlMap<int, attachedparticlesystem_t, int, CDefLess<int> > ParticleDefinitionMap_t;
  3043. const ParticleDefinitionMap_t& GetAttributeControlledParticleSystems() const { return m_mapAttributeControlledParticleSystems; }
  3044. virtual int GetNumAttributeControlledParticleSystems() const { return GetAttributeControlledParticleSystems().Count(); }
  3045. // Only intended to be used for generating data for the WebAPI.
  3046. const KillEaterScoreMap_t& GetKillEaterScoreTypes() const { return m_mapKillEaterScoreTypes; }
  3047. // Note: this returns pointers to the inside of a vector and/or NULL. Pointers are not intended to be
  3048. // saved off and used later.
  3049. const kill_eater_score_type_t *FindKillEaterScoreType( uint32 unScoreType ) const;
  3050. const CUtlVector<attr_type_t>& GetAttributeTypes() const { return m_vecAttributeTypes; }
  3051. const ISchemaAttributeType *GetAttributeType( const char *pszAttrTypeName ) const;
  3052. const LevelBlockDict_t& GetItemLevelingDataDict() const { return m_vecItemLevelingData; }
  3053. const CUtlVector<CItemLevelingDefinition> *GetItemLevelingData( const char *pszLevelBlockName ) const
  3054. {
  3055. LevelBlockDict_t::IndexType_t i = m_vecItemLevelingData.Find( pszLevelBlockName );
  3056. if ( i == LevelBlockDict_t::InvalidIndex() )
  3057. return NULL;
  3058. return m_vecItemLevelingData[i];
  3059. }
  3060. const CItemLevelingDefinition *GetItemLevelForScore( const char *pszLevelBlockName, uint32 unScore ) const;
  3061. const char *GetKillEaterScoreTypeLocString( uint32 unScoreType ) const;
  3062. bool GetKillEaterScoreTypeUseLevelData( uint32 unScoreType ) const;
  3063. const char *GetKillEaterScoreTypeLevelingDataName( uint32 unScoreType ) const;
  3064. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  3065. virtual void ItemTesting_CreateTestDefinition( int iCloneFromItemDef, int iNewDef, KeyValues *pNewKV );
  3066. virtual void ItemTesting_DiscardTestDefinition( int iDef );
  3067. #endif
  3068. econ_tag_handle_t GetHandleForTag( const char *pszTagName ); // non-const because it may create a new tag handle
  3069. typedef CUtlDict<econ_tag_handle_t> EconTagDict_t;
  3070. public:
  3071. // Subclass interface.
  3072. virtual CEconItemDefinition *CreateEconItemDefinition() { return new CEconItemDefinition; }
  3073. virtual CEconCraftingRecipeDefinition *CreateCraftingRecipeDefinition() { return new CEconCraftingRecipeDefinition; }
  3074. virtual CEconStyleInfo *CreateEconStyleInfo() { return new CEconStyleInfo; }
  3075. virtual IEconTool *CreateEconToolImpl( const char *pszToolType, const char *pszUseString, const char *pszUsageRestriction, item_capabilities_t unCapabilities, KeyValues *pUsageKV );
  3076. virtual int GetItemDefinitionCount() { return m_mapItems.Count(); }
  3077. AlternateIconData_t *GetAlternateIcon( uint64 ullAlternateIcon );
  3078. typedef CUtlMap< uint64, AlternateIconData_t, int, CDefLess<uint64> > AlternateIconsMap_t;
  3079. AlternateIconsMap_t &GetAlternateIconsMap() { return m_mapAlternateIcons; }
  3080. protected:
  3081. virtual void Reset( void );
  3082. // IEconItemSchema
  3083. // This interface isn't fully generic. Expand as needed.
  3084. virtual KeyValues* GetRawDefinition( void ) const { return m_pKVRawDefinition; }
  3085. virtual IEconItemDefinition* GetItemDefinitionInterface( int iDefIndex ) { return GetItemDefinitionMutable( iDefIndex, true ); }
  3086. virtual int GetLoadoutSlotCount() { return 0; }
  3087. virtual const char* GetLoadoutSlotName( int iSlot ) { return NULL; }
  3088. virtual int GetLoadoutSlot( const char* pszSlotName ) { return 0; }
  3089. virtual int GetCharacterSlotType( int iCharacter, int iSlot ) { return 0; }
  3090. virtual int GetCharacterID( const char* pszCharacterName ) { return 0; }
  3091. virtual bool DeleteItemDefinition( int iDefIndex );
  3092. virtual int GetCharacterCount( void ) { return 0; }
  3093. virtual const char* GetCharacterName( int iCharacter ) { return NULL; }
  3094. virtual const char* GetCharacterModel( int iCharacter ) { return NULL; }
  3095. virtual int CalculateNumberOfConcreteItems( const CEconItemDefinition *pItemDef ); // Let derived classes handle custom item types
  3096. virtual bool BInitItems( KeyValues *pKVItems, CUtlVector<CUtlString> *pVecErrors );
  3097. virtual bool BInitItemMappings( CUtlVector<CUtlString> *pVecErrors );
  3098. virtual bool BInitBundles( CUtlVector<CUtlString> *pVecErrors );
  3099. virtual bool BInitPaymentRules( CUtlVector<CUtlString> *pVecErrors );
  3100. virtual bool BInitItemSets( KeyValues *pKVItemSets, CUtlVector<CUtlString> *pVecErrors );
  3101. private:
  3102. bool BInitGameInfo( KeyValues *pKVGameInfo, CUtlVector<CUtlString> *pVecErrors );
  3103. bool BInitAttributeTypes( CUtlVector<CUtlString> *pVecErrors );
  3104. bool BInitDefinitionPrefabs( KeyValues *pKVPrefabs, CUtlVector<CUtlString> *pVecErrors );
  3105. bool BInitRarities( KeyValues *pKVRarities, CUtlVector<CUtlString> *pVecErrors );
  3106. bool BInitQualities( KeyValues *pKVAttributes, CUtlVector<CUtlString> *pVecErrors );
  3107. bool BInitColors( KeyValues *pKVColors, CUtlVector<CUtlString> *pVecErrors );
  3108. bool BInitGraffitiTints( KeyValues *pKVColors, CUtlVector<CUtlString> *pVecErrors );
  3109. bool BInitAttributes( KeyValues *pKVAttributes, CUtlVector<CUtlString> *pVecErrors );
  3110. bool BInitEquipRegions( KeyValues *pKVEquipRegions, CUtlVector<CUtlString> *pVecErrors );
  3111. bool BInitEquipRegionConflicts( KeyValues *pKVEquipRegions, CUtlVector<CUtlString> *pVecErrors );
  3112. bool BInitTimedRewards( KeyValues *pKVTimeRewards, CUtlVector<CUtlString> *pVecErrors );
  3113. bool BInitAchievementRewards( KeyValues *pKVTimeRewards, CUtlVector<CUtlString> *pVecErrors );
  3114. bool BInitRecipes( KeyValues *pKVRecipes, CUtlVector<CUtlString> *pVecErrors );
  3115. virtual bool BInitLootLists( KeyValues *pKVLootLists, KeyValues *pKVRandomAttributeTemplates, CUtlVector<CUtlString> *pVecErrors, bool bServerLists );
  3116. bool BInitRevolvingLootLists( KeyValues *pKVRevolvingLootLists, CUtlVector<CUtlString> *pVecErrors );
  3117. bool BInitQuestRewardLootLists( KeyValues *pKVQuestRewardLootLists, CUtlVector<CUtlString> *pVecErrors );
  3118. #ifdef TF_CLIENT_DLL
  3119. bool BInitConcreteItemCounts( CUtlVector<CUtlString> *pVecErrors );
  3120. #endif
  3121. bool BInitItemLevels( KeyValues *pKVItemLevels, CUtlVector<CUtlString> *pVecErrors );
  3122. bool BInitKillEaterScoreTypes( KeyValues *pKVItemLevels, CUtlVector<CUtlString> *pVecErrors );
  3123. bool BInitAlternateIcons( KeyValues *pKVAlternateIcons, CUtlVector<CUtlString> *pVecErrors );
  3124. bool BInitAlternateIcon( uint64 ullAltIconKey, char const *szSimpleName, KeyValues *pKVAlternateIcon, CUtlVector<CUtlString> *pVecErrors );
  3125. bool BInitStickerKits( KeyValues *pKVStickerKits, CUtlVector<CUtlString> *pVecErrors );
  3126. bool BInitSoundMaterials( KeyValues *pKVSoundMaterials, CUtlVector<CUtlString> *pVecErrors );
  3127. bool BInitStickerLists( KeyValues *pKVStickerKits, CUtlVector<CUtlString> *pVecErrors );
  3128. bool BInitPaintKits( KeyValues *pKVPaintKits, CUtlVector<CUtlString> *pVecErrors );
  3129. bool BInitPaintKitsRarity( KeyValues *pKVPaintKitsRarity, CUtlVector<CUtlString> *pVecErrors );
  3130. bool BInitMusicDefs( KeyValues *pKVMusicDefs, CUtlVector<CUtlString> *pVecErrors );
  3131. bool BInitQuestDefs( KeyValues *pKVQuestDefs, CUtlVector<CUtlString> *pVecErrors );
  3132. bool BInitQuestEvents( KeyValues *pKVQuestEvents, CUtlVector<CUtlString> *pVecErrors );
  3133. bool BInitCampaignDefs( KeyValues *pKVCampaignDefs, CUtlVector<CUtlString> *pVecErrors );
  3134. bool BInitProPlayers( KeyValues *pKVData, CUtlVector<CUtlString> *pVecErrors );
  3135. #ifdef CLIENT_DLL
  3136. bool BInitWebResources( KeyValues *pKVWebResources, CUtlVector<CUtlString> *pVecErrors );
  3137. #endif
  3138. bool BPostSchemaInitStartupChecks( CUtlVector<CUtlString> *pVecErrors );
  3139. virtual attachedparticlesystem_t GetAttachedParticleSystemInfo( KeyValues* pParticleSystemKV, int32 nItemIndex ) const;
  3140. virtual bool BInitAttributeControlledParticleSystems( KeyValues *pKVParticleSystems, CUtlVector<CUtlString> *pVecErrors );
  3141. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  3142. bool BInitArmoryData( KeyValues *pKVArmoryData, CUtlVector<CUtlString> *pVecErrors );
  3143. #else
  3144. bool BInitExperiements( KeyValues *pKVExperiments, CUtlVector<CUtlString> *pVecErrors );
  3145. bool BInitForeignImports( CUtlVector<CUtlString> *pVecErrors );
  3146. CForeignAppImports *FindOrAddAppImports( AppId_t unAppID );
  3147. #endif
  3148. protected:
  3149. virtual bool BInitSchema( KeyValues *pKVRawDefinition, CUtlVector<CUtlString> *pVecErrors = NULL );
  3150. private:
  3151. bool m_bSchemaUpdatesEnabled;
  3152. uint32 m_unResetCount;
  3153. KeyValues *m_pKVRawDefinition;
  3154. uint32 m_unVersion;
  3155. // Class range
  3156. equipped_class_t m_unFirstValidClass;
  3157. equipped_class_t m_unLastValidClass;
  3158. // Item slot range
  3159. equipped_slot_t m_unFirstValidItemSlot;
  3160. equipped_slot_t m_unLastValidItemSlot;
  3161. // Number of allowed presets
  3162. uint32 m_unNumItemPresets;
  3163. // Allowable range of item levels for this app
  3164. uint32 m_unMinLevel;
  3165. uint32 m_unMaxLevel;
  3166. // Total value of all the weights of the qualities
  3167. uint32 m_unSumQualityWeights;
  3168. // Name-to-implementation list of all unique attribute types (ie., "wide strange score").
  3169. CUtlVector<attr_type_t> m_vecAttributeTypes;
  3170. // Contains the list of rarity definitions
  3171. CUtlMap<int, CEconItemRarityDefinition, int, CDefLess<int> > m_mapRarities;
  3172. // Contains the list of quality definitions read in from all data files.
  3173. CUtlMap<int, CEconItemQualityDefinition, int, CDefLess<int> > m_mapQualities;
  3174. // Contains the list of item definitions read in from all data files.
  3175. ItemDefinitionMap_t m_mapItems;
  3176. // A sorted version of the same map, for instances where we really want sorted data
  3177. SortedItemDefinitionMap_t m_mapItemsSorted;
  3178. // What is the default item definition we'll return in the client code if we can't find the correct one?
  3179. CEconItemDefinition *m_pDefaultItemDefinition;
  3180. // Contains the list of attribute definitions read in from all data files.
  3181. EconAttrDefsContainer_t m_mapAttributesContainer;
  3182. // Contains the list of item recipes read in from all data files.
  3183. RecipeDefinitionMap_t m_mapRecipes;
  3184. // Contains the list of item sets.
  3185. CUtlMap<const char*, CEconItemSetDefinition, int > m_mapItemSets;
  3186. // Revolving loot lists.
  3187. CUtlMap<int, const char*, int, CDefLess<int> > m_mapRevolvingLootLists;
  3188. // Revolving loot lists.
  3189. CUtlMap<int, const char*, int, CDefLess<int> > m_mapQuestRewardLootLists;
  3190. // Contains the list of loot lists.
  3191. LootListDefinitionDict_t m_dictLootLists;
  3192. // List of events that award items based on time played
  3193. CUtlVector<CTimedItemRewardDefinition> m_vecTimedRewards;
  3194. // List of web resources.
  3195. CUtlDict<CWebResource*, int> m_dictWebResources;
  3196. // List of alternate icons.
  3197. AlternateIconsMap_t m_mapAlternateIcons;
  3198. // list of items that will be awarded from achievements
  3199. CUtlDict< AchievementAward_t *, int > m_dictAchievementRewards;
  3200. CUtlMap< uint32, AchievementAward_t *, int, CDefLess<uint32> > m_mapAchievementRewardsByData;
  3201. // Contains the map of paint kits
  3202. CUtlMap<int, CPaintKit*, int, CDefLess<int> > m_mapPaintKits;
  3203. // Contains the map of sticker kits
  3204. CUtlMap<int, CStickerKit*, int, CDefLess<int> > m_mapStickerKits;
  3205. CUtlDict< CStickerKit *, int > m_dictStickerKits;
  3206. // Contains the map of sticker lists
  3207. CUtlDict< CStickerList *, int > m_dictStickerLists;
  3208. // Contains information for attribute attached particle systems
  3209. CUtlMap<int, attachedparticlesystem_t, int, CDefLess<int> > m_mapAttributeControlledParticleSystems;
  3210. // Contains information on which equip regions conflict with each other regions and how to
  3211. // test for overlap.
  3212. EquipRegionsList_t m_vecEquipRegionsList;
  3213. // Contains information about prefab KeyValues blocks that be can referenced elsewhere
  3214. // in the schema.
  3215. CUtlMap<const char *, KeyValues *, int> m_mapDefinitionPrefabs;
  3216. // Contains runtime color information, looked-up by name.
  3217. ColorDefinitionsList_t m_vecColorDefs;
  3218. CUtlVector< CEconGraffitiTintDefinition * > m_vecGraffitiTintDefs;
  3219. CUtlStringMap< CEconGraffitiTintDefinition * > m_mapGraffitiTintByName;
  3220. int m_nMaxValidGraffitiTintDefID;
  3221. // Contains runtime music definitions for music kits.
  3222. MusicDefinitionsList_t m_mapMusicDefs;
  3223. QuestDefinitionsList_t m_mapQuestDefs;
  3224. CampaignDefinitionsList_t m_mapCampaignDefs;
  3225. QuestEvents_t m_vecQuestEvents;
  3226. QuestEventsSchedule_t m_mapQuestEventsSchedule;
  3227. typedef CUtlMap< uint32, CProPlayerData *, int, CDefLess< uint32 > > MapProPlayersByAccountID_t;
  3228. typedef CUtlStringMap< CProPlayerData * > MapProPlayersByName_t;
  3229. typedef CUtlMap< uint64, CUtlVector< const CProPlayerData * > *, int, CDefLess< uint64 > > MapProPlayersByEventIDTeamID_t;
  3230. MapProPlayersByAccountID_t m_mapProPlayersByAccountID;
  3231. MapProPlayersByName_t m_mapProPlayersByCode;
  3232. MapProPlayersByEventIDTeamID_t m_mapProPlayersByEventIDTeamID;
  3233. // Contains the list of sound material definitions
  3234. CUtlMap<int, CEconSoundMaterialDefinition, int, CDefLess<int> > m_mapSoundMaterials;
  3235. // Contains information about: a) every bodygroup that appears anywhere in the schema, and
  3236. // b) whether they default to on or off.
  3237. BodygroupStateMap_t m_mapDefaultBodygroupState;
  3238. // Various definitions can have any number of unique tags associated with them.
  3239. EconTagDict_t m_dictTags;
  3240. // List of item leveling data.
  3241. KillEaterScoreMap_t m_mapKillEaterScoreTypes;
  3242. LevelBlockDict_t m_vecItemLevelingData;
  3243. #if defined(CLIENT_DLL) || defined(GAME_DLL)
  3244. // Contains Armory data key->localization string mappings
  3245. ArmoryStringDict_t m_dictArmoryItemTypesDataStrings;
  3246. ArmoryStringDict_t m_dictArmoryItemClassesDataStrings;
  3247. ArmoryStringDict_t m_dictArmoryAttributeDataStrings;
  3248. ArmoryStringDict_t m_dictArmoryItemDataStrings;
  3249. // Used for delaying the parsing of the item schema until its safe to swap out the back end data.
  3250. IDelayedSchemaData *m_pDelayedSchemaData;
  3251. #endif
  3252. CUtlVector< CEconItemDefinition * > m_vecBundles; // A cached list of all bundles
  3253. static CUniformRandomStream m_RandomStream; // Random stream for item generation.
  3254. bool m_bSchemaParsingItems;
  3255. };
  3256. extern CEconItemSchema & GEconItemSchema();
  3257. //-----------------------------------------------------------------------------
  3258. // CSchemaFieldHandle
  3259. //-----------------------------------------------------------------------------
  3260. template < class T >
  3261. class CSchemaFieldHandle
  3262. {
  3263. public:
  3264. explicit CSchemaFieldHandle( const char *szName )
  3265. : m_szName( szName )
  3266. {
  3267. m_pRef = GetTypedRef();
  3268. m_unSchemaGeneration = GEconItemSchema().GetResetCount();
  3269. #if _DEBUG
  3270. m_unVersion_Debug = GEconItemSchema().GetVersion();
  3271. #endif
  3272. }
  3273. operator const T *( void ) const
  3274. {
  3275. uint32 unSchemaGeneration = GEconItemSchema().GetResetCount();
  3276. if ( m_unSchemaGeneration != unSchemaGeneration )
  3277. {
  3278. m_pRef = GetTypedRef();
  3279. m_unSchemaGeneration = unSchemaGeneration;
  3280. #if _DEBUG
  3281. m_unVersion_Debug = GEconItemSchema().GetVersion();
  3282. #endif
  3283. }
  3284. #if _DEBUG
  3285. Assert( m_unVersion_Debug == GEconItemSchema().GetVersion() );
  3286. #endif
  3287. return m_pRef;
  3288. }
  3289. const T *operator->( void ) const
  3290. {
  3291. return static_cast<const T *>( *this );
  3292. }
  3293. const char *GetName( void ) const
  3294. {
  3295. return m_szName;
  3296. }
  3297. private:
  3298. const T *GetTypedRef() const;
  3299. private:
  3300. const char *m_szName;
  3301. mutable const T *m_pRef;
  3302. mutable uint32 m_unSchemaGeneration;
  3303. #if _DEBUG
  3304. mutable uint32 m_unVersion_Debug;
  3305. #endif
  3306. };
  3307. template < >
  3308. inline const CEconColorDefinition *CSchemaFieldHandle<CEconColorDefinition>::GetTypedRef( void ) const
  3309. {
  3310. return GEconItemSchema().GetColorDefinitionByName( m_szName );
  3311. }
  3312. template < >
  3313. inline const CEconItemAttributeDefinition *CSchemaFieldHandle<CEconItemAttributeDefinition>::GetTypedRef( void ) const
  3314. {
  3315. return GEconItemSchema().GetAttributeDefinitionByName( m_szName );
  3316. }
  3317. template < >
  3318. inline const CEconItemDefinition *CSchemaFieldHandle<CEconItemDefinition>::GetTypedRef( void ) const
  3319. {
  3320. return GEconItemSchema().GetItemDefinitionByName( m_szName );
  3321. }
  3322. template < >
  3323. inline const CEconLootListDefinition *CSchemaFieldHandle<CEconLootListDefinition>::GetTypedRef( void ) const
  3324. {
  3325. return GEconItemSchema().GetLootListByName( m_szName );
  3326. }
  3327. typedef CSchemaFieldHandle<CEconColorDefinition> CSchemaColorDefHandle;
  3328. typedef CSchemaFieldHandle<CEconMusicDefinition> CSchemaMusicDefHandle;
  3329. typedef CSchemaFieldHandle<CEconItemAttributeDefinition> CSchemaAttributeDefHandle;
  3330. typedef CSchemaFieldHandle<CEconItemDefinition> CSchemaItemDefHandle;
  3331. typedef CSchemaFieldHandle<CEconLootListDefinition> CSchemaLootListDefHandle;
  3332. // Implementation reliant on earlier class content.
  3333. inline const CEconItemAttributeDefinition *static_attrib_t::GetAttributeDefinition() const
  3334. {
  3335. return GEconItemSchema().GetAttributeDefinition( iDefIndex );
  3336. }
  3337. // Utility function to convert datafile strings to ints.
  3338. int StringFieldToInt( const char *szValue, const char **pValueStrings, int iNumStrings, bool bDontAssert = false );
  3339. int StringFieldToInt( const char *szValue, const CUtlVector<const char *>& vecValueStrings, bool bDontAssert = false );
  3340. // Helper to get a sticker attribute at a slot
  3341. // while only doing the schema lookup once.
  3342. enum EStickerAttributeType
  3343. {
  3344. k_EStickerAttribute_ID,
  3345. k_EStickerAttribute_Wear,
  3346. k_EStickerAttribute_Scale,
  3347. k_EStickerAttribute_Rotation,
  3348. k_EStickerAttribute_Count,
  3349. };
  3350. const int g_nNumStickerAttrs = 6;
  3351. const CSchemaAttributeDefHandle& GetStickerAttributeDefHandle( int attrNum, EStickerAttributeType type );
  3352. // Helper to get a specific campaign's attribute
  3353. // while only doing the schema lookup once.
  3354. enum ECampaignAttributeType
  3355. {
  3356. k_ECampaignAttribute_CompletionBitfield,
  3357. k_ECampaignAttribute_LastCompletedQuest,
  3358. };
  3359. const int g_nNumCampaigns = 8; // 1-based! first campaign is 1, last campaign is g_nNumCampaigns
  3360. const CSchemaAttributeDefHandle& GetCampaignAttributeDefHandle( int nCampaignID, ECampaignAttributeType type );
  3361. // Share some code between schema initialization checks and the client-only icon building process so we can warn about missing icons
  3362. extern const uint32 g_unNumWearBuckets;
  3363. uint64 Helper_GetAlternateIconKeyForWeaponPaintWearItem( item_definition_index_t nDefIdx, uint32 nPaintId, uint32 nWear );
  3364. uint64 Helper_GetAlternateIconKeyForTintedStickerItem( uint32 nStickerKitID, uint32 unTintID );
  3365. #endif //ECONITEMSCHEMA_H