Начинающий
- Статус
- Оффлайн
- Регистрация
- 2 Мар 2024
- Сообщения
- 346
- Реакции
- 5
спижено с 1 дс сервера:
#include "silent_aim.hxx"
#include <engine/index/index.hxx>
#include <additional/config/config.hxx>
#include <engine/enums/enums.hxx>
auto features::silent_aim::hook( ) -> void
{
if ( !config::silent_aim::enabled ) return;
std::lock_guard<std::mutex> lock( engine::players_mutex );
engine::math::f_vector2d screen_center = { ( float )engine::math::width / 2.0f, ( float )engine::math::height / 2.0f };
float closest_dist = FLT_MAX;
uintptr_t target_mesh = 0;
uintptr_t target_actor = 0;
for ( auto& p : engine::players )
{
if ( !p.actor || !p.mesh ) continue;
engine::functions::u_skeletal_mesh_component skeletal_mesh_component( p.mesh );
engine::math::f_vector head_location = skeletal_mesh_component.bone_location( engine::enums::e_fort_body_parts::head );
engine::math::f_vector2d project_head = engine::functions::project_world_to_screen( head_location );
if ( !engine::math::in_screen( project_head ) ) continue;
if ( project_head.x == 0.f && project_head.y == 0.f ) continue;
float dx = project_head.x - screen_center.x;
float dy = project_head.y - screen_center.y;
float dist = sqrtf( dx * dx + dy * dy );
if ( dist < config::silent_aim::field_of_view && dist < closest_dist )
{
closest_dist = dist;
target_mesh = p.mesh;
target_actor = p.actor;
}
}
config::silent_aim::bind.update( );
if ( !target_mesh || !target_actor ) return;
if ( !config::silent_aim::bind.enabled ) return;
uintptr_t current_weapon = driver->read<uintptr_t>( engine::index->acknowledged_pawn + engine::offsets::a_fort_pawn::current_weapon );
if ( !current_weapon ) return;
engine::functions::u_skeletal_mesh_component target_skel( target_mesh );
engine::math::f_vector target_position = target_skel.bone_location( engine::enums::e_fort_body_parts::head );
engine::math::f_vector camera_location = engine::math::camera::location;
engine::math::f_vector direction = {
target_position.x - camera_location.x,
target_position.y - camera_location.y,
target_position.z - camera_location.z
};
float len = sqrtf( direction.x * direction.x + direction.y * direction.y + direction.z * direction.z );
if ( len == 0.f ) return;
direction.x /= len;
direction.y /= len;
direction.z /= len;
float projectile_speed = driver->read<float>( current_weapon + engine::offsets::ProjectileSpeed );
engine::math::f_vector scaled_velocity = {
direction.x * projectile_speed,
direction.y * projectile_speed,
direction.z * projectile_speed
};
driver->write<engine::math::f_vector>( current_weapon + WEAPON_PROJECTILE_VELOCITY, scaled_velocity );
driver->write<engine::math::f_vector>( current_weapon + WEAPON_LAST_PROJECTILE_VELOCITY, scaled_velocity );
driver->write<engine::math::f_vector>( current_weapon + WEAPON_FIRE_DIRECTION, direction );
}