heal arrows callout, close #175

This commit is contained in:
nullifiedcat 2017-07-07 13:17:34 +03:00
parent a1fde3f4de
commit 82089d5285
5 changed files with 50 additions and 2 deletions

View File

@ -270,6 +270,7 @@ void hack::Initialize() {
logging::Info("SDL hooking done");
g_IGameEventManager->AddListener(&adv_event_listener, false);
hacks::shared::anticheat::Init();
hacks::tf2::healarrow::Init();
InitSpinner();
logging::Info("Initialized Fidget Spinner");

View File

@ -10,11 +10,53 @@
namespace hacks { namespace tf2 { namespace healarrow {
static CatVar healarrow_charge(CV_FLOAT, "healarrow_charge", "0.25", "Healarrow Charge");
static CatVar healarrow_timeout(CV_FLOAT, "healarrow_timeout", "12.5", "Healarrow Timeout");
static CatVar healarrow_timeout(CV_FLOAT, "healarrow_timeout", "2", "Healarrow Timeout");
static CatVar healarrow(CV_SWITCH, "healarrow", "0", "Heal Arrow");
static CatVar healarrow_callout(CV_SWITCH, "healarrow_callout", "0", "Call Out", "Send a message to chat when you heal someone with an arrow");
static CatVar healarrow_callout_message(CV_STRING, "healarrow_callout_text", "Hey %%, I've just healed you for $$ HP! Your health is now ##.", "Call Out Text", "Formatting:\n%% - player name\n$$ - healing amount\n## - new health\n@@ - old health");
float healarrow_time = 0.0f;
class HealArrowListener : public IGameEventListener {
public:
virtual void FireGameEvent(KeyValues* event) {
if (!healarrow) return;
if (!healarrow_callout) return;
if (CE_BAD(LOCAL_W)) return;
if (LOCAL_W->m_iClassID != CL_CLASS(CTFCompoundBow)) return;
std::string name(event->GetName());
if (name == "player_hurt") {
int attacker = event->GetInt("attacker");
int victim = event->GetInt("userid");
int eid = g_IEngine->GetPlayerForUserID(attacker);
int vid = g_IEngine->GetPlayerForUserID(victim);
if (eid == g_IEngine->GetLocalPlayer()) {
int damageamount = event->GetInt("damageamount");
if (damageamount < 0) {
player_info_s pinfo;
if (g_IEngine->GetPlayerInfo(vid, &pinfo)) {
std::string msg(healarrow_callout_message.GetString());
ReplaceString(msg, "$$", std::to_string(-damageamount));
auto v_entity = ENTITY(vid);
if (CE_GOOD(v_entity)) {
ReplaceString(msg, "##", std::to_string(CE_INT(v_entity, netvar.iHealth) - damageamount));
ReplaceString(msg, "@@", std::to_string(CE_INT(v_entity, netvar.iHealth)));
}
ReplaceString(msg, "%%", pinfo.name);
chat_stack::Say(msg);
}
}
}
}
}
};
HealArrowListener listener;
void Init() {
g_IGameEventManager->AddListener(&listener, false);
}
void CreateMove() {
if (CE_BAD(LOCAL_W)) return;
if (healarrow) {

View File

@ -11,5 +11,6 @@ namespace hacks { namespace tf2 { namespace healarrow {
void CreateMove();
void Draw();
void Init();
}}}

View File

@ -449,7 +449,9 @@
"list": [
"healarrow",
"healarrow_charge",
"healarrow_timeout"
"healarrow_timeout",
"healarrow_callout",
"healarrow_callout_text"
]
},
{

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
echo "Searching for Team Fortress 2"
echo "Please wait..."
find / -type d -name "Team Fortress 2" 2>/dev/null | while read path; do
if [ -e "$path/tf/gameinfo.txt" ]; then
@ -10,6 +11,7 @@ find / -type d -name "Team Fortress 2" 2>/dev/null | while read path; do
ln -s "$path/cathook" "Data Folder"
rsync -avh --progress tf-settings/ "$path/cathook"
echo "Symbolic link created (Data Folder)"
echo "You can close this window"
read -p "Press ENTER to continue"
fi
fi