Начинающий
-
Автор темы
- #1
credits: plztellmewhattheheck(for posting original code and reminding me this exists) L3D451R7 (reversing it in the past)
setupbones:
#define ENTCLIENTFLAG_DONTUSEIK 0x0002 // Don't use IK on this entity even if its model has IK.
#define ENTCLIENTFLAG_ALWAYS_INTERPOLATE 0x0004 // Used by view models.
enum {
ANIMLODFLAG_DISTANT = 0x01,
ANIMLODFLAG_OUTSIDEVIEWFRUSTUM = 0x02,
ANIMLODFLAG_INVISIBLELOCALPLAYER = 0x04,
ANIMLODFLAG_DORMANT = 0x08
};
void Player::InvalidateBoneCache( ) { // NOTE: correct way to do it
auto g_iModelBoneCounter = * * ( unsigned long * * )( g_csgo.InvalidateBoneCache + 0x000A );
m_iMostRecentModelBoneCounter( ) = g_iModelBoneCounter - 1;
m_flLastBoneSetupTime( ) = -FLT_MAX;
}
bool anims::setup_bones( Player* player, BoneArray* bone, int max_bones, int mask, float time ) {
// backup globals
auto backup_curtime = g_csgo.m_globals->m_curtime;
auto backup_frametime = g_csgo.m_globals->m_frametime;
auto backup_abs_frametime = g_csgo.m_globals->m_abs_frametime;
auto backup_realtime = g_csgo.m_globals->m_realtime;
auto backup_framecount = g_csgo.m_globals->m_frame;
auto backup_tickcount = g_csgo.m_globals->m_tick_count;
auto backup_interpolation_amount = g_csgo.m_globals->m_interp_amt;
// backup netvars
const auto backup_ik = player->m_pIKContext( ); // [I]( int[/I] )( uintptr_t( player ) + ( offset_force_bone - 0x1c ) );
const int backup_client_effects = player->m_EntClientFlags( ); // [I]( int[/I] )( uintptr_t( player ) + 0x68 );
const int backup_effects = player->m_fEffects( ); // 0xEC
const int backup_last_non_skipped_frame_cnt = player->m_iLastSetupFrame( ); // [I]( int[/I] )( uintptr_t( player ) + 0xa68 );
const int backup_anim_lod_flags = player->m_nAnimLODflags( ); //[I]( int[/I] )( uintptr_t( player ) + 0xa28 );
const int backup_comp_lod_frame = player->m_nComputedLODframe( ); //[I]( int[/I] )( uintptr_t( player ) + 0xa30 ); lodflags + 0x8
const float backup_lean = player->m_AnimOverlay( )[ 12 ].m_weight;
const vec3_t backup_abs_origin = player->GetAbsOrigin( );
// onetap
g_csgo.m_globals->m_curtime = player->m_flSimulationTime( );
g_csgo.m_globals->m_realtime = player->m_flSimulationTime( );
g_csgo.m_globals->m_frametime = g_csgo.m_globals->m_interval;
g_csgo.m_globals->m_abs_frametime = g_csgo.m_globals->m_interval;
g_csgo.m_globals->m_frame = -999; // bypass ShouldSkipAnimframe
g_csgo.m_globals->m_tick_count = game::TIME_TO_TICKS( player->m_flSimulationTime( ) );
g_csgo.m_globals->m_interp_amt = 0.f;
player->InvalidateBoneCache( ); // invalidate bonecache
player->m_AnimOverlay( )[ 12 ].m_weight = 0.f; // null player lean (rip joeyy)
player->SetAbsOrigin( player->m_vecOrigin( ) ); // set origin to networked
player->m_pIKContext( ) = NULL; // null ik context
player->m_iLastSetupFrame( ) = 0; // make sure last non skipped frame is 0
player->m_nAnimLODflags( ) &= ~ANIMLODFLAG_OUTSIDEVIEWFRUSTUM; // fix pvs animlod flags
player->m_nComputedLODframe( ) = 0; // fix last computed lod frame
player->m_EntClientFlags( ) |= ENTCLIENTFLAG_DONTUSEIK; // tell the setupbones not to re-setup ik's
player->m_fEffects( ) |= EF_NOINTERP; // 8
// not in my dump sorry [USER=1314805]@plztellmewhattheheck[/USER]
// [I]( int[/I] )( uintptr_t( player ) + 0xA24 ) = -1;
// set our bones up (yippeeeee)
const bool ret = player->SetupBones( bone, max_bones, mask, time );
// restore everything once we're done
player->SetAbsOrigin( backup_abs_origin );
player->m_pIKContext( ) = backup_ik;
player->m_fEffects( ) = backup_effects;
player->m_EntClientFlags( ) = backup_client_effects;
player->m_nComputedLODframe( ) = backup_comp_lod_frame;
player->m_nAnimLODflags( ) = backup_anim_lod_flags;
g_csgo.m_globals->m_frametime = backup_frametime;
g_csgo.m_globals->m_abs_frametime = backup_abs_frametime;
g_csgo.m_globals->m_realtime = backup_realtime;
g_csgo.m_globals->m_curtime = backup_curtime;
g_csgo.m_globals->m_frame = backup_framecount;
g_csgo.m_globals->m_tick_count = backup_tickcount;
g_csgo.m_globals->m_interp_amt = backup_interpolation_amount;
return ret;
}