Add hitchance to triggerbot (spread simulation via GetInaccuracy/GetSpread)
This commit is contained in:
@@ -24,6 +24,9 @@
|
|||||||
#include <GameClient/CL_Bypass.hpp>
|
#include <GameClient/CL_Bypass.hpp>
|
||||||
#include <GameClient/CEntityCache/CEntityCache.hpp>
|
#include <GameClient/CEntityCache/CEntityCache.hpp>
|
||||||
#include <CS2/SDK/Types/CBaseTypes.hpp>
|
#include <CS2/SDK/Types/CBaseTypes.hpp>
|
||||||
|
#include <CS2/SDK/FunctionListSDK.hpp>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include <ImGui/imgui.h>
|
#include <ImGui/imgui.h>
|
||||||
|
|
||||||
@@ -296,6 +299,16 @@ auto CMisc::RunTriggerbot( CCSGOInput* pInput , CUserCmd* pUserCmd ) -> void
|
|||||||
case 7: bTargetValid = Settings::Triggerbot::Hitbox_Legs; break;
|
case 7: bTargetValid = Settings::Triggerbot::Hitbox_Legs; break;
|
||||||
default: bTargetValid = true; break;
|
default: bTargetValid = true; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( bTargetValid && Settings::Triggerbot::Hitchance > 0 )
|
||||||
|
{
|
||||||
|
const QAngle ViewAngles = *CCSGOInput_GetViewAngles( pInput , 0 );
|
||||||
|
|
||||||
|
const float flHitchance = CalculateHitchance( pInput , pTargetPawn , ViewAngles , Settings::Triggerbot::HitchanceSamples );
|
||||||
|
|
||||||
|
if ( ( flHitchance * 100.f ) < static_cast<float>( Settings::Triggerbot::Hitchance ) )
|
||||||
|
bTargetValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +363,53 @@ auto CMisc::RunTriggerbot( CCSGOInput* pInput , CUserCmd* pUserCmd ) -> void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static thread_local std::mt19937 g_TriggerRng( std::random_device{}() );
|
||||||
|
|
||||||
|
auto CMisc::CalculateHitchance( CCSGOInput* pInput , C_CSPlayerPawn* pTarget , const QAngle& ViewAngles , const int Samples ) -> float
|
||||||
|
{
|
||||||
|
if ( !pTarget || Samples <= 0 )
|
||||||
|
return 0.f;
|
||||||
|
|
||||||
|
auto* pWeapon = GetCL_Weapons()->GetLocalActiveWeapon();
|
||||||
|
|
||||||
|
if ( !pWeapon )
|
||||||
|
return 0.f;
|
||||||
|
|
||||||
|
const float flInaccuracy = C_CSWeaponBaseGun_GetInaccuracy( pWeapon , nullptr , nullptr );
|
||||||
|
const float flSpread = C_CSWeaponBaseGun_GetSpread( pWeapon );
|
||||||
|
|
||||||
|
const float flAccuracy = flInaccuracy + flSpread;
|
||||||
|
|
||||||
|
if ( flAccuracy <= 0.f )
|
||||||
|
return 1.f;
|
||||||
|
|
||||||
|
Vector3 vForward , vRight , vUp;
|
||||||
|
|
||||||
|
Math::AngleVectors( ViewAngles , vForward , vRight , vUp );
|
||||||
|
|
||||||
|
const auto vStart = GetCL_Players()->GetLocalEyeOrigin();
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> distAngle( 0.f , 6.2831853f );
|
||||||
|
std::uniform_real_distribution<float> distRadius( 0.f , 1.f );
|
||||||
|
|
||||||
|
int Hits = 0;
|
||||||
|
|
||||||
|
for ( int i = 0; i < Samples; i++ )
|
||||||
|
{
|
||||||
|
const float flAngle = distAngle( g_TriggerRng );
|
||||||
|
const float flRadius = flAccuracy * std::sqrt( distRadius( g_TriggerRng ) );
|
||||||
|
|
||||||
|
const Vector3 vDirection = ( vForward + vRight * ( std::cos( flAngle ) * flRadius ) + vUp * ( std::sin( flAngle ) * flRadius ) ).Normalized();
|
||||||
|
|
||||||
|
const Vector3 vEnd = vStart + vDirection * 8192.f;
|
||||||
|
|
||||||
|
if ( GetCL_Trace()->TraceToEntityEndPos( &vEnd ) == reinterpret_cast<C_BaseEntity*>( pTarget ) )
|
||||||
|
Hits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<float>( Hits ) / static_cast<float>( Samples );
|
||||||
|
}
|
||||||
|
|
||||||
auto CMisc::OnFrameStageNotify( int FrameStage ) -> void
|
auto CMisc::OnFrameStageNotify( int FrameStage ) -> void
|
||||||
{
|
{
|
||||||
if ( FrameStage != 6 )
|
if ( FrameStage != 6 )
|
||||||
|
|||||||
@@ -5,9 +5,13 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
#include <CS2/SDK/Math/QAngle.hpp>
|
||||||
|
#include <CS2/SDK/Math/Vector3.hpp>
|
||||||
|
|
||||||
class CCSGOInput;
|
class CCSGOInput;
|
||||||
class CUserCmd;
|
class CUserCmd;
|
||||||
class IGameEvent;
|
class IGameEvent;
|
||||||
|
class C_CSPlayerPawn;
|
||||||
|
|
||||||
class IMisc
|
class IMisc
|
||||||
{
|
{
|
||||||
@@ -30,6 +34,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
auto RunTriggerbot( CCSGOInput* pInput , CUserCmd* pUserCmd ) -> void;
|
auto RunTriggerbot( CCSGOInput* pInput , CUserCmd* pUserCmd ) -> void;
|
||||||
|
auto CalculateHitchance( CCSGOInput* pInput , C_CSPlayerPawn* pTarget , const QAngle& ViewAngles , const int Samples ) -> float;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::chrono::steady_clock::time_point m_HitTime{};
|
std::chrono::steady_clock::time_point m_HitTime{};
|
||||||
|
|||||||
@@ -393,6 +393,13 @@ auto CAndromedaMenu::RenderMiscPanel() -> void
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
SliderInt( "Hitchance (%)" , Settings::Triggerbot::Hitchance , 0 , 100 , Settings::Triggerbot::Hitchance > 0 ? "%d%%" : "%d (aus)" );
|
||||||
|
|
||||||
|
if ( Settings::Triggerbot::Hitchance > 0 )
|
||||||
|
SliderInt( "Hitchance Samples" , Settings::Triggerbot::HitchanceSamples , 16 , 128 );
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
Checkbox( "Nur gescoped (Sniper)" , Settings::Triggerbot::ScopedOnly );
|
Checkbox( "Nur gescoped (Sniper)" , Settings::Triggerbot::ScopedOnly );
|
||||||
Checkbox( "Teammates ignorieren" , Settings::Triggerbot::IgnoreTeammates );
|
Checkbox( "Teammates ignorieren" , Settings::Triggerbot::IgnoreTeammates );
|
||||||
Checkbox( "Fadenkreuz-Indikator" , Settings::Triggerbot::DrawIndicator );
|
Checkbox( "Fadenkreuz-Indikator" , Settings::Triggerbot::DrawIndicator );
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ namespace Settings
|
|||||||
inline auto Hitbox_Arms = false;
|
inline auto Hitbox_Arms = false;
|
||||||
inline auto Hitbox_Legs = false;
|
inline auto Hitbox_Legs = false;
|
||||||
inline auto DrawIndicator = true;
|
inline auto DrawIndicator = true;
|
||||||
|
inline auto Hitchance = 0; // percent, 0 = off
|
||||||
|
inline auto HitchanceSamples = 64;
|
||||||
}
|
}
|
||||||
namespace Colors
|
namespace Colors
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user