added changer
This commit is contained in:
@@ -138,6 +138,8 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\CAndromedaClient.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\CAndromedaGUI.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryChanger.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryItemsManager.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Features\CVisual\CVisual.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Fonts\CFont.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Fonts\CFontManager.cpp" />
|
||||
@@ -163,6 +165,7 @@
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_AntiTamper.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_CreateMove.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_CreateSwapChain.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_EquipItemInLoadout.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_FireEventClientSide.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_FrameStageNotify.cpp" />
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_GetMatricesForView.cpp" />
|
||||
@@ -254,6 +257,8 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\CAndromedaClient.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\CAndromedaGUI.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryChanger.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryItemsManager.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Features\CVisual\CVisual.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Fonts\CFont.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Fonts\CFontManager.hpp" />
|
||||
@@ -343,6 +348,7 @@
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_AntiTamper.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_CreateMove.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_CreateSwapChain.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_EquipItemInLoadout.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_FireEventClientSide.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_FrameStageNotify.hpp" />
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_GetMatricesForView.hpp" />
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
<Filter Include="Andromeda-CS2-Base\AndromedaClient\Features">
|
||||
<UniqueIdentifier>{eafcd62e-e607-498c-8634-0be5feeec9ae}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger">
|
||||
<UniqueIdentifier>{fe55cde6-ca84-4245-b799-edaad8c9c80d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Andromeda-CS2-Base\DllLauncher.cpp">
|
||||
@@ -465,6 +468,15 @@
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_IsLoadoutAllowed.cpp">
|
||||
<Filter>Andromeda-CS2-Base\CS2\Hook</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryChanger.cpp">
|
||||
<Filter>Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryItemsManager.cpp">
|
||||
<Filter>Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Andromeda-CS2-Base\CS2\Hook\Hook_EquipItemInLoadout.cpp">
|
||||
<Filter>Andromeda-CS2-Base\CS2\Hook</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Andromeda-CS2-Base\DllLauncher.hpp">
|
||||
@@ -1109,5 +1121,14 @@
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_IsLoadoutAllowed.hpp">
|
||||
<Filter>Andromeda-CS2-Base\CS2\Hook</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryChanger.hpp">
|
||||
<Filter>Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger\CInventoryItemsManager.hpp">
|
||||
<Filter>Andromeda-CS2-Base\AndromedaClient\Features\CInventoryChanger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Andromeda-CS2-Base\CS2\Hook\Hook_EquipItemInLoadout.hpp">
|
||||
<Filter>Andromeda-CS2-Base\CS2\Hook</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <AndromedaClient/Fonts/CFontManager.hpp>
|
||||
#include <AndromedaClient/Render/CRenderStackSystem.hpp>
|
||||
#include <AndromedaClient/Features/CVisual/CVisual.hpp>
|
||||
#include <AndromedaClient/Features/CInventoryChanger/CInventoryChanger.hpp>
|
||||
|
||||
#include <GameClient/CEntityCache/CEntityCache.hpp>
|
||||
|
||||
@@ -22,12 +23,12 @@ auto CAndromedaClient::OnInit() -> void
|
||||
|
||||
auto CAndromedaClient::OnFrameStageNotify( int FrameStage ) -> void
|
||||
{
|
||||
|
||||
GetInventoryChanger()->OnFrameStageNotify( FrameStage );
|
||||
}
|
||||
|
||||
auto CAndromedaClient::OnFireEventClientSide( IGameEvent* pGameEvent ) -> void
|
||||
{
|
||||
|
||||
GetInventoryChanger()->OnFireEventClientSide( pGameEvent );
|
||||
}
|
||||
|
||||
auto CAndromedaClient::OnAddEntity( CEntityInstance* pInst , CHandle handle ) -> void
|
||||
|
||||
+485
@@ -0,0 +1,485 @@
|
||||
#include "CInventoryChanger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <Fnv1a/Hash_Fnv1a_Constexpr.hpp>
|
||||
|
||||
#include <CS2/SDK/SDK.hpp>
|
||||
#include <CS2/SDK/Types/CEntityData.hpp>
|
||||
|
||||
#include <CS2/SDK/Interface/IGameEvent.hpp>
|
||||
#include <CS2/SDK/Interface/CSource2Client.hpp>
|
||||
#include <CS2/SDK/Interface/IEngineToClient.hpp>
|
||||
#include <CS2/SDK/Interface/CGameEntitySystem.hpp>
|
||||
#include <CS2/SDK/Interface/CLocalize.hpp>
|
||||
|
||||
#include <CS2/SDK/Econ/CEconItem.hpp>
|
||||
#include <CS2/SDK/Econ/CEconItemSchema.hpp>
|
||||
#include <CS2/SDK/Econ/CEconItemSystem.hpp>
|
||||
#include <CS2/SDK/Econ/CEconItemDefinition.hpp>
|
||||
|
||||
#include <CS2/Protobuf/base_gcmessages.pb.h>
|
||||
|
||||
#include <CS2/Hook/Hook_EquipItemInLoadout.hpp>
|
||||
|
||||
#include <CS2/SDK/Cstrike15/CCSPlayerInventory.hpp>
|
||||
#include <CS2/SDK/Cstrike15/CCSInventoryManager.hpp>
|
||||
|
||||
#include <CS2/SDK/GCSDK/GCSDKTypes/EconItemConstants.hpp>
|
||||
#include <CS2/SDK/GCSDK/GCSDKTypes/ESOCacheEvent.hpp>
|
||||
|
||||
#include <GameClient/CL_Players.hpp>
|
||||
#include <GameClient/CL_Weapons.hpp>
|
||||
#include <GameClient/CL_ItemDefinition.hpp>
|
||||
|
||||
#include <AndromedaClient/Settings/CSettingsJson.hpp>
|
||||
#include <AndromedaClient/Features/CInventoryChanger/CInventoryItemsManager.hpp>
|
||||
|
||||
static CInventoryChanger g_CInventoryChanger{};
|
||||
|
||||
auto CInventoryChanger::OnFrameStageNotify( int FrameStage ) -> void
|
||||
{
|
||||
if ( FrameStage != 6 || !SDK::Interfaces::EngineToClient()->IsInGame() )
|
||||
return;
|
||||
|
||||
auto pLocalInventory = CCSPlayerInventory::Get();
|
||||
|
||||
if ( !pLocalInventory )
|
||||
return;
|
||||
|
||||
const auto steamID = pLocalInventory->GetOwner().ID();
|
||||
const auto pLocalPlayerController = GetCL_Players()->GetLocalPlayerController();
|
||||
|
||||
if ( !pLocalPlayerController )
|
||||
return;
|
||||
|
||||
auto* pLocalPawn = GetCL_Players()->GetLocalPlayerPawn();
|
||||
|
||||
if ( !pLocalPawn )
|
||||
return;
|
||||
|
||||
auto* pWeaponServices = pLocalPawn->m_pWeaponServices();
|
||||
|
||||
if ( !pWeaponServices )
|
||||
return;
|
||||
|
||||
auto* pC_CS2HudModelWeapon = pLocalPawn->GetViewModel();
|
||||
|
||||
if ( !pC_CS2HudModelWeapon )
|
||||
return;
|
||||
|
||||
for ( auto WeaponIndex = 0; WeaponIndex < pWeaponServices->m_hMyWeapons().Count(); ++WeaponIndex )
|
||||
{
|
||||
const auto& Weapon = pWeaponServices->m_hMyWeapons()[WeaponIndex];
|
||||
|
||||
if ( !Weapon.IsValid() )
|
||||
continue;
|
||||
|
||||
auto* pEntity = Weapon.Get();
|
||||
|
||||
if ( !pEntity || !pEntity->IsBasePlayerWeapon() )
|
||||
continue;
|
||||
|
||||
auto pWeapon = reinterpret_cast<C_CSWeaponBase*>( pEntity );
|
||||
|
||||
if ( pWeapon->GetOriginalOwnerXuid() != steamID )
|
||||
continue;
|
||||
|
||||
auto pAttributeContainer = pWeapon->m_AttributeManager();
|
||||
|
||||
if ( !pAttributeContainer )
|
||||
continue;
|
||||
|
||||
auto pWeaponItemView = pAttributeContainer->m_Item();
|
||||
|
||||
if ( !pWeaponItemView )
|
||||
continue;
|
||||
|
||||
auto pWeaponDefinition = pWeaponItemView->GetStaticData();
|
||||
|
||||
if ( !pWeaponDefinition )
|
||||
continue;
|
||||
|
||||
auto pWeaponSceneNode = pWeapon->m_pGameSceneNode();
|
||||
|
||||
if ( !pWeaponSceneNode )
|
||||
continue;
|
||||
|
||||
int id = pAttributeContainer->m_Item()->m_iItemDefinitionIndex();
|
||||
|
||||
if ( id == 43 || id == 44 || id == 45 || id == 46 || id == 47 || id == 48 || id == 49 )
|
||||
continue;
|
||||
|
||||
C_EconItemView* pWeaponInLoadoutItemView = nullptr;
|
||||
|
||||
if ( pWeaponDefinition->IsWeapon() )
|
||||
{
|
||||
for ( int i = 0; i < LOADOUT_SLOT_COUNT; ++i )
|
||||
{
|
||||
auto pItemView = pLocalInventory->GetItemInLoadout( pWeapon->m_iOriginalTeamNumber() , i );
|
||||
|
||||
if ( !pItemView )
|
||||
continue;
|
||||
|
||||
if ( pItemView->m_iItemDefinitionIndex() == pWeaponDefinition->m_nDefIndex() )
|
||||
{
|
||||
pWeaponInLoadoutItemView = pItemView;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pWeaponInLoadoutItemView = pLocalInventory->GetItemInLoadout( pWeapon->m_iOriginalTeamNumber() , pWeaponDefinition->LoadoutSlot() );
|
||||
}
|
||||
|
||||
if ( !pWeaponInLoadoutItemView )
|
||||
continue;
|
||||
|
||||
auto pWeaponInLoadoutDefinition = pWeaponInLoadoutItemView->GetStaticData();
|
||||
|
||||
if ( !pWeaponInLoadoutDefinition )
|
||||
continue;
|
||||
|
||||
const auto isKnife = pWeaponInLoadoutDefinition->IsKnife( false );
|
||||
|
||||
if ( !isKnife && pWeaponInLoadoutDefinition->m_nDefIndex() != pWeaponDefinition->m_nDefIndex() )
|
||||
continue;
|
||||
|
||||
pWeaponItemView->m_bDisallowSOC() = false;
|
||||
pWeaponItemView->m_bRestoreCustomMaterialAfterPrecache() = true;
|
||||
pWeaponItemView->m_iItemID() = pWeaponInLoadoutItemView->m_iItemID();
|
||||
pWeaponItemView->m_iItemIDHigh() = pWeaponInLoadoutItemView->m_iItemIDHigh();
|
||||
pWeaponItemView->m_iItemIDLow() = pWeaponInLoadoutItemView->m_iItemIDLow();
|
||||
pWeaponItemView->m_iItemDefinitionIndex() = pWeaponInLoadoutItemView->m_iItemDefinitionIndex();
|
||||
pWeaponItemView->m_iAccountID() = uint32_t( steamID );
|
||||
|
||||
pWeapon->m_nFallbackPaintKit() = pWeaponInLoadoutItemView->GetCustomPaintKitIndex();
|
||||
|
||||
C_EconItemView_set_attribute_value_by_name( pWeaponItemView , "set item texture prefab" , pWeaponInLoadoutItemView->GetCustomPaintKitIndex() );
|
||||
|
||||
const auto& AddedItems = GetInventoryItemsManager()->GetAddedItems();
|
||||
const auto& Skin = AddedItems.find( pWeaponInLoadoutItemView->m_iItemID() );
|
||||
|
||||
auto* pKnifeModel = pLocalPawn->GetKnifeModel();
|
||||
auto* pCompositeMaterial = reinterpret_cast<CCompositeMaterialOwner*>( (PBYTE)pWeapon + g_CompositeMaterialOffset );
|
||||
|
||||
if ( pCompositeMaterial && m_ApplySkin.find( pCompositeMaterial ) == m_ApplySkin.end() )
|
||||
{
|
||||
uint64_t meshGroupMask = 1;
|
||||
|
||||
if ( Skin != AddedItems.end() )
|
||||
meshGroupMask = 1 + static_cast<uint64_t>( Skin->second.m_bLegacyModel );
|
||||
|
||||
DEV_LOG( "meshGroupMask: %i\n" , meshGroupMask );
|
||||
|
||||
if ( isKnife )
|
||||
{
|
||||
pWeapon->SetModel( pWeaponInLoadoutDefinition->m_pszModelName() );
|
||||
|
||||
if ( pKnifeModel )
|
||||
{
|
||||
pKnifeModel->SetModel( pWeaponInLoadoutDefinition->m_pszModelName() );
|
||||
pKnifeModel->m_pGameSceneNode()->SetMeshGroupMask( meshGroupMask );
|
||||
pKnifeModel->m_pGameSceneNode()->PostDataUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
pWeapon->m_pGameSceneNode()->SetMeshGroupMask( meshGroupMask );
|
||||
pC_CS2HudModelWeapon->m_pGameSceneNode()->SetMeshGroupMask( meshGroupMask );
|
||||
|
||||
std::uint32_t Hash = CUtlStringToken( std::to_string( pWeaponInLoadoutDefinition->m_nDefIndex() ).c_str() ).GetHashCode();
|
||||
|
||||
pWeapon->m_nSubclassID().SetHashCode( Hash );
|
||||
pWeapon->UpdateSubclass();
|
||||
|
||||
pWeapon->UpdateCompositeMaterial( pCompositeMaterial );
|
||||
pWeapon->UpdateSkin();
|
||||
pWeapon->m_pGameSceneNode()->PostDataUpdate();
|
||||
|
||||
auto* pCCSGO_HudWeaponSelection = CCSGOHudElement::Find<CCSGO_HudWeaponSelection>( "HudWeaponSelection" );
|
||||
|
||||
if ( pCCSGO_HudWeaponSelection )
|
||||
{
|
||||
pWeaponItemView->pCEconItemDescription() = 0;
|
||||
|
||||
CCSGO_HudWeaponSelection_ClearHudWeaponIcon(
|
||||
reinterpret_cast<CCSGO_HudWeaponSelection*>(
|
||||
(uintptr_t)pCCSGO_HudWeaponSelection - 0x98 ) , 0 , 0 );
|
||||
}
|
||||
|
||||
m_ApplySkin[pCompositeMaterial] = true;
|
||||
}
|
||||
}
|
||||
|
||||
SetGlove( pLocalInventory , pLocalPawn , pC_CS2HudModelWeapon );
|
||||
SetAgent( pLocalInventory , pLocalPawn );
|
||||
SetMusic( pLocalInventory );
|
||||
}
|
||||
|
||||
auto CInventoryChanger::OnEquipItemInLoadout( int iTeam , int iSlot , uint64_t iItemID ) -> void
|
||||
{
|
||||
auto* pInventoryManager = CCSInventoryManager::Get();
|
||||
|
||||
if ( !pInventoryManager )
|
||||
return;
|
||||
|
||||
auto* pPlayerInventory = CCSPlayerInventory::Get();
|
||||
|
||||
if ( !pPlayerInventory )
|
||||
return;
|
||||
|
||||
const auto& AddedItems = GetInventoryItemsManager()->GetAddedItems();
|
||||
|
||||
if ( AddedItems.find( iItemID ) == AddedItems.end() )
|
||||
return;
|
||||
|
||||
DEV_LOG( "OnEquipItemInLoadout: %i , %i , %lld\n" , iTeam , iSlot , iItemID );
|
||||
|
||||
EquipConfigItem( iTeam , iSlot , iItemID , true );
|
||||
|
||||
auto* pEconItemView = pPlayerInventory->GetItemViewForItem( iItemID );
|
||||
|
||||
if ( !pEconItemView )
|
||||
return;
|
||||
|
||||
auto* pItemInLoadOut = pPlayerInventory->GetItemInLoadout( iTeam , iSlot );
|
||||
|
||||
if ( !pItemInLoadOut )
|
||||
return;
|
||||
|
||||
auto* pItemInLoadoutStaticData = pItemInLoadOut->GetStaticData();
|
||||
|
||||
if ( !pItemInLoadoutStaticData )
|
||||
return;
|
||||
|
||||
if ( pItemInLoadoutStaticData->IsGlove( false ) ||
|
||||
pItemInLoadoutStaticData->IsKnife( false ) ||
|
||||
pItemInLoadoutStaticData->IsAgent( false ) ||
|
||||
pItemInLoadoutStaticData->m_nDefIndex() == pEconItemView->m_iItemDefinitionIndex() )
|
||||
{
|
||||
DEV_LOG( "Skin Cleared #1\n" );
|
||||
|
||||
// force glove
|
||||
if ( pItemInLoadoutStaticData->IsGlove( false ) )
|
||||
m_bApplyGloves = true;
|
||||
|
||||
// force skins and knife reaplly
|
||||
if ( pItemInLoadoutStaticData->m_nDefIndex() == pEconItemView->m_iItemDefinitionIndex() ||
|
||||
pItemInLoadoutStaticData->IsKnife( false ) )
|
||||
{
|
||||
m_ApplySkin.clear();
|
||||
|
||||
DEV_LOG( "Skin Cleared #2\n" );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t defaultItemID = ( std::uint64_t( 0xF ) << 60 ) | pEconItemView->m_iItemDefinitionIndex();
|
||||
|
||||
pInventoryManager->EquipItemInLoadout( iTeam , iSlot , defaultItemID );
|
||||
|
||||
auto* pItemInLoadoutSOCData = pItemInLoadOut->GetSOCData();
|
||||
|
||||
if ( !pItemInLoadoutSOCData )
|
||||
return;
|
||||
|
||||
pPlayerInventory->SOUpdated( pPlayerInventory->GetOwner() , (CSharedObject*)pItemInLoadoutSOCData , GCSDK::eSOCacheEvent_Incremental );
|
||||
}
|
||||
|
||||
auto CInventoryChanger::OnFireEventClientSide( IGameEvent* pGameEvent ) -> void
|
||||
{
|
||||
if ( _strcmpi( pGameEvent->GetName() , XorStr( "item_pickup" ) ) == 0 )
|
||||
{
|
||||
if ( const auto* pItemPickupController = pGameEvent->GetPlayerController( XorStr( "userid" ) ); pItemPickupController )
|
||||
{
|
||||
if ( pItemPickupController == GetCL_Players()->GetLocalPlayerController() )
|
||||
{
|
||||
if ( _strcmpi( pGameEvent->GetString( "item" ) , XorStr( "defuser" ) ) == 0 )
|
||||
m_bApplyGloves = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( _strcmpi( pGameEvent->GetName() , XorStr( "player_death" ) ) == 0 )
|
||||
{
|
||||
if ( auto* pPlayerInventory = CCSPlayerInventory::Get(); pPlayerInventory )
|
||||
{
|
||||
if ( auto* pLocalPlayerPawn = GetCL_Players()->GetLocalPlayerPawn(); pLocalPlayerPawn )
|
||||
{
|
||||
if ( auto* pItemInLoadOut = pPlayerInventory->GetItemInLoadout( pLocalPlayerPawn->m_iTeamNum() , LOADOUT_SLOT_MELEE ); pItemInLoadOut )
|
||||
{
|
||||
if ( auto* pItemInLoadoutStaticData = pItemInLoadOut->GetStaticData(); pItemInLoadoutStaticData )
|
||||
{
|
||||
if ( const auto* pAttackerController = pGameEvent->GetPlayerController( XorStr( "attacker" ) ); pAttackerController )
|
||||
{
|
||||
if ( GetCL_Weapons()->GetLocalWeaponType() == CSWeaponType_t::WEAPONTYPE_KNIFE )
|
||||
{
|
||||
if ( auto* pLocalPlayerController = GetCL_Players()->GetLocalPlayerController(); pLocalPlayerController )
|
||||
{
|
||||
if ( pAttackerController == pLocalPlayerController )
|
||||
{
|
||||
const auto WeaponKillName = pGameEvent->GetString( "weapon" );
|
||||
|
||||
if ( !strcmp( WeaponKillName , "knife" ) )
|
||||
{
|
||||
const auto szKnifeName = GetKnifeIconNameFromDefinitionIndex( pItemInLoadoutStaticData->m_nDefIndex() );
|
||||
|
||||
pGameEvent->SetString( "weapon" , szKnifeName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto CInventoryChanger::SetGlove( CCSPlayerInventory* pInventory , C_CSPlayerPawn* pLocalPawn , C_CS2HudModelWeapon* pViewModel ) -> void
|
||||
{
|
||||
auto& pGloveItemView = pLocalPawn->m_EconGloves();
|
||||
auto* pItemViewLoadout = pInventory->GetItemInLoadout( pLocalPawn->m_iTeamNum() , LOADOUT_SLOT_CLOTHING_HANDS );
|
||||
|
||||
if ( !pItemViewLoadout )
|
||||
return;
|
||||
|
||||
static std::uint8_t uUpdateFrames = 0U;
|
||||
|
||||
if ( pLocalPawn->m_flLastSpawnTimeIndex().m_Value != m_flLastSpawnTime || m_bApplyGloves )
|
||||
{
|
||||
uUpdateFrames = 3;
|
||||
|
||||
{
|
||||
pGloveItemView.m_bDisallowSOC() = false;
|
||||
pGloveItemView.m_bRestoreCustomMaterialAfterPrecache() = true;
|
||||
pGloveItemView.m_iItemDefinitionIndex() = pItemViewLoadout->m_iItemDefinitionIndex();
|
||||
pGloveItemView.m_iItemID() = pItemViewLoadout->m_iItemID();
|
||||
pGloveItemView.m_iItemIDHigh() = pItemViewLoadout->m_iItemIDHigh();
|
||||
pGloveItemView.m_iItemIDLow() = pItemViewLoadout->m_iItemIDLow();
|
||||
pGloveItemView.m_iAccountID() = pItemViewLoadout->m_iAccountID();
|
||||
}
|
||||
|
||||
m_flLastSpawnTime = pLocalPawn->m_flLastSpawnTimeIndex().m_Value;
|
||||
m_bApplyGloves = false;
|
||||
}
|
||||
|
||||
if ( uUpdateFrames > 0 )
|
||||
{
|
||||
pGloveItemView.m_bInitialized() = true;
|
||||
|
||||
pLocalPawn->SetBodyGroup();
|
||||
C_BaseEntity_UpdateBodyGroupChoice( pLocalPawn );
|
||||
pLocalPawn->m_bNeedToReApplyGloves() = true;
|
||||
|
||||
uUpdateFrames--;
|
||||
}
|
||||
}
|
||||
|
||||
auto CInventoryChanger::SetAgent( CCSPlayerInventory* pInventory , C_CSPlayerPawn* pLocalPawn ) -> void
|
||||
{
|
||||
auto* pItemViewLoadout = pInventory->GetItemInLoadout( pLocalPawn->m_iTeamNum() , LOADOUT_SLOT_CLOTHING_CUSTOMPLAYER );
|
||||
|
||||
if ( !pItemViewLoadout )
|
||||
return;
|
||||
|
||||
auto* pEconDefinition = pItemViewLoadout->GetStaticData();
|
||||
|
||||
if ( !pEconDefinition )
|
||||
return;
|
||||
|
||||
if ( !pLocalPawn->m_pGameSceneNode() || !pLocalPawn->m_pGameSceneNode()->GetSkeletonInstance() )
|
||||
return;
|
||||
|
||||
static uint64_t HashAgent = 0;
|
||||
|
||||
const auto pModelName = pEconDefinition->m_pszModelName();
|
||||
|
||||
if ( pModelName )
|
||||
{
|
||||
if ( hash_64_fnv1a_const( pModelName ) == HashAgent )
|
||||
return;
|
||||
|
||||
HashAgent = hash_64_fnv1a_const( pModelName );
|
||||
|
||||
if ( strlen( pModelName ) > 0 )
|
||||
pLocalPawn->SetModel( pModelName );
|
||||
}
|
||||
}
|
||||
|
||||
auto CInventoryChanger::SetMusic( CCSPlayerInventory* pInventory ) -> void
|
||||
{
|
||||
if ( auto* pLocalPlayerController = GetCL_Players()->GetLocalPlayerController(); pLocalPlayerController )
|
||||
{
|
||||
if ( auto* pInventoryServices = pLocalPlayerController->m_pInventoryServices(); pInventoryServices )
|
||||
{
|
||||
auto* pItemViewLoadout = pInventory->GetItemInLoadout( 0 , LOADOUT_SLOT_MUSICKIT );
|
||||
|
||||
if ( !pItemViewLoadout )
|
||||
return;
|
||||
|
||||
auto* pEconDefinition = pItemViewLoadout->GetStaticData();
|
||||
|
||||
if ( !pEconDefinition )
|
||||
return;
|
||||
|
||||
auto* pSOCData = pItemViewLoadout->GetSOCData();
|
||||
|
||||
if ( !pSOCData )
|
||||
return;
|
||||
|
||||
static CSOEconItem g_CSOEconItem;
|
||||
|
||||
pSOCData->SerializeToProtoBufItem( &g_CSOEconItem );
|
||||
|
||||
for ( auto AttributeIndex = 0; AttributeIndex < g_CSOEconItem.attribute_size(); AttributeIndex++ )
|
||||
{
|
||||
const auto& Attribute = g_CSOEconItem.attribute( AttributeIndex );
|
||||
|
||||
if ( Attribute.has_def_index() && Attribute.has_value_bytes() && Attribute.def_index() == ATTRIBUTE_MUSIC_ID )
|
||||
{
|
||||
pInventoryServices->m_unMusicID() = *(uint32_t*)( Attribute.value_bytes().data() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto CInventoryChanger::EquipConfigItem( int iTeam , int iSlot , uint64_t iItemID , bool Equipped ) -> void
|
||||
{
|
||||
DEV_LOG( "EquipConfigItem: %i , %i , %lld , %i\n" , iTeam , iSlot , iItemID , Equipped );
|
||||
|
||||
for ( auto& EquipItem : m_vecEquipItems )
|
||||
{
|
||||
if ( EquipItem.m_iTeam == iTeam && EquipItem.m_iSlot == iSlot )
|
||||
{
|
||||
EquipItem.m_bEquipped = false;
|
||||
}
|
||||
}
|
||||
|
||||
auto ItemHasAdded = false;
|
||||
|
||||
for ( auto& EquipItem : m_vecEquipItems )
|
||||
{
|
||||
if ( EquipItem.m_iItemID == iItemID )
|
||||
{
|
||||
EquipItem.m_bEquipped = Equipped;
|
||||
ItemHasAdded = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !ItemHasAdded )
|
||||
m_vecEquipItems.emplace_back( iTeam , iSlot , iItemID , Equipped );
|
||||
|
||||
if ( Equipped )
|
||||
EquipItemInLoadout_o( CCSInventoryManager::Get() , iTeam , iSlot , iItemID );
|
||||
}
|
||||
|
||||
auto GetInventoryChanger() -> CInventoryChanger*
|
||||
{
|
||||
return &g_CInventoryChanger;
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <Common/Common.hpp>
|
||||
|
||||
class C_CSWeaponBase;
|
||||
class CCSPlayerInventory;
|
||||
class C_CS2HudModelWeapon;
|
||||
class C_CSPlayerPawn;
|
||||
class IGameEvent;
|
||||
class CCompositeMaterialOwner;
|
||||
|
||||
enum LoadOutSlot_t
|
||||
{
|
||||
LOADOUT_SLOT_C4 = 1 ,
|
||||
LOADOUT_SLOT_CLOTHING_APPEARANCE = 46 ,
|
||||
LOADOUT_SLOT_CLOTHING_CUSTOMPLAYER = 38 ,
|
||||
LOADOUT_SLOT_CLOTHING_EYEWEAR = 42 ,
|
||||
LOADOUT_SLOT_CLOTHING_FACEMASK = 40 ,
|
||||
LOADOUT_SLOT_CLOTHING_HANDS = 41 ,
|
||||
LOADOUT_SLOT_CLOTHING_HAT = 43 ,
|
||||
LOADOUT_SLOT_CLOTHING_LOWERBODY = 44 ,
|
||||
LOADOUT_SLOT_CLOTHING_TORSO = 45 ,
|
||||
LOADOUT_SLOT_COUNT = 57 ,
|
||||
LOADOUT_SLOT_EQUIPMENT0 = 32 ,
|
||||
LOADOUT_SLOT_EQUIPMENT1 = 33 ,
|
||||
LOADOUT_SLOT_EQUIPMENT2 = 34 ,
|
||||
LOADOUT_SLOT_EQUIPMENT3 = 35 ,
|
||||
LOADOUT_SLOT_EQUIPMENT4 = 36 ,
|
||||
LOADOUT_SLOT_EQUIPMENT5 = 37 ,
|
||||
LOADOUT_SLOT_FIRST_ALL_CHARACTER = 54 ,
|
||||
LOADOUT_SLOT_FIRST_AUTO_BUY_WEAPON = 0 ,
|
||||
LOADOUT_SLOT_FIRST_COSMETIC = 41 ,
|
||||
LOADOUT_SLOT_FIRST_PRIMARY_WEAPON = 8 ,
|
||||
LOADOUT_SLOT_FIRST_WHEEL_EQUIPMENT = 32 ,
|
||||
LOADOUT_SLOT_FIRST_WHEEL_GRENADE = 26 ,
|
||||
LOADOUT_SLOT_FIRST_WHEEL_WEAPON = 2 ,
|
||||
LOADOUT_SLOT_FLAIR0 = 55 ,
|
||||
LOADOUT_SLOT_GRENADE0 = 26 ,
|
||||
LOADOUT_SLOT_GRENADE1 = 27 ,
|
||||
LOADOUT_SLOT_GRENADE2 = 28 ,
|
||||
LOADOUT_SLOT_GRENADE3 = 29 ,
|
||||
LOADOUT_SLOT_GRENADE4 = 30 ,
|
||||
LOADOUT_SLOT_GRENADE5 = 31 ,
|
||||
LOADOUT_SLOT_HEAVY0 = 20 ,
|
||||
LOADOUT_SLOT_HEAVY1 = 21 ,
|
||||
LOADOUT_SLOT_HEAVY2 = 22 ,
|
||||
LOADOUT_SLOT_HEAVY3 = 23 ,
|
||||
LOADOUT_SLOT_HEAVY4 = 24 ,
|
||||
LOADOUT_SLOT_HEAVY5 = 25 ,
|
||||
LOADOUT_SLOT_INVALID = 4294967295 ,
|
||||
LOADOUT_SLOT_LAST_ALL_CHARACTER = 56 ,
|
||||
LOADOUT_SLOT_LAST_AUTO_BUY_WEAPON = 1 ,
|
||||
LOADOUT_SLOT_LAST_COSMETIC = 41 ,
|
||||
LOADOUT_SLOT_LAST_PRIMARY_WEAPON = 25 ,
|
||||
LOADOUT_SLOT_LAST_WHEEL_EQUIPMENT = 37 ,
|
||||
LOADOUT_SLOT_LAST_WHEEL_GRENADE = 31 ,
|
||||
LOADOUT_SLOT_LAST_WHEEL_WEAPON = 25 ,
|
||||
LOADOUT_SLOT_MELEE = 0 ,
|
||||
LOADOUT_SLOT_MISC0 = 47 ,
|
||||
LOADOUT_SLOT_MISC1 = 48 ,
|
||||
LOADOUT_SLOT_MISC2 = 49 ,
|
||||
LOADOUT_SLOT_MISC3 = 50 ,
|
||||
LOADOUT_SLOT_MISC4 = 51 ,
|
||||
LOADOUT_SLOT_MISC5 = 52 ,
|
||||
LOADOUT_SLOT_MISC6 = 53 ,
|
||||
LOADOUT_SLOT_MUSICKIT = 54 ,
|
||||
LOADOUT_SLOT_PET = 39 ,
|
||||
LOADOUT_SLOT_PROMOTED = 4294967295 ,
|
||||
LOADOUT_SLOT_RIFLE0 = 14 ,
|
||||
LOADOUT_SLOT_RIFLE1 = 15 ,
|
||||
LOADOUT_SLOT_RIFLE2 = 16 ,
|
||||
LOADOUT_SLOT_RIFLE3 = 17 ,
|
||||
LOADOUT_SLOT_RIFLE4 = 18 ,
|
||||
LOADOUT_SLOT_RIFLE5 = 19 ,
|
||||
LOADOUT_SLOT_SECONDARY0 = 2 ,
|
||||
LOADOUT_SLOT_SECONDARY1 = 3 ,
|
||||
LOADOUT_SLOT_SECONDARY2 = 4 ,
|
||||
LOADOUT_SLOT_SECONDARY3 = 5 ,
|
||||
LOADOUT_SLOT_SECONDARY4 = 6 ,
|
||||
LOADOUT_SLOT_SECONDARY5 = 7 ,
|
||||
LOADOUT_SLOT_SMG0 = 8 ,
|
||||
LOADOUT_SLOT_SMG1 = 9 ,
|
||||
LOADOUT_SLOT_SMG2 = 10 ,
|
||||
LOADOUT_SLOT_SMG3 = 11 ,
|
||||
LOADOUT_SLOT_SMG4 = 12 ,
|
||||
LOADOUT_SLOT_SMG5 = 13 ,
|
||||
LOADOUT_SLOT_SPRAY0 = 56
|
||||
};
|
||||
|
||||
class IInventoryChanger
|
||||
{
|
||||
public:
|
||||
virtual void OnFrameStageNotify( int FrameStage ) = 0;
|
||||
virtual void OnEquipItemInLoadout( int iTeam , int iSlot , uint64_t iItemID ) = 0;
|
||||
virtual void OnFireEventClientSide( IGameEvent* pGameEvent ) = 0;
|
||||
};
|
||||
|
||||
class CInventoryChanger final : public IInventoryChanger
|
||||
{
|
||||
public:
|
||||
virtual void OnFrameStageNotify( int FrameStage ) override;
|
||||
virtual void OnEquipItemInLoadout( int iTeam , int iSlot , uint64_t iItemID ) override;
|
||||
virtual void OnFireEventClientSide( IGameEvent* pGameEvent ) override;
|
||||
|
||||
public:
|
||||
auto SetGlove( CCSPlayerInventory* pInventory , C_CSPlayerPawn* pLocalPawn , C_CS2HudModelWeapon* pViewModel ) -> void;
|
||||
auto SetAgent( CCSPlayerInventory* pInventory , C_CSPlayerPawn* pLocalPawn ) -> void;
|
||||
auto SetMusic( CCSPlayerInventory* pInventory ) -> void;
|
||||
|
||||
public:
|
||||
struct EquipItem_t
|
||||
{
|
||||
EquipItem_t() = default;
|
||||
EquipItem_t(int team, int slot, uint64_t itemID, bool equipped)
|
||||
: m_iTeam(team), m_iSlot(slot), m_iItemID(itemID), m_bEquipped(equipped) {}
|
||||
|
||||
int m_iTeam = -1;
|
||||
int m_iSlot = -1;
|
||||
uint64_t m_iItemID = 0;
|
||||
bool m_bEquipped = false;
|
||||
};
|
||||
|
||||
using VecEquipItems_t = std::vector<EquipItem_t>;
|
||||
|
||||
public:
|
||||
auto EquipConfigItem( int iTeam , int iSlot , uint64_t iItemID , bool Equipped = false ) -> void;
|
||||
|
||||
public:
|
||||
inline auto GetEquipConfigItems() -> VecEquipItems_t&
|
||||
{
|
||||
return m_vecEquipItems;
|
||||
}
|
||||
|
||||
public:
|
||||
bool m_bApplyGloves = false;
|
||||
|
||||
// Made public for CInventoryItemsManager access
|
||||
std::unordered_map<CCompositeMaterialOwner* , bool> m_ApplySkin;
|
||||
|
||||
// Refresh all skins (for periodic revalidation)
|
||||
auto RefreshAllSkins() -> void { m_ApplySkin.clear(); }
|
||||
|
||||
private:
|
||||
VecEquipItems_t m_vecEquipItems;
|
||||
float m_flLastSpawnTime = -1.f;
|
||||
int m_nUpdateSkinFrame = 0;
|
||||
};
|
||||
|
||||
auto GetInventoryChanger() -> CInventoryChanger*;
|
||||
+607
@@ -0,0 +1,607 @@
|
||||
#include "CInventoryItemsManager.hpp"
|
||||
|
||||
#include <Common/Helpers/StringHelper.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <CS2/SDK/SDK.hpp>
|
||||
#include <CS2/SDK/Econ/CEconItem.hpp>
|
||||
#include <CS2/SDK/Types/CEntityData.hpp>
|
||||
|
||||
#include <CS2/Protobuf/base_gcmessages.pb.h>
|
||||
|
||||
#include <CS2/SDK/Cstrike15/CCSPlayerInventory.hpp>
|
||||
#include <CS2/SDK/Cstrike15/CCSInventoryManager.hpp>
|
||||
|
||||
#include <CS2/SDK/Econ/CEconItemSchema.hpp>
|
||||
#include <CS2/SDK/Econ/CEconItemSystem.hpp>
|
||||
#include <CS2/SDK/Econ/CEconItemDefinition.hpp>
|
||||
|
||||
#include <CS2/SDK/GCSDK/GCSDKTypes/EconItemConstants.hpp>
|
||||
|
||||
#include <CS2/SDK/Interface/CSource2Client.hpp>
|
||||
#include <CS2/SDK/Interface/CLocalize.hpp>
|
||||
#include <CS2/SDK/Interface/IBaseFileSystem.hpp>
|
||||
|
||||
#include <GameClient/CL_ItemDefinition.hpp>
|
||||
|
||||
#include <AndromedaClient/Features/CInventoryChanger/CInventoryChanger.hpp>
|
||||
#include <AndromedaClient/Settings/CSettingsJson.hpp>
|
||||
|
||||
static CInventoryItemsManager g_CInventoryItemsManager{};
|
||||
|
||||
// Scan all available items WITHOUT adding them to inventory
|
||||
auto CInventoryItemsManager::ScanAllItems() -> void
|
||||
{
|
||||
auto* pItemSchema = SDK::Interfaces::Source2Client()->GetEconItemSystem()->GetEconItemSchema();
|
||||
auto* pPlayerInventory = CCSPlayerInventory::Get();
|
||||
|
||||
if ( !pItemSchema || !pPlayerInventory )
|
||||
return;
|
||||
|
||||
static const std::string SkinIconPath = "panorama/images/econ/default_generated/";
|
||||
|
||||
const CUtlMap<int , CEconItemDefinition*>& vecItems = pItemSchema->GetSortedItemDefinitionMap();
|
||||
const CUtlMap<int , CPaintKit*>& vecPaintKits = pItemSchema->GetPaintKits();
|
||||
const CUtlMap<int , CMusicKit*>& vecMusicKit = pItemSchema->GetMusicKitDefinitions();
|
||||
|
||||
for ( const auto& it : vecItems )
|
||||
{
|
||||
auto* pItem = it.m_value;
|
||||
|
||||
if ( !pItem )
|
||||
continue;
|
||||
|
||||
const bool isWeapon = pItem->IsWeapon();
|
||||
const bool isKnife = pItem->IsKnife( true );
|
||||
const bool isGlove = pItem->IsGlove( true );
|
||||
const bool isAgent = pItem->IsAgent( true );
|
||||
|
||||
if ( !isWeapon && !isKnife && !isGlove && !isAgent )
|
||||
continue;
|
||||
|
||||
// Some items don't have names.
|
||||
const char* itemBaseName = pItem->m_pszItemBaseName();
|
||||
|
||||
if ( !itemBaseName || itemBaseName[0] == '\0' )
|
||||
continue;
|
||||
|
||||
const uint16_t defIdx = pItem->m_nDefIndex();
|
||||
|
||||
DumpedItem_t dumpedItem;
|
||||
|
||||
dumpedItem.m_DefIdx = defIdx;
|
||||
dumpedItem.m_Rarity = pItem->m_nItemRarity();
|
||||
|
||||
// Get human-readable name for UI
|
||||
const char* localizedName = SDK::Interfaces::Localize()->FindSafe( itemBaseName );
|
||||
|
||||
if ( localizedName && localizedName[0] != '\0' && localizedName[0] != '#' )
|
||||
dumpedItem.m_DisplayName = localizedName;
|
||||
else if ( itemBaseName && itemBaseName[0] != '\0' )
|
||||
dumpedItem.m_DisplayName = itemBaseName;
|
||||
else
|
||||
dumpedItem.m_DisplayName = "Unknown Item";
|
||||
|
||||
if ( isWeapon )
|
||||
dumpedItem.m_ItemType = DUMPED_ITEM_TYPE_WEAPON;
|
||||
else if ( isKnife )
|
||||
dumpedItem.m_ItemType = DUMPED_ITEM_TYPE_KNIFE;
|
||||
else if ( isGlove )
|
||||
dumpedItem.m_ItemType = DUMPED_ITEM_TYPE_GLOVE;
|
||||
else if ( isAgent )
|
||||
dumpedItem.m_ItemType = DUMPED_ITEM_TYPE_AGENT;
|
||||
|
||||
if ( strstr( SDK::Interfaces::Localize()->FindSafe( itemBaseName ) , XorStr( "#CSGO_CustomPlayer" ) ) )
|
||||
continue;
|
||||
|
||||
if ( isKnife || isGlove || isAgent )
|
||||
dumpedItem.m_UnusualItem = true;
|
||||
|
||||
if ( isAgent && strstr( itemBaseName , XorStr( "map_based" ) ) )
|
||||
continue;
|
||||
|
||||
if ( isAgent )
|
||||
{
|
||||
std::string IconPath = "panorama/images/econ/characters/";
|
||||
std::string SkinName = itemBaseName + 19;
|
||||
|
||||
IconPath += "customplayer_";
|
||||
IconPath += SkinName;
|
||||
IconPath += "_png.vtex_c";
|
||||
|
||||
if ( SDK::Interfaces::BaseFileSystem()->FileExists( IconPath.c_str() ) )
|
||||
{
|
||||
dumpedItem.m_IconPath = IconPath;
|
||||
dumpedItem.m_PaintKitName = SkinName;
|
||||
}
|
||||
}
|
||||
|
||||
for ( const auto& paintIt : vecPaintKits )
|
||||
{
|
||||
CPaintKit* pPaintKit = paintIt.m_value;
|
||||
|
||||
if ( !pPaintKit || pPaintKit->nID == 0 || pPaintKit->nID == 9001 )
|
||||
continue;
|
||||
|
||||
if ( strstr( pPaintKit->sName , XorStr( "doppler_phase2" ) ) ||
|
||||
strstr( pPaintKit->sName , XorStr( "doppler_phase3" ) ) ||
|
||||
strstr( pPaintKit->sName , XorStr( "doppler_phase4" ) ) )
|
||||
continue;
|
||||
|
||||
bool hasValidIcon = false;
|
||||
std::string IconPath;
|
||||
|
||||
// Weapons
|
||||
if ( !hasValidIcon )
|
||||
{
|
||||
if ( std::string WeaponName = GetWeaponDescFromDefinitionIndex( dumpedItem.m_DefIdx ); WeaponName.size() )
|
||||
{
|
||||
IconPath = SkinIconPath + WeaponName + "_" + std::string( pPaintKit->sName ) + "_light_png.vtex_c";
|
||||
|
||||
if ( SDK::Interfaces::BaseFileSystem()->FileExists( IconPath.c_str() ) )
|
||||
hasValidIcon = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Gloves
|
||||
if ( !hasValidIcon )
|
||||
{
|
||||
if ( std::string GloveName = GetGloveDescFromDefinitionIndex( dumpedItem.m_DefIdx ); GloveName.size() )
|
||||
{
|
||||
IconPath = SkinIconPath + GloveName + "_" + std::string( pPaintKit->sName ) + "_light_png.vtex_c";
|
||||
|
||||
if ( SDK::Interfaces::BaseFileSystem()->FileExists( IconPath.c_str() ) )
|
||||
hasValidIcon = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Knifes
|
||||
if ( !hasValidIcon )
|
||||
{
|
||||
if ( std::string KnifeName = GetKnifeDescFromDefinitionIndex( dumpedItem.m_DefIdx ); KnifeName.size() )
|
||||
{
|
||||
IconPath = SkinIconPath + KnifeName + "_" + std::string( pPaintKit->sName ) + "_light_png.vtex_c";
|
||||
|
||||
if ( SDK::Interfaces::BaseFileSystem()->FileExists( IconPath.c_str() ) )
|
||||
hasValidIcon = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasValidIcon )
|
||||
{
|
||||
DumpedSkin_t dumpedSkin;
|
||||
|
||||
dumpedSkin.m_ID = pPaintKit->nID;
|
||||
dumpedSkin.m_Rarity = pPaintKit->nRarity;
|
||||
dumpedSkin.m_bLegacyModel = pPaintKit->m_use_legacy_model();
|
||||
dumpedSkin.m_PaintKitName = pPaintKit->sName;
|
||||
|
||||
// Get skin name for UI
|
||||
if ( pPaintKit->sDescriptionTag && pPaintKit->sDescriptionTag[0] != '\0' )
|
||||
{
|
||||
const char* skinName = SDK::Interfaces::Localize()->FindSafe( pPaintKit->sDescriptionTag );
|
||||
|
||||
if ( skinName && skinName[0] != '\0' && skinName[0] != '#' )
|
||||
dumpedSkin.m_DisplayName = skinName;
|
||||
else if ( pPaintKit->sName && pPaintKit->sName[0] != '\0' )
|
||||
dumpedSkin.m_DisplayName = pPaintKit->sName;
|
||||
else
|
||||
dumpedSkin.m_DisplayName = "Unknown Skin";
|
||||
}
|
||||
else if ( pPaintKit->sName && pPaintKit->sName[0] != '\0' )
|
||||
{
|
||||
dumpedSkin.m_DisplayName = pPaintKit->sName;
|
||||
}
|
||||
else
|
||||
{
|
||||
dumpedSkin.m_DisplayName = "Default";
|
||||
}
|
||||
|
||||
dumpedSkin.m_IconPath = IconPath;
|
||||
dumpedItem.m_DumpedSkins.emplace_back( dumpedSkin );
|
||||
}
|
||||
}
|
||||
|
||||
m_vecDumpedItems.emplace_back( dumpedItem );
|
||||
}
|
||||
|
||||
// Music kits
|
||||
for ( const auto& it : vecMusicKit )
|
||||
{
|
||||
CMusicKit* pItem = it.m_value;
|
||||
|
||||
if ( !pItem || pItem->nID == 1 || pItem->nID == 2 )
|
||||
continue;
|
||||
|
||||
DumpedItem_t dumpedItem;
|
||||
DumpedSkin_t dumpedSkin;
|
||||
|
||||
dumpedItem.m_DefIdx = EInventoryPrefab_t::INVENTORY_PREFAB_MUSIC_KIT;
|
||||
dumpedItem.m_ItemType = DUMPED_ITEM_TYPE_MUSIC;
|
||||
dumpedItem.m_Rarity = 1;
|
||||
dumpedItem.m_PaintKitName = pItem->sName;
|
||||
|
||||
// Get music kit name
|
||||
if ( pItem->sNameLocToken && pItem->sNameLocToken[0] != '\0' )
|
||||
{
|
||||
const char* musicName = SDK::Interfaces::Localize()->FindSafe( pItem->sNameLocToken );
|
||||
|
||||
if ( musicName && musicName[0] != '\0' && musicName[0] != '#' )
|
||||
dumpedItem.m_DisplayName = musicName;
|
||||
else if ( pItem->sName && pItem->sName[0] != '\0' )
|
||||
dumpedItem.m_DisplayName = pItem->sName;
|
||||
else
|
||||
dumpedItem.m_DisplayName = "Music Kit";
|
||||
}
|
||||
else if ( pItem->sName && pItem->sName[0] != '\0' )
|
||||
{
|
||||
dumpedItem.m_DisplayName = pItem->sName;
|
||||
}
|
||||
else
|
||||
{
|
||||
dumpedItem.m_DisplayName = "Music Kit";
|
||||
}
|
||||
|
||||
std::string SkinPath = "panorama/images/";
|
||||
std::string IconPath = SkinPath + pItem->sInventoryImage;
|
||||
|
||||
IconPath += "_png.vtex_c";
|
||||
|
||||
if ( SDK::Interfaces::BaseFileSystem()->FileExists( IconPath.c_str() ) )
|
||||
dumpedSkin.m_IconPath = IconPath;
|
||||
|
||||
dumpedSkin.m_ID = pItem->nID;
|
||||
dumpedSkin.m_Rarity = 1;
|
||||
dumpedSkin.m_DisplayName = dumpedItem.m_DisplayName;
|
||||
dumpedSkin.m_PaintKitName = dumpedItem.m_PaintKitName;
|
||||
dumpedItem.m_DumpedSkins.emplace_back( dumpedSkin );
|
||||
|
||||
m_vecDumpedItems.emplace_back( dumpedItem );
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy function - now scans items and loads selected skins from config
|
||||
auto CInventoryItemsManager::OnAddAllItems() -> void
|
||||
{
|
||||
ScanAllItems();
|
||||
|
||||
for ( auto& Item : m_vecDumpedItems )
|
||||
{
|
||||
if ( Item.m_ItemType == EDumpedItemType_t::DUMPED_ITEM_TYPE_WEAPON ||
|
||||
Item.m_ItemType == EDumpedItemType_t::DUMPED_ITEM_TYPE_KNIFE ||
|
||||
Item.m_ItemType == EDumpedItemType_t::DUMPED_ITEM_TYPE_GLOVE )
|
||||
{
|
||||
if ( Item.m_DumpedSkins.size() )
|
||||
{
|
||||
for ( auto& Skin : Item.m_DumpedSkins )
|
||||
{
|
||||
AddSelectedSkinToInventory( Item.m_DefIdx , Skin.m_ID , 0.0f , false , 0 , -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Item.m_ItemType == EDumpedItemType_t::DUMPED_ITEM_TYPE_AGENT )
|
||||
{
|
||||
AddSelectedSkinToInventory( Item.m_DefIdx , 0 , 0.0f , false , 0 , -1 );
|
||||
}
|
||||
else if ( Item.m_ItemType == EDumpedItemType_t::DUMPED_ITEM_TYPE_MUSIC )
|
||||
{
|
||||
if ( Item.m_DumpedSkins.size() )
|
||||
{
|
||||
for ( auto& Skin : Item.m_DumpedSkins )
|
||||
{
|
||||
AddMusicToInventory( Item.m_DefIdx , Skin.m_ID );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a specific skin to inventory
|
||||
auto CInventoryItemsManager::AddSelectedSkinToInventory( uint16_t defIdx , int paintKit , float wear , bool equip , int seed , int statTrak ) -> bool
|
||||
{
|
||||
auto* pCCSPlayerInventory = CCSPlayerInventory::Get();
|
||||
|
||||
if ( !pCCSPlayerInventory )
|
||||
return false;
|
||||
|
||||
// Find the item in our scanned list
|
||||
DumpedItem_t* pFoundItem = nullptr;
|
||||
DumpedSkin_t* pFoundSkin = nullptr;
|
||||
|
||||
for ( auto& item : m_vecDumpedItems )
|
||||
{
|
||||
if ( item.m_DefIdx == defIdx )
|
||||
{
|
||||
pFoundItem = &item;
|
||||
|
||||
for ( auto& skin : item.m_DumpedSkins )
|
||||
{
|
||||
if ( skin.m_ID == paintKit )
|
||||
{
|
||||
pFoundSkin = &skin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pFoundItem )
|
||||
return false;
|
||||
|
||||
CEconItem* pItem = CEconItem::Create();
|
||||
|
||||
if ( !pItem )
|
||||
return false;
|
||||
|
||||
auto highestIDs = pCCSPlayerInventory->GetHighestIDs();
|
||||
|
||||
pItem->m_ulID = highestIDs.first + 1;
|
||||
pItem->m_unInventory = highestIDs.second + 1;
|
||||
pItem->m_unAccountID = uint32_t( pCCSPlayerInventory->GetOwner().m_id );
|
||||
pItem->m_unDefIndex = defIdx;
|
||||
|
||||
if ( pFoundItem->m_UnusualItem )
|
||||
pItem->m_nQuality = IQ_UNUSUAL;
|
||||
|
||||
int skinRarity = pFoundSkin ? pFoundSkin->m_Rarity : 0;
|
||||
pItem->m_nRarity = std::clamp( pFoundItem->m_Rarity + skinRarity - 1 , 0 , ( skinRarity == 7 ) ? 7 : 6 );
|
||||
|
||||
if ( paintKit )
|
||||
{
|
||||
pItem->SetPaintKit( static_cast<float>( paintKit ) );
|
||||
}
|
||||
|
||||
// Set wear if specified
|
||||
if ( wear > 0.0f )
|
||||
{
|
||||
pItem->SetPaintWear( wear );
|
||||
}
|
||||
|
||||
// Set seed if specified
|
||||
if ( seed > 0 )
|
||||
{
|
||||
pItem->SetPaintSeed( static_cast<float>( seed ) );
|
||||
}
|
||||
|
||||
// Set StatTrak if specified
|
||||
if ( statTrak >= 0 )
|
||||
{
|
||||
pItem->SetStatTrak( statTrak );
|
||||
}
|
||||
|
||||
if ( pCCSPlayerInventory->AddEconItem( pItem ) )
|
||||
{
|
||||
AddedItem_t Item;
|
||||
|
||||
if( pFoundItem )
|
||||
{
|
||||
Item.m_DefIdx = defIdx;
|
||||
Item.m_PaintKit = paintKit;
|
||||
Item.m_Rarity = pItem->m_nRarity;
|
||||
Item.m_Wear = wear;
|
||||
Item.m_UnusualItem = pFoundItem->m_UnusualItem;
|
||||
Item.m_ItemType = pFoundItem->m_ItemType;
|
||||
|
||||
if ( pFoundItem->m_ItemType == EDumpedItemType_t::DUMPED_ITEM_TYPE_AGENT )
|
||||
{
|
||||
Item.m_bLegacyModel = false;
|
||||
Item.m_PaintKitName = pFoundItem->m_PaintKitName;
|
||||
Item.m_DisplayName = pFoundItem->m_DisplayName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( pFoundSkin )
|
||||
{
|
||||
Item.m_bLegacyModel = pFoundSkin->m_bLegacyModel;
|
||||
Item.m_PaintKitName = pFoundSkin->m_PaintKitName;
|
||||
Item.m_DisplayName = pFoundSkin->m_DisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
Item.m_pEconItem = pItem;
|
||||
|
||||
m_AddedItems[pItem->m_ulID] = Item;
|
||||
}
|
||||
|
||||
// Auto-equip to loadout for both teams
|
||||
auto* pInventoryManager = CCSInventoryManager::Get();
|
||||
|
||||
if ( pInventoryManager && pFoundItem )
|
||||
{
|
||||
// Get item definition to find loadout slot
|
||||
auto* pItemSchema = SDK::Interfaces::Source2Client()->GetEconItemSystem()->GetEconItemSchema();
|
||||
|
||||
if ( pItemSchema )
|
||||
{
|
||||
// Find item definition from map
|
||||
CEconItemDefinition* pItemDef = nullptr;
|
||||
const auto& itemMap = pItemSchema->GetSortedItemDefinitionMap();
|
||||
|
||||
for ( const auto& it : itemMap )
|
||||
{
|
||||
if ( it.m_value && it.m_value->m_nDefIndex() == defIdx )
|
||||
{
|
||||
pItemDef = it.m_value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pItemDef )
|
||||
{
|
||||
int loadoutSlot = pItemDef->LoadoutSlot();
|
||||
|
||||
if ( loadoutSlot >= 0 && equip )
|
||||
{
|
||||
// Equip to T side (team 2) and CT side (team 3)
|
||||
GetInventoryChanger()->OnEquipItemInLoadout( TEAM_TT , loadoutSlot , pItem->m_ulID );
|
||||
GetInventoryChanger()->OnEquipItemInLoadout( TEAM_CT , loadoutSlot , pItem->m_ulID );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEV_LOG( "[Inventory] Added skin: DefIdx=%d, PaintKit=%d\n" , defIdx , paintKit );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto CInventoryItemsManager::AddMusicToInventory( uint16_t defIdx , int MusicId , bool equip ) -> bool
|
||||
{
|
||||
if ( auto* pCCSPlayerInventory = CCSPlayerInventory::Get(); pCCSPlayerInventory )
|
||||
{
|
||||
// Find the item in our scanned list
|
||||
DumpedItem_t* pFoundItem = nullptr;
|
||||
DumpedSkin_t* pFoundSkin = nullptr;
|
||||
|
||||
for ( auto& item : m_vecDumpedItems )
|
||||
{
|
||||
if ( item.m_DefIdx == defIdx )
|
||||
{
|
||||
pFoundItem = &item;
|
||||
|
||||
for ( auto& skin : item.m_DumpedSkins )
|
||||
{
|
||||
if ( skin.m_ID == MusicId )
|
||||
{
|
||||
pFoundSkin = &skin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pFoundItem || !pFoundSkin )
|
||||
return false;
|
||||
|
||||
CEconItem* pItem = CEconItem::Create();
|
||||
|
||||
if ( pItem )
|
||||
{
|
||||
auto highestIDs = pCCSPlayerInventory->GetHighestIDs();
|
||||
|
||||
pItem->m_ulID = highestIDs.first + 1;
|
||||
pItem->m_unInventory = highestIDs.second + 1;
|
||||
pItem->m_unAccountID = uint32_t( pCCSPlayerInventory->GetOwner().m_id );
|
||||
pItem->m_unDefIndex = EInventoryPrefab_t::INVENTORY_PREFAB_MUSIC_KIT;
|
||||
|
||||
pItem->SetMusicId( MusicId );
|
||||
|
||||
if ( pCCSPlayerInventory->AddEconItem( pItem ) )
|
||||
{
|
||||
AddedItem_t Item;
|
||||
{
|
||||
Item.m_DefIdx = EInventoryPrefab_t::INVENTORY_PREFAB_MUSIC_KIT;
|
||||
Item.m_PaintKit = MusicId;
|
||||
Item.m_Rarity = 1;
|
||||
Item.m_UnusualItem = false;
|
||||
Item.m_PaintKitName = pFoundSkin->m_PaintKitName;
|
||||
Item.m_DisplayName = pFoundSkin->m_DisplayName;
|
||||
Item.m_ItemType = DUMPED_ITEM_TYPE_MUSIC;
|
||||
Item.m_pEconItem = pItem;
|
||||
}
|
||||
|
||||
m_AddedItems[pItem->m_ulID] = Item;
|
||||
|
||||
if ( equip )
|
||||
{
|
||||
// Equip to T side (team 2) and CT side (team 3)
|
||||
GetInventoryChanger()->OnEquipItemInLoadout( 0 , LOADOUT_SLOT_MUSICKIT , pItem->m_ulID );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto CInventoryItemsManager::RemoveItemFromInventoryByID( uint64_t ID ) -> bool
|
||||
{
|
||||
if ( IsItemIDAdded( ID ) )
|
||||
{
|
||||
if ( auto* pInventory = CCSPlayerInventory::Get(); pInventory )
|
||||
{
|
||||
auto Item = m_AddedItems.find( ID );
|
||||
{
|
||||
pInventory->RemoveEconItem( Item->second.m_pEconItem );
|
||||
}
|
||||
|
||||
m_AddedItems.erase( ID );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto CInventoryItemsManager::GetSkinName( int paintKitId ) -> std::string
|
||||
{
|
||||
for ( const auto& item : m_vecDumpedItems )
|
||||
{
|
||||
for ( const auto& skin : item.m_DumpedSkins )
|
||||
{
|
||||
if ( skin.m_ID == paintKitId )
|
||||
return skin.m_DisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
auto CInventoryItemsManager::GetWeaponName( uint16_t defIdx ) -> std::string
|
||||
{
|
||||
for ( const auto& item : m_vecDumpedItems )
|
||||
{
|
||||
if ( item.m_DefIdx == defIdx )
|
||||
return item.m_DisplayName;
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
auto CInventoryItemsManager::GetRarityName( int rarity ) -> std::string
|
||||
{
|
||||
switch ( rarity )
|
||||
{
|
||||
case 0: return "Common";
|
||||
case 1: return "Consumer Grade";
|
||||
case 2: return "Industrial Grade";
|
||||
case 3: return "Mil-Spec";
|
||||
case 4: return "Restricted";
|
||||
case 5: return "Classified";
|
||||
case 6: return "Covert";
|
||||
case 7: return "Contraband";
|
||||
case 99: return "Unsual";
|
||||
default: return "Common";
|
||||
}
|
||||
}
|
||||
|
||||
auto CInventoryItemsManager::GetRarityColor( int rarity ) -> ImU32
|
||||
{
|
||||
switch ( rarity )
|
||||
{
|
||||
case 0: return ImColor( 77 , 116 , 85 );
|
||||
case 1: return ImColor( 176 , 195 , 217 );
|
||||
case 2: return ImColor( 94 , 152 , 217 );
|
||||
case 3: return ImColor( 75 , 105 , 255 );
|
||||
case 4: return ImColor( 136 , 71 , 255 );
|
||||
case 5: return ImColor( 211 , 44 , 230 );
|
||||
case 6: return ImColor( 235 , 75 , 75 );
|
||||
case 7: return ImColor( 207 , 106 , 50 );
|
||||
case 99: return ImColor( 255 , 215 , 0 );
|
||||
default: return ImColor( 222 , 214 , 204 );
|
||||
}
|
||||
}
|
||||
|
||||
auto GetInventoryItemsManager() -> CInventoryItemsManager*
|
||||
{
|
||||
return &g_CInventoryItemsManager;
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <Common/Common.hpp>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
#include <ImGui/imgui.h>
|
||||
|
||||
class CCSPlayerInventory;
|
||||
class CEconItem;
|
||||
struct ID3D11ShaderResourceView;
|
||||
|
||||
class CInventoryItemsManager final
|
||||
{
|
||||
public:
|
||||
enum EInventoryPrefab_t : uint32_t
|
||||
{
|
||||
INVENTORY_PREFAB_MUSIC_KIT = 1314 ,
|
||||
INVENTORY_PREFAB_STICKER_KIT = 1209 ,
|
||||
};
|
||||
|
||||
enum EDumpedItemType_t
|
||||
{
|
||||
DUMPED_ITEM_TYPE_NONE ,
|
||||
DUMPED_ITEM_TYPE_WEAPON ,
|
||||
DUMPED_ITEM_TYPE_KNIFE ,
|
||||
DUMPED_ITEM_TYPE_GLOVE ,
|
||||
DUMPED_ITEM_TYPE_AGENT ,
|
||||
DUMPED_ITEM_TYPE_MUSIC,
|
||||
};
|
||||
|
||||
// Made public for UI access
|
||||
struct DumpedSkin_t
|
||||
{
|
||||
int m_ID = 0;
|
||||
int m_Rarity = 0;
|
||||
std::string m_PaintKitName = "";
|
||||
std::string m_DisplayName = ""; // Skin name for UI
|
||||
std::string m_IconPath = ""; // Path to icon for UI
|
||||
bool m_bLegacyModel = false;
|
||||
};
|
||||
|
||||
struct DumpedItem_t
|
||||
{
|
||||
uint16_t m_DefIdx = 0;
|
||||
int m_Rarity = 0;
|
||||
bool m_UnusualItem = false;
|
||||
std::vector<DumpedSkin_t> m_DumpedSkins = {};
|
||||
EDumpedItemType_t m_ItemType = DUMPED_ITEM_TYPE_NONE;
|
||||
std::string m_PaintKitName = "";
|
||||
std::string m_DisplayName = ""; // Item name for UI
|
||||
std::string m_IconPath = ""; // Path to icon for UI
|
||||
};
|
||||
|
||||
struct AddedItem_t
|
||||
{
|
||||
uint16_t m_DefIdx = 0;
|
||||
int m_PaintKit = 0;
|
||||
int m_Rarity = 0;
|
||||
float m_Wear = 0.0f;
|
||||
bool m_UnusualItem = false;
|
||||
bool m_bLegacyModel = false;
|
||||
std::string m_PaintKitName = "";
|
||||
std::string m_DisplayName = ""; // Skin/Item name for UI
|
||||
EDumpedItemType_t m_ItemType = DUMPED_ITEM_TYPE_NONE;
|
||||
CEconItem* m_pEconItem = nullptr;
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<DumpedItem_t> m_vecDumpedItems;
|
||||
std::unordered_map<uint64_t , AddedItem_t> m_AddedItems;
|
||||
|
||||
public:
|
||||
// Scan all available items (does NOT add to inventory)
|
||||
auto ScanAllItems() -> void;
|
||||
|
||||
// Legacy function - now calls ScanAllItems + applies selected skins from config
|
||||
auto OnAddAllItems() -> void;
|
||||
|
||||
// Add a specific selected skin to inventory
|
||||
auto AddSelectedSkinToInventory( uint16_t defIdx , int paintKit , float wear = 0.0f , bool equip = false , int seed = 0 , int statTrak = -1 ) -> bool;
|
||||
|
||||
public:
|
||||
auto AddMusicToInventory( uint16_t defIdx , int MusicId , bool equip = false ) -> bool;
|
||||
|
||||
public:
|
||||
auto RemoveItemFromInventoryByID( uint64_t ID ) -> bool;
|
||||
|
||||
public:
|
||||
inline auto IsItemIDAdded( uint64_t ID ) -> bool
|
||||
{
|
||||
if ( m_AddedItems.find( ID ) == m_AddedItems.end() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
inline auto GetDumpedItems() -> std::vector<DumpedItem_t>&
|
||||
{
|
||||
return m_vecDumpedItems;
|
||||
}
|
||||
|
||||
inline auto GetAddedItems()->std::unordered_map<uint64_t, AddedItem_t>&
|
||||
{
|
||||
return m_AddedItems;
|
||||
}
|
||||
|
||||
// Helper to get skin name from paint kit ID
|
||||
auto GetSkinName( int paintKitId ) -> std::string;
|
||||
|
||||
// Helper to get weapon name from def index
|
||||
auto GetWeaponName( uint16_t defIdx ) -> std::string;
|
||||
|
||||
// Helper to get rarity name
|
||||
auto GetRarityName( int rarity ) -> std::string;
|
||||
|
||||
// Helper to get rarity color
|
||||
auto GetRarityColor( int rarity ) -> ImU32;
|
||||
};
|
||||
|
||||
auto GetInventoryItemsManager() -> CInventoryItemsManager*;
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <CS2/Hook/Hook_UpdateInPVS.hpp>
|
||||
#include <CS2/Hook/Hook_AntiTamper.hpp>
|
||||
#include <CS2/Hook/Hook_IsLoadoutAllowed.hpp>
|
||||
#include <CS2/Hook/Hook_EquipItemInLoadout.hpp>
|
||||
|
||||
static CHook_Loader g_CHook_Loader{};
|
||||
|
||||
@@ -74,7 +75,8 @@ auto CHook_Loader::InstallSecondHook() -> bool
|
||||
// he is no longer needed
|
||||
//{ { XorStr( "Hook::UpdateInPVS" ) , XorStr( "48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B D9 8B F2 48 8B 89 ? ? ? ? 48 8B 01 FF 50 ? 33 FF 48 85 C0 74 ? 48 8B 80 ? ? ? ? EB ? 48 8B C7 39 B8 ? ? ? ? 0F 8F ? ? ? ? 0F B6 48 ? 80 F9" ) , CLIENT_DLL } , &Hook_UpdateInPVS , reinterpret_cast<LPVOID*>( &UpdateInPVS_o ) },
|
||||
{ { XorStr( "Hook::AntiTamper" ) , XorStr( "40 53 41 57 48 83 EC ? 48 89 74 24 ? 48 8B F1" ) , CLIENT_DLL } , &Hook_AntiTamper , reinterpret_cast<LPVOID*>( &AntiTamper_o ) },
|
||||
{ {XorStr("Hook::IsLoadoutAllowed") , XorStr("48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B E9 48 8B 0D ? ? ? ? ? ? ? FF 50") , CLIENT_DLL } ,&Hook_IsLoadoutAllowed , reinterpret_cast<LPVOID*>(&IsLoadoutAllowed_o) , true , true }
|
||||
{ {XorStr("Hook::IsLoadoutAllowed") , XorStr("48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B E9 48 8B 0D ? ? ? ? ? ? ? FF 50") , CLIENT_DLL } ,&Hook_IsLoadoutAllowed , reinterpret_cast<LPVOID*>(&IsLoadoutAllowed_o) , true , true } ,
|
||||
{ { XorStr( "Hook::EquipItemInLoadout" ) , XorStr( "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 89 54 24 ? 57 41 54 41 55 41 56 41 57 48 83 EC ? 0F B7 FA" ) , CLIENT_DLL } ,& Hook_EquipItemInLoadout , reinterpret_cast<LPVOID*>( &EquipItemInLoadout_o ) },
|
||||
};
|
||||
|
||||
return InstallHooks();
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "Hook_EquipItemInLoadout.hpp"
|
||||
|
||||
#include <AndromedaClient/Features/CInventoryChanger/CInventoryChanger.hpp>
|
||||
|
||||
auto Hook_EquipItemInLoadout( CCSInventoryManager* pManager , int iTeam , int iSlot , uint64_t iItemID ) -> void
|
||||
{
|
||||
GetInventoryChanger()->OnEquipItemInLoadout( iTeam , iSlot , iItemID );
|
||||
|
||||
EquipItemInLoadout_o( pManager , iTeam , iSlot , iItemID );
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <CS2/SDK/Cstrike15/CCSInventoryManager.hpp>
|
||||
|
||||
using EquipItemInLoadout_t = void( __fastcall* )( CCSInventoryManager* , int , int , uint64_t );
|
||||
inline EquipItemInLoadout_t EquipItemInLoadout_o = nullptr;
|
||||
|
||||
auto Hook_EquipItemInLoadout( CCSInventoryManager* pManager , int iTeam , int iSlot , uint64_t iItemID ) -> void;
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Hook_SOCacheSubscribed.hpp"
|
||||
|
||||
#include <CS2/SDK/Cstrike15/CCSPlayerInventory.hpp>
|
||||
#include <AndromedaClient/Features/CInventoryChanger/CInventoryItemsManager.hpp>
|
||||
|
||||
auto Hook_SOCacheSubscribed( CCSPlayerInventory* pCSPlayerInventory , GCSDK::SOID_t owner , int64_t unk ) -> void*
|
||||
{
|
||||
@@ -8,7 +9,7 @@ auto Hook_SOCacheSubscribed( CCSPlayerInventory* pCSPlayerInventory , GCSDK::SOI
|
||||
|
||||
if ( pCSPlayerInventory->GetOwner().m_type == owner.m_type && pCSPlayerInventory->GetOwner().m_id == owner.m_id )
|
||||
{
|
||||
|
||||
GetInventoryItemsManager()->OnAddAllItems();
|
||||
}
|
||||
|
||||
return pResult;
|
||||
|
||||
@@ -70,6 +70,7 @@ auto CFunctionList::OnInit() -> bool
|
||||
&CCSGO_HudWeaponSelection_ClearHudWeaponIcon,
|
||||
&C_BaseEntity_GetHitBoxSet,
|
||||
&C_BaseEntity_UpdateBodyGroupChoice,
|
||||
&C_EconItemView_set_attribute_value_by_name,
|
||||
};
|
||||
|
||||
auto Searched = true;
|
||||
|
||||
@@ -142,6 +142,7 @@ public:
|
||||
CBasePattern CCSGO_HudWeaponSelection_ClearHudWeaponIcon = { VmpStr( "CCSGO_HudWeaponSelection::ClearHudWeaponIcon" ) , VmpStr( "E8 ? ? ? ? 8B F8 C6 84 24" ) , CLIENT_DLL , 0 , SEARCH_TYPE_CALL };
|
||||
CBasePattern C_BaseEntity_GetHitBoxSet = { VmpStr( "C_BaseEntity::GetHitBoxSet" ) , VmpStr( "48 89 5C 24 ? 48 89 74 24 ? 57 48 81 EC ? ? ? ? 8B DA 48 8B F9 E8 ? ? ? ? 48 8B F0" ) , CLIENT_DLL , 0 , SEARCH_TYPE_NONE };
|
||||
CBasePattern C_BaseEntity_UpdateBodyGroupChoice = { VmpStr( "C_BaseEntity::UpdateBodyGroupChoice" ) , VmpStr( "E8 ? ? ? ? 4C 8B AC 24 ? ? ? ? 48 8B BC 24" ) , CLIENT_DLL , 0 , SEARCH_TYPE_CALL };
|
||||
CBasePattern C_EconItemView_set_attribute_value_by_name = { VmpStr( "C_EconItemView::set_attribute_value_by_name" ) , VmpStr( "E8 ? ? ? ? 66 41 0F 6E D4" ) , CLIENT_DLL , 0 , SEARCH_TYPE_CALL };
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,11 @@ public:
|
||||
char pad3[0x8]; // no idea
|
||||
char pad4[0x4]; // no idea
|
||||
int nRarity;
|
||||
|
||||
uint8_t m_use_legacy_model()
|
||||
{
|
||||
return *reinterpret_cast<uint8_t*>( (std::uintptr_t)this + 0xAE );
|
||||
}
|
||||
};
|
||||
|
||||
class CMusicKit
|
||||
|
||||
@@ -119,6 +119,7 @@ DECLARATE_CS2_FUNCTION_SDK_FASTCALL( void , CTraceFilter_Constructor , ( CTraceF
|
||||
DECLARATE_CS2_FUNCTION_SDK_FASTCALL( void , CCSGO_HudWeaponSelection_ClearHudWeaponIcon , ( CCSGO_HudWeaponSelection* pCCSGO_HudWeaponSelection , int unk1 , int64_t unk2 ) , ( CCSGO_HudWeaponSelection* , int , int64_t ) , ( pCCSGO_HudWeaponSelection , unk1 , unk2 ) );
|
||||
DECLARATE_CS2_FUNCTION_SDK_FASTCALL( CHitBoxSet* , C_BaseEntity_GetHitBoxSet , ( C_BaseEntity* pC_BaseEntity , uint32_t Index = 0 ) , ( C_BaseEntity* , uint32_t ) , ( pC_BaseEntity , Index ) );
|
||||
DECLARATE_CS2_FUNCTION_SDK_FASTCALL( void , C_BaseEntity_UpdateBodyGroupChoice , ( C_BaseEntity* pC_BaseEntity ) , ( C_BaseEntity* ) , ( pC_BaseEntity ) );
|
||||
DECLARATE_CS2_FUNCTION_SDK_FASTCALL( void , C_EconItemView_set_attribute_value_by_name , ( C_EconItemView* pC_EconItemView , const char* szAttributeName , float flValue ) , ( C_EconItemView* , const char* , float ) , ( pC_EconItemView , szAttributeName , flValue ) );
|
||||
|
||||
// Helpers:
|
||||
|
||||
|
||||
@@ -183,8 +183,7 @@ auto C_BaseEntity::ComputeHitboxSurroundingBox( Vector3& mins , Vector3& maxs )
|
||||
|
||||
auto C_BaseEntity::SetBodyGroup() -> void
|
||||
{
|
||||
C_BaseEntity_SetBodyGroup( this , m_iTeamNum() == TEAM_TT ? 0 : 1 , 1 );
|
||||
C_BaseEntity_UpdateBodyGroupChoice( this );
|
||||
return C_BaseEntity_SetBodyGroup( this , m_iTeamNum() == TEAM_TT ? 0 : 1 , 1 );
|
||||
}
|
||||
|
||||
auto C_BaseEntity::GetBoneIdByName( const char* szName ) -> int
|
||||
@@ -287,6 +286,11 @@ auto C_EconItemView::GetBasePlayerWeaponVData() -> CCSWeaponBaseVData*
|
||||
return C_EconItemView_GetBasePlayerWeaponVData( this );
|
||||
}
|
||||
|
||||
auto C_EconItemView::GetCustomPaintKitIndex() -> int
|
||||
{
|
||||
return C_EconItemView_GetCustomPaintKitIndex( this );
|
||||
}
|
||||
|
||||
auto C_BaseModelEntity::SetModel( const char* szModel ) -> void
|
||||
{
|
||||
return C_BaseModelEntity_SetModel( this , szModel );
|
||||
|
||||
@@ -113,13 +113,6 @@ public:
|
||||
return pBinding;
|
||||
}
|
||||
|
||||
public:
|
||||
auto PostDataUpdate() -> void
|
||||
{
|
||||
VirtualFn( void )( CEntityInstance* , int UpdateType );
|
||||
return vget< Fn >( this , SDK::VMT_Index::CEntityInstance::PostDataUpdate )( this , 1 );
|
||||
}
|
||||
|
||||
public:
|
||||
SCHEMA_OFFSET( "CEntityInstance" , "m_pEntity" , pEntityIdentity , CEntityIdentity* );
|
||||
};
|
||||
@@ -148,6 +141,13 @@ public:
|
||||
auto SetMeshGroupMask( uint64_t meshGroupMask ) -> void;
|
||||
auto GetBonePosition( int32 BoneIndex , Vector3& BonePos ) -> bool;
|
||||
|
||||
public:
|
||||
auto PostDataUpdate() -> void
|
||||
{
|
||||
VirtualFn( void )( CGameSceneNode* , int64_t UpdateType , int64_t unk1 );
|
||||
return vget< Fn >( this , SDK::VMT_Index::CGameSceneNode::PostDataUpdate )( this , 0 , 0 );
|
||||
}
|
||||
|
||||
public:
|
||||
auto GetSkeletonInstance() -> CSkeletonInstance*
|
||||
{
|
||||
@@ -190,6 +190,7 @@ public:
|
||||
auto GetSOCData() -> CEconItem*;
|
||||
auto GetStaticData() -> CEconItemDefinition*;
|
||||
auto GetBasePlayerWeaponVData() -> CCSWeaponBaseVData*;
|
||||
auto GetCustomPaintKitIndex() -> int;
|
||||
|
||||
public:
|
||||
SCHEMA_OFFSET( "C_EconItemView" , "m_bRestoreCustomMaterialAfterPrecache" , m_bRestoreCustomMaterialAfterPrecache , bool );
|
||||
@@ -506,6 +507,9 @@ public:
|
||||
PSCHEMA_OFFSET( "C_EconEntity" , "m_AttributeManager" , m_AttributeManager , C_AttributeContainer );
|
||||
SCHEMA_OFFSET( "C_EconEntity" , "m_OriginalOwnerXuidLow" , m_OriginalOwnerXuidLow , uint32 );
|
||||
SCHEMA_OFFSET( "C_EconEntity" , "m_OriginalOwnerXuidHigh" , m_OriginalOwnerXuidHigh , uint32 );
|
||||
SCHEMA_OFFSET( "C_EconEntity" , "m_nFallbackPaintKit" , m_nFallbackPaintKit , int32 );
|
||||
SCHEMA_OFFSET( "C_EconEntity" , "m_nFallbackSeed" , m_nFallbackSeed , int32 );
|
||||
SCHEMA_OFFSET( "C_EconEntity" , "m_flFallbackWear" , m_flFallbackWear , float32 );
|
||||
|
||||
inline auto GetOriginalOwnerXuid() -> uint64_t
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ static constexpr auto g_CompositeMaterialOffset = 0x608;
|
||||
|
||||
// 48 8D 58 ? 49 89 4B
|
||||
static constexpr auto g_CEconItemSchema_GetSortedItemDefinitionMap = 0x128;
|
||||
static constexpr auto g_CEconItemSchema_GetPaintKits = 0x2E8;
|
||||
static constexpr auto g_CEconItemSchema_GetPaintKits = 0x2F0;
|
||||
|
||||
// E8 ? ? ? ? 48 85 C0 74 ? 48 8B 40 ? 4C 8B C7
|
||||
/*
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace SDK::VMT_Index
|
||||
{
|
||||
GetScreenSize = 60 ,
|
||||
};
|
||||
enum CEntityInstance : uint32_t
|
||||
enum CGameSceneNode : uint32_t
|
||||
{
|
||||
PostDataUpdate = 10 ,
|
||||
PostDataUpdate = 22 ,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user