Вопрос При включении рейджа происходит обосрыха

Трахов
Пользователь
Статус
Оффлайн
Регистрация
6 Фев 2020
Сообщения
490
Реакции[?]
87
Поинты[?]
2K


C++:
#include "ragebot.h"
//#include "antiaim.h"
#include "../global.h"
#include "../utilities/math.h"
#include "lagcompensation.h"
#include "../core/variables.h"
/*
float flOldCurtime;
float flOldFrametime;

void MovementFix::Start(CUserCmd* cmd)
{
    m_oldangle = cmd->angViewPoint;
    m_oldforward = cmd->flForwardMove;
    m_oldsidemove = cmd->flSideMove;
}

void MovementFix::End(CUserCmd* cmd)
{
    float yaw_delta = cmd->angViewPoint.y - m_oldangle.y;
    float f1;
    float f2;

    if (m_oldangle.y < 0.f)
        f1 = 360.0f + m_oldangle.y;
    else
        f1 = m_oldangle.y;

    if (cmd->angViewPoint.y < 0.0f)
        f2 = 360.0f + cmd->angViewPoint.y;
    else
        f2 = cmd->angViewPoint.y;

    if (f2 < f1)
        yaw_delta = abs(f2 - f1);
    else
        yaw_delta = 360.0f - abs(f1 - f2);
    yaw_delta = 360.0f - yaw_delta;

    cmd->flForwardMove = cos(M_DEG2RAD(yaw_delta)) * m_oldforward + cos(M_DEG2RAD(yaw_delta + 90.f)) * m_oldsidemove;
    cmd->flSideMove = sin(M_DEG2RAD(yaw_delta)) * m_oldforward + sin(M_DEG2RAD(yaw_delta + 90.f)) * m_oldsidemove;
}

void RageAimbot::StartEnginePred(CUserCmd* cmd)
{
    static int nTickBase;
    static CUserCmd* pLastCmd;

    // fix tickbase if game didnt render previous tick
    if (pLastCmd)
    {
        if (pLastCmd->bHasBeenPredicted)
            nTickBase = G::pLocal->GetTickBase();
        else
            ++nTickBase;
    }

    pLastCmd = cmd;
    flOldCurtime = I::Globals->flCurrentTime;
    flOldFrametime = I::Globals->flFrameTime;

    I::Globals->flCurrentTime = nTickBase * I::Globals->flIntervalPerTick;
    I::Globals->flFrameTime = I::Globals->flIntervalPerTick;

    I::GameMovement->StartTrackPredictionErrors(G::pLocal);

    CMoveData data;
    memset(&data, 0, sizeof(CMoveData));

    I::MoveHelper->SetHost(G::pLocal);
    I::Prediction->SetupMove(G::pLocal, cmd, I::MoveHelper, &data);
    I::GameMovement->ProcessMovement(G::pLocal, &data);
    I::Prediction->FinishMove(G::pLocal, cmd, &data);
}

void RageAimbot::EndEnginePred()
{
    I::GameMovement->FinishTrackPredictionErrors(G::pLocal);
    I::MoveHelper->SetHost(nullptr);

    I::Globals->flCurrentTime = flOldCurtime;
    I::Globals->flFrameTime = flOldFrametime;
}
*/

