Get recipe in Yew.

Only working scripts
Post Reply
Atida
Neophyte
Neophyte
Posts: 17
Joined: 15.08.2017 4:33

Get recipe in Yew.

Post by Atida »

The bank is open, but the script still open bank each time.

Code: Select all

Program takegump; 
var 
b:TStringList; 
i,need:Integer; 
s:string; 
BankBox,pack:Cardinal;

const
npc = $00000507;     //要接任务的npc
marker = $40700F2E;  //标识物,找得到就是银行已经打开 if finded marker , bank is opened
bow_tool = $1022;

procedure takemakeinfo;
Label 
  readinfo;
  
begin
CloseSimpleGump(0);
CloseSimpleGump(1);
CloseSimpleGump(2);
CloseSimpleGump(3);
CloseSimpleGump(4);
//uosay(inttostr(getgumpscount-1));
if getgumpscount > 2 then begin
  for i:=0 to getgumpscount - 2 do begin
  CloseSimpleGump(i);  
  wait(1000);                           
  end;
end;
                       
readinfo:
b := TStringList.Create; 
SetSilentMode(true); 
GetGumpFullLines(getgumpscount-1, b);
if b.count < 31 then begin
   useobject(npc); 
   wait(500);
   goto readinfo
end;
s:=b.strings[31];
//addtosystemjournal(s);
if pos('Quest Conversation',s)>0 then begin
   addtosystemjournal('Quit Quest'); 
   wait(1000);
   s:=b.strings[32]; 
//   addtosystemjournal(s);
end;

if ( pos('Ingenious Archery, Part',s)=0 ) and ( pos('Simple Bow',s)=0 ) and ( pos('Lethal Darts',s)=0 ) then begin
   useobject(npc); 
   wait(1000); 
   goto readinfo
end;
if pos('Lethal Darts',s)>0 then need:=$1BFB;  //Crossbow bolts
if pos('A Simple Bow',s)>0 then need:=$13B2;  //Simplebows
if pos('Ingenious Archery, Part I',s)>0 then need:=$0F50;  //crossbow 
if pos('Ingenious Archery, Part II',s)>0 then need:=$13FD;  //heavy crossbow  
if pos('Ingenious Archery, Part III',s)>0 then need:=$26C3;  //Repeating crossbows
numgumpbutton(getgumpscount-1,4);  
wait(500);

AddToSystemJournal(s); 
AddToSystemJournal(inttostr(need)); 

end;

procedure openbank;
begin
BankBox:=ObjAtLayer(BankLayer);
  if findtype($12AC,backpack)=0 then begin
     addtosystemjournal('没有银行卡,停止');  //no found bankcard
     halt;
  end; 
  if findtype(marker,BankBox)=0 then begin
     UseObject(findtype($12ac,backpack));
     wait(1000);
  end;
end;

procedure make_bow;
Label
  ReMake;
begin
ReMake:
BankBox:=ObjAtLayer(BankLayer);
moveitem(findtype($1BD7,BankBox),150-GetQuantity(findtype($1bd7,backpack)),backpack,0,0,0);
repeat
  useobject(findtype(bow_tool,backpack));
  wait(500);
  waitgump('15');
  wait(500);          
  if need=5042 then waitgump('2');   //$13B2  Simple bows
  if need=3920 then waitgump('9');   //$0F50  crossbow
  if need=5117 then waitgump('16');  //$13FD  heavy crossbow
  if need=9923 then waitgump('30');  //$26C3  Repeating crossbows
  wait(1000);  
until (Count(need)>=10) or (GetQuantity(findtype($1bd7,backpack))<10);
if GetQuantity(findtype($1bd7,backpack))<10 then goto ReMake;
end;

procedure Toggle_quest_Item;
begin
  RequestContextMenu(self);  
  wait(500);
  SetContextMenuHook(self,2);    
  wait(500);
  repeat   
    if GetColor(findtype(need,backpack))=0 then begin
       WaitTargetObject(findtype(need,backpack));
       ignore(finditem); 
       wait(500);
    end;   
    if GetColor(findtype(need,backpack))<>0 then ignore(finditem);
  until findtype(need,backpack)=0;
  CancelTarget; 
  wait(1000);
end;

procedure Finish_Quest;
begin
  useobject(npc);
  wait(500);
  waitgump('8');
  wait(500);
  waitgump('5');
  wait(1000); 
end;


procedure Filter;      //筛选物品
begin
  repeat    
  findtype($0E75,backpack)
  UseObject(finditem); 
  pack:=finditem;
  wait(1000);
  findtype($FFFF,pack);
  until finditem>0;      
  wait(500);
  findtype($2831,pack)
  if finditem>0 then useobject(finditem); 
  wait(500);
  {if reaper in tooltip | Maker in tooltip | Faerie in tooltip | Silvani's in tooltip , save to bank  } 
  wait(500);   
  if findtype($0E75,ground)<> 0 then moveitem(pack,1,finditem,0,0,0);   
  if (findtype($0E75,ground)=0)or(injournal('cant hold')>0) then moveitem(pack,1,ground,getx(self)+1,gety(self),getz(self));                     
end;


begin
while true do begin
takemakeinfo;
BankBox:=ObjAtLayer(BankLayer);
openbank;  

if need=7163 then begin
   AddToSystemJournal('Crossbow bolts');  //$1BFB
   moveitem(findtype($1BFB,BankBox),20-GetQuantity(findtype($1BFB,backpack)),backpack,0,0,0);
end;
if need<>7163 then begin
   if need=5042 then AddToSystemJournal('Simple bows');  //$13B2  Simple bows
   if need=3920 then AddToSystemJournal('crossbow');     //$0F50 crossbow
   if need=5117 then AddToSystemJournal('heavy crossbow');     //$13FD  heavy crossbow
   if need=9923 then AddToSystemJournal('Repeating crossbows');   //$26C3 Repeating crossbows
   make_bow;
   end;
Toggle_quest_Item;
CloseSimpleGump(0);
CloseSimpleGump(1);
CloseSimpleGump(2);
CloseSimpleGump(3);
CloseSimpleGump(4);
Finish_Quest;      
Filter;  
end;    
End.

Last edited by Atida on 23.02.2018 15:09, edited 1 time in total.
Atida
Neophyte
Neophyte
Posts: 17
Joined: 15.08.2017 4:33

Re: Get recipe in Yew.

Post by Atida »

And who can help me to optimize this script.
User avatar
Vizit0r
Developer
Developer
Posts: 3955
Joined: 24.03.2005 17:05
Contact:

Re: Get recipe in Yew.

Post by Vizit0r »

BankBox:=ObjAtLayer(BankLayer);

are you sure, that bankcontainer = ObjAtLayer(BankLayer) ?
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Atida
Neophyte
Neophyte
Posts: 17
Joined: 15.08.2017 4:33

Re: Get recipe in Yew.

Post by Atida »

Vizit0r wrote:BankBox:=ObjAtLayer(BankLayer);

are you sure, that bankcontainer = ObjAtLayer(BankLayer) ?

I'm not sure, but it works now.
Post Reply