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

ZuluHotel CraftAndSellScript[Stealth v7.8.5]

Only working scripts
Post Reply
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

ZuluHotel CraftAndSellScript[Stealth v7.8.5]

Post by drabadan »

Надеюсь кому нибудь пригодится, простенький скрипт на крафт вещей.

Главный файл:

Code: Select all

Program CraftAndSellScript;

uses
  CraftAndSellScriptEngine, CraftingEngine, RunebookHelper, LocationsHolder;

const
  Version = '102';

var
  crafter : TCraftingEngine;
  locations : TLocationsHolder;

  engine : TCraftAndSellScriptEngine;

  UnloadChest, TargetContainer : Cardinal;
  HomePoint, DoorPoint : TPoint;
  Colours : Array of Word;
  craftItems : TCraftItemArray;
  ItemToMake : String;
  CountToMakeOnce : Integer;

function ReadConfigSection(Section : String; IniFile : TIniFile) : Boolean;
var 
 //IniFile : TIniFile;
 i : Integer;
 SL : TStringList;
 coloursString : String;
begin
  Result := False;
  UnloadChest := IniFile.ReadInteger(Section,'UnloadChest', 0);      
  TargetContainer := IniFile.ReadInteger(Section,'TargetContainer', 0); 
  CountToMakeOnce := IniFile.ReadInteger(Section,'CountToMakeOnce', 0);    
  HomePoint.X := IniFile.ReadInteger(Section,'HomeX', 0);
  HomePoint.Y := IniFile.ReadInteger(Section,'HomeY', 0);
  DoorPoint.X := IniFile.ReadInteger(Section,'DoorX', 0);
  DoorPoint.Y := IniFile.ReadInteger(Section,'DoorY', 0);  
  ItemToMake := IniFile.ReadString(Section,'ItemToMake', '');  
  

  if (HomePoint.X = 0) or (HomePoint.Y = 0) or (UnloadChest = 0) then
    begin
      AddToSystemJournal('Wrong CraftAndSellScriptConfig.ini path! You should place it to \Scripts\CraftAndSellScriptConfig.ini');
      Halt;
    end;  
  coloursString := IniFile.ReadString(Section, 'Colours', '');
  AddToSystemJournal('Colours priorities: ' + coloursString);
  if coloursString > '' then
    begin
      SL := TStringList.Create;
      SL.CommaText := coloursString;
      SetLength(Colours, SL.Count);  
      for i := 0 to SL.Count-1 do
        begin
          //AddToSystemJournal(SL[i]);
          Colours[i] := StrToInt(SL[i]);
        end;
      SL.Free;
    end;

end;

procedure InitConstants;
var
  IniFile : TIniFile;  
  SLNames, SLItems : TStringList;
  i : Integer;  
begin
  AddToSystemJournal('Reading constants...');
  IniFile := TIniFile.Create(StealthPath + '\Scripts\CraftAndSellScriptConfig.ini');
  
  //Reading of CraftItems
  SLNames := TStringList.Create;
  SLNames.Commatext := IniFile.ReadString('CraftItems', 'ItemsNames', '');
  if SLNames.Count > 0 then
    begin
      SetLength(craftItems, SLNames.Count);
      for i := 0 to SLNames.Count-1 do
        begin
          SLItems := TStringList.Create;
          SLItems.StrictDelimiter := True;
          SLItems.Delimiter := ',';
          SLItems.DelimitedText := IniFile.ReadString('CraftItems', SLNames[i], '');
          if SLItems.Count = 6 then
            begin
              craftItems[i] := TCraftItem.Create(StrToInt(SLItems[0]), StrToInt(SLItems[1]), StrToInt(SLItems[2]), StrToInt(SLItems[3]), SLItems[4], SLItems[5]); 
              AddToSystemJournal(SLItems[4]);
            end;
          SLItems.Free;
        end;
    end;
  SLNames.Free;

  if IniFile.SectionExists(CharName) then
    ReadConfigSection(CharName, IniFile)
  else
    ReadConfigSection('Constants', IniFile);

  IniFile.Free;
