From efa58329db39156138e433bd7641a4495434fd4d Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Mon, 19 Dec 2016 13:37:28 +0300 Subject: [PATCH] FIX thirdperson --- cathook/src/drawing.cpp | 2 +- cathook/src/entity.cpp | 2 + cathook/src/entity.h | 3 + cathook/src/globals.cpp | 2 + cathook/src/globals.h | 2 + cathook/src/gui/controls.cpp | 3 +- cathook/src/hack.cpp | 14 ++++- cathook/src/hacks/Aimbot.cpp | 11 +++- cathook/src/hacks/Aimbot.h | 1 + cathook/src/hacks/Misc.cpp | 5 +- cathook/src/hacks/Misc.h | 2 +- cathook/src/helpers.cpp | 3 +- cathook/src/interfaces.cpp | 3 +- cathook/src/interfaces.h | 2 + cathook/src/sdk.h | 1 + cathook/src/sdk/iinput.h | 118 +++++++++++++++++++++++++++++++++++ 16 files changed, 164 insertions(+), 10 deletions(-) create mode 100644 cathook/src/sdk/iinput.h diff --git a/cathook/src/drawing.cpp b/cathook/src/drawing.cpp index 264e11c4..aafe462c 100644 --- a/cathook/src/drawing.cpp +++ b/cathook/src/drawing.cpp @@ -90,7 +90,7 @@ Color draw::black(0, 0, 0, 255); Color colors::white(255, 255, 255, 255); Color colors::pink (255, 105, 180, 255); -Color colors::pinka(255, 105, 180, 180); +Color colors::pinka(255, 105, 180, 100); Color colors::bg_blk(0, 0, 0, 180); Color colors::black(0, 0, 0, 255); Color colors::tf_red(184, 56, 59, 255); diff --git a/cathook/src/entity.cpp b/cathook/src/entity.cpp index 0448f394..6b7da952 100644 --- a/cathook/src/entity.cpp +++ b/cathook/src/entity.cpp @@ -54,6 +54,8 @@ void EntityVariables::Init() { this->Rocket_iDeflected = gNetvars.get_offset("DT_TFBaseRocket", "m_iDeflected"); this->Grenade_iDeflected = gNetvars.get_offset("DT_TFWeaponBaseGrenadeProj", "m_iDeflected"); this->bDistributed = gNetvars.get_offset("DT_CurrencyPack", "m_bDistributed"); + this->angEyeAngles = gNetvars.get_offset("DT_TFPlayer", "tfnonlocaldata", "m_angEyeAngles[0]"); + this->deadflag = gNetvars.get_offset("DT_BasePlayer", "pl", "deadflag"); } void InitEntityOffsets() { diff --git a/cathook/src/entity.h b/cathook/src/entity.h index cfdcd195..e96ff6ea 100644 --- a/cathook/src/entity.h +++ b/cathook/src/entity.h @@ -84,6 +84,9 @@ public: offset_t Grenade_iDeflected; offset_t bDistributed; + + offset_t angEyeAngles; + offset_t deadflag; }; extern EntityVariables netvar; diff --git a/cathook/src/globals.cpp b/cathook/src/globals.cpp index 46b34645..8ee3e3a1 100644 --- a/cathook/src/globals.cpp +++ b/cathook/src/globals.cpp @@ -17,6 +17,8 @@ void GlobalSettings::Init() { this->bSendPackets = CreateConVar(CON_PREFIX "sendpackets", "1", "Send packets"); this->bShowLogo = CreateConVar(CON_PREFIX "logo", "1", "Show logo"); this->sDisconnectMsg = CreateConVar(CON_PREFIX "disconnect_msg", "", "Set custom disconnect message"); + this->bShowAntiAim = CreateConVar(CON_PREFIX "show_antiaim", "0", "Real angles in thirdperson"); + this->bThirdperson = CreateConVar(CON_PREFIX "thirdpeson", "0", "Thirdperson"); } GlobalSettings g_Settings; diff --git a/cathook/src/globals.h b/cathook/src/globals.h index 53833581..e4c3e6ba 100644 --- a/cathook/src/globals.h +++ b/cathook/src/globals.h @@ -23,6 +23,8 @@ public: ConVar* bShowLogo; ConVar* flDrawingOpacity; ConVar* sDisconnectMsg; + ConVar* bShowAntiAim; + ConVar* bThirdperson; }; extern GlobalSettings g_Settings; diff --git a/cathook/src/gui/controls.cpp b/cathook/src/gui/controls.cpp index 1e9ef62c..b42c6041 100644 --- a/cathook/src/gui/controls.cpp +++ b/cathook/src/gui/controls.cpp @@ -153,7 +153,8 @@ void GUIListElement_SubList::KeyEvent(ButtonCode_t key) { switch (key) { case ButtonCode_t::KEY_ENTER: case ButtonCode_t::KEY_SPACE: - m_pList->Move(m_pParentList->x + LIST_WIDTH, m_pParentList->y + VERTICAL_SPACING * m_nIndex); + case ButtonCode_t::KEY_RIGHT: + m_pList->Move(m_pParentList->x + LIST_WIDTH - 1, m_pParentList->y + VERTICAL_SPACING * m_nIndex); g_pGUI->PushList(m_pList->m_pszListID); } } diff --git a/cathook/src/hack.cpp b/cathook/src/hack.cpp index 70c08749..75b3490f 100644 --- a/cathook/src/hack.cpp +++ b/cathook/src/hack.cpp @@ -62,6 +62,8 @@ typedef void(OverrideView_t)(void*, CViewSetup*); typedef void(FrameStageNotify_t)(void*, int); typedef bool(DispatchUserMessage_t)(void*, int, bf_read&); +Vector last_angles(0.0f, 0.0f, 0.0f); + bool hack::invalidated = true; void hack::Hk_OverrideView(void* thisptr, CViewSetup* setup) { @@ -256,8 +258,9 @@ bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) { float yaw = deg2rad(ang.y - g_pLocalPlayer->v_OrigViewangles.y + cmd->viewangles.y); cmd->forwardmove = cos(yaw) * speed; cmd->sidemove = sin(yaw) * speed; - return false; + ret = false; } + last_angles = cmd->viewangles; return ret; } @@ -270,6 +273,15 @@ void hack::Hk_FrameStageNotify(void* thisptr, int stage) { SetEntityValue(g_pLocalPlayer->weapon, netvar.iItemDefinitionIndex, 1006); } } + if (g_Settings.bThirdperson->GetBool()) { + interfaces::iinput->CAM_ToFirstPerson(); + } + if (stage == 5 && g_Settings.bShowAntiAim->GetBool() && interfaces::iinput->CAM_IsThirdPerson()) { + if (g_pLocalPlayer->entity) { + SetEntityValue(g_pLocalPlayer->entity, netvar.deadflag + 4, last_angles.x); + SetEntityValue(g_pLocalPlayer->entity, netvar.deadflag + 8, last_angles.y); + } + } ((FrameStageNotify_t*)hooks::hkClient->GetMethod(hooks::offFrameStageNotify))(thisptr, stage); if (stage == 5 && g_Settings.bNoFlinch->GetBool()) { static Vector oldPunchAngles = Vector(); diff --git a/cathook/src/hacks/Aimbot.cpp b/cathook/src/hacks/Aimbot.cpp index 068d8da9..4311b00c 100644 --- a/cathook/src/hacks/Aimbot.cpp +++ b/cathook/src/hacks/Aimbot.cpp @@ -99,13 +99,14 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { case weapon_pda: case weapon_consumable: case weapon_throwable: + case weapon_invalid: return true; }; if (g_pLocalPlayer->cond_0 & cond::cloaked) return true; // TODO other kinds of cloak // TODO m_bFeignDeathReady no aim - - if (this->v_bActiveOnlyWhenCanShoot->GetBool() && !BulletTime()) return true; + if (g_pLocalPlayer->weapon->GetClientClass()->m_ClassID != ClassID::CTFMinigun) + if (this->v_bActiveOnlyWhenCanShoot->GetBool() && !BulletTime()) return true; if (this->v_bEnabledAttacking->GetBool() && !(cmd->buttons & IN_ATTACK)) { return true; @@ -118,6 +119,10 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { if (!(cmd->buttons & IN_ATTACK2)) { return true; } + if (m_nMinigunFixTicks > 0) { + m_nMinigunFixTicks--; + cmd->buttons |= IN_ATTACK; + } } if (IsAmbassador(g_pLocalPlayer->weapon)) { @@ -237,6 +242,8 @@ bool Aimbot::CreateMove(void*, float, CUserCmd* cmd) { if (target_highest != 0) { this->m_iLastTarget = target_highest->entindex(); Aim(target_highest, cmd); + if (g_pLocalPlayer->weapon->GetClientClass()->m_ClassID == ClassID::CTFMinigun) + m_nMinigunFixTicks = 10; } return !this->v_bSilent->GetBool(); } diff --git a/cathook/src/hacks/Aimbot.h b/cathook/src/hacks/Aimbot.h index 83d84d81..3d94da2a 100644 --- a/cathook/src/hacks/Aimbot.h +++ b/cathook/src/hacks/Aimbot.h @@ -39,6 +39,7 @@ public: int m_iLastTarget; int m_iHitbox; bool m_bAimKeySwitch; + int m_nMinigunFixTicks; ConVar* v_iAimKey; ConVar* v_iAimKeyMode; ConVar* v_bMinigunFix; diff --git a/cathook/src/hacks/Misc.cpp b/cathook/src/hacks/Misc.cpp index c3064674..a132c52a 100644 --- a/cathook/src/hacks/Misc.cpp +++ b/cathook/src/hacks/Misc.cpp @@ -230,7 +230,7 @@ void CC_SetValue(const CCommand& args) { } Misc::Misc() { - v_bDbWeaponInfo = CreateConVar(CON_PREFIX "misc_debug_weapon", "0", "Debug info: Weapon"); + v_bDebugInfo = CreateConVar(CON_PREFIX "misc_debug", "0", "Debug info"); c_Name = CreateConCommand(CON_PREFIX "name", CC_SetName, "Sets custom name"); c_DumpItemAttributes = CreateConCommand(CON_PREFIX "dump_item_attribs", CC_DumpAttribs, "Dump active weapon attributes"); c_SayLine = CreateConCommand(CON_PREFIX "say_lines", CC_SayLines, "Uses ^ as a newline character"); @@ -299,7 +299,7 @@ bool Misc::CreateMove(void*, float, CUserCmd* cmd) { void Misc::PaintTraverse(void*, unsigned int, bool, bool) { - if (!v_bDbWeaponInfo->GetBool())return; + if (!v_bDebugInfo->GetBool())return; /*if (!interfaces::input->IsButtonDown(ButtonCode_t::KEY_F)) { interfaces::baseClient->IN_ActivateMouse(); } else { @@ -328,6 +328,7 @@ void Misc::PaintTraverse(void*, unsigned int, bool, bool) { AddSideString(draw::white, draw::black, "Speed: %f", speed); AddSideString(draw::white, draw::black, "Gravity: %f", gravity); AddSideString(draw::white, draw::black, "IsZoomed: %i", g_pLocalPlayer->bWasZoomed); + AddSideString(draw::white, draw::black, "IsThirdPerson: %i", interfaces::iinput->CAM_IsThirdPerson()); //AddSideString(draw::white, draw::black, "???: %f", GetEntityValue(g_pLocalPlayer->entity, netvar.test)); //AddSideString(draw::white, draw::black, "VecPunchAngle: %f %f %f", pa.x, pa.y, pa.z); //draw::DrawString(10, y, draw::white, draw::black, false, "VecPunchAngleVel: %f %f %f", pav.x, pav.y, pav.z); diff --git a/cathook/src/hacks/Misc.h b/cathook/src/hacks/Misc.h index 812003ac..d7fd5cd0 100644 --- a/cathook/src/hacks/Misc.h +++ b/cathook/src/hacks/Misc.h @@ -18,7 +18,7 @@ public: DECLARE_HACK_METHODS(); Misc(); //ConVar* v_bNoShootUntilCanHeadshot; - ConVar* v_bDbWeaponInfo; + ConVar* v_bDebugInfo; ConCommand* c_Name; ConVar* v_bInfoSpam; ConVar* v_bFakeCrouch; diff --git a/cathook/src/helpers.cpp b/cathook/src/helpers.cpp index 2ea3e7f2..38017063 100644 --- a/cathook/src/helpers.cpp +++ b/cathook/src/helpers.cpp @@ -455,7 +455,8 @@ bool GetProjectileData(IClientEntity* weapon, float& speed, float& gravity) { rspeed = 1100.0f; break; case ClassID::CTFGrenadeLauncher: - rspeed = ((GetProjectileData*) *(*(const void ***) weapon + 528))(weapon); + rspeed = ((GetProjectileData*) *(*(const void ***) weapon + 527))(weapon); + rgrav = 0.5f; break; case ClassID::CTFCompoundBow: { float servertime = (float)GetEntityValue(g_pLocalPlayer->entity, netvar.nTickBase) * interfaces::gvars->interval_per_tick; diff --git a/cathook/src/interfaces.cpp b/cathook/src/interfaces.cpp index ddccdc79..4d16e3be 100644 --- a/cathook/src/interfaces.cpp +++ b/cathook/src/interfaces.cpp @@ -30,6 +30,7 @@ ICvar* interfaces::cvar = 0; CGlobalVarsBase* interfaces::gvars = 0; IPrediction* interfaces::prediction = 0; IGameMovement* interfaces::gamemovement = 0; +IInput* interfaces::iinput = 0; void interfaces::CreateInterfaces() { interfaces::centerPrint = reinterpret_cast(sharedobj::client->fptr("VCENTERPRINT002", nullptr)); @@ -54,6 +55,6 @@ void interfaces::CreateInterfaces() { //interfaces::gvars = *reinterpret_cast(hudupdate + 13 + *reinterpret_cast(hudupdate + 13 + 3) + 7); interfaces::prediction = reinterpret_cast(sharedobj::client->CreateInterface("VClientPrediction001")); interfaces::gamemovement = reinterpret_cast(sharedobj::client->CreateInterface("GameMovement001")); - + interfaces::iinput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10"))); } diff --git a/cathook/src/interfaces.h b/cathook/src/interfaces.h index 3eb556c0..b51e00e1 100644 --- a/cathook/src/interfaces.h +++ b/cathook/src/interfaces.h @@ -29,6 +29,7 @@ class IClient; class CGlobalVarsBase; class IPrediction; class IGameMovement; +class IInput; namespace interfaces { @@ -48,6 +49,7 @@ extern IInputSystem* input; extern CGlobalVarsBase* gvars; extern IPrediction* prediction; extern IGameMovement* gamemovement; +extern IInput* iinput; void CreateInterfaces(); diff --git a/cathook/src/sdk.h b/cathook/src/sdk.h index 44adbfa8..d600706c 100644 --- a/cathook/src/sdk.h +++ b/cathook/src/sdk.h @@ -38,5 +38,6 @@ #include #include "sdk/in_buttons.h" +#include "sdk/iinput.h" #endif /* SDK_H_ */ diff --git a/cathook/src/sdk/iinput.h b/cathook/src/sdk/iinput.h new file mode 100644 index 00000000..a49d08a1 --- /dev/null +++ b/cathook/src/sdk/iinput.h @@ -0,0 +1,118 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#if !defined( IINPUT_H ) +#define IINPUT_H +#ifdef _WIN32 +#pragma once +#endif + +class bf_write; +class bf_read; +class CUserCmd; +class C_BaseCombatWeapon; +struct kbutton_t; + +struct CameraThirdData_t +{ + float m_flPitch; + float m_flYaw; + float m_flDist; + float m_flLag; + Vector m_vecHullMin; + Vector m_vecHullMax; +}; + +class IInput +{ +public: + // Initialization/shutdown of the subsystem + virtual void Init_All( void ) = 0; + virtual void Shutdown_All( void ) = 0; + // Latching button states + virtual int GetButtonBits( int ) = 0; + // Create movement command + virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active ) = 0; + virtual void ExtraMouseSample( float frametime, bool active ) = 0; + virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand ) = 0; + virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot ) = 0; + virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot ) = 0; + + virtual CUserCmd *GetUserCmd( int sequence_number ) = 0; + + virtual void MakeWeaponSelection( C_BaseCombatWeapon *weapon ) = 0; + + // Retrieve key state + virtual float KeyState ( kbutton_t *key ) = 0; + // Issue key event + virtual int KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszCurrentBinding ) = 0; + // Look for key + virtual kbutton_t *FindKey( const char *name ) = 0; + + // Issue commands from controllers + virtual void ControllerCommands( void ) = 0; + // Extra initialization for some joysticks + virtual void Joystick_Advanced( void ) = 0; + virtual void Joystick_SetSampleTime( float frametime ) = 0; + virtual void IN_SetSampleTime( float frametime ) = 0; + + // Accumulate mouse delta + virtual void AccumulateMouse( void ) = 0; + // Activate/deactivate mouse + virtual void ActivateMouse( void ) = 0; + virtual void DeactivateMouse( void ) = 0; + + // Clear mouse state data + virtual void ClearStates( void ) = 0; + // Retrieve lookspring setting + virtual float GetLookSpring( void ) = 0; + + // Retrieve mouse position + virtual void GetFullscreenMousePos( int *mx, int *my, int *unclampedx = 0, int *unclampedy = 0 ) = 0; + virtual void SetFullscreenMousePos( int mx, int my ) = 0; + virtual void ResetMouse( void ) = 0; + virtual float GetLastForwardMove( void ) = 0; + virtual float Joystick_GetForward( void ) = 0; + virtual float Joystick_GetSide( void ) = 0; + virtual float Joystick_GetPitch( void ) = 0; + virtual float Joystick_GetYaw( void ) = 0; + + // Third Person camera ( TODO/FIXME: Move this to a separate interface? ) + virtual void CAM_Think( void ) = 0; + virtual int CAM_IsThirdPerson( void ) = 0; + virtual void CAM_ToThirdPerson(void) = 0; + virtual void CAM_ToFirstPerson(void) = 0; + virtual void CAM_StartMouseMove(void) = 0; + virtual void CAM_EndMouseMove(void) = 0; + virtual void CAM_StartDistance(void) = 0; + virtual void CAM_EndDistance(void) = 0; + virtual int CAM_InterceptingMouse( void ) = 0; + + // orthographic camera info ( TODO/FIXME: Move this to a separate interface? ) + virtual void CAM_ToOrthographic() = 0; + virtual bool CAM_IsOrthographic() const = 0; + virtual void CAM_OrthographicSize( float& w, float& h ) const = 0; + +#if defined( HL2_CLIENT_DLL ) + // IK back channel info + virtual void AddIKGroundContactInfo( int entindex, float minheight, float maxheight ) = 0; +#endif + + virtual void LevelInit( void ) = 0; + + // Causes an input to have to be re-pressed to become active + virtual void ClearInputButton( int bits ) = 0; + + virtual void CAM_SetCameraThirdData( CameraThirdData_t *pCameraData, const QAngle &vecCameraOffset ) = 0; + virtual void CAM_CameraThirdThink( void ) = 0; + + virtual bool EnableJoystickMode() = 0; +}; + +//extern ::IInput *input; + +#endif // IINPUT_H