Merge remote-tracking branch 'origin/testing' into testing

This commit is contained in:
TotallyNotElite 2019-01-13 14:18:52 +01:00
commit 44f5206e38
7 changed files with 60 additions and 23 deletions

View File

@ -28,6 +28,9 @@ extern settings::Bool crypt_chat;
extern settings::Bool nolerp; extern settings::Bool nolerp;
extern settings::Bool no_zoom; extern settings::Bool no_zoom;
extern settings::Bool disable_visuals; extern settings::Bool disable_visuals;
extern settings::Int print_r;
extern settings::Int print_g;
extern settings::Int print_b;
void SetCanshootStatus(); void SetCanshootStatus();
extern bool CanShootException; extern bool CanShootException;

View File

@ -38,3 +38,6 @@ settings::Bool clean_screenshots{ "visual.clean-screenshots", "false" };
settings::Bool nolerp{ "misc.no-lerp", "false" }; settings::Bool nolerp{ "misc.no-lerp", "false" };
settings::Bool no_zoom{ "remove.scope", "false" }; settings::Bool no_zoom{ "remove.scope", "false" };
settings::Bool disable_visuals{ "visual.disable", "false" }; settings::Bool disable_visuals{ "visual.disable", "false" };
settings::Int print_r{ "print.rgb.r", "183" };
settings::Int print_g{ "print.rgb.b", "27" };
settings::Int print_b{ "print.rgb.g", "139" };

View File

@ -13,6 +13,7 @@
#include "common.hpp" #include "common.hpp"
#include "hack.hpp" #include "hack.hpp"
#include "MiscTemporary.hpp"
settings::Bool log_to_console{ "hack.log-console", "false" }; settings::Bool log_to_console{ "hack.log-console", "false" };
@ -51,7 +52,7 @@ void logging::Info(const char *fmt, ...)
if (!hack::shutdown) if (!hack::shutdown)
{ {
if (*log_to_console) if (*log_to_console)
g_ICvar->ConsolePrintf("CAT: %s \n", result.get()); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: %s \n", result.get());
} }
#endif #endif
} }

View File

@ -297,6 +297,7 @@ void DoResistSwitching()
} }
int force_healing_target{ 0 }; int force_healing_target{ 0 };
unsigned steamid = 0;
static CatCommand heal_steamid("autoheal_heal_steamid", "Heals a player with SteamID", [](const CCommand &args) { static CatCommand heal_steamid("autoheal_heal_steamid", "Heals a player with SteamID", [](const CCommand &args) {
if (args.ArgC() < 2) if (args.ArgC() < 2)
{ {
@ -382,7 +383,7 @@ void UpdateData()
if (reset_cd[i].test_and_set(10000)) if (reset_cd[i].test_and_set(10000))
data[i] = {}; data[i] = {};
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_GOOD(ent)) if (CE_GOOD(ent) && ent->m_bAlivePlayer())
{ {
int health = ent->m_iHealth(); int health = ent->m_iHealth();
if (data[i].last_damage > g_GlobalVars->curtime) if (data[i].last_damage > g_GlobalVars->curtime)
@ -395,7 +396,7 @@ void UpdateData()
data[i].accum_damage_start = 0.0f; data[i].accum_damage_start = 0.0f;
} }
const int last_health = data[i].last_health; const int last_health = data[i].last_health;
if (health != last_health) if (health != last_health && health <= g_pPlayerResource->GetMaxHealth(ent))
{ {
reset_cd[i].update(); reset_cd[i].update();
data[i].last_health = health; data[i].last_health = health;
@ -523,7 +524,7 @@ void CreateMove()
current_user_cmd->buttons |= IN_ATTACK2; current_user_cmd->buttons |= IN_ATTACK2;
} }
} }
if (!force_healing_target && !enable) if (!force_healing_target && !steamid && !enable)
return; return;
if (GetWeaponMode() != weapon_medigun) if (GetWeaponMode() != weapon_medigun)
return; return;
@ -532,10 +533,27 @@ void CreateMove()
CachedEntity *target = ENTITY(force_healing_target); CachedEntity *target = ENTITY(force_healing_target);
if (CE_GOOD(target)) if (CE_GOOD(target))
{ {
Vector out; if (target->player_info.friendsID != steamid)
GetHitbox(target, 7, out); force_healing_target = 0;
AimAt(g_pLocalPlayer->v_Eye, out, current_user_cmd); else
current_user_cmd->buttons |= IN_ATTACK; {
Vector out;
GetHitbox(target, 7, out);
AimAt(g_pLocalPlayer->v_Eye, out, current_user_cmd);
current_user_cmd->buttons |= IN_ATTACK;
}
}
}
else if (steamid)
{
for (auto i = 0; i < g_IEngine->GetMaxClients(); i++)
{
CachedEntity *ent = ENTITY(i);
if (ent->player_info.friendsID == steamid)
{
force_healing_target = steamid;
break;
}
} }
} }
if (!enable) if (!enable)
@ -587,8 +605,13 @@ void CreateMove()
void rvarCallback(settings::VariableBase<int> &var, int after) void rvarCallback(settings::VariableBase<int> &var, int after)
{ {
if (after < 0) if (!after)
{
force_healing_target = 0;
steamid = 0;
return; return;
}
steamid = after;
for (int i = 1; i <= 32 && i < HIGHEST_ENTITY; i++) for (int i = 1; i <= 32 && i < HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
@ -603,8 +626,13 @@ void rvarCallback(settings::VariableBase<int> &var, int after)
} }
} }
} }
void LevelInit()
{
force_healing_target = 0;
}
static InitRoutine Init([]() { static InitRoutine Init([]() {
steam_var.installChangeCallback(rvarCallback); steam_var.installChangeCallback(rvarCallback);
EC::Register(EC::CreateMove, CreateMove, "autoheal", EC::average); EC::Register(EC::CreateMove, CreateMove, "autoheal", EC::average);
EC::Register(EC::LevelInit, LevelInit, "autoheal_lvlinit", EC::average);
}); });
} // namespace hacks::tf::autoheal } // namespace hacks::tf::autoheal

