bool inline FClassnameIs(CBaseEntity *pEntity, const char* szClassname)
{
return !strcmp(pEntity->GetClassname(), szClassname) ? true : false;
}
bool IsEntityBreakable(CBaseEntity* pEntity)
{
#if 0
typedef bool(__thiscall* IsBreakbaleEntity_t)(CBaseEntity*);
IsBreakbaleEntity_t IsBreakbaleEntityFn = (IsBreakbaleEntity_t)FindMemoryPattern(ClientHandle, "55 8B EC 51 56 8B F1 85 F6 74 68");
if (!IsBreakbaleEntityFn)
return false;
return IsBreakbaleEntityFn(pEntity);
#else
// skip null ents and the world ent.
if (!pEntity || !pEntity->index)
return false;
int iHealth = pEntity->GetHealth();
if ((iHealth >= 0 || pEntity->GetMaxHealth() <= 0))//(v2 = pEntity->GetUnknownInt(), result = 1, v2 <= 0)))
{
if (pEntity->GetTakeDamage() != DAMAGE_YES)
{
#ifndef NO_CUSTOM_FIXES
char *NetworkName = pEntity->GetClientClass()->m_pNetworkName;
if (!(NetworkName[1] != 'F' || NetworkName[4] != 'c' || NetworkName[5] != 'B' || NetworkName[9] != 'h'))
//if (*(unsigned*)NetworkName != 0x65724243)
#endif
return false;
}
int CollisionGroup = pEntity->GetCollisionGroup();
//Interfaces::Physprops->GetSurfaceIndex(pEntity->GetModelPtr()->_m_pStudioHdr->GetSurfaceProp())
if (CollisionGroup != COLLISION_GROUP_PUSHAWAY && CollisionGroup != COLLISION_GROUP_BREAKABLE_GLASS && CollisionGroup != COLLISION_GROUP_NONE)
return false;
if (iHealth > 200)
return false;
DWORD pPhysicsInterface = ((DWORD(__cdecl *)(CBaseEntity*, DWORD, DWORD, DWORD, DWORD))AdrOf_IsEntityBreakableCall)(pEntity, 0, IsEntityBreakable_FirstCall_Arg1, IsEntityBreakable_FirstCall_Arg2, 0);
if (pPhysicsInterface)
{
if (((bool(__thiscall*)(DWORD)) *(DWORD*)(*(DWORD*)pPhysicsInterface))(pPhysicsInterface) != PHYSICS_MULTIPLAYER_SOLID)
return false;
}
else
{
#ifdef NO_CUSTOM_FIXES
if (FClassnameIs(pEntity, "func_breakable") || FClassnameIs(pEntity, "func_breakable_surf"))
{
if (FClassnameIs(pEntity, "func_breakable_surf"))
{
// don't try to break it if it has already been broken
if (pEntity->IsBroken())
return false;
}
}
#else
const char *szClassname = pEntity->GetClassname();
if (szClassname[0] == 'f' && szClassname[5] == 'b' && szClassname[13] == 'e')
{
if (szClassname[15] == 's')
{
// don't try to break it if it has already been broken
if (pEntity->IsBroken())
return false;
}
}
#endif
else if (pEntity->PhysicsSolidMaskForEntity() & CONTENTS_PLAYERCLIP)
{
// hostages and players use CONTENTS_PLAYERCLIP, so we can use it to ignore them
return false;
}
}
DWORD pBreakableInterface = ((DWORD(__cdecl *)(CBaseEntity*, DWORD, DWORD, DWORD, DWORD))AdrOf_IsEntityBreakableCall)(pEntity, 0, IsEntityBreakable_SecondCall_Arg1, IsEntityBreakable_SecondCall_Arg2, 0);
if (pBreakableInterface)
{
// Bullets don't damage it - ignore
float DamageModBullet = ((float(__thiscall*)(DWORD)) *(DWORD*)(*(DWORD*)pPhysicsInterface + 0xC))(pBreakableInterface);
if (DamageModBullet <= 0.0f)
return false;
}
}
return true;
#endif
}