-
Автор темы
- #1
C++:
bool hack::tickbase::in_clmove( ) {
if ( !g_csgo.m_engine->IsConnected( ) || !g_csgo.m_engine->IsInGame( ) )
return false;
if ( !g_cl.m_local || !g_cl.m_cmd || !g_cl.m_local->alive( ) )
return false;
if ( ( g_cl.m_cmd->m_tick <= shifted_cmd.m_tick + game::TIME_TO_TICKS( 0.5f ) ) || shift_amount < 0 )
return false;
shift_amount--;
if ( !shift_amount )
can_we_dt_again = true;
return true;
}
void hack::tickbase::in_createmove( ) {
const auto& r_tickbasemanip = settings.m_enabled;// CONFIG_GET( bool, fnv1a( "r_tickbasemanip" ) );
const auto& r_tickbaseshift = settings.shift_ticks_custom;// CONFIG_GET( int, fnv1a( "r_tickbaseshift" ) );
const auto& r_overridetickbasedefault = settings.dt_shift_custom;// CONFIG_GET( bool, fnv1a( "r_overridetickbasedefault" ) );
bool dt2;
auto dt = UTILS::KeybindMethod( settings.m_dt_key, settings.dtstyle, &dt2 );
const static auto keybind_func = dt;// HANDLE_KEYBIND( fnv1a( "r_tickbasemanip_key" ) );
tickbase_key_state = GetKeyState( settings.m_dt_key );
static auto last_state = !r_tickbasemanip || !tickbase_key_state;
if ( !g_csgo.m_engine->IsConnected( ) || !g_csgo.m_engine->IsInGame( ) ) {
can_we_dt_again = true;
shifted_cmd.m_tick = -1;
original_tickbase = -1;
shift_amount = tickbase_shift = 0;
return;
}
if ( !g_cl.m_local || !g_cl.m_cmd || !g_cl.m_local->alive( ) ) {
can_we_dt_again = true;
shifted_cmd.m_tick = -1;
original_tickbase = -1;
shift_amount = tickbase_shift = 0;
return;
}
/* no shifting on this sir */
if ( g_cl.m_weapon->m_iItemDefinitionIndex() == REVOLVER ||
g_cl.m_weapon_info->m_weapon_type == WEAPONTYPE_C4 ||
g_cl.m_weapon_info->m_weapon_type == WEAPONTYPE_GRENADE ||
g_cl.m_weapon_info->m_weapon_type == WEAPONTYPE_KNIFE )
return;
/* hahahahahahahahahah wtf is this shit -swoopae from future */
const static auto get_optimal_shift_value = [ & ]( ) {
if ( !g_cl.m_local->GetActiveWeapon() )
return 15;
switch ( g_cl.m_local->GetActiveWeapon( )->m_iItemDefinitionIndex() ) {
case DEAGLE:
return 13; break;
case AWP:
case SSG08:
return 9; break;
case USPS:
case P2000:
case FIVESEVEN:
case P250:
return 10; break;
case CZ75A:
return 8; break;
case TEC9:
return 7; break;
default:
return 14; break;
}
return 14;
};
if ( r_tickbasemanip && tickbase_key_state ) {
/* recharge - always recharge 15 ticks in case we switch weapons or something */
if ( last_state ) {
can_we_dt_again = false;
shift_amount = std::fmax( 15, r_tickbaseshift );
*g_cl.m_packet = force_sendpacket = true;
}
/* shifting while choking is bad but w/e */
if ( can_we_dt_again && shift_amount < 1 && g_cl.CanFireWeapon() && g_cl.m_cmd->m_buttons & IN_ATTACK ) {
can_we_dt_again = false;
did_just_dt = true;
std::memcpy( &shifted_cmd, g_cl.m_cmd, sizeof( CUserCmd ) );
original_tickbase = g_cl.m_local->m_nTickBase( );
*g_cl.m_packet = force_sendpacket = true;
#if defined(_DEBUG) || defined(LUNAR_DEV) || defined(LUNAR_ALPHA)
if ( r_overridetickbasedefault )
tickbase_shift = shift_amount = r_tickbaseshift;
else tickbase_shift = shift_amount = get_optimal_shift_value( );
#else
tickbase_shift = shift_amount = get_optimal_shift_value( );
#endif
}
}
if ( g_csgo.m_cl->m_choked_commands > 16 )
*g_cl.m_packet = true;
last_state = !r_tickbasemanip || !tickbase_key_state;// || !g_cl.m_local->valid( );
}
void hack::tickbase::in_endscene( ) {
bool dt2;
auto dt = UTILS::KeybindMethod( settings.m_dt_key, settings.dtstyle, &dt2 );
const static auto keybind_func = dt;// HANDLE_KEYBIND( fnv1a( "r_tickbasemanip_key" ) );
tickbase_key_state = keybind_func;
}
bool hack::tickbase::in_writeucmddelta( const std::uintptr_t ecx, const std::uintptr_t edx, int slot, bf_write* buf, int from, int to, bool newcmd ) {
if ( !g_csgo.m_engine->IsConnected( ) || !g_csgo.m_engine->IsInGame( ) )
return nem_hooks::orig_write_user_cmd_delta_to_buffer( ecx, edx, slot, buf, from, to, newcmd );
if ( !g_cl.m_local || !g_cl.m_cmd || !g_cl.m_local->alive( ) )
return nem_hooks::orig_write_user_cmd_delta_to_buffer( ecx, edx, slot, buf, from, to, newcmd );
const auto& r_tickbasemanip = settings.m_enabled;// CONFIG_GET( bool, fnv1a( "r_tickbasemanip" ) );
if ( !r_tickbasemanip || !tickbase_key_state || !tickbase_shift )
return nem_hooks::orig_write_user_cmd_delta_to_buffer( ecx, edx, slot, buf, from, to, newcmd );
if ( from != -1 )
return true;
auto backup_cmds = reinterpret_cast< int* >( std::uintptr_t( buf ) - 48 ), new_cmds = reinterpret_cast< int* >( std::uintptr_t( buf ) - 44 );
auto new_commands = *new_cmds, next_cmd_number = g_csgo.m_cl->m_last_outgoing_command + g_csgo.m_cl->m_choked_commands + 1;
auto total_new_cmds = std::clamp( tickbase_shift, 0, 62 );
tickbase_shift -= total_new_cmds;
*new_cmds = total_new_cmds;
*backup_cmds=0;
for ( to = next_cmd_number - new_commands + 1; to <= next_cmd_number; to++ ) {
if ( !nem_hooks::orig_write_user_cmd_delta_to_buffer( ecx, edx, slot, buf, from, to, true ) )
return false;
from = to;
}
auto last_real_cmd = g_csgo.m_input->user_cmd( slot, from );
auto from_cmd = CUserCmd{};
if ( last_real_cmd )
from_cmd = *last_real_cmd;
auto to_cmd = from_cmd;
to_cmd.m_command_number = next_cmd_number++;
const auto& r_tickbase_teleport = settings.dt_defensive_teleport;// CONFIG_GET( bool, fnv1a( "r_tickbase_teleport" ) );
if ( !r_tickbase_teleport )
to_cmd.m_tick += 200;
for ( auto i = new_commands; i <= total_new_cmds; i++ ) {
write_user_cmd( buf, &to_cmd, &from_cmd );
from_cmd = to_cmd;
to_cmd.m_command_number++;
to_cmd.m_tick++;
}
return true;
/*
const std::uintptr_t ecx, const std::uintptr_t edx,
const int slot, bf_write* const buffer, int from, int to, const bool is_new_cmd
*/
}