Исходник Legit backtrack for legendware

Пользователь
Статус
Оффлайн
Регистрация
29 Дек 2020
Сообщения
64
Реакции[?]
31
Поинты[?]
2K
Create a cpp and a h on legitbot folder then paste this:

backtrack.cpp:
C++:
#include "BackTrack.h"
#define TICK_INTERVAL            (m_globals()->m_intervalpertick)
#define TIME_TO_TICKS( dt )        ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
TimeWarp g_Backtrack;

void TimeWarp::CreateMove(CUserCmd* cmd)
{

    int bestTargetIndex = -1;
    float bestFov = FLT_MAX;

    if (!g_ctx.local()->is_alive())
        return;

    if (!g_cfg.legitbot.enabled)
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++) //-V807
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (!e || !g_ctx.local())
            continue;

        if (!e->is_player())
            continue;

        if (e == g_ctx.local())
            continue;

        if (e->IsDormant())
            continue;

        if (e->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
            continue;

        auto pEntity = e;

        float simtime = pEntity->m_flSimulationTime();
        Vector hitboxPos = pEntity->hitbox_position(0);

        switch (g_cfg.legitbot.weapon[hooks::legit_weapon].accuracy_boost_type)
        {
        case 0:
            accuracy_boost = 4;
            break;
        case 1:
            accuracy_boost = 8;
            break;
        case 2:
            accuracy_boost = 16;
            break;
        }

        TimeWarpData[i][cmd->m_command_number % (accuracy_boost + 1)] = StoredData{ simtime, hitboxPos };
        Vector ViewDir;
        math::angle_vectors(cmd->m_viewangles + (g_ctx.local()->m_aimPunchAngle() * 2.f), ViewDir);
        float FOVDistance = math::DistancePointToLine(hitboxPos, g_ctx.local()->GetEyePos(), ViewDir);

        if (bestFov > FOVDistance)
        {
            bestFov = FOVDistance;
            bestTargetIndex = i;
        }
    }

    float bestTargetSimTime = -1;
    if (bestTargetIndex != -1)
    {
        float tempFloat = FLT_MAX;
        Vector ViewDir;
        math::angle_vectors(cmd->m_viewangles + (g_ctx.local()->m_aimPunchAngle() * 2.f), ViewDir);
        for (int t = 0; t < accuracy_boost; ++t)
        {
            float tempFOVDistance = math::DistancePointToLine(TimeWarpData[bestTargetIndex][t].hitboxPos, g_ctx.local()->GetEyePos(), ViewDir);
            if (tempFloat > tempFOVDistance && TimeWarpData[bestTargetIndex][t].simtime > g_ctx.local()->m_flSimulationTime() - 1)
            {
                if (g_ctx.local()->CanSeePlayer(static_cast<player_t*>(m_entitylist()->GetClientEntity(bestTargetIndex)), TimeWarpData[bestTargetIndex][t].hitboxPos))
                {
                    tempFloat = tempFOVDistance;
                    bestTargetSimTime = TimeWarpData[bestTargetIndex][t].simtime;
                }
            }
        }

        if (bestTargetSimTime >= 0 && cmd->m_buttons & IN_ATTACK)
            cmd->m_tickcount = TIME_TO_TICKS(bestTargetSimTime);
    }

}
backtrack.h:
C++:
#pragma once

#include "../../includes.hpp"


#define NUM_OF_TICKS 16

struct StoredData
{
    float simtime;
    Vector hitboxPos;

};

class TimeWarp
{
public:
    void CreateMove(CUserCmd* cmd);
    StoredData TimeWarpData[64][NUM_OF_TICKS];
    int nLatestTick;
    int accuracy_boost = 4;
};

extern TimeWarp g_Backtrack;

structs.cpp [line 660]
C++:
bool player_t::CanSeePlayer(player_t* player, int hitbox)
{
    CGameTrace tr;
    Ray_t ray;
    CTraceFilter filter;
    filter.pSkip = this;

    auto endpos = player->hitbox_position(hitbox);

    ray.Init(GetEyePos(), endpos);
    m_trace()->TraceRay(ray, MASK_SHOT | CONTENTS_GRATE, &filter, &tr);

    return tr.hit_entity == player || tr.fraction > 0.97f;
}

bool player_t::CanSeePlayer(player_t* player, const Vector& pos)
{
    CGameTrace tr;
    Ray_t ray;
    CTraceFilter filter;
    filter.pSkip = this;

    ray.Init(GetEyePos(), pos);
    m_trace()->TraceRay(ray, MASK_SHOT | CONTENTS_GRATE, &filter, &tr);

    return tr.hit_entity == player || tr.fraction > 0.97f;
}
math.hpp [line 61]

C++:
    inline float DistancePointToLine(Vector Point, Vector LineOrigin, Vector Dir)
    {
        auto PointDir = Point - LineOrigin;

        auto TempOffset = PointDir.Dot(Dir) / (Dir.x * Dir.x + Dir.y * Dir.y + Dir.z * Dir.z);
        if (TempOffset < 0.000001f)
            return FLT_MAX;

        auto PerpendicularPoint = LineOrigin + (Dir * TempOffset);

        return (Point - PerpendicularPoint).Length();
    }
hooked_createmove.cpp [line 215 under legitbot createmove]:
C++:
    g_Backtrack.CreateMove(m_pcmd);
done u have p backtrack now, and for the menu just put a combobox with 3 buttons, "Low", "Medium", "High".
have fun pasters, Spooky#2881 (if u need any help)
 
Последнее редактирование:
Сверху Снизу