diff --git a/external/co-library b/external/co-library index 9e964569..393948a6 160000 --- a/external/co-library +++ b/external/co-library @@ -1 +1 @@ -Subproject commit 9e964569bf615e092f03ba5ee69fe1417fd881b3 +Subproject commit 393948a6bf7ee4a62f5a3bd82d94c05d4bc405aa diff --git a/external/libglez b/external/libglez index 9457ea15..7ccff462 160000 --- a/external/libglez +++ b/external/libglez @@ -1 +1 @@ -Subproject commit 9457ea150e041689c6f38f5720b4d571cf64a943 +Subproject commit 7ccff462376086465ad5795514cdd83f587dbdb4 diff --git a/include/hacks/CMakeLists.txt b/include/hacks/CMakeLists.txt index df18df8e..9a265591 100755 --- a/include/hacks/CMakeLists.txt +++ b/include/hacks/CMakeLists.txt @@ -27,6 +27,7 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/FollowBot.hpp" "${CMAKE_CURRENT_LIST_DIR}/hacklist.hpp" "${CMAKE_CURRENT_LIST_DIR}/KillSay.hpp" + "${CMAKE_CURRENT_LIST_DIR}/DominateSay.hpp" "${CMAKE_CURRENT_LIST_DIR}/Killstreak.hpp" "${CMAKE_CURRENT_LIST_DIR}/LightESP.hpp" "${CMAKE_CURRENT_LIST_DIR}/Misc.hpp" diff --git a/include/hacks/DominateSay.hpp b/include/hacks/DominateSay.hpp new file mode 100644 index 00000000..92e01f2d --- /dev/null +++ b/include/hacks/DominateSay.hpp @@ -0,0 +1,20 @@ +/* + * DominateSay.h + * + * Created on: Oct 30, 2017 + */ + +#pragma once + +#include "common.hpp" + +namespace hacks::shared::dominatesay +{ + +void init(); +void shutdown(); +void reload(); + +extern const std::vector builtin_default; +extern const std::vector jp_anime; +} // namespace hacks::shared::dominatesay diff --git a/src/hacks/CMakeLists.txt b/src/hacks/CMakeLists.txt index 9aa35914..ec152c61 100755 --- a/src/hacks/CMakeLists.txt +++ b/src/hacks/CMakeLists.txt @@ -26,6 +26,7 @@ if(NOT LagbotMode) "${CMAKE_CURRENT_LIST_DIR}/Backtrack.cpp" "${CMAKE_CURRENT_LIST_DIR}/FollowBot.cpp" "${CMAKE_CURRENT_LIST_DIR}/KillSay.cpp" + "${CMAKE_CURRENT_LIST_DIR}/DominateSay.cpp" "${CMAKE_CURRENT_LIST_DIR}/Killstreak.cpp" "${CMAKE_CURRENT_LIST_DIR}/LightESP.cpp" "${CMAKE_CURRENT_LIST_DIR}/Misc.cpp" diff --git a/src/hacks/DominateSay.cpp b/src/hacks/DominateSay.cpp new file mode 100644 index 00000000..b338e159 --- /dev/null +++ b/src/hacks/DominateSay.cpp @@ -0,0 +1,141 @@ +/* + * DominateSay.cpp + * + * Created on: October 30, 2018 + */ + +#include +#include +#include "common.hpp" + +static settings::Int dominatesay_mode{ "dominatesay.mode", "0" }; +static settings::String filename{ "dominatesay.file", "dominatesay.txt" }; + +static CatCommand reload_command("dominatesay_reload", "Reload dominatesays", + []() { + hacks::shared::dominatesay::reload(); + }); + +namespace hacks::shared::dominatesay +{ + +const std::string tf_classes_dominatesay[] = { "class", "scout", "sniper", + "soldier", "demoman", "medic", + "heavy", "pyro", "spy", + "engineer" }; + +const std::string tf_teams_dominatesay[] = { "RED", "BLU" }; + +static std::string lastmsg{}; + +TextFile file{}; + +std::string ComposeDominateSay(IGameEvent *event) +{ + const std::vector *source = nullptr; + switch (*dominatesay_mode) + { + case 1: + source = &file.lines; + break; + case 2: + source = &builtin_default; + break; + case 3: + source = &jp_anime; + break; + default: + break; + } + if (!source || source->empty()) + return ""; + if (!event) + return ""; + int vid = event->GetInt("dominated"); + int kid = event->GetInt("dominator"); + int dnum = event->GetInt("dominations"); + + // this is actually impossible but just in case. + if (g_IEngine->GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer()) + return ""; + + std::string msg = source->at(rand() % source->size()); + + while (msg == lastmsg && source->size() > 1) + msg = source->at(rand() % source->size()); + lastmsg = msg; + player_info_s info{}; + + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(vid), &info); + ReplaceString(msg, "%name%", std::string(info.name)); + + CachedEntity *ent = ENTITY(g_IEngine->GetPlayerForUserID(vid)); + int clz = g_pPlayerResource->GetClass(ent); + + ReplaceString(msg, "%class%", tf_classes_dominatesay[clz]); + player_info_s infok{}; + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(kid), &infok); + + ReplaceString(msg, "%dominum%", std::to_string(dnum)); + ReplaceString(msg, "%killer%", std::string(infok.name)); + ReplaceString(msg, "%team%", tf_teams_dominatesay[ent->m_iTeam() - 2]); + ReplaceString(msg, "%myteam%", + tf_teams_dominatesay[LOCAL_E->m_iTeam() - 2]); + ReplaceString(msg, "%myclass%", + tf_classes_dominatesay[g_pPlayerResource->GetClass(LOCAL_E)]); + ReplaceString(msg, "\\n", "\n"); + return msg; +} + +class DominateSayEventListener : public IGameEventListener2 +{ + void FireGameEvent(IGameEvent *event) override + { + if (!dominatesay_mode) + return; + std::string message = + hacks::shared::dominatesay::ComposeDominateSay(event); + if (!message.empty()) + chat_stack::Say(message, false); + } +}; + +static DominateSayEventListener listener{}; + +void reload() +{ + file.Load(*filename); +} + +void init() +{ + g_IEventManager2->AddListener(&listener, (const char *) "player_domination", + false); +} + +void shutdown() +{ + g_IEventManager2->RemoveListener(&listener); +} + +// a much better default dominatesay would be appreciated. +const std::vector builtin_default = { + "dominating %name%! (%dominum% dominations)", + "%name%, getting tapped?", + "%killer% is dominating the server with %dominum% dominations!", +}; + +// same goes to this one +const std::vector jp_anime = { + "Get d-dominated %name%-senpai >:3", + "g- gomenasai! %name%-san!", + "Wow! hey hey hey H~ ey !!! I found you again~~!", + "%name%-san please don't get mad at me.. ><", + // https://youtu.be/sW3RT0tF020?t=207 + "kore kara mo douzo yoroshiku ne.", + "konna watashi dakedo waratte yurushite ne.", + "zutto taisetsu ni shite ne.", + "eikyuu hoshou no watashi dakara.", +}; + +} // namespace hacks::shared::dominatesay