一.前言

因为我发现火线的鼠标宏非常多,想着自己也有罗技鼠标,看能不能自己写一写让游玩的时候更方便操作一些,可能不一定有什么帮助,但也是一个学习的过程,下面就把我自己的心得和代码详细的记录下来,好多参数都是自己一遍遍试出来的,我的鼠标是g102,有俩个侧键,ghub一定要以管理员身份运行才能使用功能,如果给你提供了灵感,咱们也可以相互提升

二.所需准备

1.简单的lua语言知识

因为罗技官方ghub驱动的编写脚本所需语言就是lua,我们只需要学习简单的基础即可,比如 if else 判断,while 循环,全局变量,注释方式之类就足够了

我在这里把lua语言了解网站发出来==>lua基础

2.罗技ghub的官方api文档

这个很重要,官方的api文档里给了很多有用的函数,比如判断鼠标按键点击,判断鼠标点击状态,里面还提供了一些lua语言的基本库,math库,string库等等,足够我们使用了,官方提供的鼠标左键点击为1,右键为2,滑轮为3

我把官方api的打开方式放下面

 创建一个新脚本

 点击脚本--》编写api脚本,之后就能看见罗技官方的api脚本了

三.代码部分

代码部分主要分8类:

1.一键鬼跳

2.一键上箱

3.一键顺JU

4.usp速点

5.雷神三连发

6.雷神压枪

7.ak火麒麟压枪

3.1 一键鬼跳

一键鬼跳我写了俩个版本,第一个版本是需要自己按住ctrl,第二个版本是不需要按住ctrl,我觉得按住ctrl的手感更好一些

基础解析:if条件句代表的是,判断鼠标按压的哪个按键,ghost_jump是一个全局变量可以随意改变,默认就是ghost_jump为5,也就是我102鼠标左边第一个侧键

代码解析:其实鬼跳就是有节奏的按空格跳跃,PressKey("spacebar")代表按下空格,sleep()代表停顿任意毫秒,这里我用了随机数更稳定一些,ReleaseKey()就代表松开按键,while循环一直判断鼠标是否在按侧键,如果侧键一直处于按压状态就一直循环直到松开侧键

提示:有人说第二版鬼跳久了会有小黑屋,所以我重新改了第二版的鬼跳代码,我试了一会还可以

-- 鬼跳(按住ctrl+方向键+侧键)

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == ghost_jump) then

while(IsMouseButtonPressed(ghost_jump))

do

PressKey("spacebar")

Sleep(math.random(8,11))

ReleaseKey("spacebar")

Sleep(math.random(8,11))

end

end

--]]

-- 鬼跳1.2(只需要按住方向键+侧键)(个人觉得没有自己按ctrl手感好)

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == ghost_jump and is_open_up) then

while(IsMouseButtonPressed(ghost_jump))

do

PressKey("spacebar")

Sleep(math.random(5,8))

PressKey("lctrl")

Sleep(math.random(1,3))

ReleaseKey("spacebar")

Sleep(math.random(8,11))

end

ReleaseKey("lctrl")

end

--]]

3.2 一键上箱

操作解析:一键上箱的按键的就是 跳 =》跳 =》蹲,这个需要一些节奏才行,下面这些停顿时间的参数都是我试了30几遍试出来的,但可能随着版本不同之后参数还需要自行测试更改,这篇文章时间为2023-7-21

-- 一键上箱1.0

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == jump_box) then

PressKey("spacebar")

Sleep(math.random(267,275))

ReleaseKey("spacebar")

Sleep(math.random(346,354))

PressKey("spacebar")

Sleep(math.random(164,172))

ReleaseKey("spacebar")

Sleep(math.random(96,104))

PressKey("lctrl")

Sleep(math.random(140,148))

ReleaseKey("lctrl")

end

--]]

3.3 一键顺

操作解析:一键顺其实就是在使用大炮的时候按住鼠标右键松手之后自动开枪并且切枪

代码解析:

瞬发:还是先if判断是哪个鼠标哪个按键,PressMouseButton()代表按压鼠,ReleaseMouseButton()为松开鼠标按键,参数1,2,3,4,5 ==> 鼠标左键为1,右键为2,滚轮按键为3,4为侧键,5也为侧键,因为我是102所以如果你的侧键更多的话可能会有更多的选择

