Я не могу скомпилировать ни один сурс

Эксперт
Статус
Оффлайн
Регистрация
17 Фев 2017
Сообщения
864
Реакции[?]
420
Поинты[?]
1K
там
На счёт лямбы - проверь работает ли чит без него.
Подключаешь ДиректИКС СДК, и не будет ошибки 1083
там не в визуалке дело и не в библиотеке директ Х.

У него траблы с настройками, потому что компилятор не видит стандартные библиотеки, там где неймспейс стд например.
 
Эксперт
Статус
Оффлайн
Регистрация
17 Фев 2017
Сообщения
864
Реакции[?]
420
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
16 Ноя 2018
Сообщения
34
Реакции[?]
0
Поинты[?]
0
C++:
        __asm {
            push tr
            push filter
            push mask
            lea edx, vecAbsEnd
            lea ecx, vecAbsStart
            call clptrtp
            add esp, 0xC
        }
почему он на это ругается?
 
Эксперт
Статус
Оффлайн
Регистрация
17 Фев 2017
Сообщения
864
Реакции[?]
420
Поинты[?]
1K
C++:
        __asm {
            push tr
            push filter
            push mask
            lea edx, vecAbsEnd
            lea ecx, vecAbsStart
            call clptrtp
            add esp, 0xC
        }
почему он на это ругается?
Нажми поочередно на каждую из этих ошибок и скинь мне код который высветит. Желательно и скринами и в теге код

Это не весь код, начинай с функции. Этот код находится в { } скобках
Нужен наглядный скрин всего кода в теле функции и саму функцию которая скорее всего выглядит как лямбда-выражение
 
Эксперт
Статус
Оффлайн
Регистрация
17 Фев 2017
Сообщения
864
Реакции[?]
420
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
16 Ноя 2018
Сообщения
34
Реакции[?]
0
Поинты[?]
0
Нажми поочередно на каждую из этих ошибок и скинь мне код который высветит. Желательно и скринами и в теге код

Это не весь код, начинай с функции. Этот код находится в { } скобках
Нужен наглядный скрин всего кода в теле функции и саму функцию которая скорее всего выглядит как лямбда-выражение
Код:
#include "FakeLag.h"
#include "Autowall.h"

void peeking_fakelag_autowall::scale_damage(C_CSPlayer* target, const CCSWeaponInfo* weapon_data, float& current_damage)
{
    const auto armor_value = target->GetArmorValue();
    current_damage *= 4.f;

    if (armor_value > 0 && target->HasHelmet())
    {
        const auto bonus_value = 1.f;
        const auto armor_bonus_ratio = 0.5f;
        const auto armor_ratio = weapon_data->flArmorRatio / 2.f;

        auto new_damage = current_damage * armor_ratio;

        if (((current_damage - (current_damage * armor_ratio)) * (bonus_value * armor_bonus_ratio)) > armor_value)
            new_damage = current_damage - (armor_value / armor_bonus_ratio);

        current_damage = new_damage;
    }
}[ATTACH=full]15265[/ATTACH][ATTACH=full]15266[/ATTACH]

bool peeking_fakelag_autowall::trace_to_exit(CGameTrace& enter_trace, CGameTrace& exit_trace, Vector start_position, Vector direction)
{
    const auto max_distance = 90.f;
    const auto ray_extension = 4.f;
    float current_distance = 0;
    auto first_contents = 0;

    while (current_distance <= max_distance)
    {
        current_distance += ray_extension; ////Add extra distance to our ray

        //Multiply the direction vector to the distance so we go outwards, add our position to it.
        auto start = start_position + direction * current_distance;

        if (!first_contents)
            first_contents = ENGINETRACE->GetPointContents(start, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr);

        const auto point_contents = ENGINETRACE->GetPointContents(start, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr);

        if (!(point_contents & MASK_SHOT_HULL) || point_contents & CONTENTS_HITBOX && point_contents != first_contents)
        {
            //Let's setup our end position by deducting the direction by the extra added distance
            auto end = start - (direction * ray_extension);

            //Let's cast a ray from our start pos to the end pos
            CAutoWall::TraceLine(start, end, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr, &exit_trace);

            //Let's check if a hitbox is in-front of our enemy and if they are behind of a solid wall
            if (exit_trace.startsolid && exit_trace.surface.flags & SURF_HITBOX)
            {
                CAutoWall::TraceLine(start, start_position, MASK_SHOT_HULL, exit_trace.m_pEnt, &exit_trace);

                if (exit_trace.DidHit() && !exit_trace.startsolid)
                    return true;

                continue;
            }

            //Can we hit? Is the wall solid?
            if (exit_trace.DidHit() && !exit_trace.startsolid)
            {
                //Is the wall a breakable? If so, let's shoot through it.
                if (dynamic_cast<C_CSPlayer*>(enter_trace.m_pEnt)->IsBreakableEnt() && (dynamic_cast<C_CSPlayer*>(exit_trace.m_pEnt)->IsBreakableEnt()))
                    return true;

                if (enter_trace.surface.flags & SURF_NODRAW || !(exit_trace.surface.flags & SURF_NODRAW) && (exit_trace.plane.normal.Dot(direction) <= 1.f))
                    return true;

                continue;
            }

            if (!exit_trace.DidHit() || exit_trace.startsolid)
            {
                if (CAutoWall::DidHitNonWorldEntity(enter_trace.m_pEnt) && dynamic_cast<C_CSPlayer*>(enter_trace.m_pEnt)->IsBreakableEnt())
                {
                    exit_trace = enter_trace;
                    exit_trace.endpos = start + direction;
                    return true;
                }
            }
        }
    }
    return false;
}

