Code:
sub main()
##########################################
# Mining v1.02 #
# By Scripts Writer #
# icq : 424131028 #
# Thx to Savage's WalkN() #
# Thx to Mihail's date & time #
##########################################
# Antares. http://www.uoa.ru #
##########################################
var f=file('C:\mining.txt') #File where tile coordinates
var FromFile=1 #1-From file, 0-From client
var Hiding=1 #1-To hide before moving, 0-Don't hide
var EatFood=1 #1-To eat food, 0-Don't eat
var RuneToHome='0x40F6BCC5' #ID of rune to home
var RuneToMine='0x401E02F1' #ID of rune to cave
var Sunduk='0x404425AB' #ID of container where to put ores
var PickAxe=0x0E85 #Type of Pickaxe
var food=0x097B #Type of food to eat
var MaxWeight=600 #MaxWeight when to go unload
var msg1='Вы положили' #Msg 'You put'
var msg2='Вам не удалось' #Msg 'You fail to mine'
var msg3='Тут ничего нету' #Msg 'There is nothing ore'
#############################################################
#В бекпеке несколько кирок, руны в дом и шахту, реагенты.
#Устанавливаем флаг FromFile=0 и запускаем скрипт.Прицелами
#указываем на тайлы в шахте, собирая тем самым координаты
#по которым будем ходить и обкапывать в дальнейшем. Как только
#собрали, копируем информацию с тайлами и вставляем в ранее
#созданный файл mining.txt в каталое C:\ . На последней пустой
#строке помещаем 0 в начало строки-для определения конца файла.
#Устанавливаем флаг FromFile=1, указываем все значения #переменных
#и запускаем главную функцию main.
#############################################################
#In backpack there are some pickaxes,
#runes to the house and mine, reagents.
#We establish flag FromFile=0 and start a script.
#By targets click on tiles in cave,
#collecting that coordinates on which we shall go and
#mine in the further. As soon as have collected,
#we copy the information with tiles and it is
#inserted into earlier created file "mining.txt" in
#directory C:\. On last empty line it is placed 0 in the
#beginning of a line-for of definition of the end of a file.
#We establish flag FromFile=1, specify all
#values of variables and start main function.
#############################################################
#
# v1.01 Подправил медитацию. Добавил ведение лога в отдельном окне.
# v1.02 Изменение скрипта на вывод времени в лог.
DIM ore[4]
ore[0]='0x19B7'
ore[1]='0x19BA'
ore[2]='0x19B8'
ore[3]='0x19B9'
DIM XTile[550],YTile[550],ZTile[550]
var TileType
var mx,my
var i,k,l,mana
k=0
if FromFile==0 then
uo.DeleteJournal()
repeat
uo.AddObject('Tile')
wait(250)
while uo.Targeting()
wait(100)
wend
uo.WaitTargetTile('lasttile')
uo.Say(',infotile')
wait(500)
until uo.InJournal('stop')
return
else
f.Open()
repeat
TileType=safe call f.ReadNumber()
XTile[k]=safe call f.ReadNumber()
YTile[k]=safe call f.ReadNumber()
ZTile[k]=safe call f.ReadNumber()
if TileType<>0 then
uo.Print(STR(XTile[k])+' '+STR(YTile[k])+' '+STR(ZTile[k]))
end if
k=k+1
until TileType==0
uo.Print('There are '+STR(k-1)+' tiles in a file.')
f.Close()
end if
while not uo.Dead()
for i=0 to k-2
if Hiding==1 then
while not uo.Hidden()
uo.WarMode(0)
uo.Print('Try to hide yourself...')
uo.UseSkill('Hiding')
wait(3500)
wend
end if
if i==0 && uo.GetX('self')==358 && uo.GetY('self')==1443 then
WalkN(364,1438,"")
WalkN(382,1439,"")
end if
WalkN(XTile[i],YTile[i],"")
uo.Print('Start to mine '+STR(XTile[i])+' '+STR(YTile[i])+' '+STR(ZTile[i])+' tile.')
repeat
uo.DeleteJournal()
l=0
uo.WaitTargetTile('-1',XTile[i],YTile[i],ZTile[i])
uo.UseType(PickAxe)
repeat
wait(100)
l=l+1
until uo.InJournal(msg1) || uo.InJournal(msg2) || uo.InJournal(msg3) || l>100
until uo.InJournal(msg3) || l>100
if uo.Weight>MaxWeight then
repeat
mx=uo.GetX('self')
my=uo.GetY('self')
mana=uo.mana
if uo.mana < 30 then
uo.Print('Start meditation ... ')
uo.WarMode(0)
repeat
uo.UseSkill('Meditation')
l=0
uo.DeleteJournal()
if uo.WarMode==1 then
uo.WarMode(0)
end if
wait(250)
repeat
wait(100)
l=l+1
until uo.InJournal('Вы потеряли') || l>100 || uo.mana>=30
until uo.mana >= 30
end if
l=0
uo.Print('Start to recall home ...')
uo.WaitTargetObject(RuneToHome)
uo.Cast('Recall')
repeat
wait(100)
l=l+1
until mx<>uo.GetX('self') || my<>uo.GetY('self') || uo.mana<mana || l>100
until mx<>uo.GetX('self') || my<>uo.GetY('self')
uo.Print('We are at home.Start to unload...')
WalkN(uo.GetX(Sunduk),uo.GetY(Sunduk),Sunduk)
uo.UseObject(Sunduk)
wait(500)
uo.TextOpen()
uo.TextPrint(date(uo.date(),'.'))
uo.TextPrint(time(uo.time(),':'))
uo.TextPrint('------------------------')
for k = 0 to 3
uo.FindType(ore[k],'-1','backpack')
while uo.FindCount()
uo.Click('finditem')
wait(500)
uo.TextPrint(uo.GetName('finditem'))
uo.moveitem('finditem','all',Sunduk)
wait(1000)
uo.FindType(ore[k],'-1','backpack')
wend
next
uo.TextPrint('------------------------')
uo.IgnoreReset()
uo.Print('Upload was complete. Would you like to eat something?')
if EatFood==1 then
uo.DeleteJournal()
uo.FindType(food,'-1',Sunduk)
if uo.FindCount() then
uo.moveitem('finditem','30','backpack')
wait(1000)
repeat
wait(1000)
uo.UseType(food)
until uo.InJournal('You are simply')
end if
uo.FindType(food,'-1','backpack')
if uo.FindCount() then
uo.moveitem('finditem','all',Sunduk)
wait(1000)
end if
end if
repeat
mx=uo.GetX('self')
my=uo.GetY('self')
mana=uo.mana
if uo.mana < 30 then
uo.Print('Start meditation ... ')
uo.WarMode(0)
repeat
uo.UseSkill('Meditation')
l=0
uo.DeleteJournal()
if uo.WarMode==1 then
uo.WarMode(0)
end if
wait(250)
repeat
wait(100)
l=l+1
until uo.InJournal('Вы потеряли') || l>100 || uo.mana>=30
until uo.mana >= 30
end if
l=0
uo.Print('Start to recall mine ...')
uo.WaitTargetObject(RuneToMine)
uo.Cast('Recall')
repeat
wait(100)
l=l+1
until mx<>uo.GetX('self') || my<>uo.GetY('self') || uo.mana<mana || l>100
until mx<>uo.GetX('self') || my<>uo.GetY('self')
end if
next
wait(600000)
wend
end sub
sub WalkN(x,y,Target)
VAR i,StepSucess
VAR dx,dy,Exit=0
While Exit<>1
If Target<>"" Then
dx=UO.GetX(Target)-UO.GetX()
dy=UO.GetY(Target)-UO.GetY()
If UO.GetDistance(Target)<3 Then
Exit=1
Endif
Else
dx=x-UO.GetX()
dy=y-UO.GetY()
If dx==0 AND dy==0 Then
Exit=1
Endif
Endif
If dx<>0 AND dy<>0 Then
If dx>0 AND dy>0 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
If StepSucess==-1 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
StepSucess=Go(1,39,300) ;NE - RightArrow
If StepSucess==-1 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
Endif
Endif
Endif
If dx>0 AND dy<0 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
If StepSucess==-1 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
StepSucess=Go(3,40,300) ;SE - DownArrow
If StepSucess==-1 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
Endif
Endif
Endif
If dx<0 AND dy>0 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
If StepSucess==-1 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
StepSucess=Go(7,38,300) ;WN - UpArrow
If StepSucess==-1 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
Endif
Endif
Endif
If dx<0 AND dy<0 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
If StepSucess==-1 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
StepSucess=Go(5,37,300) ;SW - LeftArrow
If StepSucess==-1 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
Endif
Endif
Endif
Endif
If dx<>0 AND dy==0 Then
If dx>0 Then
StepSucess=Go(2,34,300) ;E - PgDown
If StepSucess==-1 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
If StepSucess==-1 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
Endif
StepSucess=Go(2,34,300) ;E - PgDown
Endif
Endif
If dx<0 Then
StepSucess=Go(6,36,300) ;W - Home
If StepSucess==-1 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
If StepSucess==-1 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
Endif
StepSucess=Go(6,36,300) ;W - Home
Endif
Endif
Endif
If dx==0 AND dy<>0 Then
If dy>0 Then
StepSucess=Go(4,35,300) ;S - End
If StepSucess==-1 Then
StepSucess=Go(3,40,300) ;SE - DownArrow
If StepSucess==-1 Then
StepSucess=Go(5,37,300) ;SW - LeftArrow
Endif
StepSucess=Go(4,35,300) ;S - End
Endif
Endif
If dy<0 Then
StepSucess=Go(0,33,300) ;N - PgUp
If StepSucess==-1 Then
StepSucess=Go(1,39,300) ;NE - RightArrow
If StepSucess==-1 Then
StepSucess=Go(7,38,300) ;WN - UpArrow
Endif
StepSucess=Go(0,33,300) ;N - PgUp
Endif
Endif
Endif
Wend
end sub
sub Go(dir,key,walkwait)
VAR x,y, OldDir
x=UO.GetX()
y=UO.GetY()
OldDir=UO.GetDir()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
UO.Press(key)
wait(walkwait)
If x==UO.GetX() AND y==UO.GetY() Then
CheckLag()
Endif
If x==UO.GetX() AND y==UO.GetY() AND OldDir<>UO.GetDir() Then
UO.Press(key)
wait(walkwait)
Endif
If x==UO.GetX() AND y==UO.GetY() Then
CheckLag()
Endif
If x==UO.GetX() AND y==UO.GetY() Then
UO.Print("Zasada!")
return -1
Else
return 1
Endif
end sub
#########################################
sub CheckLag()
UO.DeleteJournal()
UO.Click('backpack')
repeat
wait(500)
until UO.InJournal('Backpack')
end sub
sub date(jor,n)
var ser=str(jor), t=''
if len(ser)==5 then
ser='0'+ser
end if
t=right(ser,2)+n+mid(ser,2,2)+n+left(ser,2)
return t
end sub
sub time(jor,n)
var ser=str(jor),t=''
if len(ser)==5 then
ser='0'+ser
end if
t=left(ser,2)+n+mid(ser,2,2)+n+right(ser,2)
return t
end sub