-
Автор темы
- #1
I was trying to make ViewModel (Weapon) chams but failed and made attachment chams without trying LOL
Base Used: asphyxia
Note; I'm using a custom version of asphyxia, I've written about 60% of the code so I won't give source until it's finished completely.
Here is my post on the asphyxia github
Base Used: asphyxia
Note; I'm using a custom version of asphyxia, I've written about 60% of the code so I won't give source until it's finished completely.
Here is my post on the asphyxia github
Пожалуйста, авторизуйтесь для просмотра ссылки.
Attachment Chams (chams.cpp):
bool F::VISUALS::CHAMS::OnDrawObject(void* pAnimatableSceneObjectDesc, void* pDx11, CMeshData* arrMeshDraw, int nDataCount, void* pSceneView, void* pSceneLayer, void* pUnk, void* pUnk2)
{
if (!bInitialized)
return false;
if (!C_GET(bool, Vars.bVisualChams))
return false;
if (arrMeshDraw == nullptr)
return false;
if (arrMeshDraw->pSceneAnimatableObject == nullptr)
return false;
CBaseHandle hOwner = arrMeshDraw->pSceneAnimatableObject->hOwner;
auto pEntity = I::GameResourceService->pGameEntitySystem->Get<C_BaseEntity>(hOwner);
if (pEntity == nullptr)
return false;
SchemaClassInfoData_t* pClassInfo;
pEntity->GetSchemaClassInfo(&pClassInfo);
if (pClassInfo == nullptr)
return false;
// Handle player chams
if (CRT::StringCompare(pClassInfo->szName, CS_XOR("C_CSPlayerPawn")) == 0)
{
auto pPlayerPawn = I::GameResourceService->pGameEntitySystem->Get<C_CSPlayerPawn>(hOwner);
if (pPlayerPawn == nullptr)
return false;
bool bIsLocalPlayer = (pPlayerPawn == SDK::LocalPawn);
// Include local player in the chams rendering if the checkbox is checked
if (!C_GET(bool, Vars.bRenderLocalPlayerChams) && bIsLocalPlayer)
return false;
// Include enemies in the chams rendering
if (!bIsLocalPlayer && !pPlayerPawn->IsOtherEnemy(SDK::LocalPawn))
return false;
// Check if the entity is alive or if we should render chams on ragdolls
if (pPlayerPawn->GetHealth() <= 0 && !C_GET(bool, Vars.bRenderChamsOnRagdolls))
return false;
return OverrideMaterial(pAnimatableSceneObjectDesc, pDx11, arrMeshDraw, nDataCount, pSceneView, pSceneLayer, pUnk, pUnk2);
}
// Handle weapon chams for local player
if (C_GET(bool, Vars.bVisualChamsWeapons) && pEntity->IsWeapon())
{
auto pOwnerEntity = I::GameResourceService->pGameEntitySystem->Get<C_BaseEntity>(pEntity->GetOwnerHandle());
if (pOwnerEntity && pOwnerEntity == SDK::LocalPawn)
{
return OverrideMaterial(pAnimatableSceneObjectDesc, pDx11, arrMeshDraw, nDataCount, pSceneView, pSceneLayer, pUnk, pUnk2);
}
}
return false;
}
bool F::VISUALS::CHAMS::OverrideMaterial(void* pAnimatableSceneObjectDesc, void* pDx11, CMeshData* arrMeshDraw, int nDataCount, void* pSceneView, void* pSceneLayer, void* pUnk, void* pUnk2)
{
const auto oDrawObject = H::hkDrawObject.GetOriginal();
const CustomMaterial_t customMaterial = arrMaterials[C_GET(int, Vars.nVisualChamMaterial)];
auto pEntity = I::GameResourceService->pGameEntitySystem->Get<C_BaseEntity>(arrMeshDraw->pSceneAnimatableObject->hOwner);
if (pEntity == nullptr)
return false;
SchemaClassInfoData_t* pClassInfo;
pEntity->GetSchemaClassInfo(&pClassInfo);
if (pClassInfo == nullptr)
return false;
// Handle player chams
if (CRT::StringCompare(pClassInfo->szName, CS_XOR("C_CSPlayerPawn")) == 0)
{
auto pPlayerPawn = I::GameResourceService->pGameEntitySystem->Get<C_CSPlayerPawn>(arrMeshDraw->pSceneAnimatableObject->hOwner);
if (pPlayerPawn == nullptr)
return false;
bool bIsLocalPlayer = (pPlayerPawn == SDK::LocalPawn);
// Apply IgnoreZ material and color
if (C_GET(bool, Vars.bVisualChamsIgnoreZ))
{
arrMeshDraw->pMaterial = customMaterial.pMaterialInvisible;
arrMeshDraw->colValue = bIsLocalPlayer ? C_GET(Color_t, Vars.colLocalChamsIgnoreZ) : C_GET(Color_t, Vars.colEnemyChamsIgnoreZ);
oDrawObject(pAnimatableSceneObjectDesc, pDx11, arrMeshDraw, nDataCount, pSceneView, pSceneLayer, pUnk, pUnk2);
}
// Apply visible material and color
arrMeshDraw->pMaterial = customMaterial.pMaterial;
arrMeshDraw->colValue = bIsLocalPlayer ? C_GET(Color_t, Vars.colLocalChams) : C_GET(Color_t, Vars.colEnemyChams);
}
else if (C_GET(bool, Vars.bVisualChamsWeapons) && pEntity->IsWeapon())
{
auto pOwnerEntity = I::GameResourceService->pGameEntitySystem->Get<C_BaseEntity>(pEntity->GetOwnerHandle());
if (pOwnerEntity && pOwnerEntity == SDK::LocalPawn)
{
// Apply weapon material and color for local player
arrMeshDraw->pMaterial = customMaterial.pMaterial;
arrMeshDraw->colValue = C_GET(Color_t, Vars.colWeaponChams);
}
}
oDrawObject(pAnimatableSceneObjectDesc, pDx11, arrMeshDraw, nDataCount, pSceneView, pSceneLayer, pUnk, pUnk2);
return true;
}