bool peeking_fakelag_autowall::handle_bullet_penetration(C_CSPlayer* local, const CCSWeaponInfo* weapon_data, CGameTrace& enter_trace, Vector& eye_position, const Vector direction, int& possible_hits_remaining, float& current_damage, const float penetration_power, const bool sv_penetration_type, const float ff_damage_reduction_bullets, const float ff_damage_bullet_penetration) const
{
    trace_t exit_trace;

    const auto target = C_CSPlayer::GetLocalPlayer();

    if (!target)
        return false;

    const auto enter_surface_data = PHYSPROPS->GetSurfaceData(enter_trace.surface.surfaceProps);
    const int enter_material = enter_surface_data->game.material;
    const auto enter_surf_penetration_modifier = enter_surface_data->game.flPenetrationModifier;

    const auto enter_damage_modifier = enter_surface_data->game.flDamageModifier;
    float thickness, final_damage_modifier, combined_penetration_modifier;
    const bool is_solid_surf = ((enter_trace.contents >> 3) & CONTENTS_SOLID);
    const bool is_light_surf = ((enter_trace.surface.flags >> 7) & SURF_LIGHT);

    if (possible_hits_remaining <= 0
        || (!possible_hits_remaining && !is_light_surf && !is_solid_surf && enter_material != CHAR_TEX_GRATE && enter_material != CHAR_TEX_GLASS)
        || weapon_data->flPenetration <= 0.f
        || !trace_to_exit(enter_trace, exit_trace, enter_trace.endpos, direction)
        && !(ENGINETRACE->GetPointContents(enter_trace.endpos, MASK_SHOT_HULL, nullptr) & MASK_SHOT_HULL))
        return false;

    const auto exit_surface_data = PHYSPROPS->GetSurfaceData(exit_trace.surface.surfaceProps);

    if (!exit_surface_data)
        return false;

    const int exit_material = exit_surface_data->game.material;
    const auto exit_surf_penetration_modifier = exit_surface_data->game.flPenetrationModifier;
    const auto exit_damage_modifier = exit_surface_data->game.flDamageModifier;

    //Are we using the newer penetration system?
    if (sv_penetration_type)
    {
        if (enter_material == CHAR_TEX_GRATE || enter_material == CHAR_TEX_GLASS)
        {
            combined_penetration_modifier = 3.f;
            final_damage_modifier = 0.05f;
        }
        else if (is_solid_surf || is_light_surf)
        {
            combined_penetration_modifier = 1.f;
            final_damage_modifier = 0.16f;
        }
        else if (enter_material == CHAR_TEX_FLESH && (local->GetTeam() == target->GetTeam() && ff_damage_reduction_bullets == 0.f))
        {
            //Look's like you aren't shooting through your teammate today
            if (ff_damage_bullet_penetration == 0.f)
                return false;

            //Let's shoot through teammates and get kicked for teamdmg! Whatever, atleast we did damage to the enemy. I call that a win.
            combined_penetration_modifier = ff_damage_bullet_penetration;
            final_damage_modifier = 0.16f;
        }
        else
        {
            combined_penetration_modifier = (enter_surf_penetration_modifier + exit_surf_penetration_modifier) / 2.f;
            final_damage_modifier = 0.16f;
        }

        //Do our materials line up?
        if (enter_material == exit_material)
        {
            if (exit_material == CHAR_TEX_CARDBOARD || exit_material == CHAR_TEX_WOOD)
                combined_penetration_modifier = 3.f;
            else if (exit_material == CHAR_TEX_PLASTIC)
                combined_penetration_modifier = 2.f;
        }

        //Calculate thickness of the wall by getting the length of the range of the trace and squaring
        thickness = (exit_trace.endpos - enter_trace.endpos).LengthSqr();
        const auto modifier = fmaxf(1.f / combined_penetration_modifier, 0.f);

        //This calculates how much damage we've lost depending on thickness of the wall, our penetration, damage, and the modifiers set earlier
        const auto lost_damage = fmaxf(
            ((modifier * thickness) / 24.f)
            + ((current_damage * final_damage_modifier)
                + (fmaxf(3.75f / penetration_power, 0.f) * 3.f * modifier)), 0.f);

        //Did we loose too much damage?
        if (lost_damage > current_damage)
            return false;

        //We can't use any of the damage that we've lost
        if (lost_damage > 0.f)
            current_damage -= lost_damage;

        //Do we still have enough damage to deal?
        if (current_damage < 1.f)
            return false;

        eye_position = exit_trace.endpos;
        --possible_hits_remaining;

        return true;
    }
    //else

    //Legacy penetration system
    combined_penetration_modifier = 1.f;

    if (is_solid_surf || is_light_surf)
        final_damage_modifier = 0.99f; //Good meme :^)
    else
    {
        final_damage_modifier = fminf(enter_damage_modifier, exit_damage_modifier);
        combined_penetration_modifier = fminf(enter_surf_penetration_modifier, exit_surf_penetration_modifier);
    }

    if (enter_material == exit_material && (exit_material == CHAR_TEX_METAL || exit_material == CHAR_TEX_WOOD))
        combined_penetration_modifier += combined_penetration_modifier;

    thickness = (exit_trace.endpos - enter_trace.endpos).LengthSqr();

    if (sqrt(thickness) <= combined_penetration_modifier * penetration_power)
    {
        current_damage *= final_damage_modifier;
        eye_position = exit_trace.endpos;
        --possible_hits_remaining;

        return true;
    }

    return false;
}

