LUA скрипт [GS] Better Air | Auto Stop

Начинающий
Статус
Оффлайн
Регистрация
6 Дек 2021
Сообщения
23
Реакции[?]
1
Поинты[?]
1K
делов то на 10 мин
Код:
--[[
  If you have any questions, write here on Discord: askedtomy
--]]

local bit = require 'bit'
local vector = require("vector")

local feature = {
    def_hc = ui.new_slider('rage', 'aimbot', 'Default hit chance', 0, 100, 50, true, '%'),
    hc_in_air = ui.new_checkbox('rage', 'aimbot', 'SSG 08: Adaptive velocity & HC'),
    hit_chance_in_air = ui.new_slider('rage', 'aimbot', 'Hit chance in air (SSG 08)', 0, 100, 70, true, '%')
}

local hc_ref = ui.reference('rage', 'aimbot', 'minimum hit chance')
ui.set_visible(hc_ref, false)

---@param player number
---@return boolean
local function is_ssg08(player)
    local weapon = entity.get_player_weapon(player)
    if not weapon then return false end

    local weapon_id = entity.get_prop(weapon, "m_iItemDefinitionIndex")
    return weapon_id == 40
end

---@param cmd table
---@param player number
local function adaptive_auto_stop(cmd, player)
    local velocity = vector(entity.get_prop(player, "m_vecVelocity"))
    local speed = velocity:length2d()

    if speed > 5 then
        local forward_move = cmd.forwardmove
        local side_move = cmd.sidemove

        local direction = math.atan2(velocity.y, velocity.x)
        local move_angle = math.atan2(side_move, forward_move)

        local stop_angle = direction - move_angle
        cmd.forwardmove = -math.cos(stop_angle) * speed
        cmd.sidemove = -math.sin(stop_angle) * speed
    end

    cmd.buttons = bit.bor(cmd.buttons, bit.lshift(1, 17))
end

---@param target number
---@return number|nil
local function select_visible_hitbox(target)
    if not target or not entity.is_alive(target) then return nil end

    for hitbox = 0, 8 do
        local x, y, z = entity.hitbox_position(target, hitbox)
        if x and y and z and client.visible(x, y, z) then
            return hitbox
        end
    end
    return nil
end

---@param player_index number
---@param origin_pos vector
---@param enemy_pos vector
---@return boolean
local function fraction_detection(player_index, origin_pos, enemy_pos)
    local fraction = client.trace_line(player_index, origin_pos.x, origin_pos.y, origin_pos.z, enemy_pos.x, enemy_pos.y, enemy_pos.z)
    return fraction == 0.99 or fraction == 1
end

---@param player_index number
---@param origin_pos vector
---@param enemy_pos vector
---@return boolean
local function damage_detection(player_index, origin_pos, enemy_pos)
    local _, damage = client.trace_bullet(player_index, origin_pos.x, origin_pos.y, origin_pos.z, enemy_pos.x, enemy_pos.y, enemy_pos.z)
    return damage > 0
end

local min_value, max_value = math.huge, -math.huge

---@param spread number
---@param accuracy_penalty number
local function update_min_max_values(current_value)
    if current_value < min_value then
        min_value = current_value
    end
    if current_value > max_value then
        max_value = current_value
    end
end

client.set_event_callback('setup_command', function(cmd)
    local lp = entity.get_local_player()
    if not lp or not entity.is_alive(lp) then return end

    local weapon = entity.get_player_weapon(lp)
    if not weapon then return end

    local spread = entity.get_prop(weapon, "m_fAccuracyPenalty") or 0
    local inaccuracy = entity.get_prop(weapon, "m_fSpread") or 0

    local current_value = spread + inaccuracy
    update_min_max_values(current_value)

    if not is_ssg08(lp) then return end

    local target = client.current_threat()
    if not target or not entity.is_alive(target) then return end

    local selected_hitbox = select_visible_hitbox(target)
    local flags = entity.get_prop(lp, 'm_fFlags')
    local in_air = bit.band(flags, 1) ~= 1

    ui.set(hc_ref, ui.get(feature.def_hc))

    local fraction_result = fraction_detection(target, vector(entity.get_origin(lp)), vector(entity.get_origin(target)))
    local damage_result = damage_detection(target, vector(entity.get_origin(lp)), vector(entity.get_origin(target)))

    if damage_result and fraction_result and in_air and current_value < 0.0443 then
        ui.set(hc_ref, ui.get(feature.hit_chance_in_air))
        adaptive_auto_stop(cmd, lp)
    end
end)

client.set_event_callback('paint', function()
    if ui.get(feature.hc_in_air) then
        renderer.indicator(255, 255, 255, 255, "HC")
    end
end)

client.set_event_callback('shutdown', function()
    ui.set_visible(hc_ref, true)
end)

local function handle_ui_visibility(self)
    ui.set_visible(feature.hit_chance_in_air, ui.get(self))
end
ui.set_callback(feature.hc_in_air, handle_ui_visibility)
handle_ui_visibility(feature.hc_in_air)
 
Сверху Снизу