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

Alchemy Gump Forgotten World

тут можно задать вопрос по скриптингу
Post Reply
randomnoob
Neophyte
Neophyte
Posts: 30
Joined: 10.04.2008 22:26

Alchemy Gump Forgotten World

Post by randomnoob »

Image

Code: Select all

#Gump1
Serial: D3064
GumpID: 003B
X: 0000
Y: 0000
Pages: 2
Gump Options:

Text Lines:
Miscellaneous
Shrink
Bless
Invisibility
Lava Bomb
Total Heal
Mana Refresh
Total Mana
Refresh
2
3
4
6
9
5
Trance
4
Antidotum
Stoneskin

GumpButtons: X   Y   Released_ID  Pressed_ID   Quit   Page_ID   Return_value   Page
0   GumpButton: 200  200  501  501  1  2  802  1
1   GumpButton: 285  243  2224  2224  1  0  21  1
2   GumpButton: 285  263  2224  2224  1  0  22  1
3   GumpButton: 285  283  2224  2224  1  0  23  1
4   GumpButton: 285  303  2224  2224  1  0  24  1
5   GumpButton: 285  323  2224  2224  1  0  25  1
6   GumpButton: 285  343  2224  2224  1  0  26  1
7   GumpButton: 285  363  2224  2224  1  0  27  1
8   GumpButton: 475  243  2224  2224  1  0  28  1
9   GumpButton: 475  263  2224  2224  1  0  29  1
10   GumpButton: 475  283  2224  2224  1  0  30  1

Code: Select all

Serial: D3064
GumpID: 003A
X: 0000
Y: 0000
Pages: 2
Gump Options:

Text Lines:
Strength
Heal
Nightsight
Poison
Lesser
Normal
Greater
1
2
3
9
5
7
15
Deadly
6

GumpButtons: X   Y   Released_ID  Pressed_ID   Quit   Page_ID   Return_value   Page
0   GumpButton: 200  200  501  501  1  1  801  1
1   GumpButton: 556  200  502  502  1  3  803  1
2   GumpButton: 290  243  2224  2224  1  0  11  1
3   GumpButton: 290  263  2224  2224  1  0  12  1
4   GumpButton: 290  333  2224  2224  1  0  13  1
5   GumpButton: 290  353  2224  2224  1  0  14  1
6   GumpButton: 290  373  2224  2224  1  0  15  1
7   GumpButton: 480  243  2224  2224  1  0  16  1
8   GumpButton: 480  313  2224  2224  1  0  17  1
9   GumpButton: 480  333  2224  2224  1  0  18  1
10   GumpButton: 480  353  2224  2224  1  0  19  1
11   GumpButton: 480  373  2224  2224  1  0  20  1

Code: Select all

Serial: D3064
GumpID: 0039
X: 0000
Y: 0000
Pages: 2
Gump Options:

Text Lines:
Agility
Cure
Explosion
Refresh
Lesser
Normal
Greater
1
2
3
5
6
10
Total

GumpButtons: X   Y   Released_ID  Pressed_ID   Quit   Page_ID   Return_value   Page
0   GumpButton: 556  200  502  502  1  2  802  1
1   GumpButton: 290  243  2224  2224  1  0  1  1
2   GumpButton: 290  263  2224  2224  1  0  2  1
3   GumpButton: 290  333  2224  2224  1  0  3  1
4   GumpButton: 290  353  2224  2224  1  0  4  1
5   GumpButton: 290  373  2224  2224  1  0  5  1
6   GumpButton: 480  243  2224  2224  1  0  6  1
7   GumpButton: 480  263  2224  2224  1  0  7  1
8   GumpButton: 480  333  2224  2224  1  0  8  1
9   GumpButton: 480  353  2224  2224  1  0  9  1
10   GumpButton: 480  373  2224  2224  1  0  10  1
хочу скрафтить рефрешки, конструкция

Code: Select all

WaitGump('802');
wait(500);
WaitGump('801');
wait(500);
WaitGump('6');
wait(500);
usetype($0E9B, $0000); // ступка
не работает. в чем ошибка?
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Post by Vizit0r »

в том, что вейтгампы не выстраиваются в очередь, а просто каждый последующий затирает предыдущий.
тогда уже юзобж ступки вперед, и молиться чтобы ни лага, ни сейва небыло и твоя статическая задержка отработала правильно.
неужели так сложно вместо задержки фиксированной в 1,5с - проверять на GumpID, если пришел нужный -то вейтгамп, потом проверяем GumpID на следующий нужный. и гарантия что не собьется, и куда быстрее.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
randomnoob
Neophyte
Neophyte
Posts: 30
Joined: 10.04.2008 22:26

Post by randomnoob »