bool peeking_fakelag_autowall::fire_bullet(C_CSPlayer* local, CBaseCombatWeapon* weapon, float& max_range, Vector& direction, float& current_damage, int& possible_hits_remaining) const
{
    const auto target = C_CSPlayer::GetLocalPlayer();

    if (!target)
        return false;

    if (!weapon)
        return false;

    static auto util_clip_trace_to_players = [](const Vector& vec_abs_start, const Vector& vec_abs_end, unsigned int mask, ITraceFilter* filter, trace_t* tr)
    {
        static uintptr_t clptrtp = Utils::FindSignature(Utils::get_client_dll(), XorStr("53 8B DC 83 EC ? 83 E4 ? 83 C4 ? 55 8B 6B 04 89 6C 24 ? 8B EC 81 EC ? ? ? ? 8B 43 10 56 57 52 F3 0F 10 40"));

        if (!clptrtp)
            return false;

        __asm {
            push tr
            push filter
            push mask
            lea edx, vec_abs_end
            lea ecx, vec_abs_start
            call clptrtp
            add esp, 0xC
        }
    };

    //      Current bullet travel Power to penetrate Distance to penetrate Range               Player bullet reduction convars              Amount to extend ray by
    float current_distance = 0.f, penetration_power, penetration_distance;
    const auto ray_extension = 40.f;

    auto eye_position = local->GetEyePos();

    //For being superiour when the server owners think your autowall isn't well reversed. Imagine a meme HvH server with the old penetration system- pff
    static auto penetration_system = CVAR->FindVar(XorStr("sv_penetration_type"));
    static auto damage_reduction_bullets = CVAR->FindVar(XorStr("ff_damage_reduction_bullets"));
    static auto damage_bullet_penetration = CVAR->FindVar(XorStr("ff_damage_bullet_penetration"));

    if (!penetration_system || !damage_reduction_bullets || !damage_bullet_penetration)
        return false;

    const auto sv_penetration_type = penetration_system->GetBool();
    const auto ff_damage_reduction_bullets = damage_reduction_bullets->GetFloat();
    const auto ff_damage_bullet_penetration = damage_bullet_penetration->GetFloat();

    const auto weapon_data = weapon->GetCSWpnData();

    if (!weapon_data)
        return false;

    CAutoWall::GetBulletTypeParameters(penetration_power, penetration_distance, weapon_data->szBulletType, sv_penetration_type);

    if (sv_penetration_type)
        penetration_power = weapon_data->flPenetration;

    //This gets set in FX_Firebullets to 4 as a pass-through value.
    //CS:GO has a maximum of 4 surfaces a bullet can pass-through before it 100% stops.
    //Excerpt from Valve: https://steamcommunity.com/sharedfiles/filedetails/?id=275573090
    //"The total number of surfaces any bullet can penetrate in a single flight is capped at 4." -CS:GO Official

    //Set our current damage to what our gun's initial damage reports it will do
    current_damage = weapon_data->iDamage;

    trace_t enter_trace;
    CTraceFilter filter;
    filter.pSkip = local;

    //If our damage is greater than (or equal to) 1, and we can shoot, let's shoot.
    while (possible_hits_remaining > 0 && current_damage >= 1.f)
    {
        max_range -= current_distance; //Calculate max bullet range

        const auto end = eye_position + direction * max_range; //Create endpoint of bullet

        Utils::TraceLine(eye_position, end, MASK_SHOT_HULL | CONTENTS_HITBOX, local, &enter_trace);
        util_clip_trace_to_players(eye_position, end + direction * ray_extension, MASK_SHOT_HULL | CONTENTS_HITBOX, &filter, &enter_trace);

        const auto enter_surface_data = PHYSPROPS->GetSurfaceData(enter_trace.surface.surfaceProps); //We have to do this *after* tracing to the player.

        if (!enter_surface_data)
            return false;

        const auto enter_surf_penetration_modifier = enter_surface_data->game.flPenetrationModifier;

        if (enter_trace.fraction == 1.f || enter_trace.m_pEnt == target) //"Fraction == 1" means that we didn't hit anything. We don't want that- so let's break on it.
        {
            scale_damage(target, weapon_data, current_damage);
            return true;
        }

        //calculate the damage based on the distance the bullet traveled.
        current_distance += enter_trace.fraction * max_range;

        //Let's make our damage drops off the further away the bullet is.
        current_damage *= pow(weapon_data->flRangeModifier, current_distance / 500.f);

        //Sanity checking / Can we actually shoot through?
        if (current_distance > penetration_distance && weapon_data->flPenetration > 0.f || enter_surf_penetration_modifier < 0.1f)
            break;

        //Calling HandleBulletPenetration here reduces our penetrationCounter, and if it returns true, we can't shoot through it.
        if (!handle_bullet_penetration(local, weapon_data, enter_trace, eye_position, direction, possible_hits_remaining, current_damage, penetration_power, sv_penetration_type, ff_damage_reduction_bullets, ff_damage_bullet_penetration))
            break;
    }
    return false;
}

