Injection 2014 !

General Injection issues

Moderators: Murderator+, Murderator

Juicy Fruit
Posts: 820
Joined: 2011-06-11 19:54:23

Re: Injection 2014 !

Post by Juicy Fruit »

1403.16

Список изменений:
    - Добавлен параметр StartTime в функцию uo.WaitingForJournalText(StartTime,MaxDelay,Text,[Equals],[IgnoreCase],[SkillName/ObjectID])
    - Добавлены функции uo.GetFoundedText() и uo.GetFoundedTextID()
    uo.GetFoundedText() - служит для получения текстовой строки, в которой был найден искомый текст от всех поисковых функций журнала
    uo.GetFoundedTextID() - индекс искомого текста
    - Добавлена опция запуска инжекта /lowcpu или /lowcpu:<value> для включения снижения нагрузки на процессор. Не желательно ставить больше пяти /lowcpu:5
    - Исправлена дистанция поиска в uo.Findtype и uo.FindList
    - Поиск с использованием uo.FindList теперь производится по-порядку, как добавляли в лист типы
    - Поисковые функции при поиске объектов на земле теперь всегда возвращают самый ближайший к игроку объект (если такой был найден и исключая Nearest=1)
    - На вкладку скриптов добавлен чекбокс "Go to last line on load/show script", в включенном состоянии при открытии редактора скриптов каретка устанавливается на ту строку, где она была при закрытии редактора в последний раз
    - Исправлено несколько незначительных багов в Script.dll
    - Исправлен краш при вводе трех кавычек подряд в редакторе скриптов
    - Добавлены операторы continue; break; switch->case->end switch о них ниже
    - Исправлен (скорее всего) краш при удалении/обновлении предметов
    - В Script.dll добавлены функции:
    Pos(Source,SearchText) - поиск текста SearchText в строке Source, при удачном поиске возвращает позицию в строке, при неудаче 0
    GetWord(Source,WordIndex,[Separator]) - получение слова из строки Source под номером WordIndex разделенного пробелом (или Separator'ом, если он указан)
    GetWordCount(Source,[Separator]) - получение общего кол-ва слов, содержащихся в строке Source разделенных пробелом (или Separator'ом, если он указан)
    - Добавлена функция ReceiveObjectName(Serial,[MaxDelay]) для получения имени объекта. MaxDelay - время в мс за которое должно прийти имя от сервера (старндартно 1000). Актуально использовать взамен CheckLag()
    - Теперь опции препарсера досвечиваются синим цветом. Начал подсвечиваться endsub (слитный)

Оператор switch->case->end switch работает так же, как описано по ссылке, только без default: и не много другое объявление.

Code: Select all

switch <Condition> / switch:<Condition>
case <Condition> /case:<Condition>
end switch / endswitch
Объявление любым из вышеперечисленных способов.
Пример использования:

Code: Select all

Sub GetCodeByGraphic(Graphic)
   switch:Graphic
      case:'0x0190'
      case:'0x0191'
         uo.print('this is human!')
         return 1
      case:'0x2006'
         uo.print('this is corpse!')
         return 2
      case:'0x0414'
      case:'0x0146'
      case:'0x0394'
      case:'0x0681'
         uo.print('what is it?!?!?')
         return 3
   end switch
   return 0
end sub
Этот скрипт будет аналогичен следующему (собственно в него и конвертируется):

Code: Select all

Sub GetCodeByGraphic(Graphic)
   if Graphic=='0x0190' or Graphic=='0x0191' then
      uo.print('this is human!')
      return 1
   else
      if Graphic=='0x2006' then
         uo.print('this is corpse!')
         return 2
      else
         if Graphic=='0x0414' or Graphic=='0x0146' or Graphic=='0x0394' or Graphic=='0x0681' then
            uo.print('what is it?!?!?')
            return 3
         endif
      endif
   endif
   return 0
end sub


Оператор break - немедленно выходит из цикла (или из блока switch), в котором объявлен с сохранением всех переменных (существенно для цикла for)
Оператор continue - прерывает выполнение текущей итерации цикла и переходит на следующую (если это предусмотрено в рамках цикла)

Пример (по сути бесполезен, но если запустить будет видно где срабатывают continue и break):

Code: Select all

sub test_new_operators()
   var i,test1=5,test2=7,test3=23,test_bool=1,test4=1
   if test_bool then
      for i=test4 to test3
         switch i
            uo.print('switch i')
            case test1
               uo.print('case test1')
               while i>=test2-2 && i<=test3-3
                  i=i+1
                  if i==test3-6 then
                     uo.print('continue from while')
                     continue
                  endif
                  uo.print('i='+str(i))
                  wait(100)
                  if i==test3-5 then
                     i=test4+test2
                     uo.print('break from while')
                     break
                  endif
               wend
               uo.print('end of while')
            case test4+test2+1
               uo.print('test4+test2+1')
               repeat
                  i=i+1
                  if i==test4+10 then
                     uo.print('continue from until')
                     continue
                  endif
                  uo.print('i='+str(i))
                  wait(100)
                  if i==test4+14 then
                     uo.print('break from until')
                     break
                  endif
               until i>=test3-6
               uo.print('end of until')
         end switch
         if i==test3-4 then
            i=13
            break
         endif
      next
      uo.print('end of for with i='+str(i))
   endif
end sub

Вот во что превратится такой скрипт:

Code: Select all

sub test_new_operators()
   var BreakPointerVariable_2=0,BreakPointerVariable_3=0,BreakPointerVariable_0=0
   var i,test1=5,test2=7,test3=23,test_bool=1,test4=1
   if test_bool then
      for i=test4 to test3
         uo.print('switch i')
         if i==test1 then
            uo.print('case test1')
            BreakPointerVariable_2=0
            while BreakPointerVariable_2==0 and (i>=test2-2 && i<=test3-3)
               i=i+1
               if i==test3-6 then
                  uo.print('continue from while')
                  goto loc_continue_2
               endif
               uo.print('i='+str(i))
               wait(100)
               if i==test3-5 then
                  i=test4+test2
                  uo.print('break from while')
                  BreakPointerVariable_2=1
                  goto loc_continue_2
               endif
               loc_continue_2:
            wend
            uo.print('end of while')
         else
            if i==test4+test2+1 then
               uo.print('test4+test2+1')
               repeat
                  BreakPointerVariable_3=0
                  i=i+1
                  if i==test4+10 then
                     uo.print('continue from until')
                     goto loc_continue_3
                  endif
                  uo.print('i='+str(i))
                  wait(100)
                  if i==test4+14 then
                     uo.print('break from until')
                     BreakPointerVariable_3=1
                     goto loc_continue_3
                  endif
                  loc_continue_3:
               until BreakPointerVariable_3==1 or (i>=test3-6)
               uo.print('end of until')
            endif
         endif
         if i==test3-4 then
            i=13
            BreakPointerVariable_0=i
            i=test3
            goto loc_continue_0
         endif
         BreakPointerVariable_0=i
         loc_continue_0:
      next
      i=BreakPointerVariable_0
      uo.print('end of for with i='+str(i))
   endif
end sub
Mirage
Posts: 2802
Joined: 2009-05-28 09:58:28
Location: Иваново
Contact:

Re: Injection 2014 !

Post by Mirage »

когда на старой версии делал сортировку металлических предметов такая конструкция

if Graphic=='0x0414' or Graphic=='0x0146' or Graphic=='0x0394' or Graphic=='0x0681' then
типов в 20-30 не работала.

в case: сколько можно загнать строк?
Juicy Fruit
Posts: 820
Joined: 2011-06-11 19:54:23

Re: Injection 2014 !

Post by Juicy Fruit »

Mirage wrote:когда на старой версии делал сортировку металлических предметов такая конструкция

if Graphic=='0x0414' or Graphic=='0x0146' or Graphic=='0x0394' or Graphic=='0x0681' then
типов в 20-30 не работала.

в case: сколько можно загнать строк?

Если что-то не будет работать - фрагмент скрипта в личку, разберусь)

Всмысле сколько загнать строк?
Условие вычисляется таким образом:

Code: Select all

switch SwitchCondition
case Case1Condition
case Case2Condition
case Case3Condition
end switch

SwitchCondition сохраняется в буффере при обработке скрипта (до его выполнения), попадая на case, если SwitchCondition сохранено то создается условие:
if SwitchCondition==Case1Condition then
Если case следуют один за другим (как в варианте выше) то условие конструируется такое:
if SwitchCondition==Case1Condition or SwitchCondition==Case2Condition or SwitchCondition==Case3Condition then
Но если между case есть пустые строки или какой-либо текст, то будут сконструированы несколько условий.
Кол-во строк с case неограничено, но если общая длина получившейся строки будет превышать 1024 символа (вроде бы столько) то скрипт может выдать ошибку.
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Code: Select all

Sub searchTree()
   var i, x, y, t, stp, max_search = 50 ; ìàêñèìàëüíàÿ äèñòàíöèÿ äëÿ ãåíåðàöèè êîîðäèíàò.
   var cx = uo.getX()
   var cy = uo.getY()
   for i = 1 to max_search
      for x =-i to i
         stp = 1
         if not i == abs( x ) then
            stp = abs( i ) * 2
         endif
         for y = -i to i step stp
            if NOT uo.getGlobal( 't:' + str( x + cx ) + "," + str( y + cy ) ) == "empty" then
               t = IsTreeTile( x + cx, y + cy )
               if not t == false then
                  uo.setGlobal( "tree_x", str( x + cx ) )
                  uo.setGlobal( "tree_y", str( y + cy ) )
                  uo.setGlobal( "tree_t", str( t ) )
                  return false
               else
                  uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
         next
      next
   next
   uo.print( "Found no tree, exit." )
   uo.exec( "terminate autoLumber" )
   return false
endsub


В новой версии parser вылетает.
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

Ты хоть бы строку указал на какой парсер. Этот кусочек скрипта ничего не даст.
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Incorrect User wrote:Ты хоть бы строку указал на какой парсер. Этот кусочек скрипта ничего не даст.


да если бы я знал просто вылетает "Unhandled exception in parser"
когда именно эту часть запускаю

Code: Select all

#Lumbjacking с автопоиском деревий (c) Destruction, v1.0
var hatchet = "0x0F39"
Sub searchTree()
   var i, x, y, t, stp, max_search = 50 ; максимальная дистанция для генерации координат.
   var cx = uo.getX()
   var cy = uo.getY()
   for i = 1 to max_search
      for x =-i to i
         stp = 1
         if not i == abs( x ) then
            stp = abs( i ) * 2
         endif
         for y = -i to i step stp
            if NOT uo.getGlobal( 't:' + str( x + cx ) + "," + str( y + cy ) ) == "empty" then
               t = IsTreeTile( x + cx, y + cy )
               if not t == false then
                  uo.setGlobal( "tree_x", str( x + cx ) )
                  uo.setGlobal( "tree_y", str( y + cy ) )
                  uo.setGlobal( "tree_t", str( t ) )
                  return false
               else
                  uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
         next
      next
   next
   uo.print( "Found no tree, exit." )
   uo.exec( "terminate autoLumber" )
   return false
endsub

sub autoLumber()
   repeat
      searchTree()
      doMineTree()
   until UO.Dead()
endsub

Sub doMineTree()
   var x, y, t
   var end = "осталось|рубить|nothing here|reach this"
   var try = "You put|fail"
   repeat
      x = val( uo.getGlobal( "tree_x" ) )
      wait(250)
      y = val( uo.getGlobal( "tree_y" ) )
      wait(250)
      t = val( uo.getGlobal( "tree_t" ) )
      wait(250)
      uo.setGlobal( 't:' + str( x ) + "," + str( y ), "empty" )
      wait(250)
      Walker( x, y, 1 )
      wait(250)
      uo.exec( "exec searchTree" )
      wait(250)
      repeat
         if uo.waiting() then
            wait(250)   
            uo.canceltarget()
            wait(250)
         endif
         deljournal( try + "|" + end )
         wait(250)
         uo.waittargettile( str( t ), str( x ), str( y ), str( uo.getZ() ) )
         wait(250)
         uo.usetype( hatchet )
         wait(250)
         repeat
            wait(250)
         until uo.injournal( try + "|" + end )
         wait(250)
      until uo.injournal( end )
      wait(250)
      while uo.getGlobal( "tree_x" ) == str( x ) && uo.getGlobal( "tree_y" ) == str( y )
         wait(250)
      wend
   until false
endsub

Sub deljournal( msg )
   while uo.injournal( msg )
      uo.setjournalline( uo.injournal( msg ) -1, '' )
   wend
endsub

Sub IsTreeTile( x, y )
   var i, tree_count = 20
   DIM tree[ val( str( tree_count ) ) ]
   tree[0] = 6000
   tree[1] = 6001
   tree[2] = 6002
   tree[3] = 6003
   tree[4] = 6004
   tree[5] = 6005
   tree[6] = 6006
   tree[7] = 6007
   tree[8] = 6008
   tree[9] = 6009
   tree[10] = 6010
   tree[11] = 6011
   tree[12] = 6012
   tree[13] = 6013
   tree[14] = 6014
   tree[15] = 6015
   tree[16] = 6016
   tree[17] = 6017
   tree[18] = 6018
   tree[19] = 6019
   for i = 0 to tree_count -1
      if uo.privategettile( x, y, -1, tree[i], tree[i] ) then
         return tree[i]
      endif
   next
   return false
endsub


вот весь скрипт, он ещё иногда ругаеться на вот эту строку

Code: Select all

uo.usetype( hatchet )


Я сделал

Code: Select all

uo.usetype( 'hatchet' )

не помогло(
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

Задержки в циклы добавь и всё.
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

uo.usetype( 'hatchet' ) так не надо делать, а ругается потому что это глюки самого инжекта, лучше пиши uo.usetype("0x0F39") и ругаться не будет.
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Incorrect User wrote:uo.usetype( 'hatchet' ) так не надо делать, а ругается потому что это глюки самого инжекта, лучше пиши uo.usetype("0x0F39") и ругаться не будет.

ясн, а где именно задержки ставить?
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

Скрипт запускается через autoLumber() если что. А парсер возможно не из за задержек, попробуй замени

Code: Select all

uo.privategettile( x, y, -1, tree[i], tree[i] )
на

Code: Select all

uo.privategettile( x, y, 1, tree[i], tree[i] )
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Incorrect User wrote:Скрипт запускается через autoLumber() если что. А парсер возможно не из за задержек, попробуй замени

Code: Select all

uo.privategettile( x, y, -1, tree[i], tree[i] )
на

Code: Select all

uo.privategettile( x, y, 1, tree[i], tree[i] )

не помогло(
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

Code: Select all

   for i = 0 to tree_count -1
      if uo.privategettile( x, y, -1, tree[i], tree[i] ) then
         return tree[i]
      endif
   next

Перед next поставь wait(100)
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Incorrect User wrote:

Code: Select all

   for i = 0 to tree_count -1
      if uo.privategettile( x, y, -1, tree[i], tree[i] ) then
         return tree[i]
      endif
   next

Перед next поставь wait(100)


тоже не помогло(
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

Кстати скрипт то нужно переписать с нуля, уже есть больше возможностей. Еще это

Code: Select all

                  uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
         next
      next
   next

замени на

Code: Select all

                 uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
           wait(100)
         next
      next
   next
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

И замени

Code: Select all

               t = IsTreeTile( x + cx, y + cy )
               if not t == false then

на

Code: Select all

t = uo.IsTreeTile( x + cx, y + cy )
               if not t == "" then
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Incorrect User wrote:Кстати скрипт то нужно переписать с нуля, уже есть больше возможностей. Еще это

Code: Select all

                  uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
         next
      next
   next

замени на

Code: Select all

                 uo.setGlobal( 't:' + str( x + cx ) + "," + str( y + cy ), 'empty' )
               endif
            endif
           wait(100)
         next
      next
   next


ну вообщем тоже не помогло это(((

я бы с радостью написал бы с нуля, но я только учусь и для меня познание языков это целая вечность..
Incorrect User
Posts: 949
Joined: 2011-05-23 00:33:30

Re: Injection 2014 !

Post by Incorrect User »

Нашли, проблема не в скрипте, можешь оставить изначальный вариант. Пока откатись на предыдущую версию инжекта.
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

Incorrect User wrote:Нашли, проблема не в скрипте, можешь оставить изначальный вариант. Пока откатись на предыдущую версию инжекта.


хорошо жду обновлений тогда пока..
Juicy Fruit
Posts: 820
Joined: 2011-06-11 19:54:23

Re: Injection 2014 !

Post by Juicy Fruit »

Перезалил ссылку.
Проблемма была в определении карты, пока что поставил загрузку только из map0.mul (и прочих подобных мулов)
К сл. релизу разберусь.
tyca7
Posts: 125
Joined: 2012-12-22 19:14:29
Contact:

Re: Injection 2014 !

Post by tyca7 »

кстати будет поддерживать новый клиент 7.0.34.15?
Post Reply