Script to repeat dialogs actions v.2

Heres the second version of repeating dialogs script. All you have to do is, to define the names of your bot in this line:

myChars: array of string = ['Velmsun', 'Walker', 'Tower'];

And then in your main block, define the npc name and after that, all the dialog selections (by index):

begin
  allDlgOpen('Bella'); // Targeting Bella
  allDlgSel(1); // Pressing "Teleport"
  allDlgSel(2); // Pressing "Heine"
end.

In other words, its like you are running this script in your whole bot list:

begin
  Engine.SetTarget('Bella');
  Engine.MoveToTarget;
  Engine.DlgSel(1);
  Engine.DlgSel(2);
end.

Script full code listing

uses
  Classes, SysUtils;
  
var
  myChars: array of string = ['Velmsun', 'Walker', 'Tower'];
  
procedure allDlgOpen(npcName:string);
var
  remoteControl: TL2Control;
  i: integer;
begin
  for i:=0 to High(myChars) do
  begin
    remoteControl := GetControl(myChars[i]);
    if Assigned(remoteControl) then
    begin
      remoteControl.SetTarget(npcName);
      remoteControl.MoveToTarget;
      delay(400);
      remoteControl.DlgOpen;
    end;
  end;
  Engine.DlgOpen;
end;

procedure allDlgSel(index: integer);
var
  remoteControl: TL2Control;
  i: integer;
begin
  for i:=0 to High(myChars) do
  begin
    remoteControl := GetControl(myChars[i]);
    if Assigned(remoteControl) then
    begin
      remoteControl.DlgSel(index);
    end;
  end;
  Engine.DlgSel(index);
end;

  
begin
  allDlgOpen('Bella');
  allDlgSel(1);
  allDlgSel(2);
end.

How it works?

Author: Velmsun