Code: Select all
program RegsBuyHelper;
Autor: Half-Life;
Description: Скрипт на полном автомате летает по рунабуке и скупает реги. Нужно сидеть на Жуке. Жук желательно должен быть bonded.
UOStealthClientVersion: 6.2.1;
Warning! Будьте бдительны! - Администрация многих игровых серверов враждебно относится к использованию стелс клиента на своих серверах. Заподозрив вас в использовании стелс клиента и других неправославных программ они начинают сатанеть и в порыве слепой ярости могут попасть по вам Банхаммером;
const
RegsStorage=$4003101F;      //Сундук в доме куда будут скидываться реги.
StorX=1820;                 //Координата Х куда встать в доме.
StorY=1140;                 //Координата У куда встать в доме.
HomeRuneBook=$402F03B7;     //Рб с рункой в дом.
HomeRuneIndex=7;            //Номер рунки к дому. Отсчёт начинается с нуля!
HomeX=1818;                 //Координата Х рунки к дому.
HomeY=1138;                 //Координата У рунки к дому.
BankRuneIndex=8;            //Номер рунки к банку.
BankX=991;                  //Координата Х рунки к банку.
BankY=524;                  //Координата У рунки к банку.
RuneBookShift=5;      //Чем реколится. (5-магия, 7-Чива)
RuneAmount=10;        //Количетво Рун в книге с регами. Отсчёт начинается с нуля!
Mount=$0001D9F5; //Жук
GoldType=$0EED; //Тип Голды
WaitTime=500;
RecalTime=2000;
WaitCycles=7;
LagWait=10000;
Invis=False; //Кастовать инвиз или нет. По умолчанию выключено. Для того что бы прыгал в инвиз нужно поменять False на True
//Дальше ничего не меняем кроме РБ с регами в самом низу
var
CurrentRune:Byte;
CurrentBook,i:Integer;
RegTypes,VendorTypes:array of Word;
RuneBooks:array of Cardinal;
Vendors:array of String;
cTime,cTime2:TDateTime;
procedure MoveRegs(WhereFind:Cardinal;WhereDown:Cardinal);
var
CurReg: Integer;
begin
  FindDistance:=2;
  CheckLag(LagWait);
  for CurReg:=0 to Length(RegTypes)-1 do begin
    if Dead or not Connected then Exit;
    CheckLag(LagWait);
    if WhereFind=Mount then begin
      FindTypeEx(RegTypes[CurReg],$0000,WhereFind,True);
    end
    else begin
      FindType(RegTypes[CurReg],WhereFind);
    end;
    while FindCount > 0 do begin
      if Dead or not Connected then Exit;
      CheckLag(LagWait);
      Wait(WaitTime);
      MoveItem(Finditem, GetQuantity(Finditem), WhereDown, 0, 0, 0);
      if WhereFind=Mount then begin
        FindTypeEx(RegTypes[CurReg],$0000,WhereFind,True);
      end
      else begin
        FindType(RegTypes[CurReg],WhereFind);
      end;
    end;
  end;
end;
function RecallRune(RuneBook: Cardinal; Rune: Byte):Boolean;
var
X,Y:Word;
begin
  Result:=False;
  X:=GetX(Self);
  Y:=GetY(Self);
  CheckLag(LagWait);
  Wait(WaitTime);
  if Dead or not Connected then Exit;
  cTime2:=Now;
  while (cTime2<cTime)do begin
    cTime2:=Now;
    wait(100);
  end;
  UseObject(RuneBook);
  CheckLag(LagWait);
  cTime:=Now+0.00008;
  if IsGump then begin
    if NumGumpButton(GetGumpsCount-1, RuneBookShift + 6*Rune) then begin
      CheckLag(LagWait);
      Wait(RecalTime);
      CheckLag(LagWait);
      Result:=(X<>GetX(Self)) or (Y<>GetY(Self));
    end else Result:=False;
  end else Result:=False;
end;
function GoBase: Boolean;
var
StartTime:TDateTime;
begin
  StartTime:=Now;
  Result:=RecallRune(HomeRuneBook, HomeRuneIndex);
  if InJournalBetweenTimes('That location is blocked', StartTime, Now) > 0 then GoBase;
end;
function GoBank: Boolean;
var
StartTime:TDateTime;
begin
  StartTime:=Now;
  Result:=RecallRune(HomeRuneBook, BankRuneIndex);
  if InJournalBetweenTimes('That location is blocked', StartTime, Now) > 0 then GoBank;
end;
function CheckJrnl: Boolean;
var
StartTime:TDateTime;
begin
  StartTime:=Now;
  if InJournalBetweenTimes('The World is saving, please wait.', StartTime, Now) > 0 then begin
  Result:=True;
  end
  else begin
    Result:=False;
  end;
