备战2018cf自动开枪挂归纳总结(实战篇)
编辑: admin 2017-12-07
-
4
CF自动开枪
工具/原料
按键精灵
方法/步骤
1将以下代码复制
UserVar Var1=30 "开枪频率"
UserVar Var2=1 "单次开枪子弹数量"
UserVar Var3=0 "第一枪延迟"
UserVar Var4=55 "压枪延迟"
//定义变量
DimEnv iWidth ,iHeight //int 屏幕分辨率
DimEnv iFD //开枪频率
iFD=Var1
DimEnv iFN //几发连射
iFN=Var2
DimEnv iFFD //第一枪延迟
iFFD=Var3
DimEnv iND //压枪延迟
iND=Var4
//调用主函数
Call Main()
//**Main
//程序入口主函数
Sub Main()
//int 四个角的坐标
Dim iLT,iRT,iLB,iRB
//临时对象
Dim vTemp
Dim bCanShoot
Dim sStr
//得到分辨率(四个坐标)
sStr=getParameter()
//把返回的坐标分割成数组
vTemp=Split(sStr, "|", -1, 1)
iLT=vTemp(0)
iRT=vTemp(1)
iLB=vTemp(2)
iRB=vTemp(3)
//启用设置开枪频率线程
BeginThread setFireDelay
//循环脚本
While True
Delay 1
//搜索射程内的敌人
bCanShoot=findFoe(iLT,iRT,iLB,iRB)
//进入射程
If bCanShoot
//第一枪延迟
Delay iFFD
//射击
Call shootFoe()
//如果没有命中就压枪
If Bingo
Delay iND
End If
End If
Wend
End Sub
//**Function
//功能:判断屏幕分辨率
//返回:四个坐标的字符串
Function getParameter()
Dim iLT,iRT,iLB,iRB //int 四个角的坐标
iWidth = Plugin.Sys.GetScRX() //得到屏幕的宽度
iHeight = Plugin.Sys.GetScRY() //得到屏幕的高度
If iWidth=800 Then
iLT=0
iRT=0
iLB=0
iRB=0
ElseIf iWidth=1024 Then
iLT=112 //加上坐标偏移
iRT=84
iLB=112
iRB=84
ElseIf iWidth=1280 Then
iLT=240 //加上坐标偏移
iRT=100
iLB=240
iRB=100
End If
iLT=iLT+380 //LeftTop 左上角
iRT=iRT+345 //RightTop 右上角
iLB=iLB+420 //LeftBottom 左下角
iRB=iRB+355 //RightBottom 右下角
getParameter=iLT&"|"&iRT&"|"&iLB&"|"&iRB //返回字符串
End Function
//**Function
//功能:判断射程内是否有敌人
//返回:是True,否False
Function findFoe(iLT,iRT,iLB,iRB)
Dim sColor(3) //Array(string) 用于存放颜色的数组
Dim i //int 循环变量
Dim iX,iY //int 得到颜色的坐标
Dim bHave //boolean 是否找到敌人
//初始化颜色
sColor(0)="303AA5"
sColor(1)="2A3EB8"
sColor(2)="1849F0"
sColor(3)="1849F0"
bHave=false //初始化
//找颜色
For i=0 to 3 step 1
Call FindColorEx(iLT,iRT,iLB,iRB,sColor(i),1,0.7,iX,iY)
If iX>0 And iY>0
bHave=true //找到了
KeyPress 44, 1
Goto rHave //跳出
End If
Next
Rem rHave
findFoe=bHave//Return 函数返回值
End Function
//**Function
//功能:判断是否没有命中敌人
//返回:是True,否False
Function noBingo()
Dim iX,iY //int 得到颜色的坐标
Call FindColorEx(iWidth/2-5,iHeight/2-5,iWidth/2+5,iHeight+5,"7E7EC0",1,0.7,iX,iY)
If iX > 0 Then
noBingo=True
Else
noBingo=False
End If
End Function
//**Sub
//功能:射击
Sub shootFoe()
//------------------------------------------------------------
//下面是破cf230错误机枪开枪源码
s = Plugin.Sys.GetTime()
xs=int(s/1000/60/60)
fz=int(s/1000/60)-xs*60
m=Clng(s/1000)-fz*60-xs*60*60
//下面是我计算的获取毫秒用于开枪调用
hm=int(s-xs*60*60*1000-fz*1000*60-m*1000)+500
//下面是800毫秒正常开枪,不出230可以再往上调,反之往下调
If hm<800 Then
SetSimMode 2
LeftClick iFN
End If
Delay iFD //延迟 * 毫秒
End Sub
//**Sun
//参数(字符串,秒,第几行)
//功能:显示字符串
Sub showStr(str,n,row)
For n*100
Delay 1
Call Plugin.Msg.ShowScrTXT(0, (row-1)*19, 120, 19, str, "0000FF")
Next
End Sub
//**Sun
//功能:设置开枪延迟
//# 多线程启动
Sub setFireDelay()
Dim key
While True
key=WaitKey()
If key=37
iFD=iFD-1 //缩小开枪延迟
Call showStr("开枪频率为"&iFD&"毫秒",5,1)
ElseIf key=39 //方向键 右
iFD=iFD+1 //增加开枪延迟
Call showStr("开枪频率为"&iFD&"毫秒",5,1)
ElseIf key=38 //方向键 右
iFD=iFD+5 //增加开枪延迟
Call showStr("开枪频率为"&iFD&"毫秒",5,1)
ElseIf key=40 //方向键 右
iFD=iFD-5 //增加开枪延迟
Call showStr("开枪频率为"&iFD&"毫秒",5,1)
End If
Wend
End Sub
2复制上面的代码,打开按键精灵点击新建。

4点击源文件,并粘贴。

5点击调试

6这时它会问你是否保存,如果你想保存的话那就点击是。我这里点击是。

7点击启动,然后打开CF游戏。这样就实现了自动开枪。
