summaryrefslogtreecommitdiff
path: root/internal_rewrite/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'internal_rewrite/util.cpp')
-rw-r--r--internal_rewrite/util.cpp28
1 files changed, 22 insertions, 6 deletions
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 ] );