Page 1 of 1

хелп со скриптом на мининг =)

Posted: 2008-03-31 14:30:05
by fritz321
помогите плиз со скриптом... он должен сначала спросить 6 точек в пещере, записать их в файл... потом ходить по ним.. но.. гора ошибок и не чего более...

Code: Select all

sub mining()
FindTile()
end sub

###############################################################
################ поиск тайлов #################################
###############################################################
sub FindTile()
var flag=0
var count
var i
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" 
dim TileX[6], TileY[6], TileT[6]

UO.print('Выберите рунку для рекола')
uo.exec('addobject rune')
while uo.targeting() 
wait(100)
wend

uo.print("Выберите кирку")
uo.exec('addobject kirka')

while uo.targeting()
	wait(100)
wend
###############################################
uo.print("Собираем координаты")
for i=0 to 6
	uo.useObject("kirka")
	uo.deleteJournal()

	count = 0

	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 then 
		TileX[count] = uo.lastTile(1)
		TileY[count] = uo.lastTile(2)
		tileT[count] = uo.lastTile(0)
##		if uo.Lasttile(1)==uo.getX() and uo.Lasttile(2)==uo.gety() then 
##			uo.print("Анализ окончен, найдено:"+str(count)+" тайлов")
##			flag=1 
##		end if 
	count = count + 1
	SaveToFile(count,TileX,TileY,TileT)
	uo.print("Найден тайл с координатами x:"+str(TileX)+" y:"+str(TileY))
end if
next
#####################################
while 1==1 
for i=1 to count 
uo.Print('Идем к тайлу '+str(i))
flag=GotoXY(TileX[i],TileY[i]) 
obkobka()
next  
wend 
end sub

#################################################################
################ сохранение в файл ##############################
#################################################################
sub SaveToFile(count,TileX,TileY,TileT)
var file=file("c:\test.dat") ## путь к файлу в который записываются координаты
var s=0, i=0
f.open()
f.create()
s=safe call f.write(count)
for i=1 to count
s=safe call f.writeln(str(TileT[i])+' '+str(TileX[i])+' '+str(TileY[i])) 
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 obkopka()
var mx, my, mz, i, j



mx = UO.GetX("self")
my = UO.GetY("self")
mz = UO.GetZ("self")
for i = mx-2 to mx+2
     for j = my-2 to my+2
   hidding()
UO.Print("Копаем в координатах: "+str(mx-i)+" "+str(my-j)) 
while not UO.InJournal("no ore here") and not UO.InJournal("location") and not UO.InJournal("far away") and not UO.InJournal("in rock") and not UO.InJournal("Iron Ore") and not UO.InJournal("Copper") and not UO.InJournal("Rusty Ore") 
UO.DeleteJournal() 
if uo.waiting() then 
uo.canceltarget() 
endif 
uo.findman( -1 ) 
         if uo.findcount() then 
            recal() 
            uo.exec('terminate mining')
         endif
UO.Waittargettile("1341", str(i), str(j), str(mz)) 
uo.usetype('0x0E85')
while not UO.InJournal("You put") and not UO.InJournal("heavy") and not UO.InJournal("location") and not UO.InJournal("no ore") and not UO.InJournal("but fail") and not UO.InJournal("far away") and not UO.InJournal("in rock") and AntiMacro()
wait (1000) 
if uo.weight>600 then
recal()
endif
 
          uo.findman( -1 ) 
          if uo.findcount() then 
            recal() 
            uo.exec('terminate all')
          endif

wend 
wend 
UO.DeleteJournal() 
next 
next 
hidding()
end sub
###########################################################################
sub hidding()
while not uo.Hidden()
uo.WarMode("0")
uo.print('Прячемся')
uo.UseSkill("Hiding")
wait(3500)
wend
end sub
###########################################################################
sub recal()
     if uo.waiting() then
          uo.canceltarget()
     endif
            uo.print ("Сьбываемся")
          uo.waittargetobject('rune')
          uo.cast('Recall')
          wait(3500)
          uo.exec('terminate all')
          