切枪:我这里change_gun为全局参数,1为切枪,0为不切,射击之后自动按俩次q键进行快速切枪,q切枪的好处是会还原你上一次使用的道具(q切枪这个idea也是读过这篇文章的兄弟提出的建议,感谢)

-- 右键瞬狙

---[[

if (event == "MOUSE_BUTTON_RELEASED" and arg == right_fire_Ju) then

--OutputLogMessage("Hello World %f\n", math.random())

-- 瞬发

PressMouseButton(1)

Sleep(math.random(10,20))

ReleaseMouseButton(1)

-- 切枪

if(change_gun == 1) then

PressKey("q")

Sleep(math.random(9,14))

ReleaseKey("q")

Sleep(math.random(120,130))

PressKey("q")

Sleep(math.random(9,14))

ReleaseKey("q")

Sleep(math.random(9,14))

end

end

--]]

3.4 usp速点

操作解析:本质就是连续快速的点击鼠标左键,usp只有第一枪需要压枪,剩下都是一个点,我这里虽然写了usp压枪,但作用不是很大,我这里设置了一个全局变量,usp_push_gun为true或者false,用于判断是否进行压枪操作

代码解析:IsMouseButtonPressed()用于判断鼠标按键是否处于按压状态,MoveMouseRelative()代表控制鼠标进行相对移动,包含俩个参数,代表x,y分别移动多少距离,因为火线的行向弹道都是随机的,所以只能对纵向进行压制,每次循环向下移动三个像素也就是向下压枪,最后需要注意的是每次点击和释放之间以及多次点击之间需要有间隔停顿,我建议30微妙-40微妙之间比较稳定,过快会出问题

-- usp连发

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == usp_fire) then

-- usp连发压枪

time_sum = 0

move_y = 0

if(usp_push_gun)then

move_y = 3

end

while(IsMouseButtonPressed(usp_fire))

do

MoveMouseRelative(0,move_y)

PressMouseButton(1)

usp_speed_end = usp_speed + 10

time_one = math.random(usp_speed,usp_speed_end)

Sleep(time_one)

ReleaseMouseButton(1)

time_two = math.random(usp_speed,usp_speed_end)

Sleep(time_two)

time_sum = time_sum + time_one + time_two

if(time_sum > 300)

then

move_y = 0

end

end

end

--]]

3.5 雷神三连发

操作解析:众所周知雷神的前三发弹道非常准,是不用压枪的,所以只需要卡住前三发的时间松开鼠标左键就可以了,代码也很简单

-- 雷神三连发

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == tree_constant) then

-- 下面注意,判断是否按压的值和正在按压的值不同,分别是132和123value

--OutputLogMessage("Hello World %d\n",2007)

PressMouseButton(1)

Sleep(math.random(178,190))

ReleaseMouseButton(1)

Sleep(math.random(45,53))

end

end

--]]

3.6 雷神压枪

操作解析:因为前面说了火线的横向弹道是随机的,我测试了一下一共有四种横向弹道,所以只能控制纵向的压枪

代码解析:循环压枪通过随机间隔向下移动3个像素,当总间隔时间达到阈值也就是我设置的330微秒之后就停止压枪,前60微妙不需要压枪,也就是前俩发速点,m4雷神的弹道都是前面子弹向上移动,后面子弹左右移动,达到阈值之后不进行压枪自己控制左右即可,这里全局函数force_gun默认是鼠标左键也就是1

注意:IsMouseButtonPressed()这个函数很反常,里面参数1代表左键,2代表滚轮键,3代表右键,和其他函数不同,其他函数2代表右键,3代表滚轮

-- 雷神压枪2.0

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == force_gun_m4 and is_open_up) then

move_y = 3 --纵向移动坐标

move_x = 0 --横向移动坐标

time_all = 0 --枪口停止压枪阀

--last_x_pos = 0 --上次的x坐标

--last_y_pos = 0 --上次的y坐标

--last_x_pos ,last_y_pos = GetMousePosition()

--循环压枪

while(IsMouseButtonPressed(force_gun_m4))

do

if (time_all < 60)

then

--前2发不压

move_y = 0

end

time_one = math.random(7,10)

Sleep(time_one)

MoveMouseRelative(move_x,move_y)

time_two = math.random(7,10)

Sleep(time_two)

time_all = time_all + time_one + time_two

if (time_all > 360)

then

--达到压枪阈值纵坐标停止运动

move_y = 0

-- 横坐标开始运动

--current_x_pos,current_y_pos = GetMousePosition() --获取当前鼠标坐标

--如果当前鼠标移动,自动像反方向压枪

else

move_y = 3

end

end

end

--]]

3.7 AK火麒麟压枪

代码解析:其实火麒麟和雷神压枪差不多,就是力度加强了一点,然后稍微改了些延迟,防止进黑屋,火麒麟单点不压

-- AK压枪

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == force_gun_ak and is_open_up) then

move_y = 4 --纵向移动坐标

move_x = 0 --横向移动坐标

time_all = 0 --枪口停止压枪阀

--last_x_pos = 0 --上次的x坐标

--last_y_pos = 0 --上次的y坐标

--last_x_pos ,last_y_pos = GetMousePosition() --获取初始位置

--OutputLogMessage("%d,%d\n",last_x_pos,last_y_pos)

--sum_move_y = 0 --y轴移动全部距离

--循环压枪

while(IsMouseButtonPressed(force_gun_ak))

do

if (time_all < 40)

then

--单点不压

move_y = 0

end

--time_one = math.random(5,11)

--Sleep(time_one)

MoveMouseRelative(move_x,move_y)

--sum_move_y = sum_move_y + move_y --计算移动后的距离

time_two = math.random(10,22)

Sleep(time_two)

time_all = time_all + time_two

if (time_all > 430)

then

--达到压枪阈值纵坐标停止运动

move_y = 0

-- 横坐标开始运动

--current_x_pos,current_y_pos = GetMousePosition() --获取当前鼠标坐标

--如果当前鼠标移动,自动像反方向压枪

else

move_y = 4

end

end

--sum_move_y = 0 - sum_move_y

--OutputLogMessage("%d\n",sum_move_y)

--MoveMouseRelative(0,sum_move_y) --位置回执

--last_x_pos ,last_y_pos = GetMousePosition() --获取初始位置

--OutputLogMessage("%d,%d\n",last_x_pos,last_y_pos)

end

--]]

小视频展示如下:

ak火麒麟

四.总结

所有代码如下,我设置了很多全局变量用来当作开关,设置0就是关闭功能,设置1-5就是设置其为哪个鼠标按键进行触发,还可以调节usp的速度等等功能

小tips: 如果想知道自己鼠标的按键和侧键都代表数字几,可以将下面这条注释打开==》

--OutputLogMessage("Event: "..event.." Arg: "..arg.."\n"),删除前俩个 -- 就是解开注释,大块的注释类似于这种(--[[  --]])在第一组方括号之前添加一个 - 就是解开大块注释了

------------------2023-7-24 start----------------

有人建议我添加一个总开关,可以一键开启所有或者关闭所有功能,我就更新一下代码,all_button这个属性就代表着总开关的按键,我是g102设置的默认为4也就是第二个侧键,设置你想要的按键之后,点击一下就关闭所有功能,再次点击就开启了,默认是开启状态

------------------2023-7-24 end----------------

------------------2023-8-10 start----------------

回答一下大家问的比较多的问题:

1)会不会封号?

经过我自己长时间的使用,我的建议是最好不要长时间使用鬼跳,我排位鬼跳用了2个多小时进过一次一小时黑屋,usp的话目前33毫秒还是很稳定的,但是千万不要一直按,比如你打空了一梭子usp子弹,在它换子弹的时候就不要继续按个不停了,要不然很容易出现异常,什么都要适度。其他的功能目前还没有出现过问题,最后最重要的一点就是,这个东西最坏的情况也就是一小时小黑屋,不会十年的

2)使用方法

我建议没有编程基础想用下面代码的一定要全部复制,不要你需要什么功能就复制什么功能,不然很容易漏掉一些重要代码,代码总开关,usp,雷神,usp功能是默认开启的,这样是方便导入代码的测试,不想用的功能就改为0,想用的功能就改成你自己的侧键就行了,括号里的数字是我建议更改的按键数字,比如瞬狙就一定要是2才行,也就是鼠标右键按住才是合理的,雷神和AK是鼠标左键1,鼠标左右键最后不要随意使用到其他的功能,除非你能读懂或者改明白代码才行,最后注释的地方你不需要可以删除

