Вопрос Half life nl unload

Начинающий
Статус
Оффлайн
Регистрация
2 Июн 2020
Сообщения
36
Реакции[?]
2
Поинты[?]
0
когда стоит бомба луа вырубается чё делать
Код:
--[[ @region: script information
    * @ Half-life.technologies.
    * @ Created by peluchar
    * @ cracked by soru#3228 [Owned]
    * @ Version:  [dev].
    * @ Last update: 16.03.2022.
-- @endregion ]]

--[[ @region: prayers for good code!
    * Rahman ve rahim olan Allah'ın adıyla!
    * Dünyada herkesi, ahirette sadece mü'minleri rahmetine alan Allah adına.

    * C Nuestro que estas en la Memoria,
    * Compilado sea tu código,
    * venga a nosotros tu software,
    * carguense tus punteros.
    * así en la RAM como en el Disco Duro,
    * Danos hoy nuestro Array de cada día,
    * Perdona nuestros Warnings,
    * así como nosotros también los eliminamos,
    * no nos dejes caer en Bucles,
    * y libranos del Windows, Enter.

    * Избавь нас от Юзера глупого, ибо продвинут он стал и имя ему БУХ.
    * Выправи программы наши кривые, ибо клинит башни нам от конфигураторов и отладчиков.
    * Открой нам знание, ибо истинно говоришь Ты нам, где тру и фолс.
    * Откомментируй код наш многомегабайтный, ибо погрязли мы в MD-шниках своих.
-- @endregion
]]

--[[ @region: notes about updates and other stuff
    * Optimize enemy checking and thats all.
-- @endregion ]]

--- @region: all math & vector * other operations
local math = {
    abs = math.abs, ceil = math.ceil, cos = math.cos, deg = math.deg, floor = math.floor, huge = math.huge, max = math.max, min = math.min, pi = math.pi,
    modf = math.modf, rad = math.rad, pow = math.pow, random = math.random, sin = math.sin, sqrt = math.sqrt, acos = math.acos, atan = math.atan,
    atan2 = math.atan2, log = math.log, fmod = math.fmod, exp = math.exp,

    round = function(number)
        return number >= 0 and math.floor(number + 0.5) or math.ceil(number - 0.5)
    end,

    clamp = function(number, minimal, maximal)
        return number < minimal and minimal or number > maximal and maximal or number
    end,

    lerp = function(start, vend, time)
        return start + (vend - start) * time
    end,

    world_to_screen = function(x_position, y_position)
        if x_position == 0 and y_position == 0 then
            return 0
        end

        local atan_position = math.atan2(y_position, x_position)
        local deg_position = math.deg(atan_position)

        return deg_position
    end,

    calculate_angles = function(self, source, destination)
        local delta_of_vectors = destination - source
        local hyp = math.sqrt(delta_of_vectors.x * delta_of_vectors.x + delta_of_vectors.y * delta_of_vectors.y)
    
        local yaw = self.world_to_screen(delta_of_vectors.x, delta_of_vectors.y)
        local pitch = self.world_to_screen(hyp, -delta_of_vectors.z)
    
        return QAngle.new(pitch, yaw, 0)
    end,

    closest_point_on_ray = function(start_point, final_point, desired_point)
        local to = desired_point - start_point
        local direction = final_point - start_point
        local ray_length = direction:Length()
    
        direction.x = direction.x / ray_length
        direction.y = direction.y / ray_length
        direction.z = direction.z / ray_length
    
        local direction_along = direction.x * to.x + direction.y * to.y + direction.z * to.z
        if direction_along < 0 then return start_point end
        if direction_along > ray_length then return final_point end
    
        local final_vector = Vector.new(
            start_point.x + direction.x * direction_along,
            start_point.y + direction.y * direction_along,
            start_point.z + direction.z * direction_along
        )

        return final_vector
    end,

    normalize = function(value)
        while value > 180.0 do
            value = value - 360.0
        end

        while value < -180.0 do
            value = value + 360.0
        end

        return value
    end
}

local bit = {
    band = bit.band,
    lshift = bit.lshift,
    rshift = bit.rshift,
    bor = bit.bor,
    bnot = bit.bnot
}

local ffi = require("ffi")
local ffi = {
    C = ffi.C,
    cdef = ffi.cdef,
    cast = ffi.cast,
    typeof = ffi.typeof,
    sizeof = ffi.sizeof,
    new = ffi.new,
    load = ffi.load,
    string = ffi.string,
    copy = ffi.copy
}

local Utils = {
    CreateInterface = Utils.CreateInterface,
    RandomFloat = Utils.RandomFloat,
    PatternScan = Utils.PatternScan,
    UnixTime = Utils.UnixTime
}

local table = {
    concat = table.concat,
    insert = function(tbl, value)
        tbl[#tbl + 1] = value
    end,

    remove = table.remove,
    sort = table.sort
}

local string = {
    char = string.char,
    upper = string.upper,
    format = string.format
}

local Color = {
    RGBA = Color.RGBA,
    new = Color.new
}

local EngineClient = {
    GetScreenSize = EngineClient.GetScreenSize,
    ExecuteClientCmd = EngineClient.ExecuteClientCmd,
    GetLocalPlayer = EngineClient.GetLocalPlayer,
    IsInGame = EngineClient.IsInGame,
    IsConnected = EngineClient.IsConnected,
    GetViewAngles = EngineClient.GetViewAngles,
    GetNetChannelInfo = EngineClient.GetNetChannelInfo
}

local EngineTrace = {
    TraceRay = EngineTrace.TraceRay
}

local ClientState = {
    m_choked_commands = function()
        return ClientState.m_choked_commands
    end
}

local AntiAim = {
    GetInverterState = AntiAim.GetInverterState,
    OverrideYawOffset = AntiAim.OverrideYawOffset,
    OverrideInverter = AntiAim.OverrideInverter,
    OverrideLimit = AntiAim.OverrideLimit,
    OverrideDesyncOnShot = AntiAim.OverrideDesyncOnShot,
    OverridePitch = AntiAim.OverridePitch,
    GetCurrentRealRotation = AntiAim.GetCurrentRealRotation,
    GetMinDesyncDelta = AntiAim.GetMinDesyncDelta,
    GetMaxDesyncDelta = AntiAim.GetMaxDesyncDelta
}

local EntityList = {
    GetClientEntity = EntityList.GetClientEntity,
    GetPlayer = EntityList.GetPlayer,
    GetPlayerResource = EntityList.GetPlayerResource,
    GetEntitiesByName = EntityList.GetEntitiesByName,
    GetPlayerForUserID = EntityList.GetPlayerForUserID,
    GetPlayers = EntityList.GetPlayers,
    GetLocalPlayer = EntityList.GetLocalPlayer,
    GetEntitiesByClassID = EntityList.GetEntitiesByClassID
}

local Panorama = {
    Open = Panorama.Open,
    LoadString = Panorama.LoadString
}

local Vector = {
    new = Vector.new
}

local Vector2 = {
    new = Vector2.new
}

local Http = {
    GetAsync = Http.GetAsync
}

local Render = {
    InitFont = Render.InitFont,
    Text = Render.Text,
    BoxFilled = Render.BoxFilled,
    GradientBoxFilled = Render.GradientBoxFilled,
    CalcTextSize = Render.CalcTextSize,
    WorldToScreen = Render.WorldToScreen,
    GetMenuPos = Render.GetMenuPos,
    GetMenuSize = Render.GetMenuSize,
    CircleFilled = Render.CircleFilled,
    Line = Render.Line,
    PolyFilled = Render.PolyFilled,
    Circle = Render.Circle,
    Circle3DFilled = Render.Circle3DFilled,
    Box = Render.Box,
    Blur = Render.Blur
}

local QAngle = {
    new = QAngle.new
}

local RageBot = {
    OverrideHitchance = RageBot.OverrideHitchance,
    ForceHitboxSafety = RageBot.ForceHitboxSafety,
    EnableHitbox = RageBot.EnableHitbox,
    ForceSafety = RageBot.ForceSafety,
    SetTargetPriority = RageBot.SetTargetPriority,
    OverrideMinDamage = RageBot.OverrideMinDamage,
    SetHitboxPriority = RageBot.SetHitboxPriority,
    EnableMultipoints = RageBot.EnableMultipoints
}

local Cheat = {
    GetCheatUserName = Cheat.GetCheatUserName,
    AddNotify = Cheat.AddNotify,
    RegisterCallback = Cheat.RegisterCallback,
    GetBinds = Cheat.GetBinds,
    FireBullet = Cheat.FireBullet,
    VectorToAngle = Cheat.VectorToAngle,
    AngleToForward = Cheat.AngleToForward,
    SetThirdPersonAnim = Cheat.SetThirdPersonAnim,
    IsMenuVisible = Cheat.IsMenuVisible,
    GetMousePos = Cheat.GetMousePos,
    IsKeyDown = Cheat.IsKeyDown
}

local Menu = {
    Text = Menu.Text,
    Button = Menu.Button,
    Switch = Menu.Switch,
    Combo = Menu.Combo,
    MultiCombo = Menu.MultiCombo,
    SliderInt = Menu.SliderInt,
    DestroyItem = Menu.DestroyItem,
    FindVar = Menu.FindVar,
    SliderFloat = Menu.SliderFloat,
    Hotkey = Menu.Hotkey,
    ColorEdit = Menu.ColorEdit,
    SwitchColor = Menu.SwitchColor
}

local Exploits = {
    ForceTeleport = Exploits.ForceTeleport,
    OverrideDoubleTapSpeed = Exploits.OverrideDoubleTapSpeed,
    GetCharge = function()
        return Exploits.GetCharge()
    end,

    ForceCharge = Exploits.ForceCharge
}

local CVar = {
    FindVar = CVar.FindVar
}

local GlobalVars = {
    tickcount = function()
        return GlobalVars.tickcount
    end,

    realtime = function()
        return GlobalVars.realtime
    end,

    curtime = function()
        return GlobalVars.curtime
    end,

    interval_per_tick = function()
        return GlobalVars.interval_per_tick
    end,

    frametime = function()
        return GlobalVars.frametime
    end
}

local tostring, print, type, pairs, ipairs, unpack, pcall, error, tonumber = tostring, print, type, pairs, ipairs, unpack, pcall, error, tonumber
local screen_size = EngineClient.GetScreenSize()
--- @endregion

--- @region: ffi handlers
ffi.cdef[[
    typedef struct
    {
        uint8_t r;
        uint8_t g;
        uint8_t b;
        uint8_t a;
    } uint_colors_t;

    typedef void (__cdecl* console_color_print)(void*, const uint_colors_t&, const char*, ...);
    typedef uintptr_t (__thiscall* GetClientEntity_4242425_t)(void*, int);

    void* GetProcAddress(void* hModule, const char* lpProcName);
    void* GetModuleHandleA(const char* lpModuleName);

    bool PathFileExistsA(const char* pszPath);
    bool CreateDirectoryA(const char* lpPathName, void* lpSecurityAttributes);
    bool DeleteUrlCacheEntryA(const char* lpszUrlName);
    void* __stdcall URLDownloadToFileA(void* LPUNKNOWN, const char* LPCSTR, const char* LPCSTR2, int a, int LPBINDSTATUSCALLBACK);

    int VirtualProtect(void* lpAddress, unsigned long dwSize, unsigned long flNewProtect, unsigned long* lpflOldProtect);
    void* VirtualAlloc(void* lpAddress, unsigned long dwSize, unsigned long  flAllocationType, unsigned long flProtect);
    int VirtualFree(void* lpAddress, unsigned long dwSize, unsigned long dwFreeType);

    typedef struct
    {
        float x;
        float y;
        float z;
    } Vector_t;

    typedef struct
    {
        char    pad0[0x60]; // 0x00
        void* pEntity; // 0x60
        void* pActiveWeapon; // 0x64
        void* pLastActiveWeapon; // 0x68
        float        flLastUpdateTime; // 0x6C
        int            iLastUpdateFrame; // 0x70
        float        flLastUpdateIncrement; // 0x74
        float        flEyeYaw; // 0x78
        float        flEyePitch; // 0x7C
        float        flGoalFeetYaw; // 0x80
        float        flLastFeetYaw; // 0x84
        float        flMoveYaw; // 0x88
        float        flLastMoveYaw; // 0x8C // changes when moving/jumping/hitting ground
        float        flLeanAmount; // 0x90
        char    pad1[0x4]; // 0x94
        float        flFeetCycle; // 0x98 0 to 1
        float        flMoveWeight; // 0x9C 0 to 1
        float        flMoveWeightSmoothed; // 0xA0
        float        flDuckAmount; // 0xA4
        float        flHitGroundCycle; // 0xA8
        float        flRecrouchWeight; // 0xAC
        Vector_t        vecOrigin; // 0xB0
        Vector_t        vecLastOrigin;// 0xBC
        Vector_t        vecVelocity; // 0xC8
        Vector_t        vecVelocityNormalized; // 0xD4
        Vector_t        vecVelocityNormalizedNonZero; // 0xE0
        float        flVelocityLenght2D; // 0xEC
        float        flJumpFallVelocity; // 0xF0
        float        flSpeedNormalized; // 0xF4 // clamped velocity from 0 to 1
        float        flRunningSpeed; // 0xF8
        float        flDuckingSpeed; // 0xFC
        float        flDurationMoving; // 0x100
        float        flDurationStill; // 0x104
        bool        bOnGround; // 0x108
        bool        bHitGroundAnimation; // 0x109
        char    pad2[0x2]; // 0x10A
        float        flNextLowerBodyYawUpdateTime; // 0x10C
        float        flDurationInAir; // 0x110
        float        flLeftGroundHeight; // 0x114
        float        flHitGroundWeight; // 0x118 // from 0 to 1, is 1 when standing
        float        flWalkToRunTransition; // 0x11C // from 0 to 1, doesnt change when walking or crouching, only running
        char    pad3[0x4]; // 0x120
        float        flAffectedFraction; // 0x124 // affected while jumping and running, or when just jumping, 0 to 1
        char    pad4[0x208]; // 0x128
        float        flMinBodyYaw; // 0x330
        float        flMaxBodyYaw; // 0x334
        float        flMinPitch; //0x338
        float        flMaxPitch; // 0x33C
        int            iAnimsetVersion; // 0x340
    } CCSGOPlayerAnimationState_534535_t;
]]

local ffi_functions = {}

ffi_functions.interface_type = ffi.typeof("uintptr_t**")
ffi_functions.bind_argument = function(r_function, arg)
    return function(...)
        return r_function(arg, ...)
    end
end

ffi_functions.engine_cvars = Utils.CreateInterface("vstdlib.dll", "VEngineCvar007")
ffi_functions.cvar_interface = ffi.cast(ffi_functions.interface_type, ffi_functions.engine_cvars)
ffi_functions.color_print = ffi.cast("console_color_print", ffi_functions.cvar_interface[0][25])

local color_print = function(text, color)
    local new_color = ffi.new("uint_colors_t")
    local rgba_table = {"r", "g", "b", "a"}

    for index, current_color in ipairs(rgba_table) do
        new_color[current_color] = color[current_color] * 255
    end
    
    local stringed_text = tostring(text)
    ffi_functions.color_print(ffi_functions.cvar_interface, new_color, stringed_text)
end

ffi_functions.client_entity_list = Utils.CreateInterface("client.dll", "VClientEntityList003")
ffi_functions.entity_list_pointer = ffi.cast("void***", ffi_functions.client_entity_list)

ffi_functions.get_client_entity_fn = ffi.cast("GetClientEntity_4242425_t", ffi_functions.entity_list_pointer[0][3])
ffi_functions.get_entity_address = function(ent_index)
    local addr = ffi_functions.get_client_entity_fn(ffi_functions.entity_list_pointer, ent_index)
    return addr
end

ffi_functions.open_link = function(link)
    local panorama_handle = Panorama.Open()
    local steam_overlay_API = panorama_handle.SteamOverlayAPI
    local open_external_browser_url = steam_overlay_API.OpenExternalBrowserURL
    
    open_external_browser_url(link)
end

ffi_functions.create_directory = function(path)
    ffi.C.CreateDirectoryA(path, nil)
end

ffi_functions.download_file = function(path, link)
    local url_mon = ffi.load("UrlMon")
    local shl_win_api = ffi.load("SHLWApi")
    local win_internet = ffi.load("WinInet")

    local create_directory = ffi_functions.create_directory
    if not shl_win_api.PathFileExistsA("nl\\half-life") then
        create_directory("nl\\half-life")
    end

    if not shl_win_api.PathFileExistsA("nl\\half-life\\fonts") then
        create_directory("nl\\half-life\\fonts")
    end

    local is_smallest_pixel_font_exists = shl_win_api.PathFileExistsA("nl\\half-life\\fonts\\smallest-pixel-7.ttf")
    if not is_smallest_pixel_font_exists then
        win_internet.DeleteUrlCacheEntryA(link)
        url_mon.URLDownloadToFileA(nil, link, path, 0, 0)
    end

    local is_acta_symbols_w95_font_exists = shl_win_api.PathFileExistsA("nl\\half-life\\fonts\\acta-symbols-w95.ttf")
    if not is_acta_symbols_w95_font_exists then
        win_internet.DeleteUrlCacheEntryA(link)
        url_mon.URLDownloadToFileA(nil, link, path, 0, 0)
    end
end

local hook_helpers = {
    copy = function(dst, src, len)
        return ffi.copy(ffi.cast('void*', dst), ffi.cast('const void*', src), len)
    end,
    
    virtual_protect = function(lpAddress, dwSize, flNewProtect, lpflOldProtect)
        return ffi.C.VirtualProtect(ffi.cast('void*', lpAddress), dwSize, flNewProtect, lpflOldProtect)
    end,
    
    virtual_alloc = function(lpAddress, dwSize, flAllocationType, flProtect, blFree)
        local alloc = ffi.C.VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect)
        if blFree then
            table.insert(buff.free, function()
                ffi.C.VirtualFree(alloc, 0, 0x8000)
            end)
        end
        return ffi.cast('intptr_t', alloc)
    end
}

local buff = {free = {}}
local vmt_hook = {hooks = {}}

function vmt_hook.new(vt)
    local new_hook = {}
    local org_func = {}
    local old_prot = ffi.new('unsigned long[1]')
    local virtual_table = ffi.cast('intptr_t**', vt)[0]

    new_hook.this = virtual_table
    new_hook.hookMethod = function(cast, func, method)
        org_func[method] = virtual_table[method]
        hook_helpers.virtual_protect(virtual_table + method, 4, 0x4, old_prot)

        virtual_table[method] = ffi.cast('intptr_t', ffi.cast(cast, func))
        hook_helpers.virtual_protect(virtual_table + method, 4, old_prot[0], old_prot)

        return ffi.cast(cast, org_func[method])
    end

    new_hook.unHookMethod = function(method)
        hook_helpers.virtual_protect(virtual_table + method, 4, 0x4, old_prot)
        local alloc_addr = hook_helpers.virtual_alloc(nil, 5, 0x1000, 0x40, false)
        local trampoline_bytes = ffi.new('uint8_t[?]', 5, 0x90)

        trampoline_bytes[0] = 0xE9
        ffi.cast('int32_t*', trampoline_bytes + 1)[0] = org_func[method] - tonumber(alloc_addr) - 5

        hook_helpers.copy(alloc_addr, trampoline_bytes, 5)
        virtual_table[method] = ffi.cast('intptr_t', alloc_addr)

        hook_helpers.virtual_protect(virtual_table + method, 4, old_prot[0], old_prot)
        org_func[method] = nil
    end

    new_hook.unHookAll = function()
        for method, func in pairs(org_func) do
            new_hook.unHookMethod(method)
        end
    end

    table.insert(vmt_hook.hooks, new_hook.unHookAll)
    return new_hook
end

ffi_functions.vgui_system = ffi.cast(ffi_functions.interface_type, Utils.CreateInterface("vgui2.dll", "VGUI_System010"))
ffi_functions.get_clipboard_text_count = ffi_functions.bind_argument(ffi.cast("int(__thiscall*)(void*)", ffi_functions.vgui_system[0][7]), ffi_functions.vgui_system)
ffi_functions.set_clipboard_text = ffi_functions.bind_argument(ffi.cast("void(__thiscall*)(void*, const char*, int)", ffi_functions.vgui_system[0][9]), ffi_functions.vgui_system)
ffi_functions.get_clipboard_text_fn = ffi_functions.bind_argument(ffi.cast("void(__thiscall*)(void*, int, const char*, int)", ffi_functions.vgui_system[0][11]), ffi_functions.vgui_system)
ffi_functions.get_clipboard_text = function()
    local clipboard_text_length = ffi_functions.get_clipboard_text_count()
    if clipboard_text_length > 0 then
        local buffer = ffi.new("char[?]", clipboard_text_length)
        local size = clipboard_text_length * ffi.sizeof("char[?]", clipboard_text_length)
    
        ffi_functions.get_clipboard_text_fn(0, buffer, size )
        return ffi.string( buffer, clipboard_text_length-1)
    end
    return ""
end
--- @endregion