end sub
####################################################################################################################
sub DoubleCheck() 

	dim reindex[8] 
	reindex[0] = 11 
	reindex[1] = 12 
	reindex[2] = 13 
	reindex[3] = 10 
	reindex[4] = 16 
	reindex[5] = 14 
	reindex[6] = 17 
	reindex[7] = 15
	 
	var GumpID = 0 
	var ButtonID = 0 
	var ButtonText 
	
	for var i = 18 to 19
		GumpID = val(Mid(uo.LastGump('command', i), 16, 4)) 
		ButtonID = reindex[GumpID-2225] 
		ButtonText = uo.LastGump('command', ButtonID) 
		uo.LClick(Val(Mid(ButtonText, 7, 3)), Val(Mid(ButtonText, 11, 3)))
		repeat
			wait(500)
		until uo.LastGump('text', 4) <> "0"
	next

end sub 

sub AntiMacro() 

	if not uo.LastGump('replyed') then 
		if uo.LastGump('text', 0) == 'Antimacros System' then 
			DoubleCheck()
			return 0
		end if 
	end if 
	return 1
    
end sub
был бы очень благодарен... а то не чего в голову не идет

Posted: 2008-04-01 17:11:33
by fritz321
я не много переделал... скрипт бывший ветерановский на ламбер...
воть... какая то ошибка с записью координат... гляньте все таки

Code: Select all

var f=file("C:\trees3.dat") ## - Путь к файлу в котором будут хранится координаты деревьев. 
var GetFromFile=0 ## 1 - Координаты деревьев будут считыватся из файла, 0 - собиратся из клиента(сначала соберите а потом считывайте из файла). 
########### 
### Код ### 
########### 
sub Mining() 
var i=0,j=0,k=0,r=0,q=0,ii,jj 
var TopX=324,TopY=65 
dim TileX[5000], TileY[5000],TileT[5000]  
var flag=0,Count=0,clicks=0,flag2=0 
######################## 
### Графика деревьев ### 
######################## 

uo.Exec("filterspeech on") 
uo.Exec("filterspeech add 'Where do you want to use the pickaxe?'") 

##################################### 
### Загружаем координаты из файла ### 
##################################### 
if GetFromFile==1 then 
uo.Print('Загружаем координаты из файла...') 
f.open() 
Count=safe call f.ReadNumber() 
for i=1 to Count 
TileT[i]=safe call f.ReadNumber() 
TileX[i]=safe call f.ReadNumber() 
TileY[i]=safe call f.ReadNumber() 
next 
f.close() 
else 
###################################### 
### Собираем координаты из клиента ### 
######################################
UO.print('Выберите рунку')
uo.exec('addobject rune')
while uo.targeting() 
wait(100)
wend
 
uo.Print('Выбери Кирку: ') 
uo.Exec('addobject Pickaxe') 
while uo.Targeting() 
wait(100) 
wend 
uo.exec('exec findman')
uo.Print('Собираем координаты в округе...') 
repeat 
clicks=0 
flag=0 
uo.DeleteJournal() 
####################### 
### Кликаем на тайл ### 
####################### 
uo.UseObject('Pickaxe') 
while AntiMacro() and WaitForTryRock()
##waitForTarget() 
##uo.DeleteJournal() 
##WaitForTryRock() 
wend
############################### 
### Проверяем дерево ли это ### 
############################### 
if uo.Lasttile(1)==uo.getX() and uo.Lasttile(2)==uo.gety() then 
flag=3 
end if 
######################### 
### Кликнули на ствол ### 
######################### 
if flag==0 then
Count=Count+1 
TileX[Count]=uo.LastTile(1) 
TileY[Count]=uo.LastTile(2) 
TileT[Count]=uo.LastTile(0) 
uo.Print('Найдено: '+str(Count)+' : x='+str(uo.Lasttile(1))+' y='+str(uo.LastTile(2))+' '+str(Count)) 
endif
if flag==3 then 
uo.Exec("filterspeech off") 
uo.Print('Анализ закончен, координаты записаны в файл C:\trees3.dat') 
SaveToFile(Count,TileX,TileY,TileT) 
uo.Print('Найдено тайлов: '+str(Count)) 
wait(2000) 
endif
###################################### 
### Ходим по собранным координатам ### 
###################################### 
while 1==1 
if Count>0 then 
for i=1 to Count 
uo.Print('Идем к тайлу '+str(i)+': x='+str(TileX[i])+' y='+str(TileY[i])) 
flag=GotoXY(TileX[i],TileY[i]) 
wait(1000)
obkobka()
next 
end if 
wend 
uo.print("Скрипт закончен, перейдите в другую шахту...")
info()
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" 
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 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 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 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 obkopka()
var mx, my, mz, i, j

mx = UO.GetX("self")
my = UO.GetY("self")
mz = UO.GetZ("self")
for i = mx-2 to mx+2
     for j = my-2 to my+2
   hidding()
UO.Print("Копаем в координатах: "+str(mx-i)+" "+str(my-j)) 
while not UO.InJournal("no ore here") and not UO.InJournal("location") and not UO.InJournal("far away") and not UO.InJournal("in rock") and not UO.InJournal("Iron Ore") and not UO.InJournal("Copper") and not UO.InJournal("Rusty Ore") 
UO.DeleteJournal() 
if uo.waiting() then 
uo.canceltarget() 
endif 
UO.Waittargettile("1341", str(i), str(j), str(mz)) 
uo.usetype('0x0E85')
while not UO.InJournal("You put") and not UO.InJournal("heavy") and not UO.InJournal("location") and not UO.InJournal("no ore") and not UO.InJournal("but fail") and not UO.InJournal("far away") and not UO.InJournal("in rock") and AntiMacro()
wait (1000) 
if uo.weight>600 then
recal()
endif
wend 
wend 
UO.DeleteJournal() 
next 
next 
hidding()
uo.print("Вы закончили обкобку, передите на другое место и напишите: го")

while not uo.dead()
if uo.injournal("го") then
goto start
endif
uo.findman( -1 ) 
          if uo.findcount() then 
            recal() 
            uo.exec('terminate all')
          endif
wend
end sub
###########################################################################
sub hidding()
while not uo.Hidden()
uo.WarMode("0")
uo.print('Прячемся')
uo.UseSkill("Hiding")
wait(3500)
wend
end sub
###########################################################################
sub recal()
     if uo.waiting() then
          uo.canceltarget()
     endif
            uo.print ("Сьбываемся")
          uo.waittargetobject('rune')
          uo.cast('Recall')
          wait(3500)
          uo.exec('terminate all')
          
end sub
####################################################################################################################
sub DoubleCheck() 

	dim reindex[8] 
	reindex[0] = 11 
	reindex[1] = 12 
	reindex[2] = 13 
	reindex[3] = 10 
	reindex[4] = 16 
	reindex[5] = 14 
	reindex[6] = 17 
	reindex[7] = 15
	 
	var GumpID = 0 
	var ButtonID = 0 
	var ButtonText 
	
	for var i = 18 to 19
		GumpID = val(Mid(uo.LastGump('command', i), 16, 4)) 
		ButtonID = reindex[GumpID-2225] 
		ButtonText = uo.LastGump('command', ButtonID) 
		uo.LClick(Val(Mid(ButtonText, 7, 3)), Val(Mid(ButtonText, 11, 3)))
		repeat
			wait(500)
		until uo.LastGump('text', 4) <> "0"
	next

end sub 

sub AntiMacro() 

	if not uo.LastGump('replyed') then 
		if uo.LastGump('text', 0) == 'Antimacros System' then 
			DoubleCheck()
			return 0
		end if 
	end if 
	return 1
    
end sub
########################################################################################################################
sub findman()
while not uo.dead()
 uo.findman( -1 ) 
          if uo.findcount() then 
            recal() 
            uo.exec('terminate all')
          endif
wend
end sub

########################################################################################################################
sub info()
var ing
VAR Ruda1 = '0x19B9'            ; Тип руды 
VAR Ruda2 = '0x19B8'            ; Тип руды - 3 шт. 
VAR Ruda3 = '0x19BA'            ; Тип руды - 2 шт. 
VAR Ruda4 = '0x19B7'            ; Тип руды - 1 шт. 
ing=str(uo.count(Ruda1)) + str(uo.count(Ruda2)) + str(uo.count(Ruda3)) + str(uo.count(Ruda4))
uo.print("Всего выкопано"+str(ing))

end sub