end;
function NextRune: Boolean;
var
StartTime:TDateTime;
begin
  if CurrentRune>RuneAmount then begin
    IgnoreReset;
    CurrentRune:=0
    GoBase;
    MoveXY(HomeX,HomeY,true,0,true);
    Wait(WaitTime*2);
    UseSkill('Hiding');
    while not CheckJrnl do begin
      Wait(WaitTime*20);
    end;
    //Inc(CurrentBook);
    //if CurrentBook >= Length(RuneBooks) then CurrentBook := 0;
  end;
  StartTime:=Now;
  Result:=RecallRune(RuneBooks[CurrentBook], CurrentRune);
  if InJournalBetweenTimes('That location is blocked', StartTime, Now) > 0 then RecallRune(RuneBooks[CurrentBook], CurrentRune);
end;
procedure CheckGold;
var
X,Y,GoldCount:Word;
begin
  FindType(GoldType,backpack);
  GoldCount:=5000-FindFullQuantity;
  if FindFullQuantity>=5000 then exit;
  X:=GetX(Self);
  Y:=GetY(Self);
  if (X<>BankX)and(Y<>BankY) then GoBank;
  UOSay('withdraw '+IntToStr(GoldCount));
  Wait(WaitTime);
  FindType(GoldType,backpack);
  MoveItem(FindItem,FindQuantity,backpack,0,0,0);
  if FindFullQuantity < 5000 then begin
    Halt;
  end;
  RecallRune(RuneBooks[CurrentBook], CurrentRune);
end;
procedure LoadOnload;
begin
  if (BMCount=0) and (BPCount=0) and (GACount=0) and (GSCount=0) and (MRCount=0) and (NSCount=0) and (SACount=0) and (SSCount=0) then Exit;
  UseObject(self);
  Wait(WaitTime);
  CheckLag(LagWait);
  MoveRegs(backpack,Mount);
  MoveRegs(ground,Mount);
  Wait(WaitTime);
  UseObject(Mount);
  CheckLag(LagWait);
  GoBase;
  UseObject(self);
  Wait(WaitTime);
  CheckLag(LagWait);
  SetContextMenuHook(Mount,10);
  RequestContextMenu(Mount);
  MoveRegs(Mount,RegsStorage);
  Wait(WaitTime);
  UseObject(Mount);
  CheckLag(LagWait);
end;
function CheckVendor(Str:String):Boolean;
var
i:Byte;
begin
  for i:=0 to Length(Vendors)-1 do begin
    if Pos(Vendors[i],Str)>1 then begin
      Result:=True;
      Exit;
    end;
  end;
end;
Procedure Buy;
var
j:Byte;
VendorID:Cardinal;
VendorName:String;
X,Y:Word;
begin
  FindDistance:=8;
  Wait(WaitTime);
  CheckLag(LagWait);
  for j:=0 to Length(VendorTypes)-1 do begin
    if Dead or not Connected then Exit;
    CheckLag(LagWait);
    FindType(VendorTypes[j], ground);
    while FindCount>0 do begin
      if Invis then begin
        if (not Hidden) then begin
          Cast('Invisibility');
          WaitForTarget(2000);
          TargetToObject(self);
          Wait(WaitTime);
        end;
      end;
      VendorID:=Finditem;
      ClientPrint(GetCliloc(VendorID));
      VendorName:=AnsiLowerCase(GetCliloc(VendorID));
      if not CheckVendor(VendorName) then begin
        Ignore(VendorID);
        Wait(WaitTime);
        FindType(VendorTypes[j], ground);
        Continue;
      end;
      SetContextMenuHook(VendorID,1);
      RequestContextMenu(VendorID);
      Wait(WaitTime*2);
      CheckLag(LagWait);
      LoadOnload;
      CheckGold;
      X:=GetX(Self);
      Y:=GetY(Self);
      if ((X=BankX)and(Y=BankY) or (X=StorX)and(Y=StorY)) then RecallRune(RuneBooks[CurrentBook], CurrentRune);
      Ignore(VendorID);
      Wait(WaitTime);
      CheckLag(LagWait)
      FindType(VendorTypes[j], ground);
    end;
  end;
  Inc(CurrentRune);
end;
begin
  AddGumpIgnoreByID(4063159494);
  if not Connected() then begin
    Connect();
    Wait(10000);
  end;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  cTime:=Now;
  RuneBooks:=[$40274DF3]; //Рунабука с Регами
  RegTypes:=[$0F7A,$0F7B,$0F84,$0F85,$0F86,$0F88,$0F8C,$0F8D];
  VendorTypes:=[$029A,$029B,$0190,$0191];
  Vendors:=['mage','alchemist','herbalist','mystic','the reagent man','necromancer'];
  CurrentBook:=0;
  CurrentRune:=0;
  LoadOnload;
  for i:=0 to Length(RegTypes)-1 do begin
    AutoBuy(RegTypes[i],$0000,999);
  end;
  SetAutoBuyDelay:=1500;
  i:=0;
  CheckGold;
  while True do begin
    if Dead then begin
      Halt;
    end;
    if not Connected() then begin
      Connect();
      Wait(10000);
      Continue;
    end;
    NextRune;
    Buy;
  end;
end.