本帖最後由 gg2255 於 2010-7-4 20:37 編輯
#[HOTKEY]ALT+A
# 在此定義全局變量
/*
// 遊戲模式 800×600分辨率
F9 打開自定義欄 F10 擺攤
自定義欄中
F8 停戰書 F1操帆 F3警戒 F2和F4可以放料理。
在學者面前啟動腳本。有同名的圖,要把它放到收藏裡面。先擺攤一個高價道具,不要擺圖。
繞港好像不能跨海域。。。。有好的解決辦法的告訴我一聲。目前只能近港
在學者面前啟動腳本。
*/
dim pi,dis
dim angle1,angle2
dim CurrentX,CurrentY
dim destX,destY
dim AnglePe,AngleObj,dAngle
dim RouteX,RouteY,RouteXLen,RouteYLen,RouteXLenB,RouteYLenB,RouteXB,RouteYB
dim hpmin
dim hp●嚴禁張貼廣告●
dim hpmax
dim width
dim height
dim x_0
dim y_0
dim book,windowsid,ProcessID,shipside,matuoname
dim mapname,windows,tubaname
dim yanshi,csrd,zhidingID,HPmaxid,HPid
Dim CustomKey,SailKey,WatchKey,yuyongkey
dim nextxy
function main
# 在此添加由嚮導創建或錄製的代碼
SetInputMode(0)
pi=4*Atn(1)
wait(500)
GetActiveWindowSize(width, height)
GetActiveWindowXY(x_0,y_0)
if width<>800 or height<>600 then
Print("本腳本要運行在800*600窗口模式,請確認。")
exit script
end if
mapname =GetConfigString("圖的名稱")
tubaname =GetConfigString("大號的名字")
matuoname =GetConfigString("碼頭名字")
Acityname =GetConfigString("主城市名稱")
Bcityname =GetConfigString("副城市名稱")
CustomKey =GetConfigString("自定義鍵")
SailKey =GetConfigString("操帆鍵")
WatchKey =GetConfigString("警戒鍵")
yuyongkey =GetConfigString("運用鍵")
Price =GetConfigString("擺攤價格")
shipside =GetConfigNumber("碼頭")
book =GetConfigNumber("學科")
scriptmode =GetConfigNumber("腳本模式")
hpmin =GetConfigNumber("最低行動力")
windows =GetConfigNumber("小號個數")+1
yanshi =GetConfigNumber("額外延時")
zhidingID=&H00AFA1B8
HPid =&H00AF8500
HPmaxid =HPid+4
Tnum =2
csrd =0
//保存路點。城市的起點以 書庫 門口開始,出海的起點以主城市為起點。
nextxy=0
Read()
if csrd=1 then
WriteTextToFile("坐標X.txt",CurrentX & chr(13) & chr(10), true)
WriteTextToFile("坐標Y.txt",CurrentY & chr(13) & chr(10), true)
exit script
end if
if PrintSeaArea("書庫") then
door=1
else
door=0
end if
#下面的代碼是查找所有航海遊戲的窗口ID,並存入數組 arrid 中。
windowsID=Array(windows)
ProcessID=Array(windows)
k=1
for i=1 to windows
FindWindow("大航海時代 Online", ID)
windowsID=ID
ProcessID=ActiveProcess()
do
if i=windows then
EXIT DO
end if
KeyDown("ALT")
for t=1 to k
KeyPress("TAB")
next
KeyUp("ALT")
Wait(100)
FindWindow("大航海時代 Online", ID)
k=k+1
loop until Comparison(ID)=0
next
ActiveWindow(windowsID[1])
ResetActiveApp(ProcessID[1])
#查窗口ID結束,切換到大號。
while true
Wait(500)
KeyPress("HOME")
zhaonpc("學者",0)
busy()
it=0
while it<2
do
userMouseLeftClick(647,358,0)
userMouseLeftClick(204+book*56,210,1)
it=chat()
loop while it=0
if it=1 then
#讀到圖,擺攤。
KeyPress("F10")
busy()
do
wait(500)
loop until CheckColor(x_0+396, y_0+96, Color(255, 255, 255), 20)
MouseLeftClick(x_0+400,y_0+370,1000)
if Findmap(mapname)=1 then
MouseLeftClick(400)
Wait(300)
MouseLeftClick(x_0+512,y_0+179)
Wait(300)
for i=1 to len(Price)
KeyPress(mid(Price,i,1),200)
next
MouseLeftClick(x_0+465,y_0+393)
Wait(300)
MouseLeftClick(x_0+490,y_0+407)
busy()
Trumpet(Tnum)
zhaonpc("學者",0)
else
Print("沒找到圖。")
end if
end if
wend
if door=1 then
Turn()
zhaonpc("出口",0)
Wait(1500)
KeyPress("RETURN",500)
end if
if scriptmode=1 then
Around(Acityname,Bcityname)
else
Beep(800, 500)
exit script
end if
if door=1 then
zhaonpc("書庫",0)
zhaonpc("學者",0)
Wait(1500)
KeyPress("RETURN",500)
end if
wend
end function
function Around(aname,bname)
autogoto("城市X.txt","城市Y.txt",0,0)
zhaonpc(matuoname,0)
userMouseLeftClick(649,359,0)
Wait(100+yanshi*5)
userMouseLeftClick(649,359,0)
Wait(500)
userMouseLeftClick(640,386,0)
Wait(1000)
busy()
KeyPress("INSERT",400)
autogoto("繞港X.txt","繞港Y.txt",0,1)
zhaonpc(bname,1)
Wait(100+yanshi*5)
userMouseLeftClick(649,359,0)
Wait(500)
userMouseLeftClick(640,386,0)
Wait(1000)
busy()
KeyPress("INSERT",400)
autogoto("繞港X.txt","繞港Y.txt",1,1)
zhaonpc(aname,1)
userMouseLeftClick(606+shipside*40,382,0)
autogoto("城市X.txt","城市Y.txt",1,0)
end function
function Findmap(name)
foundX=0
i=1
j=1
Print(name)
TextToImage(name, "細明體", Color(255, 255, 255), Color(28, 37, 52), 15, false, 0, mapimg)
while foundX=0
MouseMove(x_0+416-i*56,y_0+396-j*56)
Wait(100)
if FindImageEx(mapimg, color(30, 30, 30), x_0+416-i*56, y_0+436-j*56, x_0+586-i*56, y_0+456-j*56, true, foundX, foundY) then
Findmap=1
end if
i=i+1
if i>5 then
i=1
j=j+1
end if
if j>5 then
foundX=1
Findmap=0
end if
wend
end function
function Trumpet(num)
i=0
k=0
while k=0
ActiveWindow(windowsID[num+i])
ResetActiveApp(ProcessID[num+i])
Wait(300)
GetActiveWindowXY(x,y)
zhaonpc(tubaname,0)
MouseLeftClick(x+647,y+358)
busy()
MouseMove(x+150,y+175)
Wait(200)
MouseLeftClick(x+150,y+175)
Wait(200)
if CheckColor(x+597, y+256, Color(255, 128, 128), 20) then
i=i+1
else
k=1
end if
wend
Wait(200)
MouseLeftClick(x+596,y+405)
busy()
Tnum=num+i
ActiveWindow(windowsID[1])
ResetActiveApp(ProcessID[1])
end function
function userMouseLeftClick(x,y,mode)
#模式mode 1為點交易品類,要先移鼠標過去;0為普通類直接點擊。
if mode=1 then
MouseMove(x_0+x,y_0+y)
Wait(200)
MouseLeftClick(x_0+x,y_0+y)
end if
MouseLeftClick(x_0+x,y_0+y)
busy()
end function
function chat
ReadMemory(&H00AFB06C,2,addr)
ReadMemory(addr+8,2,addr)
ReadMemory(addr+4,2,LogOffset)
ReadMemory(addr+&Hc,2,WordsNum)
gamelog=GetLog(LogOffset,WordsNum)
if InStr(gamelog,"腦子很疲倦了")>0 then
chat=2
// Print("腦子累了")
elseif InStr(gamelog,mapname)>0 then
chat=1
// Print("讀到圖了")
else
chat=0
// Print("沒相關信息")
end if
Wait(100)
end function
function GetLog(offset,num)
ReadMemory(&H00AFB1A4,2,base)
addr=base+offset*2
ReadMemory(addr,5,num*2,str)
GetLog=UnicodeToGB(str)
end function
function autogoto(Xtxtfile,Ytxtfile,modet,modeh)
# modet為0時,正走,為1時,從文件尾向頭走
# modeh為0時,城市裡陸地走,為1時,航海 2為房間 3為內陸
RouteXLen = ReadLinesFromFile(Xtxtfile, RouteX)
RouteYLen = ReadLinesFromFile(Ytxtfile, RouteY)
strlan=Len(Xtxtfile)
if modet=0 then
for i=2 to RouteXLen
destX=CNum(RouteX)
destY=CNum(RouteY)
Print("向路點文件 "&Mid(Xtxtfile,1,strlan-5)&" 的第 "&i&" 個目標前進。")
GotoXY(destX,destY,modeh)
KeyPress("HOME")
// wait(100)
next
elseif modet=1 then
for i=RouteXLen-1 to 1 step -1
destX=CNum(RouteX)
destY=CNum(RouteY)
Print("向路點文件 "&Mid(Xtxtfile,1,strlan-5)&" 的第 "&i&" 個目標前進。")
GotoXY(destX,destY,modeh)
KeyPress("HOME")
// wait(100)
next
end if
KeyUp("UP")
end function
function Read
//人物坐標、角度內存地址。
ReadMemory(&H00AF8548,3,CurrentX)
ReadMemory(&H00AF8550,3,CurrentY)
ReadMemory(&H00AF8558,3,angle1)
ReadMemory(&H00AF8560,3,angle2)
wait(10)
end function
# 判斷是否程序忙子函數
function busy
Wait(200)
mousebusy=Color(164,186,227)
GetMousePixel(8, 10, mousepixel)
while mousebusy=mousepixel
Wait(100)
GetMousePixel(8, 10, mousepixel)
wend
Wait(200)
end function
function eat
# 吃料理
// print("開始吃料理")
ics=0
i=1
Wait(1000)
ReadMemoryEx(zhidingID, 2, zhiding,1)
if zhiding=8 then
KeyPress("F9")
Wait(500)
end if
ReadMemoryEx(HPmaxid, 2, hpmax,1)
ReadMemoryEx(HPid,2,hp●嚴禁張貼廣告●,1)
while hp●嚴禁張貼廣告●<hpmax-80
Wait(500)
PressCustomKey(CustomKey)
KeyPress(111+i)
ReadMemoryEx(zhidingID, 2, zhiding,1)
while zhiding=8
Wait(300)
if zhiding=8 then
i=i+1
KeyPress(111+i)
else
j=1
end if
Wait(300)
ReadMemoryEx(zhidingID, 2, zhiding,1)
if i>4 then
#沒有料理,強行關機。
Print("沒有料理了。")
end if
wend
ReadMemoryEx(HPid,2,hp●嚴禁張貼廣告●,1)
wend
//print("完成吃料理")
end function
# 吃料理函數結束
function zhaonpc(npcname,matuo)
#找NPC 0為城市裡人物和場景,1為在海上找城市
Wait(100)
xmouse=10
while GetObjName()<>npcname
KeyPress("TAB")
Wait(300)
if matuo=1 then
MouseMove(x_0+xmouse,y_0+300)
MouseRightDown()
xmouse=xmouse+40
end if
if xmouse>1200 then
xmouse=0
KeyPress("INSERT",400)
MouseRightUp()
end if
wend
if matuo=1 then
while GetObjName()=npcname
KeyPress("RETURN",500)
Wait(4000)
wend
end if
MouseRightUp()
KeyPress("RETURN",500)
KeyPress("RETURN",500)
busy()
end function
// 獲取人物面向角度
function GetPersonAngle
Read()
angle=ACos(angle1)
if angle2>0 then
angle=2*pi-angle
end if
AnglePe=angle
end function
// 獲取當前坐標和目的坐標間夾角
function GetObjAngle(toX, toY)
Read()
dX=toX-CurrentX
dY=toY-CurrentY
if dX=0 then
angle=pi/2
else
angle=Atn(Abs(dY)/Abs(dX))
end if
if dX <0 and dY<=0 then
angle=pi-angle
end if
if dX<0 and dY>0 then
angle=pi+angle
end if
if dX>0 and dY<=0 then
angle=angle
end if
if dX>0 and dY>0 then
angle=2*pi-angle
end if
AngleObj=angle
end function
function GotoXY(x,y,mode)
# mode 0 為城市內部,1為海上 2為房間 3為內陸
dis=(CurrentX-x)^2+ (CurrentY-y)^2
if mode=0 or mode=3 then
dismode=32000
elseif mode=1 then
dismode=7500000000
elseif mode=2 then
dismode=5500
end if
kdis=0
while dis >dismode
GetDAngle(destX,destY,mode)
dis=(CurrentX-x)^2+ (CurrentY-y)^2
if mode=0 or mode=2 or mode=3 then
#為0,陸地模式
KeyDown("UP")
KeyUp("LEFT")
KeyUp("RIGHT")
if Abs(dAngle)>5 and Abs(dAngle)<30 then
if dAngle<0 then
KeyPress("LEFT",80)
else
KeyPress("RIGHT",80)
end if
end if
if Abs(dAngle)>355 then
if dAngle<0 then
KeyPress("RIGHT",80)
else
KeyPress("LEFT",80)
end if
end if
if mode=3 then
Read()
dis2=(CurrentX-x)^2+ (CurrentY-y)^2
if dis2=dis then
kdis=kdis+1
end if
if kdis>10 then
kdis=0
dis=10
Print("卡住了。")
end if
end if
elseif mode=1 then
autohh()
if nextxy=1 then
if dis<7600000000 then
dis=4000000000
nextxy=0
else
KeyPress("RIGHT",800)
end if
end if
#為1,海上模式
if Abs(dAngle)>5 and Abs(dAngle)<30 then
if dAngle<0 then
KeyPress("LEFT",50)
Wait(1500)
waitangle()
KeyPress("HOME")
else
KeyPress("RIGHT",50)
Wait(1500)
waitangle()
KeyPress("HOME")
end if
end if
if Abs(dAngle)>355 then
if dAngle<0 then
KeyPress("RIGHT",50)
Wait(1500)
waitangle()
KeyPress("HOME")
else
KeyPress("LEFT",50)
Wait(1500)
waitangle()
KeyPress("HOME")
end if
end if
end if
wend
KeyUp("UP")
KeyUp("DOWN")
KeyUp("LEFT")
KeyUp("RIGHT")
end function
function waitangle
# 看船是不是正在轉向。]
Wait(500)
do
ReadMemory(&H00AF8558,3,temp1)
autohh()
ReadMemory(&H00AF8558,3,temp2)
loop until Abs(Abs(temp1)-Abs(temp2))<0.043
Wait(500)
end function
// 計算所需轉角度
function GetDAngle(x,y,mode)
//轉彎再計算轉角 mode 0 為城市內,1為海上 2房間 3為內陸
GetPersonAngle()
GetObjAngle(destX,destY)
angle=AnglePe - AngleObj
angle=180*angle/pi
dis=(CurrentX-x)^2+ (CurrentY-y)^2
if mode=0 or mode=3 then
dismode=28000
elseif mode=1 then
dismode=7600000000
elseif mode=2 then
dismode=6000
end if
if dis<dismode then
angle=15
end if
if Abs(angle)>20 then
if mode=0 or mode=2 or mode=3 then
# 陸地模式
if Abs(Abs(angle)-180)<10 then
Turn()
GetDAngle(destX,destY,mode)
elseif angle>0 and angle<180 then
KeyPress("HOME")
Wait(500)
KeyPress("RIGHT",abs(angle)*17)
KeyPress("UP",500)
Wait(500)
GetDAngle(destX,destY,mode)
elseif angle<0 and angle>-180 then
KeyPress("HOME")
Wait(500)
KeyPress("LEFT",abs(angle)*17)
KeyPress("UP",500)
Wait(500)
GetDAngle(destX,destY,mode)
elseif angle>180 and angle<355 then
angle=360-angle
KeyPress("HOME")
Wait(500)
KeyPress("LEFT",abs(angle)*14)
KeyPress("UP",500)
Wait(500)
GetDAngle(destX,destY,mode)
elseif angle<-180 and angle>-355 then
angle=360+angle
KeyPress("HOME")
Wait(500)
KeyPress("RIGHT",abs(angle)*14)
KeyPress("UP",500)
Wait(500)
GetDAngle(destX,destY,mode)
end if
elseif mode=1 then
# 航海模式
if Abs(Abs(angle)-180)<10 then
Print("走過頭了。")
nextxy=1
elseif angle>0 and angle<180 then
Wait(500)
KeyPress("RIGHT",abs(angle)*7)
Wait(1500)
waitangle()
KeyPress("HOME")
GetDAngle(destX,destY,mode)
elseif angle<0 and angle>-180 then
Wait(500)
KeyPress("LEFT",abs(angle)*7)
Wait(1500)
waitangle()
KeyPress("HOME")
GetDAngle(destX,destY,mode)
elseif angle>180 and angle<355 then
angle=360-angle
Wait(500)
KeyPress("LEFT",abs(angle)*4)
Wait(1500)
waitangle()
KeyPress("HOME")
GetDAngle(destX,destY,mode)
elseif angle<-180 and angle>-355 then
angle=360+angle
Wait(500)
KeyPress("RIGHT",abs(angle)*4)
Wait(1500)
waitangle()
KeyPress("HOME")
GetDAngle(destX,destY,mode)
end if
end if
end if
dAngle=angle
end function
function Turn
//向後180度轉身
KeyUp("UP")
KeyUp("LEFT")
KeyUp("RIGHT")
KeyPress("HOME")
Wait(500)
KeyPress("DOWN",500)
KeyPress("HOME")
Wait(1000)
end function
# 下面是航行相關的函數
function autohh
ReadMemoryEx(&H00AFA3BD,0,tide,0)
if tide > 0 then
FullSail()
CheckSkill()
end if
Wait(500)
end function
function FullSail
ReadMemoryEx(&H00AF88DC,2,Sail,0)
ReadMemoryEx(&H00AF88FC,2,AutoSail,0)
if Sail > 0 and Sail < 5 and AutoSail = 0 then
PressCustomKey(CustomKey)
KeyPress(SailKey)
Wait(1500)
end if
end function
function CheckSkill
Skills = 4
dim Skill[3]
ReadMemoryEx(&H00B7EE8C,2,addr,0)
ReadMemoryEx(addr,2,addr,0)
ReadMemoryEx(addr-&H3C,2,addr,0)
ReadMemoryEx(addr+&H38,2,Skills,0)
ReadMemoryEx(addr+&H0C,2,Skill[1],0)
ReadMemoryEx(addr+&H14,2,Skill[2],0)
ReadMemoryEx(addr+&H1C,2,Skill[3],0)
do WHILE CheckColor(x_0+767, y_0+578, Color(255, 255, 255), 10)
Print("暴風雨來了。")
KeyPress("DELETE",300)
Wait(1000)
if not CheckColor(x_0+767, y_0+578, Color(255, 255, 255), 10) then
KeyPress("INSERT",400)
Print("天氣好了。")
end if
loop
if Skills < 4 then
if Skill[1] <> 75 and Skill[2] <> 75 and Skill[3] <> 75 then
PressCustomKey(CustomKey)
if CheckColor(x_0+746, y_0+219, Color(255, 255, 255), 10) then
KeyPress("F8")
Print("海上被NPC攻擊。")
Wait(1000)
else
KeyPress(WatchKey)
end if
Wait(1000)
end if
if Skill[1] <> 77 and Skill[2] <> 77 and Skill[3] <> 77 then
PressCustomKey(CustomKey)
KeyPress(yuyongkey)
end if
end if
end function
Function PressCustomKey(key)
KeyPress(key)
StartTime = GetTime()
do
Wait(100)
ReadMemoryEx(zhidingID,2,Custom,0)
IF GetTime() > StartTime + 4000 THEN
KeyPress(key)
StartTime = GetTime()
End If
loop until Custom = 8
Wait(100)
End Function
# 得當前所在地點名。
function PrintSeaArea(areaname)
wait(100)
ReadMemoryex(&h00AF89EC, 2, paddr_1,2)
ReadMemoryex(paddr_1, 2, paddr_2,2)
ReadMemoryex(paddr_2, 5,50, psea_area,2)
name=UnicodeToGB(psea_area)
if areaname=name then
PrintSeaArea=true
else
PrintSeaArea=false
end if
end function
//下面是通過內存找NPC
function GetObjAddr(ID,base)
dim A,B,temp,Addr
ReadMemoryEx(base, 2, A, 1)
ReadMemoryEx(base+&H04, 2, B, 1)
B=A+(int(ID/16) mod B) *4
ReadMemoryEx(B, 2, addr, 1)
DO
ReadMemoryEx(addr, 2, temp, 1)
if temp=ID then
exit do
end if
ReadMemoryEx(addr+&H08, 2, Addr, 1)
LOOP UNTIL addr=0
ReadMemoryEx(Addr+&H04 , 2, temp, 1)
GetObjAddr=temp
end function
function GetObjName()
dim ObjAddr,base,ID,temp
ReadMemoryEx(&H00AF5694, 2, ObjType, 1)
ReadMemoryEx(&H00AF5698, 2, ID, 1)
if ObjType =0 then
//計算NPC或PC名字
base=&H00AF89AC
ObjAddr= GetObjAddr(ID,base)
ReadMemoryEx(ObjAddr+&H3C, 2, temp, 1)
ReadMemoryEx(temp, 5, 50, temp, 1)
GetObjName = UnicodeToGB(temp)
elseif ObjType=1 then
//求場景名字
base=&H00AF89CC
ObjAddr= GetObjAddr(ID,base)
ReadMemoryEx(ObjAddr+&H0C, 2, ID, 1)
base=&H00AF905C
ObjAddr= GetObjAddr(ID,base)
ReadMemoryEx(ObjAddr+&H08, 2, temp, 1)
ReadMemoryEx(temp, 5, 50, temp, 1)
GetObjName = UnicodeToGB(temp)
end if
end function
function Comparison(ID)
for i=1 to windows
if id=windowsID then
Comparison=1
exit for
else
Comparison=0
end if
next
end function
以下是cfg檔 先貼在筆記本上然後在將筆記本檔名改成.cfg
[NAME]
大號的名字
[DESC]
讀書的大號的名字。這是讓存讀的小號找你的,一定要準確。
[VALUE]
痲痺龍(大號的名字)
[NAME]
小號個數
[DESC]
開了幾個小號就填幾,不包括大號。
[VALUE]
2
[NAME]
圖的名稱
[DESC]
要讀出圖的名字,要準確。
[VALUE]
聖母子與幼兒聖約翰
[NAME]
學科
[DESC]
1地理
2考古
3宗教
4生物
5財寶
6美術
[VALUE]
4
[NAME]
擺攤價格
[DESC]
圖的擺攤,低級的圖就1吧,省得傳錢給小號,
高級的圖怕別人偷,就要設高點。
[VALUE]
10
[NAME]
碼頭
[DESC]
碼頭進城市,有不同的地點,如碼頭,廣場,商業區,商務會館。
從左到右,1、2、3、4,任選一個,要跟據你的城市路點來設,
選個離書庫進的。
[VALUE]
2
[NAME]
主城市名稱
[DESC]
讀書的城市
[VALUE]
塞維利亞
[NAME]
副城市名稱
[DESC]
繞港的城市。
[VALUE]
休達
[NAME]
碼頭名字
[DESC]
有些是叫碼頭官員的,在這裡改下。
[VALUE]
碼頭導航員
[NAME]
腳本模式
[DESC]
1自動,0半自動
半自動就是不繞港。腦子累了就發聲報警,手動繞港。
[VALUE]
1
[NAME]
最低行動力
[DESC]
行動力少於此數值時,開始吃料理。
[VALUE]
150
[NAME]
額外延時
[DESC]
為網絡狀態不好時,添加的額外的等待時間,單位為 毫秒。
[VALUE]
200
[NAME]
操帆鍵
[DESC]
[VALUE]
F1
[NAME]
運用鍵
[DESC]
[VALUE]
F3
[NAME]
警戒鍵
[DESC]
[VALUE]
F4
[NAME]
自定義鍵
[DESC]
[VALUE]
F9
[EOF]
此版本使用內存方式_內存因改版已經變更_使用ce查詢內存將他修改後就能正常使用
還需要在4個.txt檔_檔名取繞港x.txt_繞港Y.txt裡面放出海的座標如
第一個
2864000
3163279.25
3584132
3551680.25
第2個
4550675
4915369
5163324.5
5427819.5
第3個
35090
35559.375
35039.8046875
30673.80859375
30552.005859375
32309.6953125
第4個
46980
46880.03125
43424.4375
42809.0859375
37662.0625
37760.17578125
|