bool RageAimbot::Hitchance(CBaseCombatWeapon* weapon, QAngle angles, CBaseEntity* ent, float chance) //pasted
{
    Vector forward, right, up;
    Vector src = G::pLocal->GetEyePosition();
    M::AngleVectors(angles, &forward, &right, &up);

    int cHits = 0;
    int cNeededHits = static_cast<int> (150.f * (chance / 100.f));

    weapon->UpdateAccuracyPenalty();
    float weap_spread = weapon->GetSpread();
    float weap_inaccuracy = weapon->GetInaccuracy();

    for (int i = 0; i < 150; i++)
    {
        float a = M::RandomFloat(0.f, 1.f);
        float b = M::RandomFloat(0.f, 2.f * M_PI);
        float c = M::RandomFloat(0.f, 1.f);
        float d = M::RandomFloat(0.f, 2.f * M_PI);

        float inaccuracy = a * weap_inaccuracy;
        float spread = c * weap_spread;

        if (weapon->GetItemDefinitionIndex() == 64)
        {
            a = 1.f - a * a;
            a = 1.f - c * c;
        }

        Vector spreadView((cos(b) * inaccuracy) + (cos(d) * spread), (sin(b) * inaccuracy) + (sin(d) * spread), 0), direction;

        direction.x = forward.x + (spreadView.x * right.x) + (spreadView.y * up.x);
        direction.y = forward.y + (spreadView.x * right.y) + (spreadView.y * up.y);
        direction.z = forward.z + (spreadView.x * right.z) + (spreadView.y * up.z);
        direction.Normalized();

        QAngle viewAnglesSpread;
        M::VectorAngles(direction, up, viewAnglesSpread);
        viewAnglesSpread.Normalize();

        Vector viewForward;
        M::AngleVectors(viewAnglesSpread, &viewForward);
        viewForward.NormalizeInPlace();

        viewForward = src + (viewForward * weapon->GetCSWeaponData()->flRange);

        CGameTrace tr;
        auto ray = Ray_t(src, viewForward);

        I::EngineTrace->ClipRayToEntity(ray, MASK_SHOT | CONTENTS_GRATE, ent, &tr);

        if (tr.pHitEntity == ent)
            ++cHits;

        if (static_cast<int> ((static_cast<float> (cHits) / 150.f) * 100.f) >= chance)
            return true;

        if ((150 - i + cHits) < cNeededHits)
            return false;
    }

    return false;
}
bool RageAimbot::Hitscan(CBaseEntity* Player, Vector& HitboxPos, bool Backtrack, matrix3x4_t* BoneMatrix)
{
    std::vector<int> HitBoxesToScan{ 0,1,2,3,4,5,6, HITBOX_LEFT_FOOT, HITBOX_RIGHT_FOOT };

    int bestHitbox = -1;
    if (!Backtrack)
    {
        float highestDamage;

        highestDamage = Vars.iRageMinDamage;

        for (auto HitBoxID : HitBoxesToScan)
        {
            Player->SetAbsOrigin(Player->GetOrigin());
            std::optional<Vector> Point = Player->GetHitboxPosition(HitBoxID);
            float damage = Player->GetHealth();
            if (damage >= highestDamage || damage >= Player->GetHealth())
            {
                bestHitbox = HitBoxID;
                highestDamage = damage;
                HitboxPos == Point;
                return true;
            }
        }
    }
    /*
    else //didnt autowall the backtrackz coz my pc is slow af and it goes skra
    {
        for (auto HitBoxID : HitBoxesToScan)
        {
            //Player->SetAbsOrigin(BacktrackRecords[Player->EntIndex()].back().Origin);
            std::optional<Vector>  Point = Player->GetHitboxPosition(HitBoxID);
            if (IsEnemy->CanSeePlayer(Player, Point))
            {
                bestHitbox = HitBoxID;
                HitboxPos == Point;
                return true;
            }
        }
    }*/
    return false;
}

void RageAimbot::StoreRecords()
{
    for (int i = 1; i <= 64; i++)
    {
        CBaseEntity* Player = I::ClientEntityList->Get<CBaseEntity>(i);
        if (!Player ||
            Player->IsDormant() ||
            !Player->IsPlayer() ||
            !Player->IsAlive() ||
            !Player->IsEnemy(Player))
        {
            if (BacktrackRecords[i].size() > 0)
                for (int Tick = 0; Tick < BacktrackRecords[i].size(); Tick++)
                    BacktrackRecords[i].erase(BacktrackRecords[i].begin() + Tick);
            continue;
        }

        BacktrackRecords[i].insert(BacktrackRecords[i].begin(), TickInfo(Player));
        for (auto Tick : BacktrackRecords[i])
            if (!CLagCompensation::Get().is_tick_valid(Tick.SimulationTime, 0.2f))
                BacktrackRecords[i].pop_back();
    }
}

