Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

конвертация скрипта

флуд, оффтопик и т.д.
Post Reply
Evgeniy.Hitrin
Posts: 3
Joined: 27.06.2011 19:32
Contact:

конвертация скрипта

Post by Evgeniy.Hitrin »

мастера и гуру стелса;) прошу помощи в конвертации скрипта с инжекта на стелс

если можно с объяснениями и примерами что бы в дальнейшем я мог это проделать сам...

Code: Select all

var distance='8' # дистанция поиска
var corpser=1
var tweapon=uo.getserial(uo.objatlayer('Rhand')) #щит
var tshield=uo.getserial(uo.objatlayer('Lhand')) #меч
var mx,my
mX=uo.getX("self");
mY=uo.getY("self");

sub main()
var n, m, mob

   Dim npc[10]
   npc[0]=2 # сколлько раз
   npc[1]='0x002F' #   reaper
   npc[2]='0x0018' #   лич 0x0018
   
DIM Loot[100] 
  Loot[0]=72      ; 
  Loot[1]='0x0EED'  ; gp 
  Loot[2]='0x0F7B'  ; BM 
  Loot[3]='0x0F7A'  ; BP 
  Loot[4]='0x0F84'  ; GA 
  Loot[5]='0x0F85'  ; GI 
  Loot[6]='0x0F86'  ; MR 
  Loot[7]='0x0F88'  ; NS 
  Loot[8]='0x0F8C'  ; SA 
  Loot[9]='0x0F8D'  ; SS 
  
  Loot[10]='0x0F7E' ; bones
  Loot[11]='0x1413' ;arm 
  Loot[12]='0x1415' ;arm 
  Loot[13]='0x1411' ;arm 
  Loot[14]='0x1410' ;arm 
  Loot[15]='0x1414' ;arm 
  Loot[16]='0x0E21' ; bandages 
  Loot[17]='0x0F78' ; batw 
  Loot[18]='0x0E34' ; blank scroll
  Loot[19]='0x0F25' ; amber
  
  Loot[20]='0x0F28' ; diamonds
  Loot[21]='0x0F2D' ; tourmalines
  Loot[22]='0x0F2C' ; citrine
  Loot[23]='0x0F0F' ; star sapphires
  Loot[24]='0x0F17' ; amethysts
  Loot[25]='0x0F23' ; citrines
  Loot[26]='0x0F2F' ; emeralds
  Loot[27]='0x0F22' ; amethyst
  Loot[28]='0x0F24' ; citrines
  Loot[29]='0x0F10' ; emeralds
  
  Loot[30]='0x0F27' ; diamond
  Loot[31]='0x0F14' ; ruby
  Loot[32]='0x0F11' ; sapphires
  Loot[33]='0x0F18' ; tourmalines
  Loot[34]='0x0F26' ; diamonds
  Loot[35]='0x0F2E' ; amethysts
  Loot[36]='0x0F1B' ; star sapphires
  Loot[37]='0x0F20' ; tourmalines
  Loot[38]='0x0F1A' ; rubies
  Loot[39]='0x0F1C' ; rubies
  
  Loot[40]='0x0F16' ; amethysts
  Loot[41]='0x0F1D' ; ruby
  Loot[42]='0x0F15' ; citrines
  Loot[43]='0x0F1F' ; sapphires
  Loot[44]='0x0F1E' ; tourmalines
  Loot[45]='0x0F12' ; sapphire
  Loot[46]='0x0F21' ; star sapphire
  Loot[47]='0x0F2A' ; ruby
  Loot[48]='0x0E76' ; сумкa
  Loot[49]='0x0F19' ; sapphire
  
  Loot[50]='0x0F2B' ; ruby
  Loot[51]='0x0DF2' ; wand 
  Loot[52]='0x0DF3' ; wand 
  Loot[53]='0x0DF4' ; wand 
  Loot[54]='0x0DF5' ; wand 
  Loot[55]='0x1F69' ; Summon Daemon
  Loot[56]='0x1F66' ; Energy Vortex
  Loot[57]='0x0F13' ; ruby
  Loot[58]='0x0F30' ; diamond
  Loot[59]='0x1F29' ; diamond
  
  Loot[60]='0x0F3F' ; arrows  
  Loot[61]='0x0F29' ; diamond
  Loot[62]='0x0F29' ; diamond
  Loot[63]='0x0F29' ; diamond
  Loot[64]='0x0F29' ; diamond
  Loot[65]='0x0F29' ; diamond
  Loot[66]='0x0F29' ; diamond
  Loot[67]='0x0F29' ; diamond
  Loot[68]='0x0F29' ; diamond
  Loot[69]='0x0F29' ; diamond
  Loot[70]='0x0F29' ; diamond
  Loot[71]='0x0F90' ; DEADWOOD
  Loot[72]='0x1BDD' ; Logs

   
   uo.set('finddistance',distance)
    While NOT UO.Dead()
   
         for n=1 to npc[0]
         uo.findtype(npc[n],-1,'ground')
		    if uo.findcount() then
            uo.useobject(tweapon)
            uo.useobject(tshield)
            wait(100)
            mob=uo.getserial('finditem')
	    kill(mob)
            uo.useobject('lastcorpse')
            checklag()
            wait(1000)
            for m=1 to loot[0]
        while uo.getquantity('<'+loot[m])
            uo.moveitem('<'+loot[m])
            wait(700)
		wend
            next
            while uo.life<uo.str-20 # and uo.count('0x0E21')
			#UO.Cast('Greater Heal', 'self')
	        #uo.usetype('0x0F0E','0x09BB')               #     питье хила<=====
			UO.BandageSelf()
			wait(1000) 
			uo.useobject(tweapon)
			uo.useobject(tshield)
			wait(2500)
	    wend
            if uo.count('0x0E20') then
               uo.waittargettype('0x1008')
               uo.usetype('0x0E20')
               wait(1000)
            endif
         walkn(mX,mY,"")		#ИДТИ В НАЧАЛЬНЫЕ КООРДИНАТЫ
	else
		hide()
	endif
	next
      wait(1000)
   wend
endsub

Sub kill(mob)
   var n
   checklag()
   for n=0 to 100
      uo.attack(mob)
      if uo.getdistance(mob)>1 then
         walkn(0,0,mob)
      endif
      if uo.injournal('Body of') then
         if corpser==1 then
            uo.waittargetobject('lastcorpse')
            wait(100)
            uo.usetype('0x0F51')
            wait(500)   
         endif
         return
      endif
      wait(1000)
   next
endsub


Sub WalkN(x,y,Target) ########################################## Ходилка
   VAR LastTimer
   LastTimer=UO.Timer()
   VAR i
   VAR dir,ldir,rdir,key,olddir
   VAR dx,dy,Exit=0
   VAR CacheLimit=9,CacheIndex="Text"
   DIM CacheX[10], CacheY[10]
   
   CacheX[0]="Test"
   uo.say('')   
   While Exit<>1   
      If Target<>"" Then
         dx=UO.GetX(Target)-UO.GetX()
         dy=UO.GetY(Target)-UO.GetY()         
         If UO.GetDistance(Target)<2 OR LastTimer+100<UO.Timer() Then
            wait(1000)
            return
         Endif
      Else
         dx=x-UO.GetX()
         dy=y-UO.GetY()
         If dx==0 AND dy==0 OR LastTimer+100<UO.Timer() Then
            return
         Endif
      Endif   
      If dx<>0 AND dy<>0 Then
         If dx>0 AND dy>0 Then ; GoSE
            dir=3
            ldir=2
            rdir=4
            key=40 ; DownArrow
            olddir=UO.GetDir()
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then
               If olddir==2 Then ; GoNE
                  dir=1
                  ldir=0
                  rdir=1
                  key=39 ; RightArrow
                  While UO.GetDir()<>1
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoSW
                  dir=5
                  ldir=5
                  rdir=6
                  key=37 ; LeftArrow
                  While UO.GetDir()<>5
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif
         If dx>0 AND dy<0 Then ; GoNE
            dir=1
            ldir=0
            rdir=2
            key=39 ; RightArrow
            olddir=UO.GetDir()
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then
               If olddir==0 Then ; GoWN
                  dir=7
                  ldir=6
                  rdir=7
                  key=38 ; UpArrow
                  While UO.GetDir()<>7
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoSE
                  dir=3
                  ldir=3
                  rdir=4
                  key=40 ; DownArrow
                  While UO.GetDir()<>3
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif
         If dx<0 AND dy>0 Then ; GoSW
            dir=5
            ldir=4
            rdir=6
            key=37 ; LeftArrow
            olddir=UO.GetDir()
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then
               If olddir==6 Then ; GoWN
                  dir=7
                  ldir=7
                  rdir=0
                  key=38 ; UpArrow
                  While UO.GetDir()<>7
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoSE
                  dir=3
                  ldir=2
                  rdir=3
                  key=40 ; DownArrow
                  While UO.GetDir()<>3
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif
         If dx<0 AND dy<0 Then ; GoWN
            dir=7
            ldir=6
            rdir=0
            key=38 ; UpArrow
            olddir=UO.GetDir()
            If StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key) Then
               If olddir==0 Then ; GoNE
                  dir=1
                  ldir=1
                  rdir=2
                  key=39 ; RightArrow
                  While UO.GetDir()<>1
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoSW
                  dir=5
                  ldir=4
                  rdir=5
                  key=37 ; LeftArrow
                  While UO.GetDir()<>5
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif
      Endif
      If dx<>0 AND dy==0 Then
         If dx>0 Then ; GoE
            dir=2
            key=34 ; PgDown
            olddir=UO.GetDir()
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then
               If olddir==2 Then ; GoSE
                  dir=3
                  ldir=3
                  rdir=4
                  key=40 ; DownArrow
                  While UO.GetDir()<>3
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoNE
                  dir=1
                  ldir=1
                  rdir=0
                  key=39 ; RightArrow
                  While UO.GetDir()<>1
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif       
         If dx<0 Then ; GoW
            dir=6
            key=36 ; Home key
            olddir=UO.GetDir()
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then
               If olddir==0 Then ; GoWN
                  dir=7
                  ldir=7
                  rdir=0
                  key=38 ; UpArrow
                  While UO.GetDir()<>7
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoSW
                  dir=5
                  ldir=4
                  rdir=5
                  key=37 ; LeftArrow
                  While UO.GetDir()<>5
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif
      Endif
      If dx==0 AND dy<>0 Then
         If dy>0 Then ; GoS
            dir=4
            key=35 ; End
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then
               If olddir==2 Then ; GoSE
                  dir=3
                  ldir=2
                  rdir=3
                  key=40 ; DownArrow
                  While UO.GetDir()<>3
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoSW
                  dir=5
                  ldir=6
                  rdir=5
                  key=37 ; LeftArrow
                  While UO.GetDir()<>5
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif     
         If dy<0 Then ;GoN
            dir=0
            key=33 ; PgUp
            olddir=UO.GetDir()
            If StepEdit(UO.GetX(),UO.GetY(),dir,key) Then
               If olddir==2 Then ; GoNE
                  dir=1
                  ldir=1
                  rdir=2
                  key=39 ; RightArrow
                  While UO.GetDir()<>1
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Else ; GoWN
                  dir=7
                  ldir=7
                  rdir=6
                  key=38 ; UpArrow
                  While UO.GetDir()<>7
                     StepArrow(UO.GetX(),UO.GetY(),dir,ldir,rdir,key)
                  Wend
               Endif
            Endif
         Endif
      Endif
   Wend
end sub
Sub StepEdit(x,y,dir,key)
   VAR walkwait=450
   VAR ErrLevel=0
   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()
      If x==UO.GetX() AND y==UO.GetY() Then
         ;zatik
         ErrLevel=1
      Endif
   Endif
   Return ErrLevel
end sub
Sub StepArrow(x,y,dir,ldir,rdir,key)
   VAR walkwait=450
   VAR ErrLevel=0
   If UO.GetDir()<>dir Then
      UO.Press(key)
      wait(walkwait)
      If UO.GetDir()<>dir AND UO.GetDir()<>ldir AND UO.GetDir()<>rdir Then
         CheckLag()
      Endif
   Endif
   If UO.GetX()==x AND UO.GetY()==y Then
      UO.Press(key)
      wait(walkwait)
      If UO.GetDir()==dir AND UO.GetX()==x AND UO.GetY()==y Then
         CheckLag()
         If UO.GetDir()==dir AND UO.GetX()==x AND UO.GetY()==y Then
            ;zatik         
            ErrLevel=1
         Endif
      Endif
   Endif
   Return ErrLevel
end sub
Sub checklag()
   repeat
      UO.DeleteJournal()
      UO.Click('backpack')
   until backpack()==1
endsub
Sub backpack()
   var n
   for n=0 to 200
      if uo.injournal('a backpack') then
         return 1
      endif
      wait(200)
   next
endsub 		

Sub hide()
    var failMessage = "You fail|You don't|You can't"
    var timeLeft = 0

    while not UO.Hidden()
		uo.exec("warmode 0")	
        UO.Useskill("Hiding") 

        DeleteJournal(failMessage) 
        timeLeft = 3000 
        while (not UO.Hidden()) AND (timeLeft > 0) AND (UO.InJournal(failMessage) == 0) 
            timeLeft = timeLeft - 100
            wait(100)
        wend
    wend
endsub

Sub DeleteJournal( string1 )
    VAR nom = UO.InJournal( string1 )
    If nom > 0 Then
        UO.SetJournalLine( Nom - 1, 'string replaced' )
        DeleteJournal( string1 )
    Endif
endsub
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: конвертация скрипта

Post by Vizit0r »

Sub WalkN(x,y,Target) ########################################## Ходилка
Sub StepEdit(x,y,dir,key)
Sub StepArrow(x,y,dir,ldir,rdir,key)
нафиг, в стелсе своя ходилка.

Sub checklag() + Sub backpack()
туда же, в стелсе есть встроенный чеклаг.

Sub DeleteJournal( string1 )
можно, но не нужно. варварский способ из инжекта не надо тащить в стелс :)


итого у нас осталось

Code: Select all

var distance='8' # дистанция поиска
var corpser=1
var tweapon=uo.getserial(uo.objatlayer('Rhand')) #щит
var tshield=uo.getserial(uo.objatlayer('Lhand')) #меч
var mx,my
mX=uo.getX("self");
mY=uo.getY("self");

sub main()
var n, m, mob

   Dim npc[10]
   npc[0]=2 # сколлько раз
   npc[1]='0x002F' #   reaper
   npc[2]='0x0018' #   лич 0x0018
   
DIM Loot[100] 
  Loot[0]=72      ; 
  Loot[1]='0x0EED'  ; gp 
  Loot[2]='0x0F7B'  ; BM 
  Loot[3]='0x0F7A'  ; BP 
  Loot[4]='0x0F84'  ; GA 
  Loot[5]='0x0F85'  ; GI 
  Loot[6]='0x0F86'  ; MR 
  Loot[7]='0x0F88'  ; NS 
  Loot[8]='0x0F8C'  ; SA 
  Loot[9]='0x0F8D'  ; SS 
  
  Loot[10]='0x0F7E' ; bones
  Loot[11]='0x1413' ;arm 
  Loot[12]='0x1415' ;arm 
  Loot[13]='0x1411' ;arm 
  Loot[14]='0x1410' ;arm 
  Loot[15]='0x1414' ;arm 
  Loot[16]='0x0E21' ; bandages 
  Loot[17]='0x0F78' ; batw 
  Loot[18]='0x0E34' ; blank scroll
  Loot[19]='0x0F25' ; amber
  
  Loot[20]='0x0F28' ; diamonds
  Loot[21]='0x0F2D' ; tourmalines
  Loot[22]='0x0F2C' ; citrine
  Loot[23]='0x0F0F' ; star sapphires
  Loot[24]='0x0F17' ; amethysts
  Loot[25]='0x0F23' ; citrines
  Loot[26]='0x0F2F' ; emeralds
  Loot[27]='0x0F22' ; amethyst
  Loot[28]='0x0F24' ; citrines
  Loot[29]='0x0F10' ; emeralds
  
  Loot[30]='0x0F27' ; diamond
  Loot[31]='0x0F14' ; ruby
  Loot[32]='0x0F11' ; sapphires
  Loot[33]='0x0F18' ; tourmalines
  Loot[34]='0x0F26' ; diamonds
  Loot[35]='0x0F2E' ; amethysts
  Loot[36]='0x0F1B' ; star sapphires
  Loot[37]='0x0F20' ; tourmalines
  Loot[38]='0x0F1A' ; rubies
  Loot[39]='0x0F1C' ; rubies
  
  Loot[40]='0x0F16' ; amethysts
  Loot[41]='0x0F1D' ; ruby
  Loot[42]='0x0F15' ; citrines
  Loot[43]='0x0F1F' ; sapphires
  Loot[44]='0x0F1E' ; tourmalines
  Loot[45]='0x0F12' ; sapphire
  Loot[46]='0x0F21' ; star sapphire
  Loot[47]='0x0F2A' ; ruby
  Loot[48]='0x0E76' ; сумкa
  Loot[49]='0x0F19' ; sapphire
  
  Loot[50]='0x0F2B' ; ruby
  Loot[51]='0x0DF2' ; wand 
  Loot[52]='0x0DF3' ; wand 
  Loot[53]='0x0DF4' ; wand 
  Loot[54]='0x0DF5' ; wand 
  Loot[55]='0x1F69' ; Summon Daemon
  Loot[56]='0x1F66' ; Energy Vortex
  Loot[57]='0x0F13' ; ruby
  Loot[58]='0x0F30' ; diamond
  Loot[59]='0x1F29' ; diamond
  
  Loot[60]='0x0F3F' ; arrows  
  Loot[61]='0x0F29' ; diamond
  Loot[62]='0x0F29' ; diamond
  Loot[63]='0x0F29' ; diamond
  Loot[64]='0x0F29' ; diamond
  Loot[65]='0x0F29' ; diamond
  Loot[66]='0x0F29' ; diamond
  Loot[67]='0x0F29' ; diamond
  Loot[68]='0x0F29' ; diamond
  Loot[69]='0x0F29' ; diamond
  Loot[70]='0x0F29' ; diamond
  Loot[71]='0x0F90' ; DEADWOOD
  Loot[72]='0x1BDD' ; Logs

   
   uo.set('finddistance',distance)
    While NOT UO.Dead()
   
         for n=1 to npc[0]
         uo.findtype(npc[n],-1,'ground')
          if uo.findcount() then
            uo.useobject(tweapon)
            uo.useobject(tshield)
            wait(100)
            mob=uo.getserial('finditem')
       kill(mob)
            uo.useobject('lastcorpse')
            checklag()
            wait(1000)
            for m=1 to loot[0]
        while uo.getquantity('<'+loot[m])
            uo.moveitem('<'+loot[m])
            wait(700)
      wend
            next
            while uo.life<uo.str-20 # and uo.count('0x0E21')
         #UO.Cast('Greater Heal', 'self')
           #uo.usetype('0x0F0E','0x09BB')               #     питье хила<=====
         UO.BandageSelf()
         wait(1000) 
         uo.useobject(tweapon)
         uo.useobject(tshield)
         wait(2500)
       wend
            if uo.count('0x0E20') then
               uo.waittargettype('0x1008')
               uo.usetype('0x0E20')
               wait(1000)
            endif
         walkn(mX,mY,"")      #ИДТИ В НАЧАЛЬНЫЕ КООРДИНАТЫ
   else
      hide()
   endif
   next
      wait(1000)
   wend
endsub

Sub kill(mob)
   var n
   checklag()
   for n=0 to 100
      uo.attack(mob)
      if uo.getdistance(mob)>1 then
         walkn(0,0,mob)
      endif
      if uo.injournal('Body of') then
         if corpser==1 then
            uo.waittargetobject('lastcorpse')
            wait(100)
            uo.usetype('0x0F51')
            wait(500)   
         endif
         return
      endif
      wait(1000)
   next
endsub

Sub hide()
    var failMessage = "You fail|You don't|You can't"
    var timeLeft = 0

    while not UO.Hidden()
      uo.exec("warmode 0")   
        UO.Useskill("Hiding") 

        DeleteJournal(failMessage) 
        timeLeft = 3000 
        while (not UO.Hidden()) AND (timeLeft > 0) AND (UO.InJournal(failMessage) == 0) 
            timeLeft = timeLeft - 100
            wait(100)
        wend
    wend
endsub
что гораздо интереснее и короче.

начинаем перенос....
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: конвертация скрипта

Post by Vizit0r »

скрипт без инклюдов - ведь тут нет ни проверки на сытость, ни на сейв, ни других функций из инклюдов.

Code: Select all

Program Loot;                      //стандартное начало скрипта
var tweapon,tshield,mob : Cardinal;   //обьявления переменных и их типа. 
    mx,my,n,m,i : Integer;
     : Boolean;
    distance : Byte;
    Loot : array of Word;  //зачем четко указывать максимальный размер массива, если можно сделать его динамическим?
    npc : array of Word;

const failMessage = 'You fail|You don''t|You can''t';  //а тут константа - ее значение не меняется
      corpser = True;         //и эту туда же

procedure kill(mob : Cardinal);
var n : Integer;
begin
//встроенный в стелс чеклаг, параметром идет таймаут в мс. 200 х 200 мс из инжектового скрипта как раз и дают 40 сек
  checklag(40000);   

  for n:= 0 to 100 do
    begin
      Attack(mob);
      if Getdistance(mob) > 1 then
      //Abs - модуль. цикл для вызова ходилки каждый раз до тех пор, пока не окажемся в радиусе 1 клетки от цели
        while  (Abs(GetX(Self) - GetX(mob)) > 1) or (Abs(GetY(Self) - GetY(mob)) > 1) do
//если в цикле только ОДНО действие (вызов функции, установка переменной и т.д.) - то begin end можно не ставить
//это действительно для условий тоже 

//собственно, идем.
          newMoveXY(mX,mY,True,1,True);
//тут никакой задержки, видимо предполагается что моб умирает моментально. хз.
      if InJournal('Body of') > 0 then
        begin
//смысл сей проверки мне неясен
          if corpser then
            begin
              Waittargetobject(findtype($2006,ground));
              wait(100);
              Usetype($0F51,$FFFF);
              wait(500);
            end;
//выход из процедуры. кстати, вызов из главной функции(тела скрипта) приводит к завершению скрипта.
           Exit;
        end;
      wait(1000);
    end; 
end;

procedure hide;
var c : Integer;
    stime : TDateTime;  
begin
  repeat
    SetWarMode(False);
    Useskill('Hiding');
//заводим таймер
    stime := Now; 
    repeat 
      c := InJournalBetweenTimes(failMessage, stime, Now); 
      wait(100); 
//крутимся дл тех пор, пока не пройдет 3 секунды, либо сообщение о фейле, либо спрятались
     until Hidden or (Now > stime + (0.05/1440)) or (c >= 0); 
  until Hidden;
end;

BEGIN    //а это тело скрипта, то что в инжекте обычно называлось sub main. только там оно необязательное, а 
//в стелсе этот блок обязателен.
  FindDistance := distance;
  tweapon := ObjAtLayer(RhandLayer);
  tshield := ObjAtLayer(LhandLayer);
  mx := GetX(Self);
  my := GetX(Self);
//если все элементы массива известны заранее, то их можно толпой сразу загнать в массив, 
//при этом если массив динамический(нет размера массива) - его размер увеличивается автоматически
  npc := [$002F,$0018];
  Loot := [$0EED,BM,BP,GA,GS,MR,NS,SA,SS,$0F7E];//остальные элементы из старого скрипта заполнишь сам

  While not Dead do
    begin             //берешь длину массива и идешь от нуля до нее.
      for n := 0 to GetArrayLength(npc) - 1 do
        if findtype(npc[n],ground) > 0 then 
          begin
	 mob := FindItem;
            UseObject(tweapon);
	 UseObject(tshield);
            wait(100);
            kill(mob);
            UseObject((findtype($2006,ground)));
            checklag(40000);
            for m := 0 to GetArrayLength(Loot) - 1 do
              begin
		findtype(loot[m],(findtype($2006,ground)));
                if FindCount > 0 then                  
	          for i := 1 to FindCount do
		    begin
		      MoveItem(FindItem,FindQuantity,backpack,0,0,0);
		      findtype(loot[m],(findtype($2006,ground)));
		    end;
	      end;
            while Life<Str-20 do // and count($0E21)  
	      begin
		//waittargetobject(Self);
		//Cast('Greater Heal');
                //Usetype($0F0E,$09BB);
		waittargetobject(Self);
                UseObject($0E21); 
		Wait(1000);
		UseObject(tweapon);
		UseObject(tshield);
		Wait(2500);
              end;
	    if Count($0E20) > 0 then
              begin
		Waittargettype($1008);
		usetype($0E20,$FFFF);
		Wait(1000);
	      end;
            newMoveXY(mX,mY,True,0,True);
          end
        else
          hide;
      Wait(1000);
    end;
end. основной блок заканчивается "end." и текст после него обрабатываться не будет 
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Evgeniy.Hitrin
Posts: 3
Joined: 27.06.2011 19:32
Contact:

Re: конвертация скрипта

Post by Evgeniy.Hitrin »

Code: Select all

//тут никакой задержки, видимо предполагается что моб умирает моментально. хз.
      if InJournal('Body of') > 0 then
        begin
//смысл сей проверки мне неясен
          if corpser then
            begin
              Waittargetobject(findtype($2006,ground));
              wait(100);
              Usetype($0F51,$FFFF);
              wait(500);
            end;
в этих моментах я ни че не понял (хотя если быть честным я ни где ни че не понял но читаю и стараюсь)

вобщем попробую объяснить что он делает

задержка при убийстве нет потому как этот цикл (kill) , а следовательно и ходилка, будет вызыватся пока моб не умрет

if uo.injournal('Body of') then проверка на то появился ли труп если нет то возвращается к убийству моба
corpser - это переменаая которая была задана в начале скрипта и в зависимости от того равана она 0 или 1 на труп будет использоватся дагер или нет
(если появился труп проверять резать его или нет, если 1 то использует дагер на последний труп)

Code: Select all

      if uo.injournal('Body of') then
         if corpser==1 then
            uo.waittargetobject('lastcorpse')
            wait(100)
            uo.usetype('0x0F51')
            wait(500)   
         endif
         return
      endif
непоймите неправильно, ни кого учить не пытаюсь, а пытаюсь объяснить работу скрипта в инже, что бы вы могли объяснить мне работу скрипта на стелсе.

за проделанную работу огромное спасибо

как то стараюсь переползти с инжи на стелс он мне кажется более удобным и "приятным" в обращении

Code: Select all

    mx,my,n,m,i : Integer;
     : Boolean;
    distance : Byte;
: Boolean я так понимаю какой-то переменной не хватает, но сам не нашел какой ) вроде бы все использованы
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: конвертация скрипта

Post by Vizit0r »

: Boolean;
удали, это раньше был corpser в переменных


что непонятно - спрашивай.

http://stealth.od.ua/wiki/doku.php должно помочь



ошибка - в процедуре kill вместо
newMoveXY(mX,mY,True,1,True);
должно быть
newMoveXY(GetX(mob),GetY(mob),True,1,True);
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Post Reply