More about Engine.BypassToServer

Detailed tutorial on all the subtleties of the BypassToServer function

There are a lot of questions and they are usually all of the same types, so let's shed some light on the Adrenalin command Engine.BypassToServer

So, for a start, the most important question - why is it needed?
It is necessary to select answers in all kinds of dialogues
 (conversations with the NPC, Alt+B, answers to some captchas, etc.). The Engine.DlgSel function, which is simpler to use, where we submit a line number or text - is essentially just a wrapper over Engine.BypassToServer. But Engine.DlgSel is not limited to the functionality of Engine.BypassToServer !

The next question that arises - so why not always use Engine.DlgSel ?
On some free servers Engine.DlgSel may simply not work due to the measures taken by the administration. Also, Engine.BypassToServer is necessary in cases of using dialogues through Alt + B and others like it.

Well, finally - how to use Engine.BypassToServer ?
First, a little theory: In Lineage II dialogues are usually presented in the format of HTML documents. The text of the current open dialogue can be found using Engine.DlgText - it can be simply printed.  For ease of viewing, you can also use the ready-made Script Recorder plugin. Well, in Adrenalin itself there is a sniffer: (example for buff through Alt+B), but more on that below.

For example, a dialogue with GK in Goddard:

        Gatekeeper Tatiana:<br>
        Very nice. Tatiana, Gatekeeper of Goddard. The portal allows you to move long distances in moments. But in order to master the art of portal management, you need to spend in the Ivory Tower for decades. <br>
        Come on! Name the place you want to go!<br>
        <a action="bypass -h teleport_request">Teleport</a><br>
        <a action="bypass -h menu_select?ask=-303&reply=518">Exchange Dimension Diamonds</a><br>
        <a action="bypass -h menu_select?ask=-19&reply=0">Teleport [Noblesse Only]</a><br>
        <a action="bypass -h menu_select?ask=255&reply=10" msg="811;Monster Race Track">Move to Monster Race Track (Free)</a><br>
        <a action="bypass -h menu_select?ask=-1816&reply=3" msg="811;Fantasy Isle">Move to Fantasy Isle (Free)</a><br>
        <a action="bypass -h menu_select?ask=20003&reply=1">Summon Allegria</a><br>
        <a action="bypass -h talk_select">Quest</a>

Pay attention to the <a> tags inside which there is a word bypass, we’ll stop on the first line: 

<a action="bypass -h teleport_request">Teleport</a><br>

This dialog can be selected in three different ways:

Engine.DlgSel(1);                             // by line number
Engine.DlgSel('Телепортироваться');           // by text in line
Engine.BypassToServer('teleport_request');    // using bypass

With the first two, I hope everyone understands, consider what happens in the 3rd case?
<a action="bypass -h teleport_request"> - as you can see, when this line is selected, a bypass type action will occur, which conditionally speaking "carries the essence" of teleport_request.

Consider another case where the dialogue is presented in the form of buttons, we will have lines of the form:

<button action="bypass -h npc_268448112_Olympiad 1" value="Spectate" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Watch_Down" fore="L2UI_CT1.OlympiadWnd_DF_Watch">

Despite a slightly more complex structure, the essence is exactly the same: there is a button (previously there was a link), which is assigned action="bypass -h npc_268448112_Olympiad 1". The name of the string is now stored in the value property; in fact, this is the only difference. Looking ahead, I note that the action property is not always located to the left of the value property.

Thus, in order to use Engine.BypassToServer, you need to remember a couple of points:

  1. only messages with the word bypass are suitable for sending
  2. no need to copy -h 
  3. you need to copy everything after -h and up to the closing double quotation mark
  4. if there is a .htm at the end of the bypass, then the second parameter is true:
Engine.BypassToServer('Quest 621_EggDelivery 31521-1.htm', true);

As I said above, there is a sniffer in the bot itself, the video shows how to get straight-forward values of the arguments supplied to the function.

Thus, in order to maximize the use of this function, it will be useful to be able to parse the text returned in Engine.DlgText - this way it will be possible to get around problems with dynamically changing dialogs and some captcha.