Начинающий
-
Автор темы
- #1
- float best_head_yaw( void )
- {
- // get a ptr to our local player
- entity_t* local = entity_t::get_local( );
- // lambda function that gets the closest target by fov
- auto get_target_entity = [ & ] ( void )
- {
- // values that we use to compare the entities
- float best_fov = 360.0f;
- int best_target = -1;
- // iterate through the entity_list
- for( int i = 0; i < 64; ++i )
- {
- // find entity
- entity_t* entity = entity_t::get_entity( i );
- // entity is not nullptr, not a team mate, not dormant and is alive
- if( !entity || !entity->passes_sanity_checks( ) )
- continue;
- // get that fov
- float fov_to_entity = csgo.m_math->get_fov( local, entity );
- // some comparisons
- if( fov_to_entity < best_fov )
- {
- best_fov = fov_to_entity;
- best_target = i;
- }
- }
- // ok now we have our entity
- return entity_t::get_entity( best_target );
- };
- // we will require these eye positions
- vec3_t eye_position = local->get_eye_position( );
- vec3_t target_eye_position = get_target_entity( )->get_eye_position( );
- // lets set up some basic values we need
- float best_damage = 100.0f;
- // atan 1 * 4 = 3.1415...rad
- constexpr float calculated_pi = std::atan( 1.0f ) * 4.0f;