В одном сундуке Iron инги,Tinker инструменты, a Pig(еда). В другой будем складывать каждые 50 полученных итемов.
Сундуки должны быть в досягаемости для персонажа.
Code: Select all
Program Tinker_Necklace;
const
Sunduk_With_Iron_and_Tools=$404C3CCF;
Sunduk_With_Clock=$404CAA07;
Tools=$1EBC;
Ingot=$1BEF;
Pig=$09BB;
Clock=$104F;
var
k : integer;
TimeStart : TDateTime;
procedure Check_World_Save;
 begin
  if InJournal('saving')<>-1 then
   begin 
    ClearJournal;
    k:=0;
    repeat
      wait(10000)
      k:=k+1;
      AddToSystemJournal('World is saving more than '+IntToStr(k*10)+' seconds.');
    until (InJournal('data')<>-1) or (k>10)
   end
 end;
procedure Check_Connect;
 begin
  if not Connected then 
    while not Connected do 
      begin
        Connect;
        wait(1000);
      end 
 end;
procedure Check_Iron;
 begin
  FindType(Ingot,Backpack);
  if (FindCount=0) OR (Count(Ingot)<50) then
    begin
      UseObject(Sunduk_With_Iron_and_Tools);
      wait(250);
      FindType(Ingot,Sunduk_With_Iron_and_Tools);
      if (FindCount>0) and (CountEx(Ingot,$0000,Sunduk_With_Iron_and_Tools)>200) then
        begin
          MoveItem(FindItem,200,Backpack,0,0,0);
          wait(250);
          AddToSystemJournal('Добрали 200 iron ingots. На данный момент имеем '+IntToStr(Count(Ingot))+' штук. Осталось ещё '+IntToStr(CountEx(Ingot,$0000,Sunduk_With_Iron_and_Tools))+' iron ingots.');
        end
      else
        AddToSystemJournal('Ошибка во время добора Iron Ignots.');
    end
 end;
       
 
procedure Check_Tools;
 begin
  FindType(Tools,Backpack);
  if FindCount=0 then 
    begin
      UseObject(Sunduk_With_Iron_and_Tools);
      wait(250);
      FindType(Tools,Sunduk_With_Iron_and_Tools);    
      if FindCount>0 then
        begin
          MoveItem(FindItem,1,Backpack,0,0,0);
          wait(250);
          AddToSystemJournal('Добрали Tinker tools из сундука.');
        end
      else
        AddToSystemJournal('Ошибка во время добора Tinker tools.');
    end
 end;
procedure Check_Food;
 begin
  UseObject(Sunduk_With_Iron_and_Tools)
  wait(250);
  FindType(Pig,Sunduk_With_Iron_and_Tools);
  if FindCount>0 then
    begin
      MoveItem(FindItem,1,Backpack,0,0,0);
      wait(250);
      UseObject(FindItem);
      FindType(Pig,Backpack);
      if FindCount=0 then AddToSystemJournal('Покушали.');
      if FindCount>0 then MoveItem(FindItem,1,Sunduk_With_Iron_and_Tools,0,0,0);
    end
  else
    AddToSystemJournal('a Pig не был найден в сундуке.');
 end;
Begin
 ClearJournal;
 while not Dead do
   begin
     Check_Connect;
     if InJournal('hungry')=1 then Check_Food;
     Check_Iron;
     Check_Tools;
     
     k:=0;
     TimeStart:=Now;
     WaitMenu( 'Tinkering' , 'Parts' );
     WaitMenu( 'Parts' , 'clock' );
     UseObject(FindType(Tools,Backpack));
      
     repeat 
       wait(100); 
       k := k + 1; 
       Check_World_Save;
     until (InJournalBetweenTimes('You put|failed', TimeStart, Now)<>-1) or (k > 300);
     wait(100);
     if Count(Clock)>50 then 
       begin
         MoveItem(FindItem,GetQuantity(FindItem),Sunduk_With_Clock,0,0,0);
         wait(250);
       end
     else
       AddToSystemJournal(IntToStr(Count(Clock))+' parts of a clock на данный момент в мешке.');
   end    
End.