float Hitchance2(CBaseCombatWeapon* Weapon)
// coz i need to restore shit for the proper hitchance to work with backtrack
{
    float Hitchance = 101;
    if (!Weapon) return 0;
    if (Vars.iRageHitChance > 1)
    {
        float Inaccuracy = Weapon->GetInaccuracy();
        if (Inaccuracy == 0) Inaccuracy = 0.0000001;
        Inaccuracy = 1 / Inaccuracy;
        Hitchance = Inaccuracy;

    }
    return Hitchance;
}

void RageAimbot::Do(CUserCmd* cmd, CBaseCombatWeapon* Weapon, bool& bSendPacket)
{
    if (!G::pLocal ||
        !G::pLocal->IsAlive() ||
        !Weapon ||
        Weapon->GetCSWeaponData()->IsGun() ||
        !Vars.bRage)
        return;

    int BestTargetIndex = -1;
    float BestTargetDistance = FLT_MAX;
    float BestTargetSimtime = 0.f;
    Vector Hitbox = Vector{};

    bool Backtrack = false;

    for (int i = 1; i <= 64; i++)
    {
        CBaseEntity* Player = I::ClientEntityList->Get<CBaseEntity>(i);
        if (!Player ||
            !Player->IsPlayer() ||
            Player->IsDormant() ||
            !Player->IsAlive() ||
            !Player->IsEnemy(Player) ||
            BacktrackRecords[i].size() < 1)
            continue;


        float PlayerDistance = M::VectorDistance(G::pLocal->GetOrigin(), Player->GetOrigin());
        if (BestTargetDistance > PlayerDistance)
        {
            if (BacktrackRecords[i].front().MatrixBuilt && BacktrackRecords[i].front().BoneMatrix != nullptr &&
                Hitscan(Player, Hitbox, false, BacktrackRecords[i].front().BoneMatrix))
            {
                BestTargetDistance = PlayerDistance;
                BestTargetIndex = i;
                BestTargetSimtime = Player->GetSimulationTime();
                Backtrack = false;
            }
            else if (BacktrackRecords[i].back().MatrixBuilt && BacktrackRecords[i].back().BoneMatrix != nullptr &&
                Hitscan(Player, Hitbox, true, BacktrackRecords[i].back().BoneMatrix))
            {
                BestTargetDistance = PlayerDistance;
                BestTargetIndex = i;
                BestTargetSimtime = BacktrackRecords[i].back().SimulationTime;
                Backtrack = true;
            }
        }
    }
    if (BestTargetIndex != -1 && Hitbox.IsValid() && BestTargetSimtime)
    {
        CBaseEntity* Target = I::ClientEntityList->Get<CBaseEntity>(BestTargetIndex);
        if (!Target) return;
        //QAngle AimAngle = M::CalcAngle(G::pLocal->GetEyePosition(), Hitbox);
        //AimAngle -= G::pLocal->GetPunch() * I::ConVar->FindVar("weapon_recoil_scale")->GetFloat();
        //(AimAngle).Normalize;
        //(AimAngle).Clamp;

        //cmd->angViewPoint = AimAngle;

        if (Hitchance(Weapon, cmd->angViewPoint, Target, float(Vars.iRageHitChance)) ||
            Backtrack && Vars.iRageHitChance * 1.5 <= Hitchance2(Weapon) ||
            Vars.iRageHitChance == 0)
        {
            if (!(cmd->iButtons & IN_ATTACK) && Weapon->CanFire())
            {
                bSendPacket = true;
                cmd->iTickCount = TIME_TO_TICKS(BestTargetSimtime + CLagCompensation::Get().lerp_time());
                cmd->iButtons |= IN_ATTACK;
            }
        }
    }
}
ржэкич бот взял из какой-то параши для примера (т.е буду пытаться что либо делать на нем, можно сказать переписывать фул)
в чем прекол?)
 
Сверху Снизу