diff --git a/include/crits.hpp b/include/crits.hpp index 11158e47..9abc8041 100644 --- a/include/crits.hpp +++ b/include/crits.hpp @@ -13,14 +13,14 @@ class IClientEntity; // BUGBUG TODO this struct is outdated struct crithack_saved_state { - float bucket; // 2612 - bool unknown2831; - int seed; // 2868 - float time; // 2872 - int unknown2616; - int unknown2620; - float unknown2856; - float unknown2860; + float unknown2868; + float unknown2864; + int unknown2620; + float unknown2880; + char unknown2839; + float bucket2616; + int seed2876; + void Save(IClientEntity* entity); void Load(IClientEntity* entity); }; @@ -33,6 +33,7 @@ namespace criticals { void create_move(); +void draw(); bool random_crits_enabled(); } diff --git a/include/reclasses/CTFPlayerShared.hpp b/include/reclasses/CTFPlayerShared.hpp index 610d1647..9e49cf94 100644 --- a/include/reclasses/CTFPlayerShared.hpp +++ b/include/reclasses/CTFPlayerShared.hpp @@ -3,11 +3,11 @@ class CTFPlayerShared public: inline static float GetCritMult(CTFPlayerShared *self) { - return ((fminf(fmaxf(*(unsigned(self) + 672) * 0.0039215689f, 0.0f), 1.0f) * 3.0f) + 1.0f); + return ((fminf(fmaxf(*(float *)(unsigned(self) + 672) * 0.0039215689f, 0.0f), 1.0f) * 3.0f) + 1.0f); } inline static bool IsCritBoosted(CTFPlayerShared *self) { // TODO signature return false; } -}; \ No newline at end of file +}; diff --git a/include/reclasses/C_BaseEntity.hpp b/include/reclasses/C_BaseEntity.hpp index 9cb7cddf..6611177a 100644 --- a/include/reclasses/C_BaseEntity.hpp +++ b/include/reclasses/C_BaseEntity.hpp @@ -15,7 +15,7 @@ public: typedef bool(*fn_t)(IClientEntity *); return vfunc(self, offsets::PlatformOffset(184, offsets::undefined, 184), 0)(self); } - inline int& m_nPredictionRandomSeed() + inline static int& m_nPredictionRandomSeed() { static int placeholder = 0; return placeholder; diff --git a/include/reclasses/C_BasePlayer.hpp b/include/reclasses/C_BasePlayer.hpp index 77ca47bc..389fcabc 100644 --- a/include/reclasses/C_BasePlayer.hpp +++ b/include/reclasses/C_BasePlayer.hpp @@ -3,6 +3,6 @@ class C_BasePlayer: public C_BaseEntity public: inline static CTFPlayerShared& shared_(IClientEntity *self) { - return *((CTFPlayerShared *)(unsigned(self) + 6092)) + return *((CTFPlayerShared *)(unsigned(self) + 6092)); } -}; \ No newline at end of file +}; diff --git a/include/reclasses/C_TFWeaponBase.hpp b/include/reclasses/C_TFWeaponBase.hpp index df3427a1..702f6526 100644 --- a/include/reclasses/C_TFWeaponBase.hpp +++ b/include/reclasses/C_TFWeaponBase.hpp @@ -7,7 +7,7 @@ #pragma once -class C_TFWeaponBase : public C_BaseCombatWeapon +class C_TFWeaponBase : public re::C_BaseCombatWeapon { public: inline static IClientEntity *GetOwnerViaInterface(IClientEntity *self) @@ -48,7 +48,7 @@ public: inline static void AddToCritBucket(IClientEntity *self, float value) { constexpr float max_bucket_capacity = 1000.0f; - bucket = fminf(bucket_() + value, max_bucket_capacity); + crit_bucket_(self) = fminf(crit_bucket_(self) + value, max_bucket_capacity); } inline static bool IsAllowedToWithdrawFromCritBucket(IClientEntity *self, float value) { @@ -71,7 +71,7 @@ public: if (!C_BaseEntity::IsPlayer(owner)) return false; - CTFPlayerShared *shared = C_BasePlayer::shared_(owner); + CTFPlayerShared *shared = &C_BasePlayer::shared_(owner); float critmult = CTFPlayerShared::GetCritMult(shared); if (!CanFireCriticalShot(self, 0, nullptr)) return false; @@ -120,7 +120,7 @@ public: IClientEntity *owner = GetOwnerViaInterface(self); if (owner) { - if (IsPlayer(owner)) + if (C_BaseEntity::IsPlayer(owner)) { // Always run calculations // Never write anything into entity, at least from here. diff --git a/src/crits.cpp b/src/crits.cpp index a5bbbdfc..831b6beb 100644 --- a/src/crits.cpp +++ b/src/crits.cpp @@ -73,6 +73,7 @@ void unfuck_bucket(IClientEntity *weapon) struct cached_calculation_s { int command_number; + int init_command; int weapon_entity; }; @@ -80,18 +81,28 @@ cached_calculation_s cached_calculation {}; bool force_crit(IClientEntity *weapon) { + if (cached_calculation.init_command > g_pUserCmd->command_number || + g_pUserCmd->command_number - cached_calculation.init_command > 4096 || + cached_calculation.command_number < g_pUserCmd->command_number) + cached_calculation.weapon_entity = 0; if (cached_calculation.weapon_entity == weapon->entindex()) return bool(cached_calculation.command_number); int number = find_next_random_crit_for_weapon(weapon); + logging::Info("Found critical: %d -> %d", g_pUserCmd->command_number, number); + if (number && number != g_pUserCmd->command_number) + command_number_mod[g_pUserCmd->command_number] = number; + cached_calculation.command_number = number; cached_calculation.weapon_entity = LOCAL_W->m_IDX; - return false; + return !!number; } void create_move() { + if (!crit_key) + return; if (!random_crits_enabled()) return; if (CE_BAD(LOCAL_W)) @@ -102,7 +113,7 @@ void create_move() if (!re::C_TFWeaponBase::AreRandomCritsEnabled(weapon)) return; unfuck_bucket(weapon); - if (crit_key.KeyDown()) + if ((g_pUserCmd->buttons & IN_ATTACK) && crit_key.KeyDown() && g_pUserCmd->command_number) { force_crit(weapon); } @@ -113,26 +124,58 @@ bool random_crits_enabled() { return tf_weapon_criticals->GetBool(); } +void draw() +{ + if (CE_BAD(LOCAL_W)) + return; + IClientEntity *weapon = RAW_ENT(LOCAL_W); + if (!weapon) + return; + if (!re::C_TFWeaponBase::IsBaseCombatWeapon(weapon)) + return; + if (!re::C_TFWeaponBase::AreRandomCritsEnabled(weapon)) + return; + if (crit_info && CE_GOOD(LOCAL_W)) + { + if (crit_key.KeyDown()) + { + AddCenterString("FORCED CRITS!", colors::red); + } + IF_GAME (IsTF2()) + { + if (!random_crits_enabled()) + AddCenterString("Random crits are disabled", colors::yellow); + else + { + if (!re::C_TFWeaponBase::CanFireCriticalShot(RAW_ENT(LOCAL_W), false, nullptr)) + AddCenterString("Weapon can't randomly crit", colors::yellow); + else + AddCenterString("Weapon can randomly crit"); + } + AddCenterString(format("Bucket: ", re::C_TFWeaponBase::crit_bucket_(RAW_ENT(LOCAL_W)))); + } + //AddCenterString(format("Time: ", *(float*)((uintptr_t)RAW_ENT(LOCAL_W) + 2872u))); + } +} + } void crithack_saved_state::Load(IClientEntity* entity) { - *(float*)((uintptr_t)entity + 2612) = bucket; - *(float*)((uintptr_t)entity + 2831) = unknown2831; - *(int*)((uintptr_t)entity + 2868) = seed; - *(float*)((uintptr_t)entity + 2872) = time; - *(int*)((uintptr_t)entity + 2616) = unknown2616; - *(int*)((uintptr_t)entity + 2620) = unknown2620; - *(float*)((uintptr_t)entity + 2856) = unknown2856; - *(float*)((uintptr_t)entity + 2860) = unknown2860; + *(float *)(uintptr_t(entity) + 2868) = unknown2868; + *(float *)(uintptr_t(entity) + 2864) = unknown2864; + *(float *)(uintptr_t(entity) + 2880) = unknown2880; + *(float *)(uintptr_t(entity) + 2616) = bucket2616; + *(int *)(uintptr_t(entity) + 2620) = unknown2620; + *(int *)(uintptr_t(entity) + 2876) = seed2876; + *(char *)(uintptr_t(entity) + 2839) = unknown2839; } void crithack_saved_state::Save(IClientEntity* entity) { - bucket = *(float*)((uintptr_t)entity + 2612); - unknown2831 = *(float*)((uintptr_t)entity + 2831); - seed = *(int*)((uintptr_t)entity + 2868); - time = *(float*)((uintptr_t)entity + 2872); - unknown2616 = *(int*)((uintptr_t)entity + 2616); - unknown2620 = *(int*)((uintptr_t)entity + 2620); - unknown2856 = *(float*)((uintptr_t)entity + 2856); - unknown2860 = *(float*)((uintptr_t)entity + 2860); + unknown2868 = *(float *)(uintptr_t(entity) + 2868); + unknown2864 = *(float *)(uintptr_t(entity) + 2864); + unknown2880 = *(float *)(uintptr_t(entity) + 2880); + bucket2616 = *(float *)(uintptr_t(entity) + 2616); + unknown2620 = *(int *)(uintptr_t(entity) + 2620); + seed2876 = *(int *)(uintptr_t(entity) + 2876); + unknown2839 = *(char *)(uintptr_t(entity) + 2839); } diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index e6fe3869..e4cf77ce 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -225,10 +225,6 @@ bool ShouldAim() { return false; } } - - // Check if crithack allows attacking - if (!AllowAttacking()) - return false; } return true; } diff --git a/src/hacks/LagExploit.cpp b/src/hacks/LagExploit.cpp index 5272d329..ab5dc876 100644 --- a/src/hacks/LagExploit.cpp +++ b/src/hacks/LagExploit.cpp @@ -86,7 +86,9 @@ void CreateMove() { if (!g_pUserCmd) return; if (!g_pUserCmd->command_number) return; if (!master_switch) return; - int amount = int(value); + int amount = 0; + if (key.KeyDown()) + amount = int(value); if (!amount) return; diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index c2e73936..cb27c0d3 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -270,30 +270,6 @@ void CreateMove() { #if ENABLE_VISUALS == 1 void DrawText() { - // Crithack info - // CRITHACK IS DISABLED (temporarily) - /* - if (crit_info && CE_GOOD(LOCAL_W)) { - if (CritKeyDown() || experimental_crit_hack.KeyDown()) { - AddCenterString("FORCED CRITS!", colors::red); - } - IF_GAME (IsTF2()) { - if (!vfunc(RAW_ENT(LOCAL_W), 465, 0)(RAW_ENT(LOCAL_W))) - AddCenterString("Random crits are disabled", colors::yellow); - else { - if (!WeaponCanCrit()) - AddCenterString("Weapon can't randomly crit", colors::yellow); - else - AddCenterString("Weapon can randomly crit"); - } - AddCenterString(format("Bucket: ", *(float*)((uintptr_t)RAW_ENT(LOCAL_W) + 2612u))); - if (crit_hack_next && found_crit_number > last_number && found_crit_weapon == RAW_ENT(LOCAL_W)) { - AddCenterString(format("Next crit in: ", roundf(((found_crit_number - last_number) / 66.0f) * 10.0f) / 10.0f, 's')); - } - //AddCenterString(format("Time: ", *(float*)((uintptr_t)RAW_ENT(LOCAL_W) + 2872u))); - } - }*/ - /*if (!no_homo) { int width, height; g_IEngine->GetScreenSize(width, height); diff --git a/src/hacks/Trigger.cpp b/src/hacks/Trigger.cpp index 20945c2b..779bef98 100644 --- a/src/hacks/Trigger.cpp +++ b/src/hacks/Trigger.cpp @@ -141,11 +141,6 @@ bool ShouldShoot() { } } } - IF_GAME (IsTF()) { - // Check if crithack allows attacking - if (!AllowAttacking()) - return false; - } return true; } diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 0d91acfd..8ca0f2be 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -263,7 +263,6 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { } #endif if (CE_GOOD(g_pLocalPlayer->entity)) { - ResetCritHack(); IF_GAME (IsTF2()) { SAFE_CALL(UpdateHoovyList()); } @@ -352,6 +351,10 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { PROF_SECTION(CM_misc); SAFE_CALL(hacks::shared::misc::CreateMove()); } + { + PROF_SECTION(CM_crits); + criticals::create_move(); + } { PROF_SECTION(CM_spam); SAFE_CALL(hacks::shared::spam::CreateMove()); diff --git a/src/sdk/checksum_md5.cpp b/src/sdk/checksum_md5.cpp index 4276d0ab..e39f1ef3 100644 --- a/src/sdk/checksum_md5.cpp +++ b/src/sdk/checksum_md5.cpp @@ -236,9 +236,9 @@ void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *ctx) } //----------------------------------------------------------------------------- -// Purpose: -// Input : *hash - -// hashlen - +// Purpose: +// Input : *hash - +// hashlen - // Output : char //----------------------------------------------------------------------------- char *MD5_Print( unsigned char *hash, int hashlen ) diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp index 3bfda1a6..f4f19c52 100644 --- a/src/visual/drawmgr.cpp +++ b/src/visual/drawmgr.cpp @@ -113,6 +113,10 @@ void DrawCheatVisuals() { PROF_SECTION(DRAW_esp); hacks::shared::esp::Draw(); } + IF_GAME(IsTF2()) + { + criticals::draw(); + } #ifndef FEATURE_FIDGET_SPINNER_DISABLED DrawSpinner(); #endif