From 9bdc12094e2979681787841157053f8c423c92d0 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Wed, 3 May 2017 23:22:55 +0300 Subject: [PATCH] add uberspam --- src/gui/ncc/Menu.cpp | 5 ++ src/hacks/UberSpam.cpp | 98 ++++++++++++++++++++++++++++++++++++++++ src/hacks/UberSpam.hpp | 24 ++++++++++ src/hacks/hacklist.h | 1 + src/hooks/CreateMove.cpp | 1 + 5 files changed, 129 insertions(+) create mode 100644 src/hacks/UberSpam.cpp create mode 100644 src/hacks/UberSpam.hpp diff --git a/src/gui/ncc/Menu.cpp b/src/gui/ncc/Menu.cpp index 59a470c8..7e45c31d 100644 --- a/src/gui/ncc/Menu.cpp +++ b/src/gui/ncc/Menu.cpp @@ -531,6 +531,11 @@ static const std::string list_tf2 = R"( "killsay" "spam" "spam_random" + "uberspam" + "uberspam_build" + "uberspam_ready" + "uberspam_used" + "uberspam_ended" ] "Follow Bot" [ diff --git a/src/hacks/UberSpam.cpp b/src/hacks/UberSpam.cpp new file mode 100644 index 00000000..962c9bfe --- /dev/null +++ b/src/hacks/UberSpam.cpp @@ -0,0 +1,98 @@ +/* + * UberSpam.cpp + * + * Created on: May 3, 2017 + * Author: nullifiedcat + */ + +#include "UberSpam.hpp" + +namespace hacks { namespace tf { namespace uberspam { + +TextFile custom_lines; + +static CatEnum source_enum({"DISABLED", "CATHOOK", "NCC", "CUSTOM"}); +static CatVar source(source_enum, "uberspam", "0", "Ubercharge Spam", "Defines spam ubercharge source"); +static CatVar on_ready(CV_SWITCH, "uberspam_ready", "1", "Uber Ready"); +static CatVar on_used(CV_SWITCH, "uberspam_used", "1", "Uber Used"); +static CatVar on_ended(CV_SWITCH, "uberspam_ended", "1", "Uber Ended"); +static CatVar on_build(CV_INT, "uberspam_build", "25", "Uber Build", "Send a message every #% ubercharge. 0 = never send", 0, 100); +static CatVar custom_file(CV_STRING, "uberspam_file", "uberspam.txt", "Ubercharge Spam File", "Use cat_uberspam_file_reload! Same as spam/killsay files."); +static CatCommand custom_file_reload("uberspam_file_reload", "Reload Ubercharge Spam File", []() { + custom_lines.Load(std::string(custom_file.GetString())); +}); + +const std::vector* GetSource() { + switch ((int)source) { + case 1: + return &builtin_cathook; + case 2: + return &builtin_nonecore; + case 3: + return &custom_lines.lines; + } + return nullptr; +} + +int ChargePercentLineIndex(float chargef) { + if ((int)on_build <= 0) return 0; + int charge = chargef * 100.0f; + if (charge == 100) return 0; + auto src = GetSource(); + if (!src) return 0; + int lines = src->size() - 3; + if (lines <= 0) return 0; + int cpl = 100 / lines; + return 3 + (charge / cpl); +} + +void CreateMove() { + if (!GetSource()) return; + if (LOCAL_W->m_iClassID != g_pClassID->CWeaponMedigun) return; + if (GetSource()->size() < 4) return; + float charge = CE_FLOAT(LOCAL_W, netvar.m_flChargeLevel); + static bool release_last_frame = false; + static int last_charge = 0; + bool release = CE_BYTE(LOCAL_W, netvar.bChargeRelease); + if (release_last_frame != release) { + if (release) { + if (on_used) chat_stack::stack.push(GetSource()->at(1)); + } else { + if (on_ended) chat_stack::stack.push(GetSource()->at(2)); + } + } + if (!release && ((int)(100.0f * charge) != last_charge)) { + if (charge == 1.0f) { + if (on_ready) chat_stack::stack.push(GetSource()->at(0)); + } else { + if ((int)(charge * 100.0f) != 0 && on_build) { + if (((int)(charge * 100.0f) % (int)on_build) == 0) { + std::string res = GetSource()->at(ChargePercentLineIndex(charge)); + ReplaceString(res, "%i%", std::to_string((int)(charge * 100.0f))); + chat_stack::stack.push(res); + } + } + } + } + release_last_frame = release; + last_charge = (int)(100.0f * charge); +} + +// Ready, Used, Ended, %... + +const std::vector builtin_cathook = { + "-> I am charged!", + "-> Not a step back! UBERCHARGE USED!", + "-> My Ubercharge comes to an end!", + "-> I have a bit of ubercharge!", + "-> I have half of the ubercharge!", + "-> Ubercharge almost ready!" +}; +const std::vector builtin_nonecore = { + ">>> GET READY TO RUMBLE! <<<", + ">>> CHEATS ACTIVATED! <<<", + ">>> RUMBLE COMPLETE! <<<", + ">>> RUMBLE IS %i%% CHARGED! <<<" +}; + +}}} diff --git a/src/hacks/UberSpam.hpp b/src/hacks/UberSpam.hpp new file mode 100644 index 00000000..bb3a93e9 --- /dev/null +++ b/src/hacks/UberSpam.hpp @@ -0,0 +1,24 @@ +/* + * UberSpam.hpp + * + * Created on: May 3, 2017 + * Author: nullifiedcat + */ + +#ifndef HACKS_UBERSPAM_HPP_ +#define HACKS_UBERSPAM_HPP_ + +#include "../common.h" + +namespace hacks { namespace tf { namespace uberspam { + +void CreateMove(); + +// Ready, Used, Ended, %... + +extern const std::vector builtin_cathook; +extern const std::vector builtin_nonecore; + +}}} + +#endif /* HACKS_UBERSPAM_HPP_ */ diff --git a/src/hacks/hacklist.h b/src/hacks/hacklist.h index eac379f3..fe453563 100644 --- a/src/hacks/hacklist.h +++ b/src/hacks/hacklist.h @@ -23,6 +23,7 @@ #include "SpyAlert.h" #include "Trigger.h" #include "KillSay.h" +#include "UberSpam.hpp" #include "Achievement.h" #include "Spam.h" #include "Noisemaker.h" diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 4cc74cc9..7295211d 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -178,6 +178,7 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { //RunEnginePrediction(g_pLocalPlayer->entity, cmd); SAFE_CALL(hacks::shared::esp::CreateMove()); if (!g_pLocalPlayer->life_state && CE_GOOD(g_pLocalPlayer->weapon())) { + if (TF) SAFE_CALL(hacks::tf::uberspam::CreateMove()); if (TF2) SAFE_CALL(hacks::tf2::antibackstab::CreateMove()); if (TF2) SAFE_CALL(hacks::tf2::noisemaker::CreateMove()); SAFE_CALL(hacks::shared::bunnyhop::CreateMove());