bool perebor(cchar Name, cchar ClassName, IEntity * pExp, int& BoneId, Vec3 & vBonePos)
{
if (!pExp->GetCharacter(0)) return false;
ISkeletonPose* pSkeleton = pExp->GetCharacter(0)->GetISkeletonPose();
BoneId = pSkeleton->GetJointIdByName("Bip01 Head");
if (!BoneId) return false;
BonePos = pExp->GetBonePos(pSkeleton, BoneId);
return true;
}
void SilentAim
{
static int fov = 15;
if (perebor(Name, ClassName, Entity, PartId, Pos)) && (pRenderer->IsFov(Pos, fov))
{
pWeapon->SetFiringPos(Pos);
}
}
struct IRenderer {
public:
Vec3 GetViewCamera() { return *(Vec3*)((uintptr_t)this + 0x1740); }
float GetWidth() { return (float)p8call<int(__fastcall*)(PVOID)>(this, 0x330)(this); }
float GetHeight() { return (float)p8call<int(__fastcall*)(PVOID)>(this, 0x338)(this); }
bool ProjectToScreen(SWorldToScreen * pWorldToScreen) { return p8call<bool(__thiscall*)(PVOID, SWorldToScreen*)>(this, 0x380)(this, pWorldToScreen); }
bool WorldToScreen(Vec3 vPos, Vec3 & vOut) {
SWorldToScreen p_WorldToScreen;
p_WorldToScreen.toX = vPos.x;
p_WorldToScreen.toY = vPos.y;
p_WorldToScreen.toZ = vPos.z;
p_WorldToScreen.outX = &vOut.x;
p_WorldToScreen.outY = &vOut.y;
p_WorldToScreen.outZ = &vOut.z;
ProjectToScreen(&p_WorldToScreen);
vOut.x *= (GetWidth() * 0.01f);
vOut.y *= (GetHeight() * 0.01f);
vOut.z *= 1.0f;
return ((vOut.z < 1.0f) && (vOut.x > 0) && (vOut.x < GetWidth()) && (vOut.y > 0) && (vOut.y < GetHeight()));
}
float GetHypotenuse(Vec3 vPos) {
Vec3 p_Screen;
{
float PositionX = 0.f;
float PositionY = 0.f;
float ScreenCenterX = (GetWidth() / 2.0f);
float ScreenCenterY = (GetHeight() / 2.0f);
if (WorldToScreen(vPos, p_Screen) == false) return 9999.0f;
PositionX = p_Screen.x > ScreenCenterX ? p_Screen.x - ScreenCenterX : ScreenCenterX - p_Screen.x;
PositionY = p_Screen.y > ScreenCenterY ? p_Screen.y - ScreenCenterY : ScreenCenterY - p_Screen.y;
return _sqrt(PositionX * PositionX + PositionY * PositionY);
}
return 9999.0f;
}
bool IsFov(Vec3 v_Bone, float f_Fov) {
return GetHypotenuse(v_Bone) < f_Fov * 6;
}
};