Backtrack chams + make fake latency slider better

This commit is contained in:
LightCat 2019-02-26 16:49:13 +01:00
parent 823afe67aa
commit d93f501371
9 changed files with 142 additions and 15 deletions

View File

@ -102,7 +102,9 @@
<List width="150">
<AutoVariable width="fill" target="backtrack.enable" label="Enable Backtrack"/>
<AutoVariable width="fill" target="backtrack.draw" label="Draw Backtrack"/>
<AutoVariable width="fill" target="backtrack.latency" label="Fake Latency" min="0" max="1000"/>
<AutoVariable width="fill" target="backtrack.draw-skeleon" label="Draw Skeleton"/>
<AutoVariable width="fill" target="backtrack.chams_glow" label="Chams/Glow Support"/>
<AutoVariable width="fill" target="backtrack.latency" label="Fake Latency" min="0" max="1000" step="25"/>
<LabeledObject width="fill" label="Backtrack Slots">
<Select target="backtrack.slots">
<Option name="All" value="0"/>

View File

@ -29,6 +29,7 @@ struct BacktrackData
float simtime{ 0.0f };
Vector entorigin{ 0.0f, 0.0f, 0.0f };
int index{ 0 };
matrix3x4_t bones[128]{};
};
struct BestTickData
{

View File

@ -15,7 +15,7 @@
#include "hack.hpp"
#include "MiscTemporary.hpp"
settings::Bool log_to_console{ "hack.log-console", "false" };
static settings::Bool log_to_console{ "hack.log-console", "false" };
FILE *logging::handle{ nullptr };

View File

@ -101,7 +101,7 @@ bool EntityHitboxCache::VisibilityCheck(int id)
}
static settings::Int setupbones_time{ "source.setupbones-time", "1" };
static settings::Bool bonecache_enabled{ "source.use-bone-cache", "true" };
static settings::Bool bonecache_enabled{ "source.use-bone-cache", "false" };
static std::mutex setupbones_mutex;

View File

