Merge pull request #512 from BenCat07/master

Fixes
This commit is contained in:
LightCat 2018-06-22 23:11:18 +02:00 committed by GitHub
commit 00530dcc64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 249 additions and 176 deletions

15
include/core/cvwrapper.hpp Executable file → Normal file
View File

@ -41,7 +41,16 @@ public:
int max_value;
int size;
};
namespace hacks
{
namespace tf2
{
namespace global
{
void runcfg();
}
}
}
// TODO reverse, no idea how catcommands are handled
class CatCommand
{
@ -78,7 +87,8 @@ public: // TODo, unknown reverse
inline operator bool() const
{
if (this && convar_parent && convar_parent->IsRegistered() && this->registered)
if (this && convar_parent && convar_parent->IsRegistered() &&
this->registered)
return !!convar_parent->m_nValue;
else
return false;
@ -109,6 +119,7 @@ public: // TODo, unknown reverse
}
void Register();
typedef std::function<void(CatVar *)> RegisterCallbackFn;
void OnRegister(RegisterCallbackFn fn);
void InstallChangeCallback(FnChangeCallback_t callback);

View File

@ -24,7 +24,11 @@ public:
}
inline static int GetSwingRange(IClientEntity *self)
{
if (self->GetClientClass()->m_ClassID == CL_CLASS(CTFSword) ||
self->GetClientClass()->m_ClassID == CL_CLASS(CTFKatana))
return 128;
else
return (128.0f * 0.67) - 0.5f;
}
};
}

1
include/visual/drawing.hpp Executable file → Normal file
View File

@ -22,7 +22,6 @@ namespace fonts
extern std::unique_ptr<glez::font> esp;
extern std::unique_ptr<glez::font> menu;
}
namespace fonts

View File