--- @region: custom debugger & maybe future custom error callbacks
local custom_printer = function(...)
    local data = {...}
    local current_table_with_strings = {}

    if #data == 0 then
        current_table_with_strings[#current_table_with_strings + 1] = "No values selected to debug."
    else
        for index = 1, #data do
            local current_element = data[index]
            if type(current_element) == "function" then
                current_table_with_strings[index] = ("function %s: %s"):format(
                    (tostring(current_element)):gsub("function: ", ""), current_element() or "nil"
                )
            elseif type(current_element) == "table" then
                for additional_elements = 1, #current_element do
                    if type(current_element[additional_elements]) == "function" then
                        current_element[additional_elements] = ("function %s: %s"):format(
                            (tostring(current_element[additional_elements])):gsub("function: ", ""), current_element[additional_elements]() or "nil"
                        )
                    elseif type(current_element[additional_elements]) == "string" then
                        current_element[additional_elements] = ("\"%s\""):format(current_element[additional_elements])
                    else
                        current_element[additional_elements] = tostring(current_element[additional_elements])
                    end
                end

                current_table_with_strings[index] = ("{%s}"):format(table.concat(current_element, ", "))
            else
                current_table_with_strings[index] = tostring(current_element)
            end
        end
    end

    color_print("[Half-life.lua debugger] ", Color.RGBA(247, 132, 207, 255))
    print(table.concat(current_table_with_strings, " | "))
end

local default_print = print
local print = custom_printer
--- @endregion

--- @region: menu elements
local menu_database = {}
menu_database.elements = {}
menu_database.references = {}

menu_database.update_elements = function()
    for _, current_element in pairs(menu_database.references) do
        if current_element.condition ~= nil then
            current_element.reference:SetVisible(current_element.condition())
        end
    end
end

menu_database.add_element = function(is_color, callback_name, directory, condition)
    menu_database.references[callback_name] = {
        is_color = is_color, -- # For configs!
        reference = directory,
        name = callback_name,
        condition = condition
    }

    local on_touch_callback = function(new_value)
        menu_database.elements[callback_name] = new_value
        menu_database.update_elements()
    end

    on_touch_callback(directory:Get())
    directory:RegisterCallback(on_touch_callback)
end

menu_database.set_value = function(element_name, value)
    local execute_callbacks = function()
        menu_database.elements[element_name] = value
        menu_database.update_elements()
    end

    execute_callbacks()
    menu_database.references[element_name].reference:Set(value)
end

local add_element = menu_database.add_element
local set_value = menu_database.set_value
--- @endregion

--- @region: bind system
local bind_system = {}
bind_system.list_of_directories = {
    ["Double Tap"] = Menu.FindVar("Aimbot", "Ragebot", "Exploits", "Double Tap"),
    ["Hide Shots"] = Menu.FindVar("Aimbot", "Ragebot", "Exploits", "Hide Shots"),
    ["Auto Peek"] = Menu.FindVar("Miscellaneous", "Main", "Movement", "Auto Peek"),
    ["Slow Walk"] = Menu.FindVar("Aimbot", "Anti Aim", "Misc", "Slow Walk"),
    ["Fake Duck"] = Menu.FindVar("Aimbot", "Anti Aim", "Misc", "Fake Duck"),
    ["Yaw Base"] = Menu.FindVar("Aimbot", "Anti Aim", "Main", "Yaw Base"),
    ["Enable Thirdperson"] = Menu.FindVar("Visuals", "View", "Thirdperson", "Enable Thirdperson"),

    default_hitchance = Menu.FindVar("Aimbot", "Ragebot", "Accuracy", "Hit Chance"),
    default_damage = Menu.FindVar("Aimbot", "Ragebot", "Accuracy", "Minimum Damage"),

    fakelag_value = Menu.FindVar("Aimbot", "Anti Aim", "Fake Lag", "Limit"),
    auto_strafe = Menu.FindVar("Miscellaneous", "Main", "Movement", "Auto Strafe"),
    smoothing = Menu.FindVar("Miscellaneous", "Main", "Movement", "Smoothing"),

    anti_aim = {
        yaw_add = Menu.FindVar("Aimbot", "Anti Aim", "Main", "Yaw Add"),
        yaw_modifier = Menu.FindVar("Aimbot", "Anti Aim", "Main", "Yaw Modifier"),
        modifier_degree = Menu.FindVar("Aimbot", "Anti Aim", "Main", "Modifier Degree"),

        left_limit = Menu.FindVar("Aimbot", "Anti Aim", "Fake Angle", "Left Limit"),
        right_limit = Menu.FindVar("Aimbot", "Anti Aim", "Fake Angle", "Right Limit"),

        fake_options = Menu.FindVar("Aimbot", "Anti Aim", "Fake Angle", "Fake Options"),
        lby_mode = Menu.FindVar("Aimbot", "Anti Aim", "Fake Angle", "LBY Mode"),
        freestand_desync = Menu.FindVar("Aimbot", "Anti Aim", "Fake Angle", "Freestanding Desync"),
        desync_on_shot = Menu.FindVar("Aimbot", "Anti Aim", "Fake Angle", "Desync On Shot")
    },

    remove_scope = Menu.FindVar("Visuals", "View", "Camera", "Remove Scope"),
    leg_movement = Menu.FindVar("Aimbot", "Anti Aim", "Misc", "Leg Movement")
}

bind_system.get_bind = function(bind_name)
    local binds = Cheat.GetBinds()
    local bind_information = {state = false, value = 0}

    for bind = 1, #binds do
        local current_bind = binds[bind]
        local is_active = current_bind:IsActive()

        if is_active then
            local get_bind_name = current_bind:GetName()
            local get_bind_value = current_bind:GetValue()

            if bind_name == get_bind_name then
                bind_information = {state = true, value = get_bind_value}
            end
        end
    end

    if not bind_information.state then
        local default_directory = bind_system.list_of_directories
        local default_value = default_directory[bind_name]

        if default_value ~= nil then
            bind_information = {state = default_value:Get(), value = default_value:Get()}
        end
    end

    return bind_information
end

local get_bind = bind_system.get_bind
--- @endregion

--- @region: create callback system
local callback_system = {}
callback_system.update = function()
    local cached_system = callback_system
    for callback_index = 1, #cached_system do
        local current_callback = callback_system[callback_index]
        local function_in_callbacks = current_callback.functions
        local callback_in_callbacks_index = current_callback.callback

        local update_callbacks = function(...)
            for function_index = 1, #function_in_callbacks do
                local current_function = function_in_callbacks[function_index]
                local function_in_current_index = current_function.r_function

                local function_name_in_current_index = current_function.name
                local succesfull, error_message = pcall(function_in_current_index, ...)

                if not succesfull then
                    local all_error_messages = {
                        "Something went wrong! Send that error in our discord server or dm strexxter#1234!",
                        ("Function information: name - %s; callback - %s, address - %s, status: %sx!"):format(
                            function_name_in_current_index, callback_in_callbacks_index, function_in_current_index, GlobalVars.tickcount() % 10
                        ), ("Error message - %s!"):format(error_message)
                    }

                    for error = 1, #all_error_messages do
                        local current_error_mesage = all_error_messages[error]
                        print(current_error_mesage)
                    end

                    local error_field = "Callback controller immediately terminated the script to avoid game crashes in \"callback_system.update\" section!"
                    error(error_field)
                end
            end
        end

        local current_callback_in_callback_index = current_callback.callback
        Cheat.RegisterCallback(current_callback_in_callback_index, update_callbacks)
    end
end

callback_system.register = function(callback, name, r_function)
    local is_callback_exists = false
    for callback_index = 1, #callback_system do
        local current_callback = callback_system[callback_index]
        local callback_name = current_callback.callback

        if callback_name == callback then
            is_callback_exists = true
            break
        end
    end

    if not is_callback_exists then
        table.insert(callback_system, {callback = callback, functions = {}})
        is_callback_exists = true
    end
    
    for callback_index = 1, #callback_system do
        local current_callback = callback_system[callback_index]
        local callback_name = current_callback.callback

        if callback_name == callback then
            table.insert(current_callback.functions, {r_function = r_function, name = name})
            break
        end
    end

    callback_system.update()
    return true
end
--- @endregion

--- @region: self & other player helpers
local is_local_player_valid = function()
    local local_player = EngineClient.GetLocalPlayer()
    if not local_player then return false, nil end

    local local_player_entity = EntityList.GetClientEntity(local_player)
    if not local_player_entity then return false, nil end
    
    local my_index = local_player_entity:GetPlayer()
    if not my_index then return false, nil end

    if not EngineClient.IsInGame() and not EngineClient.IsConnected() then return false, nil end
    if not my_index:IsAlive() then return false, nil end

    return true, my_index
end

function C_BaseEntity:GetOrigin()
    if self ~= nil then
        return self:GetProp("m_vecOrigin")
    end
end

function C_BaseEntity:GetHealth()
    if self ~= nil then
        return self:GetProp("m_iHealth")
    end
end

function C_BaseEntity:GetFov(angles, origin)
    if self ~= nil then
        local entity_origin = self:GetOrigin()
        local length = math.sqrt((entity_origin.x - origin.x) ^ 2 + (entity_origin.y - origin.y) ^ 2 + (entity_origin.z - origin.z) ^ 2)

        local direction = 1 / length
        local final_direction = Vector.new(
            (entity_origin.x - origin.x) * direction, (entity_origin.y - origin.y) * direction, (entity_origin.z - origin.z) * direction
        )

        return final_direction.x * angles.x + final_direction.y * angles.y + final_direction.z * angles.z
    end
end

function C_BaseEntity:GetVelocity()
    local first_velocity = self:GetProp("m_vecVelocity[0]")
    local second_velocity = self:GetProp("m_vecVelocity[1]")

    local current_speed = math.sqrt(first_velocity * first_velocity + second_velocity * second_velocity)
    return current_speed
end

function C_BaseEntity:GetState()
    if self ~= nil then
        local self_velocity = self:GetVelocity()
        local current_state = "UNKNOWN"

        local duck_amount = self:GetProp("m_flDuckAmount")
        local is_local = self:GetPlayer() == EntityList.GetLocalPlayer()

        local flags = self:GetProp("m_fFlags")
        local isFD = get_bind("Fake Duck").state
        local isSW = get_bind("Slow Walk").state

        if is_local then
            if isFD then
                current_state = "FAKEDUCK"
            elseif bit.band(flags, 1) == 0 then
                current_state = duck_amount ~= 1 and "IN AIR" or duck_amount == 1 and "IN CROUCH AIR"
            elseif bit.band(flags, 1) ~= 0 and duck_amount == 1 then
                current_state = self:GetProp("m_iTeamNum") == 2 and "CROUCH T" or self:GetProp("m_iTeamNum") == 3 and "CROUCH CT"
            elseif isSW then
                current_state = "SLOWWALK"
            elseif self_velocity > 1.1 then
                current_state = "MOVING"
            elseif self_velocity <= 1.1 then
                current_state = "STANDING"
            end
        else
            if bit.band(flags, 1) == 0 then
                current_state = duck_amount ~= 1 and "IN AIR" or duck_amount == 1 and "IN CROUCH AIR"
            elseif bit.band(flags, 1) ~= 0 and duck_amount == 1 then
                current_state = self:GetProp("m_iTeamNum") == 2 and "CROUCH T" or self:GetProp("m_iTeamNum") == 3 and "CROUCH CT"
            elseif self_velocity > 5 and self_velocity <= 80 then
                current_state = "SLOWWALK"
            elseif self_velocity > 1.1 then
                current_state = "MOVING"
            elseif self_velocity <= 1.1 then
                current_state = "STANDING"
            end
        end
        return current_state
    end
end

function C_BaseEntity:extrapolate_position(direction_value, vector)
    local velocity = self:GetProp("m_vecVelocity")
    local direction = velocity.x > 0 and direction_value or -direction_value
    
    local new_vector = Vector.new(
        vector.x + (velocity.x * GlobalVars.interval_per_tick()) + direction,
        vector.y + (velocity.y * GlobalVars.interval_per_tick()),
        vector.z + (velocity.z * GlobalVars.interval_per_tick())
    )

    return new_vector
end

local player_vars = {
    sv_maxusrcmdprocessticks = CVar.FindVar("sv_maxusrcmdprocessticks"),
    fov_cs_debug = CVar.FindVar("fov_cs_debug")
}

local client_info = {
    MAX_PLAYERS = 64,
    INT_MAX = 4.5e15
}

local button_states = {
    IN_ATTACK = bit.lshift(1, 0),
    IN_JUMP = bit.lshift(1, 1),
    IN_DUCK = bit.lshift(1, 2),
    IN_FORWARD = bit.lshift(1, 3),
    IN_BACK = bit.lshift(1, 4),
    IN_USE = bit.lshift(1, 5),
    IN_CANCEL = bit.lshift(1, 6),
    IN_LEFT = bit.lshift(1, 7),
    IN_RIGHT = bit.lshift(1, 8),
    IN_MOVELEFT = bit.lshift(1, 9),
    IN_MOVERIGHT = bit.lshift(1, 10),
    IN_ATTACK2 = bit.lshift(1, 11),
    IN_RUN = bit.lshift(1, 12),
    IN_RELOAD = bit.lshift(1, 13),
    IN_ALT1 = bit.lshift(1, 14),
    IN_ALT2 = bit.lshift(1, 15),
    IN_SCORE = bit.lshift(1, 16),
    IN_SPEED = bit.lshift(1, 17),
    IN_WALK = bit.lshift(1, 18),
    IN_ZOOM = bit.lshift(1, 19),
    IN_WEAPON1 = bit.lshift(1, 20),
    IN_WEAPON2 = bit.lshift(1, 21),
    IN_BULLRUSH = bit.lshift(1, 22)
}

local offsets = {
    animstate = 0x9960
}
--- @endregion

--- @region: enemy information collector
local enemy_data = {}

enemy_data.updated_time = GlobalVars.realtime()
enemy_data.data = {enemy_id = -1, fov = -1}

function C_BaseEntity:IsCheckedEnemyValid()
    return self:IsAlive() and not self:IsTeamMate() and self ~= EntityList.GetLocalPlayer() and not self:IsDormant() and self:GetName() ~= ""
end

enemy_data.update_enemies = function()
    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local all_players = EntityList.GetPlayers()
        local player_data = {enemy_id = -1, minimum_fov = -1}

        if enemy_data.updated_time + 0.5 < GlobalVars.realtime() then
            for player_id = 1, client_info.MAX_PLAYERS do
                local current_player = EntityList.GetPlayerForUserID(player_id)
                if current_player ~= nil then
                    local is_valid = current_player:IsCheckedEnemyValid()

                    if not is_valid then
                        goto skip
                    end

                    local my_origin = my_index:GetOrigin()
                    local enemy_origin = current_player:GetOrigin()

                    local bullet_data = Cheat.FireBullet(my_index, my_origin, enemy_origin)
                    local distance = my_origin:DistTo(enemy_origin)

                    local my_view_angles = EngineClient.GetViewAngles()
                    local angles_to_vector = Cheat.AngleToForward(my_view_angles)

                    local fov = current_player:GetFov(angles_to_vector, my_origin)
                    if fov > player_data.minimum_fov then
                        player_data.enemy_id = player_id
                        player_data.minimum_fov = fov
                    end

                    ::skip::
                end
            end

            enemy_data.data.enemy_id = player_data.enemy_id
            enemy_data.data.fov = player_data.minimum_fov
            enemy_data.updated_time = GlobalVars.realtime()
        end
    end
end
--- @endregion

--- @region: all global functions
local join_discord_button = "                     Join our discord server!              "
add_element(false, "Join discord server", Menu.Button("Half-Life: Global", "Useful buttons", join_discord_button, "Click to join our discord server!",
function()
    ffi_functions.open_link("https://discord.gg/bTVu9twXzn")
end))

local smallest_pixel_7_link = "https://cdn.discordapp.com/attachments/897931346373128274/936931900059156500/smallest_pixel-7.ttf"
local acta_symbols_w95_link = "https://cdn.discordapp.com/attachments/897931346373128274/950677116402413588/ACTA_SYMBOLS_W95_ARROWS.TTF"

ffi_functions.download_file("nl\\half-life\\fonts\\smallest-pixel-7.ttf", smallest_pixel_7_link)
ffi_functions.download_file("nl\\half-life\\fonts\\acta-symbols-w95.ttf", acta_symbols_w95_link)
--- @endregion

--- @region: all ragebot functions
add_element(false, "Enable dormant aimbot", Menu.Switch("Half-Life: Ragebot stuff", "Automatic dormant aimbot", "Enable dormant aimbot", false))
add_element(false, "Dormant aimbot minimum damage", Menu.SliderInt("Half-Life: Ragebot stuff", "Automatic dormant aimbot", "Minimum damage", 5, 0, 100
), function()
    return menu_database.elements["Enable dormant aimbot"]
end)

add_element(false, "Dormant aimbot hitchance", Menu.SliderInt("Half-Life: Ragebot stuff", "Automatic dormant aimbot", "Hitchance", 80, 0, 100
), function()
    return menu_database.elements["Enable dormant aimbot"]
end)

local all_ragebot_functions = {}
all_ragebot_functions.dormant_aimbot = {}

all_ragebot_functions.dormant_aimbot.apply_autostop = function(cmd, my_index, goal_speed)
    local forward_move, side_move = cmd.forwardmove ^ 2, cmd.sidemove ^ 2
    local minimum_speed = math.sqrt(forward_move + side_move)

    if goal_speed <= 0 or minimum_speed <= 0 then
        return
    end

    if minimum_speed <= goal_speed then
        return
    end

    local small_speed = goal_speed / minimum_speed
    local speed_factor = small_speed * 1.5

    cmd.forwardmove = cmd.forwardmove * speed_factor
    cmd.sidemove = cmd.sidemove * speed_factor
end

all_ragebot_functions.dormant_aimbot.check_next_time = function(my_index, active_weapon)
    if active_weapon:IsKnife() or active_weapon:IsGrenade() or active_weapon:IsReloading() then
        return false
    end

    local isHS = get_bind("Hide Shots").state
    local delay_to_shoot = isHS and 0.3 or 0.1

    local next_attack = my_index:GetProp("m_flNextAttack") + delay_to_shoot
    local next_primary_attack = active_weapon:GetProp("m_flNextPrimaryAttack") + delay_to_shoot
    local is_time_valid = next_attack <= GlobalVars.curtime() and next_primary_attack <= GlobalVars.curtime()

    if is_time_valid then
        return true
    end
    
    return false
end

all_ragebot_functions.dormant_aimbot.is_available_to_hit = function(cmd, my_index, enemy, start_point, final_point, active_weapon)
    local get_weapon_inaccuracy = active_weapon:GetInaccuracy(active_weapon)
    local get_weapon_spead = active_weapon:GetSpread(active_weapon)

    local inaccuracy = get_weapon_inaccuracy + get_weapon_spead
    local enemy_health = enemy:GetHealth()

    local bullet_data = Cheat.FireBullet(my_index, start_point, final_point)
    local bullet_damage = bullet_data.damage

    local reverse_bullet_to_trace = bullet_data.trace
    local bullet_hit_entity = reverse_bullet_to_trace.hit_entity

    local minimum_damage = menu_database.elements["Dormant aimbot minimum damage"]
    local minimum_hitchance = menu_database.elements["Dormant aimbot hitchance"]

    if bullet_damage < math.min(minimum_damage, enemy_health) then
        return -1
    end

    if bullet_hit_entity ~= nil then
        if bullet_hit_entity:EntIndex() ~= enemy:EntIndex() then
            return -1
        end
    end

    if active_weapon:IsSniper() then
        local is_scoped = my_index:GetProp("m_bIsScoped")
        if not is_scoped then
            cmd.buttons = bit.bor(cmd.buttons, button_states.IN_ATTACK2)
        end
    end

    local weapon_max_speed = active_weapon:GetMaxSpeed() / 10
    local autostop_work = all_ragebot_functions.dormant_aimbot.apply_autostop(cmd, my_index, weapon_max_speed)

    local hitchance_magic_value = 120
    if 1 / inaccuracy >= minimum_hitchance + hitchance_magic_value then
        return bullet_damage
    end

    return -1
end

function C_BaseEntity:IsDormantEnemyValid()
    return self:IsAlive() and not self:IsTeamMate() and self ~= EntityList.GetLocalPlayer()
end

all_ragebot_functions.dormant_aimbot.start_work = function(cmd)
    if not menu_database.elements["Enable dormant aimbot"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local active_weapon = my_index:GetActiveWeapon()
        if not active_weapon then return end

        local self_eye_position = my_index:GetEyePosition()
        local current_state = my_index:GetState()

        if current_state == "IN AIR" or current_state == "IN CROUCH AIR" then
            return
        end

        local player_data = {
            minimum_damage = 0,
            is_hitbox_available = false,
            best_angle_points = QAngle.new(0, 0, 0)
        }

        for player_id = 1, 64 do
            local enemy = EntityList.GetPlayer(player_id)
            local is_enemy_valid = enemy ~= nil and enemy:IsDormantEnemyValid()

            if is_enemy_valid then
                local enemy_origin = enemy:GetOrigin()
                local is_enemy_dormant = enemy:IsDormant() and enemy:GetNetworkState() ~= -1

                if is_enemy_dormant then
                    local is_available_to_shoot = all_ragebot_functions.dormant_aimbot.check_next_time(my_index, active_weapon)
                    if is_available_to_shoot then
                        for z_adding = 40, 53, 3 do
                            local z_vector = Vector.new(0, 0, z_adding)
                            local current_hitbox = enemy_origin + z_vector

                            local start_hitbox_position = math:calculate_angles(self_eye_position, current_hitbox)
                            local returned_damage = all_ragebot_functions.dormant_aimbot.is_available_to_hit(
                                cmd, my_index, enemy, self_eye_position, current_hitbox, active_weapon
                            )

                            if returned_damage > player_data.minimum_damage then
                                player_data.is_hitbox_available = true
                                player_data.minimum_damage = returned_damage
                                player_data.best_angle_points = start_hitbox_position
                            end
                        end
                    end
                end
            end
        end

        if player_data.is_hitbox_available then
            cmd.buttons = bit.bor(cmd.buttons, button_states.IN_ATTACK)
            cmd.viewangles = player_data.best_angle_points
        end 
    end
end

add_element(false, "Enable doubletap controllers", Menu.Switch("Half-Life: Ragebot stuff", "Doubletap controllers", "Enable doubletap controllers", false))
add_element(false, "All controllers", Menu.MultiCombo("Half-Life: Ragebot stuff", "Doubletap controllers", "All controllers", {
    "Adaptive speed", "Modify danger ticks"
}, 0), function()
    return menu_database.elements["Enable doubletap controllers"]
end)

all_ragebot_functions.doubletap_controllers = {}
all_ragebot_functions.doubletap_controllers.cached_data = {}

for player_id = 1, client_info.MAX_PLAYERS do
    all_ragebot_functions.doubletap_controllers.cached_data[player_id] = {
        ticks = 0,
        origin = Vector.new(0, 0, 0)
    }
end

all_ragebot_functions.doubletap_controllers.override_ticks = function(ticks)
    player_vars.sv_maxusrcmdprocessticks:SetInt(ticks + 2)
    Exploits.OverrideDoubleTapSpeed(ticks)
end

all_ragebot_functions.doubletap_controllers.start_work = function(cmd)
    if not menu_database.elements["Enable doubletap controllers"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local active_weapon = my_index:GetActiveWeapon()
        if not active_weapon then return end

        local enemy_id = enemy_data.data.enemy_id
        local enemy = EntityList.GetPlayerForUserID(enemy_id)

        if enemy:GetName() ~= "" then
            local isDT = get_bind("Double Tap").state
            local selectors = menu_database.elements["All controllers"]

            if isDT then
                if bit.band(selectors, bit.lshift(1, 0)) ~= 0 then
                    if not active_weapon:IsSniper() and not active_weapon:IsKnife() and not active_weapon:IsGrenade() then
                        local my_origin = my_index:GetOrigin()
                        local enemy_origin = enemy:GetOrigin()

                        local bullet_data = Cheat.FireBullet(my_index, my_origin, enemy_origin)
                        local bullet_damage = bullet_data.damage

                        local ticks = math.round(math.clamp(bullet_damage / 3, 13, 16))
                        all_ragebot_functions.doubletap_controllers.override_ticks(ticks)
                    end
                end

                if bit.band(selectors, bit.lshift(1, 1)) ~= 0 then
                    local enemy_index = enemy:EntIndex()
                    local current_data = all_ragebot_functions.doubletap_controllers.cached_data[enemy_index]

                    local enemy_origin = enemy:GetOrigin()
                    local delta_between_ticked_vectors = enemy_origin - current_data.origin

                    if #delta_between_ticked_vectors > 0 then
                        current_data.ticks = cmd.tick_count
                    end

                    current_data.origin = enemy_origin
                    local current_ticks_in_time = math.round(0.5 / GlobalVars.interval_per_tick() + 0.5)

                    local is_ticks_broken = cmd.tick_count - current_data.ticks < current_ticks_in_time
                    if is_ticks_broken then
                        RageBot.ForceSafety(enemy_index)
                    end
                end
            end
        end
    end
end
--- @endregion

--- @region: all anti-aim functions
local all_anti_aim_functions = {}
local conditions = {"Hidden", "Standing", "Moving", "Ducking", "Fakeduck", "Slow Walk", "In air"}

add_element(false, "Enable anti-aimbot stuff", Menu.Switch("Half-Life: Anti-Aim stuff", "All anti-aim conditions", "Enable anti-aim elements", false))
add_element(false, "Conditions", Menu.Combo("Half-Life: Anti-Aim stuff", "All anti-aim conditions", "Conditions", conditions, 0), function()
    return menu_database.elements["Enable anti-aimbot stuff"]
end)

for condition_id = 1, #conditions do
    local condition_name = conditions[condition_id + 1]
    local condition_letters = {"S", "M", "D", "F", "SW", "A"}

    local modes = {
        "Yaw Add Left", "Yaw Add Right",
        "Yaw Modifier", "Modifier Degree",
        "Fake Limit Type", "Left Limit", "Right Limit",
        "Fake Options", "LBY Mode", "Fake Desync", "Desync On Shot",
        "Smart options"
    }

    for mode_id = 1, #modes do
        local mode_name = modes[mode_id]
        local functions = {
            Menu.SliderInt, Menu.SliderInt,
            Menu.Combo, Menu.SliderInt,
            Menu.Combo, Menu.SliderInt, Menu.SliderInt,
            Menu.MultiCombo, Menu.Combo, Menu.Combo, Menu.Combo,
            Menu.MultiCombo
        }

        local sub_functions = {
            {0, -180, 180}, {0, -180, 180},
            {{"Disabled", "Center", "Offset", "Random", "Spin"}, 0}, {0, -180, 180},
            {{"Static", "Jitter"}, 0}, {60, 0, 60}, {60, 0, 60},
            {{"Avoid Overlap", "Jitter", "Randomize Jitter", "Anti Bruteforce"}, 0},
            {{"Disabled", "Opposite", "Sway"}, 0}, {{"Off", "Peek Fake", "Peek Real"}, 0},
            {{"Disabled", "Opposite", "Freestanding", "Switch"}, 0},
            {{"Anti-backstab", "Auto-yaw position", "Adjust pitch yaw", "Edge yaw"}, 0}
        }

        local total = {
            callbacks = ("%s %s"):format(condition_name, mode_name),
            names = ("[%s] %s\n"):format(condition_letters[condition_id], mode_name),
        }

        add_element(false, total.callbacks, functions[mode_id]("Half-Life: Anti-Aim stuff", "All anti-aim conditions", total.names, unpack(sub_functions[mode_id])),
        function()
            return menu_database.elements["Enable anti-aimbot stuff"] and menu_database.elements["Conditions"] == condition_id
        end)
    end
end

all_anti_aim_functions.custom_anti_aim = {}
all_anti_aim_functions.custom_anti_aim.is_rolling = false
all_anti_aim_functions.custom_anti_aim.fast_switcher = false

all_anti_aim_functions.custom_anti_aim.get_current_state = function(my_index)
    local current_state = my_index:GetState()
    local return_state = "Standing"

    local default_states = {"STANDING", "MOVING", "SLOWWALK", "CROUCH T", "CROUCH CT", "IN AIR", "IN CROUCH AIR", "FAKEDUCK"}
    local new_states = {"Standing", "Moving", "Slow Walk", "Ducking", "Ducking", "In air", "In air", "Ducking"}

    for state = 1, #default_states do
        if current_state == default_states[state] then
            return_state = new_states[state]
        end
    end

    return return_state
end

all_anti_aim_functions.custom_anti_aim.set_null_anti_aims = function()
    local directory = bind_system.list_of_directories.anti_aim

    directory.yaw_add:SetInt(0)
    directory.yaw_modifier:SetInt(0)
    directory.modifier_degree:SetInt(0)

    directory.left_limit:SetInt(60)
    directory.right_limit:SetInt(60)

    directory.fake_options:SetInt(0)
    directory.lby_mode:SetInt(0)
    directory.freestand_desync:SetInt(0)
    directory.desync_on_shot:SetInt(0)
end

all_anti_aim_functions.custom_anti_aim.anti_bruteforce = {}
all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases = {}

all_anti_aim_functions.custom_anti_aim.anti_bruteforce.add_new_phase = function()
    local phase_counter = #all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases
    if phase_counter > 9 then
        Cheat.AddNotify("Half-life.lua", "You cant create more than 9 phases!")
        return
    end

    local new_phase_callback = ("Phase #%s"):format(phase_counter + 1)
    add_element(false, new_phase_callback, Menu.SliderInt("Half-Life: Anti-Aim stuff", "Anti-bruteforce phases", new_phase_callback, 0, -60, 60), function()
        return menu_database.elements["Enable anti-bruteforce"]
    end)

    set_value("Anti-bruteforce value", phase_counter)
    table.insert(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases, menu_database.references[new_phase_callback].reference)
end

all_anti_aim_functions.custom_anti_aim.anti_bruteforce.remove_old_phase = function()
    local phase_counter = #all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases
    local old_phase_callback = ("Phase #%s"):format(phase_counter)

    if phase_counter <= 2 or type(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases[phase_counter]) ~= "userdata" then
        Cheat.AddNotify("Half-life.lua", "There must be at least 2 phases!")
        return
    end

    Menu.DestroyItem(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases[phase_counter])
    table.remove(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases, phase_counter)

    menu_database.elements[old_phase_callback] = nil
    menu_database.references[old_phase_callback] = nil

    set_value("Anti-bruteforce value", phase_counter)
end

local add_phase = "                               Add new phase                        "
local remove_phase = "                           Remove old phase                      "

add_element(false, "Enable anti-bruteforce", Menu.Switch("Half-Life: Anti-Aim stuff", "Anti-bruteforce phases", "Enable anti-bruteforce", false))
add_element(false, "Anti-bruteforce value", Menu.SliderInt("Half-Life: Anti-Aim stuff", "Anti-bruteforce phases", "Hidden value", 2, 2, 10), function()
    return false
end)

add_element(false, "Add phase button", Menu.Button("Half-Life: Anti-Aim stuff", "Anti-bruteforce phases", add_phase, "Click to add new phase!", function()
    all_anti_aim_functions.custom_anti_aim.anti_bruteforce.add_new_phase()
end), function()
    return menu_database.elements["Enable anti-bruteforce"]
end)

add_element(false, "Remove phase button", Menu.Button("Half-Life: Anti-Aim stuff", "Anti-bruteforce phases", remove_phase, "Click to remove old phase!", function()
    all_anti_aim_functions.custom_anti_aim.anti_bruteforce.remove_old_phase()
end), function()
    return menu_database.elements["Enable anti-bruteforce"]
end)

for phase_id = 1, menu_database.elements["Anti-bruteforce value"] do
    all_anti_aim_functions.custom_anti_aim.anti_bruteforce.add_new_phase()
end

all_anti_aim_functions.custom_anti_aim.anti_bruteforce.data = {
    reset_time = 0,
    minimum_time = 1.5,

    current_phase_id = 0,
    current_phase_angle = 0,

    distance_to_trigger = 75,
    react_triggered_tick = 0,

    is_anti_bruteforce_active = false
}

all_anti_aim_functions.custom_anti_aim.anti_bruteforce.sauron_text = {}
all_anti_aim_functions.custom_anti_aim.anti_bruteforce.is_anti_bruteforce_applied = function(my_index, bullet_vector, enemy_eye_position, self_eye_position)
    local closest_point = math.closest_point_on_ray(bullet_vector, enemy_eye_position, self_eye_position)
    local bullet_distance = closest_point:DistTo(self_eye_position)

    local data = all_anti_aim_functions.custom_anti_aim.anti_bruteforce.data
    if bullet_distance > data.distance_to_trigger then
        return
    end

    local phase_counter = #all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases
    if data.reset_time < GlobalVars.realtime() then
        for phase_id = 1, phase_counter do
            data.current_phase_id = phase_id
            break
        end
    else
        data.current_phase_id = 1 + (data.current_phase_id % phase_counter)
    end

    data.reset_time = GlobalVars.realtime() + data.minimum_time
    data.current_phase_angle = menu_database.elements[("Phase #%s"):format(data.current_phase_id)]

    while not data.current_phase_angle do
        data.current_phase_id = 1 + (data.current_phase_id % phase_counter)
        data.current_phase_angle = menu_database.elements[("Phase #%s"):format(data.current_phase_id)]
    end

    data.react_triggered_tick = GlobalVars.tickcount()
    table.insert(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.sauron_text, {
        text = "Switched side due to anti-bruteforce",

        timer = GlobalVars.realtime(),
        smooth_y = screen_size.y + 100,
        alpha = 0,

        first_circle = 0,
        second_circle = 0,

        box_left = screen_size.x / 2,
        box_right = screen_size.x / 2,

        box_left_1 = screen_size.x / 2,
        box_right_1 = screen_size.x / 2
    })
end

all_anti_aim_functions.custom_anti_aim.anti_bruteforce.trigger_anti_bruteforce = function(event)
    if not menu_database.elements["Enable anti-bruteforce"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        if event:GetName() ~= "bullet_impact" then
            return
        end

        local data = all_anti_aim_functions.custom_anti_aim.anti_bruteforce.data
        if data.react_triggered_tick == GlobalVars.tickcount() then
            return
        end

        local self_eye_position = my_index:GetEyePosition()
        local attacker = EntityList.GetPlayerForUserID(event:GetInt("userid"))

        if not attacker or attacker == my_index or attacker:IsTeamMate() or attacker:IsDormant() then
            return
        end

        local bullet_vector = Vector.new(event:GetInt("x"), event:GetInt("y"), event:GetInt("z"))
        local enemy_eye_position = attacker:GetEyePosition()

        all_anti_aim_functions.custom_anti_aim.anti_bruteforce.is_anti_bruteforce_applied(my_index, bullet_vector, enemy_eye_position, self_eye_position)
    end
end

all_anti_aim_functions.custom_anti_aim.anti_bruteforce.apply_anti_bruteforce = function()
    local data = all_anti_aim_functions.custom_anti_aim.anti_bruteforce.data
    if data.reset_time < GlobalVars.realtime() then
        data.is_anti_bruteforce_active = false
        return
    end

    AntiAim.OverrideInverter(data.current_phase_angle < 0)
    AntiAim.OverrideLimit(math.abs(data.current_phase_angle))

    data.is_anti_bruteforce_active = true
end

all_anti_aim_functions.custom_anti_aim.anti_backstab = function(directory, my_index, enemy)
    if bit.band(directory, bit.lshift(1, 0)) ~= 0 then
        if enemy:GetName() ~= "" then
            local enemy_weapon = enemy:GetActiveWeapon()
            if not enemy_weapon then return end

            local my_origin = my_index:GetOrigin()
            local enemy_origin = enemy:GetOrigin()

            local minimum_distance = 120
            local our_distance = my_origin:DistTo(enemy_origin)

            if enemy_weapon:IsKnife() then
                if our_distance <= minimum_distance then
                    AntiAim.OverrideYawOffset(180)
                    all_anti_aim_functions.custom_anti_aim.set_null_anti_aims()
                end
            end
        end
    end
end

all_anti_aim_functions.custom_anti_aim.auto_yaw_position = function(directory, my_index, enemy)
    if bit.band(directory, bit.lshift(1, 1)) ~= 0 then
        local current_yaw, is_inverted = 0, AntiAim.GetInverterState()
        local self_eye_position = my_index:GetEyePosition()

        if enemy:GetName() ~= "" then
            local enemy_position = enemy:GetOrigin()
            local calculate_distance = self_eye_position:DistTo(enemy_position)

            local minimum_distance = 300
            local calculated_angle = QAngle.new(0, 0, 0)

            if calculate_distance > minimum_distance then
                minimum_distance = calculate_distance
                calculated_angle = math:calculate_angles(self_eye_position, enemy_position)
            end

            current_yaw = math.floor(calculated_angle.pitch)
            current_yaw = math.clamp(current_yaw, -10, 10)
        else
            local all_players = EntityList.GetPlayers()
            local is_active = true

            for player_id, player in ipairs(all_players) do
                is_active = not player:IsAlive() or player:IsTeamMate() or player == my_index
            end

            if not is_active then
                local mask_offset = 0x4600400B
                local self_origin = my_index:GetOrigin()
                local stop_point = Vector.new(
                    self_origin.x + self_eye_position.x * 8192,
                    self_origin.y + self_eye_position.y * 8192,
                    self_origin.z + self_eye_position.z * 8192
                )
            
                local result_trace = EngineTrace.TraceRay(self_eye_position, stop_point, my_index, mask_offset)
                local trace_fraction = result_trace.fraction

                if trace_fraction == 1 then
                    current_yaw = is_inverted and 5 or -5
                end

                local new_stop_position = Vector.new(
                    self_origin.x + self_eye_position.x * trace_fraction * 8192,
                    self_origin.y + self_eye_position.y * trace_fraction * 8192,
                    self_origin.z + self_eye_position.z * trace_fraction * 8192
                )

                local distance = math.sqrt(
                    (self_eye_position.x - new_stop_position.x) ^ 2 +
                    (self_eye_position.y - new_stop_position.y) ^ 2 +
                    (self_eye_position.z - new_stop_position.z) ^ 2
                )

                local applied_yaw = math.clamp(math.round(distance / 10), -20, 20)
                current_yaw = is_inverted and applied_yaw or -applied_yaw
            else
                current_yaw = 0
            end
        end

        local is_anti_bruteforce_active = all_anti_aim_functions.custom_anti_aim.anti_bruteforce.data.is_anti_bruteforce_active
        if not is_anti_bruteforce_active then
            AntiAim.OverrideYawOffset(current_yaw)
        end
    end
end

all_anti_aim_functions.custom_anti_aim.adjust_pitch_yaw = function(directory, my_index)
    if bit.band(directory, bit.lshift(1, 2)) ~= 0 then
        local active_weapon = my_index:GetActiveWeapon()
        if not active_weapon then return end

        local next_attack = my_index:GetProp("m_flNextAttack")
        local next_primary_attack = active_weapon:GetProp("m_flNextPrimaryAttack")

        local is_holding = next_attack <= GlobalVars.curtime() and next_primary_attack <= GlobalVars.curtime()
        local current_pitch = math.clamp(math.round(is_holding and next_attack % 3 or next_primary_attack % 5), 0, 4)

        AntiAim.OverrideDesyncOnShot(current_pitch)
    end
end

all_anti_aim_functions.custom_anti_aim.start_point = Vector.new()
all_anti_aim_functions.custom_anti_aim.reset_data = {
    backup_value = 4,
    is_backuped = true,
    is_edge_yaw_working = false
}

all_anti_aim_functions.custom_anti_aim.collect_cache = function()
    local data = all_anti_aim_functions.custom_anti_aim.reset_data
    local yaw_base = bind_system.list_of_directories["Yaw Base"]

    if data.is_edge_yaw_working then
        yaw_base:SetInt(0)
        data.is_backuped = false
    else
        if not data.is_backuped then
            yaw_base:SetInt(data.backup_value)
            data.is_backuped = true
        end
    end
end

all_anti_aim_functions.custom_anti_aim.work_edge_yaw = function(my_index)
    local data = all_anti_aim_functions.custom_anti_aim.reset_data
    data.is_edge_yaw_working = false

    local m_chocked_commands = ClientState.m_choked_commands()
    if m_chocked_commands == 0 then
        all_anti_aim_functions.custom_anti_aim.start_point = my_index:GetEyePosition()
    end

    local distances = {}
    local final_point_vector = {}

    local start_point = all_anti_aim_functions.custom_anti_aim.start_point
    local self_view_angles = EngineClient.GetViewAngles()

    for yaw = 18, 360, 18 do
        yaw = math.normalize(yaw)

        local mask_offset = 0x46004003
        local edge_angle = QAngle.new(0, yaw, 0)

        local final_point = start_point + Cheat.AngleToForward(edge_angle) * 198
        local trace_data = EngineTrace.TraceRay(start_point, final_point, my_index, mask_offset)

        local trace_fraction = trace_data.fraction
        local trace_hit_entity = trace_data.hit_entity
        local trace_end_position = trace_data.endpos

        table.insert(distances, start_point:DistTo(trace_end_position))
        if trace_hit_entity ~= nil then
            local entity_classname = trace_hit_entity:GetClassName()
            if entity_classname == "CWorld" and trace_fraction < 0.3 then
                final_point_vector[#final_point_vector + 1] = {
                    final_point = final_point,
                    yaw = yaw
                }
            end
        end
    end

    table.sort(distances)
    if distances[1] > 30 then
        return
    end

    table.sort(final_point_vector, function(first_yaw, second_yaw)
        return first_yaw.yaw < second_yaw.yaw
    end)

    table.remove(final_point_vector, #final_point_vector)
    local edge_angle = nil

    if #final_point_vector >= 3 then
        local center_vector = math.lerp(final_point_vector[1].final_point, final_point_vector[#final_point_vector].final_point, 0.5)
        edge_angle = Cheat.VectorToAngle(start_point - center_vector)
    end

    if edge_angle ~= nil then
        local yaw = self_view_angles.yaw
        local edge_yaw = edge_angle.yaw
        local difference = math.normalize(edge_yaw - yaw)

        if math.abs(difference) < 90 then
            difference = 0
            edge_yaw = math.normalize(edge_yaw + 180)
        end

        local new_static_yaw = -edge_yaw

        new_static_yaw = math.normalize(new_static_yaw + edge_yaw)
        new_static_yaw = math.normalize(new_static_yaw + difference + 180)

        AntiAim.OverrideYawOffset(new_static_yaw)
        all_anti_aim_functions.custom_anti_aim.reset_data.is_edge_yaw_working = true
    end
end

all_anti_aim_functions.custom_anti_aim.apply_edge_yaw = function(directory, my_index)
    local data = all_anti_aim_functions.custom_anti_aim.reset_data
    if bit.band(directory, bit.lshift(1, 3)) ~= 0 then
        if data.is_backuped then
            data.backup_value = 4
        end

        all_anti_aim_functions.custom_anti_aim.collect_cache()
        all_anti_aim_functions.custom_anti_aim.work_edge_yaw(my_index)
    end
end

all_anti_aim_functions.custom_anti_aim.on_edge_yaw_destroy = function(directory, my_index)
    if not menu_database.elements["Enable anti-aimbot stuff"] then return end
    local data = all_anti_aim_functions.custom_anti_aim.reset_data

    if not data.is_backuped then
        bind_system.list_of_directories["Yaw Base"]:SetInt(data.backup_value)
    end
end

all_anti_aim_functions.custom_anti_aim.apply_custom_anti_aims = function(state, my_index, enemy)
    if not all_anti_aim_functions.custom_anti_aim.is_rolling then
        local get_state = function(base)
            return menu_database.elements[("%s %s"):format(state, base)]
        end

        local inverter_state = AntiAim.GetInverterState()
        local m_chocked_commands = ClientState.m_choked_commands()
        local directory = bind_system.list_of_directories.anti_aim

        directory.yaw_add:SetInt(inverter_state and get_state("Yaw Add Left") or get_state("Yaw Add Right"))
        directory.yaw_modifier:SetInt(get_state("Yaw Modifier"))
        directory.modifier_degree:SetInt(get_state("Modifier Degree"))

        if m_chocked_commands == 0 then
            local fake_type = get_state("Fake Limit Type")
            if fake_type == 0 then
                directory.left_limit:SetInt(get_state("Left Limit"))
                directory.right_limit:SetInt(get_state("Right Limit"))
            else
                directory.left_limit:SetInt(all_anti_aim_functions.custom_anti_aim.fast_switcher and 18 or get_state("Left Limit"))
                directory.right_limit:SetInt(all_anti_aim_functions.custom_anti_aim.fast_switcher and 18 or get_state("Right Limit"))
            end

            all_anti_aim_functions.custom_anti_aim.fast_switcher = not all_anti_aim_functions.custom_anti_aim.fast_switcher
        end

        directory.fake_options:SetInt(get_state("Fake Options"))
        directory.lby_mode:SetInt(get_state("LBY Mode"))
        directory.freestand_desync:SetInt(get_state("Fake Desync"))
        directory.desync_on_shot:SetInt(get_state("Desync On Shot"))

        all_anti_aim_functions.custom_anti_aim.anti_backstab(get_state("Smart options"), my_index, enemy)
        all_anti_aim_functions.custom_anti_aim.auto_yaw_position(get_state("Smart options"), my_index, enemy)
        all_anti_aim_functions.custom_anti_aim.adjust_pitch_yaw(get_state("Smart options"), my_index)
        all_anti_aim_functions.custom_anti_aim.apply_edge_yaw(get_state("Smart options"), my_index)
    end
end

all_anti_aim_functions.custom_anti_aim.start_work = function()
    if not menu_database.elements["Enable anti-aimbot stuff"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local enemy_id = enemy_data.data.enemy_id
        local enemy = EntityList.GetPlayerForUserID(enemy_id)

        local current_state = all_anti_aim_functions.custom_anti_aim.get_current_state(my_index)
        all_anti_aim_functions.custom_anti_aim.apply_custom_anti_aims(current_state, my_index, enemy)
    end
end

add_element(false, "Enable additional anti-aim", Menu.Switch("Half-Life: Anti-Aim stuff", "Additional anti-aim stuff", "Enable additional anti-aim stuff", false))
add_element(false, "Additional anti-aim", Menu.MultiCombo("Half-Life: Anti-Aim stuff", "Additional anti-aim stuff", "Anti-aim stuff", {
    "Break lagcomp in air", "Bombsite E-Fix", "Legit AA on E", "Disable fakelag on hideshots"
}, 0), function()
    return menu_database.elements["Enable additional anti-aim"]
end)

add_element(false, "Breaking lagcomp weapons", Menu.MultiCombo("Half-Life: Anti-Aim stuff", "Additional anti-aim stuff", "Teleport weapons", {
    "Default", "Pistols", "Heavy pistols", "Scout", "AWP", "Autosnipers", "Nades"
}, 0), function()
    return menu_database.elements["Enable additional anti-aim"] and bit.band(menu_database.elements["Additional anti-aim"], bit.lshift(1, 0)) ~= 0
end)

all_anti_aim_functions.additional_stuff = {}
all_anti_aim_functions.additional_stuff.is_weapon_active = function(my_index)
    local active_weapon = my_index:GetActiveWeapon()
    if not active_weapon then return end

    local weapons = {"Default", "Pistols", "Heavy pistols", "Scout", "AWP", "Autosnipers", "Nades"}
    local classname = active_weapon:GetClassName()

    local is_active = false
    for weapon_id = 0, #weapons do
        local current_weapon = weapons[weapon_id + 1]
        if current_weapon ~= nil then
            local directory = menu_database.elements["Breaking lagcomp weapons"]
            if bit.band(directory, bit.lshift(1, weapon_id)) ~= 0 then
                if active_weapon:IsPistol() then
                    if current_weapon == "Heavy pistols" and classname == "CDEagle" then
                        is_active = true
                    elseif current_weapon == "Pistols" and classname ~= "CDEagle" then
                        is_active = true
                    end
                elseif classname == "CWeaponSSG08" and current_weapon == "Scout" then
                    is_active = true
                elseif classname == "CWeaponAWP" and current_weapon == "AWP" then
                    is_active = true
                elseif (classname == "CWeaponSCAR20" or classname == "CWeaponG3SG1") and current_weapon == "Autosnipers" then
                    is_active = true
                elseif current_weapon == "Nades" and active_weapon:IsGrenade() then
                    is_active = true
                elseif current_weapon == "Default" and active_weapon:IsRifle() then
                    is_active = true
                end
            end
        end
    end

    return is_active
end

all_anti_aim_functions.additional_stuff.break_lagcomp = function(my_index, enemy)
    if enemy:GetName() ~= "" then
        local is_weapon_active = all_anti_aim_functions.additional_stuff.is_weapon_active(my_index)
        local isDT = get_bind("Double Tap").state

        if is_weapon_active and isDT then
            local current_state = my_index:GetState()
            local is_in_air = current_state == "IN AIR" or current_state == "IN CROUCH AIR"

            if isDT and is_in_air then
                local enemy_position = enemy:GetOrigin()
                local self_position = my_index:GetOrigin()

                local bullet_data = Cheat.FireBullet(enemy, self_position, enemy_position)
                local bullet_damage = bullet_data.damage

                if bullet_damage > 1 then
                    Exploits.ForceTeleport()
                else
                    local enemy_head_position = enemy:GetHitboxCenter(0)
                    local is_enemy_visible = enemy:IsVisible(enemy_head_position)

                    if is_enemy_visible then
                        Exploits.ForceTeleport()
                    end
                end
            end
        end
    end
end

all_anti_aim_functions.additional_stuff.bombsite_e_fix = function(cmd, my_index)
    local is_in_bombzone = my_index:GetProp("m_bInBombZone")
    local team_num = my_index:GetProp("m_iTeamNum")

    if is_in_bombzone and team_num == 2 then
        local self_eye_position = my_index:GetEyePosition()
        local view_angles_in_vector = Cheat.AngleToForward(EngineClient.GetViewAngles())

        local final_point = self_eye_position + view_angles_in_vector * 8192
        local mask_offset = 0x4600400B

        local trace_data = EngineTrace.TraceRay(self_eye_position, final_point, my_index, mask_offset)
        local trace_fraction = trace_data.fraction
        local trace_hit_entity = trace_data.hit_entity

        local is_using = false
        if trace_data ~= nil then
            if trace_fraction < 1 and trace_hit_entity ~= nil then
                local entity_classname = trace_hit_entity:GetClassName()
                is_using = entity_classname ~= "CWorld" and entity_classname ~= "CFuncBrush" and entity_classname ~= "CCSPlayer"
            end
        end

        if bit.band(cmd.buttons, 32) == 32 then
            if not is_using then
                AntiAim.OverridePitch(0)
                AntiAim.OverrideYawOffset(180)

                cmd.buttons = bit.band(cmd.buttons, bit.bnot(32))
            end
        end
    end
end

all_anti_aim_functions.additional_stuff.legit_aa_on_e = function(cmd, my_index)
    local active_weapon = my_index:GetActiveWeapon()
    if not active_weapon then return end

    local is_pressing_e = bit.band(cmd.buttons, button_states.IN_USE) > 0
    local is_holding_bomb = active_weapon:GetClassName() == "CC4"
    local is_in_bombzone = my_index:GetProp("m_bInBombZone")

    local is_planting = is_in_bombzone and is_holding_bomb
    local all_planted_bombs = EntityList.GetEntitiesByName("CPlantedC4")

    bool is_bomb_planted = #all_planted_bombs > 0
    local bomb_distance = 100

    if is_bomb_planted then
        local current_bomb = all_planted_bombs[#is_bomb_planted]

        local bomb_origin = current_bomb:GetOrigin()
        local self_origin = my_index:GetOrigin()

        bomb_distance = self_origin:DistTo(bomb_origin)
    end

    local self_team = my_index:GetProp("m_iTeamNum")
    local is_defusing = bomb_distance < 62 and self_team == 3
    if is_defusing then
        return
    end

    local local_view_angles = EngineClient.GetViewAngles()
    local self_eye_position = my_index:GetEyePosition()
    local angle_to_vector = Cheat.AngleToForward(local_view_angles)

    local final_point = self_eye_position + angle_to_vector * 8192
    local mask_offset = 0x4600400B

    local trace_data = EngineTrace.TraceRay(self_eye_position, final_point, my_index, mask_offset)
    local trace_fraction = trace_data.fraction
    local trace_hit_entity = trace_data.hit_entity

    local is_using = false
    if trace_data ~= nil then
        if trace_fraction < 1 and trace_hit_entity ~= nil then
            local entity_classname = trace_hit_entity:GetClassName()
            is_using = entity_classname ~= "CWorld" and entity_classname ~= "CFuncBrush" and entity_classname ~= "CCSPlayer"
        end
    end

    if bit.band(cmd.buttons, 32) == 32 then
        if not is_using and not is_planting then
            AntiAim.OverridePitch(0)
            AntiAim.OverrideYawOffset(180)
            cmd.buttons = bit.band(cmd.buttons, bit.bnot(button_states.IN_USE))
        end
    end
end

all_anti_aim_functions.additional_stuff.fakelag_backup_data = {
    backup_value = 14,
    is_backuped = false
}

all_anti_aim_functions.additional_stuff.disable_fakelags_on_hideshots = function()
    local data = all_anti_aim_functions.additional_stuff.fakelag_backup_data
    if not data.is_backuped then
        data.backup_value = Menu.FindVar("Aimbot", "Anti Aim", "Fake Lag", "Limit"):GetInt()
        data.is_backuped = true
    end

    local isHS = get_bind("Hide Shots").state
    local fakelag_path = bind_system.list_of_directories.fakelag_value

    if isHS then
        fakelag_path:SetInt(1)
    else
        if data.is_backuped then
            fakelag_path:SetInt(data.backup_value)
            data.is_backuped = false
        end
    end
end

all_anti_aim_functions.additional_stuff.on_fakelag_destroy = function()
    if not menu_database.elements["Enable additional anti-aim"] then return end
    local directory = menu_database.elements["Additional anti-aim"]

    if bit.band(directory, bit.lshift(1, 3)) ~= 0 then
        local fakelag_path = bind_system.list_of_directories.fakelag_value
        local data = all_anti_aim_functions.additional_stuff.fakelag_backup_data

        fakelag_path:SetInt(data.backup_value)
    end
end

all_anti_aim_functions.additional_stuff.apply_additional_stuff = function(cmd, my_index, enemy)
    local directory = menu_database.elements["Additional anti-aim"]
    if bit.band(directory, bit.lshift(1, 0)) ~= 0 then
        all_anti_aim_functions.additional_stuff.break_lagcomp(my_index, enemy)
    end

    if bit.band(directory, bit.lshift(1, 1)) ~= 0 then
        all_anti_aim_functions.additional_stuff.bombsite_e_fix(cmd, my_index)
    end

    if bit.band(directory, bit.lshift(1, 2)) ~= 0 then
        all_anti_aim_functions.additional_stuff.legit_aa_on_e(cmd, my_index)
    end

    if bit.band(directory, bit.lshift(1, 3)) ~= 0 then
        all_anti_aim_functions.additional_stuff.disable_fakelags_on_hideshots()
    end
end

all_anti_aim_functions.additional_stuff.start_work = function(cmd)
    if not menu_database.elements["Enable additional anti-aim"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local enemy_id = enemy_data.data.enemy_id
        local enemy = EntityList.GetPlayerForUserID(enemy_id)

        all_anti_aim_functions.additional_stuff.apply_additional_stuff(cmd, my_index, enemy)
    end
end

add_element(false, "Enable roll angles", Menu.Switch("Half-Life: Anti-Aim stuff", "Roll angles", "Enable roll angles", false))
add_element(false, "Roll angle bind", Menu.Hotkey("Half-Life: Anti-Aim stuff", "Roll angles", "Roll angle bind", 0x72), function()
    return menu_database.elements["Enable roll angles"]
end)

add_element(false, "Roll angle value", Menu.SliderInt("Half-Life: Anti-Aim stuff", "Roll angles", "Roll angle value", 45, 0, 75), function()
    return menu_database.elements["Enable roll angles"]
end)

all_anti_aim_functions.roll_angles = {}
all_anti_aim_functions.roll_angles.original_direction = {0, 0, 0}
all_anti_aim_functions.roll_angles.convert_to_world_screen = function(angle)
    return Vector2.new(math.cos(angle), math.sin(angle))
end

all_anti_aim_functions.roll_angles.custom_angle_to_vector = function(angles)
    local magic_value = 0.017453292519943
    local first_direction, second_direction = Vector.new(0, 0, 0), Vector.new(0, 0, 0)
    local convert_function = all_anti_aim_functions.roll_angles.convert_to_world_screen

    local pitch = convert_function(angles.pitch * magic_value)
    local yaw = convert_function(angles.yaw * magic_value)
    local roll = convert_function(angles.roll * magic_value)

    first_direction.x = pitch.x * yaw.x
    first_direction.y = pitch.x * yaw.y

    second_direction.x = -1 * roll.y * pitch.y * yaw.x + -1 * roll.x * -yaw.y
    second_direction.y = -1 * roll.y * pitch.y * yaw.y + -1 * roll.x * yaw.x

    return first_direction / #first_direction, second_direction / #second_direction
end

all_anti_aim_functions.roll_angles.movement_fix = function(cmd)
    local convert_function = all_anti_aim_functions.roll_angles.custom_angle_to_vector
    local direction_data = all_anti_aim_functions.roll_angles.original_direction

    local front_left, roght_lefthyh = convert_function(direction_data[3])
    local front_center, roght_centerhyh = convert_function(cmd.viewangles)

    local center = front_left * direction_data[1] + roght_lefthyh * direction_data[2]
    local div = roght_centerhyh.y * front_center.x - roght_centerhyh.x * front_center.y

    cmd.sidemove = (front_center.x * center.y - front_center.y * center.x) / div
    cmd.forwardmove = (roght_centerhyh.y * center.x - roght_centerhyh.x * center.y) / div
end

all_anti_aim_functions.roll_angles.override_manual_settings = function()
    local anti_aim_directory = bind_system.list_of_directories.anti_aim

    anti_aim_directory.yaw_add:SetInt(0)
    anti_aim_directory.yaw_modifier:SetInt(0)
    anti_aim_directory.modifier_degree:SetInt(0)

    anti_aim_directory.left_limit:SetInt(60)
    anti_aim_directory.right_limit:SetInt(60)

    anti_aim_directory.fake_options:SetInt(0)
    anti_aim_directory.lby_mode:SetInt(0)
    anti_aim_directory.freestand_desync:SetInt(0)
    anti_aim_directory.desync_on_shot:SetInt(0)

    AntiAim.OverrideInverter(true)
end

all_anti_aim_functions.roll_angles.is_active = false
all_anti_aim_functions.roll_angles.timer = GlobalVars.realtime()

all_anti_aim_functions.roll_angles.on_pre_prediction = function(cmd)
    all_anti_aim_functions.custom_anti_aim.is_rolling = false

    if not menu_database.elements["Enable roll angles"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local bind_value = menu_database.elements["Roll angle bind"]
        local is_active = all_anti_aim_functions.roll_angles.is_active

        if Cheat.IsKeyDown(bind_value) then
            if all_anti_aim_functions.roll_angles.timer + 0.3 < GlobalVars.realtime() then
                all_anti_aim_functions.roll_angles.is_active = not all_anti_aim_functions.roll_angles.is_active
                all_anti_aim_functions.roll_angles.timer = GlobalVars.realtime()
            end
        end

        if is_active then
            local selected_anle = menu_database.elements["Roll angle value"]
            local current_roll_angle = selected_anle

            local current_manual = menu_database.elements["Manual roll angles"]
            local is_manuals_enabled = menu_database.elements["Only manual roll angles"]

            all_anti_aim_functions.roll_angles.override_manual_settings()
            all_anti_aim_functions.custom_anti_aim.is_rolling = current_roll_angle == selected_anle

            cmd.viewangles.roll = current_roll_angle
        end
    end
end

all_anti_aim_functions.roll_angles.on_create_move = function(cmd)
    if not menu_database.elements["Enable roll angles"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local is_active = all_anti_aim_functions.roll_angles.is_active
        if is_active then
            all_anti_aim_functions.roll_angles.original_direction = {cmd.forwardmove, cmd.sidemove, QAngle.new(0, cmd.viewangles.yaw, 0)}
            all_anti_aim_functions.roll_angles.movement_fix(cmd)
        end
    end
end
--- @endregion

--- @region: all visual functions
local all_visual_functions = {}

all_visual_functions.font_system = {}
all_visual_functions.font_system.list = {}

all_visual_functions.font_system.register = function(font_name, size, parameters)
    local contain_flags = {}
    if parameters ~= nil and type(parameters) == "table" then
        for flag_id = 1, #parameters do
            local current_flag = parameters[flag_id]
            table.insert(contain_flags, current_flag)
        end
    end

    local font_data = ("Name: %s, size: %d, flags: %s"):format(font_name, size, contain_flags)
    local font_list = all_visual_functions.font_system.list

    if font_list[font_data] then
        return font_list[font_data]
    end

    local created_new_font = Render.InitFont(font_name, size, contain_flags)
    font_list[font_data] = created_new_font

    return created_new_font
end

local register_font = all_visual_functions.font_system.register
all_visual_functions.get_local_delta = function(my_index, comma_index, is_absed)
    local real_rotation = AntiAim.GetCurrentRealRotation()
    local yaw_eye_angles = my_index:GetProp("m_angEyeAngles[1]")

    local min_desync_delta = AntiAim.GetMinDesyncDelta()
    local max_desync_delta = AntiAim.GetMaxDesyncDelta()

    local delta = math.clamp(math.normalize(real_rotation - yaw_eye_angles), min_desync_delta, max_desync_delta)
    local formatted_delta = math.abs(delta)
    
    return tonumber(string.format("%." .. comma_index .. "f", is_absed and formatted_delta or delta))
end

all_visual_functions.breathing_alpha = function(value, speed)
    local new_alpha = math.round(math.sin(math.abs(-math.pi + (GlobalVars.curtime() * (1.25 * speed)) % (math.pi * 2))) * value)
    return new_alpha
end

all_visual_functions.get_condition_color = function(condition)
    local fake_color = Color.new((170 + -32 * condition) / 255, condition, condition / 255, 1)
    return fake_color
end

all_visual_functions.draw_shadow = function(type, text, x, y, color, font_size, font, centered, shadow_color)
    local x_pos = type == 0 and 1 or type == 1 and 1 or type == 2 and 0 or 1
    local y_pos = type == 0 and 1 or type == 1 and 0 or type == 2 and 1 or 1

    Render.Text(text, Vector2.new(x + x_pos, y + y_pos), shadow_color, font_size, font, false, centered)
    Render.Text(text, Vector2.new(x + 0, y + 0), color, font_size, font, false, centered)
end

local draw_shadow = all_visual_functions.draw_shadow
local breath_alpha = all_visual_functions.breathing_alpha

add_element(false, "Enable indicator list", Menu.Switch("Half-Life: Visuals stuff", "Indicator list", "Enable indicator list", false))
all_visual_functions.indicator_list = {
    "Under crosshair", "Anti-aim debugger", "Damage indicator",
    "Skeet autopeek", "Skeet indicators", "No animation on 3rd person",
    "Hitmarker crosshair", "Notifications", "Damage markers"
}

add_element(false, "Indicator list", Menu.MultiCombo("Half-Life: Visuals stuff", "Indicator list", "Indicator list", all_visual_functions.indicator_list, 0), function()
    return menu_database.elements["Enable indicator list"]
end)

all_visual_functions.crosshair_style = {"Default", "Modern", "Legacy", "Pixeled", "Updated"}
add_element(false, "Crosshair style", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Crosshair style", all_visual_functions.crosshair_style, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 0)) ~= 0
end)

all_visual_functions.smallest_pixel_font_9 = register_font("nl\\half-life\\fonts\\smallest-pixel-7.ttf", 9)
all_visual_functions.smallest_pixel_font_10 = register_font("nl\\half-life\\fonts\\smallest-pixel-7.ttf", 10)

all_visual_functions.is_extrapolated_danger = function(my_index)
    local enemy_id = enemy_data.data.enemy_id
    local enemy = EntityList.GetPlayerForUserID(enemy_id)

    if enemy:GetName() ~= "" then
        local self_velocity = my_index:GetVelocity()
        if self_velocity <= 5 then
            return false
        end

        local enemy_origin = enemy:GetOrigin()
        local self_origin = my_index:GetOrigin()

        local delta_between_vectors = enemy_origin - self_origin
        local length_of_delta = delta_between_vectors:Length2D()

        local minimum_predict_ticks = 20
        local maximum_distance = client_info.INT_MAX

        for tick_id = 1, minimum_predict_ticks do
            local extrapolated_origin = my_index:extrapolate_position(tick_id, self_origin)
            local delta_between_extrapolated_origin = extrapolated_origin - enemy_origin
            local extrapolated_distance = delta_between_extrapolated_origin:Length2D()

            if extrapolated_distance < maximum_distance then
                maximum_distance = math.abs(extrapolated_distance)
            end
        end

        return maximum_distance < length_of_delta
    end
end

all_visual_functions.get_lerp_time = function()
    local cl_interp = CVar.FindVar("cl_interp"):GetFloat()
    local cl_update_rate = CVar.FindVar("cl_updaterate"):GetFloat()

    local cl_interp_ratio = CVar.FindVar("cl_interp_ratio"):GetFloat()
    local sv_minupdaterate = CVar.FindVar("sv_minupdaterate"):GetFloat()
    local sv_maxupdaterate = CVar.FindVar("sv_maxupdaterate"):GetFloat()

    local sv_client_min_interp_ratio = CVar.FindVar("sv_client_min_interp_ratio"):GetFloat()
    local sv_client_max_interp_ratio = CVar.FindVar("sv_client_max_interp_ratio"):GetFloat()

    local clamp_inter_p_ratio = math.clamp(cl_interp_ratio, sv_client_min_interp_ratio, sv_client_max_interp_ratio)
    local clamp_update_ratio = math.clamp(cl_update_rate, sv_minupdaterate, sv_maxupdaterate)
    
    local lerp = clamp_inter_p_ratio / clamp_update_ratio
    if lerp <= cl_interp then
        lerp = cl_interp
    end

    return lerp
end

all_visual_functions.tick_update_time = GlobalVars.realtime()
all_visual_functions.current_tick_value = 13

all_visual_functions.get_tick_value = function(ticks)
    if all_visual_functions.tick_update_time + 1 < GlobalVars.realtime() then
        local correct_ticks = 0
        local lerp_time = all_visual_functions.get_lerp_time()
        local net_channel_info = EngineClient.GetNetChannelInfo()

        correct_ticks = correct_ticks + net_channel_info:GetLatency(0)
        correct_ticks = correct_ticks + net_channel_info:GetLatency(1)
        correct_ticks = correct_ticks + lerp_time

        local sv_maxunlag = CVar.FindVar("sv_maxunlag"):GetFloat()
        local clamp_correct_ticks = math.clamp(correct_ticks, 1, sv_maxunlag)

        local delta_time = correct_ticks - (GlobalVars.curtime() - ticks)
        local corrected_delta = math.round(math.abs(delta_time) * 100)

        local m_chocked_commands = ClientState.m_choked_commands()
        local final_ticks = math.abs(m_chocked_commands - corrected_delta)

        all_visual_functions.current_tick_value = final_ticks
        all_visual_functions.tick_update_time = GlobalVars.realtime()
    end

    return all_visual_functions.current_tick_value
end

all_visual_functions.get_dormant_players = function(my_index)
    local return_dormant_players = {}
    local players = EntityList.GetEntitiesByName("CCSPlayer")

    for i = 1, #players do
        local enemy = players[i]:GetPlayer()
        if enemy ~= my_index and not enemy:IsTeamMate() and enemy:IsAlive() then
            if enemy:IsDormant() then
                table.insert(return_dormant_players, enemy)
            end
        end
    end

    return #return_dormant_players
end

all_visual_functions.default_style = function(my_index)
    local active_weapon = my_index:GetActiveWeapon()
    if not active_weapon then return end

    local add_y = 35
    local indicator_list = {}
    local font = all_visual_functions.smallest_pixel_font_9

    local alpha = breath_alpha(200, 1.25)
    local edited_color = Color.RGBA(233, 163, 255, alpha)

    Render.Text("HALF-LIFE", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(230, 230, 230, 255), 9, font, true, false)
    Render.Text("BETA", Vector2.new(screen_size.x / 2 + 45, screen_size.y / 2 + add_y), edited_color, 9, font, true, false)

    local dormant_players = all_visual_functions.get_dormant_players(my_index) .. ""
    local anti_bruteforce_data = all_anti_aim_functions.custom_anti_aim.anti_bruteforce.data

    local is_rolling = all_anti_aim_functions.custom_anti_aim.is_rolling
    local is_anti_bruteforce_active = anti_bruteforce_data.is_anti_bruteforce_active

    local anti_bruteforce_text = ("BRUTEFORCE[%s][%s][%s%%]"):format(
        anti_bruteforce_data.react_triggered_tick % 12, anti_bruteforce_data.current_phase_id, math.round(anti_bruteforce_data.reset_time % 10 * 10)
    )

    add_y = add_y + 9
    if is_rolling then
        Render.Text("EXPLOITING:", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font,true, false)
        Render.Text("z°", Vector2.new(screen_size.x / 2 + 50, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font,true, false)
    elseif is_anti_bruteforce_active then
        Render.Text("ANTI ", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, false)
        Render.Text(anti_bruteforce_text, Vector2.new(screen_size.x / 2 + 21, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, false)
    else
        local is_peeking = all_visual_functions.is_extrapolated_danger(my_index)
        if is_peeking then
            local my_simulation_time = my_index:GetProp("m_flSimulationTime")
            local current_ticks_value = all_visual_functions.get_tick_value(my_simulation_time) .. ""
            
            Render.Text("DEFENSIVE:", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, false)
            Render.Text(current_ticks_value, Vector2.new(screen_size.x / 2 + 47, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, false)
        else
            local tickbase = my_index:GetProp("m_nTickBase")
            local next_attack = my_index:GetProp("m_flNextAttack")
            local next_primary_attack = active_weapon:GetProp("m_flNextPrimaryAttack")

            local ticks = GlobalVars.interval_per_tick() * (tickbase - 16)
            local shifting_tickbase = math.floor(math.clamp((ticks - next_primary_attack) * 2, 3, 17))

            local inverter = AntiAim.GetInverterState()
            local current_fake = shifting_tickbase >= 10 and (
                shifting_tickbase % 2 == 0 and (inverter and shifting_tickbase % 4 == 0) and "A" or (shifting_tickbase % 6 == 0) and "V" or "N")
                or (inverter and (math.round(ticks) % 2 == 0 and "R" or "Q") or (math.round(ticks) % 4 == 0 and "L" or "P")
            )

            Render.Text("BODY", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(197, 122, 108, 255), 9, font, true, false)
            Render.Text(" YAW: ", Vector2.new(screen_size.x / 2 + 16, screen_size.y / 2 + add_y), Color.RGBA(197, 122, 108, 255), 9, font, true, false)
            Render.Text(current_fake, Vector2.new(screen_size.x / 2 + 40, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, false)
        end
    end

    add_y = add_y + 9
    Render.Text("DORMANCY:", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 201, 132, 255), 9, font,true, false)
    Render.Text(dormant_players, Vector2.new(screen_size.x / 2 + 45, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, false)

    local isDT = get_bind("Double Tap").state
    local isHS = get_bind("Hide Shots").state
    local isDMG = get_bind("Minimum Damage").state

    local doubletap_charge = Exploits.GetCharge()
    local charge_color = doubletap_charge == 1 and Color.RGBA(133, 235, 89, 255) or Color.RGBA(244, 11, 12, 255)

    table.insert(indicator_list, {text = isDT and "DT" or "", color = charge_color})
    table.insert(indicator_list, {text = isHS and "HS" or "", color = Color.RGBA(255, 211, 168, 255)})
    table.insert(indicator_list, {text = isDMG and "DMG" or "", color = Color.RGBA(255, 255, 255, 255)})

    for k, indicator in ipairs(indicator_list) do
        if indicator.text ~= nil and indicator.text ~= "" then
            add_y = add_y + 9
            Render.Text(indicator.text,Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), indicator.color, 9, font, true, false)
        end
    end
end

all_visual_functions.modern_style = function(my_index)
    local add_y = 35
    local desync_delta = all_visual_functions.get_local_delta(my_index, 0, false) .. ""

    local indicator_list = {}
    local font = all_visual_functions.smallest_pixel_font_9

    Render.Text(desync_delta, Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, true)
    Render.GradientBoxFilled(
        Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y + 8), Vector2.new(screen_size.x / 2 + (-math.abs(desync_delta * 58 / 100)), screen_size.y / 2 + add_y + 11),
        Color.RGBA(255, 255, 120, 255), Color.RGBA(0, 255, 153, 0), Color.RGBA(255, 255, 120, 255), Color.RGBA(0, 255, 153, 0)
    )

    Render.GradientBoxFilled(
        Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y + 8), Vector2.new(screen_size.x / 2 + (math.abs(desync_delta * 58 / 100)), screen_size.y / 2 + add_y + 11),
        Color.RGBA(255, 255, 120, 255), Color.RGBA(153, 0, 255, 0), Color.RGBA(255, 255, 120, 255), Color.RGBA(153, 0, 255, 0)
    )

    Render.Text("HA", Vector2.new(screen_size.x / 2 - 18, screen_size.y / 2 + add_y + 20), Color.RGBA(30, 251, 146, 255), 9, font, true, true)
    Render.Text("LF", Vector2.new(screen_size.x / 2 - 8, screen_size.y / 2 + add_y + 20), Color.RGBA(125, 251, 146, 255), 9, font, true, true)
    Render.Text("-", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y + 20), Color.RGBA(255, 199, 49, 255), 9, font, true, true)
    Render.Text("LI", Vector2.new(screen_size.x / 2 + 8, screen_size.y / 2 + add_y + 20), Color.RGBA(255, 150, 150, 255), 9, font, true, true)
    Render.Text("FE", Vector2.new(screen_size.x / 2 + 18, screen_size.y / 2 + add_y + 20), Color.RGBA(255, 120, 120, 255), 9, font, true, true)

    local isDT = get_bind("Double Tap").state
    local isHS = get_bind("Hide Shots").state
    local isDMG = get_bind("Minimum Damage").state

    local doubletap_charge = Exploits.GetCharge()
    local charge_color = doubletap_charge == 1 and Color.RGBA(126, 214, 136, 255) or Color.RGBA(226, 54, 55, 255)

    table.insert(indicator_list, {text = isDT and "DT" or "", color = charge_color})
    table.insert(indicator_list, {text = isHS and "HS" or "", color = Color.RGBA(255, 217, 116, 255)})
    table.insert(indicator_list, {text = isDMG and "DMG" or "", color = Color.RGBA(255, 255, 255, 255)})
    
    for k, indicator in ipairs(indicator_list) do
        if indicator.text ~= nil and indicator.text ~= "" then
            add_y = add_y + 9
            Render.Text(indicator.text,Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y + 20), indicator.color, 9, font, true, true)
        end
    end
end

all_visual_functions.legacy_style = function(my_index)
    local active_weapon = my_index:GetActiveWeapon()
    if not active_weapon then return end

    local add_y = 35
    local desync_delta = all_visual_functions.get_local_delta(my_index, 0, false) .. ""

    local indicator_list = {}
    local font = all_visual_functions.smallest_pixel_font_10

    local isDT = get_bind("Double Tap").state
    local isHS = get_bind("Hide Shots").state
    local isQP = get_bind("Auto Peek").state
    local isDMG = get_bind("Minimum Damage").state

    if isDT then
        local attack = my_index:GetProp("m_flNextAttack") + 0.25
        local primary_attack = active_weapon:GetProp("m_flNextPrimaryAttack") + 0.25

        local fraction = math.abs(GlobalVars.curtime() - math.max(attack, primary_attack))
        if fraction >= 1 then fraction = 1 end

        local doubletap_charge = Exploits.GetCharge()
        if doubletap_charge ~= 1 then
            Render.Circle(Vector2.new(screen_size.x / 2 + 10, screen_size.y / 2 + add_y + 19), 3, 60, Color.RGBA(190, 190, 190, 255), 2, 270, fraction * 640)
        end
    end

    table.insert(indicator_list, {text = desync_delta, color = Color.RGBA(190, 190, 190, 255)})
    table.insert(indicator_list, {text = isDT and "DT" or "", color = Color.RGBA(190, 190, 190, 255)})
    table.insert(indicator_list, {text = isHS and "ONSHOT" or "", color = Color.RGBA(190, 190, 190, 255)})
    table.insert(indicator_list, {text = isQP and "QP" or "", color = Color.RGBA(190, 190, 190, 255)})
    table.insert(indicator_list, {text = isDMG and "DMG" or "", color = Color.RGBA(190, 190, 190, 255)})

    Render.Text("HALF-LIFE", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(132, 193, 247, 255), 10, font, true, true)
    for k, indicator in ipairs(indicator_list) do
        if indicator.text ~= nil and indicator.text ~= "" then
            add_y = add_y + 9
            Render.Text(indicator.text,Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), indicator.color, 10, font, true, true)
        end
    end
end

all_visual_functions.pixeled_combo = {"AA STATE", "ROLL", "DT", "OS", "BAIM", "SAFE", "FREESTANDING", "QUICKPEEK"}
add_element(false, "Pixeled selector", Menu.MultiCombo("Half-Life: Visuals stuff", "Indicator list", "Pixeled selector", all_visual_functions.pixeled_combo, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 0)) ~= 0 and menu_database.elements["Crosshair style"] == 3
end)

add_element(true, "Pixeled main color", Menu.ColorEdit("Half-Life: Visuals stuff", "Indicator list", "Pixeled color", Color.RGBA(255, 255, 255, 255)), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 0)) ~= 0 and menu_database.elements["Crosshair style"] == 3
end)

all_visual_functions.pixeled_style = function(my_index)
    local add_y = 35
    local indicator_list = {}

    local inverter_state = AntiAim.GetInverterState()
    local font = all_visual_functions.smallest_pixel_font_10

    local first_color = Color.RGBA(255, 255, 255, 255)
    local second_color = Color.RGBA(255, 255, 255, 100)
    local main_color = menu_database.references["Pixeled main color"].reference:Get()

    Render.Text("HALF-", Vector2.new(screen_size.x / 2 - 8, screen_size.y / 2 + add_y), inverter_state and main_color or first_color, 10, font, true, true)
    Render.Text("LIFE", Vector2.new(screen_size.x / 2 + 15, screen_size.y / 2 + add_y), inverter_state and first_color or main_color, 10, font, true, true)

    local get_mode = function()
        local get_state = my_index:GetState()
        local current_state = get_state == "IN AIR" and "/AEROBIC/"or get_state == "SLOWWALKING" and "*BOSS AA*"
        or (get_state == "CROUCH T" or get_state == "CROUCH CT") and "/CROUCH/"
        or get_state == "MOVING" and "/RUNNING/" or "/T-34/"

        local current_color = current_state == "*BOSS AA*" and main_color or second_color
        return {state = current_state, color = current_color}
    end
    
    local state = get_mode()
    local is_rolling = all_anti_aim_functions.custom_anti_aim.is_rolling

    local is_enabled = function(value)
        return bit.band(menu_database.elements["Pixeled selector"], bit.lshift(1, value)) ~= 0
    end

    local isDT = get_bind("Double Tap").state
    local isHS = get_bind("Hide Shots").state
    local isQP = get_bind("Auto Peek").state
    local isBaim = get_bind("Body Aim").state
    local isSafe = get_bind("Safe Points").state
    local isDMG = get_bind("Minimum Damage").state
    local isFS = get_bind("Yaw Base").value == "Freestanding" or bind_system.list_of_directories["Yaw Base"]:Get() == 5
    
    table.insert(indicator_list, {text = is_enabled(0) and state.state or "", color = state.color})
    table.insert(indicator_list, {text = is_enabled(1) and is_rolling and "ROLL" or "", color = main_color})
    table.insert(indicator_list, {text = is_enabled(2) and "DT" or "", color = isDT and main_color or second_color})
    table.insert(indicator_list, {text = is_enabled(3) and "OS" or "", color = isHS and main_color or second_color})
    table.insert(indicator_list, {text = is_enabled(4) and "BAIM" or "", color = isBaim and main_color or second_color})
    table.insert(indicator_list, {text = is_enabled(5) and "SAFE" or "", color = isSafe and main_color or second_color})
    table.insert(indicator_list, {text = is_enabled(6) and "FREESTANDING" or "", color = isFS and main_color or second_color})
    table.insert(indicator_list, {text = is_enabled(7) and "QUICKPEEK" or "", color = isQP and main_color or second_color})

    for k, indicator in ipairs(indicator_list) do
        if indicator.text ~= nil and indicator.text ~= "" then
            add_y = add_y + 9
            Render.Text(indicator.text,Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), indicator.color, 10, font, true, true)
        end
    end
end

all_visual_functions.updated_style = function(my_index)
    local add_y = 60
    local indicator_list = {}

    local font = all_visual_functions.smallest_pixel_font_9
    local is_rolling = all_anti_aim_functions.custom_anti_aim.is_rolling
    local get_mode = function()
        local get_state = my_index:GetState()
        local current_state = (is_rolling and "*ROLL*" or get_state == "IN AIR" and "*AIR*"or get_state == "SLOWWALKING" and "*BOSS*"
            or (get_state == "CROUCH T" or get_state == "CROUCH CT") and "*CROUCH*"
            or get_state == "MOVING" and "*TANK*" or "*ADAPTIVE*"
        )

        return current_state
    end

    local state = get_mode()
    Render.Text("HALF-LIFE.LUA", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, true)

    add_y = add_y + 9
    Render.Text(state, Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), Color.RGBA(255, 115, 96, 255), 9, font, true, true)

    local inverter_state = AntiAim.GetInverterState()
    local desync_state = inverter_state and "R" or "L"

    add_y = add_y + 9
    Render.Text("FAKE", Vector2.new(screen_size.x / 2 - 10, screen_size.y / 2 + add_y), Color.RGBA(163, 199, 255, 255), 9, font, true, true)
    Render.Text(" YAW ", Vector2.new(screen_size.x / 2 + 10, screen_size.y / 2 + add_y), Color.RGBA(163, 199, 255, 255), 9, font, true, true)
    Render.Text(desync_state, Vector2.new(screen_size.x / 2 + 23, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 9, font, true, true)

    local isDT = get_bind("Double Tap").state
    if isDT then
        local doubletap_charge = Exploits.GetCharge()
        local charge_color = doubletap_charge == 1 and Color.RGBA(126, 214, 136, 255) or Color.RGBA(226, 54, 55, 255)

        add_y = add_y + 9
        Render.Text("DT", Vector2.new(screen_size.x / 2, screen_size.y / 2 + add_y), charge_color, 9, font, true, true)
    end
end

all_visual_functions.setup_under_crosshair_indicator = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 0)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local directory = menu_database.elements["Crosshair style"]
        if directory == 0 then
            all_visual_functions.default_style(my_index)
        end

        if directory == 1 then
            all_visual_functions.modern_style(my_index)
        end

        if directory == 2 then
            all_visual_functions.legacy_style(my_index)
        end

        if directory == 3 then
            all_visual_functions.pixeled_style(my_index)
        end

        if directory == 4 then
            all_visual_functions.updated_style(my_index)
        end
    end
end

all_visual_functions.verdana_11 = register_font("Verdana", 11)
all_visual_functions.anti_aim_debugger = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 1)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local font = all_visual_functions.verdana_11
        local add_x, add_y = screen_size.x / 2 - (screen_size.x / 2 - 85), screen_size.y / 2 - 35

        local user_data = ("[half-life.lua debug],[user - %s]"):format(Cheat.GetCheatUserName())
        local calculated_text_size = Render.CalcTextSize(user_data, 11, font)

        draw_shadow(1, user_data, add_x, add_y, Color.RGBA(255, 255, 255, 255), 11, font, false, Color.RGBA(0, 0, 0, 255))
        Render.BoxFilled(Vector2.new(add_x, add_y + 15), Vector2.new(calculated_text_size.x + 85, add_y + 17), Color.RGBA(201, 175, 238, 255))

        local pixeled_font = all_visual_functions.smallest_pixel_font_9
        local is_rolling = all_anti_aim_functions.custom_anti_aim.is_rolling

        local current_state = my_index:GetState()
        local desync_delta = all_visual_functions.get_local_delta(my_index, 0, true)

        local anti_aim_mode = ("[PLAYER]ANTI-AIM.MODE:%s"):format(is_rolling and "EXTENDED" or (current_state == "STANDING" or current_state == "SLOWWALK") and "SAFE" or "TANK")
        local desync_mode = ("[PLAYER]BODY-YAW:%d°"):format(desync_delta)

        Render.Text(anti_aim_mode, Vector2.new(add_x + 20, add_y + 20), Color.RGBA(255, 255, 255, 255), 9, pixeled_font, true, false)
        Render.Text(desync_mode, Vector2.new(add_x + 20, add_y + 30), Color.RGBA(255, 255, 255, 255), 9, pixeled_font, true, false)
    end
end

all_visual_functions.damage_positions =  {"Bottom Left", "Bottom Right", "Top Right", "Top Left", "Middle", "Far Left", "Far Right", "Far Up"}
add_element(false, "Minimum damage position", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Damage position", all_visual_functions.damage_positions, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 2)) ~= 0
end)

all_visual_functions.damage_indicator = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 2)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local font = all_visual_functions.smallest_pixel_font_10
        local position = menu_database.elements["Minimum damage position"]
        local minimum_damage = bind_system.list_of_directories.default_damage:GetInt()

        local damage_text = minimum_damage == 0 and "AUTO" or tostring(minimum_damage)
        local calculated_text_size = Render.CalcTextSize(damage_text, 10, font)

        local y_position_list = {10, 10, -30, -30, -30, -55, -55, -55}
        local x_position_list = {calculated_text_size.x / 2 + 5, -15, -55, 55, 0, 45, -45, 0}

        local add_y = y_position_list[position + 1]
        local add_x = x_position_list[position + 1]

        Render.Text(damage_text, Vector2.new(screen_size.x / 2 - add_x, screen_size.y / 2 + add_y), Color.RGBA(255, 255, 255, 255), 10, font, true, true)
    end
end

add_element(false, "Autopeek type", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Autopeek type", {"Default", "Quick peek"}, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 3)) ~= 0
end)

add_element(true, "Autopeek color", Menu.ColorEdit("Half-Life: Visuals stuff", "Indicator list", "Autopeek color", Color.RGBA(255, 255, 255, 255)), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 3)) ~= 0
end)

all_visual_functions.default_autopeek_origin = Vector.new(0, 0, 0)
all_visual_functions.skeet_autopeek = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 3)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local isAutopeek = get_bind("Auto Peek").state
        if not isAutopeek then
            all_visual_functions.default_autopeek_origin = my_index:GetOrigin()
        end

        if isAutopeek then
            local color = menu_database.references["Autopeek color"].reference:Get()
            color.a = color.a / 50

            for i = 1, 45 do
                Render.Circle3DFilled(all_visual_functions.default_autopeek_origin, 60, i / 2, color, false)
            end
        end
    end
