Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hot fix for chams, remove last arg from createmove and add back input history #31

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cstrike/core/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ ViewMatrix_t* CS_FASTCALL H::GetMatrixForView(CRenderGameSystem* pRenderGameSyst
return matResult;
}

bool CS_FASTCALL H::CreateMove(CCSGOInput* pInput, int nSlot, bool bActive, std::byte unk)
bool CS_FASTCALL H::CreateMove(CCSGOInput* pInput, int nSlot, bool bActive)
{
const auto oCreateMove = hkCreateMove.GetOriginal();
const bool bResult = oCreateMove(pInput, nSlot, bActive, unk);
const bool bResult = oCreateMove(pInput, nSlot, bActive);

if (!I::Engine->IsConnected() || !I::Engine->IsInGame())
return bResult;
Expand Down
2 changes: 1 addition & 1 deletion cstrike/core/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace H

// game's functions
ViewMatrix_t* CS_FASTCALL GetMatrixForView(CRenderGameSystem* pRenderGameSystem, IViewRender* pViewRender, ViewMatrix_t* pOutWorldToView, ViewMatrix_t* pOutViewToProjection, ViewMatrix_t* pOutWorldToProjection, ViewMatrix_t* pOutWorldToPixels);
bool CS_FASTCALL CreateMove(CCSGOInput* pInput, int nSlot, bool bActive, std::byte unk);
bool CS_FASTCALL CreateMove(CCSGOInput* pInput, int nSlot, bool bActive);
bool CS_FASTCALL MouseInputEnabled(void* pThisptr);
void CS_FASTCALL FrameStageNotify(void* rcx, int nFrameStage);
__int64* CS_FASTCALL LevelInit(void* pClientModeShared, const char* szNewMap);
Expand Down
2 changes: 2 additions & 0 deletions cstrike/core/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ void T::Miscellaneous()
if (C_GET(bool, Vars.bAutoBHop))
ImGui::SliderInt(CS_XOR("chance"), &C_GET(int, Vars.nAutoBHopChance), 0, 100, CS_XOR("%d%%"));

ImGui::Checkbox(CS_XOR("auto strafe"), &C_GET(bool, Vars.bAutoStrafe));

ImGui::PopStyleVar();
}
ImGui::EndChild();
Expand Down
2 changes: 2 additions & 0 deletions cstrike/core/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct Variables_t

C_ADD_VARIABLE(bool, bAutoBHop, false);
C_ADD_VARIABLE(int, nAutoBHopChance, 100);

C_ADD_VARIABLE(bool, bAutoStrafe, false);
#pragma endregion

#pragma region variables_menu
Expand Down
29 changes: 19 additions & 10 deletions cstrike/features/misc/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ void F::MISC::MOVEMENT::OnMove(CUserCmd* pCmd, CCSPlayerController* pLocalContro
return;

BunnyHop(pCmd, pBaseCmd, pLocalPawn);
AutoStrafe(pBaseCmd, pLocalPawn);

// loop through all tick commands
//for (int nTick = 0; nTick < pBaseCmd->nTickCount; nTick++)
//{
// CCSGOInputHistoryEntryPB* pInputEntry = pCmd->cmd.inputHistoryField.pRep->tElements[nTick];
// if (pInputEntry == nullptr)
// continue;
for (int nTick = 0; nTick < pBaseCmd->nTickCount; nTick++)
{
CCSGOInputHistoryEntryPB* pInputEntry = pCmd->csgoUserCmd.GetInputHistoryEntry(nTick);
if (pInputEntry == nullptr)
continue;

// // save view angles for movement correction
// angCorrectionView = pInputEntry->pViewCmd->angValue;
// save view angles for movement correction
angCorrectionView = pInputEntry->pViewCmd->angValue;

// // movement correction & anti-untrusted
// ValidateUserCommand(pCmd, pBaseCmd, pInputEntry);
//}
// movement correction & anti-untrusted
ValidateUserCommand(pCmd, pBaseCmd, pInputEntry);
}
}

void F::MISC::MOVEMENT::BunnyHop(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn)
Expand Down Expand Up @@ -76,6 +77,14 @@ void F::MISC::MOVEMENT::BunnyHop(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, C_CSP
pCmd->nButtons.nValue &= ~IN_JUMP;
}

void F::MISC::MOVEMENT::AutoStrafe(CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn)
{
if (!C_GET(bool, Vars.bAutoStrafe) || pLocalPawn->GetFlags() & FL_ONGROUND)
return;

pUserCmd->flSideMove = pUserCmd->nMousedX > 0 ? -1.0f : 1.0f; // a bit yanky, but works
}

void F::MISC::MOVEMENT::ValidateUserCommand(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, CCSGOInputHistoryEntryPB* pInputEntry)
{
if (pUserCmd == nullptr)
Expand Down
1 change: 1 addition & 0 deletions cstrike/features/misc/movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace F::MISC::MOVEMENT
void OnMove(CUserCmd* pCmd, CCSPlayerController* pLocalController, C_CSPlayerPawn* pLocalPawn);

void BunnyHop(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn);
void AutoStrafe(CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn);
void MovementCorrection(CBaseUserCmdPB* pUserCmd, CCSGOInputHistoryEntryPB* pInputHistory, const QAngle_t& angDesiredViewPoint);

// will call MovementCorrection && validate user's angView to avoid untrusted ban
Expand Down
39 changes: 37 additions & 2 deletions cstrike/sdk/datatypes/usercmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ class CCSGOInputHistoryEntryPB : public CBasePB
int nTargetEntIndex; // 0x74
};

class CCSGOUserCmdPB
{
public:
int32_t nTickCount; // 0x0
MEM_PAD(0x4); // 0x4
void* pInputHistory; // 0x8

CCSGOInputHistoryEntryPB* GetInputHistoryEntry(std::int32_t nTick)
{
if (nTick < this->nTickCount)
{
CCSGOInputHistoryEntryPB** arrTickList = reinterpret_cast<CCSGOInputHistoryEntryPB**>(reinterpret_cast<std::uintptr_t>(pInputHistory) + 0x8);
return arrTickList[nTick];
}

return nullptr;
}
};
static_assert(sizeof(CCSGOUserCmdPB) == 0x10);

struct ButtonState_t
{
MEM_PAD(0x8);
Expand Down Expand Up @@ -114,14 +134,29 @@ class CBaseUserCmdPB : public CBasePB
};
static_assert(sizeof(CBaseUserCmdPB) == 0x80);


class CUserCmd
{
public:
MEM_PAD(0x30);
MEM_PAD(0x20);
CCSGOUserCmdPB csgoUserCmd; // 0x20
CBaseUserCmdPB* pBaseCmd; // 0x30
MEM_PAD(0x10); // 0x38
ButtonState_t nButtons; // 0x4C
MEM_PAD(0x20); // 0x64

void SetSubTickAngle(const QAngle_t& angView)
{
for (int i = 0; i < this->csgoUserCmd.nTickCount; i++)
{
CCSGOInputHistoryEntryPB* pInputEntry = this->csgoUserCmd.GetInputHistoryEntry(i);
if (pInputEntry == nullptr)
continue;

if (pInputEntry->pViewCmd == nullptr)
continue;

pInputEntry->pViewCmd->angValue = angView;
}
}
};
static_assert(sizeof(CUserCmd) == 0x88);
34 changes: 17 additions & 17 deletions cstrike/sdk/interfaces/imaterialsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ struct MaterialKeyVar_t
std::uint64_t FindKey(const char* szName)
{
using fnFindKeyVar = std::uint64_t(CS_FASTCALL*)(const char*, unsigned int, int);
static auto FindKeyVar = reinterpret_cast<fnFindKeyVar>(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 57 48 81 EC ? ? ? ? 33 C0 8B DA")));
static auto oFindKeyVar = reinterpret_cast<fnFindKeyVar>(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 57 48 81 EC ? ? ? ? 33 C0 8B DA")));

#ifdef CS_PARANOID
CS_ASSERT(FindKeyVar != nullptr);
CS_ASSERT(oFindKeyVar != nullptr);
#endif

// idk those enum flags, just saw it called like that soooo yea
return FindKeyVar(szName, 0x12, 0x31415926);
return oFindKeyVar(szName, 0x12, 0x31415926);
}
};

Expand All @@ -57,7 +57,7 @@ class CObjectInfo

class CSceneAnimatableObject
{
MEM_PAD(0xA8);
MEM_PAD(0xB0);
CBaseHandle hOwner;
};

Expand All @@ -69,36 +69,36 @@ class CMeshData
{
// @ida: #STR: shader, spritecard.vfx
using fnSetMaterialShaderType = void(CS_FASTCALL*)(void*, MaterialKeyVar_t, const char*, int);
static auto SetMaterialShaderType = reinterpret_cast<fnSetMaterialShaderType>(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 4D 8B E0 4C 8B 72 ? 48 8B F9 C0 E8 ? 24 ? 3C ? 74 ? 41 B0 ? B2 ? E8 ? ? ? ? 0F B6 07 33 DB C0 E8 ? 24 ? 3C ? 75 ? 48 8B 77 ? EB ? 48 8B F3 4C 8D 44 24 ? C7 44 24 ? ? ? ? ? 48 8D 54 24 ? 89 6C 24 ? 48 8B CE 4C 89 74 24 ? E8 ? ? ? ? 8B D0 83 F8 ? 75 ? 45 33 C9 89 6C 24 ? 4C 8D 44 24 ? 4C 89 74 24 ? 48 8B D7 48 8B CE E8 ? ? ? ? 8B D0 0F B6 0F C0 E9 ? 80 E1 ? 80 F9 ? 75 ? 48 8B 4F ? EB ? 48 8B CB 8B 41 ? 85 C0 74 ? 48 8D 59 ? 83 F8 ? 76 ? 48 8B 1B 48 63 C2 4D 85 E4")));
static auto oSetMaterialShaderType = reinterpret_cast<fnSetMaterialShaderType>(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 4D 8B E0 4C 8B 72 ? 48 8B F9 C0 E8 ? 24 ? 3C ? 74 ? 41 B0 ? B2 ? E8 ? ? ? ? 0F B6 07 33 DB C0 E8 ? 24 ? 3C ? 75 ? 48 8B 77 ? EB ? 48 8B F3 4C 8D 44 24 ? C7 44 24 ? ? ? ? ? 48 8D 54 24 ? 89 6C 24 ? 48 8B CE 4C 89 74 24 ? E8 ? ? ? ? 8B D0 83 F8 ? 75 ? 45 33 C9 89 6C 24 ? 4C 8D 44 24 ? 4C 89 74 24 ? 48 8B D7 48 8B CE E8 ? ? ? ? 8B D0 0F B6 0F C0 E9 ? 80 E1 ? 80 F9 ? 75 ? 48 8B 4F ? EB ? 48 8B CB 8B 41 ? 85 C0 74 ? 48 8D 59 ? 83 F8 ? 76 ? 48 8B 1B 48 63 C2 4D 85 E4")));

#ifdef CS_PARANOID
CS_ASSERT(SetMaterialShaderType != nullptr);
CS_ASSERT(oSetMaterialShaderType != nullptr);
#endif

MaterialKeyVar_t shaderVar(0x162C1777, CS_XOR("shader"));
SetMaterialShaderType(this, shaderVar, szShaderName, 0x18);
oSetMaterialShaderType(this, shaderVar, szShaderName, 0x18); // looks like this should be 0x19u in IDA?, not sure though. Leaving it likes for maecry
}

void SetMaterialFunction(const char* szFunctionName, int nValue)
{
using fnSetMaterialFunction = void(__fastcall*)(void*, MaterialKeyVar_t, int, int);
static auto SetMaterialFunction = reinterpret_cast<fnSetMaterialFunction>(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 48 8B F9")));
static auto oSetMaterialFunction = reinterpret_cast<fnSetMaterialFunction>(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 48 8B F9")));

#ifdef CS_PARANOID
CS_ASSERT(SetMaterialFunction != nullptr);
CS_ASSERT(oSetMaterialFunction != nullptr);
#endif

MaterialKeyVar_t functionVar(szFunctionName, true);
SetMaterialFunction(this, functionVar, nValue, 0x18);
oSetMaterialFunction(this, functionVar, nValue, 0x18);
}

MEM_PAD(0x10); // 0x0
CSceneAnimatableObject* pSceneAnimatableObject; // 0x10
CMaterial2* pMaterial; // 0x18
MEM_PAD(0x20); // 0x20
Color_t colValue; // 0x40
MEM_PAD(0x4); // 0x44
CObjectInfo* pObjectInfo; // 0x48
MEM_PAD(0x18); // 0x0
CSceneAnimatableObject* pSceneAnimatableObject; // 0x18
CMaterial2* pMaterial; // 0x20
MEM_PAD(0x20); // 0x28
Color_t colValue; // 0x48
MEM_PAD(0x4); // 0x4C
CObjectInfo* pObjectInfo; // 0x50
};

class IMaterialSystem2
Expand Down
Loading