@ -15,8 +15,27 @@ int GetRebasedCatVarCount()
{
return rebased_count;
}
static CatCommand cfg_rebase("cfg_setbase", "Rebase config", []() {
enum torun
{
rebase = 0,
resetbase,
save,
save_complete
};
int torun = -1;
std::string Args[3];
namespace hacks
{
namespace tf2
{
namespace global
{
void runcfg()
{
if (torun == -1)
return;
if (torun == rebase)
{
for (auto &cv : CatVarList())
{
std::string value(cv->GetString());
@ -27,22 +46,22 @@ static CatCommand cfg_rebase("cfg_setbase", "Rebase config", []() {
}
}
logging::Info("Successfully rebased %d variables", rebased_count);
});
static CatCommand cfg_resetbase("cfg_resetbase", "Reset config base", []() {
}
else if (torun == resetbase)
{
for (auto &cv : CatVarList())
{
cv->current_base = cv->defaults;
}
rebased_count = 0;
});
static CatCommand save_settings(
"save", "Save settings (optional filename)", [](const CCommand &args) {
std::string filename("lastcfg");
if (args.ArgC() > 1)
}
else if (torun == save)
{
filename = std::string(args.Arg(1));
std::string filename("lastcfg");
if (Args[0] != "")
{
filename = Args[0];
Args[0] = "";
}
std::string path = format("tf/cfg/cat_", filename, ".cfg");
logging::Info("Saving settings to %s", path.c_str());
@ -55,6 +74,7 @@ static CatCommand save_settings(
if (file.bad())
{
logging::Info("Couldn't open the file!");
torun = -1;
return;
}
for (const auto &i : CatVarList())
@ -70,15 +90,14 @@ static CatCommand save_settings(
}
}
file.close();
});
static CatCommand save_settings_complete(
"save_complete", "Save all settings (optional filename)",
[](const CCommand &args) {
std::string filename("lastcfg");
if (args.ArgC() > 1)
}
else if (torun == save_complete)
{
filename = std::string(args.Arg(1));
std::string filename("lastcfg");
if (Args[0] != "")
{
filename = Args[0];
Args[0] = "";
}
std::string path = format("tf/cfg/cat_", filename, ".cfg");
logging::Info("Saving settings to %s", path.c_str());
@ -102,6 +121,37 @@ static CatCommand save_settings_complete(
file << CON_PREFIX << i->name << " \"" << i->GetString() << "\"\n";
}
file.close();
}
torun = -1;
}
}
}
}
static CatCommand cfg_rebase("cfg_setbase", "Rebase config",
[]() { torun = rebase; });
static CatCommand cfg_resetbase("cfg_resetbase", "Reset config base",
[]() { torun = resetbase; });
static CatCommand save_settings("save", "Save settings (optional filename)",
[](const CCommand &args) {
if (args.ArgC() > 1)
{
Args[0] = std::string(args.Arg(1));
}
torun = save;
});
static CatCommand
save_settings_complete("save_complete",
"Save all settings (optional filename)",
[](const CCommand &args) {
if (args.ArgC() > 1)
{
Args[0] = std::string(args.Arg(1));
}
torun = save_complete;
});
// Prevent initialization errors.

View File

@ -467,7 +467,8 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state)
if (GetWeaponMode() == weaponmode::weapon_melee ||
(int) priority_mode == 2)
{
scr = 4096.0f - calculated_data_array[i].aim_position.DistTo(
scr = 4096.0f -
calculated_data_array[i].aim_position.DistTo(
g_pLocalPlayer->v_Eye);
}
else

View File

@ -56,6 +56,8 @@ void CreateMove()
return;
if (CE_BYTE(LOCAL_E, netvar.m_bFeignDeathReady))
return;
if (HasCondition<TFCond_Cloaked>(LOCAL_E) || HasCondition<TFCond_CloakFlicker>(LOCAL_E))
return;
if (CE_INT(LOCAL_E, netvar.iHealth) < (int) trigger_health &&
NearbyEntities() > 1)
g_pUserCmd->buttons |= IN_ATTACK2;

View File

@ -23,8 +23,11 @@ static CatVar draw_bt(CV_SWITCH, "backtrack_draw", "0", "Draw",
CatVar latency(CV_FLOAT, "backtrack_latency", "0", "fake lantency",
"Set fake latency to this many ms");
static CatVar mindistance(CV_FLOAT, "mindistance", "60", "mindistance");
static CatEnum slots_enum({ "All", "Primary", "Secondary", "Melee", "Primary Secondary", "Primary Melee", "Secondary Melee" });
static CatVar slots(slots_enum, "backtrack_slots", "0", "Enabled Slots", "Select what slots backtrack should be enabled on.");
static CatEnum slots_enum({ "All", "Primary", "Secondary", "Melee",
"Primary Secondary", "Primary Melee",
"Secondary Melee" });
static CatVar slots(slots_enum, "backtrack_slots", "0", "Enabled Slots",
"Select what slots backtrack should be enabled on.");
BacktrackData headPositions[32][66];
BestTickData sorted_ticks[66];
@ -241,7 +244,8 @@ void Draw()
bool shouldBacktrack()
{
int slot = re::C_BaseCombatWeapon::GetSlot(RAW_ENT(g_pLocalPlayer->weapon()));
int slot =
re::C_BaseCombatWeapon::GetSlot(RAW_ENT(g_pLocalPlayer->weapon()));
switch ((int) slots)
{
case 0:
@ -274,7 +278,6 @@ bool shouldBacktrack()
}
return false;
}
}
}
}

View File

@ -253,8 +253,7 @@ struct bonelist_s
{
glez::draw::line(last_screen.x, last_screen.y,
current_screen.x - last_screen.x,
current_screen.y - last_screen.y, color,
0.5f);
current_screen.y - last_screen.y, color, 0.5f);
}
last_screen = current_screen;
}
@ -388,8 +387,10 @@ void Init()
{
/*esp_font_scale.InstallChangeCallback(
[](IConVar *var, const char *pszOldValue, float flOldValue) {
logging::Info("current font: %p %s %d", fonts::esp.get(), fonts::esp->path.c_str(), fonts::esp->isLoaded());
fonts::esp.reset(new glez::font(DATA_PATH "/fonts/verasans.ttf", esp_font_scale));
logging::Info("current font: %p %s %d", fonts::esp.get(),
fonts::esp->path.c_str(), fonts::esp->isLoaded());
fonts::esp.reset(new glez::font(DATA_PATH "/fonts/verasans.ttf",
esp_font_scale));
});*/
}
@ -434,7 +435,8 @@ void _FASTCALL emoji(CachedEntity *ent)
playerlist::k_EState::CAT)
glez::draw::rect_textured(
head_scr.x - size / 2, head_scr.y - size / 2, size,
size, glez::color::white, idspec, 2 * 64, 1 * 64, 64, 64, 0);
size, glez::color::white, idspec, 2 * 64, 1 * 64,
64, 64, 0);
for (int i = 0; i < 4; i++)
{
if (steamID == steamidarray[i])
@ -445,10 +447,10 @@ void _FASTCALL emoji(CachedEntity *ent)
ii++;
i -= 4;
}
glez::draw::rect_textured(head_scr.x - size / 2,
head_scr.y - size / 2, size,
size, glez::color::white, idspec,
i * 64, ii * 64, 64, 64, 0);
glez::draw::rect_textured(
head_scr.x - size / 2, head_scr.y - size / 2,
size, size, glez::color::white, idspec, i * 64,
ii * 64, 64, 64, 0);
hascall = true;
}
}
@ -456,8 +458,8 @@ void _FASTCALL emoji(CachedEntity *ent)
glez::draw::rect_textured(
head_scr.x - size / 2, head_scr.y - size / 2, size,
size, colors::white, textures::atlas().texture,
(3 + (v9mode ? 3 : (int) emoji_esp)) * 64, (v9mode ? 3 : 4) * 64,
64, 64, 0);
(3 + (v9mode ? 3 : (int) emoji_esp)) * 64,
(v9mode ? 3 : 4) * 64, 64, 64, 0);
}
}
}
@ -525,8 +527,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent)
draw::WorldToScreen(ent->m_vecOrigin(), scn);
// Draw a line
glez::draw::line(scn.x, scn.y, width - scn.x, height - scn.y, fg,
0.5f);
glez::draw::line(scn.x, scn.y, width - scn.x, height - scn.y, fg, 0.5f);
}
// Sightline esp
@ -810,9 +811,9 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent)
// If the origin is centered, we use one method. if not, the other
if (!origin_is_zero || true)
{
glez::draw::outlined_string(
draw_point.x, draw_point.y, string.data,
*fonts::esp, color, colors::black, nullptr, nullptr);
glez::draw::outlined_string(draw_point.x, draw_point.y,
string.data, *fonts::esp, color,
colors::black, nullptr, nullptr);
}
else
{ /*
@ -1419,8 +1420,7 @@ void _FASTCALL Draw3DBox(CachedEntity *ent, const rgba_t &clr)
(points[i + 3].y) - (points[i - 1].y), clr, 0.5f);
glez::draw::line((points[i + 3].x), (points[i + 3].y),
(points[i % 4 + 4].x) - (points[i + 3].x),
(points[i % 4 + 4].y) - (points[i + 3].y), clr,
0.5f);
(points[i % 4 + 4].y) - (points[i + 3].y), clr, 0.5f);
}
}

View File

@ -193,7 +193,8 @@ void WorldTick()
if (dist_to_target > (float) follow_distance)
{
// Check for idle
if (idle_time.check(3000) || (breadcrumbs.size() > 1 && LOCAL_E->m_vecVelocity.IsZero(5.0f)))
if (idle_time.check(3000) ||
(breadcrumbs.size() > 1 && LOCAL_E->m_vecVelocity.IsZero(5.0f)))
g_pUserCmd->buttons |= IN_JUMP;
if (idle_time.test_and_set(5000))
{
@ -282,16 +283,15 @@ void DrawTick()
if (draw::WorldToScreen(breadcrumbs[i], wts1) &&
draw::WorldToScreen(breadcrumbs[i + 1], wts2))
{
glez::draw::line(wts1.x, wts1.y, wts2.x - wts1.x,
wts2.y - wts1.y, colors::white, 0.1f);
glez::draw::line(wts1.x, wts1.y, wts2.x - wts1.x, wts2.y - wts1.y,
colors::white, 0.1f);
}
}
Vector wts;
if (!draw::WorldToScreen(breadcrumbs[0], wts))
return;
glez::draw::rect(wts.x - 4, wts.y - 4, 8, 8, colors::white);
glez::draw::rect_outline(wts.x - 4, wts.y - 4, 7, 7, colors::white,
1.0f);
glez::draw::rect_outline(wts.x - 4, wts.y - 4, 7, 7, colors::white, 1.0f);
#endif
}

0
src/hacks/KillSay.cpp Executable file → Normal file
View File

View File

@ -64,8 +64,7 @@ void draw()
else
size = abs(maxp[i].y - minp[i].y);
glez::draw::rect(
out.x, out.y, size / 4, size / 4,
glez::draw::rect(out.x, out.y, size / 4, size / 4,
hacks::shared::lightesp::LightESPColor(pEntity));
}
}

View File

@ -91,16 +91,19 @@ static std::vector<textures::sprite> tx_items{};
InitRoutine init([]() {
// Background circles
for (int i = 0; i < 2; ++i)
tx_teams.push_back(textures::atlas().create_sprite(704, 384 + i * 64, 64, 64));
tx_teams.push_back(
textures::atlas().create_sprite(704, 384 + i * 64, 64, 64));
// Items
for (int i = 0; i < 2; ++i)
tx_items.push_back(textures::atlas().create_sprite(640, 384 + i * 64, 64, 64));
tx_items.push_back(
textures::atlas().create_sprite(640, 384 + i * 64, 64, 64));
// Classes
for (int i = 0; i < 3; ++i)
{
tx_class.emplace_back();
for (int j = 0; j < 9; ++j)
tx_class[i].push_back(textures::atlas().create_sprite(j * 64, 320 + i * 64, 64, 64));
tx_class[i].push_back(
textures::atlas().create_sprite(j * 64, 320 + i * 64, 64, 64));
}
logging::Info("Radar sprites loaded");
});
@ -132,9 +135,9 @@ void DrawEntity(int x, int y, CachedEntity *ent)
tx_teams[idx].draw(x + wtr.first, y + wtr.second,
(int) icon_size, (int) icon_size,
colors::white);
tx_class[0][clazz - 1].draw(
x + wtr.first, y + wtr.second, (int) icon_size,
(int) icon_size, colors::white);
tx_class[0][clazz - 1].draw(x + wtr.first, y + wtr.second,
(int) icon_size, (int) icon_size,
colors::white);
}
else
{
@ -156,8 +159,8 @@ void DrawEntity(int x, int y, CachedEntity *ent)
glez::draw::rect_outline(
x + wtr.first, y + wtr.second + (int) icon_size,
(int) icon_size, 4, colors::black, 0.5f);
glez::draw::rect(
x + wtr.first + 1, y + wtr.second + (int) icon_size + 1,
glez::draw::rect(x + wtr.first + 1,
y + wtr.second + (int) icon_size + 1,
((float) icon_size - 2.0f) * healthp, 2, clr);
}
}
@ -193,8 +196,8 @@ void DrawEntity(int x, int y, CachedEntity *ent)
WorldToRadar(ent->m_vecOrigin().x, ent->m_vecOrigin().y);
float sz = float(icon_size) * 0.15f * 0.5f;
float sz2 = float(icon_size) * 0.85;
tx_items[1].draw(x + wtr.first + sz, y + wtr.second + sz,
sz2, sz2, colors::white);
tx_items[0].draw(x + wtr.first + sz, y + wtr.second + sz, sz2,
sz2, colors::white);
}
else if (show_ammopacks && (ent->m_ItemType() == ITEM_AMMO_LARGE ||
ent->m_ItemType() == ITEM_AMMO_MEDIUM ||
@ -204,8 +207,8 @@ void DrawEntity(int x, int y, CachedEntity *ent)
WorldToRadar(ent->m_vecOrigin().x, ent->m_vecOrigin().y);
float sz = float(icon_size) * 0.15f * 0.5f;
float sz2 = float(icon_size) * 0.85;
tx_items[0].draw(x + wtr.first + sz, y + wtr.second + sz,
sz2, sz2, colors::white);
tx_items[1].draw(x + wtr.first + sz, y + wtr.second + sz, sz2,
sz2, colors::white);
}
}
}
@ -233,8 +236,7 @@ void Draw()
glez::draw::rect(x, y, radar_size, radar_size,
colors::Transparent(colors::black, 0.4f));
glez::draw::rect_outline(x, y, radar_size, radar_size, outlineclr,
0.5f);
glez::draw::rect_outline(x, y, radar_size, radar_size, outlineclr, 0.5f);
if (enemies_over_teammates)
enemies.clear();
@ -268,8 +270,8 @@ void Draw()
g_pLocalPlayer->v_Origin.y);
if (!use_icons)
glez::draw::rect_outline(x + wtr.first, y + wtr.second,
int(icon_size), int(icon_size),
GUIColor(), 0.5f);
int(icon_size), int(icon_size), GUIColor(),
0.5f);
}
glez::draw::line(x + half_size, y + half_size / 2, 0, half_size,

View File

@ -1092,8 +1092,8 @@ void DrawConnection(index_t a, connection_s &b)
flags += "H";
// int size_x = 0, size_y = 0;
// FTGL_StringLength(flags, fonts::font_main, &size_x, &size_y);
glez::draw::string(wts_cc.x, wts_cc.y - 4, flags,
*fonts::menu, colors::white, nullptr, nullptr);
glez::draw::string(wts_cc.x, wts_cc.y - 4, flags, *fonts::menu,
colors::white, nullptr, nullptr);
}
}
@ -1147,9 +1147,9 @@ void DrawNode(index_t node, bool draw_back)
if (not draw::WorldToScreen(n.xyz(), wts))
return;
glez::draw::outlined_string(
wts.x, wts.y, std::to_string(node).c_str(), *fonts::menu,
*color, colors::black, nullptr, nullptr);
glez::draw::outlined_string(wts.x, wts.y, std::to_string(node).c_str(),
*fonts::menu, *color, colors::black,
nullptr, nullptr);
}
}

View File

@ -160,6 +160,7 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
time_replaced = false;
curtime_old = g_GlobalVars->curtime;
hacks::tf2::global::runcfg();
if (nolerp)
{
// g_pUserCmd->tick_count += 1;

View File

@ -99,8 +99,8 @@ void Prediction_PaintTraverse()
Vector screen;
if (draw::WorldToScreen(predicted_players[i][j], screen))
{
glez::draw::line(
screen.x, screen.y, previous_screen.x - screen.x,
glez::draw::line(screen.x, screen.y,
previous_screen.x - screen.x,
previous_screen.y - screen.y, color, 0.5f);
previous_screen = screen;
}

View File

@ -18,8 +18,8 @@ sprite::sprite(float x, float y, float w, float h, texture_atlas &atlas)
void sprite::draw(float scrx, float scry, float scrw, float scrh,
const rgba_t &rgba)
{
glez::draw::rect_textured(scrx, scry, scrw, scrh, rgba, atlas.texture,
nx, ny, nw, nh, 0);
glez::draw::rect_textured(scrx, scry, scrw, scrh, rgba, atlas.texture, nx,
ny, nw, nh, 0);
}
texture_atlas::texture_atlas(std::string filename, float width, float height)

11
src/visual/drawing.cpp Executable file → Normal file
View File

@ -46,9 +46,9 @@ void DrawStrings()
int y{ 8 };
for (size_t i = 0; i < side_strings_count; ++i)
{
glez::draw::outlined_string(
8, y, side_strings[i], *fonts::menu,
side_strings_colors[i], colors::black, nullptr, nullptr);
glez::draw::outlined_string(8, y, side_strings[i], *fonts::menu,
side_strings_colors[i], colors::black,
nullptr, nullptr);
y += fonts::menu->size + 1;
}
y = draw::height / 2;
@ -57,8 +57,8 @@ void DrawStrings()
float sx, sy;
fonts::menu->stringSize(center_strings[i], &sx, &sy);
glez::draw::outlined_string(
(draw::width - sx) / 2, y, center_strings[i].c_str(),
*fonts::menu, center_strings_colors[i], colors::black, nullptr, nullptr);
(draw::width - sx) / 2, y, center_strings[i].c_str(), *fonts::menu,
center_strings_colors[i], colors::black, nullptr, nullptr);
y += fonts::menu->size + 1;
}
}
@ -81,7 +81,6 @@ namespace fonts
std::unique_ptr<glez::font> menu{ nullptr };
std::unique_ptr<glez::font> esp{ nullptr };
}
void draw::Initialize()

View File

@ -102,6 +102,7 @@ void DrawCheatVisuals()
}
}
}
hacks::tf2::global::runcfg();
if (spectator_target)
{
AddCenterString("Press SPACE to stop spectating");

View File

@ -96,8 +96,9 @@ void DrawSpinner()
int state = min(3, int(spinning_speed / 250));
glez::draw::rect_textured(draw::width / 2, draw::height / 2, size, size,
colors::white, textures::atlas().texture, 64 * state,
(3 + (v9mode ? 0 : 1)) * 64, 64, 64, angle);
colors::white, textures::atlas().texture,
64 * state, (3 + (v9mode ? 0 : 1)) * 64, 64, 64,
angle);
if (angle > PI * 4)
angle -= PI * 4;
}