#include "Hooks.h"
#include "Autopeek.h"
#include "Bunnyhop.h"
#include "Legitbot.h"
#include "Ragebot.h"
#include "AntiAims.h"
#include "checksum_md5.h"
#include "Resolver.h"
#include "Knifebot.h"
#include "Misc.h"
#include "EnginePrediction.h"
#include "NetChannelhook.h"
#include "WriteUsercmdDeltaToBuffer.h"
#include "RunCommand.h"
void __stdcall hooked_createmove(int sequence_number, float input_sample_frametime, bool active, bool& send_packet)
{
static auto CreateMove = g_pClientHook->GetOriginal< CreateMoveFn >(22);
csgo->updatelocalplayer();
auto cmd = interfaces.input->GetUserCmd(sequence_number);
auto verified = interfaces.input->GetVerifiedUserCmd(sequence_number);
if (!cmd || !cmd->command_number || !csgo->local || csgo->DoUnload)
return;
csgo->in_cm = true;
csgo->cmd = cmd;
csgo->original = cmd->viewangles;
csgo->send_packet = true;
csgo->m_nTickbaseShift = 0;
Misc::Get().Clantag();
Misc::Get().MouseDelta();
Misc::Get().ProcessMissedShots();
INetChannel* pNetChannel = (INetChannel*)csgo->client_state->pNetChannel;
if (csgo->local->isAlive())
{
/*if (csgo->dt_charged)
{
[&]()
{
cmd->tick_count = INT_MAX;
cmd->forwardmove = 0.0f;
cmd->sidemove = 0.0f;
cmd->upmove = 0.0f;
cmd->buttons &= ~IN_ATTACK;
cmd->buttons &= ~IN_ATTACK2;
if (++csgo->skip_ticks >= 16)
{
csgo->dt_charged = false;
csgo->send_packet = true;
}
else
csgo->send_packet = false;
}();
return false;
}*/
[&]()
{
static bool once = false;
if (vars.ragebot.double_tap.active)
{
if (!once) {
Misc::Get().double_tap_key = true;
once = true;
}
}
else
once = false;
if (csgo->skip_ticks < 16 && (Misc::Get().double_tap_enabled && Misc::Get().double_tap_key))
csgo->dt_charged = true;
}();
[]() {
if (csgo->cmd->buttons & IN_FORWARD && csgo->cmd->buttons & IN_BACK)
{
csgo->cmd->buttons &= ~IN_FORWARD;
csgo->cmd->buttons &= ~IN_BACK;
}
if (csgo->cmd->buttons & IN_MOVELEFT && csgo->cmd->buttons & IN_MOVERIGHT)
{
csgo->cmd->buttons &= ~IN_MOVELEFT;
csgo->cmd->buttons &= ~IN_MOVERIGHT;
}
}();
[&]() {
csgo->fixed_tickbase = csgo->local->GetTickBase();
csgo->tick_rate = 1.f / interfaces.global_vars->interval_per_tick;
csgo->vecUnpredictedVel = csgo->local->GetVelocity();
csgo->unpdred_tick = interfaces.global_vars->tickcount;
csgo->weapon = csgo->local->GetWeapon();
csgo->origin = csgo->local->GetOrigin();
csgo->unpred_eyepos = csgo->local->GetEyePosition();
csgo->duck_amount = csgo->local->GetDuckAmount();
csgo->unpred_inaccuracy = csgo->weapon->GetInaccuracy();
csgo->weapon_range = []() {
if (const auto& info = csgo->weapon->GetCSWpnData(); info != nullptr)
return info->m_flRange;
return -1.f;
}();
Ragebot::Get().DropTarget();
}();
features->Bunnyhop->Run(csgo->original);
[&]() {
if (csgo->weapon)
{
csgo->exploits = vars.ragebot.double_tap.active && Misc::Get().double_tap_key;
[&]() {
csgo->original_forwardmove = cmd->forwardmove;
csgo->original_sidemove = cmd->sidemove;
engine_prediction->update();
Misc::Get().FakeDuck();
Ragebot::Get().DoQuickStop();
engine_prediction->update();
engine_prediction->start(csgo->local, cmd);
}();
[&]() {
g_NetData->RecordViewmodelValues();
CMAntiAim::Get().Fakelag();
csgo->weapon_data = csgo->weapon->GetCSWpnData();
if (csgo->weapon->IsGun())
{
csgo->spread = csgo->weapon->GetSpread();
csgo->innacuracy = csgo->weapon->GetInaccuracy();
csgo->weaponspread = (csgo->spread + csgo->innacuracy) * 1000.f;
}
else
csgo->weaponspread = 0.f;
if (vars.misc.knifebot)
CKnifebot::Get().Run();
if (vars.ragebot.enable) {
Ragebot::Get().in_ragebot = true;
Ragebot::Get().Run();
Ragebot::Get().in_ragebot = false;
}
CAutopeek::Get().Run();
csgo->eyepos = csgo->local->GetEyePosition();
Legitbot::Get().AutoPistol();
if (vars.legitbot.backtrack)
Legitbot::Get().Backtrack();
if (vars.antiaim.enable)
{
CMAntiAim::Get().Run();
if (!CAutopeek::Get().has_shot)
CMAntiAim::Get().Sidemove();
}
Misc::Get().Doubletap();
if (F::Shooting()) {
csgo->m_shot_command_number = cmd->command_number;
if (!csgo->fake_duck)
csgo->send_packet = true;
}
csgo->forcing_shot = false;
[&]() {
if (cmd->command_number >= csgo->m_shot_command_number
&& csgo->m_shot_command_number >= cmd->command_number - csgo->client_state->iChokedCommands) {
csgo->forcing_shot = true;
if (csgo->send_packet)
csgo->FakeAngle = interfaces.input->m_pCommands[csgo->m_shot_command_number % 150].viewangles;
else
csgo->VisualAngle = interfaces.input->m_pCommands[csgo->m_shot_command_number % 150].viewangles;
csgo->CurAngle = interfaces.input->m_pCommands[csgo->m_shot_command_number % 150].viewangles;
}
else {
if (csgo->send_packet)
csgo->FakeAngle = csgo->cmd->viewangles;
else
csgo->VisualAngle = csgo->cmd->viewangles;
csgo->CurAngle = csgo->cmd->viewangles;
}
}();
g_Animfix->UpdateFakeState();
g_Animfix->UpdateRealState();
engine_prediction->end(csgo->local);
if (vars.misc.antiuntrusted)
csgo->cmd->viewangles = Math::normalize(csgo->cmd->viewangles);
Misc::Get().FixMovement(cmd, csgo->original);
}();
static auto previous_ticks_allowed = csgo->skip_ticks;
if (csgo->send_packet && csgo->client_state->pNetChannel)
{
auto choked_packets = csgo->client_state->pNetChannel->iChokedPackets;
if (choked_packets >= 0)
{
auto ticks_allowed = csgo->skip_ticks;
auto command_number = cmd->command_number - choked_packets;
do
{
auto command = &interfaces.input->m_pCommands[cmd->command_number - 150 * (command_number / 150) - choked_packets];
if (!command || command->tick_count > interfaces.global_vars->tickcount * 2)
{
if (--ticks_allowed < 0)
ticks_allowed = 0;
csgo->skip_ticks = ticks_allowed;
}
++command_number;
--choked_packets;
} while (choked_packets >= 0);
}
}
if (csgo->skip_ticks > 17)
csgo->skip_ticks = clamp(csgo->skip_ticks - 1, 0, 17);
int tick_to_choke = 0;
if (previous_ticks_allowed && !csgo->skip_ticks)
tick_to_choke = 16;
previous_ticks_allowed = csgo->skip_ticks;
auto& correct = csgo->c_data.emplace_front();
correct.command_number = csgo->cmd->command_number;
correct.choked_commands = csgo->client_state->iChokedCommands + 1;
correct.tickcount = interfaces.global_vars->tickcount;
if (csgo->send_packet)
csgo->choked_number.clear();
else
csgo->choked_number.emplace_back(correct.command_number);
while (csgo->c_data.size() > (int)(2.0f / interfaces.global_vars->interval_per_tick))
csgo->c_data.pop_back();
auto& out = csgo->packets.emplace_back();
out.is_outgoing = csgo->send_packet;
out.is_used = false;
out.cmd_number = csgo->cmd->command_number;
out.previous_command_number = 0;
while (csgo->packets.size() > (int)(1.0f / interfaces.global_vars->interval_per_tick))
csgo->packets.pop_front();
if (!csgo->send_packet && !csgo->game_rules->IsValveDS())
{
auto net_channel = csgo->client_state->pNetChannel;
if (net_channel->iChokedPackets > 0 && !(net_channel->iChokedPackets % 4))
{
auto backup_choke = net_channel->iChokedPackets;
net_channel->iChokedPackets = 0;
net_channel->SendDatagram();
--net_channel->iOutSequenceNr;
net_channel->iChokedPackets = backup_choke;
}
}
CGrenadePrediction::Get().Tick(csgo->cmd->buttons);
}
}();
resolver->StoreAntifreestand();
Misc::Get().UpdateDormantTime();
Misc::Get().StoreTaserRange();
static INetChannel* old_net_chan = nullptr;
if (csgo->local->isAlive())
{
csgo->ping = interfaces.engine->GetNetChannelInfo()->GetLatency(FLOW_INCOMING) + interfaces.engine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);
csgo->ping *= 1000.f;
}
}
else {
csgo->ForceOffAA = false;
csgo->should_draw_taser_range = false;
}
[&]() {
if (csgo->client_state != nullptr
&& pNetChannel != nullptr)
{
csgo->g_pNetChannelHook = std::make_unique<VMTHook>();
csgo->g_pNetChannelHook->Setup(pNetChannel);
csgo->g_pNetChannelHook->Hook(46, Hooked_SendDatagram);
}
}();
csgo->last_sendpacket = csgo->send_packet;
csgo->in_cm = false;
send_packet = csgo->send_packet;
verified->m_cmd = *cmd;
verified->m_crc = cmd->GetChecksum();
}
__declspec(naked) void __stdcall hooked_createmove_proxy(int sequence_number, float input_sample_frametime, bool active)
{
__asm
{
push ebx
push esp
push dword ptr[esp + 20]
push dword ptr[esp + 0Ch + 8]
push dword ptr[esp + 10h + 4]
call hooked_createmove
pop ebx
retn 0Ch
}
}