end

all_visual_functions.set_direction = function(cmd, my_index, speed, current_x_position, current_y_position)
    local self_origin = my_index:GetOrigin()
    local self_view_angles = EngineClient.GetViewAngles()
    
    local yaw = self_view_angles.yaw
    local vector_forward = {x = self_origin.x - current_x_position, y = self_origin.y - current_y_position}
    local velocity = {
        x = -(vector_forward.x * math.cos(yaw / 180 * math.pi) + vector_forward.y * math.sin(yaw / 180 * math.pi)),
        y = vector_forward.y * math.cos(yaw / 180 * math.pi) - vector_forward.x * math.sin(yaw / 180 * math.pi),
    }

    cmd.forwardmove = speed < 3 and velocity.x * 1 or velocity.x * 15
    cmd.sidemove = speed < 3 and velocity.y * 1 or velocity.y * 15
end

all_visual_functions.quick_peek = function(cmd)
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 3)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local autopeek_type = menu_database.elements["Autopeek type"]
        if autopeek_type == 1 then
            local current_state = my_index:GetState()
            local current_velocity = my_index:GetVelocity()

            local is_moving = (
                bit.band(cmd.buttons, button_states.IN_FORWARD) > 0 or
                bit.band(cmd.buttons, button_states.IN_BACK) > 0 or
                bit.band(cmd.buttons, button_states.IN_LEFT) > 0 or
                bit.band(cmd.buttons, button_states.IN_RIGHT) > 0
            )

            local default_origin = my_index:GetOrigin()
            local isAutopeek = get_bind("Auto Peek").state

            local origin_data = all_visual_functions.default_autopeek_origin
            local is_in_air = current_state == "IN AIR" or current_state == "IN CROUCH AIR"

            if not is_in_air and not is_moving and isAutopeek then
                if origin_data.x ~= default_origin.x and origin_data.y ~= default_origin.y then
                    all_visual_functions.set_direction(cmd, my_index, current_velocity, origin_data.x, origin_data.y)
                end
            end
        end
    end
