2.0后坐标和抓的图必须重新做。
自己学习按键做的第一个脚本,很花了几天,这个过程中学到不少知识,现在发出来分享下。
2.0以前自己电脑上测试效果蛮好的,呵呵。
脚本很简单,高手莫喷,但是个人觉得思路不错,源码里相当于已经有了自动瞄准脚本哦,现在市面上还有卖的,嘿嘿 ,小小的得意一下。
简单说下思路:
首先把所有地图右上角透明框长度存入tl数组,30定,50定。。。。。70定力度数据存入对应数组【当然你可以存入更详细的数据,使更精确,我这里加入了角度修正,其实由于没有考虑风力以及找色读出的角度有时存在1度左右误差,休不休正和考不考虑风都没多大关系(毕竟只为挂机),关于角度,我在这里卡住了一天,本来是想用OCR直接读出角度,但是自制点阵后发现由于地图变换,识别也不尽人意,后来只有找色求角,还好效果不错,这都是过程中遇到的问题】
继续,说说抓图,识别地图的图找画面上始终固定的部分抓,我都是在小地图里抓,判读载入地图否找画面右下角抓,然后就是找红蓝两色计算屏距,在蓄力图出现的情况下找左上角颜色进行判断自己的颜色,颜色,角度,屏距,都知道了,打击力度就简单了,就是delay的时间问题了,看看源码应该就明白了。
脚本直接用的大兵的插件,看不明白的可以看一下大兵的函数说明,大兵是好人啊 呵呵
最后谢谢大大的银币和鲜花啊,在论坛上找了很多前辈大大的帖子,感谢感谢,共同学习,共同进步。
果真都是拿来主义,没几个喜欢写脚本的,结贴 有需要源码的留言
有人要源码,再度贴出。
请不要将此源码用于商业用途,只供学习交流,其他作者一概不负责!!!
//tl为透明框长,ss为30定20距对应力度
VBS dim hwnd,TL(42),ss(20),ws(20),ls(20),lw(20),qs(20),sj,tj,jdxz
Dim jb
Plugin jb=Window.MousePoint()
hwnd=jb
tj=10
jdxz=0.06
maxt=4
ss(0)=0:ss(1)=1.4:ss(2)=2:ss(3)=2.47:ss(4)=2.87:ss(5)=3.23:ss(6)=3.57:ss(7)=3.88:ss(8)=4.18:ss(9)=4.47:ss(10)=4.75:ss(11)=5.02:ss(12)=5.28:ss(13)=5.53:ss(14)=5.79:ss(15)=6.03:ss(16)=6.27:ss(17)=6.51:ss(18)=6.75:ss(19)=6.98:ss(20)=7.21
ws(0)=0:ws(1)=1.41:ws(2)=2.01:ws(3)=2.48:ws(4)=2.88:ws(5)=3.25:ws(6)=3.59:ws(7)=3.9:ws(8)=4.2:ws(9)=4.49:ws(10)=4.77:ws(11)=5.04:ws(12)=5.3:ws(13)=5.56:ws(14)=5.81:ws(15)=6.06:ws(16)=6.3:ws(17)=6.54:ws(18)=6.78:ws(19)=7.02:ws(20)=7.25
ls(0)=0:ls(1)=1.55:ls(2)=2.21:ls(3)=2.73:ls(4)=3.17:ls(5)=3.57:ls(6)=3.95:ls(7)=4.29:ls(8)=4.63:ls(9)=4.94:ls(10)=5.25:ls(11)=5.55:ls(12)=5.84:ls(13)=6.12:ls(14)=6.4:ls(15)=6.67:ls(16)=6.94:ls(17)=7.2:ls(18)=7.46:ls(19)=7.72:ls(20)=7.97
lw(0)=0:lw(1)=1.6:lw(2)=2.3:lw(3)=2.9:lw(4)=3.3:lw(5)=3.7:lw(6)=4.1:lw(7)=4.4:lw(8)=4.85:lw(9)=5.3:lw(10)=5.6:lw(11)=5.8:lw(12)=6.1:lw(13)=6.4:lw(14)=6.7:lw(15)=7:lw(16)=7.3:lw(17)=7.6:lw(18)=7.9:lw(19)=8.2:lw(20)=8.5
qs(0)=0:qs(1)=1.85:qs(2)=2.64:qs(3)=3.26:qs(4)=3.79:qs(5)=4.27:qs(6)=4.72:qs(7)=5.13:qs(8)=5.53:qs(9)=5.91:qs(10)=6.28:qs(11)=6.63:qs(12)=6.98:qs(13)=7.31:qs(14)=7.65:qs(15)=7.97:qs(16)=8.29:qs(17)=8.61:qs(18)=8.92:qs(19)=9.23:qs(20)=9.53
TL(0)=0:TL(1)=78 :TL(2)=108:TL(3)=82 :TL(4)=67 :TL(5)=92 :TL(6)=97 :TL(7)=93 :TL(8)=98 :TL(9)=92 :TL(10)=119:TL(11)=105:TL(12)=78 :TL(13)=106:TL(14)=114:TL(15)=111:TL(16)=65:TL(17)=94 :TL(18)=94 :TL(19)=86 :TL(20)=150:TL(21)=70 :TL(22)=119:TL(23)=113:TL(24)=124:TL(25)=109:TL(26)=81 :TL(27)=115:TL(28)=109:TL(29)=104:TL(30)=100:TL(31)=130:TL(32)=125:TL(33)=138:TL(34)=118:TL(35)=82:TL(36)=111:TL(37)=123:TL(38)=104:TL(39)=103:TL(40)=92:TL(41)=145:TL(42)=80
Plugin DBSoft.RegDBSoft("F27873CF2364C2129452C57003F97017")
Rem 开始
//移动到 创建 坐标并点击 坐标(701,505)
Plugin Bkgnd.MoveTo(Hwnd, 920, 550)
Delay 100
Plugin Bkgnd.LeftClick(Hwnd,920, 550)
Delay 100
//移动并点击 确定 坐标(435,507)
Plugin Bkgnd.MoveTo (hwnd,665,550)
Delay 100
Plugin Bkgnd.LeftClick(Hwnd,665, 550)
Delay 2000
//点击开始游戏 坐标 937,513
Plugin Bkgnd.MoveTo(Hwnd, 1152, 555)
Delay 100
Plugin Bkgnd.LeftClick(Hwnd,1152, 555)
Delay 1000
//判断是否跳过等待并载入地图
i=0
Rem 判
Plugin pan=DBSoft.FindPic(hwnd,1139,519,1217,592,"C:\Documents and Settings\nayan\My Documents\ddt\pan.bmp",0.8,-2,1)
//记录开始时间分
Plugin bsj=DBSoft.GetTimePerson("",4)
bsj=clng(bsj)
If pan(0)>=0 and pan(1)>=0
MessageBox "zhaodaopan"
Goto 识别地图
Else
If i<=65000
i=i+1000
Delay 1000
Else
Goto 开始
EndIf
Goto 判
EndIf
// 识别图
Rem 识别地图
Plugin map=DBSoft.FindMorePicInScreenEx(hwnd,888,58,1225,196,"C:\Documents and Settings\nayan\My Documents\ddt\dt","*.bmp",0.4,-1,8)
If map(0)>0
j=clng(map(1))
MessageBox "地图是"&j
Else
Goto 识别地图
EndIf
//判断自己颜色 yanse=1 则为红
Rem 判断颜色
Plugin xu=DBSoft.FindPic(hwnd,339,163,428,199,"C:\Documents and Settings\nayan\My Documents\ddt\蓄力.bmp",0.8,-2,1)
If xu(0)>=0 and xu(1)>=0
Plugin ys =DBSoft.GetColorXY(hwnd,230,64,280,77, "1A1AD2","30,30,30",2)
X = Clng(YS(0)): Y = Clng(YS(1))
If x>0 and y>0
yanse=1
Else
yanse=2
EndIf
//MessageBox "调试1颜色是"&yanse
Else
Goto 判断颜色
EndIf
Rem 判断开炮
Plugin xu=DBSoft.FindPic(hwnd,339,163,428,199,"C:\Documents and Settings\nayan\My Documents\ddt\蓄力.bmp",0.8,-2,1)
//判断当前时间分
Plugin esj=DBSoft.GetTimePerson("",4)
esj=clng(esj)
sjt=esj-bsj
If sjt>=maxt
Goto 自杀
Else
Delay 100
EndIf
If xu(0)>=0 and xu(1)>=0
//计算pj
Plugin HXY =DBSoft.GetColorXY(hwnd,888,58,1225,196, "0000FF","0,0,0",2)
Delay 200
HX =clng(HXY(0)): HY =clng(HXY(1))
Plugin LXY =DBSoft.GetColorXY(hwnd,888,58,1225,196, "FFCC00","0,0,0",2)
Delay 200
LX=clng(LXY(0))Y=clng(LXY(1))
//MessageBox hx
// MessageBox lx
juli=abs(HX-LX)
pj=clng(10*juli/tl(j))
// MessageBox "距离是"&juli
// MessageBox "屏距是"&pj
//判断道具有无
Plugin daoju1 =DBSoft.GetColorXY(hwnd,1179,212,1196,229, "5D6DE4","30,30,30",2)
Plugin daoju2 =DBSoft.GetColorXY(hwnd,1177,267,1204,281, "D29820","30,30,30",2)
dj1=clng(daoju1(0))
dj2=clng(daoju2(0))
If dj1>0 and dj2>0
//使用道具1 2
Plugin Bkgnd.KeyPress(Hwnd, 97)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 98)
Delay 200
Else
//使用zxc
Plugin Bkgnd.KeyPress(Hwnd, 90)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 88)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 67)
Delay 200
EndIf
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 100
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 20
If yanse=1
If HX-LX<=0
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 300
//找定点计算角度 角度数jds 角度差jdc
Plugin zb=DBSoft.GetColorXY(hwnd,222,548,343,649,"0000FF","0,0,0",2)
Delay 200
c=clng(zb(0)):d=clng(zb(1))
Plugin jiaodu=DBSoft.Angle3Point(c,d,294,597,c,597,1)
jds=abs(clng(jiaodu))
dim jdcz(4),jdc(4)
jdcz(0)=30-jds:jdcz(1)=50-jds:jdcz(2)=60-jds:jdcz(3)=65-jds:jdcz(4)=70-jds
jdc(0)=abs(30-jds):jdc(1)=abs(50-jds):jdc(2)=abs(60-jds):jdc(3)=abs(65-jds):jdc(4)=abs(70-jds)
//zx为最小下标 zxz为最小角度差数值
Plugin zx=DBSoft.MinNum(jdc,1)
Plugin zxz=DBSoft.MinNum(jdcz,0)
zx=clng(zx):zxz=clng(zxz)
//角度差修正
pj=pj+jdxz*zxz
// MessageBox "角度代号"&zx
If zx=0
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ss(pj)/10*3500+tj
Delay sj
EndIf
If zx=1
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ws(pj)/10*3500+tj
Delay sj
EndIf
If zx=2
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ls(pj)/10*3500+tj
Delay sj
EndIf
If zx=3
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=lw(pj)/10*3500+tj
Delay sj
EndIf
If zx=4
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=qs(pj)/10*3500+tj
Delay sj
EndIf
Plugin Bkgnd.KeyUp(Hwnd, 32)
Else
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 300
//找定点计算角度 角度数jds 角度差jdc
Plugin zb=DBSoft.GetColorXY(hwnd,222,548,343,649,"0000FF","0,0,0",2)
Delay 200
c=clng(zb(0)):d=clng(zb(1))
Plugin jiaodu=DBSoft.Angle3Point(c,d,294,597,c,597,1)
jds=abs(clng(jiaodu))
dim jdcz(4),jdc(4)
jdcz(0)=30-jds:jdcz(1)=50-jds:jdcz(2)=60-jds:jdcz(3)=65-jds:jdcz(4)=70-jds
jdc(0)=abs(30-jds):jdc(1)=abs(50-jds):jdc(2)=abs(60-jds):jdc(3)=abs(65-jds):jdc(4)=abs(70-jds)
//zx为最小下标 zxz为最小角度差数值
Plugin zx=DBSoft.MinNum(jdc,1)
Plugin zxz=DBSoft.MinNum(jdcz,0)
zx=clng(zx):zxz=clng(zxz)
//角度差修正
pj=pj+jdxz*zxz
// MessageBox "角度代号"&zx
If zx=0
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ss(pj)/10*3500+tj
Delay sj
EndIf
If zx=1
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ws(pj)/10*3500+tj
Delay sj
EndIf
If zx=2
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ls(pj)/10*3500+tj
Delay sj
EndIf
If zx=3
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=lw(pj)/10*3500+tj
Delay sj
EndIf
If zx=4
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=qs(pj)/10*3500+tj
Delay sj
EndIf
Plugin Bkgnd.KeyUp(Hwnd, 32)
EndIf
Else
If LX-HX<=0
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 200
// MessageBox "向右"
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 200
// MessageBox "向左"
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 200
// MessageBox "向左"
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 300
// MessageBox "向右"
//找定点计算角度 角度数jds 角度差jdc
Plugin zb=DBSoft.GetColorXY(hwnd,222,548,343,649,"0000FF","0,0,0",2)
Delay 200
c=clng(zb(0)):d=clng(zb(1))
Plugin jiaodu=DBSoft.Angle3Point(c,d,294,597,c,597,1)
jds=abs(clng(jiaodu))
dim jdcz(4),jdc(4)
jdcz(0)=30-jds:jdcz(1)=50-jds:jdcz(2)=60-jds:jdcz(3)=65-jds:jdcz(4)=70-jds
jdc(0)=abs(30-jds):jdc(1)=abs(50-jds):jdc(2)=abs(60-jds):jdc(3)=abs(65-jds):jdc(4)=abs(70-jds)
//zx为最小下标 zxz为最小角度差数值
Plugin zx=DBSoft.MinNum(jdc,1)
Plugin zxz=DBSoft.MinNum(jdcz,0)
zx=clng(zx):zxz=clng(zxz)
//角度差修正
pj=pj+jdxz*zxz
// MessageBox "角度代号"&zx
If zx=0
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ss(pj)/10*3500+tj
Delay sj
EndIf
If zx=1
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ws(pj)/10*3500+tj
Delay sj
EndIf
If zx=2
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ls(pj)/10*3500+tj
Delay sj
EndIf
If zx=3
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=lw(pj)/10*3500+tj
Delay sj
EndIf
If zx=4
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=qs(pj)/10*3500+tj
Delay sj
EndIf
Plugin Bkgnd.KeyUp(Hwnd, 32)
Else
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 39)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 37)
Delay 300
//找定点计算角度 角度数jds 角度差jdc
Plugin zb=DBSoft.GetColorXY(hwnd,222,548,343,649,"0000FF","0,0,0",2)
Delay 200
c=clng(zb(0)):d=clng(zb(1))
Plugin jiaodu=DBSoft.Angle3Point(c,d,294,597,c,597,1)
jds=abs(clng(jiaodu))
dim jdcz(4),jdc(4)
jdcz(0)=30-jds:jdcz(1)=50-jds:jdcz(2)=60-jds:jdcz(3)=65-jds:jdcz(4)=70-jds
jdc(0)=abs(30-jds):jdc(1)=abs(50-jds):jdc(2)=abs(60-jds):jdc(3)=abs(65-jds):jdc(4)=abs(70-jds)
//zx为最小下标 zxz为最小角度差数值
Plugin zx=DBSoft.MinNum(jdc,1)
Plugin zxz=DBSoft.MinNum(jdcz,0)
zx=clng(zx):zxz=clng(zxz)
//角度差修正
pj=pj+jdxz*zxz
// MessageBox "角度代号"&zx
If zx=0
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ss(pj)/10*3500+tj
Delay sj
EndIf
If zx=1
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ws(pj)/10*3500+tj
Delay sj
EndIf
If zx=2
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=ls(pj)/10*3500+tj
Delay sj
EndIf
If zx=3
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=lw(pj)/10*3500+tj
Delay sj
EndIf
If zx=4
Plugin Bkgnd.KeyDown(Hwnd, 32)
sj=qs(pj)/10*3500+tj
Delay sj
EndIf
Plugin Bkgnd.KeyUp(Hwnd, 32)
EndIf
EndIf
// MessageBox "时间"&sj
Delay 100
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 100
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 38)
Delay 1600
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 100
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 100
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 100
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 1200
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
Plugin Bkgnd.KeyPress(Hwnd, 40)
Delay 50
//判断游戏是否结束
Plugin jieshu=DBSoft.FindPic(hwnd,946,146,1077,301,"C:\Documents and Settings\nayan\My Documents\ddt\翻牌.bmp",0.8,-2,1)
Delay 300
If jieshu(0)>=0 and jieshu(1)>=0
Goto 翻牌
Else
Delay 7500
Goto 判断开炮
EndIf
Else
Plugin jieshu=DBSoft.FindPic(hwnd,946,146,1077,301,"C:\Documents and Settings\nayan\My Documents\ddt\翻牌.bmp",0.8,-2,1)
Delay 300
If jieshu(0)>=0 and jieshu(1)>=0
Goto 翻牌
Else
Goto 判断开炮
EndIf
EndIf
Rem 自杀
//判断道具并使用
Plugin daoju1 =DBSoft.GetColorXY(hwnd,1179,212,1196,229, "5D6DE4","30,30,30",2)
Plugin daoju2 =DBSoft.GetColorXY(hwnd,1177,267,1204,281, "D29820","30,30,30",2)
dj1=clng(daoju1(0))
dj2=clng(daoju2(0))
If dj1>0 and dj2>0
//使用道具1 2
Plugin Bkgnd.KeyPress(Hwnd, 97)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 98)
Delay 200
Else
//使用zxc
Plugin Bkgnd.KeyPress(Hwnd, 90)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 88)
Delay 200
Plugin Bkgnd.KeyPress(Hwnd, 67)
Delay 200
EndIf
Plugin Bkgnd.KeyDown(Hwnd, 32)
Delay 10
Plugin Bkgnd.KeyUp(Hwnd, 32)
Plugin jieshu=DBSoft.FindPic(hwnd,946,146,1077,301,"C:\Documents and Settings\nayan\My Documents\ddt\翻牌.bmp",0.8,-2,1)
Delay 300
If jieshu(0)>=0 and jieshu(1)>=0
Goto 翻牌
Else
Goto 判断开炮
EndIf
Rem 翻牌
Plugin Bkgnd.LeftClick(Hwnd, 1000, 270)
Delay 150
Plugin Bkgnd.LeftClick(Hwnd, 890,270)
Delay 300
Rem 收取
Plugin shouqu=DBSoft.FindPic(hwnd,621,108,708,154,"C:\Documents and Settings\nayan\My Documents\ddt\背包.bmp",0.8,-2,1)
If shouqu(0)>=0 and shouqu(1)>=0
Delay 300
Plugin Bkgnd.LeftClick(Hwnd, 654, 331)
Delay 500
Plugin Bkgnd.LeftClick(Hwnd, 907, 579)
Delay 300
EndIf
Plugin yanzhen=DBSoft.FindPic(hwnd,0,0,997,520,"C:\Documents and Settings\nayan\My Documents\ddt\验证码.bmp",1.0,-2,1)
If yanzhen(0)>=0 and yanzhen(1)>=0
Plugin DBSoft.PlayMedia("C:\Documents and Settings\nayan\My Documents\ddt\yanzhen.wav",5)
EndIf
Plugin dianjuan=DBSoft.FindPic(hwnd,712,602,827,655,"C:\Documents and Settings\nayan\My Documents\ddt\点卷.bmp",1.0,-2,1)
If dianjuan(0)>=0 and dianjuan(1)>=0
Goto 开始
Else
Delay 300
Goto 收取
EndIf