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.

43 lines
1.7 KiB

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