@ -1443,7 +1443,12 @@ static void DrawText()
}
}
#endif
void rvarCallback(settings::VariableBase<int> &var, int after)
{
backtrackAimbot = after > 190.0f;
}
static InitRoutine EC([]() {
hacks::shared::backtrack::latency.installChangeCallback(rvarCallback);
EC::Register(EC::LevelInit, Reset, "INIT_Aimbot", EC::average);
EC::Register(EC::LevelShutdown, Reset, "RESET_Aimbot", EC::average);
EC::Register(EC::CreateMove, CreateMove, "CM_Aimbot", EC::late);

View File

@ -15,11 +15,14 @@
static settings::Bool enable{ "backtrack.enable", "false" };
static settings::Bool draw_bt{ "backtrack.draw", "false" };
static settings::Bool draw_skeleton{ "backtrack.draw-skeleon", "false" };
static settings::Float mindistance{ "backtrack.min-distance", "60" };
static settings::Int slots{ "backtrack.slots", "0" };
namespace hacks::shared::backtrack
{
settings::Bool backtrack_chams_glow{ "backtrack.chams_glow", "true" };
settings::Int latency{ "backtrack.latency", "0" };
void EmptyBacktrackData(BacktrackData &i);
@ -45,7 +48,6 @@ void UpdateIncomingSequences()
lastincomingsequencenumber = m_nInSequenceNr;
sequences.push_front(CIncomingSequence(instate, m_nInSequenceNr, g_GlobalVars->realtime));
}
if (sequences.size() > 2048)
sequences.pop_back();
}
@ -144,6 +146,7 @@ static void Run()
hbd.collidable.min = RAW_ENT(pEntity)->GetCollideable()->OBBMins() + hbd.entorigin;
hbd.collidable.max = RAW_ENT(pEntity)->GetCollideable()->OBBMaxs() + hbd.entorigin;
hbd.collidable.center = (hbd.collidable.min + hbd.collidable.max) / 2;
memcpy((void *) hbd.bones, (void *) pEntity->hitboxes.bones, sizeof(matrix3x4_t) * 128);
}
}
@ -167,11 +170,72 @@ static void Run()
}
}
}
CatCommand print_bones("debug_print_bones", "debug print bone id + name", []() {
if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer())
return;
// Get player model
const model_t *model = RAW_ENT(LOCAL_E)->GetModel();
if (not model)
return;
// Get Studio models (for bones)
studiohdr_t *hdr = g_IModelInfo->GetStudiomodel(model);
if (not hdr)
return;
// Get the name of the bones
for (int i = 0; i < hdr->numbones; i++)
logging::Info(format(std::string(hdr->pBone(i)->pszName()), " ", i).c_str());
});
static std::vector<int> bones_leg_r = { 17, 16, 15 };
static std::vector<int> bones_leg_l = { 14, 13, 12 };
static std::vector<int> bones_bottom = { 15, 1, 12 };
static std::vector<int> bones_spine = { 1, 2, 3, 4, 5, 0 };
static std::vector<int> bones_arm_r = { 9, 10, 11 };
static std::vector<int> bones_arm_l = { 6, 7, 8 };
static std::vector<int> bones_up = { 9, 5, 6 };
void DrawBone(std::vector<int> hitbox, std::array<hitboxData, 18> hitboxes)
{
for (int i = 0; i < hitbox.size() - 1; i++)
{
Vector bone1 = hitboxes.at(hitbox.at(i)).center;
Vector bone2 = hitboxes.at(hitbox.at(i + 1)).center;
Vector draw_position1, draw_position2;
if (draw::WorldToScreen(bone1, draw_position1) && draw::WorldToScreen(bone2, draw_position2))
draw::Line(draw_position1.x, draw_position1.y, draw_position2.x - draw_position1.x, draw_position2.y - draw_position1.y, colors::white, 1.0f);
}
}
static void Draw()
{
#if ENABLE_VISUALS
if (!isBacktrackEnabled)
return;
// :b:ones for non drawable ents
if (draw_skeleton)
for (int i = 0; i < g_IEngine->GetMaxClients(); i++)
{
CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent) || !ent->m_bAlivePlayer() || i == g_IEngine->GetLocalPlayer())
continue;
auto head_pos = headPositions[i];
// Usable vector instead of ptr to c style array, also used to filter valid and invalid ticks
std::vector<BacktrackData> usable;
for (int i = 0; i < 66; i++)
{
if (ValidTick(head_pos[i], ent))
usable.push_back(head_pos[i]);
}
// Crash much?
if (usable.size())
{
DrawBone(bones_leg_l, usable[0].hitboxes);
DrawBone(bones_leg_r, usable[0].hitboxes);
DrawBone(bones_bottom, usable[0].hitboxes);
DrawBone(bones_spine, usable[0].hitboxes);
DrawBone(bones_arm_l, usable[0].hitboxes);
DrawBone(bones_arm_r, usable[0].hitboxes);
DrawBone(bones_up, usable[0].hitboxes);
}
}
if (!draw_bt)
return;
for (int i = 0; i < g_IEngine->GetMaxClients(); i++)

View File

@ -6,10 +6,25 @@
#include <MiscTemporary.hpp>
#include <settings/Bool.hpp>
#include "HookedMethods.hpp"
#include "Backtrack.hpp"
#include <visual/EffectChams.hpp>
#include <visual/EffectGlow.hpp>
static settings::Bool no_arms{ "remove.arms", "false" };
static settings::Bool no_hats{ "remove.hats", "false" };
namespace effect_glow
{
extern settings::Bool enable;
}
namespace effect_chams
{
extern settings::Bool enable;
}
namespace hacks::shared::backtrack
{
extern settings::Bool backtrack_chams_glow;
}
namespace hooked_methods
{
@ -18,7 +33,7 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, const DrawMod
if (!isHackActive())
return original::DrawModelExecute(this_, state, info, bone);
if (!(spectator_target || no_arms || no_hats || (*clean_screenshots && g_IEngine->IsTakingScreenshot()) || CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer()))
if (!(hacks::shared::backtrack::isBacktrackEnabled || spectator_target || no_arms || no_hats || (*clean_screenshots && g_IEngine->IsTakingScreenshot()) || CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer()))
{
return original::DrawModelExecute(this_, state, info, bone);
}
@ -45,6 +60,46 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, const DrawMod
}
}
if (hacks::shared::backtrack::isBacktrackEnabled && hacks::shared::backtrack::backtrack_chams_glow && (effect_glow::enable || effect_chams::enable))
{
const char *name = g_IModelInfo->GetModelName(info.pModel);
if (name)
{
std::string sname = name;
if (sname.find("models/player") || sname.find("models/weapons") || sname.find("models/workshop/player") || sname.find("models/workshop/weapons"))
{
if (IDX_GOOD(info.entity_index) && info.entity_index < g_IEngine->GetMaxClients() && info.entity_index != g_IEngine->GetLocalPlayer())
{
CachedEntity *ent = ENTITY(info.entity_index);
if (CE_GOOD(ent) && ent->m_bAlivePlayer())
{
// Backup Blend
float orig_blend = g_IVRenderView->GetBlend();
// Make Backtrack stuff seethrough
g_IVRenderView->SetBlend(0.999f);
// Get Backtrack data for target entity
auto head_pos = hacks::shared::backtrack::headPositions[info.entity_index];
// Usable vector instead of ptr to c style array, also used to filter valid and invalid ticks
std::vector<hacks::shared::backtrack::BacktrackData> usable;
for (int i = 0; i < 66; i++)
{
if (hacks::shared::backtrack::ValidTick(head_pos[i], ent))
usable.push_back(head_pos[i]);
}
// Crash much?
if (usable.size())
{
// Sort
std::sort(usable.begin(), usable.end(), [](hacks::shared::backtrack::BacktrackData &a, hacks::shared::backtrack::BacktrackData &b) { return a.tickcount < b.tickcount; });
original::DrawModelExecute(this_, state, info, usable[0].bones);
}
g_IVRenderView->SetBlend(orig_blend);
}
}
}
}
}
IClientUnknown *unk = info.pRenderable->GetIClientUnknown();
if (unk)
{
@ -57,5 +112,5 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, const DrawMod
}
return original::DrawModelExecute(this_, state, info, bone);
}
} // namespace hooked_methods
} // namespace hooked_methods