View File

@ -11,6 +11,7 @@
#include "common.hpp" #include "common.hpp"
#include "hack.hpp" #include "hack.hpp"
#include "MiscTemporary.hpp"
static settings::Bool autojoin_team{ "autojoin.team", "false" }; static settings::Bool autojoin_team{ "autojoin.team", "false" };
static settings::Int autojoin_class{ "autojoin.class", "0" }; static settings::Int autojoin_class{ "autojoin.class", "0" };
@ -131,7 +132,7 @@ void onShutdown()
tfmm::startQueue(); tfmm::startQueue();
} }
static CatCommand get_steamid("print_steamid", "Prints your SteamID", []() { g_ICvar->ConsolePrintf("%u\n", g_ISteamUser->GetSteamID().GetAccountID()); }); static CatCommand get_steamid("print_steamid", "Prints your SteamID", []() { g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "%u\n", g_ISteamUser->GetSteamID().GetAccountID()); });
static InitRoutine init([]() { static InitRoutine init([]() {
EC::Register(EC::CreateMove, update, "cm_autojoin", EC::average); EC::Register(EC::CreateMove, update, "cm_autojoin", EC::average);

View File

@ -7,7 +7,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <thread> #include <thread>
#include <MiscTemporary.hpp>
/* /*
Created on 29.07.18. Created on 29.07.18.
*/ */
@ -17,14 +17,14 @@ static void getAndSortAllConfigs();
static CatCommand cat("cat", "", [](const CCommand &args) { static CatCommand cat("cat", "", [](const CCommand &args) {
if (args.ArgC() < 3) if (args.ArgC() < 3)
{ {
g_ICvar->ConsolePrintf("Usage: cat <set/get> <variable> [value]\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "Usage: cat <set/get> <variable> [value]\n");
return; return;
} }
auto variable = settings::Manager::instance().lookup(args.Arg(2)); auto variable = settings::Manager::instance().lookup(args.Arg(2));
if (variable == nullptr) if (variable == nullptr)
{ {
g_ICvar->ConsolePrintf("Variable not found: %s\n", args.Arg(2)); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "Variable not found: %s\n", args.Arg(2));
return; return;
} }
@ -32,21 +32,21 @@ static CatCommand cat("cat", "", [](const CCommand &args) {
{ {
if (args.ArgC() < 4) if (args.ArgC() < 4)
{ {
g_ICvar->ConsolePrintf("Usage: cat <set> <variable> <value>\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "Usage: cat <set> <variable> <value>\n");
return; return;
} }
variable->fromString(args.Arg(3)); variable->fromString(args.Arg(3));
g_ICvar->ConsolePrintf("%s = \"%s\"\n", args.Arg(2), variable->toString().c_str()); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "%s = \"%s\"\n", args.Arg(2), variable->toString().c_str());
return; return;
} }
else if (!strcmp(args.Arg(1), "get")) else if (!strcmp(args.Arg(1), "get"))
{ {
g_ICvar->ConsolePrintf("%s = \"%s\"\n", args.Arg(2), variable->toString().c_str()); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "%s = \"%s\"\n", args.Arg(2), variable->toString().c_str());
return; return;
} }
else else
{ {
g_ICvar->ConsolePrintf("Usage: cat <set/get> <variable> <value>\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "Usage: cat <set/get> <variable> <value>\n");
return; return;
} }
}); });

View File

@ -8,6 +8,7 @@
#include "core/logging.hpp" #include "core/logging.hpp"
#include "interfaces.hpp" #include "interfaces.hpp"
#include "icvar.h" #include "icvar.h"
#include "MiscTemporary.hpp"
settings::SettingsWriter::SettingsWriter(settings::Manager &manager) : manager(manager) settings::SettingsWriter::SettingsWriter(settings::Manager &manager) : manager(manager)
{ {
@ -23,7 +24,7 @@ bool settings::SettingsWriter::saveTo(std::string path, bool only_changed)
if (!stream || stream.bad() || !stream.is_open() || stream.fail()) if (!stream || stream.bad() || !stream.is_open() || stream.fail())
{ {
logging::Info("cat_save: FATAL! FAILED to create stream!"); logging::Info("cat_save: FATAL! FAILED to create stream!");
g_ICvar->ConsolePrintf("CAT: cat_save: Can't create config file!\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: cat_save: Can't create config file!\n");
return false; return false;
} }
@ -46,11 +47,11 @@ bool settings::SettingsWriter::saveTo(std::string path, bool only_changed)
} }
if (!stream || stream.bad() || stream.fail()) if (!stream || stream.bad() || stream.fail())
{ {
g_ICvar->ConsolePrintf("CAT: cat_save: Failed to save config!\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: cat_save: Failed to save config!\n");
logging::Info("cat_save: FATAL! Stream bad!"); logging::Info("cat_save: FATAL! Stream bad!");
} }
else else
g_ICvar->ConsolePrintf("CAT: cat_save: Successfully saved config!\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: cat_save: Successfully saved config!\n");
stream.close(); stream.close();
if (stream.fail()) if (stream.fail())
logging::Info("cat_save: FATAL! Stream bad (2)!"); logging::Info("cat_save: FATAL! Stream bad (2)!");
@ -99,7 +100,7 @@ bool settings::SettingsReader::loadFrom(std::string path)
if (stream.fail()) if (stream.fail())
{ {
logging::Info("cat_load: Can't access file!"); logging::Info("cat_load: Can't access file!");
g_ICvar->ConsolePrintf("CAT: cat_load: File doesn't exist / can't open file!\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: cat_load: File doesn't exist / can't open file!\n");
return false; return false;
} }
@ -114,12 +115,12 @@ bool settings::SettingsReader::loadFrom(std::string path)
if (stream.fail() && !stream.eof()) if (stream.fail() && !stream.eof())
{ {
logging::Info("cat_load: FATAL: Read failed!"); logging::Info("cat_load: FATAL: Read failed!");
g_ICvar->ConsolePrintf("CAT: cat_load: Failed to read config!\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: cat_load: Failed to read config!\n");
return false; return false;
} }
logging::Info("cat_load: Read Success!"); logging::Info("cat_load: Read Success!");
g_ICvar->ConsolePrintf("CAT: cat_load: Successfully loaded config!\n"); g_ICvar->ConsoleColorPrintf(Color(*print_r, *print_g, *print_b, 255), "CAT: cat_load: Successfully loaded config!\n");
finishString(true); finishString(true);
return true; return true;