Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$I srl-6/srl.simba}
- /by rjj ~2016
- const
- USERNAME = '';
- CLIENTNAME = 'Runique';
- CLIENTWIDTH = 765;
- CLIENTHEIGHT = 525;
- EAT_AT = 650;
- DRINK_PRAYER_AT = 450;
- lootItems = ['Dragon bones', 'Draconic visage',
- 'Dragon platelegs', 'Dragon plateskirt', 'Runique chest key'];
- antiFireSTRING = 'mQwAAAHicY2ZgYDjMxMCwF4hPAnE6IwNDFBDHAHGZ8AygLCMUIwAjqigA6U8EmQ==';
- prayerSTRING = 'mQwAAAHicY2ZgYHBlYmDwAmJ7IHZmZGAwA2JzIHa/vAgoywjFCMCIKgoAlPADTA==';
- attackSTRING = 'mQwAAAHicY2ZgYDjCxMCwF4hPAHE3IwNDPRTbO10CyjJCMQIwoooCAAQ5BTc=';
- strengthSTRING = 'mQwAAAHicY2ZgYHBlYmDwBmJ7IF7PyMCwBIgXA/GFc+eAsoxgzMqAAIxIGAgA7AkFSA==';
- sharkSTRING = 'mWAAAAHicY2FgYChgYmDIB+IkIK4CYnNGBgZtILYEYjMgnteUDVTFCMesQBIZM6JhEAAAEHUEQw==';
- vialSTRING = 'mWAAAAHicY2FgYDjMxMBwAoj3AvEhIBZnZGAQgmI5IE5LzwSqYgTjmpoaBlYgCxkzomEQAACBAgY4';
- type
- TLOCATION = (SWBANK, NEWSPOT, DUNGEON, LOST);
- TDIRECTION = (NORTH, EAST, SOUTH, WEST);
- fnct_actionOptions = (ClickRight, ClickLeft, ClickMiddle, Move, Nothing);
- TOptions = record
- Str: string;
- Bounds, BigBox: TBox;
- end;
- TPOTIONTIMER = record
- potionDTM, lastSip, interval:integer;
- name:string;
- end;
- TRSInventory = record
- bounds:tbox;
- slots:TBoxArray;
- end;
- var
- antiFireDTM, prayerDTM, attackDTM, strengthDTM:integer;
- sharkDTM, vialDTM, lastPotion:integer;
- rsClient:TSysProc;
- inventory:TRSInventory;
- function boxCenter(bx: TBox): TPoint; begin if ((bx.X1 > bx.X2) or (bx.Y1 > bx.Y2)) then begin if(bx.X1 > bx.X2) then Swap(bx.X1, bx.X2); if (bx.Y1 > bx.Y2) then Swap(bx.Y1, bx.Y2); end; Result := Point(Round(bx.X1 + ((bx.X2 - bx.X1) div 2)), Round(bx.Y1 + ((bx.Y2 - bx.Y1) div 2))); end;
- function explodeBox(bx: TBox; rows, columns: integer): TBoxArray; var r, c, w, h, ew, eh, ow, oh, i, x, y: integer; begin if ((rows > 0) and (columns > 0) and(bx.X1 <= bx.X2) and (bx.Y1 <= bx.Y2)) then begin w := ((bx.X2 - bx.X1) + 1); h := ((bx.Y2 - bx.Y1) + 1); if (rows < 1) then rows := 1 else if (rows > h) then rows := h; if (columns < 1) then columns := 1 else if (columns > w) then columns := w; w := (w div columns); h := (h div rows); ew := (((bx.X2 - bx.X1) + 1) - (w * columns)); eh := (((bx.Y2 - bx.Y1) + 1) - (h * rows)); SetLength(result, (rows * columns)); y :=bx.Y1;for r := 0 to (rows - 1) do begin x := bx.X1; if ((eh > 0) and (r < eh)) then oh := 1 else oh := 0; for c := 0 to (columns - 1) do begin if ((ew > 0) and (c < ew)) then ow := 1 else ow := 0; i := ((r * columns) + c); result[i].X1 := x; result[i].X2 := (x + (w - 1) + ow); result[i].Y1 := y; result[i].Y2 := (y + (h - 1) + oh); x := (Result[i].X2 + 1); end;y := (result[i].Y2 + 1); end; end else SetLength(result, 0); end;
- function isText(Text, theText: TStringArray): Boolean;
- var
- i, k: Integer;
- begin
- for i := 0 to High(Text) do
- for k := 0 to high(theText) do
- if (Pos(Text[i], TheText[k]) > 0) then
- exit(true);
- end;
- procedure clickMouse2(button:integer);
- begin
- holdMouse(0, 0, button);
- wait(50);
- releaseMouse(0, 0, button);
- wait(10);
- end;
- procedure Mouse(T:TPoint)override;
- begin
- moveMouse(T);
- wait(100);
- clickMouse2(1);
- end;
- function getOptions(): Array of TOptions;
- var
- B, BB: TBox;
- TPA, restpa, blacktpa, newtpa, merged: TPointArray;
- ATPA, tempatpa, blackatpa, newatpa: T2DPointArray;
- I, L, target, bmp, w, h: Integer;
- BoxColors: TIntegerArray;
- begin
- target := GetImageTarget;
- GetClientDimensions(B.X2, B.Y2);
- B := IntToBox(0, 0, B.X2-1, B.Y2-1);
- BoxColors := [4674653];
- SetLength(ATPA, Length(BoxColors));
- FindColors(tpa, 4674653, b);
- If Length(tpa) < 100 Then
- exit;
- atpa := clusterTpa(tpa, 3);
- for i := 0 to High(ATPA) do
- begin
- B := GetTPABounds(ATPA[i]);
- if ((B.x2-B.x1) > 95) and ((B.y2-B.y1) > 18) then
- Break
- else
- B := IntToBox(0, 0, 0, 0);
- end;
- If (B.x2 = 0) then
- exit;
- findcolors(blacktpa, 0, b);
- if (length(blacktpa) < 1) then
- exit;
- blackatpa := clustertpa(blacktpa, 1);
- for i := 0 to high(blackatpa) do
- begin
- b := gettpaBounds(blackatpa[i]);
- if ((B.x2-B.x1) > 95) and ((B.y2-B.y1) > 16) then
- break
- else
- b := inttobox(0, 0, 0, 0);
- end;
- findcolors(newtpa, 4674653, b);
- if (length(newtpa) < 0) then
- exit;
- newatpa := clustertpa(newtpa, 1);
- b := gettpaBounds(newatpa[0]);
- findcolors(blacktpa, 0, b);
- merged := mergeAtpa([blacktpa, newtpa]);
- ReturnPointsNotInTPAWrap(merged, b, resTPA);
- bmp := CreateBitmap(b.X2-B.X1+2, b.Y2-b.Y1+2);
- OffsetTPA(restpa, Point(-B.X1, -B.Y1));
- FastDrawClear(bmp, 0);
- DrawTPABitmap(bmp, restpa, clRed);//Text
- GetbitmapSize(bmp, w, h);
- settargetbitmap(bmp);
- SetLength(newatpa, H div 16);
- for i := 0 to High(newatpa) do
- FindColorsTolerance(newatpa[i], 255, 0, 2+i*15, W-1, 15+i*15, 0);
- L := High(newatpa);
- SortATPAFromFirstPointY(newatpa, Point(w div 2,0));
- SetArrayLength(Result, Length(newatpa));
- Result[0].BigBox := b;
- for i := 0 to high(newatpa) do
- begin
- TPA := newatpa[i];
- tempatpa := SplitTPAEx(TPA, 1, 10);
- SortATPAFromFirstPointX(tempatpa, Point(0, 0));
- Result[i].Str := GetTextATPA(tempatpa, 4, 'UpChars07'); //Writeln(Result[i].Str);
- BB := GetTPABounds(newatpa[i]);
- Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
- setlength(tempatpa,0);
- setlength(TPA,0);
- end;
- SetImageTarget(target);
- FreeBitmap(bmp);
- end;
- function ArrInStr(arrS: TStringArray; str: string): Boolean;
- var
- I, L, H: Integer;
- begin
- Result := True;
- L := Low(arrS); H := High(arrS);
- for I := L to H do
- if Pos(arrS[I], Str) > 0 then
- Exit;
- Result := False;
- end;
- function chooseOptionMulti(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
- var
- B: TBox;
- i, H, x, R: Integer;
- T: TPoint;
- Options: array of TOptions;
- begin
- Result := False;
- Options := getOptions();
- if (Length(Options) < 1) then
- Exit;
- H := High(Options);
- for i := 0 To H do
- begin
- if ArrInStr(Texts, Options[i].Str) then
- begin
- Result := True;
- B := Options[i].Bounds;
- GetMousePos(T.x, T.y);
- R:= Min(((B.X2 - B.X1) shr 1), 5);
- case Action of
- ClickLeft:
- if PointInBox(T, B) then
- ClickMouse2(mouse_left)
- else
- Mouse(intToBox(B.x1 + R, B.Y1, B.x2 - R, B.Y1 + 5).getMiddle(), mouse_Left);
- Move:
- if not PointInBox(T, B) then
- Mouse(intToBox(B.x1 + R, B.Y1, B.x2 - R, B.Y1 + 5).getMiddle(), mouse_move);
- Nothing:
- begin
- end;
- else
- writeLn('ChooseOptionMultiEx ', ' ClickRight not a valid click for RS menus!');
- end;
- Exit;
- end;
- end;
- B := Options[0].BigBox;
- if Action <> Nothing then
- begin
- x := Max(B.X1 - 52, 0);
- if x = 0 then
- x := B.X2+10;
- MoveMouse(0, 0);
- Wait(200 + Random(100));
- end;
- end;
- function chooseOptionMulti(Txt: TStringArray): Boolean; overload;
- begin
- Result := chooseOptionMulti(Txt, 'All', ClickLeft);
- end;
- function chooseOption2(Txt, TextType: string): Boolean;
- begin
- Result := chooseOptionMulti([Txt], TextType, ClickLeft);
- end;
- function chooseOption2(Txt: String): Boolean; overload;
- begin
- Result := chooseOptionMulti([Txt], 'All', ClickLeft);
- end;
- function waitOptionMulti(S: TStringArray; TextType: string; Action: fnct_ActionOptions; Time: Integer): Boolean;
- var
- T: Integer;
- begin
- Result := False;
- T := GetSystemTime + Time;
- while (GetSystemTime < T) do
- begin
- if (chooseOptionMulti(S, TextType, Action)) then
- exit(true);
- Wait(20 + Random(10));
- end;
- end;
- function waitOptionMulti(S: TStringArray; Time: Integer): Boolean; overload;
- begin
- Result := waitOptionMulti(S, 'all', ClickLeft, Time);
- end;
- function waitOption(S: string; Time: Integer): Boolean; overload;
- begin
- Result := waitOptionMulti([s], 'all', ClickLeft, Time);
- end;
- procedure markTime(var t:Integer);
- begin
- t := getSystemTime;
- end;
- function timeFromMark(i:Integer):Integer;
- begin
- result := i - getSystemTime;
- end;
- procedure DebugBitmap2(Bmp: Integer);
- var
- W, H: Integer;
- begin
- try
- GetBitmapSize(Bmp, W, H);
- DisplayDebugImgWindow(W, H);
- DrawBitmapDebugImg(Bmp);
- except
- writeLn('DebugBitmap Error in DebugBitmap');
- end;
- end;
- (*
- Auther: Wizzup?
- Description: Shows an image of the Debug screen, plotting colors over the points
- stored in Points TPA. If a name is specified, an image will be saved to that path..
- *)
- function DebugTPA2(Points: TPointArray; BmpName: string): Boolean;
- var
- Bmp: integer;
- Box : TBox;
- TempTPA : TPointArray;
- begin
- Box := GetTPABounds(Points);
- Bmp := BitmapFromClient(Box.x1,Box.y1,Box.x2,Box.y2);
- TempTPA := CopyTPA(Points);
- OffsetTPA(TempTPA,Point(-box.x1,-box.y1));
- DrawTPABitmap(Bmp,TempTPA,clRed);
- DisplayDebugImgWindow(box.x2-Box.x1 + 1, box.y2-box.y1 + 1);
- DrawBitmapDebugImg(Bmp);
- if bmpname <> '' then
- SaveBitmap(Bmp, ScriptPath + BmpName + '.bmp');
- FreeBitmap(Bmp);
- Result := True;
- end;
- (*
- Auther: Wizzup?
- Description: Shows an image of the client, plotting each TPA of the 2D point
- array aPoints. Each TPA is a different color. If a name is specified, an image
- will be saved.
- *)
- function DebugATPA2(aPoints: T2DPointArray; BmpName: string): Boolean;
- var
- Width, Height, ClientBMP: Integer;
- ATPA : T2DPointArray;Box : TBox;
- begin
- result := false;
- if length(aPoints) = 0 then
- exit;
- Box := GetATPABounds(aPoints);
- Width := box.x2 - box.x1 + 1;
- Height := box.y2 - box.y1 + 1;
- DisplayDebugImgWindow(Width, Height);
- ClientBMP := BitmapFromClient(box.x1,box.y1,box.x2,box.y2);
- ATPA := CopyATPA(aPoints);
- OffsetATPA(ATPA,point(-box.x1,-box.y1));
- DrawATPABitmap(ClientBMP,ATPA);
- DrawBitmapDebugImg(ClientBMP);
- if BmpName <> '' then
- SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
- FreeBitmap(ClientBMP);
- Result := True;
- end;
- (*
- Auther: Wizzup?, lordsaturn, & caused
- Description: Shows an image of the client, plotting each TPA's bounds as a box
- of different colour per TPA. If a name is specified, an image will be saved.
- *)
- procedure DebugATPABounds2(aPoints: array Of TPointArray);
- var
- Width, Height, ClientBMP, I: Integer;
- B, Box: TBox;
- BoxColors : TIntegerArray;
- SelColor: Integer;
- x,y : integer;
- BMP : Integer;
- begin
- Box := GetATPABounds(aPoints);
- Width := Box.X2 + 5;
- Height := Box.Y2 + 5;
- DisplayDebugImgWindow(Width, Height);
- BoxColors := [clRed, clBlue, clBlack, clGreen, clYellow];
- ClientBMP := BitmapFromClient(0,0,width-1,height-1);
- for i:= 0 to high(aPoints) do
- begin
- SelColor := BoxColors[Random(length(Boxcolors))];
- B := getTPABounds(aPoints[i]);
- for x := B.x1 to B.x2 do
- begin
- FastSetPixel(ClientBMP, x, b.y1, selColor);
- FastSetPixel(ClientBMP, x, B.y2, selColor);
- end;
- for y := B.y1 to B.y2 do
- begin
- FastSetPixel(ClientBMP, B.x1, y, selColor);
- FastSetPixel(ClientBMP, B.x2, y, selColor);
- end;
- BMP := BitmapFromText(inttostr(i),StatChars);
- FastReplaceColor(bmp,clblack,clyellow);
- FastReplaceColor(bmp,clwhite,clblack);
- SetTransparentColor(bmp,clYellow);
- FastDrawTransparent(B.x1 + 2, b.y1 + 2, bmp,clientbmp);
- FreeBitmap(BMP);
- end;
- DrawBitmapDebugImg(clientBMP);
- FreeBitmap(ClientBmp);
- end;
- procedure state(s:string);
- begin
- clearDebug();
- writeln('=======================================');
- writeln('Dragons killed: 0| Per hour: 0');
- writeln('XP Gained: 0| Per hour: 0');
- writeln('State:', s);
- writeln('=======================================');
- end;
- procedure initInv();
- begin
- inventory.slots := explodeBox(inventory.bounds, 7, 4);
- end;
- function TRSInventory.getSlot(slot:integer):Tbox;
- begin
- result := self.slots[slot];
- end;
- function TRSInventory.slotFull(s:Integer):Boolean;
- var
- xee, yee:integer;
- begin
- result := FindColor(xee, yee, 65536, self.slots[s]);
- end;
- function TRSInventory.count:Integer;
- var
- i:Integer;
- begin
- for i := 0 to high(self.slots) do
- if self.slotFull(i) then
- result := result + 1;
- end;
- function TRSInventory.full:Boolean;
- begin
- result := false;
- exit(self.count = 28);
- end;
- function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
- var
- textTPA:TPointArray;
- textATPA, textATPAS:T2DPointArray;
- i:integer;
- textStr:string;
- begin
- setLength(textATPAS, length(colors));
- for i := 0 to high(colors) do
- findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
- textTPA := mergeATPA(textATPAS);
- textATPA := SplitTPAEx(textTPA, 1, 10);
- filtertpasbetween(textatpa, 0, 1);
- SortATPAFromFirstPointX(textATPA, Point(0, 0));
- result := getTextATPA(textATPA, 3, font);
- end;
- function getFightingMonster():string;
- begin
- result := getSimpleText([16777215], 33, 78, 142, 103, 'UpChars07');
- end;
- function inCombat(monster:string):boolean;
- begin
- result := getFightingMonster() = monster;
- end;
- function inCombat():boolean;overload;
- begin
- result := inCombat('Steel dragon');
- end;
- function getHealth():integer;
- begin;
- try
- result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 724, 72, 750, 90, 'statchars07'));
- except
- result := 0;
- end;
- end;
- function getPrayer():integer;
- begin;
- try
- result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 739, 112, 764, 130, 'statchars07'));
- except
- result := 0;
- end;
- end;
- function getXpBarTPA():TPointArray;
- begin
- findColors(result, 16777215, 424, 101, 519, 118);
- end;
- function getXpBarText():string;
- var
- textTPA:TPointArray;
- textATPA:T2DPointArray;
- begin
- textTPA := getXpBarTPA();
- textATPA := splittpaex(textTPA, 1, 10);
- filtertpasbetween(textatpa, 0, 1);
- SortATPAFromFirstPointX(textATPA, Point(0, 0));
- result := getTextATPA(textatpa, 3, 'smallchars07');
- end;
- function xpBarOpen():boolean;
- begin
- result := getXPBarText().contains('XP:');
- end;
- function getXpBarTotal():integer;
- var
- BARstring:string;
- begin
- BARstring := getXpBarText();
- BARstring := replace(BARstring, '''', '', [rfReplaceAll]);
- BARstring := replace(BARstring, 'XP:', '', [rfReplaceAll]);
- BARstring := replace(BARstring, ' ', '', [rfReplaceAll]);
- result := strtoInt(barString);
- end;
- function getLocation():TLOCATION;
- begin
- if (not isLoggedIn()) then
- exit
- else if (countColorTolerance(2678011, intToBox(550, 51, 717, 214), 1, colorSetting(2, 0.00, 0.00)) > 200) then
- result := SWBANK
- else if (countColorTolerance(0, intToBox(550, 51, 717, 214), 1, colorSetting(2, 0.00, 0.00)) > 500) and
- (countColorTolerance(2840425, intToBox(550, 51, 717, 214), 4, colorSetting(2, 0.24, 1.42)) > 600) then
- result := DUNGEON
- else
- result := LOST;
- end;
- procedure withdrawItems();
- begin
- wait(50);
- mouse(Point(189, 146), 1);
- wait(500);
- mouse(Point(232, 146), 1);
- wait(500);
- mouse(Point(277, 146), 1);
- wait(500);
- mouse(Point(321, 146), 1);
- wait(150);
- mouse(Point(321, 146), 1);
- wait(500);
- mouse(Point(366, 146), 1);
- wait(150);
- mouse(Point(366, 146), 1);
- wait(500);
- end;
- function bankOpen():boolean;
- begin
- result := getSimpleText([2070783], 180, 65, 312, 84, 'UpChars07') = 'The Bank of Runique';
- end;
- procedure bankAll();
- begin
- if bankOpen() then
- mouse(Point(356, 348), 1);
- end;
- procedure closeBank();
- begin
- if bankOpen() then
- mouse(Point(491, 75), 1);
- end;
- function findBank():boolean;
- var
- brownTPA, silverTPA:TPointArray;
- brownATPA, silverATPA:T2DPointArray;
- P:TPoint;
- i:integer;
- begin
- if findColorstolerancE(brownTPA, 6057341, intToBox(4, 47, 520, 384), 16, colorSetting(2, 0.05, 0.70)) then
- begin
- brownATPA := clusterTPA(brownTPA, 10);
- filterTPAsbetween(brownATPA, 0, 500);
- for i := 0 to high(brownATPA) do
- if findColorsTolerance(silverTPA, 11250613, brownATPA[i].getBounds(), 14, colorSetting(2, 0.15, 0.11)) then
- begin
- silverATPA := clusterTPA(silverTPA, 10);
- for i := 0 to high(silverATPA) do
- begin
- p := silverATPA[i].getBounds().getMiddle();
- mouse(p, 0);
- if waitOption('Use', 1000) then
- if waitFunc(@bankOpen, 40, 4000) then
- exit(true)
- else
- begin
- mouse(Point(0, 0), 0);
- wait(100);
- end;
- end;
- //debugATPABounds2(silverATPA);
- end;
- end;
- end;
- function teleportTo(place:TLOCATION):boolean;
- var
- t:integer;
- begin
- wait(50);
- mouse(Point(504, 512));
- wait(500);
- case place of
- SWBANK : sendKeys('MS', 75, 75);
- DUNGEON: sendKeys('DB', 75, 75);
- end;
- markTime(t);
- repeat
- wait(100)
- until (getLocation() = place) or timeFromMark(t) > 3500;
- wait(1700);
- end;
- procedure makeCompassHigh;
- begin
- keyDown(vk_up);
- wait(2000);
- keyUp(vk_up);
- end;
- function tileToCoords(Location, Tile:TPoint):TPoint;
- begin
- if (Tile.x - Location.x > 17) or (Location.y - Tile.y > 17) then
- begin
- Result := Point(-1, -1);
- exit;
- end;
- result.x := ((Tile.x - Location.x) * 4) + 630;
- result.y := ((Location.y - Tile.y) * 4) + 132;
- end;
- function getTile():TPoint;
- var
- s:string;
- begin
- sendKeys('::mypos', 30, 300);
- pressKey(vk_enter);
- wait(700);
- s := getSimpleText([0], 13, 491, 105, 506, 'smallchars07');
- if s.contains('[') then
- begin
- try
- result.x := strToInt(between('[', '''', s));
- result.y := strtoInt(between(''' ','''',s));
- except
- result := Point(-1, -1);
- end;
- end;
- state('Tile has been read at ' + toStr(result));
- end;
- function walkTile(p:TPoint):boolean;
- var
- T:TPoint;
- begin
- T := tileToCoords(getTile(), p);
- if (T.X <> -1) then
- begin
- mouse(T, 1);
- wait(3000);
- result := true;
- end;
- end;
- function seeDragon(var p:TPoint):boolean;
- var
- dragonTPA:TPointArray;
- dragonATPA:T2DPointArray;
- i:integer;
- begin
- findColorstolerance(dragonTPA, 8620443, intToBox(7, 49, 517, 383), 14, colorSetting(2, 0.32, 0.53));
- dragonATPA := clusterTPA(dragonTPA, 8);
- filterTPAsbetween(dragonATPA, 0, 350);
- sortATPAFrom(dragonATPA, Point(336, 309));
- for i := 0 to high(dragonATPA) do
- if ((dragonATPA[i].getBounds().getWidth() > 90) and (dragonATPA[i].getBounds().getHeight() > 90)) then
- begin
- p := dragonATPA[i].getBounds().getMiddle();
- result := true;
- end;
- end;
- function seeDragon():boolean; overload;
- var
- p:TPoint;
- begin
- result := seeDragon(p);
- end;
- procedure walkToSpot;
- begin
- walkTile(Point(2704, 9459));
- waitFunc(@seeDragon, 40, 4000);
- end;
- function findDragon():boolean;
- var
- T:TPoint;
- begin
- if seeDragon(T) then
- begin
- result := true;
- mouse(t);
- end;
- end;
- function string.contains(s: string): Boolean;
- begin
- if ((self <> '') and (s <> '')) then
- result := (pos(s, self) > 0)
- else
- result := False;
- end;
- function getOptionsString():TStringArray;
- var
- t:array of Toptions;
- i:integer;
- begin
- t := getOptions();
- setLength(result, length(t));
- for i := 0 to high(t) do
- result[i] := t[i].str;
- end;
- function validDropMenu():boolean;
- var
- i:integer;
- t:TStringArray;
- begin
- t := getOptionsString();
- for i := 0 to high(t) do
- if lowercase(t[i]).contains('take dragon bones') then
- exit(true);
- end;
- function getDropCount():integer;
- var
- i, k:integer;
- t:tStringArray;
- begin
- t := getOptionsString();
- for i := 0 to high(lootItems) do
- for k := 0 to high(t) do
- if lowercase(t[k]).contains(lowercase('Take ' + lootItems[i])) then
- result := result + 1;
- end;
- procedure pickUpItems();
- var
- redDotsTPA, groundTPA, objectsTPA:TPointArray;
- redDotsATPA, groundATPA, objectsATPA:T2DPointArray;
- itemsOnGround:TStringArray;
- nearestDirection, nearestDrop, me:TPoint;
- i, dx, dy, dropCount:integer;
- begin
- me := Point(630, 132);
- findColorsTolerance(redDotsTPA, 1776620, 630 - 30, 132 - 30, 630 + 30, 132 + 30, 43);
- redDotsATPA := clusterTPA(redDotsTPA, 1);
- filterTPAsBetween(redDotsATPA, 25, 200);
- sortATPAFrom(redDotsATPA, Point(630, 132));
- if (length(redDotsATPA) > 0) then
- begin
- nearestDrop := redDotsATPA[0].getBounds().getMiddle();
- findColorsTolerance(groundTPA, 2312279, intToBox(7, 49, 517, 383), 6, colorSetting(2, 0.18, 1.06));
- groundATPA := clusterTPA(groundTPA, 3);
- filterTPAsbetween(groundATPA, 0, 700);
- objectsTPA := returnPointsNotInTPA(mergeATPA(groundATPA), intToBox(7, 49, 517, 383));
- objectsATPA := clusterTPA(objectsTPA, 2);
- filterTPAsbetween(objectsATPA, 400, 50000);
- dx := me.x - nearestDrop.x;
- dy := me.y - nearestDrop.y;
- if abs(dx) > abs(dy) then
- begin
- if (dx < 0) then
- nearestDirection := Point(me.x + 15,me.y)
- else nearestDirection := Point(me.x - 15,me.y);
- end else
- if abs(dx) < abs(dy) then
- begin
- if (dy < 0) then
- nearestDirection := Point(me.x ,me.y + 15)
- else
- nearestDirection := Point(me.x ,me.y - 15)
- end else
- nearestDirection := me;
- sortATPAFromFirstPoint(objectsATPA, nearestDirection);
- for i := 0 to high(objectsATPA) do
- begin
- mouse(objectsATPA[i].getBounds().getMiddle(), 0);
- wait(250);
- if (validDropMenu()) then
- begin
- dropCount := getDropCount();
- if waitOptionMulti(lootItems, 1000) then
- begin
- dropCount := dropCount - 1;
- state('Drop count:' + toStr(dropCount));
- for i := 0 to dropCount do
- begin
- mouse(Point(265, 230), 0);
- if waitOptionMulti(lootItems, 1000) then
- wait(750);
- end;
- end;
- exit();
- end else
- begin
- moveMouse(0, 0);
- wait(150);
- end;
- end;
- end;
- end;
- function activateRsClient(firstTime:boolean):boolean;
- var
- processes: TSysProcArr;
- i: integer;
- begin
- result := false;
- processes := GetProcesses();
- if (firstTime) then
- writeln('Scanning for ' , CLIENTNAME , 'Client..');
- for i := 0 to high(processes) do
- if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
- begin
- if (firstTime) then
- begin
- writeln('Found client');
- writeln('Target set to: ' , toStr(processes[i]));
- end;
- rsClient := processes[i];
- setTarget(processes[i]);
- ActivateClient();
- exit(true);
- end;
- end;
- function getClientName():string;
- begin
- activateRsClient(false);
- result := rsClient.title;
- end;
- function isLoggedIn():boolean; override;
- begin
- if (USERNAME = '') then
- begin
- writeln('Please enter a username at the top of the script');
- terminateScript();
- end else
- result := getClientName().contains(USERNAME);
- end;
- function loginPlayer():boolean;
- begin
- writeln('logging in player');
- end;
- procedure TRSInventory.interactItem(const slot, Button:Integer);
- begin
- if (self.slotFull(slot)) then
- mouse(boxCenter(self.slots[slot]).x, boxCenter(self.slots[slot]).y, 0, 0, BUTTON);
- end;
- function TRSInventory.DTMExists(const DTM, slot:integer):boolean;
- var
- x, y:integer;
- begin
- result := findDTM(DTM, x, y, self.slots[slot].X1, self.slots[slot].y1, self.slots[slot].x2, self.slots[slot].y2);
- end;
- function TRSInventory.countDTM(const DTMSearch:Integer):Integer;
- var
- i:Integer;
- begin
- for i := 0 to high(self.slots) do
- if (self.DTMExists(dtmSearch, i)) then
- result := result + 1;
- end;
- function TRSInventory.countDTM(const DTMSearch:TIntegerArray):integer; overload;
- var
- i:integer;
- begin
- for i := 0 to high(DTMSearch) do
- result := result + self.countDTM(DTMsearch[i]);
- end;
- function TRSInventory.searchDTM(const DTMSearch:Integer;click, cont:Boolean;button:Integer):Boolean;
- var
- i:Integer;
- begin
- for i := 0 to high(self.slots) do
- begin
- if self.DTMExists(dtmSearch, i) then
- begin
- result := true;
- if click then
- self.interactItem(i, button);
- if not cont then
- exit;
- end;
- end;
- end;
- function TRSInventory.searchDTM(const DTMSearch:Integer;cont:Boolean;button:Integer):Boolean; overload;
- var
- I:Integer;
- begin
- result := false;
- for i := 0 to high(self.slots) do
- begin
- if self.DTMExists(dtmSearch, i) then
- begin
- result := true;
- self.interactItem(i, button);
- if not cont then
- exit;
- end;
- end;
- end;
- function TRSInventory.searchDTM(const DTMSearch:Integer;button:Integer):Boolean; overload;
- var
- I, x, y:Integer;
- begin
- result := false;
- for i := 0 to high(self.slots) do
- begin
- if self.DTMExists(dtmSearch, i) then
- begin
- self.interactItem(i, button);
- exit(true);
- end;
- end;
- end;
- function TRSInventory.searchDTM(const DTMSearch:TIntegerarray;button:Integer):boolean; overload;
- var
- i:integer;
- begin
- for i := 0 to high(DTMSearch) do
- if inventory.searchDTM(DTMSearch[i], true, false, 1) then
- exit(true);
- end;
- function inventoryReady():boolean;
- var
- i:integer;
- prayPotCount:integer;
- begin
- result := inventory.countDTM([antiFireDTM, prayerDTM, attackDTM, strengthDTM, sharkDTM, vialDTM]) = 7;
- end;
- function needEatOrPray():boolean;
- begin
- if (getHealth < EAT_AT) or (getPrayer < DRINK_PRAYER_AT) then
- result := true;
- end;
- function checkHealthPray():boolean;
- begin
- if (getHealth < EAT_AT) then
- begin
- inventory.searchDTM(sharkDTM, 1);
- result := true;
- wait(500);
- end;
- if (getPrayer < DRINK_PRAYER_AT) then
- begin
- result := true;
- inventory.searchDTM(prayerDTM, 1);
- end;
- if (timeFromMark(lastPotion) > 300000) then
- begin
- markTime(lastPotion);
- inventory.searchDTM(attackDTM, 1);
- wait(1000);
- inventory.searchDTM(strengthDTM, 1);
- wait(1200);
- inventory.searchDTM(antiFireDTM, 1);
- wait(350);
- end;
- end;
- function prayOn():boolean;
- var
- x, y:integer;
- begin
- result := findColorTolerance(x, y, 13956822, 720, 108, 733, 125, 2);
- end;
- procedure togglePrayer();
- begin
- mouse(Point(728, 116));
- end;
- procedure initDTMz();
- begin
- antiFireDTM := DTMFromString(antiFireSTRING);
- prayerDTM := DTMFromString(prayerSTRING);
- attackDTM := DTMFromString(attackSTRING);
- strengthDTM := DTMFromString(strengthSTRING);
- sharkDTM := DTMFromString(sharkSTRING);
- vialDTM := DTMFromString(vialSTRING);
- end;
- procedure freememory;
- begin
- freeDTM(antiFireDTM);
- freeDTM(prayerDTM);
- freeDTM(attackDTM);
- freeDTM(strengthDTM);
- freeDTM(sharkDTM);
- freeDTM(vialDTM);
- end;
- function checkHealthPray2():boolean;
- begin
- if (getPrayer < DRINK_PRAYER_AT) then
- begin
- inventory.searchDTM(prayerDTM, 1);
- wait(3000);
- end;
- end;
- procedure loop();
- var
- t, d, sharkAmount, i:integer;
- begin
- if (not isLoggedIn()) then
- exit;
- case getLocation() of
- SWBANK:
- begin
- if prayOn() then
- togglePrayer();
- closeBank();
- if needEatOrPray() then
- begin
- if findBank() then
- begin
- bankAll();
- state('Healing');
- sharkAmount := round((900 - getHealth())/200);
- for i := 0 to sharkAmount do
- begin
- mouse(Point(364, 139), 1);
- wait(250);
- end;
- mouse(Point(320, 147), 1);
- wait(400);
- closeBank();
- markTime(t);
- repeat
- if (getPrayer() < 600) then
- inventory.searchDTM(prayerDTM, 1)
- else if (getHealth() < 800) then
- inventory.searchDTM(sharkDTM, 1)
- else begin
- state('Finished healing');
- break;
- end;
- until timeFromMark(t) > 10000;
- wait(750);
- inventory.searchDTM(prayerDTM, 1);
- wait(500);
- end;
- end;
- if (inventory.count() > 7) or (not inventoryReady()) then
- begin
- if findBank() then
- begin
- state('Banking items');
- bankAll();
- withdrawItems();
- closeBank();
- end;
- end else if inventoryReady() then
- begin
- state('Teleporting to dungeon');
- teleportTo(DUNGEON);
- walkToSpot;
- end;
- begin
- state('Inventory not ready');
- if findBank() then
- begin
- state('Banking all items');
- bankAll();
- withdrawItems();
- closeBank();
- end;
- end;
- end;
- DUNGEON:
- begin
- if (not prayOn()) then
- togglePrayer();
- if (getHealth() < 200) or (getPrayer() < 100) then
- begin
- state('Low health teleporting to bank');
- teleportTo(SWBANK);
- end
- else if (inventory.count() > 15) then
- teleportTo(SWBANK)
- else if seeDragon() then
- begin
- markTime(d);
- repeat
- if findDragon() then
- begin
- state('Found dragon');
- waitFunc(@inCombat, 150, 3500);
- if getFightingMonster() = 'Steel dragon' then
- begin
- state('We are fighting the dragon');
- markTime(t);
- while inCombat() do
- begin
- state('We will just check if health is low');
- checkHealthPray;
- if (timeFromMark(t) > 75000) then
- begin
- state('Woah took too long to kill dragon');
- exit;
- end;
- end;
- inventory.searchDTM(vialDTM, 0);
- waitOption('rop', 800);
- if (inventory.Full() or inventory.count = 27) then
- begin
- inventory.searchDTM([antiFireDTM, prayerDTM, attackDTM, strengthDTM, sharkDTM, vialDTM], 1);
- waitOption('rop', 800);
- wait(350);
- inventory.searchDTM([antiFireDTM, prayerDTM, attackDTM, strengthDTM, sharkDTM, vialDTM], 1);
- waitOption('rop', 800);
- end;
- pickUpItems();
- waitOption('rop', 800);
- writeln('waiting for dragon to spawn');
- waitFunc(@seeDragon, 40, 15000);
- end;
- end else
- begin
- state('Can not find dragon');
- wait(200);
- end;
- Until (inventory.full()) or (timeFromMark(d) > 10000000);
- end else
- begin
- teleportTo(DUNGEON);
- walkToSpot;
- end;
- end;
- LOST:
- begin
- state('Lost, teleporting to soulwars bank');
- teleportTo(SWBANK);
- wait(3500);
- end;
- end;
- end;
- begin
- initDTMz();
- addOnTerminate('freememory');
- activateRsClient(true);
- wait(1500);
- inventory.bounds := IntTobox(567, 259, 722, 506);
- initInv();
- repeat
- checkHealthPray2();
- wait(2000);
- until false;
- lastPotion := -1000000;
- repeat
- wait(100);
- loop;
- until isKeyDown(113);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement