Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program AloraGemStallThiever;
- {$I AeroLib/AeroLib.simba}
- {$define MOUSE_HOPPING} (* <-- Remove or comment out this line to disable mouse hopping *)
- const
- USER = '';
- PASS = '';
- type
- tThieveObj = record
- _Color: TColEx;
- _UpTexts: TStringArray;
- _Options: TStringArray;
- end;
- tOddItem = record
- _Name: String;
- _Class: String;
- _pixel: TIntegerArray;
- _Point: TPoint;
- end;
- var
- Ali, Stall: tThieveObj;
- Gem, Cash: TItem;
- Fails: Integer;
- tOddArray: array of tOddItem := [
- ['Shield', 'Armor', [2374, 1854, 2331], Point( - 1, - 1)], ['Helmet', 'Armor', [1038], Point( - 1, - 1)], ['Axe', 'Weapon', [1196], Point( - 1, - 1)], ['Sword', 'Weapon', [424], Point( - 1, - 1)], ['Shears', 'Garden', [876], Point( - 1, - 1)], ['Shovel', 'Garden', [876], Point( - 1, - 1)], ['B Fish', 'Fish', [3135, 2541], Point( - 1, - 1)], ['S Fish', 'Fish', [2300, 2279], Point( - 1, - 1)], ['Ring', 'Jewelry', [686], Point( - 1, - 1)], ['Necklace', 'Jewelry', [364], Point( - 1, - 1)]
- ];
- {$IFDEF MOUSE_HOPPING}
- procedure mouse(Pnt: TPoint; rX, rY, clickType: Integer); override;
- begin
- moveMouse(pnt.x + RandomRange(-rx, rx), pnt.y + RandomRange(-ry, ry));
- wait(randomRange(50,150));
- fastClick(clickType);
- end;
- {$ENDIF}
- procedure tThieveObj.Init();
- begin
- with Ali do
- begin
- _Color := createCol(12371140, 19, 0.13, 0.09);
- _UpTexts := ['li Morr', 'orrisane'];
- _Options := ['rade Al', 'e Ali Mor'];
- end;
- with Stall do
- begin
- _Color := createCol(9150637, 9, 0.06, 0.55);
- _UpTexts := ['teal-fr', 'al-from'];
- _Options := ['teal-fr', 'al-from'];
- end;
- end;
- procedure freeMemory();
- begin
- freeDTM(Cash.DTM);
- freeDTM(Gem.DTM);
- end;
- procedure Load();
- begin
- initAL();
- MouseSpeed := 50;
- tThieveObj.init();
- Gem.DTM := DTMFromString('mWAAAAHicY2FgYKhjYmAoB+JmKOZlZGDgA2IhIOYB4pOHDjEsnjOHoSg7i2HO1KkMXEA9rEiYEQ2DAAD5NwmX');
- Cash.DTM := DTMFromString('mbQAAAHicY2VgYFjAxMAwE4jXQvF8IF7MyMCwHIjXAfF8KL6+XhKM72yWZDi/Qpzh81EZBkmgfnTMiAWDAQAZvg9H');
- addonterminate('freeMemory');
- end;
- function lobbyScreen(): boolean;
- begin
- result := findTextTPA(0, 3, IntToBox(270, 37, 401, 55), 'are', SmallChars07, -1);
- end;
- function shopOpen(): boolean;
- begin
- result := findTextTPA(2070783, 3, IntToBox(210, 30, 315, 52), 'ievin', UpChars07, -1);
- end;
- function seeRandom(): boolean;
- var
- col: TColEx;
- begin
- col.create(6758413, 20);
- result := (col.count(IntToBox(171, 356, 337, 390)) > 50);
- end;
- {====== odd methods =======}
- function tOddItem.Click():Boolean;
- begin
- if (Self._point.x > 0) then
- begin
- writeln('Clicking ' + self._name);
- Mouse(self._point, 0, 0, MOUSE_LEFT);
- result := true;
- end else
- result := false;
- end;
- Procedure tOddItem.resetAll();
- var
- I : Integer;
- begin
- for I := low(tOddArray) to high(tOddArray) do
- if (tOddArray[I]._point.x > 0) then
- tOddArray[I]._point := Point(-1, -1);
- end;
- Function tOddItem.getOddOneOut(): tOddItem;
- var
- I: Integer;
- Arr: array of tOddItem;
- begin
- Arr := [];
- for I := low(tOddArray) to high(tOddArray) do
- begin
- if (tOddArray[I]._point.x > 0) then
- begin
- setLength(Arr, Length(Arr) + 1);
- Arr[High(Arr)] := tOddArray[I];
- end;
- end;
- if (Length(Arr) <> 3) then exit;
- if (Arr[0]._class = Arr[1]._class) then
- result := Arr[2]
- else if (Arr[1]._class = Arr[2]._class) then
- result := Arr[0]
- else
- result := Arr[1];
- end;
- (* this func is messy af i know :^) *)
- Function tOddItem.Solve(): Boolean;
- var
- Boxes: TboxArray;
- pixCount, tempCount,
- I, J, K, X, Y: Integer;
- Time: Timer;
- Col: TColEx;
- gem_slots: TIntegerArray;
- TPA: TPointArray;
- function opBounds(): tbox;
- var
- B : tbox;
- boxCol : TColEx;
- TPA : TPointArray;
- begin
- getClientDimensions(B.X2, B.Y2);
- boxCol.create(4674653,0);
- B := toBox(0, 0, B.X2 - 1, B.Y2 - 1);
- boxCol.findAllIn(B, TPA);
- if (length(TPA) < 75) then
- Exit;
- result := TPA.getBounds();
- end;
- begin
- result := false;
- tOddItem.resetAll();
- Boxes := [
- IntToBox(14, 361, 168, 467),
- IntToBox(175, 361, 336, 467),
- IntToBox(350, 361, 498, 467)
- ];
- for I := 0 to high(Boxes) do
- begin
- Time.Start();
- Col.create(3169904, 27, 0.05, 0.50);
- pixCount := 0;
- if (not (Col.findAllIn(AREA_MS, TPA))) then exit;
- repeat
- tempCount := Col.count(Boxes[I]);
- if (tempCount > pixCount) then
- pixCount := tempCount;
- //writeln(pixCount);
- until(Time.TimeElapsed > 2200);
- for J := low(tOddArray) to high(tOddArray) do
- begin
- for K := low(tOddArray[J]._pixel) to high(tOddArray[J]._pixel) do
- if (InRange(tOddArray[J]._pixel[K], pixCount - 2, pixCount + 2)) then
- begin
- tOddArray[J]._point := Boxes[I].MidPoint;
- writeln('Found item "' + tOddArray[J]._name + '" in ', Boxes[I]);
- break;
- end;
- end;
- end;
- if (not tOddItem.getOddOneOut().Click) then
- begin
- writeln('Could not solve random, clicking middle box');
- Mouse(IntToBox(175, 361, 336, 467).MidPoint, 0, 0, MOUSE_LEFT);
- end;
- Time.start();
- while ((seeRandom) and (Time.TimeElapsed < 5000)) do
- sleep(50);
- result := (not seeRandom());
- if (result) then
- begin
- gem_slots := gem.getSlots();
- for i := 2 to 28 do
- if (itemInSlot(i)) and (cash.getSlot() <> i) and (not InIntArray(gem_slots, i)) then
- if interactSlot(i, MOUSE_RIGHT) then
- if (findText(x, y, 'rop', 'UpChars07', opBounds)) then
- mouse(Point(x + 3, y + 3), 0, 0, mouse_left);
- end;
- end;
- {===============}
- function Login(): Boolean;
- var
- i: integer;
- label
- lobby;
- begin
- result := false;
- if (lobbyScreen()) then
- goTo lobby;
- Mouse(Point(337, 231), 0, 0, Mouse_LEFT);
- wait(250);
- i := 0;
- repeat
- Inc(i);
- PressKey(VK_Back);
- until (i > 40);
- wait(250);
- typesend(User, false);
- wait(250);
- Presskey(9);
- wait(250);
- i := 0;
- repeat
- Inc(i);
- PressKey(VK_Back);
- until (i > 40);
- wait(250);
- typesend(Pass, false);
- wait(250);
- Mouse(Point(300, 300), 0, 0, Mouse_LEFT);
- waitfunc(@lobbyScreen, 100, 20000);
- lobby:
- if (lobbyScreen) then
- Mouse(Point(382, 327), 0, 0, Mouse_LEFT)
- else
- exit;
- if waitFunc(@isloggedin, 200, 20000) then
- begin
- sleep(250);
- toggleRunning(true);
- setAngle(ANGLE_HIGH);
- result := true;
- end;
- end;
- procedure randomCompass();
- var
- Keys: TIntegerArray;
- I: Integer;
- begin
- Keys := [VK_RIGHT, VK_LEFT];
- I := Random(0, 1);
- Wait(100 + random(50));
- KeyDown(Keys[I]);
- Wait(500 + random(1000));
- KeyUp(Keys[I]);
- Wait(200 + random(350));
- end;
- function Ali.Trade(): Boolean;
- var
- TPA: TPointArray;
- ATPA: T2DPointArray;
- found: Boolean;
- i: integer;
- begin
- result := false;
- found := false;
- self._Color.FindAllIn(Area_MS, TPA);
- if (length(TPA) < 1) then exit;
- ATPA := ClusterTPAEx(TPA, 12, 12);
- FilterTPAsBetween(ATPA, 0, 120);
- if (length(ATPA) < 1) then exit;
- for i := low(ATPA) to high(ATPA) do
- begin
- if (length(ATPA[i]) < 15) then
- continue;
- mouse(ATPA[i].midPnt, 0, 0, MOUSE_MOVE);
- if (waitUpTextMulti(self._UpTexts, 200)) then
- begin
- fastClick(MOUSE_RIGHT);
- if (waitOptionMulti(self._Options, 200)) then
- begin
- found := true;
- break;
- end;
- end;
- end;
- if (not found) then exit;
- result := waitFunc(@shopOpen, 25, 5000);
- end;
- function Ali.Sell(): Boolean;
- var
- slots: TIntegerArray;
- i, c, t: Integer;
- begin
- result := false;
- slots := Gem.getSlots();
- {doing it this way because sometimes it fails to see options in some slots}
- for i := low(slots) to high(slots) do
- begin
- if (not (itemInSlot(slots[i]))) then exit(true); //just incase
- c := getInvCount();
- mouse(invBox(slots[i]).MidPoint, 0, 0, MOUSE_RIGHT);
- if (waitOptionMulti(['ll-50', '-50'], 250)) then
- begin
- result := true;
- t := (getTimeRunning() + 8000);
- while (c = getInvCount()) and (getTimeRunning() < t) do
- sleep(50);
- break;
- end;
- end;
- writeln(result);
- end;
- function Ali.Close(): Boolean;
- var
- t: Integer;
- begin
- mouse(Point(486, 42), 0, 0, MOUSE_LEFT);
- t := (getTimeRunning() + 8000);
- while (shopOpen()) and (getTimeRunning() < t) do
- sleep(200 + random(150));
- result := not ShopOpen();
- end;
- function Stall.Interact(): Boolean;
- var
- TPA: TPointArray;
- ATPA: T2DPointArray;
- begin
- result := false;
- self._Color.FindAllIn(Area_MS, TPA);
- if (length(TPA) < 1) then exit;
- ATPA := FloodFillTPA(TPA);
- FilterTPAsBetween(ATPA, 0, 250);
- SortATPASize(ATPA, true);
- if (length(ATPA) < 1) then exit;
- Mouse((ATPA[0].MidPnt), 5, 5, MOUSE_MOVE);
- if (waitUpTextMulti(self._UpTexts, 200)) then
- fastClick(MOUSE_LEFT)
- else
- begin
- fastClick(MOUSE_RIGHT);
- if (not (waitOptionMulti(self._Options, 200))) then exit;
- end;
- result := didRedClick();
- end;
- function GetState(): Integer;
- begin
- if (not isLoggedIn()) then
- exit(0);
- if (seeRandom()) then
- exit(1);
- if (ShopOpen()) then
- if (IsInvFull) then
- exit(2)
- else
- exit(3);
- case (IsInvFull) of
- true : exit(4);
- false: exit(5);
- end;
- end;
- procedure Execute();
- var
- State: Variant;
- begin
- sleep(50);
- case (GetState) of
- 0: State := Login();
- 1: State := tOddItem.Solve();
- 2: State := Ali.Sell();
- 3: State := Ali.Close();
- 4: State := Ali.Trade();
- 5: State := Stall.Interact();
- end;
- if (not State) and (isLoggedIn()) then
- begin
- writeln('Failed to perform state... rotating compass');
- randomCompass();
- inc(Fails);
- end else
- Fails := 0;
- if (Fails > 5) then (* At this point it is assumed that we failed a random or were teled/moved off the map *)
- begin
- typesend('::thieve', true);
- sleep(5000);
- end;
- end;
- begin
- Load();
- if (isLoggedIn()) then
- begin
- toggleRunning(true);
- setAngle(ANGLE_HIGH);
- if ((getCurrentTab() = TAB_INV) and (Cash.getSlot() <> 1) and (Cash.inInventory())) then
- moveItemTo(Cash.getSlot(), 1);
- end;
- while (true) do
- Execute();
- end.
Add Comment
Please, Sign In to add comment