Code: Select all
###############################################
# Antares
####################################################
var f=file("C:\trees3.dat") ## - Путь к файлу в котором будут хранится координаты деревьев.
###
var TryHiding=1 ## 1 - Перед тем как рубить дерево, будет пытаться уйти в хайд, 0 - не будет .
###
var TryRecall=1 ## 1 - После того как соберет LogsQty логов, будет пытаться реколиться домой,
### складывать логи в сундук и реколиться обратно , 0 - не будет.
###
var LogsQty=1500 ## - Количество логов, добыв которое надо реколиться домой.
###
var GetFromFile=1 ## 1 - Координаты деревьев будут считыватся из файла, 0 - собиратся из клиента
### (сначала соберите а потом считывайте из файла).
###
var AttackEnts=0 ## 1 - Включить рекол по руне(в паке) при атаке, 0 - отключить рекол.
###
var CastAtAttack=0 ## 1 - Включить каст - "Magic Arrow" на напавшего, 0 - отключить каст.
###
var EatingFood=0 ## 1 - Будем есть, 0 - нет.
###
var TypeFood='0x097B' ## - Тип еды которую будем кушать.(сейчас фиштейки)
###
var Reconnect=0 ## 1 - Включить реконнект на сервер если выкинет, 0 - отключить реконнект.
###
var RecallDrop=0 ## 1 - Включить рекол после побега от ента домой и выложить логи, 0 -выключить.
###
var RecallLumber=0 ## 1 - Включить рекол в лес после указания обьектов, 0 - выключить.
###
var Chest='0x40017F16' ## - ID сундука куда будут выгружаться логи, где должны лежать реколы и еда.
###
var LumberSound=('C:\Warning.wav') ## - Звук которы будет пригран при атаке.(замените на свой)
###
var oldX,oldY,time ## - Для рекола.
###
###################################################################################################
###
###########
sub main()
var i=0,j=0,k=0,r=0,q=0,ii,jj
var TopX=324,TopY=65
dim TreeX[5000], TreeY[5000],TreeT[5000]
dim TreeTile[10]
var flag=0,treeCount=0,clicks=0,flag2=0
########################
### Графика деревьев ###
########################
TreeTile[0]=3283
TreeTile[1]=3277
TreeTile[2]=3293
TreeTile[3]=3296
TreeTile[4]=3302
TreeTile[5]=3299
TreeTile[6]=3290
TreeTile[7]=3288
TreeTile[8]=3286
TreeTile[9]=3280
uo.Exec("filterspeech on")
uo.Exec("filterspeech add 'Where do you want to use the pickaxe?'")
if Reconnect==1 then
uo.Exec('exec Reconnect')
end if
if AttackEnts==1 then
uo.Exec('exec AttackEnts')
end if
if RecallLumber==1 then
Recall('Les')
wait(9000)
end if
#####################################
### Загружаем координаты из файла ###
#####################################
if GetFromFile==1 then
uo.Print('Loading from file...')
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()
else
######################################
### Собираем координаты из клиента ###
######################################
uo.Print('Collect coordinates...')
repeat
clicks=0
flag=0
uo.DeleteJournal()
#######################
### Кликаем на тайл ###
#######################
uo.UseType('0x0E85') ;PickAxe
waitForTarget()
uo.DeleteJournal()
WaitForTryRock()
###############################
### Проверяем дерево ли это ###
###############################
flag=0
for k=0 to 9
if uo.LastTile(0)==TreeTile[k]+1 then
flag=2
end if
next
if flag==0 then
for k=0 to 9
if uo.LastTile(0)==TreeTile[k] then
flag=1
end if
next
end if
if uo.Lasttile(1)==uo.getX() and uo.Lasttile(2)==uo.gety() then
flag=3
end if
#########################
### Кликнули на ствол ###
#########################
if flag==1 then
flag2=0
if treeCount>0 then
for ii=1 to treeCount
if TreeX[ii]==uo.LastTile(1) and TreeY[ii]==uo.LastTile(2) then
flag2=1
end if
next
end if
if flag2==0 then
treeCount=treeCount+1
TreeX[treeCount]=uo.LastTile(1)
TreeY[treeCount]=uo.LastTile(2)
TreeT[treeCount]=uo.LastTile(0)
uo.Print('Tree founded1 '+str(treeCount)+' : x='+str(uo.Lasttile(1))+' y='+str(uo.LastTile(2))+' '+str(treeCount))
end if
end if
##########################
### Кликнули по листве ###
##########################
if flag==2 then
flag2=0
if treeCount>0 then
for ii=1 to treeCount
if TreeX[ii]==uo.LastTile(1) and TreeY[ii]==uo.LastTile(2) then
flag2=1
end if
next
end if
if flag2==0 then
treeCount=treeCount+1
TreeX[treeCount]=uo.LastTile(1)
TreeY[treeCount]=uo.LastTile(2)
TreeT[treeCount]=uo.LastTile(0)-1
uo.print('tree founded2 '+str(treeCount)+' : x='+str(uo.Lasttile(1))+' y='+str(uo.LastTile(2)))
end if
end if
until (Flag==3) or (treeCount==500)
uo.Exec("filterspeech off")
uo.Print('Analis finished, saving to file C:\trees3.dat')
SaveToFile(treeCount,TreeX,TreeY,TreeT)
end if
uo.Print('Trees quntity: '+str(treeCount))
wait(2000)
######################################
### Ходим по собранным координатам ###
######################################
while true
if treeCount>0 then
for i=1 to treeCount
if TryRecall==1 and uo.Count('ZLK')>=LogsQty then
ToRecall()
end if
uo.Print('Go to tree '+str(i)+': x='+str(TreeX[i])+' y='+str(TreeY[i]))
InfoLogs()
flag=GotoXY(TreeX[i],TreeY[i])
if flag==1 then
if TryHiding==1 then
ToHide()
end if
GetTree(str(TreeT[i]),str(TreeX[i]),str(TreeY[i]),str(uo.GetZ()))
end if
next
end if
wend
end sub
##########################
sub SaveToFile(treeCount,TreeX,TreeY,TreeT)
var f=file("C:\trees3.dat")
var s=0,i=0
f.open()
f.create()
s=safe call f.writeln(treeCount)
for i=1 to treeCount
s=safe call f.writeln(str(TreeT[i])+' '+str(TreeX[i])+' '+str(TreeY[i]))
next
f.close()
end sub
###########################################
sub GetTree(Type,X,Y,Z)
var i
uo.Print('Start lumberjacking...')
for i=0 to 15
if uo.Warmode()==1 then
return 0
end if
wait(200)
uo.DeleteJournal()
### CheckLag()
uo.WaitTargetTile(Type,X,Y,Z)
uo.UseType('0x0F43')
if WaitForChange()==1 then
return 1
end if
next
return 0
end sub
#################################
sub takereg()
;var RC = '0x40026308' ;ID контейнера с регами, Arre
var RC = '0x40FE3EC4' ; ID контейнера с регами, Sharman
DIM reg[3]
var i,n
reg[1]='0x0F86' ; MR
reg[2]='0x0F7B' ; BM
reg[3]='0x0F7A' ; BP
UO.UseObject(RC)
for i=1 to 3
while UO.Count(reg[i])<5
UO.FindType(reg[i],-1,RC)
n=UO.Count(reg[i])
UO.Grab(str(5-n),'finditem')
wait(200)
wend
next
end sub
#################################
sub ToRecall()
Recall('Bank')
DropLogs()
InfoLogs()
takereg()
if EatingFood==1 then
EatingFood()
end if
wait(3000)
Recall('Les')
end sub
#################################
sub Recall(dest)
var b
uo.print('Recoll')
for b=1 to 10
uo.deletejournal()
uo.waittargetobject(dest)
uo.cast('Recall',dest)
if WaitForRecall()==1 then
return 1
end if
next
return 0
end sub
###################################
sub WaitForRecall()
var Text1=uo.getname()+": The spell fizzles."
var mess='',lastX=uo.getX(),lastY=uo.getY()
for var v=0 to 200
mess=uo.journal(0)
if uo.Journal(0)==Text1 then
return 0
end if
if uo.getX()<>lastX OR uo.getY()<>LastY then
return 1
end if
wait(50)
next
return 0
end sub
###############################################
sub ToHide()
while not uo.Hidden()
uo.Print('Hiding...')
uo.DeleteJournal()
uo.UseSkill('Stealth')
wait(6000)
wend
wait(100)
end sub
#################################################
sub WaitForHide()
var Text1=uo.GetName()+": You have hidden yourself well"
var Text2=uo.GetName()+": You can't seem to hide here."
var mess
for var i=0 to 200
mess=uo.Journal(0)
if uo.Journal(0)==Text1 then
return 1
end if
if uo.Journal(0)==Text2 then
return 0
end if
wait(50)
next
return 0
end sub
##############################################
sub WaitForChange()
var Text1=uo.GetName()+': You hack at the tree for a while, but fail to produce any useable wood.'
var Text2='There is nothing 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
end if
if uo.Journal(0)==Text1 then
return 0
end if
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
end if
wait(50)
next
return 0
end sub
#######################################
sub WaitForTryRock()
var Text1="That is too far away."
var Text2="Try mining in rock."
var Text3="There is no ore here to mine."
var Text4="You have no line of sight to that location"
var Text5="You can't see the target"
var Text6="Try mining elsewhere."
var Text7="You can't use the %s where it is."
for var i=0 to 50
if uo.Journal(0)==Text1 or uo.Journal(0)==Text2 or uo.Journal(0)==Text3 or uo.Journal(0)==Text4 or uo.Journal(0)==Text5 or uo.Journal(0)==Text6 or uo.Journal(0)==Text7 then
return 1
end if
wait(200)
next
return 0
end sub
#####################################
sub WaitForTarget()
for var i=0 to 50
if uo.Targeting()==1 then
return 1
end if
wait(200)
next
return 0
end sub
#############################
sub WaitForChangeXY(myX,myY,lastX,lastY)
for var i=1 to 50
if lastX<>myX or lastY<>myY then
return 1
end if
wait(200)
next
return 0
end sub
####################################
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
#############################
sub DropLogs()
UO.Say('bank')
ToHide()
if uo.Waiting() then
uo.CancelTarget()
end if
var a,Exit
dim Logs[1]
Logs[0]=0x1BDD
uo.Print('Unload logs.')
uo.SetReceivingContainer(Chest)
wait(500)
for a=0 to 0
Exit=0
repeat
uo.FindType(Logs[a])
if uo.GetQuantity('finditem')>0 then
uo.Grab('0','finditem')
wait(1500)
else
Exit=1
end if
until Exit==1
next
uo.UnSetReceivingContainer(Chest)
uo.Print('Логи Выложены.')
end sub
#################################
sub InfoLogs()
uo.Print(str(uo.Count('0x1BDD'))+' logs in bag')
uo.Print(str(uo.Count('0x1BDD','0x0000'))+' simple and ' +str(uo.Count('0x1BDD')-uo.Count('0x1BDD','0x0000'))+' colored')
end sub
#################################
sub Open(Container)
uo.DeleteJournal()
uo.UseObject(Container)
repeat
wait(500)
until uo.InJournal('Contains')
end sub
###################
sub EatingFood()
ToEat()
DropFood()
end sub
#######################
sub ToEat()
uo.SetReceivingContainer('backpack')
Open(Chest)
uo.FindType(TypeFood,'-1',Chest)
uo.Grab('50','finditem')
wait(500)
repeat
Checklag()
uo.UseType(TypeFood)
wait(1000)
until uo.InJournal('You are simply too full to eat any more!')
uo.UnsetReceivingContainer()
end sub
#############################
sub DropFood()
if uo.Waiting() then
uo.CancelTarget()
end if
var f,Exit
dim Food[1]
Food[0]=TypeFood
uo.SetReceivingContainer(Chest)
wait(500)
for f=0 to 0
Exit=0
repeat
uo.FindType(Food[f])
if uo.GetQuantity('finditem')>0 then
uo.Grab('0','finditem')
wait(1500)
else
Exit=1
end if
until Exit==1
next
uo.UnSetReceivingContainer(Chest)
end sub
##################################
sub AttackEnts()
uo.DeleteJournal()
var Enemy='0x00000000'
repeat
if uo.InJournal('is attacking you') or uo.InJournal('OOPS!!!') or uo.InJournal('Wis Quas') then
uo.Exec('terminate Lumberjacking')
Enemy=uo.JournalSerial(uo.InJournal('is attacking you')-1)
##uo.PlayWav(LumberSound)
if CastAtAttack==1 then
uo.Cast('Magic Arrow',Enemy)
end if
uo.DeleteJournal()
Recall('Bank')
end if
wait(1000)
until false
end sub
######################################
sub Reconnect()
var ReconnectTime,rFlag
ReconnectTime='0'
rFlag=1
repeat
while (uo.ObjAtLayer('Bpack')=='')
if rFlag then
ReconnectTime=MakeTime()
rFlag=0
end if
wait(20000)
uo.Say('')
wait(3000)
uo.Say('')
wait(3000)
uo.Say('')
wait(3000)
uo.LDblClick(357,164)
uo.LClick(616,459)
wait(3000)
wend
wait(3000)
if (rFlag==0) and (ReconnectTime<>'0') then
uo.TextOpen()
uo.TextPrint('Disconnected & Reconnected @ '+ReconnectTime)
rFlag=1
ReconnectTime='0'
end if
until false
end sub
#####################################
sub MakeTime()
var d,t,ret,i
ret=str(uo.Time())
t=""
for i=0 to Len(ret)
t=ret[Len(ret)-i]+t
if (i==2) or (i==4) then
t=":"+t
end if
next
ret=str(uo.Date())
d=""
for i=0 to Len(ret)
d=ret[Len(ret)-i] + d
if (i==2) or (i==4) then
d="."+d
end if
next
ret=t+" @ "+d
return ret
end sub
########################################
sub Terminate()
uo.Print('terminate all')
uo.DeleteJournal()
uo.Exec('terminate all')
wait(100)
uo.Exec('terminate all')
wait(100)
uo.Exec('terminate all')
wait(100)
end sub
#########################################
sub CheckLag()
if uo.Waiting()>0 then
uo.Exec('canceltarget')
end if
uo.DeleteJournal()
uo.Click('backpack')
repeat
wait(50)
until uo.InJournal('backpack')
end sub