@@ -1192,6 +1192,7 @@ static class CRD_Inventory_Manager final : public CAutoGameSystem, public CGameE
11921192 case CRAFT_DELETE:
11931193 return true ;
11941194 case CRAFT_PICKUP_MATERIAL:
1195+ case CRAFT_PICKUP_MATERIAL_ASSIST:
11951196 case CRAFT_BTS:
11961197 case CRAFT_DROP:
11971198 case CRAFT_PROMO:
@@ -1225,6 +1226,7 @@ static class CRD_Inventory_Manager final : public CAutoGameSystem, public CGameE
12251226 case CRAFT_DYNAMIC_PROPERTY_INIT_RETRY:
12261227 return pTask->m_iAccessoryDef != BaseModUI::ItemShowcase::MODE_ITEM_DROP;
12271228 case CRAFT_PICKUP_MATERIAL:
1229+ case CRAFT_PICKUP_MATERIAL_ASSIST:
12281230 // returning false to avoid popping up modal errors during gameplay
12291231 return false ;
12301232 case CRAFT_BTS:
@@ -1348,6 +1350,51 @@ static class CRD_Inventory_Manager final : public CAutoGameSystem, public CGameE
13481350 args.AddToTail ( pTask->m_iAccessoryDef );
13491351 UTIL_RD_SendInventoryCommand ( INVCMD_MATERIAL_PICKUP, args, pTask->m_hResult );
13501352 }
1353+ #endif
1354+ break ;
1355+ case CRAFT_PICKUP_MATERIAL_ASSIST:
1356+ #ifdef RD_7A_DROPS
1357+ {
1358+ RD_Crafting_Material_t eMaterialType = static_cast < RD_Crafting_Material_t >( pTask->m_iAccessoryDef );
1359+ RD_Crafting_Material_Rarity_t eMaterialRarity = g_RD_Crafting_Material_Info[eMaterialType].m_iRarity ;
1360+ const char *szPickupSound = g_RD_Crafting_Material_Rarity_Info[eMaterialRarity].m_szPickupSound ;
1361+
1362+ if ( szPickupSound )
1363+ {
1364+ CLocalPlayerFilter filter;
1365+ C_BaseEntity::EmitSound ( filter, -1 /* SOUND_FROM_LOCAL_PLAYER*/ , szPickupSound );
1366+ }
1367+
1368+ uint32 nCount{};
1369+ pInventory->GetResultItems ( pTask->m_hResult , NULL , &nCount );
1370+ CUtlVector<SteamItemDetails_t> diff;
1371+ diff.AddMultipleToTail ( nCount );
1372+ pInventory->GetResultItems ( pTask->m_hResult , diff.Base (), &nCount );
1373+
1374+ int added = 0 ;
1375+ FOR_EACH_VEC ( diff, i )
1376+ {
1377+ if ( diff[i].m_unFlags & ( k_ESteamItemConsumed | k_ESteamItemRemoved ) )
1378+ {
1379+ continue ;
1380+ }
1381+
1382+ if ( const ItemInstance_t *pCached = GetLocalItemCache ( diff[i].m_itemId ) )
1383+ {
1384+ diff[i].m_unQuantity = MAX ( 0 , int ( diff[i].m_unQuantity ) - pCached->Quantity );
1385+ }
1386+
1387+ if ( diff[i].m_iDefinition == g_RD_Crafting_Material_Info[eMaterialType].m_iItemDef )
1388+ {
1389+ added = diff[i].m_unQuantity ;
1390+ }
1391+ }
1392+
1393+ CUtlVector<int > args;
1394+ args.AddToTail ( eMaterialType );
1395+ args.AddToTail ( added );
1396+ UTIL_RD_SendInventoryCommand ( INVCMD_MATERIAL_PICKUP_ASSIST, args, pTask->m_hResult );
1397+ }
13511398#endif
13521399 break ;
13531400 case CRAFT_BTS:
@@ -2174,7 +2221,8 @@ static class CRD_Inventory_Manager final : public CAutoGameSystem, public CGameE
21742221 }
21752222
21762223 Assert ( eMaterial > RD_CRAFTING_MATERIAL_NONE && eMaterial < NUM_RD_CRAFTING_MATERIAL_TYPES );
2177- if ( eMaterial <= 0 || eMaterial >= NUM_RD_CRAFTING_MATERIAL_TYPES)
2224+ Assert ( g_RD_Crafting_Material_Rarity_Info[g_RD_Crafting_Material_Info[eMaterial].m_iRarity ].m_bCanFindInMission );
2225+ if ( eMaterial <= 0 || eMaterial >= NUM_RD_CRAFTING_MATERIAL_TYPES )
21782226 {
21792227 Warning ( " Cannot pick up crafting material at location %d with out of range type %d!\n " , iLocation, eMaterial );
21802228 return ;
@@ -2206,6 +2254,77 @@ static class CRD_Inventory_Manager final : public CAutoGameSystem, public CGameE
22062254
22072255 m_CraftingMaterialToken[iLocation] = k_SteamItemInstanceIDInvalid;
22082256 // leave m_CraftingMaterialType[iLocation] set
2257+ if ( ItemInstance_t *pConsumed = GetLocalItemCacheForModify ( m_CraftingMaterialToken[iLocation] ) )
2258+ {
2259+ pConsumed->Quantity --;
2260+ }
2261+
2262+ }
2263+
2264+ void PickUpCraftingMaterialAssist ( RD_Crafting_Material_t eMaterial )
2265+ {
2266+ GET_INVENTORY_OR_BAIL;
2267+
2268+ Assert ( eMaterial > RD_CRAFTING_MATERIAL_NONE && eMaterial < NUM_RD_CRAFTING_MATERIAL_TYPES );
2269+ Assert ( g_RD_Crafting_Material_Rarity_Info[g_RD_Crafting_Material_Info[eMaterial].m_iRarity ].m_bCanFindInMission );
2270+ Assert ( g_RD_Crafting_Material_Rarity_Info[g_RD_Crafting_Material_Info[eMaterial].m_iRarity ].m_bAllowPickupAssist );
2271+ if ( eMaterial <= 0 || eMaterial >= NUM_RD_CRAFTING_MATERIAL_TYPES )
2272+ {
2273+ Warning ( " Cannot pick up crafting material for assist with out of range type %d!\n " , eMaterial );
2274+ return ;
2275+ }
2276+
2277+ CUtlVector<ReactiveDropInventory::ItemInstance_t> optin;
2278+ ReactiveDropInventory::GetItemsForSlot ( optin, " crafting_material_beta_opt_in" );
2279+ if ( !rd_crafting_material_pickups.GetBool () || !optin.Count () )
2280+ {
2281+ // we're pretending we don't have any material tokens.
2282+ return ;
2283+ }
2284+
2285+ SteamItemDef_t generate[1 ] = { g_RD_Crafting_Material_Info[eMaterial].m_iRedeemDef };
2286+ SteamItemInstanceID_t consume[1 ] = { k_SteamItemInstanceIDInvalid };
2287+ uint32 one[1 ] = { 1 };
2288+
2289+ CUtlVector<ItemInstance_t> tokens;
2290+ GetItemsForDef ( tokens, g_RD_Crafting_Material_Info[eMaterial].m_iTokenDef );
2291+
2292+ FOR_EACH_VEC ( tokens, i )
2293+ {
2294+ int count = tokens[i].Quantity ;
2295+ for ( int iLocation = 0 ; iLocation < RD_MAX_CRAFTING_MATERIAL_SPAWN_LOCATIONS; iLocation++ )
2296+ {
2297+ if ( m_CraftingMaterialToken[iLocation] == tokens[i].ItemID )
2298+ {
2299+ count--;
2300+ }
2301+ }
2302+
2303+ if ( count > 0 )
2304+ {
2305+ consume[0 ] = tokens[i].ItemID ;
2306+ break ;
2307+ }
2308+ }
2309+
2310+ if ( consume[0 ] == k_SteamItemInstanceIDInvalid )
2311+ {
2312+ // don't have a spare token.
2313+ return ;
2314+ }
2315+
2316+ SteamInventoryResult_t *pResult = AddCraftItemTask ( CRAFT_PICKUP_MATERIAL_ASSIST, eMaterial, consume[0 ] );
2317+ pInventory->ExchangeItems ( pResult, generate, one, 1 , consume, one, 1 );
2318+
2319+ if ( rd_debug_inventory.GetBool () )
2320+ {
2321+ Msg ( " [C] Sent request to pick up %s (assist) (handle: %08x)\n " , g_RD_Crafting_Material_Info[eMaterial].m_szName , *pResult );
2322+ }
2323+
2324+ if ( ItemInstance_t *pConsumed = GetLocalItemCacheForModify ( consume[0 ] ) )
2325+ {
2326+ pConsumed->Quantity --;
2327+ }
22092328 }
22102329#endif
22112330
@@ -3489,6 +3608,15 @@ namespace ReactiveDropInventory
34893608
34903609 s_RD_Inventory_Manager.PickUpCraftingMaterialAtLocation ( iLocation, eMaterial );
34913610 }
3611+ void PickUpCraftingMaterialAssist ( RD_Crafting_Material_t eMaterial )
3612+ {
3613+ if ( engine->IsPlayingDemo () )
3614+ {
3615+ return ;
3616+ }
3617+
3618+ s_RD_Inventory_Manager.PickUpCraftingMaterialAssist ( eMaterial );
3619+ }
34923620 int GetCraftingMaterialsFound ()
34933621 {
34943622 int nCount = 0 ;
0 commit comments