diff --git a/SpyCustom/Aimbot.cpp b/SpyCustom/Aimbot.cpp new file mode 100644 index 0000000..be2be3c --- /dev/null +++ b/SpyCustom/Aimbot.cpp @@ -0,0 +1,578 @@ +#include "Aimbot.hpp" + +///autowall +/* +bool IsBreakableEntity(C_BaseEntity* pEntity) +{ + // @ida isbreakableentity: 55 8B EC 51 56 8B F1 85 F6 74 68 + + // skip invalid entities + if (pEntity == nullptr) + return false; + + const int iHealth = ((C_BasePlayer*)pEntity)->GetHealth(); + + // first check to see if it's already broken + if (iHealth < 0 && pEntity->IsMaxHealth() > 0) + return true; + + if (pEntity->GetTakeDamage() != DAMAGE_YES) + { + const char* szClassName = pEntity->GetClientClass()->GetName(); + if (!strcmp(szClassName, XorStr("func_brush"))) + return false; + } + + const int nCollisionGroup = pEntity->GetCollisionGroup(); + + if (nCollisionGroup != COLLISION_GROUP_PUSHAWAY && nCollisionGroup != COLLISION_GROUP_BREAKABLE_GLASS && nCollisionGroup != COLLISION_GROUP_NONE) + return false; + + if (iHealth > 200) + return false; + + IMultiplayerPhysics* pPhysicsInterface = dynamic_cast(pEntity); + if (pPhysicsInterface != nullptr) + { + if (pPhysicsInterface->GetMultiplayerPhysicsMode() != PHYSICS_MULTIPLAYER_SOLID) + return false; + } + else + { + const char* szClassName = pEntity->GetClientClass()->GetName(); + + if (!strcmp(szClassName, XorStr("func_breakable")) || !strcmp(szClassName, XorStr("func_breakable_surf"))) + { + if (!strcmp(szClassName, XorStr("func_breakable_surf"))) + { + CBreakableSurface* pSurface = static_cast(pEntity); + + // don't try to break it if it has already been broken + if (pSurface->IsBroken()) + return false; + } + } + else if (pEntity->PhysicsSolidMaskForEntity() & CONTENTS_PLAYERCLIP) + { + // hostages and players use CONTENTS_PLAYERCLIP, so we can use it to ignore them + return false; + } + } + + IBreakableWithPropData* pBreakableInterface = dynamic_cast(pEntity); + if (pBreakableInterface != nullptr) + { + // bullets don't damage it - ignore + if (pBreakableInterface->GetDmgModBullet() <= 0.0f) + return false; + } + + return true; +} + +void ScaleDamage(int iHitGroup, C_BaseEntity* pEntity, float flWeaponArmorRatio, float& flDamage) +{ + const bool bHeavyArmor = pEntity->HasHeavyArmor(); + const int iArmor = pEntity->GetArmor(); + + static ConVar* mp_damage_scale_ct_head = iff.g_pCVar->FindVar(XorStr("mp_damage_scale_ct_head")); + static ConVar* mp_damage_scale_t_head = iff.g_pCVar->FindVar(XorStr("mp_damage_scale_t_head")); + + static ConVar* mp_damage_scale_ct_body = iff.g_pCVar->FindVar(XorStr("mp_damage_scale_ct_body")); + static ConVar* mp_damage_scale_t_body = iff.g_pCVar->FindVar(XorStr("mp_damage_scale_t_body")); + + const float flHeadScale = ((C_BasePlayer*)pEntity)->GetTeam() == TEAM_CT ? mp_damage_scale_ct_head->GetFloat() : ((C_BasePlayer*)pEntity)->GetTeam() == TEAM_TERRORIST ? mp_damage_scale_t_head->GetFloat() : 1.0f; + const float flBodyScale = ((C_BasePlayer*)pEntity)->GetTeam() == TEAM_CT ? mp_damage_scale_ct_body->GetFloat() : ((C_BasePlayer*)pEntity)->GetTeam() == TEAM_TERRORIST ? mp_damage_scale_t_body->GetFloat() : 1.0f; + + switch (iHitGroup) + { + case HITGROUP_HEAD: + flDamage *= (bHeavyArmor ? 2.0f : 4.0f) * flHeadScale; + break; + case HITGROUP_STOMACH: + flDamage *= 1.25f * flBodyScale; + break; + case HITGROUP_CHEST: + case HITGROUP_LEFTARM: + case HITGROUP_RIGHTARM: + flDamage *= flBodyScale; + break; + case HITGROUP_LEFTLEG: + case HITGROUP_RIGHTLEG: + flDamage *= 0.75f * flBodyScale; + break; + default: + break; + } + + // check is armored + if (iArmor > 0 && ((iHitGroup == HITGROUP_HEAD && pEntity->HasHelmet()) || (iHitGroup >= HITGROUP_GENERIC && iHitGroup <= HITGROUP_RIGHTARM))) + { + float flArmorScale = 1.0f, flArmorBonusRatio = 0.5f, flArmorRatio = flWeaponArmorRatio * 0.5f; + + if (bHeavyArmor) + { + flArmorScale = 0.33f; + flArmorBonusRatio = 0.33f; + flArmorRatio *= 0.5f; + } + + float flNewDamage = flDamage * flArmorRatio; + + if (bHeavyArmor) + flNewDamage *= 0.85f; + + if (((flDamage - flDamage * flArmorRatio) * (flArmorScale * flArmorBonusRatio)) > iArmor) + flNewDamage = flDamage - iArmor / flArmorBonusRatio; + + flDamage = flNewDamage; + } +} + +bool TraceToExit(CGameTrace& enterTrace, CGameTrace& exitTrace, Vector vecPosition, Vector vecDirection) +{ + float flDistance = 0.0f; + int iStartContents = 0; + + while (flDistance <= 90.0f) + { + // add extra distance to our ray + flDistance += 4.0f; + + // multiply the direction vector to the distance so we go outwards, add our position to it + Vector vecStart = vecPosition + vecDirection * flDistance; + + if (!iStartContents) + iStartContents = iff.g_pEnginetrace->GetPointContents(vecStart, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr); + + const int iCurrentContents = iff.g_pEnginetrace->GetPointContents(vecStart, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr); + + if (!(iCurrentContents & MASK_SHOT_HULL) || (iCurrentContents & CONTENTS_HITBOX && iCurrentContents != iStartContents)) + { + // setup our end position by deducting the direction by the extra added distance + const Vector vecEnd = vecStart - (vecDirection * 4.0f); + + // trace ray to world + Ray_t rayWorld; rayWorld.Init(vecStart, vecEnd); + iff.g_pEnginetrace->TraceRay(rayWorld, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr, &exitTrace); + + // check if a hitbox is in-front of our enemy and if they are behind of a solid wall + if (exitTrace.startsolid && exitTrace.surface.flags & SURF_HITBOX) + { + // trace ray to entity + Ray_t ray; ray.Init(vecStart, vecPosition); + CTraceFilter filter(exitTrace.m_pEnt); + + iff.g_pEnginetrace->TraceRay(ray, MASK_SHOT_HULL, &filter, &exitTrace); + + if (exitTrace.DidHit() && !exitTrace.startsolid) + { + vecStart = exitTrace.vecEnd; + return true; + } + + continue; + } + + if (exitTrace.DidHit() && !exitTrace.startsolid) + { + if (IsBreakableEntity(enterTrace.m_pEnt) && IsBreakableEntity(exitTrace.m_pEnt)) + return true; + + if (enterTrace.surface.flags & SURF_NODRAW || (!(exitTrace.surface.flags & SURF_NODRAW) && exitTrace.plane.normal.DotProduct(vecDirection) <= 1.0f)) + { + const float flMultiplier = exitTrace.fraction * 4.0f; + vecStart -= vecDirection * flMultiplier; + return true; + } + + continue; + } + + if (!exitTrace.DidHit() || exitTrace.startsolid) + { + if (enterTrace.m_pEnt != nullptr && enterTrace.m_pEnt->GetIndex() != 0 && IsBreakableEntity(enterTrace.m_pEnt)) + { + // did hit breakable non world entity + exitTrace = enterTrace; + exitTrace.vecEnd = vecStart + vecDirection; + return true; + } + + continue; + } + } + } + + return false; +} + +bool HandleBulletPenetration(CBaseEntity* pLocal, CCSWeaponInfo* pWeaponData, surfacedata_t* pEnterSurfaceData, FireBulletData_t& data) +{ + static ConVar* ff_damage_reduction_bullets = iff.g_pCVar->FindVar(XorStr("ff_damage_reduction_bullets")); + static ConVar* ff_damage_bullet_penetration = iff.g_pCVar->FindVar(XorStr("ff_damage_bullet_penetration")); + + const float flReductionDamage = ff_damage_reduction_bullets->GetFloat(); + const float flPenetrateDamage = ff_damage_bullet_penetration->GetFloat(); + + const MaterialHandle_t hEnterMaterial = pEnterSurfaceData->game.hMaterial; + const float flEnterPenetrationModifier = pEnterSurfaceData->game.flPenetrationModifier; + const bool bIsSolidSurf = ((data.enterTrace.contents >> 3) & CONTENTS_SOLID); + const bool bIsLightSurf = ((data.enterTrace.surface.flags >> 7) & SURF_LIGHT); + + CGameTrace exitTrace = { }; + + if (data.iPenetrateCount <= 0 || + (!data.iPenetrateCount && !bIsLightSurf && !bIsSolidSurf && hEnterMaterial != CHAR_TEX_GRATE && hEnterMaterial != CHAR_TEX_GLASS) || + (pWeaponData->m_flPenetration <= 0.0f) || + (!TraceToExit(data.enterTrace, exitTrace, data.enterTrace.vecEnd, data.vecDirection) && !(I::EngineTrace->GetPointContents(data.enterTrace.vecEnd, MASK_SHOT_HULL, nullptr) & MASK_SHOT_HULL))) + return false; + + const surfacedata_t* pExitSurfaceData = I::PhysicsProps->GetSurfaceData(exitTrace.surface.surfaceProps); + const MaterialHandle_t hExitMaterial = pExitSurfaceData->game.hMaterial; + const float flExitPenetrationModifier = pExitSurfaceData->game.flPenetrationModifier; + + float flDamageLostModifier = 0.16f; + float flPenetrationModifier = 0.0f; + + if (hEnterMaterial == CHAR_TEX_GRATE || hEnterMaterial == CHAR_TEX_GLASS) + { + flDamageLostModifier = 0.05f; + flPenetrationModifier = 3.0f; + } + else if (bIsSolidSurf || bIsLightSurf) + { + flDamageLostModifier = 0.16f; + flPenetrationModifier = 1.0f; + } + else if (hEnterMaterial == CHAR_TEX_FLESH && (((C_BasePlayer*)pLocal)->GetTeam() == ((C_BasePlayer*)data.enterTrace.m_pEnt)->GetTeam() && flReductionDamage == 0.0f)) + { + if (flPenetrateDamage == 0.0f) + return false; + + // shoot through teammates + flDamageLostModifier = 0.16f; + flPenetrationModifier = flPenetrateDamage; + } + else + { + flDamageLostModifier = 0.16f; + flPenetrationModifier = (flEnterPenetrationModifier + flExitPenetrationModifier) * 0.5f; + } + + if (hEnterMaterial == hExitMaterial) + { + if (hExitMaterial == CHAR_TEX_CARDBOARD || hExitMaterial == CHAR_TEX_WOOD) + flPenetrationModifier = 3.0f; + else if (hExitMaterial == CHAR_TEX_PLASTIC) + flPenetrationModifier = 2.0f; + } + + const float flTraceDistance = (exitTrace.vecEnd - data.enterTrace.vecEnd).LengthSqr(); + + // penetration modifier + const float flModifier = std::max(0.0f, 1.0f / flPenetrationModifier); + + // this calculates how much damage we've lost depending on thickness of the wall, our penetration, damage, and the modifiers set earlier + const float flLostDamage = (data.flCurrentDamage * flDamageLostModifier + std::max(0.0f, 3.75f / pWeaponData->flPenetration) * (flModifier * 3.0f)) + ((flModifier * flTraceDistance) / 24.0f); + + // did we loose too much damage? + if (flLostDamage > data.flCurrentDamage) + return false; + + // we can't use any of the damage that we've lost + if (flLostDamage > 0.0f) + data.flCurrentDamage -= flLostDamage; + + // do we still have enough damage to deal? + if (data.flCurrentDamage < 1.0f) + return false; + + data.vecPosition = exitTrace.vecEnd; + --data.iPenetrateCount; + return true; +} + + +void ClipTraceToPlayers(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int fMask, ITraceFilter* pFilter, CGameTrace* pTrace) +{ + CGameTrace trace = { }; + float flSmallestFraction = pTrace->fraction; + + Ray_t ray; ray.Init(vecAbsStart, vecAbsEnd); + + for (int i = 1; i < I::Globals->nMaxClients; i++) + { + CBaseEntity* pEntity = I::ClientEntityList->Get(i); + + if (pEntity == nullptr || !pEntity->IsAlive() || pEntity->IsDormant()) + continue; + + if (pFilter != nullptr && !pFilter->ShouldHitEntity(pEntity, fMask)) + continue; + + ICollideable* pCollideable = pEntity->GetCollideable(); + + if (pCollideable == nullptr) + continue; + + // get bounding box + const Vector vecMin = pCollideable->OBBMins_(); + const Vector vecMax = pCollideable->OBBMaxs_(); + + // calculate world space center + const Vector vecCenter = (vecMax + vecMin) * 0.5f; + const Vector vecPosition = vecCenter + pEntity->GetAbsOrigin(); + + Vector vecTo = vecPosition - vecAbsStart; + Vector vecDirection = vecAbsEnd - vecAbsStart; + const float flLength = vecDirection.NormalizeInPlace(); + + const float flRangeAlong = vecDirection.DotProduct(vecTo); + float flRange = 0.0f; + + // calculate distance to ray + if (flRangeAlong < 0.0f) + // off start point + flRange = -vecTo.Length(); + else if (flRangeAlong > flLength) + // off end point + flRange = -(vecPosition - vecAbsEnd).Length(); + else + // within ray bounds + flRange = (vecPosition - (vecDirection * flRangeAlong + vecAbsStart)).Length(); + + if (flRange < 0.0f || flRange > 60.0f) + continue; + + I::EngineTrace->ClipRayToEntity(ray, fMask | CONTENTS_HITBOX, pEntity, &trace); + + if (trace.fraction < flSmallestFraction) + { + // we shortened the ray - save off the trace + *pTrace = trace; + flSmallestFraction = trace.fraction; + } + } +} + + +bool SimulateFireBullet(C_BaseEntity* pLocal, C_BaseAttributableItem* pWeapon, FireBulletData_t& data) +{ + CCSWeaponInfo* pWeaponData = iff.g_pWeaponSystem->GetWpnData((ItemDefinitionIndex)pWeapon->GetItemDefinitionIndex()); + + if (pWeaponData == nullptr) + return false; + + float flMaxRange = pWeaponData->m_flRange; + + // the total number of surfaces any bullet can penetrate in a single flight is capped at 4 + data.iPenetrateCount = 4; + // set our current damage to what our gun's initial damage reports it will do + data.flCurrentDamage = static_cast(pWeaponData->m_iDamage); + + float flTraceLenght = 0.0f; + CTraceFilter filter(pLocal); + + while (data.iPenetrateCount > 0 && data.flCurrentDamage >= 1.0f) + { + // max bullet range + flMaxRange -= flTraceLenght; + + // end position of bullet + const Vector vecEnd = data.vecPosition + data.vecDirection * flMaxRange; + + Ray_t ray; ray.Init(data.vecPosition, vecEnd); + iff.g_pEnginetrace->TraceRay(ray, MASK_SHOT_HULL | CONTENTS_HITBOX, &filter, &data.enterTrace); + + // check for player hitboxes extending outside their collision bounds + ClipTraceToPlayers(data.vecPosition, vecEnd + data.vecDirection * 40.0f, MASK_SHOT_HULL | CONTENTS_HITBOX, &filter, &data.enterTrace); + + surfacedata_t* pEnterSurfaceData = I::PhysicsProps->GetSurfaceData(data.enterTrace.surface.surfaceProps); + const float flEnterPenetrationModifier = pEnterSurfaceData->game.flPenetrationModifier; + + // we didn't hit anything, stop tracing shoot + if (data.enterTrace.fraction == 1.0f) + break; + + // calculate the damage based on the distance the bullet traveled + flTraceLenght += data.enterTrace.fraction * flMaxRange; + data.flCurrentDamage *= std::powf(pWeaponData->m_flRangeModifier, flTraceLenght / MAX_DAMAGE); + + // check is actually can shoot through + if (flTraceLenght > 3000.0f || flEnterPenetrationModifier < 0.1f) + break; + + // check is can do damage + if (data.enterTrace.hitgroup != HITGROUP_GENERIC && data.enterTrace.hitgroup != HITGROUP_GEAR && pLocal->IsEnemy(data.enterTrace.m_pEnt)) + { + // we got target - scale damage + ScaleDamage(data.enterTrace.hitgroup, data.enterTrace.m_pEnt, pWeaponData->m_flArmorRatio, data.flCurrentDamage); + return true; + } + + // calling handlebulletpenetration here reduces our penetration pounter, and if it returns true, we can't shoot through it + if (!HandleBulletPenetration(pLocal, pWeaponData, pEnterSurfaceData, data)) + break; + } + + return false; +} + +float GetDamage(C_BaseEntity* pLocal, const Vector& vecPoint, FireBulletData_t& dataOut) +{ + const Vector vecPosition = pLocal->GetViewPos(); + + // setup data + FireBulletData_t data = { }; + data.vecPosition = vecPosition; + data.vecDirection = (vecPoint - vecPosition).Normalized(); + + auto wep = ((C_BaseCombatCharacter*)pLocal)->GetActiveWeapon(); + C_BaseAttributableItem* pWeapon = (C_BaseAttributableItem*)iff.g_pEntityList->GetClientEntityFromHandle(wep); + + if (pWeapon == nullptr) + return -1.0f; + + if (!SimulateFireBullet(pLocal, pWeapon, data)) + return -1.0f; + + dataOut = data; + return data.flCurrentDamage; +} + +bool ScanDamage(CBaseEntity* pLocal, Vector vecStart, Vector vecEnd) +{ + CGameTrace trace = { }; + if (1) //C::Get(Vars.bAimAutoWall) + { + FireBulletData_t data = { }; + + // get autowall damage and data from it + float flDamage = GetDamage(pLocal, vecEnd, data); + + // check for minimal damage + if (flDamage < 1);// C::Get(Vars.iAimMinimalDamage)) + return false; + + // copy trace from autowall + trace = data.enterTrace; + } + + //Traced target + CBaseEntity* pEntity = trace.m_pEnt; + + //Check the traced target is vailed + if (pEntity == nullptr || !pEntity->IsAlive() || pEntity->IsDormant() || !pEntity->IsPlayer() || pEntity->HasImmunity() || !pLocal->IsEnemy(pEntity)) + { + return false; + } + + //We can shot the target + return true; +} +*/ + + + +C_BasePlayer* GetBestTarget(CUserCmd* cmd) +{ + static C_CS_PlayerResource** g_player_resource = C_CS_PlayerResource::GetPlayerResource(); + + float ofov = g_Options.aimbotfov; + float nfov = 0; + C_BasePlayer* player = nullptr; + + for (int iPlayer = 0; iPlayer < iff.g_pGlobals->maxClients; iPlayer++) + { + auto pCSPlayer = reinterpret_cast(iff.g_pEntityList->GetClientEntity(iPlayer)); + if (!pCSPlayer) + continue; + if (pCSPlayer == iff.pLocal || pCSPlayer->GetTeam() == iff.pLocal->GetTeam()) + continue; + if (pCSPlayer->IsDormant()) + continue; + if (!((*g_player_resource)->IsAlive()[iPlayer] && pCSPlayer->GetHealth() > 0)) + continue; + if (pCSPlayer->HasImmunity()) + continue; + Vector eyepos = iff.pLocal->GetViewPos(); + Vector enemyheadpos = pCSPlayer->GetBonePosition(8); + + // If the enemy is not visible, do the scan damage + if (!iff.pLocal->IsVisible(pCSPlayer, enemyheadpos)) + { + //if (!ScanDamage(iff.pLocal, eyepos, enemyheadpos)) + continue; + } + + Vector angleTo = CalcAngle(eyepos, enemyheadpos); + angleTo.Clamp(); + if (g_Options.rcs) { + Vector myangles; + iff.g_pEngineClient->GetViewAngles(myangles); + nfov = myangles.DistTo(angleTo); + } + else + nfov = cmd->viewangles.DistTo(angleTo); + if (nfov < ofov) + { + ofov = nfov; + player = pCSPlayer; + } + } + + //printfdbg("Best target %x\n", player); + return player; +} + +void AimBot(CUserCmd* cmd) +{ + static C_CS_PlayerResource** g_player_resource = C_CS_PlayerResource::GetPlayerResource(); + + if (!iff.g_pEngineClient->IsConnected() || !iff.g_pEngineClient->IsInGame()) + return; + if (!iff.pLocal) + return; + if (!(*g_player_resource)->IsAlive()[iff.pLocal->GetIndex()]) + return; + C_BasePlayer* target = GetBestTarget(cmd); + if (target) + { + //player_info_t pinfo; + //iff.g_pEngineClient->GetPlayerInfo(target->GetIndex(), &pinfo); + //printfdbg("Best target %x %s\n", target, pinfo.name); + Vector eyepos = iff.pLocal->GetViewPos(); + Vector targethead = target->GetBonePosition(8); + Vector viewangles = CalcAngle(eyepos, targethead); + viewangles.Clamp(); + Vector delta = cmd->viewangles - viewangles; + delta.Clamp(); + Vector finalAng = cmd->viewangles - delta;// / (variables::aimbot_smoothing * 20); + finalAng.Clamp(); finalAng.Normalize(); + // if (variables::aimbot_isvisiblecheck && csgo::local_player->can_see_player_pos(target, target->get_eye_pos())) + // { + // cmd->viewangles = finalAng; + // interfaces::engine->set_view_angles(cmd->viewangles); + // } + // else if (!variables::aimbot_isvisiblecheck) + // { + + //rcs + if (g_Options.rcs) { + Vector aimPunchAngles = iff.pLocal->GetAimPunchAngle(); + Vector newAngles = (finalAng - aimPunchAngles * 2); + newAngles.Clamp(); newAngles.Normalize(); + cmd->viewangles = newAngles; + } + else + cmd->viewangles = finalAng; + + if (!g_Options.silentaim) + iff.g_pEngineClient->SetViewAngles((QAngle&)finalAng); + if (g_Options.aimbotautoshoot) + cmd->buttons |= IN_ATTACK; + //} + } +} + diff --git a/SpyCustom/Aimbot.hpp b/SpyCustom/Aimbot.hpp new file mode 100644 index 0000000..489ff97 --- /dev/null +++ b/SpyCustom/Aimbot.hpp @@ -0,0 +1,30 @@ +#pragma once + + +#include "sdk/c_baseentity.h" +#include "Interfaces.hpp" +#include "Options.hpp" + + +// autowall objects structure +struct FireBulletData_t +{ + Vector vecPosition = { }; + Vector vecDirection = { }; + CGameTrace enterTrace = { }; + float flCurrentDamage = 0.0f; + int iPenetrateCount = 0; +}; + +bool IsBreakableEntity(CBaseEntity* pEntity); +void ScaleDamage(int iHitGroup, CBaseEntity* pEntity, float flWeaponArmorRatio, float& flDamage); +bool TraceToExit(CGameTrace& enterTrace, CGameTrace& exitTrace, Vector vecPosition, Vector vecDirection); +bool HandleBulletPenetration(CBaseEntity* pLocal, CCSWeaponInfo* pWeaponData, surfacedata_t* pEnterSurfaceData, FireBulletData_t& data); +void ClipTraceToPlayers(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int fMask, ITraceFilter* pFilter, CGameTrace* pTrace); +bool SimulateFireBullet(C_BaseEntity* pLocal, C_BaseAttributableItem* pWeapon, FireBulletData_t& data); +float GetDamage(C_BaseEntity* pLocal, const Vector& vecPoint, FireBulletData_t& dataOut); +bool ScanDamage(CBaseEntity* pLocal, Vector vecStart, Vector vecEnd); + +C_BasePlayer* GetBestTarget(CUserCmd* cmd); +void AimBot(CUserCmd* cmd); + diff --git a/SpyCustom/Hooks.hpp b/SpyCustom/Hooks.hpp index 7f31e5c..91223a3 100644 --- a/SpyCustom/Hooks.hpp +++ b/SpyCustom/Hooks.hpp @@ -1,8 +1,8 @@ #pragma once #include "sdk/particles.h" -#include "ProtobuffMessages.h" - +#include "ProtobuffMessages.h" +#include "Aimbot.hpp" VMTHook* SoundHook = nullptr; void __fastcall hkEmitSound1(void* _this, int edx, IRecipientFilter& filter, int iEntIndex, int iChannel, char* pSoundEntry, unsigned int nSoundEntryHash, const char* pSample, float flVolume, int nSeed, float flAttenuation, int iFlags, int iPitch, const Vector* pOrigin, const Vector* pDirection, void* pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity, int unk) { @@ -35,7 +35,7 @@ void replacemat(int d) else material = iff.g_pMaterialSystem->FindMaterial(g_Options.materials.value->arr[d].texture, TEXTURE_GROUP_MODEL); material->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, g_Options.materials.value->arr[d].wireframe); - material->SetMaterialVarFlag(MATERIAL_VAR_FLAT, g_Options.materials.value->arr[d].flat); + material->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, g_Options.materials.value->arr[d].ignorez); material->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, g_Options.materials.value->arr[d].nodraw); material->ColorModulate(g_Options.materials.value->arr[d].coloralpha.x, g_Options.materials.value->arr[d].coloralpha.y, g_Options.materials.value->arr[d].coloralpha.z); material->AlphaModulate(g_Options.materials.value->arr[d].coloralpha.w); @@ -85,7 +85,7 @@ void __stdcall DrawModelExecute(IMatRenderContext* ctx, const DrawModelState_t& replacemat(d); } } - } + } ofunc(iff.g_pMdlRender, ctx, state, pInfo, pCustomBoneToWorld); @@ -166,12 +166,12 @@ static void __stdcall hkdoPostScreenEffects(void* param) noexcept { static auto ofunc = ClientModeHook->GetOriginal(44); + int localplayer_index = iff.g_pEngineClient->GetLocalPlayer(); + C_BasePlayer* localplayer = static_cast(iff.g_pEntityList->GetClientEntity(localplayer_index)); + if (*g_Options.entityloop_count) { if (iff.g_pEngineClient->IsInGame()) { - int localplayer_index = iff.g_pEngineClient->GetLocalPlayer(); - C_BasePlayer* localplayer = static_cast(iff.g_pEntityList->GetClientEntity(localplayer_index)); - for (int i = iff.g_pEngineClient->GetMaxClients() + 1; i <= iff.g_pEntityList->GetHighestEntityIndex(); ++i) { C_BasePlayer* pEntity = (C_BasePlayer*)iff.g_pEntityList->GetClientEntity(i); @@ -199,10 +199,54 @@ static void __stdcall hkdoPostScreenEffects(void* param) noexcept modelprecache->AddString(false, model); } } + + } } } + + for (int i = 0; i < iff.g_GlowObjectManager->m_GlowObjectDefinitions.Count(); i++) + { + CGlowObjectManager::GlowObjectDefinition_t& glow = iff.g_GlowObjectManager->m_GlowObjectDefinitions[i]; + + if (glow.m_nNextFreeSlot != CGlowObjectManager::GlowObjectDefinition_t::ENTRY_IN_USE) + continue; + + if (!glow.m_pEntity) + continue; + + if (fnv2::hash(glow.m_pEntity->GetClientClass()->GetName()) == fnv2::hash("CCSPlayer")) + { + if (localplayer->GetTeam() != ((C_BasePlayer*)glow.m_pEntity)->GetTeam() && g_Options.glowObjects.value->arr[0].enabled) + { + memcpy(&glow.m_vGlowColor, &g_Options.glowObjects.value->arr[0].color, sizeof(float) * 4); + glow.m_bRenderWhenOccluded = true; + glow.m_bRenderWhenUnoccluded = false; + glow.m_flGlowAlphaMax = g_Options.glowObjects.value->arr[0].alphamax; + glow.m_nRenderStyle = g_Options.glowObjects.value->arr[0].glowstyle; + glow.m_bFullBloomRender = false; + glow.m_nFullBloomStencilTestValue = 0; + } + + if (localplayer->GetTeam() == ((C_BasePlayer*)glow.m_pEntity)->GetTeam() && g_Options.glowObjects.value->arr[1].enabled) + { + memcpy(&glow.m_vGlowColor, &g_Options.glowObjects.value->arr[1].color, sizeof(float) * 4); + glow.m_bRenderWhenOccluded = true; + glow.m_bRenderWhenUnoccluded = false; + glow.m_flGlowAlphaMax = g_Options.glowObjects.value->arr[1].alphamax; + glow.m_nRenderStyle = g_Options.glowObjects.value->arr[1].glowstyle; + glow.m_bFullBloomRender = false; + glow.m_nFullBloomStencilTestValue = 0; + } + } + } + + if (g_Options.flashalpha != 255.0f) + { + localplayer->GetFlashMaxAlpha() = g_Options.flashalpha; + } + ofunc(iff.g_ClientMode, param); } @@ -215,7 +259,7 @@ void __stdcall hkOverrideView(CViewSetup* vsView) { { if (!localplayer->IsScoped()) - vsView->fov = g_Options.fov; + vsView->fov = g_Options.fov; auto ViewModel = reinterpret_cast(iff.g_pEntityList->GetClientEntityFromHandle(localplayer->GetViewModel())); if (ViewModel) @@ -227,6 +271,7 @@ void __stdcall hkOverrideView(CViewSetup* vsView) { ViewModel->GetAbsAngles() = eyeAng; } } + ofunc(vsView); } @@ -500,19 +545,44 @@ void FastLadder(C_BasePlayer* localplayer, CUserCmd* cmd) } -bool __stdcall hkCreateMove(float frame_time, CUserCmd* pCmd) + +bool bSendPacket = 1; +bool __stdcall hkCreateMove2(float frame_time, CUserCmd* pCmd); + +__declspec(naked) bool __stdcall hkCreateMove(float frame_time, CUserCmd* pCmd) +{ + __asm + { + push ebp + mov ebp, esp + mov bSendPacket, bl + } + + hkCreateMove2(frame_time, pCmd); + +__asm{ + mov bl, bSendPacket + pop ebp + ret 0x08 + } +} + + +bool __stdcall hkCreateMove2(float frame_time, CUserCmd* pCmd) { - uintptr_t* frame_pointer; - __asm mov frame_pointer, ebp; - bool& send_packet = *reinterpret_cast(*frame_pointer - 0x1C); - static auto ofunc = ClientModeHook->GetOriginal(24); short localid = iff.g_pEngineClient->GetLocalPlayer(); C_BasePlayer* localplayer = static_cast(iff.g_pEntityList->GetClientEntity(localid)); - if (!localplayer) return 0; + iff.pLocal = localplayer; + if (!localplayer) return ofunc(frame_time, pCmd); + + if (g_Options.rcs) localplayer->GetViewPunchAngle() = Vector(0, 0, 0); + + if (!pCmd->command_number) return ofunc(frame_time, pCmd); + const auto pre_flags = localplayer->GetFlags(); bool interval = !((pCmd->tick_count + 1) % 10); @@ -550,7 +620,7 @@ bool __stdcall hkCreateMove(float frame_time, CUserCmd* pCmd) { auto entityList = iff.g_pEntityList->GetClientEntity(i); if (entityList && _tcsstr(entityList->GetClientClass()->GetName(), "CPlantedC4") != NULL && tick < ((CPlantedC4*)entityList)->GetC4Blow()) - { + { printfdbg("Found PlantedC4 %d (%f %f)\n", i, tick, ((CPlantedC4*)entityList)->GetC4Blow()); c4id = i; break; @@ -640,25 +710,63 @@ bool __stdcall hkCreateMove(float frame_time, CUserCmd* pCmd) Vector delta = localpos - entpos; float deltaXold = delta[0]; float deltaYold = delta[1]; delta[0] = deltaXold * cos(viewAngles[1] * PI / 180) + deltaYold * sin(viewAngles[1] * PI / 180); - delta[1] = -deltaXold * sin(viewAngles[1] * PI / 180) + deltaYold * cos(viewAngles[1] * PI / 180); - pCmd->forwardmove = -delta[0] * 40; - pCmd->sidemove = delta[1] * 40; + delta[1] = -deltaXold * sin(viewAngles[1] * PI / 180) + deltaYold * cos(viewAngles[1] * PI / 180); + pCmd->forwardmove = std::clamp(-delta[0] * 40, -450.f, 450.f); + pCmd->sidemove = std::clamp(delta[1] * 40, -450.f, 450.f); } } + + if (g_Options.rcs) { + Vector aimPunchAngles = localplayer->GetAimPunchAngle(); + Vector currentViewAngles; iff.g_pEngineClient->GetViewAngles(currentViewAngles); + Vector newAngles = (currentViewAngles - aimPunchAngles * 2); + newAngles.Clamp(); newAngles.Normalize(); + pCmd->viewangles = newAngles; + //localplayer->GetViewPunchAngle() = Vector(0, 0, 0); + } + + + if (g_Options.fakelag) + { + auto choked = iff.g_pClientState->m_nChokedCommands; + + if (choked < g_Options.fakelag) + bSendPacket = 0; + else + bSendPacket = 1; + } + + /* + if (!iff.g_pClientState->m_nChokedCommands) + { + static bool flip_movement = false; + + if (pCmd->forwardmove == 0.0f && !(pCmd->buttons & (int)IN_JUMP)) + { + pCmd->forwardmove += flip_movement ? -1.01f : 1.01f; + }//nonsense + flip_movement = !flip_movement; + } + */ + + if (g_Options.aimbot) + if (g_Options.aimbotautoshoot || iff.g_pInputSystem->IsButtonDown(MOUSE_LEFT)) + AimBot(pCmd); + pCmd->viewangles.Clamp(); + pCmd->viewangles.Normalize(); pCmd->forwardmove = std::clamp(pCmd->forwardmove, -450.f, 450.f); pCmd->sidemove = std::clamp(pCmd->sidemove, -450.f, 450.f); pCmd->upmove = std::clamp(pCmd->upmove, -320.f, 320.f); - //return ofunc(frame_time, pCmd); + //return ofunc(frame_time, pCmd); return false; } - typedef const __int64(__cdecl* pDevMsg)(_In_z_ _Printf_format_string_ char const* const _Format, ...); pDevMsg oDevMsg; //(char* a1, int a2, char a3) __int64 __cdecl hkDevMsg(_In_z_ _Printf_format_string_ char const* const _Format, ...) @@ -704,7 +812,7 @@ bool __fastcall hkDispatchUserMessage(void* thisptr, void*, int msg_type, int32 } static auto ofunc = ClientHook->GetOriginal(38); - + /* //read chat example if (msg_type == CS_UM_SayText2) { @@ -753,3 +861,13 @@ int __fastcall hkGetPlayerMoney(void* this_, void* edx, int ent_index) return ((C_BasePlayer*)player)->GetAccount(); } } + +VMTHook* ViewRenderHook = nullptr; + +void __fastcall hkRenderSmokeOverlay(uintptr_t ecx, uintptr_t edx, bool a1) +{ + static auto oRenderSmokeOverlay = ViewRenderHook->GetOriginal(41); + if (!g_Options.wfsmoke) + oRenderSmokeOverlay(ecx, a1); + else *reinterpret_cast(std::uintptr_t(iff.g_ViewRender) + 0x588) = 0.0f; +} \ No newline at end of file diff --git a/SpyCustom/Interfaces.cpp b/SpyCustom/Interfaces.cpp index abbe355..3954fd0 100644 --- a/SpyCustom/Interfaces.cpp +++ b/SpyCustom/Interfaces.cpp @@ -167,6 +167,13 @@ void IF::Init() GameRulesProxy = *(C_GameRulesProxy**)(FindPatternV2("client.dll", "A1 ? ? ? ? 85 C0 0F 84 ? ? ? ? 80 B8 ? ? ? ? ? 74 7A")+1); //C_GameRulesProxy dwRadarBase = FindPatternV2("client.dll", "A1 ? ? ? ? 8B 0C B0 8B 01 FF 50 ? 46 3B 35 ? ? ? ? 7C EA 8B 0D") + 1; g_pMoveHelper = **reinterpret_cast(FindPatternV2("client.dll", "8B 0D ? ? ? ? 8B 46 08 68") + 2); + g_GlowObjectManager = *(CGlowObjectManager**)(FindPatternV2("client.dll", "0F 11 05 ? ? ? ? 83 C8 01") + 3); + printfdbg("g_GlowObjectManager %x\n", g_GlowObjectManager); + + OverheadInfo = (void*)(FindPatternV2("client.dll", "E8 ? ? ? ? 3B C6 5E 5F") + 5); + pLocal = 0; + + g_pWeaponSystem = *reinterpret_cast(FindPatternV2("client.dll", "8B 35 ? ? ? ? FF 10 0F B7 C0") + 0x2); } @@ -277,16 +284,19 @@ void ShowMenu(std::string text) } } - -//if sv_voicecodec = vaudio_celt + + bool VoiceRecordStart(const char* pUncompressedFile) { typedef bool(__cdecl* Voice_RecordStartFn)(const char*, const char*, const char*); static Voice_RecordStartFn Voice_RecordStart = Voice_RecordStartFn(FindPatternV2("engine.dll", "55 8B EC 83 EC 0C 83 3D ?? ?? ?? ?? ?? 56 57")); - //m_FileDuration = GetWavFileDuration(WavSound); - //m_FilePlayEndTime = iff.g_pGlobals->curtime + m_FileDuration; + //const char* WavSound = "MyCustomPathToMyFile.wav"; + + //m_FileDuration = Utils.GetWavFileDuration(WavSound); + //m_FilePlayEndTime = I::Globals->curtime + m_FileDuration; + //iff.g_pCVar->FindVar("sv_voicecodec")->SetValue("vaudio_celt"); iff.g_pEngineClient->ExecuteClientCmd("voice_loopback 1"); return Voice_RecordStart(pUncompressedFile, nullptr, nullptr); } diff --git a/SpyCustom/Interfaces.hpp b/SpyCustom/Interfaces.hpp index 2829cde..d18abbc 100644 --- a/SpyCustom/Interfaces.hpp +++ b/SpyCustom/Interfaces.hpp @@ -2,7 +2,6 @@ #define INTERFACES #pragma once -//random crashes while loading config without DEBUG defined #define DEBUG #ifdef DEBUG @@ -73,6 +72,8 @@ #include "sdk/gamerules.h" #include "sdk/igametypes.h" #include "sdk/gamemovement.h" +#include "sdk/glow_outline_effect.h" +#include "sdk/cs_weapon_parse.h" #include "XorStr.hpp" @@ -152,7 +153,11 @@ public: DWORD dwRadarBase = NULL; IMoveHelper* g_pMoveHelper = NULL; //CMoveHelperClient IGameMovement* g_pGameMovement = NULL; - + CGlowObjectManager* g_GlowObjectManager = NULL; + void* OverheadInfo = NULL; + C_BasePlayer* pLocal = NULL; + IWeaponSystem* g_pWeaponSystem = NULL; + }; @@ -238,73 +243,7 @@ struct model_t void AngleVectors(const Vector& angles, Vector* forward, Vector* right, Vector* up); -enum ItemDefinitionIndex -{ - ITEM_NONE = 0, - WEAPON_DEAGLE = 1, - WEAPON_ELITE = 2, - WEAPON_FIVESEVEN = 3, - WEAPON_GLOCK = 4, - WEAPON_AK47 = 7, - WEAPON_AUG = 8, - WEAPON_AWP = 9, - WEAPON_FAMAS = 10, - WEAPON_G3SG1 = 11, - WEAPON_GALILAR = 13, - WEAPON_M249 = 14, - WEAPON_M4A1 = 16, - WEAPON_MAC10 = 17, - WEAPON_P90 = 19, - WEAPON_UMP45 = 24, - WEAPON_XM1014 = 25, - WEAPON_BIZON = 26, - WEAPON_MAG7 = 27, - WEAPON_NEGEV = 28, - WEAPON_SAWEDOFF = 29, - WEAPON_TEC9 = 30, - WEAPON_TASER = 31, - WEAPON_HKP2000 = 32, - WEAPON_MP7 = 33, - WEAPON_MP9 = 34, - WEAPON_NOVA = 35, - WEAPON_P250 = 36, - WEAPON_SCAR20 = 38, - WEAPON_SG553 = 39, - WEAPON_SSG08 = 40, - WEAPON_KNIFE_GOLD = 41, - WEAPON_KNIFE = 42, - WEAPON_FLASHBANG = 43, - WEAPON_HEGRENADE = 44, - WEAPON_SMOKEGRENADE = 45, - WEAPON_MOLOTOV = 46, - WEAPON_DECOY = 47, - WEAPON_INCGRENADE = 48, - WEAPON_C4 = 49, - WEAPON_KNIFE_T = 59, - WEAPON_M4A1_SILENCER = 60, - WEAPON_USP_SILENCER = 61, - WEAPON_CZ75A = 63, - WEAPON_REVOLVER = 64, - WEAPON_KNIFE_BAYONET = 500, - WEAPON_KNIFE_FLIP = 505, - WEAPON_KNIFE_GUT = 506, - WEAPON_KNIFE_KARAMBIT = 507, - WEAPON_KNIFE_M9_BAYONET = 508, - WEAPON_KNIFE_TACTICAL = 509, - WEAPON_KNIFE_FALCHION = 512, - WEAPON_KNIFE_SURVIVAL_BOWIE = 514, - WEAPON_KNIFE_BUTTERFLY = 515, - WEAPON_KNIFE_PUSH = 516, - GLOVE_STUDDED_BLOODHOUND = 5027, - GLOVE_T_SIDE = 5028, - GLOVE_CT_SIDE = 5029, - GLOVE_SPORTY = 5030, - GLOVE_SLICK = 5031, - GLOVE_LEATHER_WRAP = 5032, - GLOVE_MOTORCYCLE = 5033, - GLOVE_SPECIALIST = 5034, - MAX_ITEMDEFINITIONINDEX -}; + static int random(int min, int max) noexcept diff --git a/SpyCustom/Menu.hpp b/SpyCustom/Menu.hpp index 7997a53..2e11f70 100644 --- a/SpyCustom/Menu.hpp +++ b/SpyCustom/Menu.hpp @@ -1,5 +1,59 @@ #pragma once +LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; +struct vertex { + FLOAT x, y, z, + rhw; + DWORD color; +}; + +void DrawCircle(IDirect3DDevice9* p_Device, float x, float y, float rad, float rotate, int resolution, DWORD color) +{ + vector circle(resolution + 2); + float angle = rotate * PI / 180; + + circle[0].x = x - rad; + circle[0].y = y; + circle[0].z = 0; + circle[0].rhw = 1; + circle[0].color = color; + + for (int i = 1; i < resolution + 2; i++) + { + circle[i].x = (float)(x - rad * cos(PI * ((i - 1) / (resolution / 2.0f)))); + circle[i].y = (float)(y - rad * sin(PI * ((i - 1) / (resolution / 2.0f)))); + circle[i].z = 0; + circle[i].rhw = 1; + circle[i].color = color; + } + + // Rotate matrix + int _res = resolution + 2; + for (int i = 0; i < _res; i++) + { + circle[i].x = x + cos(angle) * (circle[i].x - x) - sin(angle) * (circle[i].y - y); + circle[i].y = y + sin(angle) * (circle[i].x - x) + cos(angle) * (circle[i].y - y); + } + + p_Device->CreateVertexBuffer((resolution + 2) * sizeof(vertex), D3DUSAGE_WRITEONLY, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &v_buffer, NULL); + + VOID* pVertices; + v_buffer->Lock(0, (resolution + 2) * sizeof(vertex), (void**)&pVertices, 0); + memcpy(pVertices, &circle[0], (resolution + 2) * sizeof(vertex)); + v_buffer->Unlock(); + + p_Device->SetTexture(0, NULL); + p_Device->SetPixelShader(NULL); + p_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + p_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + p_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + + p_Device->SetStreamSource(0, v_buffer, 0, sizeof(vertex)); + p_Device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); + p_Device->DrawPrimitive(D3DPT_LINESTRIP, 0, resolution); + if (v_buffer != NULL) v_buffer->Release(); +} + IMaterial* CreateMaterial(std::string matname, std::string mat_data = "") { KeyValues* keyValues = new KeyValues(matname.c_str()); @@ -10,6 +64,32 @@ IMaterial* CreateMaterial(std::string matname, std::string mat_data = "") return newmat; } +void wfsmoke(bool on = 1) noexcept +{ + constexpr std::array smokeMaterials{ + "particle/vistasmokev1/vistasmokev1_emods", + "particle/vistasmokev1/vistasmokev1_emods_impactdust", + "particle/vistasmokev1/vistasmokev1_fire", + "particle/vistasmokev1/vistasmokev1_smokegrenade" + }; + + if (on) + { + if (!*g_Options.wfsmoke) return; + + for (const auto mat : smokeMaterials) { + const auto material = iff.g_pMaterialSystem->FindMaterial(mat, TEXTURE_GROUP_PARTICLE); + material->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, true); + } + } + else + { + for (const auto mat : smokeMaterials) { + const auto material = iff.g_pMaterialSystem->FindMaterial(mat, TEXTURE_GROUP_PARTICLE); + material->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, false); + } + } +} void colorWorld(bool on = 1) noexcept { @@ -82,6 +162,27 @@ void ResetMisc() SetValueUnrestricted("cl_wpn_sway_scale", GetVisibleFloat("cl_wpn_sway_scale")); iff.g_pCVar->FindVar("cl_ragdoll_gravity")->SetValue(600.0f); memcpy(g_Options.ragdollgravity, &f600, 4); SetValueUnrestricted("cl_phys_timescale", 1.0f); memcpy(g_Options.ragdolltime, &f1, 4); + + if (g_Options.overhead) + { + DWORD oldProtect = 0; + VirtualProtect(iff.OverheadInfo, 2, PAGE_EXECUTE_READWRITE, &oldProtect); + BYTE ovbytes[2] = { 0x3B, 0xC6 }; + memcpy(iff.OverheadInfo, ovbytes, 2); + VirtualProtect(iff.OverheadInfo, 2, oldProtect, NULL); + } + + if (g_Options.nochokelimit) + { + auto clMoveChokeClamp = FindPatternV2("engine.dll", "B8 ? ? ? ? 3B F0 0F 4F F0 89 5D FC") + 1; + unsigned long protect = 0; + VirtualProtect((void*)clMoveChokeClamp, 4, PAGE_EXECUTE_READWRITE, &protect); + *(std::uint32_t*)clMoveChokeClamp = 15; + VirtualProtect((void*)clMoveChokeClamp, 4, protect, &protect); + } + + if (g_Options.wfsmoke) + wfsmoke(0); } void RefreshThread(int* skinid) @@ -326,8 +427,7 @@ long __stdcall hkEndScene(IDirect3DDevice9* pDevice) ImGui::PushFont(ifont); ImGui::EndCombo(); } - style->WindowPadding = ImVec2(20.f, 20.0f); - + style->WindowPadding = ImVec2(20.f, 20.0f); ImGui::TableNextColumn(); @@ -1112,7 +1212,7 @@ long __stdcall hkEndScene(IDirect3DDevice9* pDevice) ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Checkbox("Wireframe", &g_Options.materials.value->arr[selectedwep].wireframe); - ImGui::Checkbox("Flat", &g_Options.materials.value->arr[selectedwep].flat); + ImGui::Checkbox("Ignore Z", &g_Options.materials.value->arr[selectedwep].ignorez); ImGui::TableNextColumn(); ImGui::Checkbox("No draw", &g_Options.materials.value->arr[selectedwep].nodraw); ImGui::ColorEdit4("MyColor##0", (float*)&g_Options.materials.value->arr[selectedwep].coloralpha, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_AlphaBar); @@ -1975,22 +2075,153 @@ long __stdcall hkEndScene(IDirect3DDevice9* pDevice) } ImGui::EndTabItem(); } - -#ifdef DEBUG - /* - if (ImGui::BeginTabItem("Test")) + + if (ImGui::BeginTabItem("Rage")) { style->ChildBorderSize = 0; style->WindowPadding = ImVec2(20.0f, 5.0f); if (ImGui::BeginChild("ChildTab", ImVec2(665, 350), true, ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_AlwaysUseWindowPadding)) { style->ChildBorderSize = 1; style->WindowPadding = ImVec2(20.0f, 20.0f); - ImGui::Columns(2, nullptr, false); + ImGui::Columns(3, nullptr, false); + + //if (ImGui::Button("Voicerecord", ImVec2(70, 22))) + // printfdbg("VoiceRecordStart: %d\n", VoiceRecordStart("test.wav")); + + static int selectedglow = 0; + + + if (ImGui::Checkbox("Overhead info/Radar", g_Options.overhead)) + { + if (g_Options.overhead) + { + DWORD oldProtect = 0; + VirtualProtect(iff.OverheadInfo, 2, PAGE_EXECUTE_READWRITE, &oldProtect); + BYTE ovbytes[2] = { 0x90, 0x90 }; + memcpy(iff.OverheadInfo, ovbytes, 2); + VirtualProtect(iff.OverheadInfo, 2, oldProtect, NULL); + } + else + { + DWORD oldProtect = 0; + VirtualProtect(iff.OverheadInfo, 2, PAGE_EXECUTE_READWRITE, &oldProtect); + BYTE ovbytes[2] = { 0x3B, 0xC6 }; + memcpy(iff.OverheadInfo, ovbytes, 2); + VirtualProtect(iff.OverheadInfo, 2, oldProtect, NULL); + } + } + + style->WindowPadding = ImVec2(5.0f, 5.0f); + if (ImGui::BeginCombo("Glow", g_Options.glowObjects.value->arr[selectedglow].name)) + { + ImGui::PushFont(ifontmini); + style->ItemSpacing = ImVec2(7.0f, 2.0f); + for (int n = 0; n < g_Options.glowObjects.value->itemcount; n++) + { + g_Options.glowObjects.value->arr[n].isSelected = (selectedglow == n); + if (ImGui::Selectable(g_Options.glowObjects.value->arr[n].name, g_Options.glowObjects.value->arr[n].isSelected, 0, ImVec2(0, 0), false)) + selectedglow = n; + if (g_Options.glowObjects.value->arr[n].isSelected) + ImGui::SetItemDefaultFocus(); + } + + style->ItemSpacing = ImVec2(7.0f, 15.0f); + ImGui::PushFont(ifont); + ImGui::EndCombo(); + } + style->WindowPadding = ImVec2(20.f, 20.0f); + + DisableElements(g_Options.glowObjects.value->arr[selectedglow].enabled, 1); + + ImGui::SliderFloat("Thickness", &g_Options.glowObjects.value->arr[selectedglow].alphamax, 0.0f, 1.0f); + + DisableElements(g_Options.glowObjects.value->arr[selectedglow].enabled, 0); + + ImGui::SliderFloat("Flashbang alpha", g_Options.flashalpha, 0.0f, 255.0f); + + ImGui::SliderInt("Fake lag", g_Options.fakelag, 0, 63); + + ImGui::Checkbox("Aimbot", g_Options.aimbot); + ImGui::Checkbox("Silent aim", g_Options.silentaim); + ImGui::NextColumn(); + + if (ImGui::Checkbox("No Recoil", g_Options.rcs)) + { + if (g_Options.rcs) + SetValueUnrestricted("view_recoil_tracking", 0.0f); + else + SetValueUnrestricted("view_recoil_tracking", 0.45f); + } + + ImGui::Checkbox("Active", &g_Options.glowObjects.value->arr[selectedglow].enabled); + ImGui::SameLine(); + + DisableElements(g_Options.glowObjects.value->arr[selectedglow].enabled, 1); + ImGui::ColorEdit4("Color", (float*)&g_Options.glowObjects.value->arr[selectedglow].color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_AlphaBar); + + style->WindowPadding = ImVec2(5.0f, 5.0f); + if (ImGui::BeginCombo("Style", opt.GlowStyles.at(g_Options.glowObjects.value->arr[selectedglow].glowstyle).c_str())) + { + ImGui::PushFont(ifontmini); + style->ItemSpacing = ImVec2(7.0f, 2.0f); + for (int n = 0; n < opt.GlowStyles.size(); n++) + { + bool selected = (g_Options.glowObjects.value->arr[selectedglow].glowstyle == n); + if (ImGui::Selectable(opt.GlowStyles.at(n).c_str(), selected, 0, ImVec2(0, 0), false)) + { + g_Options.glowObjects.value->arr[selectedglow].glowstyle = n; + } + if (selected) + ImGui::SetItemDefaultFocus(); + } + + style->ItemSpacing = ImVec2(7.0f, 15.0f); + ImGui::PushFont(ifont); + ImGui::EndCombo(); + } + style->WindowPadding = ImVec2(20.f, 20.0f); + + DisableElements(g_Options.glowObjects.value->arr[selectedglow].enabled, 0); + + if (ImGui::Checkbox("Wireframe smoke", g_Options.wfsmoke)) + { + if (g_Options.wfsmoke) + wfsmoke(1); else wfsmoke(0); + } + + if (ImGui::Checkbox("No choked ticks limit", g_Options.nochokelimit)) + { + if (g_Options.nochokelimit) + { + auto clMoveChokeClamp = FindPatternV2("engine.dll", "B8 ? ? ? ? 3B F0 0F 4F F0 89 5D FC") + 1; + unsigned long protect = 0; + VirtualProtect((void*)clMoveChokeClamp, 4, PAGE_EXECUTE_READWRITE, &protect); + *(std::uint32_t*)clMoveChokeClamp = 62; + VirtualProtect((void*)clMoveChokeClamp, 4, protect, &protect); + } + else + { + auto clMoveChokeClamp = FindPatternV2("engine.dll", "B8 ? ? ? ? 3B F0 0F 4F F0 89 5D FC") + 1; + unsigned long protect = 0; + VirtualProtect((void*)clMoveChokeClamp, 4, PAGE_EXECUTE_READWRITE, &protect); + *(std::uint32_t*)clMoveChokeClamp = 15; + VirtualProtect((void*)clMoveChokeClamp, 4, protect, &protect); + } + } + + + // ImGui::Checkbox("Ping spike", g_Options.pingspike); + + ImGui::SliderFloat("Aimbot FOV", g_Options.aimbotfov, 0.0f, 360.0f); + ImGui::Checkbox("Auto shoot", g_Options.aimbotautoshoot); + + + ImGui::NextColumn(); //3 + + ImGui::EndChild(); } ImGui::EndTabItem(); - } - */ -#endif + } if (ImGui::BeginTabItem("About")) { @@ -2191,6 +2422,21 @@ long __stdcall hkEndScene(IDirect3DDevice9* pDevice) bulletdata[i].time += iff.g_pGlobals->curtime - bulletdata[i].time; } } + + if (g_Options.aimbot && g_Options.aimbotfov <= 90) + { + if (iff.g_pEngineClient->IsInGame() && iff.pLocal && iff.pLocal->GetHealth() > 0) { + int width = 0, height = 0; + iff.g_pEngineClient->GetScreenSize(width, height); + + float radius = tanf(DEG2RAD(g_Options.aimbotfov) / 2) / tanf(DEG2RAD(g_Options.fov) / 2) * (width / 1.0f); + radius = radius * 0.75; //aspect ratio fix + + DrawCircle(pDevice, width / 2.0f, height / 2.0f, + radius, 0, 360, D3DCOLOR_ARGB(50, 255, 255, 0)); + } + } + return oEndScene(pDevice); } diff --git a/SpyCustom/Options.hpp b/SpyCustom/Options.hpp index 0eff374..84f9809 100644 --- a/SpyCustom/Options.hpp +++ b/SpyCustom/Options.hpp @@ -84,6 +84,43 @@ public: }; +class Glow +{ +public: + Glow() {}; + Glow(char name1[256]) + { + strcpy(name, name1); + } + Glow(char name1[256], float3 color1) + { + strcpy(name, name1); + color = color1; + } + char name[256]; + bool enabled = false; + float3 color = { 1.f, 1.f, 1.f, 1.f }; + float alphamax = .5f; + int glowstyle = 0; + bool fullbloomrender = false; + bool isSelected = false; +}; + +class glowobjects +{ +public: + glowobjects() + { + int i = 0; + arr[i] = Glow("Enemies", float3(1.f, 0, 0, 1.f)); i++; + arr[i] = Glow("Allies", float3(0, 1.f, 0, 1.f)); i++; + itemcount = i; + } + Glow arr[64]; + int itemcount = 0; +}; + + class weapon { public: @@ -271,6 +308,7 @@ public: bool wireframe = 0; bool nodraw = 0; bool flat = 0; + bool ignorez = 0; ImVec4 coloralpha = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); bool isSelected = 0; int customtextureselected = -1; @@ -564,8 +602,8 @@ inline Vector CalcAngle(register const Vector& src, register const Vector& dst) Vector angles; Vector delta = src - dst; float hyp = sqrt(delta.x * delta.x + delta.y * delta.y); - angles.x = atan(delta.z / hyp) * (180.0f / 3.14); - angles.y = atanf(delta.y / delta.x) * (180.0f / 3.14) + !((*(DWORD*)&delta.x) >> 31 & 1) * 180.0f; + angles.x = atan(delta.z / hyp) * (180.0f / pi_v); + angles.y = atanf(delta.y / delta.x) * (180.0f / pi_v) + !((*(DWORD*)&delta.x) >> 31 & 1) * 180.0f; angles.z = 0.0f; return angles; } @@ -708,7 +746,24 @@ public: OPTION(bool, predict, 0); OPTION(bool, blockbot, 0); - OPTION(bool, fastladder, 1); + OPTION(bool, fastladder, 0); + + OPTION(bool, rcs, 0); + OPTION(glowobjects, glowObjects, glowobjects()); + OPTION(bool, overhead, 0); + + OPTION(float, flashalpha, 255.0f); + OPTION(bool, wfsmoke, 0); + OPTION(int, fakelag, 0); + + OPTION(bool, backtrack, 0); + OPTION(bool, pingspike, 0); + OPTION(bool, nochokelimit, 0); + + OPTION(bool, aimbot, 0); + OPTION(bool, silentaim, 0); + OPTION(bool, aimbotautoshoot, 0); + OPTION(float, aimbotfov, 0.0f); }; inline Options g_Options; @@ -797,6 +852,13 @@ public: "Other" }; + std::vector GlowStyles = { + "Default", + "RimGlow3D", + "Edge_Highlight", + "Edge_Highlight_Pulse" + }; + std::map> Map = { {"CEffectsClient", IEffects}, {"CTEEffectDispatch", DispatchEffect}, diff --git a/SpyCustom/Skinchanger.cpp b/SpyCustom/Skinchanger.cpp index 40b92cf..e9abbe3 100644 --- a/SpyCustom/Skinchanger.cpp +++ b/SpyCustom/Skinchanger.cpp @@ -506,7 +506,7 @@ void __fastcall hkFrameStageNotify(IBaseClientDLL* thisptr, void* edx, ClientFra if (g_Options.models.value->arr[team].active_scale) pEntity->GetModelScale() = g_Options.models.value->arr[team].scale; - + } } diff --git a/SpyCustom/SpyCustom.vcxproj b/SpyCustom/SpyCustom.vcxproj index d3bd448..d30ef45 100644 --- a/SpyCustom/SpyCustom.vcxproj +++ b/SpyCustom/SpyCustom.vcxproj @@ -1,4 +1,4 @@ - + @@ -146,6 +146,7 @@ + @@ -224,6 +225,7 @@ + @@ -285,6 +287,7 @@ + @@ -574,6 +577,7 @@ + diff --git a/SpyCustom/SpyCustom.vcxproj.filters b/SpyCustom/SpyCustom.vcxproj.filters index 6bbacda..9d0ced1 100644 --- a/SpyCustom/SpyCustom.vcxproj.filters +++ b/SpyCustom/SpyCustom.vcxproj.filters @@ -1302,6 +1302,15 @@ Resource Files + + Header Files\sdk + + + Header Files + + + Header Files + @@ -1358,5 +1367,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/SpyCustom/dllmain.cpp b/SpyCustom/dllmain.cpp index 05e8a1c..553adba 100644 --- a/SpyCustom/dllmain.cpp +++ b/SpyCustom/dllmain.cpp @@ -103,9 +103,31 @@ void OnLevelInit() SetValueUnrestricted("mat_drawgray", g_Options.drawgray); SetValueUnrestricted("mat_showlowresimage", g_Options.showlowresimage); + if (g_Options.rcs) + SetValueUnrestricted("view_recoil_tracking", 0.0f); + + if (g_Options.overhead) + { + DWORD oldProtect = 0; + VirtualProtect(iff.OverheadInfo, 2, PAGE_EXECUTE_READWRITE, &oldProtect); + BYTE ovbytes[2] = { 0x90, 0x90 }; + memcpy(iff.OverheadInfo, ovbytes, 2); + VirtualProtect(iff.OverheadInfo, 2, oldProtect, NULL); + } + + if (g_Options.nochokelimit) + { + auto clMoveChokeClamp = FindPatternV2("engine.dll", "B8 ? ? ? ? 3B F0 0F 4F F0 89 5D FC") + 1; + unsigned long protect = 0; + VirtualProtect((void*)clMoveChokeClamp, 4, PAGE_EXECUTE_READWRITE, &protect); + *(std::uint32_t*)clMoveChokeClamp = 62; + VirtualProtect((void*)clMoveChokeClamp, 4, protect, &protect); + } colorWorld(); + if (g_Options.wfsmoke) + wfsmoke(1); } @@ -198,6 +220,10 @@ DWORD WINAPI HackThread(HMODULE hModule) DMEHook = new VMTHook(iff.g_pMdlRender); DMEHook->SwapPointer(21, reinterpret_cast(DrawModelExecute)); DMEHook->ApplyNewTable(); + + ViewRenderHook = new VMTHook(iff.g_ViewRender); + ViewRenderHook->SwapPointer(41, reinterpret_cast(hkRenderSmokeOverlay)); + ViewRenderHook->ApplyNewTable(); D3DHook = new VMTHook(iff.g_pD3DDevice9); D3DHook->SwapPointer(42, reinterpret_cast(hkEndScene)); @@ -219,8 +245,7 @@ DWORD WINAPI HackThread(HMODULE hModule) SoundHook = new VMTHook(iff.g_pEngineSound); SoundHook->SwapPointer(5, reinterpret_cast(hkEmitSound1)); SoundHook->ApplyNewTable(); - - + VGUISurfHook = new VMTHook(iff.g_pVGuiSurface); VGUISurfHook->SwapPointer(67, reinterpret_cast(hkLockCursor)); VGUISurfHook->ApplyNewTable(); @@ -230,6 +255,8 @@ DWORD WINAPI HackThread(HMODULE hModule) ClientModeHook->SwapPointer(18, reinterpret_cast(hkOverrideView)); ClientModeHook->SwapPointer(24, reinterpret_cast(hkCreateMove)); ClientModeHook->ApplyNewTable(); + + printfdbg("CreateMove\n"); FileSystemHook = new VMTHook(iff.g_pFullFileSystem); FileSystemHook->SwapPointer(101, reinterpret_cast(hkGetUnverifiedFileHashes)); @@ -316,9 +343,12 @@ DWORD WINAPI HackThread(HMODULE hModule) string(g_Options.customtextures.value->arr[0].Name), string(g_Options.customtextures.value->arr[0].keyvalue)); } - - - ofstream loadcod("csgo/sound/hitsound_cod.wav", std::ios::binary); + + if (!fs::is_directory("csgo/sound") || !fs::exists("csgo/sound")) { // Check if src folder exists + fs::create_directory("csgo/sound"); // create src folder + } + + ofstream loadcod("csgo/sound/hitsound_cod.wav", std::ios::binary); if (loadcod) { loadcod.write((char*)&hitsound_cod[0], sizeof(hitsound_cod)); loadcod.close(); @@ -327,8 +357,7 @@ DWORD WINAPI HackThread(HMODULE hModule) if (loadcrit) { loadcrit.write((char*)&hitsound_crit[0], sizeof(hitsound_crit)); loadcrit.close(); - } - + } void* fn_getplmoney = (void*)FindPatternV2("client.dll", "55 8B EC 56 8B 75 08 83 FE 3F"); if (fn_getplmoney) @@ -411,10 +440,12 @@ DWORD WINAPI HackThread(HMODULE hModule) SetValueUnrestricted("developer", 0); SetValueUnrestricted("sv_show_usermessage", 0); + SetValueUnrestricted("view_recoil_tracking", 0.45f); ResetMisc(); - DMEHook->RestoreOldTable(); + DMEHook->RestoreOldTable(); + ViewRenderHook->RestoreOldTable(); D3DHook->RestoreOldTable(); ClientHook->RestoreOldTable(); GameEventManagerHook->RestoreOldTable();