建议:雷神,火麒麟鼠标设为1(左键),顺狙为2(鼠标右键),其他功能设置为侧键就行了,最后不用的功能一定设为0,防止冲突,鬼跳我这里开启的是自己按ctrl蹲的版本,如果改自己改一下注释就行了(鬼跳跳久了可能会黑屋)

3)如何知道自己鼠标每个按键代表数字几?

将代码第25行的注释打开,--OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")这条代码,将前面俩个横杠删除再ctrl + s 保存就打开这条注释了,然后调出控制台,点击鼠标不同的按键就会在控制台提示对应的数字了,控制台打开方法我放下面了(左上角浏览==》控制台)

------------------2023-8-10 end----------------

注意:运行罗技ghub的时候一定记得以管理员身份运行,修改按键之后也要记得 ctrl + s 保存,不然好多功能无法使用

-- 基础设置

-- 罗技鼠标dpi为800,穿越火线内设置速度为12

-- 使用哪个就将0改为对应数字即可,关闭为0

local all_button = 4 -- 总开关按键(4)(默认是开启)

local right_fire_Ju = 0 -- 右键瞬狙开关(2)

local usp_fire = 5 -- usp连发(5)

local jump_box = 0 -- 一键上箱开关(5)

local ghost_jump = 0 -- 鬼跳开关(5)

local tree_constant = 0 -- 雷神三连发开关(1)

local force_gun_m4 = 1 -- 雷神压枪开关(1)

local force_gun_ak = 0 -- 火麒麟压枪开关(1)

--属性设置,不更改为默认

local change_gun = 1 -- 瞬狙之后是否切枪(1为切枪,0为不切)

local usp_speed = 33 -- usp速度,默认20毫秒起步

local usp_push_gun = false-- usp是否压枪,true为压枪,false为否,按习惯来

local is_open_up = true -- 总开关属性(不用修改)

EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)

--OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")

-- 控制总开关(按键开启或者关停所有功能)

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == all_button) then

is_open_up = not is_open_up

end

--]]

-- 一键上箱1.0

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == jump_box and is_open_up) then

PressKey("spacebar")

Sleep(math.random(267,275))

ReleaseKey("spacebar")

Sleep(math.random(346,354))

PressKey("spacebar")

Sleep(math.random(164,172))

ReleaseKey("spacebar")

Sleep(math.random(96,104))

PressKey("lctrl")

Sleep(math.random(140,148))

ReleaseKey("lctrl")

end

--]]

-- 右键瞬狙

---[[

if (event == "MOUSE_BUTTON_RELEASED" and arg == right_fire_Ju and is_open_up) then

--OutputLogMessage("Hello World %f\n", math.random())

-- 瞬发

PressMouseButton(1)

Sleep(math.random(20,30))

ReleaseMouseButton(1)

-- 切枪

if(change_gun == 1) then

PressKey("q")

Sleep(math.random(9,14))

ReleaseKey("q")

Sleep(math.random(130,160))

PressKey("q")

Sleep(math.random(9,14))

ReleaseKey("q")

Sleep(math.random(9,14))

end

end

--]]

-- usp连发

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == usp_fire and is_open_up) then

-- usp连发压枪

time_sum = 0

move_y = 0

if(usp_push_gun)then

move_y = 3

end

while(IsMouseButtonPressed(usp_fire))

do

MoveMouseRelative(0,move_y)

PressMouseButton(1)

usp_speed_end = usp_speed + 10

time_one = math.random(usp_speed,usp_speed_end)

Sleep(time_one)

ReleaseMouseButton(1)

time_two = math.random(usp_speed,usp_speed_end)

Sleep(time_two)

time_sum = time_sum + time_one + time_two

if(time_sum > 300)

then

move_y = 0

end

end

end

--]]

-- 鬼跳(按住ctrl+方向键+侧键)

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == ghost_jump and is_open_up) then

while(IsMouseButtonPressed(ghost_jump))

do

PressKey("spacebar")

Sleep(math.random(8,11))

ReleaseKey("spacebar")

Sleep(math.random(8,11))

end

end

--]]

-- 鬼跳1.2(只需要按住方向键+侧键)(个人觉得没有自己按ctrl手感好)

--[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == ghost_jump and is_open_up) then

while(IsMouseButtonPressed(ghost_jump))

do

PressKey("spacebar")

