Skip to content

Commit

Permalink
Fix antiaim with grappling hook
Browse files Browse the repository at this point in the history
Fix antiaim with grappling hook
  • Loading branch information
iraizo authored and BenCat07 committed May 6, 2021
1 parent 1e14a64 commit 70d5a7a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -290,3 +290,5 @@ scripts/updater-preferences

*.autosave

# clangd
.cache
2 changes: 2 additions & 0 deletions include/hacks/AntiAim.hpp
Expand Up @@ -6,6 +6,7 @@
*/

#pragma once
#include <inetmessage.h>

class CUserCmd;

Expand All @@ -17,4 +18,5 @@ void SetSafeSpace(int safespace);
bool ShouldAA(CUserCmd *cmd);
void ProcessUserCmd(CUserCmd *cmd);
bool isEnabled();
void SendNetMessage(INetMessage &msg);
} // namespace hacks::shared::antiaim
24 changes: 23 additions & 1 deletion src/hacks/AntiAim.cpp
Expand Up @@ -10,7 +10,6 @@
#include <hacks/AntiAim.hpp>

#include "common.hpp"

namespace hacks::shared::antiaim
{
bool force_fakelag = false;
Expand Down Expand Up @@ -199,6 +198,25 @@ void SetSafeSpace(int safespace)
safe_space = safespace;
}

/* checks if action slot is being used */
void SendNetMessage(INetMessage &msg)
{
if (!enable)
return;

if(!((KeyValues *) (((unsigned *) &msg)[4])))
return;

auto name = ((KeyValues *) (((unsigned *) &msg)[4]))->GetName();

if (CE_BAD(LOCAL_E))
return;

/* checks if action slot has been used & grapple is equipped */
if (!strcmp(name, "+use_action_slot_item_server") && HasWeapon(LOCAL_E, 1152))
SetSafeSpace(2);
}

bool ShouldAA(CUserCmd *cmd)
{
if (hacks::tf2::antibackstab::noaa)
Expand All @@ -213,6 +231,10 @@ bool ShouldAA(CUserCmd *cmd)
}
if ((cmd->buttons & IN_ATTACK2) && classid == CL_CLASS(CTFLunchBox))
return false;
if ((cmd->buttons & IN_ATTACK) && classid == CL_CLASS(CTFGrapplingHook) && !g_pLocalPlayer->bAttackLastTick)
{
SetSafeSpace(2);
}
switch (mode)
{
case weapon_projectile:
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/SendNetMsg.cpp
Expand Up @@ -5,6 +5,7 @@

#include <MiscTemporary.hpp>
#include <settings/Int.hpp>
#include "AntiAim.hpp"
#include "HookedMethods.hpp"
#include <MiscTemporary.hpp>
#include "nullnexus.hpp"
Expand Down Expand Up @@ -291,7 +292,10 @@ DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &msg, boo
}
}*/
if (!strcmp(msg.GetName(), "clc_CmdKeyValues"))
{
hacks::shared::antiaim::SendNetMessage(msg);
hacks::shared::catbot::SendNetMsg(msg);
}
if (log_sent && msg.GetType() != 3 && msg.GetType() != 9)
{
if (!strcmp(msg.GetName(), "clc_CmdKeyValues"))
Expand Down

0 comments on commit 70d5a7a

Please sign in to comment.