crithack progress
This commit is contained in:
parent
23221e11ee
commit
77a939426f
@ -11,6 +11,7 @@
|
|||||||
class CUserCmd;
|
class CUserCmd;
|
||||||
class IClientEntity;
|
class IClientEntity;
|
||||||
|
|
||||||
|
// BUGBUG TODO this struct is outdated
|
||||||
struct crithack_saved_state {
|
struct crithack_saved_state {
|
||||||
float bucket; // 2612
|
float bucket; // 2612
|
||||||
bool unknown2831;
|
bool unknown2831;
|
||||||
@ -24,41 +25,23 @@ struct crithack_saved_state {
|
|||||||
void Load(IClientEntity* entity);
|
void Load(IClientEntity* entity);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool weapon_can_crit_last;
|
|
||||||
|
|
||||||
extern CatVar crit_hack_next;
|
|
||||||
extern CatVar crit_info;
|
extern CatVar crit_info;
|
||||||
extern CatVar crit_hack;
|
extern CatVar crit_key;
|
||||||
extern CatVar crit_melee;
|
extern CatVar crit_melee;
|
||||||
extern CatVar crit_suppress;
|
|
||||||
|
|
||||||
namespace criticals
|
namespace criticals
|
||||||
{
|
{
|
||||||
|
|
||||||
void unfuck_bucket();
|
void create_move();
|
||||||
bool force_crit();
|
bool random_crits_enabled();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CritKeyDown();
|
|
||||||
bool AllowAttacking();
|
|
||||||
bool RandomCrits();
|
|
||||||
bool WeaponCanCrit();
|
|
||||||
bool IsAttackACrit(CUserCmd* cmd);
|
|
||||||
void ResetCritHack();
|
|
||||||
void LoadSavedState();
|
|
||||||
void ModifyCommandNumber();
|
|
||||||
|
|
||||||
#include <beforecheaders.hpp>
|
#include <beforecheaders.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <aftercheaders.hpp>
|
#include <aftercheaders.hpp>
|
||||||
class CatVar;
|
|
||||||
extern CatVar experimental_crit_hack;
|
|
||||||
|
|
||||||
extern int* g_PredictionRandomSeed;
|
extern int* g_PredictionRandomSeed;
|
||||||
extern std::unordered_map<int, int> command_number_mod;
|
extern std::unordered_map<int, int> command_number_mod;
|
||||||
|
|
||||||
//bool CalcIsAttackCritical(IClientEntity* weapon);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* CRITS_HPP_ */
|
#endif /* CRITS_HPP_ */
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
// *(int *)(self + 2872) = g_GlobalVars->framecount;
|
// *(int *)(self + 2872) = g_GlobalVars->framecount;
|
||||||
// *(char *)(self + 2839) = 0;
|
// *(char *)(self + 2839) = 0;
|
||||||
|
|
||||||
if (g_pGameRules->critmode == 5 ||
|
if (g_pGameRules->roundmode == 5 &&
|
||||||
g_pGameRules->winning_team == NET_INT(owner, netvar.iTeamNum))
|
g_pGameRules->winning_team == NET_INT(owner, netvar.iTeamNum))
|
||||||
{
|
{
|
||||||
// *(char *)(self + 2838) = 1;
|
// *(char *)(self + 2838) = 1;
|
||||||
|
@ -11,7 +11,7 @@ class CGameRules
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int unknown_pad_0[12];
|
int unknown_pad_0[12];
|
||||||
int critmode;
|
int roundmode;
|
||||||
int unknown_pad_1[1];
|
int unknown_pad_1[1];
|
||||||
int winning_team;
|
int winning_team;
|
||||||
};
|
};
|
||||||
|
152
src/crits.cpp
152
src/crits.cpp
@ -8,15 +8,11 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
|
|
||||||
CatVar crit_hack_next(CV_SWITCH, "crit_hack_next", "0", "Next crit info");
|
CatVar crit_info(CV_SWITCH, "crit_info", "0", "Show crit info");
|
||||||
CatVar crit_info(CV_SWITCH, "crit_info", "0", "Show crit info"); // TODO separate
|
CatVar crit_key(CV_KEY, "crit_key", "0", "Crit Key");
|
||||||
CatVar crit_hack(CV_KEY, "crit_hack", "0", "Crit Key");
|
|
||||||
CatVar crit_melee(CV_SWITCH, "crit_melee", "0", "Melee crits");
|
CatVar crit_melee(CV_SWITCH, "crit_melee", "0", "Melee crits");
|
||||||
CatVar crit_suppress(CV_SWITCH, "crit_suppress", "0", "Disable random crits", "Can help saving crit bucket for forced crits");
|
|
||||||
CatVar experimental_crit_hack(CV_KEY, "crit_hack_experimental", "0", "Unstable Crit Hack", "Experimental crit hack, use this **OR** old crit hack, do not use both!\nNEEDS NEXT CRIT INFO TO BE ACTIVE!");
|
|
||||||
|
|
||||||
std::unordered_map<int, int> command_number_mod {};
|
std::unordered_map<int, int> command_number_mod {};
|
||||||
|
|
||||||
int* g_PredictionRandomSeed = nullptr;
|
int* g_PredictionRandomSeed = nullptr;
|
||||||
|
|
||||||
namespace criticals
|
namespace criticals
|
||||||
@ -74,51 +70,49 @@ void unfuck_bucket(IClientEntity *weapon)
|
|||||||
last_bucket = bucket;
|
last_bucket = bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool force_crit()
|
struct cached_calculation_s
|
||||||
{
|
{
|
||||||
|
int command_number;
|
||||||
|
int weapon_entity;
|
||||||
|
};
|
||||||
|
|
||||||
|
cached_calculation_s cached_calculation {};
|
||||||
|
|
||||||
|
bool force_crit(IClientEntity *weapon)
|
||||||
|
{
|
||||||
|
if (cached_calculation.weapon_entity == weapon->entindex())
|
||||||
|
return bool(cached_calculation.command_number);
|
||||||
|
|
||||||
|
int number = find_next_random_crit_for_weapon(weapon);
|
||||||
|
|
||||||
|
cached_calculation.command_number = number;
|
||||||
|
cached_calculation.weapon_entity = LOCAL_W->m_IDX;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void create_move()
|
||||||
|
{
|
||||||
|
if (!random_crits_enabled())
|
||||||
|
return;
|
||||||
|
if (CE_BAD(LOCAL_W))
|
||||||
|
return;
|
||||||
|
IClientEntity *weapon = RAW_ENT(LOCAL_W);
|
||||||
|
if (!re::C_TFWeaponBase::IsBaseCombatWeapon(weapon))
|
||||||
|
return;
|
||||||
|
if (!re::C_TFWeaponBase::AreRandomCritsEnabled(weapon))
|
||||||
|
return;
|
||||||
|
unfuck_bucket(weapon);
|
||||||
|
if (crit_key.KeyDown())
|
||||||
|
{
|
||||||
|
force_crit(weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CritKeyDown() {
|
bool random_crits_enabled() {
|
||||||
return g_IInputSystem->IsButtonDown(static_cast<ButtonCode_t>((int)hacks::shared::misc::crit_hack));// || g_IInputSystem->IsButtonDown(static_cast<ButtonCode_t>((int)experimental_crit_hack));
|
static ConVar* tf_weapon_criticals = g_ICvar->FindVar("tf_weapon_criticals");
|
||||||
|
return tf_weapon_criticals->GetBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AllowAttacking() {
|
|
||||||
return true;
|
|
||||||
/*
|
|
||||||
if (!(CritKeyDown() || ((GetWeaponMode() == weapon_melee) && hacks::shared::misc::crit_melee)) && !hacks::shared::misc::crit_suppress) return true;
|
|
||||||
bool crit = IsAttackACrit(g_pUserCmd);
|
|
||||||
LoadSavedState();
|
|
||||||
if (hacks::shared::misc::crit_suppress && !(CritKeyDown() || ((GetWeaponMode() == weapon_melee) && hacks::shared::misc::crit_melee))) {
|
|
||||||
if (crit && !IsPlayerCritBoosted(LOCAL_E)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if ((CritKeyDown() || ((GetWeaponMode() == weapon_melee) && hacks::shared::misc::crit_melee)) && RandomCrits() && WeaponCanCrit() && (g_pLocalPlayer->weapon()->m_iClassID != CL_CLASS(CTFKnife))) {
|
|
||||||
if (!crit) return false;
|
|
||||||
}
|
|
||||||
return true;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModifyCommandNumber() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RandomCrits() {
|
|
||||||
static ConVar* tf_weapon_criticals = g_ICvar->FindVar("tf_weapon_criticals");
|
|
||||||
return tf_weapon_criticals->GetBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool weapon_can_crit_last = false;
|
|
||||||
|
|
||||||
bool WeaponCanCrit() {
|
|
||||||
IF_GAME (!IsTF()) return false;
|
|
||||||
if (CE_BAD(LOCAL_W)) return false;
|
|
||||||
IClientEntity* weapon = RAW_ENT(LOCAL_W);
|
|
||||||
weapon_can_crit_last = vfunc<bool(*)(IClientEntity*)>(weapon, 190, 0)(weapon) && vfunc<bool(*)(IClientEntity*)>(weapon, 465 + 21, 0)(weapon);
|
|
||||||
return weapon_can_crit_last;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void crithack_saved_state::Load(IClientEntity* entity) {
|
void crithack_saved_state::Load(IClientEntity* entity) {
|
||||||
@ -142,77 +136,3 @@ void crithack_saved_state::Save(IClientEntity* entity) {
|
|||||||
unknown2856 = *(float*)((uintptr_t)entity + 2856);
|
unknown2856 = *(float*)((uintptr_t)entity + 2856);
|
||||||
unknown2860 = *(float*)((uintptr_t)entity + 2860);
|
unknown2860 = *(float*)((uintptr_t)entity + 2860);
|
||||||
}
|
}
|
||||||
|
|
||||||
static crithack_saved_state state;
|
|
||||||
static bool state_saved { false };
|
|
||||||
void LoadSavedState() {
|
|
||||||
// TODO TF2C Crit Hack
|
|
||||||
IF_GAME (!IsTF2()) return;
|
|
||||||
if (!state_saved) return;
|
|
||||||
if (CE_GOOD(LOCAL_W)) {
|
|
||||||
IClientEntity* weapon = RAW_ENT(LOCAL_W);
|
|
||||||
state.Load(weapon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ResetCritHack() {
|
|
||||||
state_saved = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsAttackACrit(CUserCmd* cmd) {
|
|
||||||
// TODO TF2C Crit Hack
|
|
||||||
IF_GAME (!IsTF2()) return false;
|
|
||||||
if (CE_GOOD(LOCAL_W)) {
|
|
||||||
IClientEntity* weapon = RAW_ENT(LOCAL_W);
|
|
||||||
/*if (TF2C) {
|
|
||||||
if (vfunc<bool(*)(IClientEntity*)>(weapon, 1824 / 4, 0)(weapon)) {
|
|
||||||
static uintptr_t CalcIsAttackCritical_s = gSignatures.GetClientSignature("55 89 E5 56 53 83 EC 10 8B 5D 08 89 1C 24 E8 ? ? ? ? 85 C0 89 C6 74 59 8B 00 89 34 24 FF 90 E0 02 00 00 84 C0 74 4A A1 ? ? ? ? 8B 40 04 3B 83 A8 09 00 00 74 3A");
|
|
||||||
typedef void(*CalcIsAttackCritical_t)(IClientEntity*);
|
|
||||||
CalcIsAttackCritical_t CIACFn = (CalcIsAttackCritical_t)(CalcIsAttackCritical_s);
|
|
||||||
*(float*)((uintptr_t)weapon + 2468ul) = 0.0f;
|
|
||||||
int tries = 0;
|
|
||||||
static int lcmdn = 0;
|
|
||||||
if (*(bool*)((uintptr_t)RAW_ENT(LOCAL_W) + 2454ul)) return true;
|
|
||||||
static int& seed = *(int*)(sharedobj::client->lmap->l_addr + 0x00D53F68ul);
|
|
||||||
bool cmds = false;
|
|
||||||
seed = MD5_PseudoRandom(cmd->command_number) & 0x7fffffff;
|
|
||||||
RandomSeed(seed);
|
|
||||||
CIACFn(RAW_ENT(LOCAL_W));
|
|
||||||
return *(bool*)((uintptr_t)RAW_ENT(LOCAL_W) + 2454ul);
|
|
||||||
}
|
|
||||||
} else if (TF2) */
|
|
||||||
{
|
|
||||||
if (vfunc<bool(*)(IClientEntity*)>(weapon, 1944 / 4, 0)(weapon)) {
|
|
||||||
static uintptr_t CalcIsAttackCritical_s = gSignatures.GetClientSignature("55 89 E5 83 EC 28 89 5D F4 8B 5D 08 89 75 F8 89 7D FC 89 1C 24 E8 ? ? ? ? 85 C0 89 C6 74 60 8B 00 89 34 24 FF 90 E0 02 00 00 84 C0 74 51 A1 ? ? ? ? 8B 40 04");
|
|
||||||
typedef void(*CalcIsAttackCritical_t)(IClientEntity*);
|
|
||||||
CalcIsAttackCritical_t CIACFn = (CalcIsAttackCritical_t)(CalcIsAttackCritical_s);
|
|
||||||
if (cmd->command_number) {
|
|
||||||
int tries = 0;
|
|
||||||
static int cmdn = 0;
|
|
||||||
bool chc = false;
|
|
||||||
int md5seed = MD5_PseudoRandom(cmd->command_number) & 0x7fffffff;
|
|
||||||
int rseed = md5seed;
|
|
||||||
//float bucket = *(float*)((uintptr_t)RAW_ENT(LOCAL_W) + 2612u);
|
|
||||||
|
|
||||||
*g_PredictionRandomSeed = md5seed;
|
|
||||||
int c = LOCAL_W->m_IDX << 8;
|
|
||||||
int b = LOCAL_E->m_IDX;
|
|
||||||
rseed = rseed ^ (b | c);
|
|
||||||
RandomSeed(rseed);
|
|
||||||
if (GetWeaponMode() == weapon_melee) {
|
|
||||||
*(float*)((uintptr_t)RAW_ENT(LOCAL_W) + 2612u) = 1000.0f;
|
|
||||||
}
|
|
||||||
state.Save(weapon);
|
|
||||||
|
|
||||||
state_saved = true;
|
|
||||||
//float saved_time = *(float*)(weapon + 2872ul);
|
|
||||||
//*(float*)(weapon + 2872ul) = 0.0f;
|
|
||||||
bool crits = vfunc<bool(*)(IClientEntity*)>(weapon, 1836 / 4, 0)(weapon);
|
|
||||||
//*(float*)(weapon + 2872ul) = saved_time;
|
|
||||||
//if (!crits) *(float*)((uintptr_t)RAW_ENT(LOCAL_W) + 2612u) = bucket;
|
|
||||||
return crits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user