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

Poisoning

тут можно задать вопрос по скриптингу
Post Reply
Antarius
Neophyte
Neophyte
Posts: 45
Joined: 24.06.2005 20:03

Poisoning

Post by Antarius »

Оптимизируйте и отладте, пожалуйста, скрипт. Скрипт написан мною, почему не пойзонет оружие не могу понять :(. Вот что в журнале пишется:

Code: Select all

System: You are stuffed
System: You fill a bottle with liquid from the keg.
System: You are out of bottles
System: Select a poison potion.
System: You must select a poison potion!
System: You are out of bottles
System: You must wait to perform another action.
System: You are out of bottles
System: You must wait to perform another action.
System: You are out of bottles
System: You must wait to perform another action.
System: You are out of bottles
System: Select a poison potion.
System: You must select a poison potion!
System: You are out of bottles
System: You must wait to perform another action.
System: You are out of bottles
System: You must wait to perform another action.
Сам скрипт:

Code: Select all

Program Poisoning;
var 
a : TDateTime;
t : Integer;
{$Include 'all.inc'}

procedure dropa;
begin
if (not dead) and (connected) then begin
FindType($1940,backpack);
if getquantity(finditem)> 0 then begin
MoveItem(finditem,0,$536E968D,0,0,0);
UnEquip(RHandLayer);
wait(2000);
end;
end;
end;

procedure poison;
var b : TDateTime;
begin
if (not dead) and (connected) then begin
if targetPresent then canceltarget;
FindType($0F0A,backpack);
if getquantity(finditem)> 0 then begin
WaitTargetObject(finditem);
UseSkill('Poisoning');
WaitJournalLine(b, 'You fail to apply|You have successfully|You fail and poison',30000);
WaitTargetObject($45E169AE);
wait (3000);
end;
end;
end;

procedure graba;
begin
if (not dead) and (connected) then begin
FindType($1940,backpack);
if getquantity(finditem)<= 0 then begin
useobject($536E9755); 
wait(2000);
FindType($1940,$536E9755);
if getquantity(finditem)> 0 then begin
Grab(finditem,0);
wait(1000);
end;
end;
end;
end;

Begin
SetARStatus(true);
Hungry(1,ground); 
 while not Dead do 
            begin
            waitconnection(3000);
  for t:=1 to 10 do begin
CheckSave;
graba;
FindType($1940,backpack);
UseObject(finditem);
WaitJournalLine(a, 'You fill a bottle|The keg is',30000);
if (InJournal('The keg is empty.') >= 0) then
begin
dropa;
end;
poison;
   CheckTargetError(2,2);
  end;
 CheckSave;
  hungry(1,ground);
 end;
End.
Alex
Moderator
Moderator
Posts: 351
Joined: 07.04.2005 4:41

Post by Alex »

Code: Select all

WaitTargetObject(finditem); 
UseSkill('Poisoning'); 
WaitJournalLine(b, 'You fail to apply|You have successfully|You fail and poison',30000); 
WaitTargetObject($45E169AE); 
скрипт кидает таргет на пойсон бутылку потом ждет сообющения, потом не дождавшись сообщения включает ловушку ожидания таргета на нож, на сколько я понял..
лучше сделать так

Code: Select all

checksave;
if targetpresent then canceltarget;
time :- now;
useskill('Poison');
waitfortarget(5000);
if targetpresent then
  begin
  targettoobject(PoisonPotion);
  waitfortarget(5000);
  if targetpresent then targettoobject(Dagger);
  waitjournalline(time,'apply|fail',30000);
  end;
и подбор, сброс кегов тоже у тебя очень глючные, из за них у скрипта будет очень много холостых ходов, главная их проблема - отсуцтвие контроля за перемещением вещи

так как у Миралекса еще не дошли руки сделать containerof()
проверять можно такой конструкцией

n := 1;
repeat {ждать пока в паке не найдеться кег, или пройдет 10000 сек}
wait(500);
n := n + 1;
until (findtype(keg,backpack) > 0)) or (n > 20)