end

all_visual_functions.skeet_elements = {
    "AA With Circle", "Shot/Miss Percent", "FL Text indicator", "Body Aim", "Exploit", "Damage", "Dormant Aimbot", "Fake Ping", "Lag Compensation", "Fake Duck", "Bomb Info", "Double Tap"
}

add_element(false, "Skeet indicator elements", Menu.MultiCombo("Half-Life: Visuals stuff", "Indicator list", "Indicator elements", all_visual_functions.skeet_elements, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 4)) ~= 0
end)

add_element(false, "Hit/miss type", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Hit/miss type", {"Style 1", "Style 2"}, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 4)) ~= 0
    and bit.band(menu_database.elements["Skeet indicator elements"], bit.lshift(1, 1)) ~= 0
end)

add_element(false, "Damage type", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Damage type", {"Damage: ", "DMG", "Damage value"}, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 4)) ~= 0
    and bit.band(menu_database.elements["Skeet indicator elements"], bit.lshift(1, 5)) ~= 0
end)

all_visual_functions.calibri_30_bold = register_font("Calibri", 30, {"b"})
all_visual_functions.render_skeet_indicator = function(text, color, add_y)
    local back_alpha = 65
    local x, y = screen_size.x / 100 - 3, screen_size.y / 1.50 - 5

    local font = all_visual_functions.calibri_30_bold
    local text_size = Render.CalcTextSize(text, 22, font)
    
    Render.GradientBoxFilled(
        Vector2.new(13, y + add_y), Vector2.new(13 + text_size.x / 2, y + add_y + 28),
        Color.RGBA(0, 0, 0, 0), Color.RGBA(0, 0, 0, back_alpha), Color.RGBA(0, 0, 0, 0), Color.RGBA(0, 0, 0, back_alpha)
    )

    Render.GradientBoxFilled(
        Vector2.new(13 + text_size.x / 2, y + add_y), Vector2.new(13 + text_size.x, y + add_y + 28),
        Color.RGBA(0, 0, 0, back_alpha), Color.RGBA(0, 0, 0, 0), Color.RGBA(0, 0, 0, back_alpha), Color.RGBA(0, 0, 0, 0)
    )

    draw_shadow(2, text, x + 4, y + add_y + 4, color, 23, font, false, Color.RGBA(0, 0, 0, 170))
