-
Автор темы
- #1
C++:
bool AimPlayer::SetupHitboxPoints( LagRecord *record, BoneArray *bones, int index, std::vector< vec3_t > &points ) {
// reset points.
points.clear( );
const model_t *model = m_player->GetModel( );
if ( !model )
return false;
studiohdr_t *hdr = g_csgo.m_model_info->GetStudioModel( model );
if ( !hdr )
return false;
mstudiohitboxset_t *set = hdr->GetHitboxSet( m_player->m_nHitboxSet( ) );
if ( !set )
return false;
mstudiobbox_t *bbox = set->GetHitbox( index );
if ( !bbox )
return false;
// get hitbox scales.
float scale = g_menu.main.aimbot.scale.get( ) / 100.f;
// big inair fix.
if ( !( record->m_pred_flags & FL_ONGROUND ) )
scale = 0.7f;
float bscale = g_menu.main.aimbot.body_scale.get( ) / 100.f;
// these indexes represent boxes.
if ( bbox->m_radius <= 0.f ) {
// convert rotation angle to a matrix.
matrix3x4_t rot_matrix;
g_csgo.AngleMatrix( bbox->m_angle, rot_matrix );
// apply the rotation to the entity input space (local).
matrix3x4_t matrix;
math::ConcatTransforms( bones[ bbox->m_bone ], rot_matrix, matrix );
// extract origin from matrix.
vec3_t origin = matrix.GetOrigin( );
// compute raw center point.
vec3_t center = ( bbox->m_mins + bbox->m_maxs ) / 2.f;
// the feet hiboxes have a side, heel and the toe.
const int HITBOX_RIGHT_FOOT = HITBOX_R_FOOT;
const int HITBOX_LEFT_FOOT = HITBOX_L_FOOT;
if ( index == HITBOX_RIGHT_FOOT || index == HITBOX_LEFT_FOOT ) {
float foot_offset = ( bbox->m_mins.z - center.z ) * 0.875f;
// Invert offset for left foot
if ( index == HITBOX_LEFT_FOOT )
foot_offset *= -1.f;
// Center of foot
points.push_back( { center.x, center.y, center.z + foot_offset } );
if ( g_menu.main.aimbot.multipoint.get( 3 ) ) {
// Heel offset relative to center of hitbox
// (bbox->m_mins.x - center.x) * scale
float heel_offset = ( bbox->m_mins.x - center.x );
if ( scale != 0 )
heel_offset *= scale;
// Toe offset relative to center of hitbox
// (bbox->m_maxs.x - center.x) * scale
float toe_offset = ( bbox->m_maxs.x - center.x );
if ( scale != 0 )
toe_offset *= scale;
// Heel
points.push_back( { center.x + heel_offset, center.y, center.z } );
// Toe
points.push_back( { center.x + toe_offset, center.y, center.z } );
}
}
// nothing to do here we are done.
if ( points.empty( ) )
return false;
// rotate our bbox points by their correct angle
// and convert our points to world space.
for ( auto &p : points ) {
// VectorRotate.
// rotate point by angle stored in matrix.
p = { p.dot( matrix[ 0 ] ), p.dot( matrix[ 1 ] ), p.dot( matrix[ 2 ] ) };
// transform point to world space.
p += origin;
}
}
// these hitboxes are capsules.
else {
float r = bbox->m_radius * scale;
float br = bbox->m_radius * bscale;
vec3_t center = ( bbox->m_mins + bbox->m_maxs ) / 2.f;
if ( index == HITBOX_HEAD ) {
points.push_back( center );
if ( g_menu.main.aimbot.multipoint.get( 0 ) ) {
constexpr float rotation = 0.70710678f;
points.push_back( { bbox->m_maxs.x + ( rotation * r ), bbox->m_maxs.y + ( -rotation * r ), bbox->m_maxs.z } );
points.push_back( { bbox->m_maxs.x, bbox->m_maxs.y, bbox->m_maxs.z + r } );
points.push_back( { bbox->m_maxs.x, bbox->m_maxs.y, bbox->m_maxs.z - r } );
points.push_back( { bbox->m_maxs.x, bbox->m_maxs.y - r, bbox->m_maxs.z } );
CCSGOPlayerAnimState* state = record->m_player->m_PlayerAnimState( );
if ( state && record->m_anim_velocity.length( ) <= 0.1f && record->m_eye_angles.x <= state->m_min_pitch )
points.push_back( { bbox->m_maxs.x - r, bbox->m_maxs.y, bbox->m_maxs.z } );
}
}
else if ( index == HITBOX_BODY ) {
points.push_back( center );
if ( g_menu.main.aimbot.multipoint.get( 2 ) )
points.push_back( { center.x, bbox->m_maxs.y - br, center.z } );
}
else if ( index == HITBOX_PELVIS || index == HITBOX_UPPER_CHEST ) {
points.push_back( { center.x, bbox->m_maxs.y - r, center.z } );
}
else if ( index == HITBOX_THORAX || index == HITBOX_CHEST ) {
points.push_back( center );
if ( g_menu.main.aimbot.multipoint.get( 1 ) ) {
points.push_back( { center.x, bbox->m_maxs.y - r, center.z } );
}
}
else if ( index == HITBOX_R_CALF || index == HITBOX_L_CALF ) {
points.push_back( center );
if ( g_menu.main.aimbot.multipoint.get( 3 ) ) {
points.push_back( { bbox->m_maxs.x - ( bbox->m_radius / 2.f ), bbox->m_maxs.y, bbox->m_maxs.z } );
}
}
else if ( index == HITBOX_R_THIGH || index == HITBOX_L_THIGH ) {
points.push_back( center );
}
else if ( index == HITBOX_R_UPPER_ARM || index == HITBOX_L_UPPER_ARM ) {
points.push_back( { bbox->m_maxs.x + bbox->m_radius, center.y, center.z } );
}
else {
return false;
}
if (points.empty( ) ) {
return false;
}
for ( auto& p : points ) {
math::VectorTransform( p, bones[ bbox->m_bone ], p );
}
}
return true;
}