end;


begin  
  AddToSystemJournal('Version ' + Version);
  InitConstants;
  
  SetARStatus (True);
  SetPauseScriptOnDisconnectStatus(True);

  MoveOpenDoor := True;
  MoveThroughNPC := 0;

  locations := TLocationsHolder.Create;
  locations.AddLocation('Home', HomePoint);
  locations.AddLocation('Door', DoorPoint);

  crafter := TCraftingEngine.Create(craftItems);
  
  engine := TCraftAndSellScriptEngine.Create;
  engine.Locations := locations;
  engine.Colours := Colours;
  engine.UnloadChest := UnloadChest;
  engine.TargetContainer := FindType($09AA, Backpack);//TargetContainer;
  engine.ItemToMake := ItemToMake;
  engine.CountToMakeOnce := CountToMakeOnce;
  engine.Crafter := crafter;

  engine.StartWorker;

end.
Конфиг:

Code: Select all

[Constants]
UnloadChest = $43208D0C 
TargetContainer = 0
CountToMakeOnce = 4
ItemToMake = Wand
HomeX = 399
HomeY = 3446
DoorX = 400
DoorY = 3451

Colours = $0425, $0

[YOUR_CHAR_NAME]
UnloadChest = $43208D0C 
TargetContainer = 0
CountToMakeOnce = 5
ItemToMake = Wand
HomeX = 399
HomeY = 3446
DoorX = 400
DoorY = 3451

Colours = $050C, $0425, $0


[CraftItems]
ItemsNames = Wand, Lockpicks
;ToolType, ReagentType, ResultItem, RegsCount, MenuString, CategoryString
Wand = $1EBC, $1BF2,$DF2,7,Wand,Deadly Tools
Lockpicks = $1EBC,$1BF2,$14FB,1,Lockpicks,Tools
Вспомогательные юниты:

Code: Select all

unit LocationsHolder;

interface

type 
 TLocation = record
  X, Y : Word;
  Title : String;
 end;

type TLocationsArray = Array of TLocation;

type
  TLocationsHolder = class
   private
    AllLocations : TLocationsArray;
   public
    function GetLocation(Key : String) : TLocation; //search for location in AllLocations
    function HasLocation(Key : String) : Boolean; //search for location in AllLocations
    function AddLocation(Title : String; X, Y : Word) : Integer; overload;//returns current length of AllLocations
    function AddLocation(Title : String; LocationPoint : TPoint) : Integer; overload;//returns current length of AllLocations

    function MoveToLocation(Key : String; Precision : Integer = 1) : Boolean;  
  end;

implementation

function TLocationsHolder.GetLocation(Key: String): TLocation;
var 
  i : Integer;
begin
  for i := 0 to High(AllLocations) do
    if (AllLocations[i].Title = Key) then
      begin
        Result := AllLocations[i];
        Exit;
      end;
  
  AddToSystemJournal('Location with title: ' + Key + ' not found!');
end;

function TLocationsHolder.HasLocation(Key: String): Boolean;
var 
  i : Integer;
begin
  Result := False;
  for i := 0 to High(AllLocations) do
    if (AllLocations[i].Title = Key) then
      begin
        Result := True;
        Exit;
      end;
end;


function TLocationsHolder.AddLocation(Title: String; X, Y: Word): Integer;
var
  tmpLoc : TLocation;
begin
  if HasLocation(Title) then
    begin
      Result := -1;
      Exit;
    end;
  
  tmpLoc.Title := Title;
  tmpLoc.X := X;
  tmpLoc.Y := Y;

  SetLength(AllLocations, Length(AllLocations) + 1);
  AllLocations[High(AllLocations)] := tmpLoc;
  Result := High(AllLocations);
end;

function TLocationsHolder.AddLocation(Title: String; LocationPoint: TPoint): Integer;
begin
  Result := AddLocation(Title, LocationPoint.X, LocationPoint.Y);  
end;


function TLocationsHolder.MoveToLocation(Key: String; Precision: Integer = 1): Boolean;
begin
  //AddToSystemJournal('Precision is: ' + Precision.ToString);
  ClearBadLocationList;
  Result := newMoveXY(GetLocation(Key).X,  GetLocation(Key).Y, true, Precision, true);
end;

end.
unit CraftAndSellScriptEngine;

interface

uses 
  ItemsHelper, RunebookHelper, LocationsHolder, CraftingEngine, MoverHelper;

type
  TCraftAndSellScriptEngine = class
  private 
    
    HomeRuneIdx, SellRuneIdx : Integer;
    IHelper : TItemsHelper;
    procedure InitializeSelf;
    function Unload : Boolean;
    function GoSellAll : Boolean;
    function WorkerWork : Boolean;    
  public
    Locations : TLocationsHolder;    
    Runebook : TRunebook;
    Mover : TMoverHelper;
    Crafter : TCraftingEngine;

    UnloadChest, TargetContainer : Cardinal;
    Colours : Array of Word;
    ItemToMake : String;
    CountToMakeOnce : Integer;

    procedure StartWorker;
    constructor Create;
end;

implementation

procedure TCraftAndSellScriptEngine.InitializeSelf;
begin
  IHelper := TItemsHelper.Create;
  Mover := TMoverHelper.Create;
  Runebook := TRunebook.Create;  
  HomeRuneIdx := Runebook.SearchForHomeRune;
  SellRuneIdx := Runebook.SearchRunesByKey('Prodaja')[0].ButtonId;
end;

constructor TCraftAndSellScriptEngine.Create;
begin
  InitializeSelf;
end;

function TCraftAndSellScriptEngine.WorkerWork: Boolean;
begin
  Unload;

  if Crafter.CraftItem(ItemToMake, Colours, TargetContainer, CountToMakeOnce) then
    GoSellAll;

  Result := True;
end;

procedure TCraftAndSellScriptEngine.StartWorker;
begin
  while True do
    begin
      WorkerWork;
      Wait(1000);
    end;
end;

function TCraftAndSellScriptEngine.Unload: Boolean;
begin
  Result := True;
  if (Dist(GetX(SelfId), GetY(SelfId), Locations.GetLocation('Home').X, Locations.GetLocation('Home').Y) > 20) then
    Runebook.Recall(HomeRuneIdx);

  Mover.MoveToSpotThroughDoor(Locations.GetLocation('Home').X, Locations.GetLocation('Home').Y, Locations.GetLocation('Door').X, Locations.GetLocation('Door').Y); 
  while (FindType($0EED, Backpack) > 0) do
    begin
      MoveItem(FindItem, 0, UnloadChest, 0,0,0);
      Wait(300);
      CheckLag(30000);
    end;

  Runebook.Restock(UnloadChest);
end;

function TCraftAndSellScriptEngine.GoSellAll: Boolean;
begin  
  Runebook.Recall(SellRuneIdx);
  FindDistance := 6;
  if (FindType($0190, Ground) > 0) or (FindType($0191, Ground) > 0) then
    newMoveXY(GetX(FindItem),  GetY(FindItem), true, 0, true)
  else
    begin
      AddToSystemJournal('Vendor not found!');
      Result := False;
      Exit;
    end;
  
  UOSay('Sell Bag');
  if WaitForTarget(10000) then
    TargetToObject(TargetContainer);

  Wait(1000);
  CheckLag(30000);
  Result := True;
end;

end.
unit CraftingEngine;


interface

uses
  ItemsHelper;

type 
 TCraftItem = record
  ToolType, ReagentType, RegColour, ResultItem : Word;
  RegsCount : Integer;
  MenuString, CategoryString : String;

  constructor Create(ToolType, ReagentType, ResultItem : Word; RegsCount : Integer; MenuString, CategoryString : String);
 end;

type TCraftItemArray = Array of TCraftItem;

type
  TCraftingEngine = class
   private
     CraftItems : TCraftItemArray;
     procedure InitializeCraftItems;
     
   public    
     IHelper : TItemsHelper;
     RestockChest : Cardinal;

     //function Restock : Boolean;
     function Checkregs(CraftItem : TCraftItem; Count : Integer) : Cardinal;
     function CheckTool(CraftItem : TCraftItem) : Cardinal;
     function MakeItem(CraftItem : TCraftItem; TargetContainer : Cardinal; Count : Integer = 1) : Boolean; overload;
     function MakeItem(CraftItem : TCraftItem; Count : Integer = 1) : Boolean; overload;

     function CraftItem(ItemTitle : String; TargetContainer : Cardinal; Count : Integer = 1) : Boolean; overload;
     function CraftItem(ItemTitle: String; Colour : Cardinal; TargetContainer : Cardinal; Count : Integer = 1): Boolean; overload;
     function CraftItem(ItemTitle: String; Colours : Array of Word; TargetContainer : Cardinal; Count : Integer = 1): Boolean; overload;

     constructor Create; overload;
     constructor Create(CraftItemsLoaded : TCraftItemArray); overload;
  end;


implementation

constructor TCraftItem.Create(ToolType, ReagentType, ResultItem: Word; RegsCount : Integer; MenuString, CategoryString: String);
begin
  Self.ToolType := ToolType;
  Self.ReagentType := ReagentType;
  Self.RegColour := $0000;
  Self.ResultItem := ResultItem;
  Self.RegsCount := RegsCount;
  Self.MenuString := MenuString;
  Self.CategoryString := CategoryString;
end;


procedure TCraftingEngine.InitializeCraftItems;  
begin
  SetLength(CraftItems, 1);

  CraftItems[0] := TCraftItem.Create($1EBC, $1BF2, $DF2, 7, 'Wand', 'Deadly Tools');
end;

constructor TCraftingEngine.Create(CraftItemsLoaded: TCraftItemArray);
begin
  Self.CraftItems := CraftItemsLoaded;  
end;

constructor TCraftingEngine.Create;
begin
  InitializeCraftItems;  
end;

function TCraftingEngine.Checkregs(CraftItem: TCraftItem; Count: Integer) : Cardinal;
var
  tmpRegs : Cardinal;
  tmpStacks : TCardinalArray;
  i : Integer;
begin   
  tmpStacks := IHelper.GetFoundItems(CraftItem.ReagentType, CraftItem.RegColour, Backpack);
  for i := 1 to High(tmpStacks) do
    begin
      MoveItem(tmpStacks[i], 0, tmpStacks[i-1], 0,0,0);
      Wait(300);
      CheckLag(30000);
    end;

  FindTypeEx(CraftItem.ReagentType, CraftItem.RegColour, Backpack, false);
  //AddToSystemJournal(GetQuantity(FindItem).ToString);
  if GetQuantity(FindItem) >= CraftItem.RegsCount then
    begin
      Result := FindItem;
      Exit;
    end;
  //if RestockChest = 0 then
    //Exit;
  if RestockChest > 0 then
    begin
      UseObject(RestockChest);
      Wait(300);  
      CheckLag(30000);
    end;

  tmpRegs := FindTypeEx(CraftItem.ReagentType, CraftItem.RegColour, RestockChest, false);

  if tmpRegs = 0 then
    begin
      AddToSystemJournal('Regs not found!');
      Wait(30000);
      Result := Checkregs(CraftItem, Count);
      Exit;
    end;

  //if (FindFullQuantity >= Count) then
  MoveItem(FindItem, Count, Backpack, 0,0,0);
  Wait(300);
  CheckLag(30000);

  Result := Checkregs(CraftItem, Count);//FindTypeEx(CraftItem.ReagentType, CraftItem.RegColour, Backpack, false);
end;

function TCraftingEngine.CheckTool(CraftItem: TCraftItem) : Cardinal;
begin
  Result := FindType(CraftItem.ToolType, Backpack);
end;

function TCraftingEngine.MakeItem(CraftItem: TCraftItem; TargetContainer: Cardinal; Count: Integer): Boolean;
var
  tmpRegs : Cardinal;  
  tmpCount : Integer;
begin
  //AddToSystemJournal(IntToHex(TargetContainer, 8));
  UseObject(TargetContainer);
  CheckLag(30000);
  FindType(CraftItem.ResultItem, TargetContainer);
  tmpCount := FindCount;
  //AddToSystemJournal(FindCount.ToString);
  if (FindFullQuantity >= Count) then
    begin
      while FindType(CraftItem.ReagentType, Backpack) > 0 do
        begin
          MoveItem(FindItem, 0, Ground, 0,0,0);
          Wait(1000);
        end;
      Result := True;
      Exit;
    end;
  //AddToSystemJournal(((CraftItem.RegsCount * Count) - (CraftItem.RegsCount * tmpCount)).ToString + ' regsCount');
  tmpRegs := Checkregs(CraftItem, (CraftItem.RegsCount * Count) - (CraftItem.RegsCount * tmpCount));//FindTypeEx(CraftItem.ReagentType, $050C , Backpack, false);
  if (tmpRegs = 0) then
    begin
      AddToSystemJournal('No regs');
      Result := False;
      Exit;
    end;
    
  WaitMenu('What would you like to make?', CraftItem.CategoryString);
  WaitMenu('What would you like to make?', CraftItem.MenuString);

  if FindType(CraftItem.ToolType, Backpack) = 0 then
    if FindType(CraftItem.ToolType, Ground) = 0 then
      if FindType(CraftItem.ToolType, RestockChest) = 0 then
        begin
          AddToSystemJournal('Tools not found!');
          Result := False;
          Wait(30000);
          Result := MakeItem(CraftItem, TargetContainer, Count);
          Exit;
        end;

  UseObject(FindItem);
  if WaitForTarget(10000) then
    TargetToObject(tmpRegs);
  if not WaitJournalLineSystem(Now, 'Success|Fail|You destroyed', 30000) then
    AddToSystemJournal('Something wrong with waiting craft result')
  else if(TargetContainer <> Backpack) and (FoundedParamID = 0) then
    begin
      while (FindType(CraftItem.ResultItem, Backpack) > 0) do
        begin
          MoveItem(FindItem, 0, TargetContainer, 0,0,0);
          Wait(300);
          CheckLag(30000);
        end;
    end;

  Result := MakeItem(CraftItem, TargetContainer, Count);
end;

function TCraftingEngine.MakeItem(CraftItem: TCraftItem; Count : Integer = 1) : Boolean;
begin
  Result := MakeItem(CraftItem, Backpack, Count);
end;

function TCraftingEngine.CraftItem(ItemTitle: String; TargetContainer : Cardinal; Count : Integer = 1): Boolean;
var 
  i : Integer;
begin
  for i := 0 to High(CraftItems) do
    if(ItemTitle = CraftItems[i].MenuString) then
      begin
        Result := MakeItem(CraftItems[i], TargetContainer, Count);
        Exit;
      end;
end;

function TCraftingEngine.CraftItem(ItemTitle: String; Colour : Cardinal; TargetContainer : Cardinal; Count : Integer = 1): Boolean;
var 
  i : Integer;
begin
  for i := 0 to High(CraftItems) do
    if(ItemTitle = CraftItems[i].MenuString) then
      begin
        CraftItems[i].RegColour := Colour;
        Result := MakeItem(CraftItems[i], TargetContainer, Count);
        CraftItems[i].RegColour := $0;
        Exit;
      end;
end;

function TCraftingEngine.CraftItem(ItemTitle: String; Colours: Array of Word; TargetContainer: Cardinal; Count: Integer): Boolean;
var
  i : Integer;
begin
  for i := 0 to High(Colours) do
    Result := CraftItem(ItemTitle, Colours[i], TargetContainer, Count);
end;


end.
unit ItemsHelper;

interface

type TCardinalArray = Array of Cardinal;

type
  TItemsHelper = class
  public
    function GetFoundItems(ItemType: Word; Container : Cardinal) : TCardinalArray; overload;
    function GetFoundItems(ItemType, ItemColour: Word; Container : Cardinal) : TCardinalArray; overload;
    function CheckNotorietyArea(NotorietyLevel : Byte) : Boolean;
  end;

implementation

function TItemsHelper.GetFoundItems(ItemType: Word; Container : Cardinal): TCardinalArray;
var 
 res : TCardinalArray;
 List: TStringList; 
 i: Integer;
begin
  if (FindType(ItemType, Container) <= 0) then
    Exit;
    
  List := TStringList.Create;
  if GetFindedList(List) then
   begin
    SetLength(res, List.Count);
    for i := 0 to Length(res)-1 do 
      res[i] := StrToInt('$'+List.Strings[i]);
   end;

  List.Free; 

  Result := res;
end;

function TItemsHelper.GetFoundItems(ItemType, ItemColour: Word; Container : Cardinal): TCardinalArray;
var 
 res : TCardinalArray;
 List: TStringList; 
 i: Integer;
begin
  if (FindTypeEx(ItemType, ItemColour, Container, False) <= 0) then
    Exit;
    
  List := TStringList.Create;
  if GetFindedList(List) then
   begin
    SetLength(res, List.Count);
    for i := 0 to Length(res)-1 do 
      res[i] := StrToInt('$'+List.Strings[i]);
   end;

  List.Free; 

  Result := res;
end;

function TItemsHelper.CheckNotorietyArea(NotorietyLevel : Byte): Boolean;
var 
 founded : TCardinalArray;
 i : Integer;
begin
  Result := False;
  founded := GetFoundItems($FFFF, Ground);
  for i := 0 to High(founded) do
    if (GetNotoriety(founded[i]) >= NotorietyLevel) then
      begin
       Result := True;
       Exit;
      end;
end;

end.
Unit RunebookHelper;

interface

type
 TRuneEntry = record
  Title : String;
  ButtonId : Integer;
  constructor Create(Title : String; ButtonId : Integer);
 end;

type TRuneEntryArray = Array of TRuneEntry;

type
 TRunebook = class
 private
  LatestGumpInfo : TGumpInfo;
  Id : Cardinal;

  MaxCharges : Integer;

  function Open : Boolean; 
  function ParseCharges(Str : String) : Integer;    
 public
  Runes : TRuneEntryArray;
  Charges : Integer;

  function Initialize : Boolean;

  function Recall(Rune : TRuneEntry) : Boolean; overload;
  function Recall(RuneTitle : String) : Boolean; overload;
  function Recall(ButtonId : Integer) : Boolean; overload;
  
  function Restock(ScrollChest : Cardinal) : Boolean;
  
  function SearchForHomeRune : Integer;
  function SearchRunesByKey(Key : String) : TRuneEntryArray;

  procedure SayAllDestinations;
  
  constructor Create; overload;
  constructor Create(Id : Cardinal); overload;
 end;

implementation

const
 __STANDARTLAG = 1000;
 __RUNEBOOK_TYPE = $0EFA;

constructor TRuneEntry.Create(Title: String; ButtonId: Integer);
begin
  Self.Title := Title;
  Self.ButtonId := ButtonId;
end;

constructor TRunebook.Create;
begin
  if (FindType(__RUNEBOOK_TYPE, Backpack) > 0) then
    Self.Id := FindItem
  else
    begin
      AddToSystemJournal('Runebook not found in pack!');
      Self.Id := 0;      
    end;

  Initialize;
end;

constructor TRunebook.Create(Id: Cardinal);
begin
  Self.Id := Id;
end;


function TRunebook.ParseCharges(Str : String) : Integer;
begin
  Result := -1;
  if(Pos('Charges:', Str) <= 0) then
    Exit;

  Result := StrToInt(Copy(Str, Pos(':', Str) + 1, Length(Str) - Pos(':', Str)));
end;


function TRunebook.Initialize : Boolean;
var
 i, runeCount, gumpsCount : Integer;
 tmpRuneEntry : TRuneEntry;
begin
  if not Connected then
    Exit;

  SetLength(Runes, 0);

  Open;
  Wait(2000);

  if (GetGumpsCount = 0) then
   begin
    AddToSystemJournal('Could not open runebook!');
    Initialize;
   end;
  
 gumpsCount := GetGumpsCount-1;
 if not (gumpsCount >= 0) then
   gumpsCount := 0;

  GetGumpInfo(gumpsCount, LatestGumpInfo);

  runeCount := 0;
  
  if(Length(LatestGumpInfo.Text) <= 0) then
   begin
    Result := False;
    AddToSystemJournal('Wrong runebook gump info data!');
    Exit;  
   end;

   Charges := ParseCharges(LatestGumpInfo.Text[0]);
   MaxCharges := ParseCharges(LatestGumpInfo.Text[1]);

   for i := 0 to High(LatestGumpInfo.Text) do
    if(LatestGumpInfo.Text[i] = 'Drop rune') then
      begin
         tmpRuneEntry.Title := LatestGumpInfo.Text[i+1];
         tmpRuneEntry.ButtonId := 1025 + runeCount;
         Inc(runeCount);

         SetLength(Runes, Length(Runes) + 1);
         Runes[High(Runes)] := tmpRuneEntry;
       end;
  Result := True;
end;

function TRunebook.Open: Boolean;
begin
  if TargetPresent then 
   begin
    CancelTarget;
    Wait(1000);
  end;

  UseObject(Self.Id);
  Wait(1000);
  Result := True;  
end;

function TRunebook.Recall(ButtonId: Integer): Boolean;
var 
 x, y : Word;
 i, count : Integer;
begin
  if Dead then 
   Exit;
  
  if not IsObjectExists(Self.Id) then
    UseObject(Backpack);
  
  if not Self.Open then
  begin
    UseObject(Backpack);
    Result := False;
    Exit;
  end;

  Step(1, true);
  Wait(1000);

  x := GetX(SelfID);
  y := GetY(SelfID);

  count := GetGumpsCount;
  if(count > 0) then
   NumGumpButton(count - 1, ButtonId)
  else
   Recall(ButtonId);

  Wait(__STANDARTLAG);
  Charges := Charges - 1;
  
  for i := 0 to 5 do
    begin
      //AddToSystemJournal('Change position seq: ' + i.ToString);
      Wait(__STANDARTLAG*2);
      if ((GetX(SelfID) <> x) or (GetY(SelfID) <> y)) then
       begin
         Result := True;
         Exit;
       end;
    end;
end;

function TRunebook.Recall(Rune: TRuneEntry): Boolean;
begin
  AddToSystemJournal('Recalling to ' + Rune.Title);
  Result := Recall(Rune.ButtonId);  
end;

function TRunebook.Recall(RuneTitle: String): Boolean;
var
 i : Integer;
 tmpRuneEntry : TRuneEntry;
begin
  Result := False;
  for i := 0 to High(Runes) do
    if(Runes[i].Title = RuneTitle) then
     begin
      AddToSystemJournal(Runes[i].Title + ' ' + RuneTitle);
      tmpRuneEntry := Runes[i];
      Break;
     end;
  AddToSystemJournal('bla ' + tmpRuneEntry.Title);
  Result := Recall(tmpRuneEntry);
end;

procedure TRunebook.SayAllDestinations;
var
 i : Integer;
begin
  for i := 0 to High(Runes) do
    AddToSystemJournal(Runes[i].Title);  
end;

