按键精灵中如何解决大唐无双的世界地图坐标查找问题

标签:
漠北坐标大唐无双大地图世界地图按键精灵编程解决办法杂谈 |
http://bbs.anjian.com/forum.php?mod=attachment&aid=NTM5NDV8ZDU1NDFjNWJ8MTM0MjY4MTYwNXw2MjYyNDV8MjE0MjA5&noupdate=yes
具体的请看简图,红色部分是屏幕的坐标系,浅色部分是大唐的坐标系。
经过大量的数据采集 ,进行平均和归化计算,基本可以肯定,两轴间的夹角如
图所示。在此基础上,得出如下的计算公式。(解决问题为,已知大地图某点坐标和该点的实际坐
标,求出欲达到大地图的坐标的实际坐标。)
定义如下变量:
-
目标_地图,坐标_地图,坐标_实际,目标_实际
坐标型;
- 实际距离x,图上距离x,实际距离y,图上距离y,中转坐标x,中转坐标y,Y差,X差 数值型
-
比例尺=0.315
(实验得出在0.3~0.35,不过没有试过不同分辨率的缩放比例是否相同,有意者可以自行实验得出数据)
- 图上距离y = 目标_地图.y - 坐标_地图.y
- 实际距离x = 图上距离x ÷ 比例尺
- Y差 = 实际距离x ÷ 2
- X差 = 实际距离x × 求平方根 (3) ÷ 2
- 中转坐标x = 坐标_实际.x + X差
- 中转坐标y = 坐标_实际.y + Y差(注意这个)
- 实际距离y = 图上距离y ÷ 比例尺
- Y差 = 实际距离y ÷ 2
- X差 = 实际距离y × 求平方根 (3) ÷ 2
- 目标_实际.x = 中转坐标x + X差
- 目标_实际.y = 中转坐标y - Y差(如果把坐标摆正,发现两个的Y是相反的,所以这个要“-Y”不是在计算x偏移的“+Y”)
经过上述计算,得出的 目标_实际 就是地图上目标点的实际屏幕坐标。有这个公式,游戏地图基本上是任我行了,
如果考虑得到的实际距离超出地图边界的问题 ,还可以依据这个实现智能移动大地图,以达到去往地图上任意点的
功能。那么诸如采集之类的脚本就可以不局限于地图的一角,或者固定几点,实际上我自己正是这样做的,我只需
要给出资源点的坐标,人物就能自己去坐标进行采集工作。
以上是按键小小生的方法。
我自己的方法不多做解释,直接上代码,看不懂的不要骚扰本人,简单解释下,用了大漠插件写的,另外有点乱,还没来得及精简代码,交期紧张,先这样凑和着用吧。
Dim x1,y1,x2,y2
//PutAttachment "d:\sx","*.*"
set ws=createobject("Wscript.Shell")
ws.run "regsvr32 d:\sx\dm.dll /s"
set ws=nothing
Delay 1500
Set dm = CreateObject("dm.dmsoft")
ver = dm.Ver()
If len(ver) = 0 Then
End If
MessageBox "鼠标准备了"
Delay 2000
hwnd = dm.GetMousePointWindow()
//MessageBox "现在找父句柄"
//Delay 1000
//hf = dm.getmousepointwindow()
dm_ret = dm.BindWindow(hwnd,"dx2","windows","windows",0)
Delay 1000
dm.SetPath "d:\sx"
dm.SetDict 0, "dtws.txt"
dm.SetDict 1, "song9.txt"
dm.SetDict 2, "songpua13.txt"
dm.SetDict 3, "spuaul13.txt"
dm.SetDict 4, "dm_soft.txt"
//Call lib.xyb.gc()
Call main()
dm_ret = dm.UnBindwindow()
Sub main()
x1=446:y1=400
Call coordinate()
x1=501:y1=418
Call coordinate()
x1=510:y1=362
Call coordinate()
x1=454:y1=318
Call coordinate()
x1=506:y1=241
Call coordinate()
x1=454:y1=202
Call coordinate()
x1=425:y1=100
Call coordinate()
x1=415:y1=69
Call coordinate()
x1=319:y1=90
Call coordinate()
x1=312:y1=203
Call coordinate()
x1=301:y1=244
Call coordinate()
End Sub
Sub activeit()'打开地图激活鼠标
Rem openworldmap
dm_ret = dm.Findstr(0, 0, 2000, 2000, "世界地图", "f7d9a6-000000", 1.0,
x, y)
If x > 0 Then
Else
dm.keypress 77
Delay 200
Goto openworldmap
End If
Delay 50
nowps = dm.ocr(xp1, yp1, xp2, yp2, "ffffff-000000", 1.0)
Rem confirmstate
Delay 50
dm.mover 10, 10
Delay 100
nowps2 = dm.ocr(xp1, yp1, xp2, yp2, "ffffff-000000", 1.0)
Delay 50
If nowps2 = nowps Then
End If
End Sub
Sub coordinate()
Dim Myarray
Rem againboy
dm.usedict 0
Rem openworldmap
dm_ret = dm.Findstr(0, 0, 2000, 2000, "世界地图", "f7d9a6-000000", 1.0,
x, y)
If x > 0 Then
Else
dm.keypress 77
Delay 200
Goto openworldmap
End If
abc = 50
kax = 0.866*3 : kbx = 0.866*3 : kay=0.5*3 : kby=-0.5*3
Delay abc
nowps = dm.ocr(xp1, yp1, xp2, yp2, "ffffff-000000", 1.0)
Rem confirmstate
Delay 50
dm.mover 10, 10
Delay 100
nowps2 = dm.ocr(xp1, yp1, xp2, yp2, "ffffff-000000", 1.0)
Delay 50
If nowps2 = nowps Then
End If
For 10000
Delay abc
nowps = dm.ocr(xp1, yp1, xp2, yp2, "ffffff-000000", 1.0)
Myarray = Split(nowps, ",")
x0 = CInt(myarray(0)) : y0 = CInt(myarray(1))
//If abs(x0 - x1)<2 and abs(y0 -
y1)<2 Then
If x0=x1 and y0=y1 then
Exit For
Else
If abs(x0 - x1) > 4 and abs(y0-y1)>4
Then
Else
If abs(x0 - x1) > 4 Then
//If abs(x0 - x1)<2 Then
If x0=x1 then
If y0 < y1 Then
End If
Else
If x0 < x1 Then
End If
End If
End If
End If
End If
End If
Next
dm.rightclick
Delay 1000
dm.keypress 77
Delay 500
Call position()
If x2 = x1 and y2 = y1 Then
End If
End Sub
Sub position()
Dim myarray
dm.usedict 0
Rem startboy
newps = dm.ocr(888, 118, 973, 151, "dad487-000000", 1.0)
myarray = split(newps, ",")
x2 = CInt(myarray(0)) : y2 = CInt(myarray(1))
Delay 500
If x2 = x1 and y2 = y1 Then
End If
End Sub