From 73b7bb4a7326ab201469057be79cc148e743f187 Mon Sep 17 00:00:00 2001 From: LightCat Date: Sat, 19 Jan 2019 17:27:05 +0100 Subject: [PATCH 1/2] Improve experimental crithack --- src/crits.cpp | 56 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/src/crits.cpp b/src/crits.cpp index 4e581316..0eadf5ce 100644 --- a/src/crits.cpp +++ b/src/crits.cpp @@ -20,22 +20,10 @@ int *g_PredictionRandomSeed = nullptr; namespace criticals { -CatCommand test("crit_debug_print", "debug", []() { - if (CE_BAD(LOCAL_E)) - return; - if (CE_BAD(LOCAL_W)) - return; - unsigned unk1 = *(unsigned *) (RAW_ENT(LOCAL_W) + 2832); - unsigned unk2 = *(unsigned *) (RAW_ENT(LOCAL_W) + 2820); - unsigned char CritSlots = *(unsigned char *) (unk1 + (unk2 << 6) + 1844); - int CritSlots2 = *(unsigned *) (unk1 + (unk2 << 6) + 1788); - unsigned CritSlots3 = *(unsigned *) (unk1 + (unk2 << 6) + 1788); - int CritSlots4 = *(int *) (unk1 + (unk2 << 6) + 1788); - logging::Info("%u %d %d %u %d", unk1, int(CritSlots), CritSlots2, CritSlots3, CritSlots4); -}); + int find_next_random_crit_for_weapon(IClientEntity *weapon) { - int tries = 0, number = current_user_cmd->command_number, found = 0, seed, seed_md5, seed_backup; + int tries = 0, number = current_user_cmd->command_number, found = 0, seed_backup; crithack_saved_state state{}; state.Save(weapon); @@ -43,9 +31,7 @@ int find_next_random_crit_for_weapon(IClientEntity *weapon) seed_backup = *g_PredictionRandomSeed; while (!found && tries < 4096) { - seed_md5 = MD5_PseudoRandom(number) & 0x7FFFFFFF; - *g_PredictionRandomSeed = seed_md5; - seed = seed_md5 ^ (LOCAL_E->m_IDX | (LOCAL_W->m_IDX << 8)); + *g_PredictionRandomSeed = MD5_PseudoRandom(number) & 0x7FFFFFFF; found = re::C_TFWeaponBase::CalcIsAttackCritical(weapon); if (found) break; @@ -54,7 +40,8 @@ int find_next_random_crit_for_weapon(IClientEntity *weapon) } *g_PredictionRandomSeed = seed_backup; - state.Load(weapon); + if (!crit_experimental || g_pLocalPlayer->weapon_mode == weaponmode::weapon_melee) + state.Load(weapon); if (found) return number; return 0; @@ -90,7 +77,7 @@ struct cached_calculation_s int weapon_entity; }; -cached_calculation_s cached_calculation{}; +static cached_calculation_s cached_calculation{}; static int number = 0; static int lastnumber = 0; @@ -103,37 +90,30 @@ bool force_crit(IClientEntity *weapon) if (lastnumber < command_number || lastweapon != weapon->GetModel() || lastnumber - command_number > 1000) { - if (cached_calculation.init_command > command_number || command_number - cached_calculation.init_command > 4096 || (command_number && (cached_calculation.command_number < command_number))) - cached_calculation.weapon_entity = 0; - if (cached_calculation.weapon_entity == weapon->entindex()) - return bool(cached_calculation.command_number); - + if (!*crit_experimental || g_pLocalPlayer->weapon_mode == weapon_melee) + { + if (cached_calculation.init_command > command_number || command_number - cached_calculation.init_command > 4096 || (command_number && (cached_calculation.command_number < command_number))) + cached_calculation.weapon_entity = 0; + if (cached_calculation.weapon_entity == weapon->entindex()) + return bool(cached_calculation.command_number); + } number = find_next_random_crit_for_weapon(weapon); } else number = lastnumber; // logging::Info("Found critical: %d -> %d", command_number, // number); - lastweapon = weapon->GetModel(); - lastnumber = number; if (crit_experimental && GetWeaponMode() != weapon_melee) { + cached_calculation.command_number = number; + cached_calculation.weapon_entity = LOCAL_W->m_IDX; if (!crit_legiter) { if (number && number != command_number) command_number_mod[command_number] = number; - - cached_calculation.command_number = number; - cached_calculation.weapon_entity = LOCAL_W->m_IDX; - } - else - { - if (number && number - 30 < command_number) - command_number_mod[command_number] = number; - - cached_calculation.command_number = number; - cached_calculation.weapon_entity = LOCAL_W->m_IDX; } + else if (number && number - 30 < command_number) + command_number_mod[command_number] = number; } else { @@ -152,6 +132,8 @@ bool force_crit(IClientEntity *weapon) current_user_cmd->buttons |= IN_ATTACK; } } + lastweapon = weapon->GetModel(); + lastnumber = number; return number != 0; } From 55e03ef4a5554bc0334afa0d5f7bc011828dbbf3 Mon Sep 17 00:00:00 2001 From: LightCat Date: Sun, 20 Jan 2019 13:30:34 +0100 Subject: [PATCH 2/2] Fix Backtrack melee aimbot --- src/hacks/Aimbot.cpp | 111 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 23 deletions(-) diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index 09d0cf6d..8d43eb6e 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -437,18 +437,49 @@ bool IsTargetStateGood(CachedEntity *entity) } else { - float swingrange = re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); - int hb = BestHitbox(entity); - if (hb == -1) - return false; - Vector newangle = GetAimAtAngles(g_pLocalPlayer->v_Eye, entity->hitboxes.GetHitbox(hb)->center); - trace_t trace; - Ray_t ray; - trace::filter_default.SetSelf(RAW_ENT(g_pLocalPlayer->entity)); - ray.Init(g_pLocalPlayer->v_Eye, GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange)); - g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace); - if ((IClientEntity *) trace.m_pEnt != RAW_ENT(entity)) + float swingrange = EffectiveTargetingRange(); + if (!IsBacktracking() || entity->m_Type() != ENTITY_PLAYER) + { + int hb = BestHitbox(entity); + if (hb == -1) + return false; + Vector newangle = GetAimAtAngles(g_pLocalPlayer->v_Eye, entity->hitboxes.GetHitbox(hb)->center); + trace_t trace; + Ray_t ray; + trace::filter_default.SetSelf(RAW_ENT(g_pLocalPlayer->entity)); + ray.Init(g_pLocalPlayer->v_Eye, GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange)); + g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace); + if ((IClientEntity *) trace.m_pEnt != RAW_ENT(entity)) + return false; + } + else + { + namespace bt = hacks::shared::backtrack; + for (int i = 0; i < 66; i++) + { + if (!bt::ValidTick(bt::headPositions[entity->m_IDX][i], entity)) + continue; + Vector bbox_min = bt::headPositions[entity->m_IDX][i].collidable.min; + Vector bbox_max = bt::headPositions[entity->m_IDX][i].collidable.max; + for (int j = 17; j >= 0; j--) + { + Vector aim_at = bt::headPositions[entity->m_IDX][i].hitboxes[j].center; + Vector newangle = GetAimAtAngles(g_pLocalPlayer->v_Eye, aim_at); + Vector new_vec = GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange); + if (new_vec.x > bbox_min.x && new_vec.x < bbox_max.x && new_vec.y > bbox_min.y && new_vec.y < bbox_max.y && new_vec.z > bbox_min.z && new_vec.z < bbox_max.z) + { + /*auto it = bt::headPositions[entity->m_IDX][i]; + current_user_cmd->tick_count = it.tickcount; + Vector &angles = NET_VECTOR(RAW_ENT(entity), netvar.m_angEyeAngles); + float &simtime = NET_FLOAT(RAW_ENT(entity), netvar.m_flSimulationTime); + angles.y = it.viewangles; + simtime = it.simtime;*/ + return true; + } + } + } return false; + } } } // Rage only check @@ -907,11 +938,42 @@ const Vector &PredictEntity(CachedEntity *entity) // Players only if ((entity->m_Type() == ENTITY_PLAYER)) { - namespace bt = hacks::shared::backtrack; - auto hb = bt::headPositions[entity->m_IDX][good_tick.first]; - cd.predict_tick = tickcount; - result = hb.hitboxes[cd.hitbox].center; - cd.fov = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, result); + if (GetWeaponMode() != weapon_melee) + { + namespace bt = hacks::shared::backtrack; + auto hb = bt::headPositions[entity->m_IDX][good_tick.first]; + cd.predict_tick = tickcount; + result = hb.hitboxes[cd.hitbox].center; + cd.fov = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, result); + } + else + { + namespace bt = hacks::shared::backtrack; + for (int i = 0; i < 66; i++) + { + if (!bt::ValidTick(bt::headPositions[entity->m_IDX][i], entity)) + continue; + Vector bbox_min = bt::headPositions[entity->m_IDX][i].collidable.min; + Vector bbox_max = bt::headPositions[entity->m_IDX][i].collidable.max; + for (int j = 17; j >= 0; j--) + { + float swingrange = re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); + Vector aim_at = bt::headPositions[entity->m_IDX][i].hitboxes[j].center; + Vector newangle = GetAimAtAngles(g_pLocalPlayer->v_Eye, aim_at); + Vector new_vec = GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange); + if (new_vec.x > bbox_min.x && new_vec.x < bbox_max.x && new_vec.y > bbox_min.y && new_vec.y < bbox_max.y && new_vec.z > bbox_min.z && new_vec.z < bbox_max.z) + { + result = new_vec; + auto it = bt::headPositions[entity->m_IDX][i]; + current_user_cmd->tick_count = it.tickcount; + Vector &angles = NET_VECTOR(RAW_ENT(entity), netvar.m_angEyeAngles); + float &simtime = NET_FLOAT(RAW_ENT(entity), netvar.m_flSimulationTime); + angles.y = it.viewangles; + simtime = it.simtime; + } + } + } + } } } // Return the found vector @@ -1188,13 +1250,16 @@ bool VischeckPredictedEntity(CachedEntity *entity, bool Backtracking) auto ticks = bt::headPositions[entity->m_IDX]; if (good_tick.first != -1 && good_tick.second == entity->m_IDX && IsEntityVectorVisible(entity, PredictEntity(entity))) { - cd.vcheck_tick = tickcount; - cd.visible = true; - current_user_cmd->tick_count = ticks[good_tick.first].tickcount; - Vector &angles = CE_VECTOR(entity, netvar.m_angEyeAngles); - float &simtime = CE_FLOAT(entity, netvar.m_flSimulationTime); - angles.y = ticks[good_tick.first].viewangles; - simtime = ticks[good_tick.first].simtime; + cd.vcheck_tick = tickcount; + cd.visible = true; + if (g_pLocalPlayer->weapon_mode != weapon_melee) + { + current_user_cmd->tick_count = ticks[good_tick.first].tickcount; + Vector &angles = CE_VECTOR(entity, netvar.m_angEyeAngles); + float &simtime = CE_FLOAT(entity, netvar.m_flSimulationTime); + angles.y = ticks[good_tick.first].viewangles; + simtime = ticks[good_tick.first].simtime; + } } else cd.visible = false;