end

all_visual_functions.render_circle = function(text, x_position, y_position, add_y, size, color, value)
    local font = all_visual_functions.calibri_30_bold
    local text_size = Render.CalcTextSize(text, 22, font)
    local x, y = screen_size.x / 100 - 3, screen_size.y / 1.50 - 5

    Render.Circle(Vector2.new(x + text_size.x + x_position + 5, y + add_y + text_size.y / 2 + y_position + 3), size + 1, 60, Color.RGBA(0, 0, 0, 255), 3)
    Render.Circle(Vector2.new(x + text_size.x + x_position + 5, y + add_y + text_size.y / 2 + y_position + 3), size + 0, 60, color, 4, 0, value)
end

all_visual_functions.skeet_data = {}
all_visual_functions.skeet_data.fakelag = {fakelag_1 = 0, fakelag_2 = 0, fakelag_3 = 0, fakelag_4 = 0, fakelag_5 = 0, old_choke = 0}
all_visual_functions.skeet_data.fake = {smooth_fill = 0}

all_visual_functions.skeet_data.shot_stats = {}
all_visual_functions.skeet_data.shot_stats.data = {hits = 0, misses = 0, all_shots = 0}
all_visual_functions.skeet_data.shot_stats.count_shots = function(shot)
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 4)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        if bit.band(menu_database.elements["Skeet indicator elements"], bit.lshift(1, 0)) ~= 0 then
            local data = all_visual_functions.skeet_data.shot_stats.data
            if shot.reason == 0 then
                data.hits = data.hits + 1
            else
                data.misses = data.misses + 1
            end

            data.all_shots = data.all_shots + 1
        end
    end
end

all_visual_functions.get_fakelag_state = function()
    local self_chocking = ClientState.m_choked_commands()
    if self_chocking < all_visual_functions.skeet_data.fakelag.old_choke then
        all_visual_functions.skeet_data.fakelag.fakelag_1 = all_visual_functions.skeet_data.fakelag.fakelag_2
        all_visual_functions.skeet_data.fakelag.fakelag_2 = all_visual_functions.skeet_data.fakelag.fakelag_3
        all_visual_functions.skeet_data.fakelag.fakelag_3 = all_visual_functions.skeet_data.fakelag.fakelag_4
        all_visual_functions.skeet_data.fakelag.fakelag_4 = all_visual_functions.skeet_data.fakelag.fakelag_5
        all_visual_functions.skeet_data.fakelag.fakelag_5 = all_visual_functions.skeet_data.fakelag.old_choke
    end

    all_visual_functions.skeet_data.fakelag.old_choke = self_chocking
    return ("%i-%i-%i-%i-%i"):format(
        all_visual_functions.skeet_data.fakelag.fakelag_1,
        all_visual_functions.skeet_data.fakelag.fakelag_2,
        all_visual_functions.skeet_data.fakelag.fakelag_3,
        all_visual_functions.skeet_data.fakelag.fakelag_4,
        all_visual_functions.skeet_data.fakelag.fakelag_5
    )
end

all_visual_functions.get_ping_color = function()
    local player_resource = EntityList.GetPlayerResource()
    local ping = player_resource:GetProp("m_iPing")[2]

    local color = Color.RGBA(math.floor(255 - ((ping / 189 * 60) * 2.29824561404)), math.floor((ping / 189 * 60) * 2.42105263158), math.floor((ping / 189 * 60) * 0.22807017543), 255)
    return color
end

all_visual_functions.skeet_data.lag_compensation = {}
all_visual_functions.skeet_data.lag_compensation.is_lagging = false
all_visual_functions.skeet_data.lag_compensation.timer = GlobalVars.curtime()

all_visual_functions.skeet_data.bomb_data = {}
all_visual_functions.skeet_data.bomb_data.vars = {
    bombsite = -1,
    is_defusing = false,
    is_planting = false,
    plant_time = 0
}

all_visual_functions.skeet_data.bomb_data.vars.on_begin_plant = function(event)
    if event:GetName() ~= "bomb_beginplant" then return end

    all_visual_functions.skeet_data.bomb_data.vars.bombsite = event:GetInt("site")
    all_visual_functions.skeet_data.bomb_data.vars.is_planting = true
    all_visual_functions.skeet_data.bomb_data.vars.plant_time = GlobalVars.curtime()
end

all_visual_functions.skeet_data.bomb_data.vars.on_bomb_plant = function(event)
    if event:GetName() ~= "bomb_planted" then return end

    all_visual_functions.skeet_data.bomb_data.vars.bombsite = -1
    all_visual_functions.skeet_data.bomb_data.vars.is_planting = false
end

all_visual_functions.skeet_data.bomb_data.vars.on_abort_plant = function(event)
    if event:GetName() ~= "bomb_abortplant" then return end

    all_visual_functions.skeet_data.bomb_data.vars.bombsite = -1
    all_visual_functions.skeet_data.bomb_data.vars.is_planting = false
end

all_visual_functions.skeet_data.bomb_data.vars.on_defusing = function(event)
    if event:GetName() ~= "bomb_begindefuse" then return end

    all_visual_functions.skeet_data.bomb_data.vars.is_defusing = true
end

all_visual_functions.skeet_data.bomb_data.vars.on_abort_defusing = function(event)
    if event:GetName() ~= "bomb_abortdefuse" then return end
    
    all_visual_functions.skeet_data.bomb_data.vars.is_defusing = false
end

all_visual_functions.skeet_data.bomb_data.vars.on_round_prestart = function(event)
    if event:GetName() ~= "round_prestart" then return end

    all_visual_functions.skeet_data.bomb_data.vars.bombsite = -1
    all_visual_functions.skeet_data.bomb_data.vars.is_defusing = false
    all_visual_functions.skeet_data.bomb_data.vars.is_planting = false
    all_visual_functions.skeet_data.bomb_data.vars.plant_time = 0
end

all_visual_functions.skeet_data.bomb_data.vars.on_self_connected = function(event)
    if event:GetName() ~= "player_connect_full" then return end

    all_visual_functions.skeet_data.bomb_data.vars.plant_time = 0
    local c4 = EntityList.GetEntitiesByClassID(129)[1]

    if not c4 then
        all_visual_functions.skeet_data.bomb_data.vars.bombsite = -1
        all_visual_functions.skeet_data.bomb_data.vars.is_planting = false
    else
        all_visual_functions.skeet_data.bomb_data.vars.is_planting = true
        all_visual_functions.skeet_data.bomb_data.vars.bombsite = c4:GetProp("m_nBombSite")
    end
end

all_visual_functions.skeet_data.bomb_data.vars.load_bomb_modules = function(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_begin_plant(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_bomb_plant(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_abort_plant(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_round_prestart(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_defusing(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_abort_defusing(event)
    all_visual_functions.skeet_data.bomb_data.vars.on_self_connected(event)
end

all_visual_functions.skeet_indicators = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 4)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local render_circle = all_visual_functions.render_circle
        local render_indicator = all_visual_functions.render_skeet_indicator

        local indicator_list = {}
        local is_enabled = function(value)
            return bit.band(menu_database.elements["Skeet indicator elements"], bit.lshift(1, value)) ~= 0
        end

        local data = all_visual_functions.skeet_data
        local desync_delta = all_visual_functions.get_local_delta(my_index, 0, true)

        data.fake.smooth_fill = math.lerp(data.fake.smooth_fill, desync_delta, GlobalVars.frametime() * 5)
        local fake_color = all_visual_functions.get_condition_color(data.fake.smooth_fill / 60)

        table.insert(indicator_list, {
            type = "circle",

            fl_text = "FAKE",
            fl_color = fake_color,

            x_pos = is_enabled(0) and 15 or "",
            y_pos = 0,
            size = 7,
            color = fake_color,
            value = data.fake.smooth_fill * 6.4
        })
        
        if is_enabled(1) then
            local hits = data.shot_stats.data.hits
            local misses = data.shot_stats.data.misses
            local all_shots = data.shot_stats.data.all_shots

            local selected_style = menu_database.elements["Hit/miss type"]
            if selected_style == 0 then
                if all_shots > 0 then
                    local result_stats = ("%.1f"):format((hits / all_shots) * 100)
                    local result_text = ("%s/%s (%s)"):format(hits, all_shots, result_stats)

                    table.insert(indicator_list, {
                        type = "text",
                        text = result_text,
                        color = Color.RGBA(255, 255, 255, 255) 
                    })
                end
            else
                local hard_math = math.floor((hits / all_shots) * 100)
                if hard_math ~= hard_math then -- watafak
                    hard_math = 100
                end

                local result_stats = ("%s%%"):format(hard_math)
                local result_text = ("%s/%s"):format(misses, result_stats)

                table.insert(indicator_list, {
                    type = "text",
                    text = result_text,
                    color = Color.RGBA(255, 255, 255, 255) 
                })
            end
        end

        local fakelag_data = all_visual_functions.get_fakelag_state()
        table.insert(indicator_list, {
            type = "text",
            text = is_enabled(2) and fakelag_data or "",
            color = Color.RGBA(255, 255, 255, 255)
        })

        local isDT = get_bind("Double Tap").state
        local isBaim = get_bind("Body Aim").state
        local isFD = get_bind("Fake Duck").state
        local isPing = get_bind("Fake Ping").state

        local isDMG = get_bind("Minimum Damage").state
        local curDMG = get_bind("Minimum Damage").value

        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(3) and isBaim) and "BODY" or "",
            color = Color.RGBA(255, 255, 255, 255)
        })

        local current_state = my_index:GetState()
        local is_in_air = current_state == "IN AIR" or current_state == "IN CROUCH AIR"

        table.insert(indicator_list, {
            type = "text",
            text = is_enabled(4) and "EX" or "",
            color = (isDT and is_in_air) and Color.RGBA(132, 195, 16, 255) or Color.RGBA(208, 208, 20, 255)
        })

        local damage_type = menu_database.elements["Damage type"]
        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(5) and isDMG) and (damage_type == 0 and ("Damage: %s"):format(curDMG) or damage_type == 1 and ("DMG: %s"):format(curDMG) or damage_type == 2 and tostring(curDMG) or "") or "",
            color = (damage_type == 0 and Color.RGBA(255, 255, 255, 255) or damage_type == 1 and Color.RGBA(255, 255, 255, 150) or Color.RGBA(255, 255, 255, 255))
        })

        local isDA = menu_database.elements["Enable dormant aimbot"]
        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(6) and isDA) and "DA" or "",
            color = Color.RGBA(132, 195, 16, 255)
        })

        local ping_color = all_visual_functions.get_ping_color()
        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(7) and isPing) and "PING" or "",
            color = ping_color
        })

        if is_in_air then
            data.lag_compensation.is_lagging = true
            data.lag_compensation.timer = GlobalVars.curtime() + 0.1
        else
            if data.lag_compensation.timer > GlobalVars.curtime() then
                data.lag_compensation.is_lagging = true
            else
                data.lag_compensation.is_lagging = false
            end
        end

        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(8) and data.lag_compensation.is_lagging) and "LC" or "",
            color = my_index:GetVelocity() < 285 and Color.RGBA(255, 0, 0, 255) or Color.RGBA(132, 195, 16, 255)
        })

        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(9) and isFD) and "DUCK" or "",
            color = Color.RGBA(255, 255, 255, 255)
        })

        if is_enabled(10) then
            local c4 = EntityList.GetEntitiesByClassID(129)[1]
            if c4 then
                if c4:GetProp("m_bBombTicking") and not c4:GetProp("m_bBombDefused") then
                    local get_damage = function()
                        local damagePercentage = 1
                        local flDamage = 500

                        local bomb_origin = c4:GetOrigin()
                        local self_origin = my_index:GetOrigin()
                        local flDistanceToLocalPlayer = self_origin:DistTo(bomb_origin)

                        local fGaussianFalloff = math.exp(-flDistanceToLocalPlayer * flDistanceToLocalPlayer / (2 * flDamage * flDamage))
                        local flAdjustedDamage = flDamage * fGaussianFalloff * damagePercentage

                        local scaleDamageArmor = function(flDamage, armor_value)
                            local flArmorRatio = 0.5
                            local flArmorBonus = 0.5

                            if armor_value > 0 then
                                local flNew = flDamage * flArmorRatio
                                local flArmor = (flDamage - flNew) * flArmorBonus

                                if flArmor > armor_value then
                                    flArmor = armor_value * (1 / flArmorBonus)
                                    flNew = flDamage - flArmor
                                end

                                flDamage = flNew
                            end

                            return flDamage
                        end
                        
                        local armor_value = my_index:GetProp("m_ArmorValue")
                        local self_health = my_index:GetHealth()

                        flAdjustedDamage = scaleDamageArmor(flAdjustedDamage, armor_value)
                        local text = math.round(flAdjustedDamage) >= self_health and "FATAL" or ("-%s HP"):format(math.round(flAdjustedDamage))
                        local color = math.round(flAdjustedDamage) >= self_health and Color.RGBA(255, 0, 0, 255) or Color.RGBA(210, 216, 112, 255)

                        return {text = text, color = color}
                    end

                    local timer = c4:GetProp("m_flC4Blow") - GlobalVars.curtime()
                    local bomb_data = get_damage()
                    local current_site = data.bomb_data.vars.bombsite % 2 == 1 and "B" or "A"

                    if timer > 0.1 then
                        local plant_info = ("%s - %ss"):format(current_site, ("%.1f"):format(timer))
                        table.insert(indicator_list, {
                            type = "text",
                            text = plant_info,
                            color = Color.RGBA(255, 255, 255, 255)
                        })

                        table.insert(indicator_list, {
                            type = "text",
                            text = bomb_data.text,
                            color = bomb_data.color
                        })

                        if data.bomb_data.vars.is_defusing then
                            local defuse_timer = c4:GetProp("m_flDefuseCountDown") - GlobalVars.curtime()
                            local defuse_length = c4:GetProp("m_flDefuseLength")

                            local defuse_bar_length = ((screen_size.y - 50) / defuse_length) * defuse_timer
                            local bar_color = timer > defuse_length and Color.RGBA(58, 191, 54, 120) or Color.RGBA(252, 18, 19, 120)

                            Render.BoxFilled(Vector2.new(0, 0), Vector2.new(10, screen_size.y), Color.RGBA(25, 25, 25, 120))
                            Render.BoxFilled(Vector2.new(0, screen_size.y - defuse_bar_length), Vector2.new(10, screen_size.y), bar_color)
                            Render.Box(Vector2.new(0, 0), Vector2.new(10, screen_size.y), Color.RGBA(25, 25, 25, 120))
                        end
                    end
                end
            end

            if data.bomb_data.vars.is_planting then
                local current_site = data.bomb_data.vars.bombsite % 2 == 1 and "B" or "A"
                local frac = math.clamp(3.125 - (3.125 + data.bomb_data.vars.plant_time - GlobalVars.curtime()), 0, 3.125)

                table.insert(indicator_list, {
                    type = "circle",

                    fl_text = ("Bombsite %s"):format(current_site),
                    fl_color = Color.RGBA(234, 209, 138, 255),

                    x_pos = 16,
                    y_pos = 0,
                    size = 8,
                    color = Color.RGBA(255, 255, 255, 255),
                    value = (frac / 3.3) * 360
                })
            end
        end

        local doubletap_charge = Exploits.GetCharge()
        local charge_color = Exploits.GetCharge() == 1 and Color.RGBA(255, 255, 255, 255) or Color.RGBA(255, 0, 0, 255)

        table.insert(indicator_list, {
            type = "text",
            text = (is_enabled(11) and isDT) and "DT" or "",
            color = charge_color
        })

        local add_y = 50
        for k, indicator in ipairs(indicator_list) do
            if indicator.type == "text" then
                if indicator.text ~= nil and indicator.text ~= "" then
                    render_indicator(indicator.text, indicator.color, add_y)
                end
            end

            if indicator.type == "circle" then
                if indicator.x_pos ~= "" then
                    render_indicator(indicator.fl_text, indicator.fl_color, add_y)
                    render_circle(indicator.fl_text, indicator.x_pos, indicator.y_pos, add_y, indicator.size, indicator.color, indicator.value)
                end
            end

            if (indicator.text ~= nil and indicator.text ~= "") or (indicator.type == "circle" and indicator.x_pos ~= "") then
                add_y = add_y - 35
            end
        end
    end
end

all_visual_functions.disable_animation_on_3rd_person = function(stage)
    if stage ~= 6 then
        return
    end

    Cheat.SetThirdPersonAnim(true)

    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 5)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        Cheat.SetThirdPersonAnim(false)
    end
end

all_visual_functions.hitmarker_data = {}
all_visual_functions.register_hitmarker = function(shot)
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 6)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        if shot.reason == 0 then
            table.insert(all_visual_functions.hitmarker_data, {timer = GlobalVars.realtime(), alpha = 0})
        end
    end
end

add_element(true, "Crosshair hitmarker color", Menu.ColorEdit("Half-Life: Visuals stuff", "Indicator list", "Crosshair color", Color.RGBA(255, 255, 255, 255)), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 6)) ~= 0
end)

all_visual_functions.crosshair_hitmarker = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 6)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        for i, info in ipairs(all_visual_functions.hitmarker_data) do
            if info.timer + 0.5 < GlobalVars.realtime() then
                info.alpha = math.lerp(info.alpha, 0, GlobalVars.frametime() * 15)
            else
                info.alpha = math.lerp(info.alpha, 255, GlobalVars.frametime() * 15)
            end

            local alpha = math.round(info.alpha)
            local color = menu_database.references["Crosshair hitmarker color"].reference:Get()

            Render.Line(Vector2.new(screen_size.x / 2 - 5, screen_size.y / 2 - 5), Vector2.new(screen_size.x / 2 - 10, screen_size.y / 2 - 10), Color.new(color.r, color.g, color.b, alpha / 200))
            Render.Line(Vector2.new(screen_size.x / 2 + 5, screen_size.y / 2 - 5), Vector2.new(screen_size.x / 2 + 10, screen_size.y / 2 - 10), Color.new(color.r, color.g, color.b, alpha / 200))
            Render.Line(Vector2.new(screen_size.x / 2 + 5, screen_size.y / 2 + 5), Vector2.new(screen_size.x / 2 + 10, screen_size.y / 2 + 10), Color.new(color.r, color.g, color.b, alpha / 200))
            Render.Line(Vector2.new(screen_size.x / 2 - 5, screen_size.y / 2 + 5), Vector2.new(screen_size.x / 2 - 10, screen_size.y / 2 + 10), Color.new(color.r, color.g, color.b, alpha / 200))

            if info.timer + 1.5 < GlobalVars.realtime() then
                table.remove(all_visual_functions.hitmarker_data, i)
            end
        end
    end
end

add_element(false, "Notifications type", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Notifications type", {"Static", "Gradient"}, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 7)) ~= 0
end)

add_element(true, "Notifications color", Menu.ColorEdit("Half-Life: Visuals stuff", "Indicator list", "Notifications color", Color.RGBA(255, 255, 255, 255)), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 7)) ~= 0 and menu_database.elements["Notifications type"] == 0
end)

all_visual_functions.on_getting_damage = function(event)
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 7)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        if event:GetName() ~= "player_hurt" then
            return
        end

        local victim = EntityList.GetPlayerForUserID(event:GetInt("userid"))
        local attacker = EntityList.GetPlayerForUserID(event:GetInt("attacker"))
        if victim == attacker or attacker == my_index then return end

        table.insert(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.sauron_text, {
            text = "Switched side due to hit",

            timer = GlobalVars.realtime(),
            smooth_y = screen_size.y + 100,
            alpha = 0,

            first_circle = 0,
            second_circle = 0,

            box_left = screen_size.x / 2,
            box_right = screen_size.x / 2,

            box_left_1 = screen_size.x / 2,
            box_right_1 = screen_size.x / 2
        })
    end
end

all_visual_functions.verdana_12 = register_font("Verdana", 12)
all_visual_functions.hsv_to_rgb = function(h, s, v)
    local r, g, b

    local i = math.floor(h * 6);
    local f = h * 6 - i;
    local p = v * (1 - s);
    local q = v * (1 - f * s);
    local t = v * (1 - (1 - f) * s);

    i = i % 6

    if i == 0 then r, g, b = v, t, p
    elseif i == 1 then r, g, b = q, v, p
    elseif i == 2 then r, g, b = p, v, t
    elseif i == 3 then r, g, b = p, q, v
    elseif i == 4 then r, g, b = t, p, v
    elseif i == 5 then r, g, b = v, p, q
    end

    return Color.new(r, g, b)
end

all_visual_functions.notifications = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 7)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local y = screen_size.y - 100
        local data = all_anti_aim_functions.custom_anti_aim.anti_bruteforce.sauron_text

        for i, info in ipairs(data) do
            if i > 3 then
                table.remove(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.sauron_text, i)
            end

            if info.text ~= nil and info.text ~= "" then
                local font = all_visual_functions.verdana_12
                local text_size = Render.CalcTextSize(info.text, 12, font)

                if info.timer + 3.8 < GlobalVars.realtime() then
                    info.first_circle = math.lerp(info.first_circle, 0, GlobalVars.frametime() * 1)
                    info.second_circle = math.lerp(info.second_circle, 0, GlobalVars.frametime() * 1)
    
                    info.box_left = math.lerp(info.box_left, screen_size.x / 2, GlobalVars.frametime() * 1)
                    info.box_right = math.lerp(info.box_right, screen_size.x / 2, GlobalVars.frametime() * 1)
    
                    info.box_left_1 = math.lerp(info.box_left_1, screen_size.x / 2, GlobalVars.frametime() * 1)
                    info.box_right_1 = math.lerp(info.box_right_1, screen_size.x / 2, GlobalVars.frametime() * 1)

                    info.smooth_y = math.lerp(info.smooth_y, screen_size.y + 100, GlobalVars.frametime() * 2)
                    info.alpha = math.lerp(info.alpha, 0, GlobalVars.frametime() * 4)
                else
                    info.first_circle = math.lerp(info.first_circle, 275, GlobalVars.frametime() * 5)
                    info.second_circle = math.lerp(info.second_circle, -95, GlobalVars.frametime() * 3)

                    info.box_left = math.lerp(info.box_left, screen_size.x / 2 - text_size.x / 2 - 2, GlobalVars.frametime() * 6)
                    info.box_right = math.lerp(info.box_right, screen_size.x / 2 + text_size.x / 2 + 4, GlobalVars.frametime() * 6)

                    info.box_left_1 = math.lerp(info.box_left_1, screen_size.x / 2 - text_size.x / 2 - 2, GlobalVars.frametime() * 6)
                    info.box_right_1 = math.lerp(info.box_right_1, screen_size.x / 2 + text_size.x / 2 + 4, GlobalVars.frametime() * 6)

                    info.alpha = math.lerp(info.alpha, 255, GlobalVars.frametime() * 4)
                    info.smooth_y = math.lerp(info.smooth_y, y, GlobalVars.frametime() * 4)
                end

                local alpha = math.round(info.alpha)
                local add_y = math.round(info.smooth_y)

                local first_circle = math.round(info.first_circle)
                local second_circle = math.round(info.second_circle)

                local left_box = math.round(info.box_left)
                local right_box = math.round(info.box_right)

                local left_box_1 = math.round(info.box_left_1)
                local right_box_1 = math.round(info.box_right_1)

                local rgb = all_visual_functions.hsv_to_rgb(GlobalVars.realtime() / 4, 1, 1)
                local second_gradient = Color.new(rgb.b, rgb.r, rgb.g, 1)
                local third_gradient = Color.new(rgb.g, rgb.b, rgb.r, 1)

                local notifications_type = menu_database.elements["Notifications type"]
                local notifications_color = menu_database.references["Notifications color"].reference:Get()

                Render.BoxFilled(Vector2.new(screen_size.x / 2 - text_size.x / 2 - 13, add_y - 26), Vector2.new(screen_size.x / 2 + text_size.x / 2 + 13, add_y - 4), Color.RGBA(17, 17, 17, alpha - 65), 90)
                Render.Circle(Vector2.new(screen_size.x / 2 - text_size.x / 2 - 4, add_y - 15), 10, 90, notifications_type == 0 and notifications_color or second_gradient, 2, 90, first_circle)
                Render.Circle(Vector2.new(screen_size.x / 2 + text_size.x / 2 + 4, add_y - 15), 10, 90, notifications_type == 0 and notifications_color or third_gradient, 2, 90, second_circle)

                if notifications_type == 0 then
                    for k = 1, 2 do
                        Render.BoxFilled(Vector2.new(left_box - 4, add_y - 6), Vector2.new(screen_size.x / 2, add_y - 4.5), notifications_color)
                        Render.BoxFilled(Vector2.new(right_box + 4, add_y - 6), Vector2.new(screen_size.x / 2, add_y - 4.5), notifications_color)
                        
                        Render.BoxFilled(Vector2.new(screen_size.x / 2, add_y - 24), Vector2.new(left_box_1 - 2, add_y - 26), notifications_color)
                        Render.BoxFilled(Vector2.new(screen_size.x / 2, add_y - 24), Vector2.new(right_box_1 + 2, add_y - 26), notifications_color)
                    end
                else
                    for k = 1, 2 do
                        Render.GradientBoxFilled(Vector2.new(left_box - 4, add_y - 6), Vector2.new(screen_size.x / 2, add_y - 4.5), second_gradient, second_gradient, second_gradient, second_gradient)
                        Render.GradientBoxFilled(Vector2.new(right_box + 4, add_y - 6), Vector2.new(screen_size.x / 2, add_y - 4.5), third_gradient, second_gradient, third_gradient, second_gradient)
                        
                        Render.GradientBoxFilled(Vector2.new(screen_size.x / 2, add_y - 24), Vector2.new(left_box_1 - 2, add_y - 26), second_gradient, second_gradient, second_gradient, second_gradient)
                        Render.GradientBoxFilled(Vector2.new(screen_size.x / 2, add_y - 24), Vector2.new(right_box_1 + 2, add_y - 26), second_gradient, third_gradient, second_gradient, third_gradient)
                    end
                end

                draw_shadow(0, info.text, screen_size.x / 2 - text_size.x / 2, add_y - 21, Color.RGBA(255, 255, 255, alpha), 12, font, false, Color.RGBA(0, 0, 0, alpha))
                y = y - 30

                if info.timer + 4 < GlobalVars.realtime() then
                    table.remove(all_anti_aim_functions.custom_anti_aim.anti_bruteforce.sauron_text, i)
                end
            end
        end
    end
end

add_element(false, "Hitmarker mode", Menu.Combo("Half-Life: Visuals stuff", "Indicator list", "Hitmarker mode", {"+", "x"}, 0), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) ~= 0
end)

add_element(true, "Hitmarker color", Menu.ColorEdit("Half-Life: Visuals stuff", "Indicator list", "Hitmarker color", Color.RGBA(255, 255, 255, 255)), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) ~= 0
end)

add_element(false, "Hitmarker size", Menu.SliderInt("Half-Life: Visuals stuff", "Indicator list", "Hitmarker size", 1, 4, 10), function()
    return menu_database.elements["Enable indicator list"] and bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) ~= 0
end)

all_visual_functions.damage_marker_data = {
    particles = {},
    hitmarkers = {}
}

all_visual_functions.register_damage_marker = function(shot)
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local index = EntityList.GetClientEntity(shot.target_index)
        if not index then return end

        local get_player = index:GetPlayer()
        if not get_player then return end

        if shot.reason == 0 then
            local damage = shot.damage
            if damage < 1 then
                return
            end

            local bullet_position = get_player:GetHitboxCenter(shot.hitgroup)
            if not bullet_position then
                bullet_position = get_player:GetRenderOrigin()
                bullet_position.y = bullet_position.y + 30
            end

            bullet_position.x = (bullet_position.x - 10) + (math.random() * 20)
            bullet_position.y = (bullet_position.y - 10) + (math.random() * 20)
            bullet_position.z = (bullet_position.z - 15) + (math.random() * 30)

            table.insert(all_visual_functions.damage_marker_data.particles, {
                position = bullet_position,
                timer = GlobalVars.tickcount() + 80,
                damage = damage,
                is_killed = get_player:GetHealth() - damage <= 0 and true or false
            })

            table.insert(all_visual_functions.damage_marker_data.hitmarkers, {
                position = get_player:GetHitboxCenter(shot.hitgroup),
                timer = GlobalVars.realtime(),
                alpha = 0,
            })
        end
    end
end

all_visual_functions.move_damage_marker_position = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        for k, information in pairs(all_visual_functions.damage_marker_data.particles) do
            local delta = information.timer - GlobalVars.tickcount()
            if delta > 0 then
                information.position.z = information.position.z + 0.3
            end
        end
    end
end

all_visual_functions.reset_damage_marker_data = function(event)
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        if event:GetName() == "player_connect_full" or event:GetName() == "round_prestart" then
            all_visual_functions.damage_marker_data.particles = {}
            all_visual_functions.damage_marker_data.hitmarkers = {}
        end
    end
end

all_visual_functions.verdana_13 = register_font("Verdana", 13)
all_visual_functions.damage_markers = function()
    if not menu_database.elements["Enable indicator list"] then return end
    if bit.band(menu_database.elements["Indicator list"], bit.lshift(1, 8)) == 0 then return end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        for k, information in ipairs(all_visual_functions.damage_marker_data.particles) do
            if information.position and information.timer and (information.damage and information.damage > 0) then
                local time = math.floor(information.timer - GlobalVars.tickcount())
                local position = Render.WorldToScreen(information.position)
                
                if time > 255 then
                    time = 255
                end

                if (not(time < 0)) then
                    local font = all_visual_functions.verdana_13
                    local damage = tostring(information.damage)
                    
                    local color = information.is_killed and Color.RGBA(255, 236, 132, 255) or Color.RGBA(255, 255, 255, 255)
                    color.a = time

                    draw_shadow(0, damage, position.x, position.y, color, 13, font, false, Color.RGBA(0, 0, 0, 255))
                end
            end
        end

        for k, information in ipairs(all_visual_functions.damage_marker_data.hitmarkers) do
            if information.position and information.timer and information.alpha then
                local position = Render.WorldToScreen(information.position)
                if information.timer + 4 < GlobalVars.realtime() then
                    information.alpha = math.max(0, information.alpha - 2)
                else
                    information.alpha = math.min(information.alpha + 3, 255)
                end

                local alpha = math.floor(information.alpha)
                local current_size = menu_database.elements["Hitmarker size"]
                local current_mode = menu_database.elements["Hitmarker mode"]

                local current_color = menu_database.references["Hitmarker color"].reference:Get()
                local color = Color.new(current_color.r, current_color.g, current_color.b, alpha / 255)

                if current_mode == 0 then
                    Render.Line(Vector2.new(position.x, position.y - current_size), position, color)
                    Render.Line(Vector2.new(position.x - current_size, position.y), position, color)
                    Render.Line(Vector2.new(position.x, position.y + current_size), position, color)
                    Render.Line(Vector2.new(position.x + current_size, position.y), position, color)
                else
                    Render.Line(position, Vector2.new(position.x - current_size, position.y - current_size), color)
                    Render.Line(position, Vector2.new(position.x - current_size, position.y + current_size), color)
                    Render.Line(position, Vector2.new(position.x + current_size, position.y + current_size), color)
                    Render.Line(position, Vector2.new(position.x + current_size, position.y - current_size), color)
                end

                if information.timer + 5 < GlobalVars.realtime() then
                    table.remove(all_visual_functions.damage_marker_data.hitmarkers, k)
                end
            end
        end
    end
end

add_element(false, "Enable keybinds", Menu.Switch("Half-Life: Visuals stuff", "Solus UI Elements", "Enable keybinds", false))
add_element(false, "Keybinds x-adding", Menu.SliderInt("Half-Life: Visuals stuff", "Solus UI Elements", "Keybinds x-adding", 325, 0, screen_size.x), function() return false end)
add_element(false, "Keybinds y-adding", Menu.SliderInt("Half-Life: Visuals stuff", "Solus UI Elements", "Keybinds y-adding", 325, 0, screen_size.y), function() return false end)

