Page 1 of 1

Лёгкое дополнение к минингу

Posted: 2006-12-08 01:12:03
by -=SweD=-
Добрый день. Хотелось бы немного дополнить скрипт некоторыми функциями, помагите кто знает.

Сам скрипт:

Code: Select all

sub main()
uo.deletejournal()
uo.set('finddistance',1)
wait(100)
var i,b,f,tile,xx,yy,j
dim x[50]
dim y[50]
dim t[50]
dim a[50]

start:

a[1] = "1342 1254 1240 0"
a[2] = "1340 1254 1241 0"
a[3] = "1343 1254 1242 0"
a[4] = "1341 1254 1243 0"
a[5] = "1339 1254 1244 0"
a[6] = "1341 1254 1245 0"
a[7] = "1342 1254 1246 0"
a[8] = "1345 1254 1247 0"
a[9] = "1347 1255 1247 0"
a[10] = "1346 1256 1247 0"
a[11] = "1347 1257 1247 0"
a[12] = "1341 1258 1247 0"
a[13] = "1342 1259 1247 0"
a[14] = "1343 1260 1247 0"
a[15] = "1341 1261 1247 0"
a[16] = "1339 1262 1247 0"
a[17] = "1340 1262 1246 0"
a[18] = "1342 1262 1245 0"
a[19] = "1339 1262 1244 0"
a[20] = "1340 1262 1243 0"
a[21] = "1339 1262 1242 0"
a[22] = "1340 1262 1241 0"
a[23] = "1341 1262 1240 0"
a[24] = "1352 1262 1239 0"
a[25] = "1342 1261 1239 0"
a[26] = "1342 1260 1239 0"
a[27] = "1339 1259 1239 0"
a[28] = "1343 1258 1239 0"
a[29] = "1340 1257 1239 0"
a[30] = "1341 1256 1239 0"
a[31] = "1343 1255 1239 0"
#a[32] = "1343 2571 454 0"
#a[33] = "1343 2571 453 0"
#a[34] = "1343 2571 452 0"
#a[35] = "1343 2571 451 0"
#a[36] = "1343 2571 450 0"
#a[37] = "1343 2571 449 0"
#a[38] = "1342 2571 448 0"
#a[39] = "1343 2571 447 0"
#a[40] = "1343 2571 446 0"
#a[41] = "1343 2572 446 0"
#a[42] = "1343 2573 446 0"
#a[43] = "1343 2574 446 0"
#a[44] = "1343 2575 446 0"
#a[45] = "1343 2576 446 0"

for j = 1 to 50
if a[j] then
b = a[j]
i = 1
t[j] = b[0]
while b[i] <> " "
t[j] = t[j] + b[i]
i = i + 1
wend
i = i + 1
x[j] = b[i]
while b[i] <> " "
x[j] = x[j] + b[i+1]
i = i + 1
wend
i = i + 1
y[j] = b[i]
while b[i] <> " "
y[j] = y[j] + b[i+1]
i = i + 1
wend
xx = val(x[j])
yy = val(y[j])
tile = val(t[j])
uo.print("Tile: "+t[j]+" X: "+x[j]+" Y: "+y[j])
uo.print("Tree number "+str(j))
mine(xx,yy,tile)
endif
next
goto start:
end sub


sub mine(xx,yy,tile)
var a,b,c
var D = 1
var T = "True"
var x = xx
var y = yy
uo.deletejournal()
if UO.objatlayer("Rhand")=="" then
UO.equipt("Rhand","0x0E85") 
end if
wait(200)

uo.print (str(xx)+" "+str(yy))
GoToTile(x,y,d,t) 
c = uo.timer()
uo.exec ("waittargettile "+str(tile)+" "+str(xx)+" "+str(yy)+" 0")
wait (500)
uo.usetype('0x0E85')
repeat
wait (500)
until uo.injournal("You finished looping") or uo.injournal("You stop mining") or uo.injournal("Looping aborted") or uo.injournal("You put") or uo.injournal("There is nothing") or uo.injournal("You loosen some")
wait(2000)
a = uo.getx()
b = uo.gety()
end sub



var need_hungry_level = 1
sub hungry()
var i,htest,htime,htest2
dim a[11]
a[0] = "You are absolutely stuffed"
a[1] = "You are stuffed"
a[2] = "You aren't hungry at all"
a[3] = "You are a little hungry"
a[4] = "You are somewhat hungry"
a[5] = "You are REALLY hungry"
a[6] = "Your stomash hurts"
a[7] = "Your stomash hurts and you feel dizzy"
a[8] = "You are starving"
a[9] = "You are almost dying of hunger"
a[10] = "You are DYING of hunger"
htest = 0
repeat
uo.deletejournal()
uo.serverprint(".hungry")
wait (1000)
i = 0
htest2 = 0
if uo.count("0x097B") > 0 then
repeat
if uo.injournal(a[i]) then
if (i - need_hungry_level) > 0 then
uo.exec("usetype 0x097B")
repeat
wait (50)
until uo.injournal("Tasty!") or uo.injournal("Good!") or uo.injournal("Yum!") or uo.injournal("I am already") or uo.injournal("123")
htest2 = 1
else
htest = 1
htest2 = 1
endif
endif
i = i + 1
until i == 11 or htest2 == 1
else
htest = 1
endif
until htest == 1
endsub

Var MoveDelay=500
Var MoveNumber=1
Var Ep=0.172
Sub Perp(Dir) 
Var D 
D=Dir 
If Dir==1 Then 
 D=3 
EndIf 
If Dir==2 Then 
 D=4 
EndIf 
If Dir==3 Then 
 D=-1 
EndIf 
If Dir==4 Then 
 D=-2 
EndIf 
If Dir==-1 Then 
 D=-3 
EndIf 
If Dir==-2 Then 
 D=-4 
EndIf 
If Dir==-3 Then 
 D=1 
EndIf 
If Dir==-4 Then 
 D=2 
EndIf 
RETURN D 
EndSub 

Sub MoveOnce(Dir,Del,Rev) 
Var Num 
If Rev Then 
 Num=MoveNumber+1 
Else 
 Num=MoveNumber 
EndIf 
If (Num>0) and (Dir<>0) Then 
 If Dir==1 Then 
  UO.Press(38,Num,Del) 
 EndIf 
 If Dir==2 Then 
  UO.Press(33,Num,Del) 
 EndIf 
 If Dir==3 Then 
  UO.Press(39,Num,Del) 
 EndIf 
 If Dir==4 Then 
  UO.Press(34,Num,Del) 
 EndIf 
 If Dir==-1 Then 
  UO.Press(40,Num-1,Del) 
 EndIf 
 If Dir==-2 Then 
  UO.Press(35,Num,Del) 
 EndIf 
 If Dir==-3 Then 
  UO.Press(37,Num,Del) 
 EndIf 
 If Dir==-4 Then 
  UO.Press(36,Num,Del) 
 EndIf 
 If Rev Then 
  If Dir<>-1 Then 
   UO.Press(40,1,Del) 
  EndIf 
 EndIf 
EndIf 
EndSub 

Sub GetQDir(x,y) 
Var J=0 
If X==0 Then 
 J=1 
Else 
 If (Y/X)<ep Then 
  J=3 
 Else 
  If (X/Y)<ep Then 
   J=1 
  Else 
   J=2 
  EndIf 
 EndIf 
EndIf 
RETURN J 
EndSub 

sub GetDir(myx,myy,ox,oy) 
Var I,J 
J=0 
Var X=ox-myx 
Var Y=oy-myy 
I=GetQDir(Abs(X),Abs(Y)) 
If X>=0 Then 
 If Y>=0 Then 
  If I==1 Then 
   J=-2 
  Else 
   If I==2 Then 
    J=-1 
   Else 
    If I==3 Then 
     J=4 
    EndIf 
   EndIf 
  EndIf 
 Else 
  If I==1 Then 
   J=2 
  Else 
   If I==2 Then 
    J=3 
   Else 
    If I==3 Then 
     J=4 
    EndIf 
   EndIf 
  EndIf 
 EndIf 
Else 
 If Y>=0 Then 
  If I==1 Then 
   J=-2 
  Else 
   If I==2 Then 
    J=-3 
   Else 
    If I==3 Then 
     J=-4 
    EndIf 
   EndIf 
  EndIf 
 Else 
  If I==1 Then 
   J=2 
  Else 
   If I==2 Then 
    J=1 
   Else 
    If I==3 Then 
     J=-4 
    EndIf 
   EndIf 
  EndIf 
 EndIf 
EndIf 
RETURN J 
endsub 

sub abs(a) 
Var b 
If a<0 Then 
 b=-a 
Else 
 b=a 
endif 
return b 
endsub 

Sub PermResend() 
Var Mn=9 
Repeat 
 UO.Resend() 
 Wait(MoveDelay*Mn) 
Until (1>2) 
EndSub 

sub max(A,B) 
Var C 
If A>B Then 
 C=A 
Else 
 C=B 
EndIf 
Return C 
EndSub 

sub GetDistance(X,Y) 
return max(abs(X-uo.getx()),abs(Y-uo.gety())) 
endsub 

sub GoToTile(OX,OY,N,S) 
var myx, myy, MD, J 
var Lx1 ,Ly1 
var Lx2 ,Ly2 
var Sx ,Sy 
var T 
var Des=N 
J=1 
MD=MoveDelay*1.5 
myx=uo.getx() 
myy=uo.gety() 
MoveOnce(GetDir(uo.getx(),uo.gety(),ox,oy),MD,False) 
Sx=0 
Sy=0 
Lx1=uo.getx()/2 
Ly1=uo.gety()/2 
Lx2=Lx1/2 
Ly2=Ly1/2 
T=UO.Timer() 
If (GetDistance(ox,oy)<>N) or ((not S) and GetDistance(ox,oy)>N) Then 
 UO.Exec('exec PermResend') 
EndIf 
While ((GetDistance(ox,oy)<>N) or ((not S) and GetDistance(ox,oy)>N)) and (OX>=0) and (OY>=0) 
 If ((UO.Timer()-T)*15>MoveDelay) Then 
  T=UO.Timer() 
  UO.Print(Str(uo.getx())+' '+Str(uo.gety())+' '+Str(ox)+' '+Str(oy)+' '+Str(GetDir(uo.getx(),uo.gety(),ox,oy))+' '+Str(T)) 
  Lx2=Lx1 
  Ly2=Ly1 
  Lx1=myx 
  Ly1=myy 
  myx=uo.getx() 
  myy=uo.gety() 
 endIf 
 MD=MoveDelay 
 If ((OX-uo.getx())*(OX-uo.getx())+(OY-uo.gety())*(OY-uo.gety())>0) Then 
  MD=MD*3/GetDistance(ox,oy) 
 EndIf 
 wait(MD) 
 If GetDistance(OX,OY)>Des Then 
  MoveOnce(GetDir(uo.GetX(),uo.GetY(),ox,oy),MD,False) 
 Else 
  If S Then 
   If GetDistance(OX,OY)<Des Then 
    If GetDistance(OX,OY)<>0 Then 
     MoveOnce(GetDir(ox,oy,uo.GetX(),uo.GetY()),MD,False) 
    Else 
     MoveOnce(GetDir(uo.GetX(),uo.GetY(),Lx2,Ly2),MD,False) 
    EndIf 
   EndIf 
  EndIf 
 EndIf 
 If GetDistance(OX,OY)<>Des Then 
  If (Lx2==uo.getx()) and (Ly2==uo.gety()) Then 
   If (Sx<>uo.getx()) or (Sy<>uo.gety()) Then 
    J=1 
   EndIf 
   J=J+1 
   UO.Resend() 
   Sx = uo.getx() 
   Sy = uo.gety() 
   Stun(ox,oy,J) 
  EndIf 
 EndIf 
Wend 
UO.Exec('terminate PermResend') 
endsub 

Sub Stun(X,Y,N) 
Var I 
Var myx 
Var myy 
myx = uo.getx() 
myy = uo.gety() 
For I=1 to N 
 MoveOnce(perp(GetDir(myx,myy,x,y)),MoveDelay,False) 
Next 
Wait(MoveDelay) 
UO.Resend() 
If (myx==uo.getx()) and (myy==uo.gety()) Then 
 For I=1 to N 
  MoveOnce(-perp(GetDir(myx,myy,x,y)),MoveDelay,False) 
 Next 
 Wait(MoveDelay) 
 UO.Resend() 
EndIf 
If (myx==uo.getx()) and (myy==uo.gety()) Then 
 For I=1 to N 
  MoveOnce(-GetDir(myx,myy,x,y),MoveDelay,False) 
 Next 
 Wait(MoveDelay) 
 Stun(x,y,N) 
EndIf    
EndSub 

sub NearTile(Obj,Des) 
var ox, oy, myx, myy, MD, J 
var Lx1 ,Ly1 
var Lx2 ,Ly2 
var Sx ,Sy 
var T 
UO.Click(Obj) 
MD=MoveDelay*1.5 
ox=uo.GetX(Obj) 
oy=uo.GetY(Obj) 
J=1 
myx = uo.getx() 
myy = uo.gety() 
Sx=0 
Sy=0 
Lx1=myx/2 
Ly1=myy/2 
Lx2=Lx1/2 
Ly2=Ly1/2 
T=UO.Timer() 
If not (UO.GetDistance(Obj)==Des) Then 
 UO.Exec('exec PermResend') 
EndIf 
While not (UO.GetDistance(Obj)==Des) 
 ox=uo.GetX(Obj) 
 oy=uo.GetY(Obj) 
 If ((UO.Timer()-T)*15>MoveDelay) Then 
  T=UO.Timer() 
  UO.Print('Go to '+Str(Des)+' to '+UO.GetName(Obj)) 
  UO.Print(Str(UO.GetDistance(Obj))) 
  UO.Print(Str(uo.GetX())+' '+Str(uo.GetY())+' '+Str(uo.GetX(Obj))+' '+Str(uo.GetY(Obj))+' '+Str(GetDir(uo.GetX(),uo.GetY(),uo.GetX(Obj),uo.GetY(Obj)))+' '+Str(T)) 
  Lx2=Lx1 
  Ly2=Ly1 
  Lx1=myx 
  Ly1=myy 
  myx=uo.getx() 
  myy=uo.gety() 
 endIf 
 MD=MoveDelay*1.5 
 If (UO.GetDistance(Obj)>0) Then 
  MD=MD/UO.GetDistance(Obj) 
 EndIf 
 wait(MD) 
 If UO.GetDistance(Obj)>Des Then 
  MoveOnce(GetDir(uo.GetX(),uo.GetY(),uo.GetX(Obj),uo.GetY(Obj)),MD,False) 
 Else 
  If UO.GetDistance(Obj)<Des Then 
   If UO.GetDistance(Obj)<>0 Then 
    MoveOnce(GetDir(uo.GetX(obj),uo.GetY(obj),uo.GetX(),uo.GetY()),MD,False) 
   Else 
    MoveOnce(GetDir(uo.GetX(),uo.GetY(),Lx2,Ly2),MD,False) 
   EndIf 
  EndIf 
 EndIf 
 If UO.GetDistance(Obj)<>Des Then 
  If (Lx2==uo.getx()) and (Ly2==uo.gety()) Then 
   If (Sx<>uo.getx()) or (Sy<>uo.gety()) Then 
    J=1 
   EndIf 
   J=J+1 
   UO.Resend() 
   Sx = uo.getx() 
   Sy = uo.gety() 
   Stun(uo.GetX(Obj),uo.GetY(Obj),J) 
  EndIf 
 EndIf 
Wend 
UO.Exec('terminate PermResend') 
endsub 



var max_wait = 3 #(v secundax)
sub gotoxy(x,y,prec) 
var ld=0,ldc=0 
var dx,dy 
var mx,my 
var ox,oy,mk,k 
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 
end if 
if not ldc then
uo.print("Lag")
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 
end if 
if ld==dx then 
ldc=ldc+1 
if ldc>max_wait 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.Press(33) 
goto start 
endif 
UO.Press(35) 
goto start 
end if 
if mx<x then 
if my>y then 
UO.Press(39) 
goto start 
endif 
if my==y then 
UO.Press(34) 
goto start 
endif 
UO.Press(40) 
goto start 
end if 
if my<y then 
UO.Press(37) 
goto start 
endif 
if my==y then 
UO.Press(36) 
goto start 
endif 
UO.Press(38) 
goto start 
end sub
Собственно чар ходит по координатам которые я введу...
Собствеено хотелось добавить вот что:
1. При завршении круга, чар тыкает в столб (ID=0x4008DB03 Type=0x0ED4) - эт банк (находится на тайле: 1343 1255 1239 0), и выкладывает всю руду в сумочку (можно massmove)
2. При копке выкидывал бы не нужную руду, просто сам пытался доделать, не разобрался с командой ,drop
Руда по типу одинаковая, цвета разные.

Заранее спасибо.

Posted: 2006-12-08 07:50:19
by Nmy
оhttps://yoko.uokit.com/viewtopic.php?t=10249&highlight=
скрипт сбрасывает оры...
разгружалку можно взять такую:

Code: Select all

sub unloadore()
  VAR Sunduk

Dim UnLoad[10]
	UnLoad[1] = '0x19B9'
	UnLoad[2] = '0x19B8'
	UnLoad[3] = '0x19BA'
	UnLoad[4] = '0x19B7'
	UnLoad[5] = '0x0EED'
	UnLoad[6] = '0x09AA'
	UnLoad[7] = '0x1088'
	UnLoad[8] = '0x1087'
	UnLoad[9] = '0x1086'
	UnLoad[10]= '0x108A'

    UO.UseObject('Sunduk')
    CheckLag()

For n = 1 to 10
UO.FindType( UnLoad[n] , -1 ,'backpack')
while UO.GetQuantity('finditem') > 0
UO.moveitem('finditem','0','Sunduk')
CheckLag()
UO.FindType( UnLoad[n] , -1 ,'backpack')
wend
next

UO.FindType('0x0E85', -1 ,'backpack')
If UO.FindCount() == 0 then
UO.FindType('0x0E85', -1 ,'Sunduk')
UO.MoveItem('finditem')
Endif

    WalkMe(4559,3170,'')
    WalkMe(4557,3170,'')
    WalkMe(4554,3173,'')
  	WalkMe(TempX,TempY,'')
end sub
Швед на альфу забил ? :roll: