Yoko

All sides of Injection
It is currently 2024-03-28 11:18:23

All times are UTC+02:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: 2006-12-28 14:39:48 
Offline

Joined: 2005-05-02 17:37:12
Posts: 46
Скриптик на руду от домика до шахты скидывание руды, и добор кирок, для работы необходимо с помошью процедурки Metka_kochek() замарчить тайлы в шахте, ею же можно замарчить и дорогу от шахты и обратно, сделал две дороги так как, при вырубке элема есть шанс что он останет где нибудь по второму макршуруту, у меня он проходил среди множества домов, и элемы отвлекались на чужих ботов :)
имена фалов с тайлами смотрите в теле скрипта, в заголовок не стал выносить
Code:
;*********************************************************************************** 
var Ruda = '0x19b9'
var Kirka = '0x0E86'
var bagpak     
var Box         
var box_regi
Var FileName
Var MaxWeight
Var MoveDelay=1000 # Промежуток между шагами
Var MoveNumber=1   # Количество шагов при смене дислокации
Var Ep=0.172 # Значение ширины угла хождения при определении направления.
#Если на пути встречаются сложные и широкие препятствия - увеличить.
#0.172 - сбалансированный.
MaxWeight= ((uo.STR*3.5)+39)
var Stoplocation
var nom_run
var danger = 0
Var F
var sc  = 0           ; счетчик тайлов
UO.Set( 'finddistance', '2' )

sub start()
   uo.exec('exec control')
      uo.exec('exec main')
end sub

sub Main()
wait(1000)
uo.Targeting('self')
Box = 'Box'
uo.set('norbcalc','1')
uo.set('norbcheck','1')
uo.set('injectecho','1')
uo.useobject("Box")

      
while not uo.dead()
   wait(500)

   if uo.count(Kirka) < 1  then
      GrAxe()
      wait(3000)
   end if
   go_to_Shahta()                                       ; Перед тем как бежать к точке реколимся в  шахту
   FileName = 'c:\_A\_Macr\dob\Mining_d\mn0.txt'                       
   F=File(FileName)
   F.Open()   
   wait(3000)
   uo.sayU("Go go go!")
   Rubit()     ; Запускаем рубку
wend
EndSub

;--------------------------------------------- РУБИМ -----------------------------
Sub Rubit()
Var Tl,T,X,Y,Z
var Tim
var Jurn

Dim Cli[4]
Cli[0]="cliloc# 0xA867"  ;You can't mine...
Cli[1]="cliloc# 0xAD00"  ;there no metal
Cli[2]="cliloc# 0x6B31"  ;backpack full
Cli[3]="cliloc# 0xA2DE"  ;is too far away
Cli[4]="cliloc# 0xA866"  ;You can't mine...


Beg:
Tl=safecall F.Readln()
Tl=Trim(Tl)
If Tl=='File read error' Then
  f.close()
  rec_to_home()      ;                                Реколл домой неспеша по регам
  wait(2000)
  GrRuda()   ; Скидываем добытое
  GrAxe()   ; Берем кирки
  GetRegs()         ; берем реги, свитки и т.д.
  wait(1000)
  main()
EndIf


T=GetNumb(Tl,0)
X=GetNumb(Tl,1)
Y=GetNumb(Tl,2)
Z=GetNumb(Tl,3)
  UO.Print('GoTo next point ' + str(sc) + ' X= '+ str(X) + ' Y= '+str(Y))
   sc = sc+1
  gotoxy(X,Y,1)                                  ;   --------------- Ходим по точкам из  файла c тайлами -----------
  uo.useskill("Hiding")                  ; прячемся
  wait(200) 

REPEAT
    uo.deletejournal()   
    UO.WaitTargetTile(Str(T),Str(X),Str(Y),Str(Z))
    UO.usetype(Kirka)   
    wait(1500)
    Jurn=UO.Journal(0)
UNTIL  Jurn == Cli[0] or (UO.Weight >  400) or Jurn == Cli[1] or Jurn == Cli[2] or Jurn == Cli[3] or Jurn == Cli[4]  or uo.count(Kirka) == 0
If (UO.Weight > 400) or uo.count(Kirka) < 1 then
  UO.Print('Domoi !!!')
  go_to_home()  ;   домой
  wait(2000)
  GrRuda()   ; Скидываем руду
  GrAxe()   ; Берем топоры
  GetRegs()         ; берем реги, свитки и т.д.
  wait(500)
  UO.Print('Obratno rabotat!!!')
  go_to_Shahta()
  uo.say("Rubim!")     
  F=File(FileName)
  F.Open()
  Rubit()     ;      Запускаем  рубку метталла
End If
  UO.Print('Dalee !!!')
Goto Beg
End Sub


;-------------------------------------------------------------------------------------------------
Sub GetNumb(C,I)     ; Процедура разборки тайлов по пробелам
var J,T,K
J=0
K=1
While K>0
  J=J+1
  If (Mid(C,J,1)==' ') Or (J>=Len(C)-1) Then
   If I==0 Then
    T=Val(Left(C,J))
   Else
    T=GetNumb(Right(C,Len(C)-J-1),I-1)
   EndIf
   K=0
  EndIf
wend
UO.Print(T)
return T
endsub
;---------------------------------------------
Sub GrRuda()             ; Процедура скидывания руды в указаный в начале ящик
repeat
;  uo.say("BANK")
  wait(1500)
  uo.findtype(Ruda) #Ruda
  uo.moveitem('finditem','0',Box) 
  wait(1000)
until not uo.count(Ruda)
end sub
;---------------------------------------------
sub GrAxe()                   ; Процедура взятия кирок из ящика
uo.deletejournal()
uo.useobject('Box')
wait(3000)
if uo.count(Kirka) < 2 then
     uo.sayU("Berem kirki")
      uo.findtype(Kirka,'-1','Box')
      wait(100)
      UO.grab('1','finditem')
      Wait(600)
      uo.findtype(Kirka,'-1','Box')
      wait(100)
      UO.grab('1','finditem')
      Wait(600)
end if
end sub

sub Control()
    var Notoriety,IsNPC, Jurn
    var v = val(uo.getglobal('tek_run'))
    var i
     while not uo.dead()
     Jurn=UO.Journal(0)
      if uo.Life < 120 then
      UO.Exec('terminate Main')
      UO.Exec('terminate main')
      UO.Set('finddistance',10)           
      repeat
         UO.FindType('0x0e43', '-1', '1')      ; Ищем сундуки
         wait(100)
         If UO.FindCount() < 1 Then      ; если не находим то значит не смотались       
         uo.waittargetobject("runebookid")
         wait(100)
         UO.Usetype("0x1f4c")
         wait(100)
         go_danger()        ;   Убегаем от опасности
         else
            danger = 1                    ; Ставим признак что опасность миновала
         end if
         wait(500)
      until danger > 0
       uo.sayU('Warning, atacking')
      while uo.Life < 120
          uo.bandageself()
          wait(5000)
       wend
       danger = 0
       GetRegs()            ; добираем бинтов, регов и скролов
       GrRuda()         ; скинем руду
       wait(500)
        uo.exec('exec main')               ; продожаем рубить
       end if
wait(200)
       wend
end sub

sub Metka_kochek()   #         
repeat
uo.infotile()
wait(3000)
until false
end sub

sub go_to_home()
   Var Tl,T,X,Y,Z, eo = 0
   FileName = 'c:\_A\_Macr\dob\Mining_d\go_house.txt'                       
   F=File(FileName)
   F.Open()
   repeat    
   Tl=safecall F.Readln()
   Tl=Trim(Tl)
   If Tl=='File read error' Then
      eo = 1
   else
        T=GetNumb(Tl,0)
      X=GetNumb(Tl,1)
      Y=GetNumb(Tl,2)
      Z=GetNumb(Tl,3)
      UO.Print('GoTo  ' + str(sc) + ' X= '+ str(X) + ' Y= '+str(Y))
      sc = sc+1
       gotoxy(X,Y,0)
       eo = 0
      end if
    until eo == 1
   
   
end sub


sub go_to_Shahta()
   Var Tl,T,X,Y,Z, eo = 0
   FileName = 'c:\_A\_Macr\dob\Mining_d\go_min.txt'                       
   F=File(FileName)
   F.Open()
   repeat    
   Tl=safecall F.Readln()
   Tl=Trim(Tl)
   If Tl=='File read error' Then
      eo = 1
   else
        T=GetNumb(Tl,0)
      X=GetNumb(Tl,1)
      Y=GetNumb(Tl,2)
      Z=GetNumb(Tl,3)
      UO.Print('GoTo  ' + str(sc) + ' X= '+ str(X) + ' Y= '+str(Y))
      sc = sc+1
       gotoxy(X,Y,0)
       eo = 0
      end if
    until eo == 1
   
end sub

sub go_danger()
end sub



sub Setup()
   uo.Exec('addobject Box')
   while uo.Targeting()
   wait(100)
   wend
   uo.Exec('addobject bagpak')
   while uo.Targeting()
   wait(100)
   wend
end sub

sub close()
var f
f.close()
end sub




;********************************************     Ходилка (не моя)*********************************************
Sub GetNumb(C,I)
var J,T,K
J=0
K=1
While K>0
  J=J+1
  If (Mid(C,J,1)==' ') Or (J>=Len(C)-1) Then
   If I==0 Then
    T=Val(Left(C,J))
   Else
    T=GetNumb(Right(C,Len(C)-J-1),I-1)
   EndIf
   K=0
  EndIf
wend
UO.Print(T)
return T
endsub

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(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
end if
if ld==dx then
ldc=ldc+1
if ldc>100 then
  uo.print("Can not reach location!")
  Stoplocation = 1   
  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




Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited