pastebin http://pastebin.com/8UzQA17s
or
void DrawESP( CEntity *player, CEntity *localPlayer ) { static Vector duckOffset = Vector( 0.f, 0.f, 53.5f ); // VEC_DUCK_HULL_MAX static Vector standOffset = Vector( 0.f, 0.f, 72.f ); // VEC_HULL_MAX Vector origin; if ( !g_Drawing.WorldToScreen( player->GetAbsOrigin(), origin ) ) { return; } Vector offset = ( player->GetFlags() & FL_DUCKING ) ? duckOffset : standOffset; Vector max = ( player->GetAbsOrigin() + offset ); Vector top; if ( !g_Drawing.WorldToScreen( max, top ) ) { return; } float len = 0.f; int fontIndex = 0; if ( localPlayer ) { len = ( max - localPlayer->GetEyePosition() ).Length(); fontIndex = GetFontIndexByDistance( len ); } Color colour = GameResources()->GetTeamColor( player->GetTeamNum() ); // box esp // inversed delta calc because it's screen coords, and they start from top left corner float boxHeight = ( origin.y - top.y ); float boxHalfWidth = ( boxHeight * .25f ); // ghett0 fix so box has same width when crouching and when standing // 72 / 53.5 = 1.345794392523364 if ( player->GetFlags() & FL_DUCKING ) { boxHalfWidth *= 1.345794392523364f; } Vector box( ( top.x - boxHalfWidth ), top.y, 0.f ); static int layers = 3; // outline g_Drawing.DrawOutlinedRect( ( box.x - 1 ), ( box.y - 1 ), ( ( boxHalfWidth * 2 ) + 2 ), ( boxHeight + 2 ), Color( 0, 0, 0, 255 ) ); g_Drawing.DrawOutlinedRect( ( box.x + 1 ), ( box.y + 1 ), ( ( boxHalfWidth * 2 ) - 2 ), ( boxHeight - 2 ), Color( 0, 0, 0, 255 ) ); // actual coloured box g_Drawing.DrawOutlinedRect( box.x, box.y, ( boxHalfWidth * 2 ), boxHeight, colour ); { // health float health = player->GetHealth(); if ( health > 0 ) { int scale = ( health * 2.55f ); Color patch( 0, 0, 0, 255 ); if ( health > 100 ) { patch.SetColor( 255, 255, 255, 255 ); } // outline g_Drawing.DrawOutlinedRect( ( ( top.x - boxHalfWidth ) - 6 ), ( top.y - 1 ), 4, ( boxHeight + 2 ), Color( 0, 0, 0, 255 ) ); // green bar g_Drawing.DrawFilledRect( ( ( top.x - boxHalfWidth ) - 5 ), top.y, 2, boxHeight, Color( ( 255 - scale ), scale, 0, 255 ) ); // black patch to make the bar appear to grow upwards, couldn't draw an inversed bar cause of unkwn reasons g_Drawing.DrawFilledRect( ( ( top.x - boxHalfWidth ) - 5 ), top.y, 2, ( ( 100 - health ) * ( boxHeight / 100 ) ), Color( 0, 0, 0, 255 ) ); } } { // armor float armor = min( player->GetArmorValue(), 100 ); if ( armor > 0 ) { int scale = ( armor * 2.55f ); Color patch( 85, 85, 85, 255 ); if ( player->HasHelmet() ) { patch.SetColor( 0, 0, 0, 255 ); } // outline g_Drawing.DrawOutlinedRect( ( ( top.x - boxHalfWidth ) - ( 6 + 6 ) ), ( top.y - 1 ), 4, ( boxHeight + 2 ), patch ); // green bar g_Drawing.DrawFilledRect( ( ( top.x - boxHalfWidth ) - ( 5 + 6 ) ), top.y, 2, boxHeight, Color( scale, scale, scale, 255 ) ); // black patch to make the bar appear to grow upwards, couldn't draw an inversed bar cause of unkwn reasons g_Drawing.DrawFilledRect( ( ( top.x - boxHalfWidth ) - ( 5 + 6 ) ), top.y, 2, ( ( 100 - armor ) * ( boxHeight / 100 ) ), patch ); } } // go to right side of box top.x += ( boxHalfWidth + 5 ); top.y -= 4; // name g_Drawing.DrawString( false, fontIndex, top.x, top.y, colour, "%s", GameResources()->GetPlayerName( player->GetIndex() ) ); top.y += ( ( 16 - GetFontIndexByDistance( len ) ) + 1 ); // newline: 16 - font index = height, +1 is for a space in between // weapon CWeapon *weapon = player->GetWeapon(); if ( weapon ) { int id = weapon->GetID(); const char *tmp = CWeaponInfo::GetWeaponAlias( id ); // convert to uppercase char weaponName[0xFF]; strcpy( weaponName, tmp ); char *c = weaponName; while ( *c ) { *c = toupper( *c ); ++c; } g_Drawing.DrawString( false, fontIndex, top.x, top.y, colour, "%s", weaponName ); top.y += ( ( 16 - GetFontIndexByDistance( len ) ) + 1 ); // newline: 16 - font index = height, +1 is for a space in between } }
Comment