-
Автор темы
- #1
C++:
int Aimbot::calc_hit_chance( Player* target, const ang_t angle ) {
constexpr float HITCHANCE_MAX = 100.f;
constexpr int SEED_MAX = 128;
vec3_t end, fwd, right, up, dir, wep_spread;
float inaccuracy, spread;
CGameTrace tr;
int total_hits{};
// get needed directional vectors.
math::AngleVectors( angle, &fwd, &right, &up );
// store off inaccuracy / spread ( these functions are quite intensive and we only need them once ).
inaccuracy = g_cl.m_weapon->GetInaccuracy( );
spread = g_cl.m_weapon->GetSpread( );
// iterate all possible seeds.
for ( int i{ 0 }; i < SEED_MAX; i++ ) {
// get spread.
wep_spread = g_cl.m_weapon->CalculateSpread( i, inaccuracy, spread );
vec3_t calc_spread;
calc_spread.x = ((right.x * wep_spread.x) + fwd.x) + (up.x * wep_spread.y);
calc_spread.y = ((right.y * wep_spread.x) + fwd.y) + (up.y * wep_spread.y);
calc_spread.z = ((right.z * wep_spread.x) + fwd.z) + (up.z * wep_spread.y);
const float spread_multiplier = 1.0 / (std::sqrt(((calc_spread.x * calc_spread.x) + (calc_spread.y * calc_spread.y)) + (calc_spread.z * calc_spread.z)) + 0.00000011920929f);
vec3_t v229;
v229.x = spread_multiplier * calc_spread.x;
v229.y = spread_multiplier * calc_spread.y;
v229.z = spread_multiplier * calc_spread.z;
// get spread direction.
dir = ( fwd + ( right * wep_spread.x ) + ( up * wep_spread.x ) );
dir = ( fwd + ( right * wep_spread.y ) + ( up * wep_spread.y ) );
dir = ( fwd + ( right * wep_spread.z ) + ( up * wep_spread.z ) );
// get end of trace.
end = start + ( v229 * g_cl.m_weapon_info->m_range );
float dmg{ 0.f };
int hitbox{ -1 };
int remain_pen{ -1 };
int hit_group{ -1 };
bool dont_care{};
if( g_auto_wall.get( )->fire_bullet(
g_cl.m_weapon,
v229,
dont_care,
dmg,
remain_pen,
hit_group,
hitbox,
target,
g_cl.m_weapon_info->m_range,
g_cl.m_shoot_pos ) ) {
++total_hits;
}
}
}
Последнее редактирование: