Code: Select all
Program Lumber;
/// Настройки ///
const
RadiusX=10;
RadiusY=10;
Axe=$0F43; 
////////////////////
//Wend, ICQ 492280//
//v. 1.3
type
 TreeRecord = Record
  t,x,y: integer;
  end;
var
 TreeTile: array[0..50] of integer;
 TreePlace: array[0..500] of TreeRecord;
 TreeCount: integer;
 s: boolean;
 x,y,c,a,len,i: integer;
procedure CheckCon;
begin
 if Connected=False then
  begin;
   repeat
    Wait(1000);
   until Connected=True;
   Wait(5000);
  end;
end;
function CheckTool: boolean;
begin
 CheckCon;
 FindType(Axe, backpack);
  if (not dead) and (FindCount = 0) and (ObjAtLayer(LHandLayer) = 0) then
   begin
    AddToSystemJournal('Нет топора');
    s:=false;
    result:=false;
   end
  else 
    result:=true;      
end;
procedure CheckTree;
var
 LCount: integer;
 t: integer;
 TTile: TStaticCell;
begin
 TTile:=ReadStaticsXY(x, y, WorldNum);
 LCount:=GetLayerCount(x, y, WorldNum);
 for i:=0 to LCount-1 do
  begin
   for t:=0 to len-1 do
    if TTile.Statics[i].Tile=TreeTile[t] then
     begin 
      TreePlace[c].t:=TTile.Statics[i].Tile;
      TreePlace[c].x:=x;
      TreePlace[c].y:=y;
      c:=c+1;
     end;
  end;  
end;
procedure FindTree;
begin
 for x:=GetX(self)-RadiusX to GetX(self)+RadiusX do
  if x mod 2 = 0 then
   begin
    for y:=GetY(self)-RadiusY to GetY(self)+RadiusY do
     CheckTree;
   end
  else
   begin
    for y:=GetY(self)+RadiusY downto GetY(self)-RadiusY do
     CheckTree;
   end;   
 TreeCount:=c-1;
end;  
   
procedure Lumber;
var
 t: TDateTime;
begin
 for a:=0 to TreeCount do
  begin
   if not Dead and CheckTool then
    repeat
     CheckCon;
     MoveXY(TreePlace[a].x, TreePlace[a].y, true, 1, false);
     if TargetPresent then CancelTarget;
     t:=now;
     WaitTargetTile(TreePlace[a].t, TreePlace[a].x, TreePlace[a].y, 1);
     UseType(Axe, $FFFF);
     WaitJournalLine(t, 'stop lumberjacking|any wood', 120000); 
    until (InJournalBetweenTimes('no wood|any wood', t, now) > 0) or Dead
   else break;    
  end; 
end; 
begin 
 SetPauseScriptOnDisconnectStatus(false); 
 s:=true;
 TreeTile[0]:=3240; 
 TreeTile[1]:=3242; 
 TreeTile[2]:=3277; 
 TreeTile[3]:=3283; 
 TreeTile[4]:=3286; 
 TreeTile[5]:=3288; 
 TreeTile[6]:=3289; 
 TreeTile[7]:=3290; 
 TreeTile[8]:=3291; 
 TreeTile[9]:=3294; 
 TreeTile[10]:=3296; 
 TreeTile[11]:=3299; 
 TreeTile[12]:=3302; 
 TreeTile[13]:=3393; 
 TreeTile[14]:=3394; 
 TreeTile[15]:=3395; 
 TreeTile[16]:=3396; 
 TreeTile[17]:=3415; 
 TreeTile[18]:=3416; 
 TreeTile[19]:=3417; 
 TreeTile[20]:=3418; 
 TreeTile[21]:=3419; 
 TreeTile[22]:=3438; 
 TreeTile[23]:=3439; 
 TreeTile[24]:=3440; 
 TreeTile[25]:=3441; 
 TreeTile[26]:=3442; 
 TreeTile[27]:=3460; 
 TreeTile[28]:=3461; 
 TreeTile[29]:=3462; 
 TreeTile[30]:=3480;
 TreeTile[31]:=3482; 
 TreeTile[32]:=3488;  
 for i:=0 to Length(TreeTile)-1 do
  if TreeTile[i] <> 0 then
   len:=len+1;
 CheckCon;
 FindTree;
 AddToSystemJournal('Найдено деревьев: '+IntToStr(TreeCount));
 while (not Dead) and s and CheckTool do
  Lumber;
 SetARStatus(false);
 Disconnect;
  
end.Пример, сообщения из журнала:
[12:23:30:968] System: You start lumberjacking...
[12:23:31:109] System: Looping.
[12:23:46:468] System: You fail to find any usable wood.
[12:23:46:812] System: Looping.
[12:24:00:281] System: Reconnected.


 