-- Apex Legends 罗技压枪脚本 (Tab键开关)
-- 版本: 1.1
-- 更新日期: 2025-09-07
local recoilCompensation = false -- 压枪补偿默认关闭
local currentWeaponProfile = 1 -- 默认武器配置
-- 武器配置库(可根据实际使用调整参数)
local weaponProfiles = {
-- 配置文件1: 轻型弹药武器 (R-301, R-99, RE-45等)
{name = "Light Ammo", verticalRecoil = 10, horizontalRecoil = 2, sleepDuration = 15},
-- 配置文件2: 重型弹药武器 (Flatline, Wingman, Hemlok等)
{name = "Heavy Ammo", verticalRecoil = 14, horizontalRecoil = 3, sleepDuration = 18},
-- 配置文件3: 能量弹药武器 (Volt, Devotion, L-Star等)
{name = "Energy Ammo", verticalRecoil = 12, horizontalRecoil = 4, sleepDuration = 12},
-- 配置文件4: 狙击步枪 (Sentinel, Longbow, Charge Rifle等)
{name = "Sniper Rifles", verticalRecoil = 20, horizontalRecoil = 1, sleepDuration = 30},
-- 配置文件5: 霰弹枪 (Mastiff, EVA-8, Peacekeeper等)
{name = "Shotguns", verticalRecoil = 25, horizontalRecoil = 5, sleepDuration = 50}
}
-- 随机数种子初始化
math.randomseed(GetRunningTime())
-- 启用主鼠标按钮事件检测
EnablePrimaryMouseButtonEvents(true)
-- 主事件处理函数
function OnEvent(event, arg)
-- Tab键按下事件处理 (G9通常对应键盘Tab键,需在G Hub中绑定)
if event == "G_PRESSED" and arg == 9 then
recoilCompensation = not recoilCompensation
OutputLogMessage("压枪补偿: %s\n", recoilCompensation and "开启" or "关闭")
end
-- 鼠标侧键切换武器配置(可选功能)
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then -- 侧键5
currentWeaponProfile = currentWeaponProfile % #weaponProfiles + 1
OutputLogMessage("武器配置切换为: %s\n", weaponProfiles[currentWeaponProfile].name)
end
-- 左键按下时的处理(压枪补偿)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoilCompensation then
RecoilCompensation()
end
end
-- 压枪补偿函数
function RecoilCompensation()
local profile = weaponProfiles[currentWeaponProfile]
local moveX = 0
local moveY = profile.verticalRecoil
-- 添加小幅随机水平偏移(更自然)[citation:5]
if profile.horizontalRecoil > 0 then
moveX = math.random(-profile.horizontalRecoil, profile.horizontalRecoil)
end
-- 添加小幅随机延迟(更自然)
local sleepTime = profile.sleepDuration + math.random(-5, 5)
-- 执行压枪动作[citation:5]
MoveMouseRelative(moveX, moveY)
Sleep(sleepTime)
end