-
Автор темы
- #1
Код:
template <typename T>
std::string to_string_with_precision( const T a_value, const int n = 3 )
{
std::ostringstream out;
out.precision( n );
out << std::fixed << a_value;
return out.str( );
}
void getze_nade( int x, int y, double factor, Color color, float spawn_time, std::string name ) {
render::rect_filled( x - 49, y + 10, 70, 4, { 40, 40, 40, 150 } );
render::rect_filled( x - 49, y + 10, 70 * factor, 4, color );
render::rect( x - 50, y + 9, 72, 6, Color( 25, 25, 25, 150 ) );
// timer
auto text = to_string_with_precision( spawn_time, 2 );
auto size = render::small_pix.size( text );
auto size2 = render::small_pix.size( name );
int center_x = x - 49 + ( 71 - size.m_width ) / 2 + 8;
int center_x2 = x - 49 + ( 71 - size2.m_width ) / 2 - 2;
int center_y = y + 16;
//std::transform( text.begin( ), text.end( ), text.begin( ), ::toupper );
render::small_pix.string( center_x, center_y, colors::white, text, render::ALIGN_CENTER );
render::small_pix.string( center_x2, y - 2, colors::white, name );
}
void Visuals::DrawProjectile(Weapon* ent) {
vec2_t screen;
vec3_t origin = ent->GetAbsOrigin( );
if ( !render::WorldToScreen( origin, screen ) )
return;
Color col = g_menu.main.visuals.proj_color.get(); // fuck this out
col.a( ) = 0xb4;
// draw decoy.
if ( ent->is( HASH( "CDecoyProjectile" ) ) )
render::small_pix.string( screen.x, screen.y, col, XOR( "DECOY" ) );
// draw molotov.
else if ( ent->is( HASH( "CMolotovProjectile" ) ) )
render::small_pix.string( screen.x, screen.y, col, XOR( "MOLLY" ) );
else if ( ent->is( HASH( "CBaseCSGrenadeProjectile" ) ) ) {
const model_t* model = ent->GetModel( );
if ( model ) {
// grab modelname.
std::string name{ ent->GetModel( )->m_name };
if ( name.find( XOR( "flashbang" ) ) != std::string::npos )
render::small_pix.string( screen.x, screen.y, col, XOR( "FLASH" ) );
else if ( name.find( XOR( "fraggrenade" ) ) != std::string::npos ) {
render::small_pix.string( screen.x, screen.y, col, XOR( "FRAG" ) );
}
}
}
// find classes.
else if ( ent->is( HASH( "CInferno" ) ) ) {
Weapon* grenade_entity = reinterpret_cast< Weapon* >( ent );
const auto spawn_time = *( float* )( uintptr_t( grenade_entity ) + 0x20 );
const auto factor = ( ( spawn_time + 7.03125f ) - g_csgo.m_globals->m_curtime ) / 7.03125f;
int red = fmax( fmin( 255 * factor, 255 ), 0 );
int green = fmax( fmin( 255 * ( 1.f - factor ), 255 ), 0 );
if ( spawn_time > 0.f ) { // l3d saves me
/* this avoid rendering when nade is not on the ground */
getze_nade( screen.x, screen.y, factor, Color( 255, 0, 0, 245 ), ( spawn_time + 7.03125f ) - g_csgo.m_globals->m_curtime, "MOLLY" );
}
//render::esp.string( screen.x, screen.y, col, XOR( "FIRE" ) );
}
else if ( ent->is( HASH( "CSmokeGrenadeProjectile" ) ) ) {
Weapon* pSmokeEffect = reinterpret_cast< Weapon* >( ent );
const float spawn_time = game::TICKS_TO_TIME( pSmokeEffect->m_nSmokeEffectTickBegin( ) );
const double reltime = ( ( spawn_time + 17.441 ) - g_csgo.m_globals->m_curtime );
const double factor = reltime / 17.441;
int red = std::fmax( std::fmin( 255 * factor, 255 ), 0 );
int green = std::fmax( std::fmin( 255 * ( 1.f - factor ), 255 ), 0 );
if ( spawn_time > 0.f ) { // l3d saves me
/* this avoid rendering when nade is not on the ground */
getze_nade( screen.x, screen.y, factor, Color( 0, 213, 255, 245 ), ( spawn_time + 17.441 ) - g_csgo.m_globals->m_curtime, "SMOKE" );
}
//render::esp.string( screen.x, screen.y, col, XOR( "SMOKE" ) );
}
}