function TRunebook.Restock(ScrollChest: Cardinal): Boolean;
begin
  if (Charges = MaxCharges) then
    Exit;
  
  //if not IsObjectExists(ScrollChest) then
  //  begin
  //    Result := False;
  //    AddToSystemJournal('Restock chest not found!');
  //    Exit;
  //  end;

  newMoveXY(GetX(ScrollChest), GetY(ScrollChest), true, 1, true);

  UseObject(ScrollChest);
  Wait(__STANDARTLAG);
  
  if not (FindType($1F4C, Ground) > 0) then
    FindType($1F4C, ScrollChest);
  
  //AddToSystemJournal('Recall scrolls in chest left: ' + FindFullQuantity.ToString + ' ' + MaxCharges.ToString + ' z: ' + GetZ(FindItem).ToString + ' id: 0x' + IntToHex(FindItem, 8));

  if (FindFullQuantity > 0) then
   begin
     MoveItem(FindItem, MaxCharges - Charges, Id, 0,0,0);
     Wait(__STANDARTLAG);
     if(FindFullQuantity > (MaxCharges - Charges)) then
      Charges := MaxCharges
     else
      Charges := Charges + FindFullQuantity;      
   end;

   if (FindType($1F4C, Backpack) > 0) then
     begin
       MoveItem(FindItem, 0, ScrollChest, 0,0,0);
       Wait(__STANDARTLAG);
     end;

   Result := True;
end;

function TRunebook.SearchForHomeRune: Integer;
var 
 i : Integer;
begin
  Result := -1;
  if(Length(Runes) = 0) then
    Initialize;

  if(Length(Runes) = 0)then
    Exit;

  for i := 0 to High(Runes) do 
   //AddToSystemJournal(Runes[i].Title);
   if (Pos('Home', Runes[i].Title) > 0) then        
     begin
       Result := Runes[i].ButtonId;
       Break;
     end;
    //end;
end;

function TRunebook.SearchRunesByKey(Key: String): TRuneEntryArray
var 
 i : Integer;
 OutRunes : TRuneEntryArray;
begin
 //Result := -1;

 for i := 0 to High(Runes) do
  if (Pos(Key, Runes[i].Title) > 0) then
   begin
     SetLength(OutRunes, Length(OutRunes) + 1);
     //OutRunes[High(OutRunes)] := Runes[i];
     OutRunes[High(OutRunes)] := TRuneEntry.Create(Runes[i].Title, Runes[i].ButtonId);
   end;

  Result := OutRunes;
end;

end. 
Unit MoverHelper;

interface


type 
 TMoverHelper = class
 private
  function ValidateMovement(X, Y : Word) : Boolean;
 public
  function MoveToSpot(X, Y : Word) : Boolean;
  function MoveToSpotThroughDoor(X, Y, DoorX, DoorY : Word) : Boolean;
 end;

implementation

function TMoverHelper.MoveToSpot(X, Y: Word): Boolean;
begin
  Result := False;
  
  if not ValidateMovement(X, Y) then
    AddToSystemJournal('Some problem with point: X=' + X.ToString + ', Y=' + Y.ToString)
  else
   begin
    newMoveXY(X, Y, true, 1, true);
    Result := True;
   end;
end;

function TMoverHelper.ValidateMovement(X, Y: Word): Boolean;
begin
  Result := True;
end;

function TMoverHelper.MoveToSpotThroughDoor(X, Y, DoorX, DoorY: Word): Boolean;
begin
  ClearBadLocationList;
  ClearBadObjectList;
  newMoveXY(DoorX, DoorY, true, 1, true);
  Wait(500);
  newMoveXY(X, Y, true, 1, true);
  Result := True;
end;

end.
Чтобы запустить нужно сохранить все файлы в папку Scripts и нажать плей.
Скрипт умеет подбирать под ногами ресы крафтить из них нужное колво вещей и лететь продавать их вендору командой sell bag.

тут по большей части крафт и иже с ним, он же вещи котоыре делать читает из файла, то-есть любой из вас может добавить себе любую вещь в крафт если она делается из 1 рега. Так же и с цветами ресурсов, то-есть там список цветов в инфофайле, будет крафтить из цветов по убыванию, то-есть первый в списке цвет будет крафтиться первым. Так же реализован конфиг отдельно для любого чара, то-есть допустим у вас 2 тинкера один гм другой 45 первый может крафтить из всего а второй только из айрона, вы тому который из айрона копипастите отдельный конфиг с его ником в заголовке как тут сделано в секции YOUR_CHAR_NAME и он будет читать конфиг отдельно, может у вас 2 разных чара в разных домах для которых точки разные.
Post Reply