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

40 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "tf_item_system.h"
  8. #include "econ_item_inventory.h"
  9. #include "tf_item_inventory.h"
  10. //-----------------------------------------------------------------------------
  11. // Purpose: Generate the base item for a class's loadout slot
  12. //-----------------------------------------------------------------------------
  13. item_definition_index_t CTFItemSystem::GenerateBaseItem( baseitemcriteria_t *pCriteria )
  14. {
  15. Assert( pCriteria->iClass != 0 );
  16. Assert( pCriteria->iSlot != LOADOUT_POSITION_INVALID );
  17. // Some slots don't have base items (i.e. were added after launch)
  18. if ( !TFInventoryManager()->SlotContainsBaseItems( GEconItemSchema().GetEquipTypeFromClassIndex( pCriteria->iClass ), pCriteria->iSlot ) )
  19. return INVALID_ITEM_DEF_INDEX;
  20. CItemSelectionCriteria criteria;
  21. criteria.SetQuality( AE_NORMAL );
  22. criteria.SetItemLevel( 1 );
  23. criteria.BAddCondition( "baseitem", k_EOperator_String_EQ, "1", true );
  24. InventoryManager()->AddBaseItemCriteria( pCriteria, &criteria );
  25. int iChosenItem = GenerateRandomItem( &criteria, NULL );
  26. return iChosenItem;
  27. }
  28. //-----------------------------------------------------------------------------
  29. // Purpose:
  30. //-----------------------------------------------------------------------------
  31. CTFItemSystem *TFItemSystem( void )
  32. {
  33. CEconItemSystem *pItemSystem = ItemSystem();
  34. Assert( dynamic_cast<CTFItemSystem *>( pItemSystem ) != NULL );
  35. return (CTFItemSystem *)pItemSystem;
  36. }