float peeking_fakelag_autowall::can_hit(Vector& end_pos, C_CSPlayer* local) const
{
    if (!local)
        return 0;

    Vector angles, direction;
    const auto tmp = end_pos - local->GetEyePos();

    auto max_range = tmp.Length();

    Math::VectorAngles(tmp, angles);
    Math::AngleVectors(angles, &direction);
    direction.NormalizeInPlace();

    auto current_damage = 0.f;
    auto possible_hits_remaining = 4;
    if (fire_bullet(local, local->GetActiveWeapon(), max_range, direction, current_damage, possible_hits_remaining))
        return current_damage;

    return 0.f; //That wall is just a bit too thick buddy
}

bool fake_lag::adaptive_fl(C_CSPlayer* local, bool& send_packet)
{
    if (!local)
        return false;

    const auto sweet_spot = (g::previous_position - local->GetAbsOrigin()).Length() > 64.f;
    const auto is_moving = local->GetVelocity().Length() > 0 && !(local->GetFlags() & FL_ONGROUND) || INPUTSYSTEM->IsButtonDown(KEY_SPACE) && MiscVars::get().g_bBunnyHop; //local->GetVelocity().Length2D() > 50.f;

    if (!is_moving) //not moving, return false so that we can do our AA
        return false;

    if (!sweet_spot && CLIENTSTATE->net_channel->m_nChokedPackets < MiscVars::get().g_iFakeLagAmount)
        send_packet = false;

    return true;
}

bool fake_lag::static_fl(bool& send_packet)
{
    send_packet = !(CLIENTSTATE->net_channel->m_nChokedPackets < MiscVars::get().g_iFakeLagAmount);

    return true;
}

bool is_valid_target(C_CSPlayer* ent, C_CSPlayer* local)
{
    if (!local)
        return false;
    if (!ent)
        return false;
    if (ent == local)
        return false;
    if (!ent->IsPlayer())
        return false;
    if (g::plist[ent->EntIndex()].corrections.bWhiteListed)
        return false;
    if (!ent->IsAlive())
        return false;
    if (ent->GetTeam() == local->GetTeam())
        return false;
    if (ent->GetTeam() != 2 && ent->GetTeam() != 3)
        return false;
    if (ent->GetGunGameImmunity())
        return false;

    return true;
}

bool fake_lag::peeking_fl(C_CSPlayer* local, bool& send_packet)
{
    /*
     * may be easier to just check if entity can hit head in like 7 ticks
     * make sure we leave enough ticks to stop and become accurate so we can shoot
     * and choke that amount of ticks until aimbot is true or we hit max choked ticks
     */

    static auto in_peeking_fl = false;

    if (!local)
        return false;

    C_CSPlayer* entity = nullptr;

    float best_fov = 999.f;
    for (int i = 0; i < 64; i++)
    {
        if (i == ENGINE->GetLocalPlayer())
            continue;

        const auto p_entity = dynamic_cast<C_CSPlayer*>(ENTITYLIST->GetClientEntity(i));

        if (!is_valid_target(p_entity, local))
            continue;

        const auto fov = Math::GetFov(QAngle(0, Math::CalcAngle(local->GetEyePos(), p_entity->GetEyePos()).y, 0), g::cmd->viewangles);
        if (fov < best_fov)
        {
            entity = p_entity;
            best_fov = fov;
        }
    }

    if (!entity)
        return false;

    const auto extrap_amount = MiscVars::get().g_iFakeLagAmount - CLIENTSTATE->chokedcommands;
    auto pos = Utils::GetHitboxPosition(local, HITBOX_HEAD);
    const auto velocity = local->GetVelocity();
    auto extrapolated_pos = pos + velocity * (GLOBALS->interval_per_tick * extrap_amount);

    const auto extrap_dmg = peeking_fakelag_autowall::get().can_hit(extrapolated_pos, entity);
    const auto dmg = peeking_fakelag_autowall::get().can_hit(pos, entity);

    if ((extrap_dmg && !dmg) || (in_peeking_fl && extrap_dmg)) //if they can hit our extrapolated position but not our current, we need to start lagging
    {
        send_packet = false;
        in_peeking_fl = true;
        return true;
    }

    send_packet = true;
    in_peeking_fl = false;
    return false;
}

bool fake_lag::create_move(bool & send_packet)
{
    const auto local = C_CSPlayer::GetLocalPlayer();

    if (!local)
        return false;

    if (!local->IsAlive())
        return false;

    if (g::b_in_fake_walk)
        return true;

    if (MiscVars::get().g_nFakeLag == FLAG_OFF && !(MiscVars::get().g_bFakeLagOnKey && INPUTSYSTEM->IsButtonDown(MiscVars::get().g_kLagKey)))
        return false;

    if (MiscVars::get().g_bFakeLagOnKey && INPUTSYSTEM->IsButtonDown(MiscVars::get().g_kLagKey))
    {
        if (g::aimbotting)
        {
            send_packet = true;
            return false;
        }

        send_packet = false;
        return true;
    }

    if (MiscVars::get().g_bFakelagOnlyOnMove)
    {
        const auto is_moving = local->GetVelocity().Length() > 10.0f || !(local->GetFlags() & FL_ONGROUND);

        if (!is_moving)
            return false;
    }

    if (MiscVars::get().g_bFakelagOnLand)
    {
        const auto is_moving = local->GetVelocity().Length() > 1.0f && local->GetFlags() & FL_ONGROUND && INPUTSYSTEM->IsButtonDown(KEY_SPACE);

        if (is_moving)
        {
            send_packet = false;
            return true;
        }
    }

    if (CLIENTSTATE->net_channel->m_nChokedPackets >= 15)
        return true;

    if (MiscVars::get().g_nFakeLag == FLAG_NORMAL)
        return static_fl(send_packet);

    if (MiscVars::get().g_nFakeLag == FLAG_ADAPTIVE)
        return adaptive_fl(local, send_packet);

    if (MiscVars::get().g_nFakeLag == FLAG_ONPEEK)
        return peeking_fl(local, send_packet);

    return false;
}
Код:
#include "Autowall.h"
#include "Globals.h"
#include <intrin.h>

bool CAutoWall::DidHitNonWorldEntity(IClientEntity* m_pEnt)
{
    return m_pEnt != nullptr && m_pEnt != ENTITYLIST->GetClientEntity(0);
}

void CAutoWall::TraceLine(Vector& absStart, Vector& absEnd, unsigned int mask, IClientEntity* ignore, CGameTrace* ptr)
{
    Ray_t ray;
    ray.Init(absStart, absEnd);
    CTraceFilter filter;
    filter.pSkip = ignore;

    ENGINETRACE->TraceRay(ray, mask, &filter, ptr);
}

void CAutoWall::ClipTraceToPlayers(Vector& absStart, Vector absEnd, unsigned int mask, ITraceFilter* filter, CGameTrace* tr)
{
    static uintptr_t clptrtp = Utils::FindSignature(Utils::get_client_dll(), XorStr("53 8B DC 83 EC ? 83 E4 ? 83 C4 ? 55 8B 6B 04 89 6C 24 ? 8B EC 81 EC ? ? ? ? 8B 43 10 56 57 52 F3 0F 10 40"));
           
    if (!clptrtp)
        return;

    __asm
    {
        mov eax, filter
        lea ecx, tr
        push ecx
        push eax
        push mask
        lea edx, absEnd
        lea ecx, absStart
        call clptrtp
        add esp, 0xC
    }
}

//Legacy Function
void CAutoWall::GetBulletTypeParameters(float& maxRange, float& maxDistance, char* bulletType, bool sv_penetration_type)
{
    if (sv_penetration_type)
    {
        maxRange = 35.0;
        maxDistance = 3000.0;
    }
    else
    {
        //Play tribune to framerate. Thanks, stringcompare
        //Regardless I doubt anyone will use the old penetration system anyway; so it won't matter much.
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_338MAG")))
        {
            maxRange = 45.0;
            maxDistance = 8000.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_762MM")))
        {
            maxRange = 39.0;
            maxDistance = 5000.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_556MM")) || !strcmp(bulletType, XorStr("BULLET_PLAYER_556MM_SMALL")) || !strcmp(bulletType, XorStr("BULLET_PLAYER_556MM_BOX")))
        {
            maxRange = 35.0;
            maxDistance = 4000.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_57MM")))
        {
            maxRange = 30.0;
            maxDistance = 2000.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_50AE")))
        {
            maxRange = 30.0;
            maxDistance = 1000.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_357SIG")) || !strcmp(bulletType, XorStr("BULLET_PLAYER_357SIG_SMALL")) || !strcmp(bulletType, XorStr("BULLET_PLAYER_357SIG_P250")) || !strcmp(bulletType, XorStr("BULLET_PLAYER_357SIG_MIN")))
        {
            maxRange = 25.0;
            maxDistance = 800.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_9MM")))
        {
            maxRange = 21.0;
            maxDistance = 800.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_45ACP")))
        {
            maxRange = 15.0;
            maxDistance = 500.0;
        }
        if (!strcmp(bulletType, XorStr("BULLET_PLAYER_BUCKSHOT")))
        {
            maxRange = 0.0;
            maxDistance = 0.0;
        }
    }
}

void CAutoWall::scale_damage(CGameTrace& enterTrace, const CCSWeaponInfo* weaponData, float& currentDamage) const
{
    //Cred. to N0xius for reversing this.
    //TODO: _xAE^; look into reversing this yourself sometime

    bool hasHeavyArmor = false;//((C_CSPlayer*)enterTrace.m_pEnt)->HeavyArmor();
    int armorValue = ((C_CSPlayer*)enterTrace.m_pEnt)->GetArmorValue();

    //screw making a new function, lambda beste. ~ Does the person have armor on for the hitbox checked?
    auto IsArmored = [&enterTrace]()->bool
    {
        C_CSPlayer* targetEntity = (C_CSPlayer*)enterTrace.m_pEnt;
        switch (enterTrace.hitgroup)
        {
        case HITGROUP_HEAD:
            return !!(C_CSPlayer*)targetEntity->HasHelmet(); //screw compiler errors - force-convert it to a bool via (!!)
        case HITGROUP_GENERIC:
        case HITGROUP_CHEST:
        case HITGROUP_STOMACH:
        case HITGROUP_LEFTARM:
        case HITGROUP_RIGHTARM:
            return true;
        default:
            return false;
        }
    };

    switch (enterTrace.hitgroup)
    {
    case HITGROUP_HEAD:
        currentDamage *= hasHeavyArmor ? 2.f : 4.f; //Heavy Armor does 1/2 damage
        break;
    case HITGROUP_STOMACH:
        currentDamage *= 1.25f;
        break;
    case HITGROUP_LEFTLEG:
    case HITGROUP_RIGHTLEG:
        currentDamage *= 0.75f;
        break;
    default:
        break;
    }

    if (armorValue > 0 && IsArmored())
    {
        float bonusValue = 1.f, armorBonusRatio = 0.5f, armorRatio = weaponData->flArmorRatio / 2.f;

        //Damage gets modified for heavy armor users
        if (hasHeavyArmor)
        {
            armorBonusRatio = 0.33f;
            armorRatio *= 0.5f;
            bonusValue = 0.33f;
        }

        auto NewDamage = currentDamage * armorRatio;

        if (hasHeavyArmor)
            NewDamage *= 0.85f;

        if (((currentDamage - (currentDamage * armorRatio)) * (bonusValue * armorBonusRatio)) > armorValue)
            NewDamage = currentDamage - (armorValue / armorBonusRatio);

        currentDamage = NewDamage;
    }
}

bool CAutoWall::TraceToExit(CGameTrace& enterTrace, CGameTrace& exitTrace, Vector startPosition, Vector direction)
{
    /*
    Masks used:
    MASK_SHOT_HULL                     = 0x0600400B
    CONTENTS_HITBOX                     = 0x40000000
    MASK_SHOT_HULL | CONTENTS_HITBOX = 0x4600400B
    */

    float maxDistance = 90.f, rayExtension = 4.f, currentDistance = 0;
    int firstContents = 0;

    while (currentDistance <= maxDistance)
    {
        //Add extra distance to our ray
        currentDistance += rayExtension;

        //Multiply the direction vector to the distance so we go outwards, add our position to it.
        Vector start = startPosition + direction * currentDistance;

        if (!firstContents)
            firstContents = ENGINETRACE->GetPointContents(start, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr); /*0x4600400B*/
        int pointContents = ENGINETRACE->GetPointContents(start, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr);

        if (!(pointContents & MASK_SHOT_HULL) || pointContents & CONTENTS_HITBOX && pointContents != firstContents) /*0x600400B, *0x40000000*/
        {
            //Let's setup our end position by deducting the direction by the extra added distance
            Vector end = start - (direction * rayExtension);

            //Let's cast a ray from our start pos to the end pos
            TraceLine(start, end, MASK_SHOT_HULL | CONTENTS_HITBOX, nullptr, &exitTrace);

            //Let's 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)
            {
                TraceLine(start, startPosition, MASK_SHOT_HULL, exitTrace.m_pEnt, &exitTrace);

                if (exitTrace.DidHit() && !exitTrace.startsolid)
                {
                    start = exitTrace.endpos;
                    return true;
                }

                continue;
            }

            //Can we hit? Is the wall solid?
            if (exitTrace.DidHit() && !exitTrace.startsolid)
            {
                //Is the wall a breakable? If so, let's shoot through it.
                if (((C_CSPlayer*)enterTrace.m_pEnt)->IsBreakableEnt() && (((C_CSPlayer*)exitTrace.m_pEnt)->IsBreakableEnt()))
                    return true;

                if (enterTrace.surface.flags & SURF_NODRAW || !(exitTrace.surface.flags & SURF_NODRAW) && (exitTrace.plane.normal.Dot(direction) <= 1.f))
                {
                    float multAmount = exitTrace.fraction * 4.f;
                    start -= direction * multAmount;
                    return true;
                }

                continue;
            }

            if (!exitTrace.DidHit() || exitTrace.startsolid)
            {
                if (DidHitNonWorldEntity(enterTrace.m_pEnt) && ((C_CSPlayer*)enterTrace.m_pEnt)->IsBreakableEnt())
                {
                    exitTrace = enterTrace;
                    exitTrace.endpos = start + direction;
                    return true;
                }

                continue;
            }
        }
    }
    return false;
}

bool CAutoWall::HandleBulletPenetration(C_CSPlayer* pLocal, const CCSWeaponInfo* weaponData, CGameTrace& enterTrace, Vector& eyePosition, Vector direction, int& possibleHitsRemaining, float& currentDamage, float penetrationPower, bool sv_penetration_type, float ff_damage_reduction_bullets, float ff_damage_bullet_penetration) const
{
    trace_t exitTrace;

    C_CSPlayer* pEnemy = (C_CSPlayer*)enterTrace.m_pEnt;

    if (!pEnemy)
        return false;

    surfacedata_t *enterSurfaceData = PHYSPROPS->GetSurfaceData(enterTrace.surface.surfaceProps);
    int enterMaterial = enterSurfaceData->game.material;
    float enterSurfPenetrationModifier = enterSurfaceData->game.flPenetrationModifier;

    float enterDamageModifier = enterSurfaceData->game.flDamageModifier;
    float thickness, finalDamageModifier, combinedPenetrationModifier;
    bool isSolidSurf = ((enterTrace.contents >> 3) & CONTENTS_SOLID);
    bool isLightSurf = ((enterTrace.surface.flags >> 7) & SURF_LIGHT);

    if (possibleHitsRemaining <= 0
        || (!possibleHitsRemaining && !isLightSurf && !isSolidSurf && enterMaterial != CHAR_TEX_GRATE && enterMaterial != CHAR_TEX_GLASS)
        || weaponData->flPenetration <= 0.f
        || !TraceToExit(enterTrace, exitTrace, enterTrace.endpos, direction)
        && !(ENGINETRACE->GetPointContents(enterTrace.endpos, MASK_SHOT_HULL, nullptr) & MASK_SHOT_HULL))
        return false;

    surfacedata_t *exitSurfaceData = PHYSPROPS->GetSurfaceData(exitTrace.surface.surfaceProps);

    if (!exitSurfaceData)
        return false;

    int exitMaterial = exitSurfaceData->game.material;
    float exitSurfPenetrationModifier = exitSurfaceData->game.flPenetrationModifier;
    float exitDamageModifier = exitSurfaceData->game.flDamageModifier;

    //Are we using the newer penetration system?
    if (sv_penetration_type)
    {
        if (enterMaterial == CHAR_TEX_GRATE || enterMaterial == CHAR_TEX_GLASS)
        {
            combinedPenetrationModifier = 3.f;
            finalDamageModifier = 0.05f;
        }
        else if (isSolidSurf || isLightSurf)
        {
            combinedPenetrationModifier = 1.f;
            finalDamageModifier = 0.16f;
        }
        else if (enterMaterial == CHAR_TEX_FLESH && (pLocal->GetTeam() == pEnemy->GetTeam() && ff_damage_reduction_bullets == 0.f))
        {
            //Look's like you aren't shooting through your teammate today
            if (ff_damage_bullet_penetration == 0.f)
                return false;

            //Let's shoot through teammates and get kicked for teamdmg! Whatever, atleast we did damage to the enemy. I call that a win.
            combinedPenetrationModifier = ff_damage_bullet_penetration;
            finalDamageModifier = 0.16f;
        }
        else
        {
            combinedPenetrationModifier = (enterSurfPenetrationModifier + exitSurfPenetrationModifier) / 2.f;
            finalDamageModifier = 0.16f;
        }

        //Do our materials line up?
        if (enterMaterial == exitMaterial)
        {
            if (exitMaterial == CHAR_TEX_CARDBOARD || exitMaterial == CHAR_TEX_WOOD)
                combinedPenetrationModifier = 3.f;
            else if (exitMaterial == CHAR_TEX_PLASTIC)
                combinedPenetrationModifier = 2.f;
        }

        //Calculate thickness of the wall by getting the length of the range of the trace and squaring
        thickness = (exitTrace.endpos - enterTrace.endpos).LengthSqr();
        float modifier = fmaxf(1.f / combinedPenetrationModifier, 0.f);

        //This calculates how much damage we've lost depending on thickness of the wall, our penetration, damage, and the modifiers set earlier
        float lostDamage = fmaxf(
            ((modifier * thickness) / 24.f)
            + ((currentDamage * finalDamageModifier)
                + (fmaxf(3.75f / penetrationPower, 0.f) * 3.f * modifier)), 0.f);

        //Did we loose too much damage?
        if (lostDamage > currentDamage)
            return false;

        //We can't use any of the damage that we've lost
        if (lostDamage > 0.f)
            currentDamage -= lostDamage;

        //Do we still have enough damage to deal?
        if (currentDamage < 1.f)
            return false;

        eyePosition = exitTrace.endpos;
        --possibleHitsRemaining;

        return true;
    }
    else //Legacy penetration system
    {
        combinedPenetrationModifier = 1.f;

        if (isSolidSurf || isLightSurf)
            finalDamageModifier = 0.99f; //Good meme :^)
        else
        {
            finalDamageModifier = fminf(enterDamageModifier, exitDamageModifier);
            combinedPenetrationModifier = fminf(enterSurfPenetrationModifier, exitSurfPenetrationModifier);
        }

        if (enterMaterial == exitMaterial && (exitMaterial == CHAR_TEX_METAL || exitMaterial == CHAR_TEX_WOOD))
            combinedPenetrationModifier += combinedPenetrationModifier;

        thickness = (exitTrace.endpos - enterTrace.endpos).LengthSqr();

        if (sqrt(thickness) <= combinedPenetrationModifier * penetrationPower)
        {
            currentDamage *= finalDamageModifier;
            eyePosition = exitTrace.endpos;
            --possibleHitsRemaining;

            return true;
        }

        return false;
    }
}

bool CAutoWall::FireBullet(C_CSPlayer* pLocal, CBaseCombatWeapon* pWeapon, Vector& direction, float& currentDamage, int& possibleHitsRemaining) const
{
    if (!pWeapon)
        return false;

    static auto UTIL_ClipTraceToPlayers = [](const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, ITraceFilter* filter, trace_t* tr)
    {
        static uintptr_t clptrtp = Utils::FindSignature(Utils::get_client_dll(), XorStr("53 8B DC 83 EC ? 83 E4 ? 83 C4 ? 55 8B 6B 04 89 6C 24 ? 8B EC 81 EC ? ? ? ? 8B 43 10 56 57 52 F3 0F 10 40"));
           
        if (!clptrtp)
            return false;
           
        __asm {
            push tr
            push filter
            push mask
            lea edx, vecAbsEnd
            lea ecx, vecAbsStart
            call clptrtp
            add esp, 0xC
        }
    };

    //      Current bullet travel Power to penetrate Distance to penetrate Range               Player bullet reduction convars              Amount to extend ray by
    float currentDistance = 0.f, penetrationPower, penetrationDistance, rayExtension = 40.f;

    Vector eyePosition = pLocal->GetEyePos();

    //For being superiour when the server owners think your autowall isn't well reversed. Imagine a meme HvH server with the old penetration system- pff
    static ConVar* penetrationSystem = CVAR->FindVar(XorStr("sv_penetration_type"));
    static ConVar* damageReductionBullets = CVAR->FindVar(XorStr("ff_damage_reduction_bullets"));
    static ConVar* damageBulletPenetration = CVAR->FindVar(XorStr("ff_damage_bullet_penetration"));

    if (!penetrationSystem || !damageReductionBullets || !damageBulletPenetration)
        return false;

    bool sv_penetration_type = penetrationSystem->GetBool();
    float ff_damage_reduction_bullets = damageReductionBullets->GetFloat();
    float ff_damage_bullet_penetration = damageBulletPenetration->GetFloat();

    const CCSWeaponInfo* weaponData = pWeapon->GetCSWpnData();
   
    if (!weaponData)
        return false;

    float maxRange = weaponData->flRange;

    GetBulletTypeParameters(penetrationPower, penetrationDistance, weaponData->szBulletType, sv_penetration_type);

    if (sv_penetration_type)
        penetrationPower = weaponData->flPenetration;

    //This gets set in FX_Firebullets to 4 as a pass-through value.
    //CS:GO has a maximum of 4 surfaces a bullet can pass-through before it 100% stops.
    //Excerpt from Valve: https://steamcommunity.com/sharedfiles/filedetails/?id=275573090
    //"The total number of surfaces any bullet can penetrate in a single flight is capped at 4." -CS:GO Official

    //Set our current damage to what our gun's initial damage reports it will do
    currentDamage = weaponData->iDamage;

    trace_t enterTrace;
    CTraceFilter filter;
    filter.pSkip = pLocal;

    //If our damage is greater than (or equal to) 1, and we can shoot, let's shoot.
    while (possibleHitsRemaining > 0 && currentDamage >= 1.f)
    {
        //Calculate max bullet range
        maxRange -= currentDistance;

        //Create endpoint of bullet
        Vector end = eyePosition + direction * maxRange;

        Utils::TraceLine(eyePosition, end, MASK_SHOT_HULL | CONTENTS_HITBOX, pLocal, &enterTrace);
        UTIL_ClipTraceToPlayers(eyePosition, end + direction * rayExtension, MASK_SHOT_HULL | CONTENTS_HITBOX, &filter, &enterTrace);

        //We have to do this *after* tracing to the player.
        surfacedata_t* enterSurfaceData = PHYSPROPS->GetSurfaceData(enterTrace.surface.surfaceProps);

        if (!enterSurfaceData)
            return false;

        float enterSurfPenetrationModifier = enterSurfaceData->game.flPenetrationModifier;
        int enterMaterial = enterSurfaceData->game.material;

        //"Fraction == 1" means that we didn't hit anything. We don't want that- so let's break on it.
        if (enterTrace.fraction == 1.f)
            break;

        //calculate the damage based on the distance the bullet traveled.
        currentDistance += enterTrace.fraction * maxRange;

        //Let's make our damage drops off the further away the bullet is.
        currentDamage *= pow(weaponData->flRangeModifier, (currentDistance / 500.f));

        //Sanity checking / Can we actually shoot through?
        if (currentDistance > penetrationDistance && weaponData->flPenetration > 0.f || enterSurfPenetrationModifier < 0.1f)
            break;

        //This looks dumb if we put it into 1 long line of code.
        bool canDoDamage = (enterTrace.hitgroup != HITGROUP_GEAR && enterTrace.hitgroup != HITGROUP_GENERIC);
        bool isPlayer = ((enterTrace.m_pEnt)->GetClientClass()->m_ClassID == CCSPlayer);
        bool isEnemy = (((C_CSPlayer*)pLocal)->GetTeam() != ((C_CSPlayer*)enterTrace.m_pEnt)->GetTeam());
        bool onTeam = (((C_CSPlayer*)enterTrace.m_pEnt)->GetTeam() == 3 || ((C_CSPlayer*)enterTrace.m_pEnt)->GetTeam() == 2);

        //TODO: Team check config
        if (canDoDamage && isPlayer && isEnemy && onTeam)
        {
            scale_damage(enterTrace, weaponData, currentDamage);
            return true;
        }

        //Calling HandleBulletPenetration here reduces our penetrationCounter, and if it returns true, we can't shoot through it.
        if (!HandleBulletPenetration(pLocal, weaponData, enterTrace, eyePosition, direction, possibleHitsRemaining, currentDamage, penetrationPower, sv_penetration_type, ff_damage_reduction_bullets, ff_damage_bullet_penetration))
            break;
    }
    return false;
}

float CAutoWall::can_hit(Vector &point, C_CSPlayer* pLocal) const
{
    if (!pLocal)
        return 0;

    Vector angles, direction;
    Vector tmp = point - pLocal->GetEyePos();
   
    Math::VectorAngles(tmp, angles);
    Math::AngleVectors(angles, &direction);
    direction.NormalizeInPlace();

    float currentDamage = 0.f;
    int possibleHitsRemaining = 4;
    if (FireBullet(pLocal, pLocal->GetActiveWeapon(), direction, currentDamage, possibleHitsRemaining))
    {
        if (possibleHitsRemaining < 4 && !WeaponConfigVars::get().WeaponConfig[g::weaponconfig].ragebot.g_bAutoWall)
            return 0.f;

        return currentDamage;
    }

    return 0.f; //That wall is just a bit too thick buddy
}
 

Вложения

Сверху Снизу