Помоги Ветеранр !!
Posted: 2005-01-26 08:23:07
У меня вродебы нормальный скрипт но он не работает снова и снова вот он нарубил 1к скока указано и вырубаеться а как зделать так чтобы он повторялся и повторялся! ВОТ скрипт
##################################################################################################
var FileName=("c:\trees.dat") ## - Путь к файлу в котором будут хранится координаты деревьев.
###
var LogsQty=1000 ## - Количество логов, добыв которое надо слаживать в дид.
###################################################################################################
#################
### Включалка ###
#################
sub Start()
If UO.GetGlobal('Lumberjackingcheck')=='on' Then
UO.SetGlobal('Lumberjackingcheck','off')
UO.exec('exec Terminate')
Else
UO.exec('exec Lumberjacking')
UO.SetGlobal('Lumberjackingcheck','on')
EndIf
end sub
###########
### Код ###
###########
Sub Lumberjacking()
Var i=0, f
Var flag=0, treeCount=0
Dim TreeX[5000], TreeY[5000], TreeT[5000]
Dim TreeTile[29]
########################
### Графика деревьев ###
########################
TreeTile[0]=3277
TreeTile[1]=3280
TreeTile[2]=3283
TreeTile[3]=3286
TreeTile[4]=3289
TreeTile[5]=3291
TreeTile[6]=3294
TreeTile[7]=3296
TreeTile[8]=3299
TreeTile[9]=3302
TreeTile[10]=3393
TreeTile[11]=3394
TreeTile[12]=3395
TreeTile[13]=3396
TreeTile[14]=3415
TreeTile[15]=3416
TreeTile[16]=3417
TreeTile[17]=3418
TreeTile[18]=3419
TreeTile[19]=3438
TreeTile[20]=3439
TreeTile[21]=3440
TreeTile[22]=3441
TreeTile[23]=3442
TreeTile[24]=3460
TreeTile[25]=3461
TreeTile[26]=3462
TreeTile[27]=3290
TreeTile[28]=3288
UO.Exec("useobject backpack")
UO.FilterSpeech('on')
UO.FilterSpeech('add', 'Where do you want to use the pickaxe?')
UO.Print("!!!SELECT YOU AXE!!!")
UO.Exec('addobject Axe')
While UO.Targeting()
Wait(100)
Wend
Wait(2000)
UO.Print("!!!SELECT YOU JAIL DEED!!!")
UO.Exec('addobject Deed')
While UO.Targeting()
Wait(100)
Wend
Wait(2000)
#####################################
### Загружаем координаты из файла ###
#####################################
f = file(FileName)
f.open()
treeCount = safe call f.ReadNumber()
For i = 1 TO treeCount
TreeT[i] = safe call f.ReadNumber()
TreeX[i] = safe call f.ReadNumber()
TreeY[i] = safe call f.ReadNumber()
Next
f.close()
UO.Print("Open File "+FileName)
Wait(2000)
UO.Print("Trees in you file ["+str(treeCount)+"]")
Wait(2000)
######################################
### Ходим по собранным координатам ###
######################################
While 1==1 and NOT UO.Dead()
If treeCount > 0 Then
For i = 1 TO treeCount
if UO.Count('0x1BDD') >= LogsQty then
ToDeed()
end if
UO.Print("Go to Tree ["+str(i)+"] : x="+str(TreeX[i])+" y="+str(TreeY[i]))
flag = GotoXY(TreeX[i],TreeY[i])
If flag==1 Then
GetTree(str(TreeT[i]),str(TreeX[i]),str(TreeY[i]),str(UO.GetZ()))
EndIf
Next
EndIf
Wend
End sub
##################
### Рубим логи ###
##################
Sub GetTree(Type,X,Y,Z)
Var i
UO.Print("RUBIM...")
For i = 0 TO 15
Wait(200)
If UO.Waiting() Then
UO.CancelTarget()
EndIf
UO.DeleteJournal()
UO.WaitTargetTile(Type,X,Y,Z)
UO.UseObject('Axe')
If WaitForChange()==1 Then
return 1
EndIf
Next
return 0
End sub
##################################
### Складываем логи в жэил дид ###
##################################
Sub ToDeed()
var n
UO.WaittargetObject('Deed')
UO.UseType('0x1BDD')
Wait(5000)
UO.Click('Deed')
wait(5000)
n=Mid(UO.GetName('Deed'),20,4)
If VAL(n) <= 100 Then
UO.Print("I am FREE!!!")
UO.Exec('exec Start')
Else
UO.Print("NOT Good! ["+n+"] logs")
EndIf
End sub
######################
### Выход из замка ###
######################
Sub Go()
GotoXY2(352,835,0)
wait(8000)
if uo.getgraphic("0x40000666")=='0x067D' then
uo.usefromground('0x067D')
endif
wait(1000)
GotoXY2(337,835,0)
wait(1000)
GotoXY2(338,793,0)
wait(1000)
GotoXY2(328,793,0)
wait(5000)
if uo.getgraphic("0x40001C32")=='0x067D' then
uo.usefromground('0x067D')
endif
wait(1000)
GotoXY2(313,793,0)
wait(5000)
if uo.getgraphic("0x40001763")=='0x0675' then
uo.usefromground('0x0675')
endif
wait(1000)
GotoXY2(313,784,0)
wait(5000)
if uo.getgraphic("0x40007B5C")=='0x0677' then
uo.usefromground('0x0677')
endif
wait(1000)
GotoXY2(313,762,0)
wait(1000)
GotoXY2(298,762,0)
wait(1000)
GotoXY2(299,763,0)
wait(5000)
if uo.getgraphic("0x40000D0F")=='0x0675' then
uo.usefromground('0x0675')
endif
wait(1000)
GotoXY2(299,776,0)
wait(1000)
GotoXY2(291,768,0)
wait(1000)
GotoXY2(291,764,0)
wait(1000)
GotoXY2(296,764,0)
wait(1000)
GotoXY2(286,771,0)
wait(1000)
GotoXY2(286,782,0)
wait(1000)
GotoXY2(291,782,0)
wait(1000)
GotoXY2(300,762,0)
wait(5000)
if uo.getgraphic("0x400C09D8")=='0x067F' then
uo.usefromground('0x067F')
endif
wait(1000)
GotoXY2(309,762,0)
wait(1000)
GotoXY(300,793,0)
end sub
##################################
### Проверки на рубку, таргеты ###
##################################
Sub WaitForChange()
Var Text1 = "You hack at the tree for a while, but fail to produce any useable wood."
Var Text2 = "There are no logs here to chop."
Var Text3 = "You can't reach this."
Var Text4 = "That is too far away."
Var Text5 = "You can't do much in your current state."
Var mess
For Var i = 0 to 200
mess = UO.Journal(0)
If UO.Journal(0)==Text2 or UO.Journal(0)==Text3 or UO.Journal(0)==Text4 Then
return 1
EndIf
If UO.Journal(0)==Text1 Then
return 0
EndIf
If mess[0]=='Y' and mess[1]=='o' and mess[2]=='u' and mess[4]=='p' and mess[5]=='u' and mess[6]=='t' Then
return 0
EndIf
Wait(50)
Next
return 0
End sub
#########################
### Движок ходьбы (1) ###
#########################
Sub GotoXY(x,y)
var myX,myY,lastX=0,lastY=0,i,halt=0,z,r=0
for i=1 to 60
myX=uo.getX();
myY=uo.getY();
if LastX==myX and LastY==myY then
halt=halt+1
else
halt=0
end if
if halt>=10 then
if uo.GetDir()==1 then
for z=0 to 8
uo.Press(40)
next
end if
if uo.GetDir()==3 then
for z=0 to 8
uo.Press(37)
next
end if
if uo.GetDir()==5 then
for z=0 to 8
uo.Press(38)
next
end if
if uo.GetDir()==7 then
for z=0 to 8
uo.Press(39)
next
end if
halt=15
end if
if Numb(x-myX)<=1 and Numb(y-myY)<=2 then
return 1
end if
if x<=myX then
if y<=myY then
for z=0 to 3
uo.Press(38)
next
else
for z=0 to 3
uo.Press(37)
next
end if
else
if y<=myY then
for z=0 to 3
uo.Press(39)
next
else
for z=0 to 3
uo.Press(40)
next
end if
end if
lastX=myX
lastY=myY
wait(200)
next
return 0
end sub
Sub Numb(num)
if num>=0 then
return num
else
return num*(-1)
end if
end sub
#########################
### Движок ходьбы (2) ###
#########################
Sub GotoXY2(x,y,prec)
var ld=0, ldc=0, dx
var dy, mx, my, ox, oy, mk, k
var T=1000 ; Время задержки между нажатиями клавиш
#uo.print(">")
#uo.track("1",str(x),str(y))
start:
mx=UO.GetX()
my=UO.GetY()
dx=mx-x
if dx<0 then
dx=0-dx
endif
dy=my-y
if dy<0 then
dy=0-dy
endif
if dy>dx then
dx=dy
end if
if dx<=prec then
return 1
end if
if not ldc then
#uo.print(STR(dx))
end if
if dx<3 then
mk=70
else
mk=15
end if
ox=mx
oy=my
for k=1 to mk
mx=UO.GetX()
my=UO.GetY()
if mx<>ox or my<>oy then
goto sdidapl
end if
wait(10)
next
sdidapl:
mx=UO.GetX()
my=UO.GetY()
dx=mx-x
if dx<0 then
dx=0-dx
endif
dy=my-y
if dy<0 then
dy=0-dy
endif
if dy>dx then
dx=dy
end if
if dx<=prec then
return 1
end if
if ld==dx then
ldc=ldc+1
if ldc>100 then
uo.print("Can not reach location!")
return
end if
else
ld=dx
end if
if mx==x then
if my==y then
return
endif
if my>y then
#UO.Print("UR")
UO.Press(33)
Wait(T)
goto start
endif
#UO.Print("DL")
UO.Press(35)
Wait(T)
goto start
end if
if mx<x then
if my>y then
#UO.Print("R")
UO.Press(39)
Wait(T)
goto start
endif
if my==y then
#UO.Print("DR")
UO.Press(34)
Wait(T)
goto start
endif
#UO.Print("D")
UO.Press(40)
Wait(T)
goto start
end if
if my<y then
#UO.Print("L")
UO.Press(37)
Wait(T)
goto start
endif
if my==y then
#UO.Print("LU")
UO.Press(36)
Wait(T)
goto start
endif
#UO.Print("U")
UO.Press(38)
Wait(T)
goto start
end sub
#############################
### Выключаем все скрипты ###
#############################
Sub Terminate()
UO.Print("Lumberjacking script: Off!")
UO.DeleteJournal()
UO.Exec('terminate all')
Wait(100)
UO.Exec('terminate all')
Wait(100)
UO.Exec('terminate all')
Wait(100)
##################################################################################################
var FileName=("c:\trees.dat") ## - Путь к файлу в котором будут хранится координаты деревьев.
###
var LogsQty=1000 ## - Количество логов, добыв которое надо слаживать в дид.
###################################################################################################
#################
### Включалка ###
#################
sub Start()
If UO.GetGlobal('Lumberjackingcheck')=='on' Then
UO.SetGlobal('Lumberjackingcheck','off')
UO.exec('exec Terminate')
Else
UO.exec('exec Lumberjacking')
UO.SetGlobal('Lumberjackingcheck','on')
EndIf
end sub
###########
### Код ###
###########
Sub Lumberjacking()
Var i=0, f
Var flag=0, treeCount=0
Dim TreeX[5000], TreeY[5000], TreeT[5000]
Dim TreeTile[29]
########################
### Графика деревьев ###
########################
TreeTile[0]=3277
TreeTile[1]=3280
TreeTile[2]=3283
TreeTile[3]=3286
TreeTile[4]=3289
TreeTile[5]=3291
TreeTile[6]=3294
TreeTile[7]=3296
TreeTile[8]=3299
TreeTile[9]=3302
TreeTile[10]=3393
TreeTile[11]=3394
TreeTile[12]=3395
TreeTile[13]=3396
TreeTile[14]=3415
TreeTile[15]=3416
TreeTile[16]=3417
TreeTile[17]=3418
TreeTile[18]=3419
TreeTile[19]=3438
TreeTile[20]=3439
TreeTile[21]=3440
TreeTile[22]=3441
TreeTile[23]=3442
TreeTile[24]=3460
TreeTile[25]=3461
TreeTile[26]=3462
TreeTile[27]=3290
TreeTile[28]=3288
UO.Exec("useobject backpack")
UO.FilterSpeech('on')
UO.FilterSpeech('add', 'Where do you want to use the pickaxe?')
UO.Print("!!!SELECT YOU AXE!!!")
UO.Exec('addobject Axe')
While UO.Targeting()
Wait(100)
Wend
Wait(2000)
UO.Print("!!!SELECT YOU JAIL DEED!!!")
UO.Exec('addobject Deed')
While UO.Targeting()
Wait(100)
Wend
Wait(2000)
#####################################
### Загружаем координаты из файла ###
#####################################
f = file(FileName)
f.open()
treeCount = safe call f.ReadNumber()
For i = 1 TO treeCount
TreeT[i] = safe call f.ReadNumber()
TreeX[i] = safe call f.ReadNumber()
TreeY[i] = safe call f.ReadNumber()
Next
f.close()
UO.Print("Open File "+FileName)
Wait(2000)
UO.Print("Trees in you file ["+str(treeCount)+"]")
Wait(2000)
######################################
### Ходим по собранным координатам ###
######################################
While 1==1 and NOT UO.Dead()
If treeCount > 0 Then
For i = 1 TO treeCount
if UO.Count('0x1BDD') >= LogsQty then
ToDeed()
end if
UO.Print("Go to Tree ["+str(i)+"] : x="+str(TreeX[i])+" y="+str(TreeY[i]))
flag = GotoXY(TreeX[i],TreeY[i])
If flag==1 Then
GetTree(str(TreeT[i]),str(TreeX[i]),str(TreeY[i]),str(UO.GetZ()))
EndIf
Next
EndIf
Wend
End sub
##################
### Рубим логи ###
##################
Sub GetTree(Type,X,Y,Z)
Var i
UO.Print("RUBIM...")
For i = 0 TO 15
Wait(200)
If UO.Waiting() Then
UO.CancelTarget()
EndIf
UO.DeleteJournal()
UO.WaitTargetTile(Type,X,Y,Z)
UO.UseObject('Axe')
If WaitForChange()==1 Then
return 1
EndIf
Next
return 0
End sub
##################################
### Складываем логи в жэил дид ###
##################################
Sub ToDeed()
var n
UO.WaittargetObject('Deed')
UO.UseType('0x1BDD')
Wait(5000)
UO.Click('Deed')
wait(5000)
n=Mid(UO.GetName('Deed'),20,4)
If VAL(n) <= 100 Then
UO.Print("I am FREE!!!")
UO.Exec('exec Start')
Else
UO.Print("NOT Good! ["+n+"] logs")
EndIf
End sub
######################
### Выход из замка ###
######################
Sub Go()
GotoXY2(352,835,0)
wait(8000)
if uo.getgraphic("0x40000666")=='0x067D' then
uo.usefromground('0x067D')
endif
wait(1000)
GotoXY2(337,835,0)
wait(1000)
GotoXY2(338,793,0)
wait(1000)
GotoXY2(328,793,0)
wait(5000)
if uo.getgraphic("0x40001C32")=='0x067D' then
uo.usefromground('0x067D')
endif
wait(1000)
GotoXY2(313,793,0)
wait(5000)
if uo.getgraphic("0x40001763")=='0x0675' then
uo.usefromground('0x0675')
endif
wait(1000)
GotoXY2(313,784,0)
wait(5000)
if uo.getgraphic("0x40007B5C")=='0x0677' then
uo.usefromground('0x0677')
endif
wait(1000)
GotoXY2(313,762,0)
wait(1000)
GotoXY2(298,762,0)
wait(1000)
GotoXY2(299,763,0)
wait(5000)
if uo.getgraphic("0x40000D0F")=='0x0675' then
uo.usefromground('0x0675')
endif
wait(1000)
GotoXY2(299,776,0)
wait(1000)
GotoXY2(291,768,0)
wait(1000)
GotoXY2(291,764,0)
wait(1000)
GotoXY2(296,764,0)
wait(1000)
GotoXY2(286,771,0)
wait(1000)
GotoXY2(286,782,0)
wait(1000)
GotoXY2(291,782,0)
wait(1000)
GotoXY2(300,762,0)
wait(5000)
if uo.getgraphic("0x400C09D8")=='0x067F' then
uo.usefromground('0x067F')
endif
wait(1000)
GotoXY2(309,762,0)
wait(1000)
GotoXY(300,793,0)
end sub
##################################
### Проверки на рубку, таргеты ###
##################################
Sub WaitForChange()
Var Text1 = "You hack at the tree for a while, but fail to produce any useable wood."
Var Text2 = "There are no logs here to chop."
Var Text3 = "You can't reach this."
Var Text4 = "That is too far away."
Var Text5 = "You can't do much in your current state."
Var mess
For Var i = 0 to 200
mess = UO.Journal(0)
If UO.Journal(0)==Text2 or UO.Journal(0)==Text3 or UO.Journal(0)==Text4 Then
return 1
EndIf
If UO.Journal(0)==Text1 Then
return 0
EndIf
If mess[0]=='Y' and mess[1]=='o' and mess[2]=='u' and mess[4]=='p' and mess[5]=='u' and mess[6]=='t' Then
return 0
EndIf
Wait(50)
Next
return 0
End sub
#########################
### Движок ходьбы (1) ###
#########################
Sub GotoXY(x,y)
var myX,myY,lastX=0,lastY=0,i,halt=0,z,r=0
for i=1 to 60
myX=uo.getX();
myY=uo.getY();
if LastX==myX and LastY==myY then
halt=halt+1
else
halt=0
end if
if halt>=10 then
if uo.GetDir()==1 then
for z=0 to 8
uo.Press(40)
next
end if
if uo.GetDir()==3 then
for z=0 to 8
uo.Press(37)
next
end if
if uo.GetDir()==5 then
for z=0 to 8
uo.Press(38)
next
end if
if uo.GetDir()==7 then
for z=0 to 8
uo.Press(39)
next
end if
halt=15
end if
if Numb(x-myX)<=1 and Numb(y-myY)<=2 then
return 1
end if
if x<=myX then
if y<=myY then
for z=0 to 3
uo.Press(38)
next
else
for z=0 to 3
uo.Press(37)
next
end if
else
if y<=myY then
for z=0 to 3
uo.Press(39)
next
else
for z=0 to 3
uo.Press(40)
next
end if
end if
lastX=myX
lastY=myY
wait(200)
next
return 0
end sub
Sub Numb(num)
if num>=0 then
return num
else
return num*(-1)
end if
end sub
#########################
### Движок ходьбы (2) ###
#########################
Sub GotoXY2(x,y,prec)
var ld=0, ldc=0, dx
var dy, mx, my, ox, oy, mk, k
var T=1000 ; Время задержки между нажатиями клавиш
#uo.print(">")
#uo.track("1",str(x),str(y))
start:
mx=UO.GetX()
my=UO.GetY()
dx=mx-x
if dx<0 then
dx=0-dx
endif
dy=my-y
if dy<0 then
dy=0-dy
endif
if dy>dx then
dx=dy
end if
if dx<=prec then
return 1
end if
if not ldc then
#uo.print(STR(dx))
end if
if dx<3 then
mk=70
else
mk=15
end if
ox=mx
oy=my
for k=1 to mk
mx=UO.GetX()
my=UO.GetY()
if mx<>ox or my<>oy then
goto sdidapl
end if
wait(10)
next
sdidapl:
mx=UO.GetX()
my=UO.GetY()
dx=mx-x
if dx<0 then
dx=0-dx
endif
dy=my-y
if dy<0 then
dy=0-dy
endif
if dy>dx then
dx=dy
end if
if dx<=prec then
return 1
end if
if ld==dx then
ldc=ldc+1
if ldc>100 then
uo.print("Can not reach location!")
return
end if
else
ld=dx
end if
if mx==x then
if my==y then
return
endif
if my>y then
#UO.Print("UR")
UO.Press(33)
Wait(T)
goto start
endif
#UO.Print("DL")
UO.Press(35)
Wait(T)
goto start
end if
if mx<x then
if my>y then
#UO.Print("R")
UO.Press(39)
Wait(T)
goto start
endif
if my==y then
#UO.Print("DR")
UO.Press(34)
Wait(T)
goto start
endif
#UO.Print("D")
UO.Press(40)
Wait(T)
goto start
end if
if my<y then
#UO.Print("L")
UO.Press(37)
Wait(T)
goto start
endif
if my==y then
#UO.Print("LU")
UO.Press(36)
Wait(T)
goto start
endif
#UO.Print("U")
UO.Press(38)
Wait(T)
goto start
end sub
#############################
### Выключаем все скрипты ###
#############################
Sub Terminate()
UO.Print("Lumberjacking script: Off!")
UO.DeleteJournal()
UO.Exec('terminate all')
Wait(100)
UO.Exec('terminate all')
Wait(100)
UO.Exec('terminate all')
Wait(100)