Code: Select all

program test;
  var
    i:integer;
  begin
    usetype($0E9B, $0000);
    i:=GetGumpID(?);
    if i=003B then
      begin 
        WaitGump('802');
        i:=GetGumpID(?);
      end;
        if i=003A then
          begin
            WaitGump('801');
            i:=GetGumpID(?);
          end;
            if i=0039 then
              begin 
                WaitGump('6');
                i:=GetGumpID(?);
              end;
  end.
а откуда взять ГАМПИНДЕКС или то, что вместо "?" ?
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Post by Vizit0r »

так, направление правильное.
теперь с индексами гампов.
пришел гамп самый первый от сервера (положим, на него нет ловушки. остался висеть). его гампиндекс = 0.
пришел следующий, висит. гампиндекс = 1.
и т.д.

соответственно, для того чтобы иметь дело с самым последним гампом, вместо индекса пишешь GetGumpsCount-1
итого, код будет выглядеть примерно так:

Code: Select all

program test; 
  var 
    i:integer; 
  begin 
    usetype($0E9B, $0000); 
    while GetGumpID(GetGumpsCount-1) <> $3B do
      wait(100);
    WaitGump('802'); 
    while GetGumpID(GetGumpsCount-1) <> $3A do
      wait(100);
    WaitGump('801'); 
    while GetGumpID(GetGumpsCount-1) <> $39 do
      wait(100);
    WaitGump('6'); 
  end; 
end.
еще подобавлять таймауты, проверки на коннлост и сейв, но это ты уже сам.

и незабывай ставить $ перед шестнадцатиричными числами.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
randomnoob
Neophyte
Neophyte
Posts: 30
Joined: 10.04.2008 22:26

Post by randomnoob »

спасибо за помощь!

получилось вот что:

Code: Select all

program test;
{$Include 'all.inc'}  
  var
    k:integer;
    TimeStart : TDateTime;   
    
begin
    {while IsGump = true do
      begin
        CloseSimpleGump(GetGumpsCount);
        wait(500);
      end;  }
    Checksave;
    usetype($0E9B, $0000);
    while GetGumpID(GetGumpsCount-1) <> $3B do
      wait(100);
    WaitGump('802');
    while GetGumpID(GetGumpsCount-1) <> $3A do
      wait(100);
    WaitGump('801');
    while GetGumpID(GetGumpsCount-1) <> $39 do
      wait(100);
    WaitGump('6');    
    k:=0;
    TimeStart:=Now;
      repeat
        wait(100);
        k := k + 1;
        CheckSave;
      until (InJournalBetweenTimes('pour the completed|loss the failed', TimeStart, Now)<>-1) or (k > 100);
    wait(100);      
end.
хотелось бы сделать проверку на наличие гампа перед началом(в "{}"), но, к сожалению "2 левых руки" :(
Alexej
Novice
Novice
Posts: 79
Joined: 06.06.2008 11:55
Contact:

Post by Alexej »

Code: Select all

If GetGumpsCount > 0 Then WaitGump('');
или

Code: Select all

If IsGump Then WaitGump('');
randomnoob
Neophyte
Neophyte
Posts: 30
Joined: 10.04.2008 22:26

Post by randomnoob »

Alexej, ты наверное не совсем правильно меня понял. я хотел реализовать аналог "cancelmenu;" в начале. но скрипт и так отлично работает.

всем спасибо
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Post by Vizit0r »

моё

Code: Select all

procedure CloseGumps;
var i,GumpsCount : Integer;
    tryClose : Boolean;
begin
i := 0;
while True do
  begin
    if i >= GetGumpsCount then Break;
    if tryClose and (GumpsCount = GetGumpsCount) then
      inc(i);
    GumpsCount := GetGumpsCount;
    tryClose := False;
    If IsGumpCanBeClosed(i) then
      begin
        CloseSimpleGump(i);
        tryClose := True;
      end
    else
      Inc(i);
    wait(20);          
  end;
end;
всем хорошо, кроме того, что в последней выложенной версии нет функции IsGumpCanBeClosed :)

можно еще попробовать модифицировать так:

Code: Select all

procedure CloseGumps;
var i,GumpsCount : Integer;
begin
i := 0;
while True do
  begin
    if i >= GetGumpsCount then Break;
    if GumpsCount = GetGumpsCount then
      inc(i);
    GumpsCount := GetGumpsCount;
    tryClose := False;
    If IsGumpCanBeClosed(i) then
      CloseSimpleGump(i)
    else
       NumGumpButton(0,i);//на гампе есть опция NoClose, пробуем закрыть через нулевую кнопку.
    wait(20);          
  end;
end;
но это надо протестить, а времени нет.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Post Reply