Sleep(math.random(5,8))

PressKey("lctrl")

Sleep(math.random(1,3))

ReleaseKey("spacebar")

Sleep(math.random(8,11))

end

ReleaseKey("lctrl")

end

--]]

-- 雷神三连发

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == tree_constant and is_open_up) then

-- 下面注意,判断是否按压的值和正在按压的值不同,分别是132和123value

--OutputLogMessage("Hello World %d\n",2007)

PressMouseButton(1)

Sleep(math.random(178,190))

ReleaseMouseButton(1)

Sleep(math.random(45,53))

end

--]]

-- 雷神连续3连发

--[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == tree_constant and is_open_up) then

-- 下面注意,判断是否按压的值和正在按压的值不同,分别是132和123value

while(IsMouseButtonPressed(tree_constant))

do

--OutputLogMessage("Hello World %d\n",2007)

PressMouseButton(1)

Sleep(math.random(178,190))

ReleaseMouseButton(1)

Sleep(math.random(45,53))

end

end

--]]

-- 雷神压枪2.0

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == force_gun_m4 and is_open_up) then

move_y = 3 --纵向移动坐标

move_x = 0 --横向移动坐标

time_all = 0 --枪口停止压枪阀

--last_x_pos = 0 --上次的x坐标

--last_y_pos = 0 --上次的y坐标

--last_x_pos ,last_y_pos = GetMousePosition()

--循环压枪

while(IsMouseButtonPressed(force_gun_m4))

do

if (time_all < 60)

then

--前2发不压

move_y = 0

end

time_one = math.random(7,10)

Sleep(time_one)

MoveMouseRelative(move_x,move_y)

time_two = math.random(7,10)

Sleep(time_two)

time_all = time_all + time_one + time_two

if (time_all > 360)

then

--达到压枪阈值纵坐标停止运动

move_y = 0

-- 横坐标开始运动

--current_x_pos,current_y_pos = GetMousePosition() --获取当前鼠标坐标

--如果当前鼠标移动,自动像反方向压枪

else

move_y = 3

end

end

end

--]]

-- AK压枪

---[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == force_gun_ak and is_open_up) then

move_y = 4 --纵向移动坐标

move_x = 0 --横向移动坐标

time_all = 0 --枪口停止压枪阀

--last_x_pos = 0 --上次的x坐标

--last_y_pos = 0 --上次的y坐标

--last_x_pos ,last_y_pos = GetMousePosition() --获取初始位置

--OutputLogMessage("%d,%d\n",last_x_pos,last_y_pos)

--sum_move_y = 0 --y轴移动全部距离

--循环压枪

while(IsMouseButtonPressed(force_gun_ak))

do

if (time_all < 40)

then

--单点不压

move_y = 0

end

--time_one = math.random(5,11)

--Sleep(time_one)

MoveMouseRelative(move_x,move_y)

--sum_move_y = sum_move_y + move_y --计算移动后的距离

time_two = math.random(10,22)

Sleep(time_two)

time_all = time_all + time_two

if (time_all > 430)

then

--达到压枪阈值纵坐标停止运动

move_y = 0

-- 横坐标开始运动

--current_x_pos,current_y_pos = GetMousePosition() --获取当前鼠标坐标

--如果当前鼠标移动,自动像反方向压枪

else

move_y = 4

end

end

--sum_move_y = 0 - sum_move_y

--OutputLogMessage("%d\n",sum_move_y)

--MoveMouseRelative(0,sum_move_y) --位置回执

--last_x_pos ,last_y_pos = GetMousePosition() --获取初始位置

--OutputLogMessage("%d,%d\n",last_x_pos,last_y_pos)

end

--]]

--获取毫秒

--[[

if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then

OutputLogMessage("%d ms\n", GetRunningTime())

--OutputLogMessage("%s\n", GetDate())

--OutputLogMessage("%d\n", GetMKeyState())

end

--]]

--左右横压

--[[if(time_all < 400)then

move_x = -1

--OutputLogMessage("LEFT\n")

end

if(time_all > 400 and time_all < 530)then

move_x = 1

--OutputLogMessage("RIGHT\n")

end

if(time_all > 530)then

move_x = 0

end

--]]

end

最后,如果有没看懂的或者哪个地方有更好的优化可以发我邮箱,874302104@qq.com,完毕!

参考链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: