Yoko

All sides of Injection
It is currently 2025-12-17 21:35:08

All times are UTC+02:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: sparring
PostPosted: 2006-02-25 00:53:37 
Offline

Joined: 2006-02-03 06:53:36
Posts: 64
балшой скрипт на спариг :)
отходит
хилит себя/оппонента
меняет сломанные девайс/щиты
выключаеться если ктото помер, кончились бинты/щиты/девайсы
можно настроить при скольки % хп своего/оппонента отходить - переменные oppHpThreshold, selfHpThreshold

Code:
sub sparring()
   var oppHpThreshold = 50/100   #порог хп оппонента, при котором отходить
   var selfHpThreshold = 50/100  #порог своего хп, при котором отходить

   uo.AddObject('opponent')
   while uo.targeting()
      wait(100)
   wend
   
   
   var done = 0
   var oppHpLow = 0
   var selfHpLow = 0
   var selfX = uo.GetX()
   var selfY = uo.GetY()
   var oppX = uo.GetX('opponent')
   var oppY = uo.GetY('opponent')
   var dx = oppX - selfX
   var dy = oppY - selfY
   
   var Rhand = uo.GetGraphic(uo.ObjAtLayer('Rhand')) #тип объекта в правой руке (0x0000 если пусто)
   var Lhand = uo.GetGraphic(uo.ObjAtLayer('Lhand')) #тип объекта в левой руке (0x0000 если пусто)

   uo.WarMode(1)
   uo.Attack('opponent')

   repeat

      if (uo.GetHP('opponent') < uo.GetMaxHP('opponent') * oppHpThreshold) then
         oppHpLow = 1
      end if

      if (uo.Life < uo.str * selfHpThreshold) then
         selfHpLow = 1
      end if

      #если у кого-то мало хп, отходи и лечимся
      if (oppHpLow or selfHpLow) then
         Step(-dx, -dy)
         uo.WarMode(0)

         if (oppHpLow) then
            HealOpponent()
            oppHpLow = 0
         end if

         if (selfHpLow) then
            HealSelf()
            selfHpLow = 0
         end if
         
         Step(dx, dy)
         uo.WarMode(1)
         uo.Attack('opponent')
      end if
      
      wait(500)
      
      #иногда на сейвах слетает вар
      if (not uo.WarMode()) then
         uo.WarMode(1)
         uo.Attack('opponent')
      end if
      
      #если в правой руке не то, что было в самом начале,
      #и если в самом начале там что-то было, пытаемся взять тоже самое
      #если того-же самого нет, ставим флаг завершения
      
      if (uo.GetGraphic(uo.ObjAtLayer('Rhand')) <> Rhand and Rhand <> '0x0000') then
         uo.FindType(Rhand)
         if (uo.FindCount()) then
            uo.Equipt('Rhand', Rhand)
            uo.print('Equip Rhand device')
         else
            done = 1
            uo.print('no more Rhand devices')
         end if
      end if

      #аналогично правой руке
      if (uo.GetGraphic(uo.ObjAtLayer('Lhand')) <> Lhand and Lhand <> '0x0000') then
         uo.FindType(Lhand)
         if (uo.FindCount()) then
            uo.Equipt('Lhand', Lhand)
            uo.print('Equip Lhand device')
         else
            done = 1
            uo.print('no more Lhand devices')
         end if
      end if
      
      #проверка на дохлость
      if (uo.GetHP('opponent') == 0 or uo.Life == 0) then
         done = 1
         uo.print('somebody is dead')
      end if
      
      #если бинты кончились, заканчиваем
      if (uo.B == 0) then
         done = 1
         uo.print('no more bandages')
      end if
      
   until done
   
   Step(-dx, -dy)
   uo.WarMode(0)
   uo.print('Done traning')
   
end sub

#---------------------------------------------
#вспомогательные функции
sub HealOpponent()
   uo.print('heal opponent')
   repeat
      uo.waittargetobject('opponent')
      uo.usetype('0x0E21') #бинты
      wait(5000)
   until uo.getHP('opponent') == uo.getMaxHP('opponent')
   uo.print('opponent heal complete')
end sub

sub HealSelf()
   uo.print('heal self')
   repeat
      uo.bandageself()
      wait(5000)
   until uo.Life == uo.STR
   uo.print('self heal complete')
end sub

sub Step(dx, dy)
   var direction
   dim directions[9]
   directions[1] = 8
   directions[2] = 7
   directions[3] = 4
   directions[4] = 9
   directions[5] = 5
   directions[6] = 1
   directions[7] = 6
   directions[8] = 3
   directions[9] = 2
   var idx = (sign(dx) + 1) * 3 + (sign(dy) + 1) + 1
   
   uo.AddStep(directions[idx])
end sub

sub sign(n)
   if (n < 0) then
      n = -1
   end if
   
   if (n > 0) then
      n = 1
   end if
   
   return n
end sub


Top
   
 Post subject:
PostPosted: 2008-03-04 14:40:24 
Offline

Joined: 2005-08-25 23:35:29
Posts: 96
Что то он галимо отходит! как можно переделать отходилку ?


Top
   
 Post subject:
PostPosted: 2008-03-09 00:00:25 
Offline
Expert!
User avatar

Joined: 2006-02-07 08:51:40
Posts: 1348
Location: г. Старый Оскол
Shadowdancer wrote:
Что то он галимо отходит! как можно переделать отходилку ?


Риторический вопрос... Вставь другую.


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

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 6 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:  
Powered by phpBB® Forum Software © phpBB Limited