Guest User

Untitled

a guest
May 15th, 2017
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.19 KB | None | 0 0
  1. program AloraGemStallThiever;
  2. {$I AeroLib/AeroLib.simba}
  3. {$define MOUSE_HOPPING} (* <-- Remove or comment out this line to disable mouse hopping *)
  4.  
  5. const
  6. USER = '';
  7. PASS = '';
  8.  
  9. type
  10. tThieveObj = record
  11. _Color: TColEx;
  12. _UpTexts: TStringArray;
  13. _Options: TStringArray;
  14. end;
  15.  
  16. tOddItem = record
  17. _Name: String;
  18. _Class: String;
  19. _pixel: TIntegerArray;
  20. _Point: TPoint;
  21. end;
  22.  
  23. var
  24. Ali, Stall: tThieveObj;
  25. Gem, Cash: TItem;
  26.  
  27. Fails: Integer;
  28. tOddArray: array of tOddItem := [
  29. ['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)]
  30. ];
  31.  
  32. {$IFDEF MOUSE_HOPPING}
  33. procedure mouse(Pnt: TPoint; rX, rY, clickType: Integer); override;
  34. begin
  35. moveMouse(pnt.x + RandomRange(-rx, rx), pnt.y + RandomRange(-ry, ry));
  36. wait(randomRange(50,150));
  37. fastClick(clickType);
  38. end;
  39. {$ENDIF}
  40.  
  41. procedure tThieveObj.Init();
  42. begin
  43. with Ali do
  44. begin
  45. _Color := createCol(12371140, 19, 0.13, 0.09);
  46. _UpTexts := ['li Morr', 'orrisane'];
  47. _Options := ['rade Al', 'e Ali Mor'];
  48. end;
  49. with Stall do
  50. begin
  51. _Color := createCol(9150637, 9, 0.06, 0.55);
  52. _UpTexts := ['teal-fr', 'al-from'];
  53. _Options := ['teal-fr', 'al-from'];
  54. end;
  55. end;
  56.  
  57. procedure freeMemory();
  58. begin
  59. freeDTM(Cash.DTM);
  60. freeDTM(Gem.DTM);
  61. end;
  62.  
  63. procedure Load();
  64. begin
  65. initAL();
  66. MouseSpeed := 50;
  67. tThieveObj.init();
  68. Gem.DTM := DTMFromString('mWAAAAHicY2FgYKhjYmAoB+JmKOZlZGDgA2IhIOYB4pOHDjEsnjOHoSg7i2HO1KkMXEA9rEiYEQ2DAAD5NwmX');
  69. Cash.DTM := DTMFromString('mbQAAAHicY2VgYFjAxMAwE4jXQvF8IF7MyMCwHIjXAfF8KL6+XhKM72yWZDi/Qpzh81EZBkmgfnTMiAWDAQAZvg9H');
  70. addonterminate('freeMemory');
  71. end;
  72.  
  73. function lobbyScreen(): boolean;
  74. begin
  75. result := findTextTPA(0, 3, IntToBox(270, 37, 401, 55), 'are', SmallChars07, -1);
  76. end;
  77.  
  78. function shopOpen(): boolean;
  79. begin
  80. result := findTextTPA(2070783, 3, IntToBox(210, 30, 315, 52), 'ievin', UpChars07, -1);
  81. end;
  82.  
  83. function seeRandom(): boolean;
  84. var
  85. col: TColEx;
  86. begin
  87. col.create(6758413, 20);
  88. result := (col.count(IntToBox(171, 356, 337, 390)) > 50);
  89. end;
  90.  
  91. {====== odd methods =======}
  92.  
  93. function tOddItem.Click():Boolean;
  94. begin
  95. if (Self._point.x > 0) then
  96. begin
  97. writeln('Clicking ' + self._name);
  98. Mouse(self._point, 0, 0, MOUSE_LEFT);
  99. result := true;
  100. end else
  101. result := false;
  102. end;
  103.  
  104. Procedure tOddItem.resetAll();
  105. var
  106. I : Integer;
  107. begin
  108. for I := low(tOddArray) to high(tOddArray) do
  109. if (tOddArray[I]._point.x > 0) then
  110. tOddArray[I]._point := Point(-1, -1);
  111. end;
  112.  
  113. Function tOddItem.getOddOneOut(): tOddItem;
  114. var
  115. I: Integer;
  116. Arr: array of tOddItem;
  117. begin
  118. Arr := [];
  119. for I := low(tOddArray) to high(tOddArray) do
  120. begin
  121. if (tOddArray[I]._point.x > 0) then
  122. begin
  123. setLength(Arr, Length(Arr) + 1);
  124. Arr[High(Arr)] := tOddArray[I];
  125. end;
  126. end;
  127. if (Length(Arr) <> 3) then exit;
  128. if (Arr[0]._class = Arr[1]._class) then
  129. result := Arr[2]
  130. else if (Arr[1]._class = Arr[2]._class) then
  131. result := Arr[0]
  132. else
  133. result := Arr[1];
  134. end;
  135.  
  136. (* this func is messy af i know :^) *)
  137. Function tOddItem.Solve(): Boolean;
  138. var
  139. Boxes: TboxArray;
  140. pixCount, tempCount,
  141. I, J, K, X, Y: Integer;
  142. Time: Timer;
  143. Col: TColEx;
  144. gem_slots: TIntegerArray;
  145. TPA: TPointArray;
  146. function opBounds(): tbox;
  147. var
  148. B : tbox;
  149. boxCol : TColEx;
  150. TPA : TPointArray;
  151. begin
  152. getClientDimensions(B.X2, B.Y2);
  153. boxCol.create(4674653,0);
  154. B := toBox(0, 0, B.X2 - 1, B.Y2 - 1);
  155. boxCol.findAllIn(B, TPA);
  156. if (length(TPA) < 75) then
  157. Exit;
  158. result := TPA.getBounds();
  159. end;
  160. begin
  161. result := false;
  162. tOddItem.resetAll();
  163. Boxes := [
  164. IntToBox(14, 361, 168, 467),
  165. IntToBox(175, 361, 336, 467),
  166. IntToBox(350, 361, 498, 467)
  167. ];
  168. for I := 0 to high(Boxes) do
  169. begin
  170. Time.Start();
  171. Col.create(3169904, 27, 0.05, 0.50);
  172. pixCount := 0;
  173. if (not (Col.findAllIn(AREA_MS, TPA))) then exit;
  174. repeat
  175. tempCount := Col.count(Boxes[I]);
  176. if (tempCount > pixCount) then
  177. pixCount := tempCount;
  178. //writeln(pixCount);
  179. until(Time.TimeElapsed > 2200);
  180. for J := low(tOddArray) to high(tOddArray) do
  181. begin
  182. for K := low(tOddArray[J]._pixel) to high(tOddArray[J]._pixel) do
  183. if (InRange(tOddArray[J]._pixel[K], pixCount - 2, pixCount + 2)) then
  184. begin
  185. tOddArray[J]._point := Boxes[I].MidPoint;
  186. writeln('Found item "' + tOddArray[J]._name + '" in ', Boxes[I]);
  187. break;
  188. end;
  189. end;
  190. end;
  191. if (not tOddItem.getOddOneOut().Click) then
  192. begin
  193. writeln('Could not solve random, clicking middle box');
  194. Mouse(IntToBox(175, 361, 336, 467).MidPoint, 0, 0, MOUSE_LEFT);
  195. end;
  196. Time.start();
  197. while ((seeRandom) and (Time.TimeElapsed < 5000)) do
  198. sleep(50);
  199. result := (not seeRandom());
  200. if (result) then
  201. begin
  202. gem_slots := gem.getSlots();
  203. for i := 2 to 28 do
  204. if (itemInSlot(i)) and (cash.getSlot() <> i) and (not InIntArray(gem_slots, i)) then
  205. if interactSlot(i, MOUSE_RIGHT) then
  206. if (findText(x, y, 'rop', 'UpChars07', opBounds)) then
  207. mouse(Point(x + 3, y + 3), 0, 0, mouse_left);
  208. end;
  209. end;
  210.  
  211. {===============}
  212.  
  213. function Login(): Boolean;
  214. var
  215. i: integer;
  216. label
  217. lobby;
  218. begin
  219. result := false;
  220. if (lobbyScreen()) then
  221. goTo lobby;
  222. Mouse(Point(337, 231), 0, 0, Mouse_LEFT);
  223. wait(250);
  224. i := 0;
  225. repeat
  226. Inc(i);
  227. PressKey(VK_Back);
  228. until (i > 40);
  229. wait(250);
  230. typesend(User, false);
  231. wait(250);
  232. Presskey(9);
  233. wait(250);
  234. i := 0;
  235. repeat
  236. Inc(i);
  237. PressKey(VK_Back);
  238. until (i > 40);
  239. wait(250);
  240. typesend(Pass, false);
  241. wait(250);
  242. Mouse(Point(300, 300), 0, 0, Mouse_LEFT);
  243. waitfunc(@lobbyScreen, 100, 20000);
  244. lobby:
  245. if (lobbyScreen) then
  246. Mouse(Point(382, 327), 0, 0, Mouse_LEFT)
  247. else
  248. exit;
  249. if waitFunc(@isloggedin, 200, 20000) then
  250. begin
  251. sleep(250);
  252. toggleRunning(true);
  253. setAngle(ANGLE_HIGH);
  254. result := true;
  255. end;
  256. end;
  257.  
  258. procedure randomCompass();
  259. var
  260. Keys: TIntegerArray;
  261. I: Integer;
  262. begin
  263. Keys := [VK_RIGHT, VK_LEFT];
  264. I := Random(0, 1);
  265. Wait(100 + random(50));
  266. KeyDown(Keys[I]);
  267. Wait(500 + random(1000));
  268. KeyUp(Keys[I]);
  269. Wait(200 + random(350));
  270. end;
  271.  
  272. function Ali.Trade(): Boolean;
  273. var
  274. TPA: TPointArray;
  275. ATPA: T2DPointArray;
  276. found: Boolean;
  277. i: integer;
  278. begin
  279. result := false;
  280. found := false;
  281.  
  282. self._Color.FindAllIn(Area_MS, TPA);
  283. if (length(TPA) < 1) then exit;
  284. ATPA := ClusterTPAEx(TPA, 12, 12);
  285.  
  286. FilterTPAsBetween(ATPA, 0, 120);
  287. if (length(ATPA) < 1) then exit;
  288.  
  289. for i := low(ATPA) to high(ATPA) do
  290. begin
  291. if (length(ATPA[i]) < 15) then
  292. continue;
  293. mouse(ATPA[i].midPnt, 0, 0, MOUSE_MOVE);
  294. if (waitUpTextMulti(self._UpTexts, 200)) then
  295. begin
  296. fastClick(MOUSE_RIGHT);
  297. if (waitOptionMulti(self._Options, 200)) then
  298. begin
  299. found := true;
  300. break;
  301. end;
  302. end;
  303. end;
  304.  
  305. if (not found) then exit;
  306. result := waitFunc(@shopOpen, 25, 5000);
  307. end;
  308.  
  309. function Ali.Sell(): Boolean;
  310. var
  311. slots: TIntegerArray;
  312. i, c, t: Integer;
  313. begin
  314. result := false;
  315. slots := Gem.getSlots();
  316. {doing it this way because sometimes it fails to see options in some slots}
  317. for i := low(slots) to high(slots) do
  318. begin
  319. if (not (itemInSlot(slots[i]))) then exit(true); //just incase
  320. c := getInvCount();
  321. mouse(invBox(slots[i]).MidPoint, 0, 0, MOUSE_RIGHT);
  322. if (waitOptionMulti(['ll-50', '-50'], 250)) then
  323. begin
  324. result := true;
  325. t := (getTimeRunning() + 8000);
  326. while (c = getInvCount()) and (getTimeRunning() < t) do
  327. sleep(50);
  328. break;
  329. end;
  330. end;
  331. writeln(result);
  332. end;
  333.  
  334. function Ali.Close(): Boolean;
  335. var
  336. t: Integer;
  337. begin
  338. mouse(Point(486, 42), 0, 0, MOUSE_LEFT);
  339. t := (getTimeRunning() + 8000);
  340. while (shopOpen()) and (getTimeRunning() < t) do
  341. sleep(200 + random(150));
  342. result := not ShopOpen();
  343. end;
  344.  
  345. function Stall.Interact(): Boolean;
  346. var
  347. TPA: TPointArray;
  348. ATPA: T2DPointArray;
  349. begin
  350. result := false;
  351. self._Color.FindAllIn(Area_MS, TPA);
  352. if (length(TPA) < 1) then exit;
  353.  
  354. ATPA := FloodFillTPA(TPA);
  355. FilterTPAsBetween(ATPA, 0, 250);
  356. SortATPASize(ATPA, true);
  357. if (length(ATPA) < 1) then exit;
  358.  
  359. Mouse((ATPA[0].MidPnt), 5, 5, MOUSE_MOVE);
  360. if (waitUpTextMulti(self._UpTexts, 200)) then
  361. fastClick(MOUSE_LEFT)
  362. else
  363. begin
  364. fastClick(MOUSE_RIGHT);
  365. if (not (waitOptionMulti(self._Options, 200))) then exit;
  366. end;
  367. result := didRedClick();
  368. end;
  369.  
  370. function GetState(): Integer;
  371. begin
  372. if (not isLoggedIn()) then
  373. exit(0);
  374. if (seeRandom()) then
  375. exit(1);
  376. if (ShopOpen()) then
  377. if (IsInvFull) then
  378. exit(2)
  379. else
  380. exit(3);
  381. case (IsInvFull) of
  382. true : exit(4);
  383. false: exit(5);
  384. end;
  385. end;
  386.  
  387. procedure Execute();
  388. var
  389. State: Variant;
  390. begin
  391. sleep(50);
  392. case (GetState) of
  393. 0: State := Login();
  394. 1: State := tOddItem.Solve();
  395. 2: State := Ali.Sell();
  396. 3: State := Ali.Close();
  397. 4: State := Ali.Trade();
  398. 5: State := Stall.Interact();
  399. end;
  400. if (not State) and (isLoggedIn()) then
  401. begin
  402. writeln('Failed to perform state... rotating compass');
  403. randomCompass();
  404. inc(Fails);
  405. end else
  406. Fails := 0;
  407. if (Fails > 5) then (* At this point it is assumed that we failed a random or were teled/moved off the map *)
  408. begin
  409. typesend('::thieve', true);
  410. sleep(5000);
  411. end;
  412. end;
  413.  
  414. begin
  415. Load();
  416. if (isLoggedIn()) then
  417. begin
  418. toggleRunning(true);
  419. setAngle(ANGLE_HIGH);
  420. if ((getCurrentTab() = TAB_INV) and (Cash.getSlot() <> 1) and (Cash.inInventory())) then
  421. moveItemTo(Cash.getSlot(), 1);
  422. end;
  423. while (true) do
  424. Execute();
  425. end.
Add Comment
Please, Sign In to add comment