View File

@ -11,7 +11,6 @@
#include "common.hpp"
#include "Backtrack.hpp"
static settings::Bool enable{ "chams.enable", "false" };
static settings::Bool flat{ "chams.flat", "false" };
static settings::Bool health{ "chams.health", "false" };
static settings::Bool teammates{ "chams.show.teammates", "false" };
@ -31,6 +30,7 @@ static settings::Bool disco_chams{ "chams.disco", "false" };
namespace effect_chams
{
settings::Bool enable{ "chams.enable", "false" };
CatCommand fix_black_chams("fix_black_chams", "Fix Black Chams", []() {
effect_chams::g_EffectChams.Shutdown();
effect_chams::g_EffectChams.Init();
@ -95,7 +95,7 @@ static Timer t{};
static int prevcolor = -1;
rgba_t EffectChams::ChamsColor(IClientEntity *entity)
{
if (!isHackActive() || !*enable)
if (!isHackActive() || !*effect_chams::enable)
return colors::empty;
;
CachedEntity *ent = ENTITY(entity->entindex());
@ -200,9 +200,9 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity)
bool EffectChams::ShouldRenderChams(IClientEntity *entity)
{
if (!isHackActive() || !*enable)
if (!isHackActive() || !*effect_chams::enable)
return false;
if (!enable)
if (!effect_chams::enable)
return false;
if (entity->entindex() < 0)
return false;
@ -261,7 +261,7 @@ bool EffectChams::ShouldRenderChams(IClientEntity *entity)
void EffectChams::RenderChamsRecursive(IClientEntity *entity)
{
if (!isHackActive() || !*enable)
if (!isHackActive() || !*effect_chams::enable)
return;
entity->DrawModel(1);
@ -300,7 +300,7 @@ void EffectChams::RenderChamsRecursive(IClientEntity *entity)
void EffectChams::RenderChams(IClientEntity *entity)
{
if (!isHackActive() || !*enable)
if (!isHackActive() || !*effect_chams::enable)
return;
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
if (ShouldRenderChams(entity))
@ -331,7 +331,7 @@ void EffectChams::Render(int x, int y, int w, int h)
PROF_SECTION(DRAW_chams);
if (!isHackActive())
return;
if (!enable)
if (!effect_chams::enable)
return;
if (g_Settings.bInvalid)
return;

View File

@ -11,7 +11,6 @@
#include <settings/Bool.hpp>
#include "common.hpp"
static settings::Bool enable{ "glow.enable", "false" };
static settings::Bool health{ "glow.health", "false" };
static settings::Bool teammates{ "glow.show.teammates", "false" };
static settings::Bool players{ "glow.show.players", "true" };
@ -40,6 +39,7 @@ CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration(const char *pName
namespace effect_glow
{
settings::Bool enable{ "glow.enable", "false" };
struct ShaderStencilState_t
{
@ -257,7 +257,7 @@ void EffectGlow::DrawEntity(IClientEntity *entity)
void EffectGlow::Render(int x, int y, int w, int h)
{
if (!enable)
if (!effect_glow::enable)
return;
if (!init)
Init();