еще можно привинтить таймер....ладно и его привенчу))
Antarius
Neophyte
Neophyte
Posts: 45
Joined: 24.06.2005 20:03

Post by Antarius »

Благодарю тебя Alex, спасибо тебе огромное! Отдельное спасибо за функции, я вообщем переписал скрипт полностью, вот протестирую 2-е суток, если всё без проблем, то выставлю в скрипты.
Antarius
Neophyte
Neophyte
Posts: 45
Joined: 24.06.2005 20:03

Post by Antarius »

Вот переписанный скрипт, но не могу опять, понять как только закачивается кег, скрипт замерает и чар просто втыкает, при этом старый кег он выкидывает и новый достает, что требуется выкл. и вкл заново скрипт.

Сам он:

Code: Select all

Program Poisoning;
var 
me,time : TDateTime;
e,o,b,t,n,m,q : Integer;

{$Include 'all.inc'}

Begin
SetARStatus(true);
Hungry(1,ground); 
 while not Dead do 
            begin
            waitconnection(3000);
for t:=1 to 100 do begin
if (not dead) and (connected) then begin
CheckSave;
FindType($1940,backpack);
if getquantity(finditem)<= 0 then begin
useobject($536E9755); 
      wait(3000);
      FindType($1940,$536E9755);
if getquantity(finditem)> 0 then begin
      Grab(finditem,0);
      q := 1;
      repeat {ждать пока в паке найдеться кег или пройдет 10000 сек}
      wait(500);
      q := q + 1;
      until (findtype($1940,backpack) <= 0) or (q > 20)
      end;
      end;
UseObject(finditem);
me := Now;
repeat 
   e := InJournalBetweenTimes('That keg is empty.', me, Now); 
   if (e >= 0) then
      begin
      wait(3000);
      me := Now;
      CheckSave;
      FindType($1940,backpack);
      if getquantity(finditem)> 0 then begin
      MoveItem(finditem,0,$536E968D,0,0,0);
      n := 1;
      repeat {ждать пока в паке не найдеться кег или пройдет 10000 сек}
      wait(500);
      n := n + 1;
      until (findtype($1940,backpack) > 0) or (n > 20)
      end;
      CheckSave;
      useobject($536E9755); 
      wait(3000);
      FindType($1940,$536E9755);
      if getquantity(finditem)> 0 then begin
      Grab(finditem,0);
      m := 1;
      repeat {ждать пока в паке найдеться кег или пройдет 10000 сек}
      wait(500);
      m := m + 1;
      until (findtype($1940,backpack) <= 0) or (m > 20)
      end;
      end;
   b := InJournalBetweenTimes('You fill a bottle with liquid from the keg.', me, Now); 
   o := InJournalBetweenTimes('You are out of bottles', me, Now); 
   wait(200); 
until (LineCount > 10) or (b >= 0) or (o >= 0);
{Часть с пойзоном}
checksave;
if targetpresent then canceltarget;
time := now;
useskill('Poisoning');
waitfortarget(5000);
if targetpresent then
  begin
  WaitTargetType($0F0A);
  waitfortarget(5000);
  if targetpresent then targettoobject($45E169AE);
  waitjournalline(time,'You fail to apply|You have successfully|You fail and poison',30000);
  wait(8000);
  end;
end;
end;
end;
End.
Alex
Moderator
Moderator
Posts: 351
Joined: 07.04.2005 4:41

Post by Alex »

Code: Select all

repeat
wait(500)
until false
такой цикл будет выполняться безконечное количество раз

ты просто перепутал логическое условие, в этом скрипте все на оборот : он выкладывает кег и ждет пока он появиться, он берет кег и ждет пока тот исчезнет :) от сюда задержки, я думаю

еще добавь порверку на наличие банки пойсона, перед ее использованием для отравления, и советую не использовать такие большие строки в ф-иях работы с журналом, лучше выбрать по одному характерному слову и все..

Code: Select all

if count(PoisonBottle) then
begin
{Poison}
end;
Post Reply