add_element(false, "Enable watermark", Menu.Switch("Half-Life: Visuals stuff", "Solus UI Elements", "Enable watermark", false))
add_element(false, "Enable exploiting indicator", Menu.Switch("Half-Life: Visuals stuff", "Solus UI Elements", "Enable exploiting indicator", false))

add_element(true, "Accent color", Menu.ColorEdit("Half-Life: Visuals stuff", "Solus UI Elements", "Accent color", Color.RGBA(255, 255, 255, 255)), function()
    return menu_database.elements["Enable watermark"] or menu_database.elements["Enable keybinds"] or menu_database.elements["Enable exploiting indicator"]
end)

all_visual_functions.verdana_11_r = register_font("Verdana", 11, {"r"})
all_visual_functions.keybind_vars = {
    keybinds_alpha = {},
    keybinds_y = {},

    width = 0,
    is_draggable = false,
    cursor_last_pos = Vector2.new(0, 0)
}

all_visual_functions.render_keybind_container = function(x, y, w)
    local height = 18
    local font = all_visual_functions.verdana_11_r
    local name_size = Render.CalcTextSize("keybinds", 11, font)

    local null_color = Color.RGBA(0, 0, 0, 0)
    local color = menu_database.references["Accent color"].reference:Get()
    local r, g, b, a = color.r, color.g, color.b, math.floor(color.a * 255)

    Render.Blur(Vector2.new(x - 70, y - 6), Vector2.new(x + w, y + height - 2), Color.RGBA(200, 200, 200, a), 5)
    Render.BoxFilled(Vector2.new(x - 67, y - 6), Vector2.new(x + w - 3, y - 4), Color.new(r, g, b, 1))
    Render.Circle(Vector2.new(x - 67, y - 1), 4, 32, Color.new(r, g, b, 1), 2, 270, 180)
    Render.Circle(Vector2.new(x + w - 3, y - 1), 4, 32, Color.new(r, g, b, 1), 2, 0, -90)

    Render.GradientBoxFilled(Vector2.new(x - 70, y - 1), Vector2.new(x - 72, y + 14), Color.new(r, g, b, 1), Color.new(r, g, b, 1), null_color, null_color)
    Render.GradientBoxFilled(Vector2.new(x + w, y - 1), Vector2.new(x + w + 2, y + 11), Color.new(r, g, b, 1), Color.new(r, g, b, 1), null_color, null_color)
    Render.BoxFilled(Vector2.new(x - 67, y + 14), Vector2.new(x + w - 3, y + 16), Color.new(r, g, b, 0.3))

    Render.Circle(Vector2.new(x - 67, y + 11), 4, 32, Color.new(r, g, b, 0.3), 2, 180, 90)
    Render.Circle(Vector2.new(x + w - 3, y + 11), 4, 32, Color.new(r, g, b, 0.3), 2, 0, 90)

    draw_shadow(2, "keybinds", x - 35 + w / 2 - name_size.x / 2, y - 2, Color.RGBA(255, 255, 255, 255), 11, font, false, Color.RGBA(0, 0, 0, 205))
end

