From 80d9845607058a85c5250aebca1280324b811285 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 5 Sep 2018 23:19:33 +0200 Subject: whole bunch of shit --- internal_rewrite/util.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'internal_rewrite/util.cpp') diff --git a/internal_rewrite/util.cpp b/internal_rewrite/util.cpp index 9bc315f..a4df63d 100644 --- a/internal_rewrite/util.cpp +++ b/internal_rewrite/util.cpp @@ -210,7 +210,7 @@ bool __vectorcall util::intersects_hitbox( vec3_t eye_pos, vec3_t end_pos, vec3_ } // Note: abuse this as much as you can to achieve the full potential it offers. -bool util::hitchance( int target, const vec3_t& angles, int percentage ) { +bool util::hitchance( int target, const vec3_t& angles, int percentage, int hitbox ) { if( g_settings.rage.compensate_spread ) return true; @@ -276,16 +276,32 @@ bool util::hitchance( int target, const vec3_t& angles, int percentage ) { if( !hdr ) return false; matrix3x4 bone_matrix[ 128 ]; - if( !ent->ce()->SetupBones( bone_matrix, 128, 0x100, g_csgo.m_globals->m_curtime ) ) { - return false; - } + memcpy( bone_matrix, + ent->m_CachedBoneData( ).GetElements( ), + ent->m_CachedBoneData( ).GetSize( ) * sizeof( matrix3x4 ) ); auto set = hdr->pHitboxSet( ent->m_nHitboxSet( ) ); if( !set ) return false; - for( int hitbox{ }; hitbox < set->numhitboxes; ++hitbox ) { + if( hitbox == -1 ) { + for( int hitbox{ }; hitbox < set->numhitboxes; ++hitbox ) { + auto box = set->pHitbox( hitbox ); + if( !box ) continue; + + auto min = math::vector_transform( box->bbmin, bone_matrix[ box->bone ] ); + auto max = math::vector_transform( box->bbmax, bone_matrix[ box->bone ] ); + auto radius = box->m_flRadius; + + if( radius == -1.f ) { + radius = min.dist_to( max ); + } + + m_hitbox_data.push_back( hitbox_data_t( min, max, radius ) ); + } + } + else { auto box = set->pHitbox( hitbox ); - if( !box ) continue; + if( !box ) return false; auto min = math::vector_transform( box->bbmin, bone_matrix[ box->bone ] ); auto max = math::vector_transform( box->bbmax, bone_matrix[ box->bone ] ); -- cgit v1.2.3