Code:
bool WorldToScreenM(float * from, float * to) {
[add_junk /]
WorldToScreenMatrix_t WorldToScreenMatrix;
WorldToScreenMatrix = Nsane.Read<WorldToScreenMatrix_t>(Client + ViewMatrix);
[add_junk /]
float w = 0.0f;
[add_junk /]
to[0] = WorldToScreenMatrix.flMatrix[0][0] * from[0] + WorldToScreenMatrix.flMatrix[0][1] * from[1] + WorldToScreenMatrix.flMatrix[0][2] * from[2] + WorldToScreenMatrix.flMatrix[0][3];
to[1] = WorldToScreenMatrix.flMatrix[1][0] * from[0] + WorldToScreenMatrix.flMatrix[1][1] * from[1] + WorldToScreenMatrix.flMatrix[1][2] * from[2] + WorldToScreenMatrix.flMatrix[1][3];
w = WorldToScreenMatrix.flMatrix[3][0] * from[0] + WorldToScreenMatrix.flMatrix[3][1] * from[1] + WorldToScreenMatrix.flMatrix[3][2] * from[2] + WorldToScreenMatrix.flMatrix[3][3];
[add_junk /]
if (w < 0.01f)
return false;
[add_junk /]
float invw = 1.0f / w;
to[0] *= invw;
to[1] *= invw;
[add_junk /]
int width = (int)(OurWindow.right - OurWindow.left);
int height = (int)(OurWindow.bottom - OurWindow.top);
[add_junk /]
float x = width / 2;
float y = height / 2;
[add_junk /]
x += 0.5 * to[0] * width + 0.5;
y -= 0.5 * to[1] * height + 0.5;
[add_junk /]
to[0] = x + OurWindow.left; // Our Window :) Remember? The RECT Function XPPP
to[1] = y + OurWindow.top;
[add_junk /]
return true;
}
float Get3D(float X, float Y, float Z, float eX, float eY, float eZ)
{
[add_junk /]
return(sqrtf((eX - X) * (eX - X) + (eY - Y) * (eY - Y) + (eZ - Z) * (eZ - Z)));
[add_junk /]
}
void ESP()
{
[add_junk /]
BoxESPEnabledFunction = true;
if (BoxESPEnabled)
{
[add_junk /]
for (int i = 0; i < 32; i++) {
[add_junk /]
EnemyPlayer[i].ReadInfo(i);
TeamPlayer[i].ReadInfo(i);
SimplePlayer.ReadInfo();
[add_junk /]
if (EnemyPlayer[i].TeamNum != 2 && EnemyPlayer[i].TeamNum != 3)
continue;
[add_junk /]
if (EnemyPlayer[i].Dormant)
continue; //Ghost Boxes? No!
[add_junk /]
if (EnemyPlayer[i].Health < 1)
continue; // THERE IS AN NEW UPDATE, 2 is no longer = Dead. I've tested it.
[add_junk /]
float W2SP[3];
if (WorldToScreenM(EnemyPlayer[i].Posi, W2SP))
{
[add_junk /]
if (EnemyPlayer[i].TeamNum != SimplePlayer.TeamNum)
{
[add_junk /]
int distance = Get3D(EnemyPlayer[0].Posi[0], EnemyPlayer[0].Posi[1], EnemyPlayer[0].Posi[2], EnemyPlayer[i].Posi[0], EnemyPlayer[i].Posi[1], EnemyPlayer[i].Posi[2]);
int width1 = 18100 / distance;
int height1 = 41000 / distance;
[add_junk /]
if (EnemyPlayer[i].Flags == 775)
{
width1 = 15950 / distance;
height1 = 33000 / distance;
}
[add_junk /]
int Health = EnemyPlayer[i].Health;
int ArmorValue = EnemyPlayer[i].ArmorValueInt;
[add_junk /]
std::stringstream ss, hp, ap;
ss << (int)distance / 3;
hp << Health;
ap << ArmorValue;
[add_junk /]
char * distanceInfo = new char[ss.str().size() + 1];
strcpy(distanceInfo, ss.str().c_str());
[add_junk /]
char * HealthInfo = new char[hp.str().size() + 1];
strcpy(HealthInfo, hp.str().c_str());
[add_junk /]
char * ArmorInfo = new char[ap.str().size() + 1];
strcpy(ArmorInfo, ap.str().c_str());
[add_junk /]
DrawString("HP:", W2SP[0] + (width1 / 2) + 5, W2SP[1] - height1, BoxR, BoxG, BoxB, pFontSmall);
DrawString(HealthInfo, W2SP[0] + (width1 / 2) + 30, W2SP[1] - height1, BoxR, BoxG, BoxB, pFontSmall);
[add_junk /]
DrawString("AP:", W2SP[0] + (width1 / 2) + 5, W2SP[1] - height1 + 20, BoxR, BoxG, BoxB, pFontSmall);
DrawString(ArmorInfo, W2SP[0] + (width1 / 2) + 30, W2SP[1] - height1 + 20, BoxR, BoxG, BoxB, pFontSmall);
[add_junk /]
DrawString("Dist:", W2SP[0] + (width1 / 2) + 5, W2SP[1] - height1 + 40, BoxR, BoxG, BoxB, pFontSmall);
DrawString(distanceInfo, W2SP[0] + (width1 / 2) + 35, W2SP[1] - height1 + 40, BoxR, BoxG, BoxB, pFontSmall);
[add_junk /]
int playerhealthheight = ((Health * height1) / 100);
int playerhealthwidth = ((Health * width1) / 100);
[add_junk /]
DrawHealthBarHorizontal(W2SP[0] - (width1 / 2), W2SP[1] + 5, width1, 3, playerhealthwidth, BoxR, BoxG, BoxB);
[add_junk /]
CornerBox(W2SP[0] - (width1 / 2), W2SP[1] - height1, width1, height1, BoxR, BoxG, BoxB, 255);
[add_junk /]
delete[] HealthInfo, distanceInfo;
}
}
}
}
}