all_visual_functions.keybinds = function()
    if not menu_database.elements["Enable keybinds"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local x = menu_database.elements["Keybinds x-adding"]
        local y = menu_database.elements["Keybinds y-adding"]

        local add_y = 0
        local max_width = 0
        local font = all_visual_functions.verdana_11_r

        local binds = Cheat.GetBinds()
        local directory = all_visual_functions.keybind_vars
        local render_container = all_visual_functions.render_keybind_container

        for i = 1, #binds do
            local bind = binds[i]
            table.insert(directory.keybinds_alpha, 0)

            local bind_name = bind:GetName()
            local isFS = get_bind("Yaw Base").value == "Freestanding" or bind_system.list_of_directories["Yaw Base"]:Get() == 5

            bind_name = bind_name:gsub("Double Tap", "Double tap")
            bind_name = bind_name:gsub("Fake Duck", "Duck peek assist")
            bind_name = bind_name:gsub("Auto Peek", "Quick peek assist")
            bind_name = isFS and bind_name:gsub("Yaw Base", "Freestanding") or bind_name:gsub("Yaw Base", "")

            add_y = add_y + 16
            if bind_name ~= "" then
                if bind:IsActive() then
                    directory.keybinds_alpha[i] = math.lerp(directory.keybinds_alpha[i], 255, GlobalVars.frametime() * 25)
                else
                    directory.keybinds_alpha[i] = math.lerp(directory.keybinds_alpha[i], 0, GlobalVars.frametime() * 25)
                end

                local bind_state = bind:GetMode() == 1 and "[holding]" or "[toggled]"
                local bind_state_size = Render.CalcTextSize(bind_state, 11, font)
                local bind_name_size = Render.CalcTextSize(bind_name, 11, font)
            
                local width = math.floor(directory.width)
                local smooth_alpha = math.floor(directory.keybinds_alpha[i])
            
                draw_shadow(1, bind_name, x - 63, y + add_y + 4, Color.RGBA(255, 255, 255, smooth_alpha), 11, font, false, Color.RGBA(0, 0, 0, smooth_alpha - 50))
                draw_shadow(1, bind_state, x + (width - bind_state_size.x) - 5, y + add_y + 4, Color.RGBA(255, 255, 255, smooth_alpha), 11, font, false, Color.RGBA(0, 0, 0, smooth_alpha - 50))
            
                local length = 75
                local bind_width = bind_state_size.x + bind_name_size.x - 40
            
                if bind_width > length then
                    if bind_width > max_width then
                        max_width = bind_width
                    end
                end
            else
                add_y = add_y - 16
            end
        end

        directory.width = math.max(65, max_width)
        if not Cheat.IsMenuVisible() then
            directory.is_draggable = false
        end

        local width = math.round(directory.width)
        local mouse = Cheat.GetMousePos()

        if Cheat.IsMenuVisible() or #binds > 0 then
            all_visual_functions.render_keybind_container(x, y, width)
            if Cheat.IsKeyDown(0x1) then
                if not directory.is_draggable then
                    if mouse.x >= x - 70 and mouse.y >= y and mouse.x <= x + width and mouse.y <= y + 18 then
                        directory.is_draggable = true
                    end
                else
                    local x_pos = x + (mouse.x - directory.cursor_last_pos.x)
                    local y_pos = y + (mouse.y - directory.cursor_last_pos.y)

                    menu_database.set_value("Keybinds x-adding", math.round(x_pos))
                    menu_database.set_value("Keybinds y-adding", math.round(y_pos))
                end
            else
                directory.is_draggable = false
            end

            directory.cursor_last_pos = mouse
        end
    end
end

all_visual_functions.watermark_data = {realtime = GlobalVars.realtime(), chocking = 0}
all_visual_functions.watermark = function()
    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        local font = all_visual_functions.verdana_11_r
        local color = menu_database.references["Accent color"].reference:Get()

        local add_y = 0
        local r, g, b, a = color.r, color.g, color.b, math.round(color.a * 255)

        if menu_database.elements["Enable watermark"] then
            add_y = 25
            local utils = {
                get_ping = function()
                    local netchann_info = EngineClient.GetNetChannelInfo()
                    if not netchann_info then return "0" end

                    local latency = netchann_info:GetLatency(0)
                    return string.format("%1.f", math.max(0.0, latency) * 1000.0)
                end,

                get_current_time = function()
                    local seconds = math.floor(Utils.UnixTime() / 1000)
                    local hours = math.floor((seconds / 3600 + 3) % 24)
                    local minutes = math.floor(seconds / 60 % 60)

                    return string.format("%02d:%02d:%02d", hours, minutes, (seconds % 60))
                end,

                get_ticks = function()
                    return math.floor(1.0 / GlobalVars.interval_per_tick())
                end
            }
            
            local max_width = 0
            local null_color = Color.RGBA(0, 0, 0, 0)

            local ping = utils.get_ping()
            local ticks = utils.get_ticks()
            local name = Cheat.GetCheatUserName()
            local time = utils.get_current_time()

            local text = ("half-life %s  delay: %sms  %s tick  %s"):format(name, ping, ticks, time)
            local text_size = Render.CalcTextSize(text, 11, font) + 16

            Render.Blur(Vector2.new(screen_size.x - text_size.x - 6, 10), Vector2.new(screen_size.x - 10, 28), Color.RGBA(200, 200, 200, a), 5)
            Render.BoxFilled(Vector2.new(screen_size.x - text_size.x - 3, 8), Vector2.new(screen_size.x - 13, 10), Color.new(r, g, b, 1))

            Render.Circle(Vector2.new(screen_size.x - text_size.x - 3, 13), 4, 32, Color.new(r, g, b, 1), 2, 270, 180)
            Render.Circle(Vector2.new(screen_size.x - 13, 13), 4, 32, Color.new(r, g, b, 1), 2, 0, -90)

            Render.GradientBoxFilled(Vector2.new(screen_size.x - 8, 13), Vector2.new(screen_size.x - 10, 28), Color.new(r, g, b, 1), Color.new(r, g, b, 1), null_color, null_color)
            Render.GradientBoxFilled(Vector2.new(screen_size.x - text_size.x - 6, 13), Vector2.new(screen_size.x - text_size.x - 8, 28), Color.new(r, g, b, 1), Color.new(r, g, b, 1), null_color, null_color)
            Render.BoxFilled(Vector2.new(screen_size.x - text_size.x - 3, 28), Vector2.new(screen_size.x - 13, 30), Color.new(r, g, b, 0.3))

            Render.Circle(Vector2.new(screen_size.x - text_size.x - 3, 25), 4, 32, Color.new(r, g, b, 0.3), 2, 180, 90)
            Render.Circle(Vector2.new(screen_size.x - 13, 25), 4, 32, Color.new(r, g, b, 0.3), 2, 0, 90)

            local text_size_for_text = Render.CalcTextSize("half-", 11, font)
            draw_shadow(0, text, screen_size.x - text_size.x, 12, Color.RGBA(255, 255, 255, 255), 11, font, false, Color.RGBA(0, 0, 0, 255))
            Render.Text("life", Vector2.new(screen_size.x - text_size.x + text_size_for_text.x, 12), Color.new(r, g, b, 1), 11, font)
        end

        if menu_database.elements["Enable exploiting indicator"] then
            local data = all_visual_functions.watermark_data
            if data.realtime + 0.48 < GlobalVars.realtime() then
                data.chocking = ClientState.m_choked_commands()
                data.realtime = GlobalVars.realtime()
            end

            local isDT = get_bind("Double Tap").state
            local fakelag_text = isDT and "FL: 14 | EXPLOITING" or "FL: 14"
            local text_size = Render.CalcTextSize(fakelag_text, 11, font) + 16

            local fakelag_color = Color.RGBA(math.floor(255 - (data.chocking * 8.57142857142)), math.floor(data.chocking * 14.28105263158), math.floor(data.chocking * 0.84807017543), 255)
            local fakelag_color_2 = Color.RGBA(math.floor(255 - (data.chocking * 8.57142857142)), math.floor(data.chocking * 14.28105263158), math.floor(data.chocking * 0.84807017543), 0)

            Render.Blur(Vector2.new(screen_size.x - text_size.x - 6, 10 + add_y), Vector2.new(screen_size.x - 10, 28 + add_y), Color.RGBA(200, 200, 200, a), 5)
            Render.GradientBoxFilled(Vector2.new(screen_size.x - text_size.x / 2 - 6, 28 + add_y), Vector2.new(screen_size.x - 10, 29 + add_y), fakelag_color, fakelag_color_2, fakelag_color, fakelag_color_2)
            Render.GradientBoxFilled(
                Vector2.new(screen_size.x - text_size.x - 6, 28 + add_y), Vector2.new(screen_size.x - text_size.x / 2 - 6, 29 + add_y),
                fakelag_color_2, fakelag_color, fakelag_color_2, fakelag_color
            )

            local text_size_2 = Render.CalcTextSize("FL: 14", 11, font)
            local text_size_3 = Render.CalcTextSize(tostring(data.chocking), 11, font)
            local fakelag_text_2 = isDT and data.chocking .. " | EXPLOITING" or tostring(data.chocking)
            
            draw_shadow(0, "FL: ", screen_size.x - text_size.x, 12 + add_y, Color.RGBA(255, 255, 255, 255), 11, font, false, Color.RGBA(0, 0, 0, 255))
            draw_shadow(2, fakelag_text_2, screen_size.x - text_size.x + text_size_2.x - text_size_3.x, 12 + add_y, Color.RGBA(255, 255, 255, 255), 11, font, false, Color.RGBA(0, 0, 0, 255))
        end
    end
end

add_element(true, "Enable peek arrows", Menu.SwitchColor("Half-Life: Visuals stuff", "Arrow elements", "Enable peek arrows", false, Color.RGBA(255, 255, 255, 255)))
add_element(false, "Peek arrow distance", Menu.SliderInt("Half-Life: Visuals stuff", "Arrow elements", "Peek distance", 50, 0, 100), function()
    return menu_database.elements["Enable peek arrows"]
end)

all_visual_functions.verdana_21_b = register_font("Verdana", 21, {"b"})
all_visual_functions.peek_arrows = function()
    if not menu_database.elements["Enable peek arrows"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local font = all_visual_functions.verdana_21_b
        local inverter_state = AntiAim.GetInverterState()

        local distance = menu_database.elements["Peek arrow distance"]
        local color = menu_database.references["Enable peek arrows"].reference:GetColor()

        draw_shadow(3, ">", screen_size.x / 2 + distance, screen_size.y / 2 - 12, inverter_state and color or Color.RGBA(255, 255, 255, 255), 21, font, false, Color.RGBA(0, 0, 0, 170))
        draw_shadow(3, "<", screen_size.x / 2 - (distance + 15), screen_size.y / 2 - 12, not inverter_state and color or Color.RGBA(255, 255, 255, 255), 21, font, false, Color.RGBA(0, 0, 0, 170))
    end
end

add_element(true, "Enable manual arrows", Menu.SwitchColor("Half-Life: Visuals stuff", "Arrow elements", "Enable manual arrows", false, Color.RGBA(255, 255, 255, 255)))
add_element(false, "Manual arrow distance", Menu.SliderInt("Half-Life: Visuals stuff", "Arrow elements", "Manual distance", 50, 0, 100), function()
    return menu_database.elements["Enable manual arrows"]
end)

all_visual_functions.acta_symbols_w95 = register_font("nl\\half-life\\fonts\\acta-symbols-w95.ttf", 24)
all_visual_functions.manual_arrows = function()
    if not menu_database.elements["Enable manual arrows"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local inverter_state = AntiAim.GetInverterState()
        local distance = menu_database.elements["Manual arrow distance"]

        local font = all_visual_functions.acta_symbols_w95
        local color = menu_database.references["Enable manual arrows"].reference:GetColor()

        draw_shadow(3, "Z", screen_size.x / 2 + distance, screen_size.y / 2 - 8, inverter_state and color or Color.RGBA(255, 255, 255, 255), 21, font, false, Color.RGBA(0, 0, 0, 170))
        draw_shadow(3, "X", screen_size.x / 2 - (distance + 15), screen_size.y / 2 - 8, not inverter_state and color or Color.RGBA(255, 255, 255, 255), 21, font, false, Color.RGBA(0, 0, 0, 170))
    end
end

add_element(false, "Enable weapons in scope", Menu.Switch("Half-Life: Visuals stuff", "Other indicators", "Enable weapons in scope", false))
add_element(false, "Enable custom scope", Menu.SwitchColor("Half-Life: Visuals stuff", "Other indicators", "Enable custom scope", false, Color.RGBA(255, 255, 255, 255)))

local custom_scope_elements = {"Initial position", "Offset"}
for index = 1, #custom_scope_elements do
    local current_element = custom_scope_elements[index]
    local functions = {Menu.SliderInt, Menu.SliderInt}

    local sub_functions = {{200, 0, 400}, {15, 0, 1000}}
    local callbacks = ("Custom scope %s"):format(current_element:lower())

    add_element(false, callbacks, functions[index]("Half-Life: Visuals stuff", "Other indicators", current_element, unpack(sub_functions[index])), function()
        return menu_database.elements["Enable custom scope"]
    end)
end

all_visual_functions.weapons_in_scope = function(stage)
    if not menu_database.elements["Enable weapons in scope"] then
        player_vars.fov_cs_debug:SetInt(0)
        return
    end

    local is_local_player_valid, my_index = is_local_player_valid()
    if is_local_player_valid then
        if stage ~= 6 then
            return
        end

        local is_scoped = my_index:GetProp("m_bIsScoped")
        if is_scoped then
            local is_third_person = get_bind("Enable Thirdperson").state
            player_vars.fov_cs_debug:SetInt(is_third_person and 0 or 90)
        else
            player_vars.fov_cs_debug:SetInt(0)
        end
    end
end

all_visual_functions.scope_value = 0
all_visual_functions.is_backuped = false

all_visual_functions.custom_scope = function()
    if menu_database.elements["Enable custom scope"] then
        local is_local_player_valid, my_index = is_local_player_valid()
        if is_local_player_valid then
            local is_scoped = my_index:GetProp("m_bIsScoped")
            local directory = bind_system.list_of_directories.remove_scope

            if is_scoped then
                if not all_visual_functions.is_backuped then all_visual_functions.is_backuped = true end
                directory:SetInt(2)

                local offset = menu_database.elements["Custom scope offset"]
                local initial_position = menu_database.elements["Custom scope initial position"]

                if all_visual_functions.scope_value < initial_position / 2 + offset then
                    all_visual_functions.scope_value = all_visual_functions.scope_value + 100
                else
                    all_visual_functions.scope_value = initial_position / 2 + offset
                end

                local color = menu_database.references["Enable custom scope"].reference:GetColor()
                local ready_color = Color.new(color.r, color.g, color.b, 0.05)

                local alpha_time = all_visual_functions.scope_value
                local first_color = (function(a, b) if initial_position <= 30 then return b else return a end end)(color, ready_color)
                local second_color = (function(a, b) if initial_position <= 30 then return a else return b end end)(color, ready_color)

                Render.GradientBoxFilled(
                    Vector2.new(screen_size.x / 2 - 0.1, screen_size.y / 2 - math.min(initial_position, alpha_time)),
                    Vector2.new(screen_size.x / 2 + 1,  screen_size.y / 2 - math.min(initial_position, alpha_time) - math.min(offset, alpha_time)),
                    second_color, second_color, first_color, first_color
                )

                Render.GradientBoxFilled(
                    Vector2.new(screen_size.x / 2 - math.min(initial_position, alpha_time), screen_size.y / 2 - 0.1),
                    Vector2.new(screen_size.x / 2 - math.min(initial_position, alpha_time) - math.min(offset, alpha_time), screen_size.y / 2 + 1),
                    second_color, first_color, second_color, first_color
                )

                Render.GradientBoxFilled(
                    Vector2.new(screen_size.x / 2 - 0.1, screen_size.y / 2 + math.min(initial_position, alpha_time)),
                    Vector2.new(screen_size.x / 2 + 1, screen_size.y / 2  + math.min(initial_position, alpha_time) + math.min(offset, alpha_time)),
                    second_color, second_color, first_color, first_color
                )

                Render.GradientBoxFilled(
                    Vector2.new(screen_size.x / 2 + math.min(initial_position, alpha_time), screen_size.y / 2 - 0.1),
                    Vector2.new(screen_size.x / 2  + math.min(initial_position, alpha_time) + math.min(offset, alpha_time), screen_size.y / 2 + 1),
                    second_color, first_color, second_color, first_color
                )
            else
                if all_visual_functions.scope_value > 0 then
                    all_visual_functions.scope_value = all_visual_functions.scope_value - 100
                else
                    all_visual_functions.scope_value = 0
                end
            end
        else
            local directory = bind_system.list_of_directories.remove_scope
            if all_visual_functions.is_backuped then
                directory:SetInt(1)
                all_visual_functions.is_backuped = false
            end
        end
    else
        local directory = bind_system.list_of_directories.remove_scope
        if all_visual_functions.is_backuped then
            directory:SetInt(1)
            all_visual_functions.is_backuped = false
        end
    end
end

all_visual_functions.custom_scope_on_destroy = function()
    local directory = bind_system.list_of_directories.remove_scope
    directory:SetInt(1)
end
--- @endregion

--- @region: all miscellaneous functions
local all_miscellaneous_functions = {}
add_element(false, "Enable hitlogs", Menu.Switch("Half-Life: Miscell. stuff", "Hitlogging information", "Enable hitlogs", false))

all_miscellaneous_functions.hitlog_data = {
    hitlogs = {},
    count_shots = 0,

    miss_reasons = {
        [1] = "resolver",
        [2] = "spread",
        [3] = "occlusion",
        [4] = "pred. error"
    },
    
    hitgroups = {
        [0] = "generic",
        [1] = "head",
        [2] = "chest",
        [3] = "stomach",
        [4] = "left arm",
        [5] = "right arm",
        [6] = "left leg",
        [7] = "right leg",
        [10] = "gear"
    }
}

all_miscellaneous_functions.register_shots = function(shot)
    if not menu_database.elements["Enable hitlogs"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local data = all_miscellaneous_functions.hitlog_data
        data.count_shots = data.count_shots + 1

        if data.count_shots > 99 then
            data.count_shots = 0
        end

        local index = EntityList.GetClientEntity(shot.target_index)
        if not index then return end

        local target = index:GetPlayer()
        local name = target:GetName()

        local hitbox = data.hitgroups[math.min(shot.hitgroup, 10)]
        local wanted_hitgroup = data.hitgroups[math.min(shot.wanted_hitgroup, 10)]

        local damage = {
            hit = shot.damage,
            wanted = shot.wanted_damage,
            remain = math.clamp(target:GetHealth() - shot.damage, 0, client_info.INT_MAX)
        }

        local hit_hitchance = shot.hitchance
        local is_missmatch = damage.hit ~= damage.wanted and true or false

        local backtrack = shot.backtrack
        local miss_reason = data.miss_reasons[math.min(1, shot.reason)]

        local second_correction = math.random(-15, 15)
        local first_correction = 0

        if 1 - math.round(hit_hitchance / 100) == 0 then
            first_correction = 1
        elseif 1 - math.round(hit_hitchance / 100) == 1 then
            first_correction = 2
        else
            first_correction = 3
        end

        local text = ""
        if shot.reason == 0 then
            if is_missmatch then
                text = ("Registered %sth shot in %s's %s for %s damage [angle: 0.%s°, %s:%s°] ( hitchance: %s | history(Δ): %s | %s health | missmatch: [dmg: %s] )"):format(
                    data.count_shots, name, hitbox, damage.hit, math.random(0, 60), first_correction, second_correction, hit_hitchance, backtrack, damage.remain, damage.wanted
                )
            else
                text = ("Registered %sth shot in %s's %s for %s damage [angle: 0.%s°, %s:%s°] ( hitchance: %s | history(Δ): %s | %s health )"):format(
                    data.count_shots, name, hitbox, damage.hit, math.random(0, 60), first_correction, second_correction, hit_hitchance, backtrack, damage.remain
                )
            end
        else
            text = ("Missed %sth shot at %s's %s due to %s [angle: 0.%s°, %s:%s°] ( damage: %s | hitchance: %s | history(Δ): %s | %s health )"):format(
                data.count_shots, name, wanted_hitgroup, miss_reason, math.random(0, 60), first_correction, second_correction, damage.wanted, hit_hitchance, backtrack, damage.remain
            )
        end

        color_print("[half-life] ", Color.RGBA(255, 255, 102, 255))
        color_print(text .. "\n", Color.RGBA(255, 255, 255, 255))
    
        table.insert(data.hitlogs, {
            text = text, time = GlobalVars.realtime(), color = Color.RGBA(255, 255, 255, 255)
        })
    end
end

all_miscellaneous_functions.register_additional_logs = function(event)
    if not menu_database.elements["Enable hitlogs"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local data = all_miscellaneous_functions.hitlog_data
        if event:GetName() == "player_hurt" then
            local victim = EntityList.GetPlayerForUserID(event:GetInt("userid"))
            local attacker = EntityList.GetPlayerForUserID(event:GetInt("attacker"))
            if victim == attacker or attacker ~= my_index then return end

            local target_name = victim:GetName()
            local health_damage = event:GetInt("dmg_health")
            local remaining_damage = event:GetInt("health")

            local weapon = event:GetString("weapon")
            local text = (
                weapon == "hegrenade" and ("Naded %s for %s (%s remaining)"):format(
                    target_name, health_damage, remaining_damage
                ) or weapon == "inferno" and ("Burned %s for %s (%s remaining)"):format(
                    target_name, health_damage, remaining_damage
                ) or weapon == "knife" and ("Knifed %s for %s (%s remaining)"):format(
                    target_name, health_damage, remaining_damage
                ) or nil
            )

            if text ~= nil then
                color_print("[half-life] ", Color.RGBA(255, 255, 102, 255))
                color_print(text .. "\n", Color.RGBA(255, 255, 255, 255))

                table.insert(data.hitlogs, {
                    text = text, time = GlobalVars.realtime(), color = Color.RGBA(255, 255, 255, 255)
                })
            end
        end

        if event:GetName() == "item_purchase" then
            if not EntityList.GetPlayerForUserID(event:GetInt("userid")) then return end
            local buyer = EntityList.GetPlayerForUserID(event:GetInt("userid")):GetName()

            local weapon = event:GetString("weapon")
            if not weapon then return end

            weapon = weapon:gsub("unknown", "assaultsuit")
            local text = string.format("%s bought %s", buyer, weapon)

            color_print("[half-life] ", Color.RGBA(255, 255, 102, 255))
            color_print(text .. "\n", Color.RGBA(255, 255, 255, 255))

            table.insert(data.hitlogs, {
                text = text, time = GlobalVars.realtime(), color = Color.RGBA(255, 255, 255, 255)
            })
        end
    end
end

all_miscellaneous_functions.lucida_console_10_r = register_font("Lucida Console", 10, {"r"})
all_miscellaneous_functions.render_hitlogs = function()
    if not menu_database.elements["Enable hitlogs"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local data = all_miscellaneous_functions.hitlog_data
        local x, y = 5, 5

        for k, information in ipairs(data.hitlogs) do
            if information.text and information.time and information.color then
                local text = information.text
                local color = information.color
                local font = all_miscellaneous_functions.lucida_console_10_r

                draw_shadow(0, text, x, y, color, 10, font, false, Color.RGBA(0, 0, 0, 255))
                y = y + 15

                if information.time + 3.8 < GlobalVars.realtime() then
                    table.remove(data.hitlogs, k)
                end
            end
        end
    end
end

add_element(false, "Enable trashtalk", Menu.Switch("Half-Life: Miscell. stuff", "Other functions", "Enable trashtalk", false))
all_miscellaneous_functions.phrases = {
    "1 пидорасина ебаная спи",
    "Нихуя я тебе зубы расхуярил",
    "1000-7",
    " пикать у нолава учился?",
    "1 дегенерат нерусский ",
    "выебан ублюдок",
    "обоссан",
    "by DOKOTA Далбаеб)",
    "але уебище халву  гетни потом выпездывай что то",
    "Ебать ты на банку принглса присел далбаеб)",
    "заглотнул коки яки",
    "в сон нахуй",
    "уебашил дилдом по ебалу",
    "сбил пидораса обоссаного",
    "глотай овца",
    "трахнут",
    "Распикал тебя на халве",
    "По еблу припиздок",
    "слишком сочный для Half-life.lua ",
    "sleep",
    "изи упал нищий",
    "посажен на хуй",
    "Кислота.exe Activated",
    "what you do dog??",
    "В следующий раз уебан",
    "1 week lov doggo ovned",
    "лерн ту плей пидорас",
    "Нихуя вырубил",
    "Норм бакша слетела",
    "1 мусор учись играть",
    "$$$ 1 TAP UFF YA zu krass",
    "Оформил посос члена)",
    "я ķ¤нɥåλ ϯ⤣ü ɱåɱķ£ β Ƥ¤ϯ",
    "улетаешь со своего ванвея хуесос",
    "0 iq",
    "сразу видно кфг иссуе мб конфиг у илюхи докотова прикупишь ?",
    "iq ? ",
    "Best and cheap configurations for gamesense, ot and neverlose waiting for your order  at ---> vk.com/DokotaHvH",
    "я смотрел видосы нолава мне похуй (◣_◢)",
    "земля те землей хуйло чиста к мамаше отлетел",
    "Создатель JS DOKOTA"
}

all_miscellaneous_functions.trashtalk = function(event)
    if not menu_database.elements["Enable trashtalk"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        if event:GetName() ~= "player_death" then
            return
        end

        local victim = EntityList.GetPlayerForUserID(event:GetInt("userid"))
        local attacker = EntityList.GetPlayerForUserID(event:GetInt("attacker"))
        if victim == attacker or attacker ~= my_index then return end

        local phrases = all_miscellaneous_functions.phrases
        local get_phrase = phrases[math.random(1, #phrases)]:gsub('\"', '')
        
        EngineClient.ExecuteClientCmd((' say "%s"'):format(get_phrase))
    end
end

add_element(false, "Enable hitsounds", Menu.Switch("Half-Life: Miscell. stuff", "Other functions", "Enable hitsounds", false))

all_miscellaneous_functions.engine_sound_client = ffi.cast("uintptr_t**", Utils.CreateInterface("engine.dll", "IEngineSoundClient003"))
all_miscellaneous_functions.play_sound = ffi_functions.bind_argument(
    ffi.cast("void*(__thiscall*)(void*, const char*, float, int, int, float)", all_miscellaneous_functions.engine_sound_client[0][12]), all_miscellaneous_functions.engine_sound_client
)

all_miscellaneous_functions.hitsounds = function(event)
    if not menu_database.elements["Enable hitsounds"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        if event:GetName() ~= "player_hurt" then
            return
        end

        local victim = EntityList.GetPlayerForUserID(event:GetInt("userid"))
        local attacker = EntityList.GetPlayerForUserID(event:GetInt("attacker"))
        if victim == attacker or attacker ~= my_index then return end

        local play_sound = all_miscellaneous_functions.play_sound
        local directory = "buttons/arena_switch_press_02.wav"

        play_sound(directory, 1, 100, 0, 0)
    end
end

add_element(false, "Enable animation breakers", Menu.Switch("Half-Life: Miscell. stuff", "Animation breaker", "Enable animation breakers", false))
all_miscellaneous_functions.animation_breakers = {"Static legs in air", "Break leg animation", "Pitch 0 on land"}

add_element(false, "Animation breakers", Menu.MultiCombo("Half-Life: Miscell. stuff", "Animation breaker", "Animation breakers", all_miscellaneous_functions.animation_breakers, 0), function()
    return menu_database.elements["Enable animation breakers"]
end)

add_element(false, "Static legs timer", Menu.SliderFloat("Half-Life: Miscell. stuff", "Animation breaker", "Static legs timer", 0.5, 0, 1), function()
    return menu_database.elements["Enable animation breakers"] and bit.band(menu_database.elements["Animation breakers"], bit.lshift(1, 0)) ~= 0
end)

add_element(false, "Leg fucker type", Menu.Combo("Half-Life: Miscell. stuff", "Animation breaker", "Leg breaker modes", {"Static", "Jitter"}, 0), function()
    return menu_database.elements["Enable animation breakers"] and bit.band(menu_database.elements["Animation breakers"], bit.lshift(1, 1)) ~= 0
end)

all_miscellaneous_functions.breakers = {}
all_miscellaneous_functions.breakers.data = {
    hooked_function = nil,
    is_on_ground = false
}

all_miscellaneous_functions.breakers.updateCSA = function(thisptr, edx)
    local is_localplayer = ffi.cast("uintptr_t", thisptr) == ffi_functions.get_entity_address(EngineClient.GetLocalPlayer())
    local data = all_miscellaneous_functions.breakers.data

    data.hooked_function(thisptr, edx)
    if is_localplayer then
        if not menu_database.elements["Enable animation breakers"] then
            return
        end

        local addons = menu_database.elements["Animation breakers"]
        local pose_parameters_data = ffi.cast("float*", ffi.cast("uintptr_t", thisptr) + 10104)

        if bit.band(addons, bit.lshift(1, 0)) ~= 0 then
            local static_legs_value = menu_database.elements["Static legs timer"]
            pose_parameters_data[6] = static_legs_value
        end

        if bit.band(addons, bit.lshift(1, 1)) ~= 0 then
            local leg_breaker_value = menu_database.elements["Leg fucker type"]
            pose_parameters_data[0] = leg_breaker_value == 0 and 1 or (GlobalVars.tickcount() % 4 == 0 and 0.5 or 0)
        end

        if bit.band(addons, bit.lshift(1, 2)) ~= 0 then
            local bHitGroundAnimation = ffi.cast("CCSGOPlayerAnimationState_534535_t**", ffi.cast("uintptr_t", thisptr) + 0x9960)[0].bHitGroundAnimation
            local is_available = data.is_on_ground

            if bHitGroundAnimation and is_available then
                pose_parameters_data[12] = 0.5
            end
        end
    end
end

all_miscellaneous_functions.breakers.on_pre_prediction = function(cmd)
    local data = all_miscellaneous_functions.breakers.data
    data.is_on_ground = bit.band(cmd.buttons, 2) == 0
end

all_miscellaneous_functions.breakers.prediction = function(cmd)
    if not menu_database.elements["Enable animation breakers"] then return end
    local is_local_player_valid, my_index = is_local_player_valid()

    if is_local_player_valid then
        local addons = menu_database.elements["Animation breakers"]
        if bit.band(addons, bit.lshift(1, 1)) ~= 0 then
            bind_system.list_of_directories.leg_movement:Set(cmd.command_number % 3 == 0 and 0 or 1)
        end
    end
end

all_miscellaneous_functions.breakers.on_create_move = function()
    local local_player = EntityList.GetLocalPlayer()
    if not local_player then
        return
    end
    
    local local_player_ptr = ffi_functions.get_entity_address(local_player:EntIndex())
    local data = all_miscellaneous_functions.breakers.data

    if not local_player_ptr or data.hooked_function then
        return
    end

    local C_CSPLAYER = vmt_hook.new(local_player_ptr)
    data.hooked_function = C_CSPLAYER.hookMethod("void(__fastcall*)(void*, void*)", all_miscellaneous_functions.breakers.updateCSA, 224)
end

all_miscellaneous_functions.breakers.on_destroy = function()
    for i, unHookFunc in ipairs(vmt_hook.hooks) do
        unHookFunc()
    end

    for i, free in ipairs(buff.free) do
        free()
    end
end
--- @endregion

--- @region: Config system
local base64 = {}
base64.extract = function(value, from, width)
    return bit.band(bit.rshift(value, from), bit.lshift(1, width) - 1)
end

base64.create_encoder = function(input_alphabet)
    local encoder = {}
    local alphabet = {}

    for i = 1, #input_alphabet do
        alphabet[i - 1] = input_alphabet:sub(i, i)
    end

    for b64code, char in pairs(alphabet) do
        encoder[b64code] = char:byte()
    end

    return encoder
end

base64.create_decoder = function(alphabet)
    local decoder = {}
    for b64code, charcode in pairs(base64.create_encoder(alphabet)) do
        decoder[charcode] = b64code
    end

    return decoder
end

base64.default_encode_alphabet = base64.create_encoder("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
base64.default_decode_alphabet = base64.create_decoder("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")

base64.custom_encode_alphabet = base64.create_encoder("a8tsQE4FdNKZ1WlzRP6UH9fmkiAyjxw2OXcgVvL5IG0eYDnTB3CMJqhpbSo7ru+/=")
base64.custom_decode_alphabet = base64.create_decoder("a8tsQE4FdNKZ1WlzRP6UH9fmkiAyjxw2OXcgVvL5IG0eYDnTB3CMJqhpbSo7ru+/=")

base64.encode = function(string, encoder)
    string = tostring(string)
    encoder = encoder or base64.default_encode_alphabet

    local t, k, n = {}, 1, #string
    local lastn = n % 3
    local cache = {}

    for i = 1, n - lastn, 3 do
        local a, b, c = string:byte(i, i + 2)
        local v = a * 0x10000 + b * 0x100 + c
        local s = string.char(encoder[base64.extract(v, 18, 6)], encoder[base64.extract(v, 12, 6)], encoder[base64.extract(v, 6, 6)], encoder[base64.extract(v, 0, 6)])

        t[k] = s
        k = k + 1
    end

    if lastn == 2 then
        local a, b = string:byte(n - 1, n)
        local v = a * 0x10000 + b * 0x100

        t[k] = string.char(encoder[base64.extract(v, 18, 6)], encoder[base64.extract(v, 12, 6)], encoder[base64.extract(v, 6, 6)], encoder[64])
    elseif lastn == 1 then
        local v = string:byte(n) * 0x10000
        t[k] = string.char(encoder[base64.extract(v, 18, 6)], encoder[base64.extract(v, 12, 6)], encoder[64], encoder[64])
    end

    return table.concat(t)
end

function base64.decode(b64, decoder)
    decoder = decoder or base64.default_decode_alphabet
    local pattern = "[^%w%+%/%=]"
    
    if decoder then
        local s62 = nil
        local s63 = nil

        for charcode, b64code in pairs(decoder) do
            if b64code == 62 then
                s62 = charcode
            elseif b64code == 63 then
                s63 = charcode
            end
        end

        pattern = ("[^%%w%%%s%%%s%%=]"):format(string.char(s62), string.char(s63))
    end

    b64 = b64:gsub(pattern, "")
    local n = #b64

    local t, k = {}, 1
    local padding = b64:sub(-2) == "==" and 2 or b64:sub(-1) == "=" and 1 or 0

    for i = 1, padding > 0 and n - 4 or n, 4 do
        local a, b, c, d = b64:byte(i, i + 3)
        local v = decoder[a] * 0x40000 + decoder[b] * 0x1000 + decoder[c] * 0x40 + decoder[d]
        local s = string.char(base64.extract(v, 16, 8), base64.extract(v, 8, 8), base64.extract(v, 0, 8))

        t[k] = s
        k = k + 1
    end

    if padding == 1 then
        local a, b, c = b64:byte(n - 3, n - 1)
        local v = decoder[a] * 0x40000 + decoder[b] * 0x1000 + decoder[c] * 0x40

        t[k] = string.char(base64.extract(v, 16, 8), base64.extract(v, 8, 8))
    elseif padding == 2 then
        local a, b = b64:byte(n - 3, n - 2)
        local v = decoder[a] * 0x40000 + decoder[b] * 0x1000

        t[k] = string.char(base64.extract(v, 16, 8))
    end

    return table.concat(t)
end

local config_system = {}
config_system.convert_color = function(color)
    return {r = math.round(color.r * 255), g = math.round(color.g * 255), b = math.round(color.b * 255), a = math.round(color.a * 255)}
end

config_system.json = Panorama.LoadString([[
    return {
        stringify: JSON.stringify,
        parse: JSON.parse
    };
]])()

config_system.copy_all_elements = function()
    local all_menu_elements = {}
    local all_references = menu_database.references
    local convert_color = config_system.convert_color

    for key, element in pairs(all_references) do
        local element_cache = {}
        element_cache.value = element.reference:Get()

        if type(element_cache.value) == "userdata" then
            element_cache.color = convert_color(element_cache.value)
            element_cache.value = nil
        else
            element_cache.color = element.is_color and convert_color(element.reference:GetColor()) or false
        end

        if not element_cache.color and not element_cache.value then
            goto skip_element
        end

        ::skip_element::
        all_menu_elements[key] = element_cache
    end

    local json_config = config_system.json.stringify(all_menu_elements)
    local base_64_decoded = base64.encode(json_config, base64.custom_encode_alphabet)

    ffi_functions.set_clipboard_text(base_64_decoded, #base_64_decoded)
end

config_system.paste_all_elements = function(text)
    local safe_executor = function()
        local final_text = text or ffi_functions.get_clipboard_text()
        local json_config = base64.decode(final_text, base64.custom_decode_alphabet)
    
        json_config = config_system.json.parse(json_config)
        if not json_config then
            print("Your JSON-config is wrong!")
            return
        end
    
        local anti_bruteforce_phases = -1
        for key, element in pairs(json_config) do
            if key:find("^Phase #") ~= nil then
                local anti_bruteforce_value = tonumber(key:sub(#"Phase #" + 1, #key))
                anti_bruteforce_phases = math.max(anti_bruteforce_value, anti_bruteforce_phases)
            end
    
            if menu_database.references[key] ~= nil then
                if element.value ~= nil then
                    menu_database.references[key].reference:Set(element.value)
                    menu_database.elements[key] = element.value
                end
    
                if element.color ~= false then
                    menu_database.references[key].reference:SetColor(Color.RGBA(element.color.r, element.color.g, element.color.b, element.color.a))
                end
            end
        end
    
        if #all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases > anti_bruteforce_phases then
            while #all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases > anti_bruteforce_phases do
                all_anti_aim_functions.custom_anti_aim.anti_bruteforce.remove_old_phase()
            end
        else
            while #all_anti_aim_functions.custom_anti_aim.anti_bruteforce.all_phases < anti_bruteforce_phases do
                all_anti_aim_functions.custom_anti_aim.anti_bruteforce.add_new_phase()
            end
        end
    
        for phase = 1, anti_bruteforce_phases do
            local phase_counter = ("Phase #%s"):format(phase)
            local json_value = json_config[phase_counter].value

            menu_database.references[phase_counter].reference:Set(json_value)
            menu_database.elements[phase_counter] = json_value
        end
    
        menu_database.update_elements()
        Cheat.AddNotify("Half-life.lua", "Config successfully loaded!")
    end

    local successfull, error_mesage = pcall(safe_executor)
    if not successfull then
        print(("Failed to load your config! Error: %s"):format(error_mesage))
        Cheat.AddNotify("Half-life.lua", "Failed to load config!")

        return
    end
end

local default_link = "https://www.toptal.com/developers/hastebin/raw/akozepaquj"
add_element(false, "Default config", Menu.Button("Half-Life: Global", "Config system", "                         Load default config                   ", "Click to load default config!", function()
    Http.GetAsync(default_link, function(data)
        config_system.paste_all_elements(data)
    end)
end))

add_element(false, "Export config", Menu.Button("Half-Life: Global", "Config system", "             Export your config to clipboard       ", "Click to export your config to the clipboard!", function()
    config_system.copy_all_elements()
end))

add_element(false, "Import config", Menu.Button("Half-Life: Global", "Config system", "             Import your config to clipboard       ", "Click to import your config from the clipboard!", function()
    config_system.paste_all_elements()
end))

--- @endregion

--- @region: callback section
local add_callback = callback_system.register
add_callback("createmove", "enemy_data.update_enemies", enemy_data.update_enemies)
add_callback("prediction", "all_ragebot_functions.dormant_aimbot.start_work", all_ragebot_functions.dormant_aimbot.start_work)
add_callback("prediction", "all_ragebot_functions.doubletap_controllers.start_work", all_ragebot_functions.doubletap_controllers.start_work)

add_callback("prediction", "all_anti_aim_functions.custom_anti_aim.start_work", all_anti_aim_functions.custom_anti_aim.start_work)
add_callback("prediction", "anti_bruteforce.apply_anti_bruteforce", all_anti_aim_functions.custom_anti_aim.anti_bruteforce.apply_anti_bruteforce)
add_callback("prediction", "all_anti_aim_functions.additional_stuff.start_work", all_anti_aim_functions.additional_stuff.start_work)

add_callback("events", "anti_bruteforce.trigger_anti_bruteforce", all_anti_aim_functions.custom_anti_aim.anti_bruteforce.trigger_anti_bruteforce)
add_callback("destroy", "all_anti_aim_functions.custom_anti_aim.on_edge_yaw_destroy", all_anti_aim_functions.custom_anti_aim.on_edge_yaw_destroy)
add_callback("destroy", "all_anti_aim_functions.additional_stuff.on_fakelag_destroy", all_anti_aim_functions.additional_stuff.on_fakelag_destroy)

add_callback("createmove", "all_anti_aim_functions.roll_angles.on_create_move", all_anti_aim_functions.roll_angles.on_create_move)
add_callback("prediction", "all_anti_aim_functions.roll_angles.on_pre_prediction", all_anti_aim_functions.roll_angles.on_pre_prediction)

add_callback("draw", "all_visual_functions.setup_under_crosshair_indicator", all_visual_functions.setup_under_crosshair_indicator)
add_callback("draw", "all_visual_functions.anti_aim_debugger", all_visual_functions.anti_aim_debugger)
add_callback("draw", "all_visual_functions.damage_indicator", all_visual_functions.damage_indicator)

add_callback("draw", "all_visual_functions.skeet_autopeek", all_visual_functions.skeet_autopeek)
add_callback("pre_prediction", "all_visual_functions.quick_peek", all_visual_functions.quick_peek)

add_callback("draw", "all_visual_functions.skeet_indicators", all_visual_functions.skeet_indicators)
add_callback("registered_shot", "all_visual_functions.skeet_data.shot_stats.count_shots", all_visual_functions.skeet_data.shot_stats.count_shots)
add_callback("events", "all_visual_functions.skeet_data.bomb_data.vars.load_bomb_modules", all_visual_functions.skeet_data.bomb_data.vars.load_bomb_modules)

add_callback("registered_shot", "all_visual_functions.register_hitmarker", all_visual_functions.register_hitmarker)
add_callback("draw", "all_visual_functions.crosshair_hitmarker", all_visual_functions.crosshair_hitmarker)

add_callback("frame_stage", "all_visual_functions.disable_animation_on_3rd_person", all_visual_functions.disable_animation_on_3rd_person)
add_callback("events", "all_visual_functions.on_getting_damage", all_visual_functions.on_getting_damage)
add_callback("draw", "all_visual_functions.notifications", all_visual_functions.notifications)

add_callback("registered_shot", "all_visual_functions.register_damage_marker", all_visual_functions.register_damage_marker)
add_callback("createmove", "all_visual_functions.move_damage_marker_position", all_visual_functions.move_damage_marker_position)
add_callback("events", "all_visual_functions.reset_damage_marker_data", all_visual_functions.reset_damage_marker_data)
add_callback("draw", "all_visual_functions.damage_markers", all_visual_functions.damage_markers)

add_callback("draw", "all_visual_functions.keybinds", all_visual_functions.keybinds)
add_callback("draw", "all_visual_functions.watermark", all_visual_functions.watermark)

add_callback("draw", "all_visual_functions.peek_arrows", all_visual_functions.peek_arrows)
add_callback("draw", "all_visual_functions.manual_arrows", all_visual_functions.manual_arrows)

add_callback("frame_stage", "all_visual_functions.weapons_in_scope", all_visual_functions.weapons_in_scope)
add_callback("draw", "all_visual_functions.custom_scope", all_visual_functions.custom_scope)
add_callback("destroy", "all_visual_functions.custom_scope_on_destroy", all_visual_functions.custom_scope_on_destroy)

add_callback("registered_shot", "all_miscellaneous_functions.register_shots", all_miscellaneous_functions.register_shots)
add_callback("events", "all_miscellaneous_functions.register_additional_logs", all_miscellaneous_functions.register_additional_logs)
add_callback("draw", "all_miscellaneous_functions.render_hitlogs", all_miscellaneous_functions.render_hitlogs)

add_callback("events", "all_miscellaneous_functions.trashtalk", all_miscellaneous_functions.trashtalk)
add_callback("events", "all_miscellaneous_functions.hitsounds", all_miscellaneous_functions.hitsounds)

add_callback("pre_prediction", "all_miscellaneous_functions.breakers.on_pre_prediction", all_miscellaneous_functions.breakers.on_pre_prediction)
add_callback("createmove", "all_miscellaneous_functions.breakers.on_create_move", all_miscellaneous_functions.breakers.on_create_move)
add_callback("destroy", "all_miscellaneous_functions.breakers.on_destroy", all_miscellaneous_functions.breakers.on_destroy)
add_callback("prediction", "all_miscellaneous_functions.breakers.on_prediction", all_miscellaneous_functions.breakers.prediction)
--- @endregion
 
Сверху Снизу