Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.20 KB | None | 0 0
  1. program cooking;
  2. {$DEFINE SMART}
  3. {$I SRL-6/SRL.simba}
  4. {$I sps/lib/sps-rs3.simba}
  5.  
  6. var
  7. _totalEXP, food_cooked, food_burnt: integer;
  8. cook_walk: TSPSArea;
  9. paths: T2DPointArray;
  10.  
  11. const
  12. USE_DirectX = false;
  13.  
  14. procedure declarePlayers;
  15. begin
  16. setLength(players, 1);
  17. with players[0] do
  18. begin
  19. loginName := '';
  20. bankPin := '';
  21. password := '';
  22. integers[0] := 1;//slot containing food to cook
  23. extendeds[0]:= 120;//exp per item
  24. isActive := true;
  25. isMember := true;
  26. world := -1;
  27. end;
  28. currentPlayer := 0;
  29. end;
  30.  
  31. procedure initPaths;
  32. begin
  33. cook_walk.setup('cook_spot', '', __DEFAULT_ACCURACY, __DEFAULT_TOLERANCE, 0.7);
  34. setLength(paths, 3);
  35. //to bank
  36. paths[0] := [Point(90, 164), Point(94, 171), Point(102, 178), Point(114, 173), Point(117, 159), Point(119, 141), Point(114, 119), Point(110, 107), Point(95, 104)];
  37.  
  38. //to the north dock
  39. paths[1] := [Point(97, 166), Point(97, 173), Point(98, 179), Point(123, 180), Point(126, 152), Point(114, 136), Point(112, 116), Point(98, 106)];
  40.  
  41. //to the south dock
  42. paths[2] := [Point(94, 166), Point(118, 162), Point(118, 144), Point(104, 124), Point(97, 109), Point(94, 104)];
  43. end;
  44.  
  45. function location: TPoint;
  46. var
  47. places: TPointArray;
  48. bankD, rangeD: integer;
  49. begin
  50. result := cook_walk.getPlayerPos;
  51. players[currentPlayer].location := '';
  52. if result.equals([-1, -1]) then exit;
  53.  
  54. rangeD := distance(result, Point(95, 104));
  55. bankD := distance(result, Point(90, 164));
  56.  
  57. if (rangeD < 15) then players[currentPlayer].location := 'range' else
  58. if (bankD < 15) then players[currentPlayer].location := 'bank';
  59. status(players[currentPlayer].location);
  60. end;
  61.  
  62. function walk(bank: boolean): boolean;
  63. var
  64. our_path: TPointArray;
  65. ourPos: TPoint;
  66. threshold: integer;
  67. n: integer;
  68. begin
  69. ourPos := location;
  70. if ourPos.equals([-1, -1]) then exit;
  71.  
  72. our_path := paths[random(length(paths))].copy;
  73. if bank then invertTPA(our_path);
  74.  
  75. threshold := getSystemTime + randomRange(45000, 65000);
  76. repeat
  77. if cook_walk.walkPath(our_path) then minimap.waitPlayerMoving();
  78. wait(randomRange(250, 500));
  79. ourPos := location;
  80. until ((distance(our_path[high(our_path)], ourPos) < 12)) or (getSystemTime > threshold);
  81. result := (threshold > getSystemTime);
  82. end;
  83.  
  84. //this function returns the closest point in the array to the center of the arra
  85. function TPointArray.centerPoint(): TPoint;
  86. var
  87. tmpArray: TPointArray;
  88. begin
  89. if length(self) < 1 then exit;
  90. tmpArray := self;
  91. tmpArray.sortFromPoint(self.getMiddle);
  92. result := tmpArray[0];
  93. end;
  94.  
  95.  
  96. //This just ensures that the option window gets closed
  97. function TRSChooseOption.close2(): boolean;
  98. var
  99. t: integer;
  100. begin
  101. t := getSystemTime + randomRange(2000,3000);
  102. while (t > getSystemTime) do if self.isOpen then self.close else exit(true);
  103. end;
  104.  
  105. //This function will find all colors close to the range color and split them into
  106. //TPA's by width and height, a use range function will call this one
  107. function findRange: T2DPointArray;
  108. var
  109. rangeTPA: TPointArray;
  110. begin
  111. if findColorsTolerance(rangeTPA, 4146611, mainscreen.getBounds, 4, colorSetting(2, 0.06, 0.53)) then
  112. result := rangeTPA.toATPA(15, 15);
  113. sortATPAFromMidPoint(result, mainscreen.playerPoint);
  114. end;
  115.  
  116. function useRange: boolean;
  117. var
  118. range: T2DPointArray;
  119. pont: TPoint;
  120. i, h, timer: integer;
  121. begin
  122. range := findRange;
  123. if (length(range) < 1) then exit;
  124. h := high(range);
  125. for i := 0 to h do
  126. begin
  127. if productionScreen.isOpen then exit(productionScreen.clickStart);
  128. if (length(range[i]) < 5) then continue;
  129. pont := range[i].centerPoint;
  130. mouse(pont.rand(-3, 3), Mouse_Right, Mouse_Human);
  131. if chooseOption.select(['-> Range'], randomRange(1000, 4000)) then
  132. begin
  133. minimap.waitPlayerMoving();
  134. timer := getSystemTime + randomRange(3000, 6000);
  135. repeat
  136. wait(randomRange(100, 400));
  137. until (productionScreen.isOpen) or (getSystemTime > timer);
  138. end;
  139. end else chooseOption.close2;
  140. end;
  141.  
  142. function doneButton: boolean;
  143. var
  144. bluePoints: TPointArray;
  145. blueArea: TBox;
  146. begin
  147. blueArea := [244,197, 335, 223];
  148. findColorsTolerance(bluePoints, 13278759, blueArea, 44);
  149. result := length(bluePoints) > 145;
  150. end;
  151.  
  152. procedure whileCooking;
  153. var
  154. blkCount: TPointArray;
  155. count, threshold: integer;
  156. begin
  157. threshold := getSystemTime + randomRange(70000, 80000);
  158. repeat
  159. wait(randomRange(255, 555));
  160. if doneButton then
  161. begin
  162. threshold := getSystemTime + randomRange(2500, 3500);
  163. repeat
  164. wait(randomRange(255, 555));
  165. if not(doneButton) then exit;
  166. until (getSystemTime > threshold);
  167. end;
  168. until (getSystemTime > threshold);
  169. end;
  170.  
  171. //This function will find all colors close to the banker color and split them into
  172. //TPA's by width and height, a use bank function will call this one
  173. function findBankers: T2DPointArray;
  174. var
  175. bankerTPA: TPointArray;
  176. begin
  177. if findColorsTolerance(bankerTPA, 2450798, mainscreen.getBounds, 14, colorSetting(2, 0.09, 1.31)) then
  178. result := bankerTPA.toATPA(15, 15);
  179. sortATPAFromMidPoint(result, mainscreen.playerPoint);
  180. end;
  181.  
  182. function useBank: boolean;
  183. var
  184. bankers: T2DPointArray;
  185. pont: TPoint;
  186. i, h, timer: integer;
  187. begin
  188. bankers := findBankers;
  189. if (length(bankers) < 1) then exit;
  190. h := high(bankers);
  191. for i := 0 to h do
  192. begin
  193. if (length(bankers[i]) < 5) then continue;
  194. pont := bankers[i].centerPoint;
  195. mouse(pont.rand(-3, 3), Mouse_Right, Mouse_Human);
  196. if chooseOption.select(['Bank Banker', 'Bank Bank', 'nk Banker'], randomRange(1000, 4000)) then
  197. begin
  198. minimap.waitPlayerMoving();
  199. timer := getSystemTime + randomRange(3000, 6000);
  200. repeat
  201. wait(randomRange(100, 400));
  202. until (bankscreen.isOpen) or (pinscreen.isOpen) or (getSystemTime > timer);
  203. if pinscreen.isOpen then pinScreen.enter(players[currentPlayer].bankPin);
  204. if bankscreen.isOpen then exit(true);
  205. end else chooseOption.close2;
  206. end;
  207. end;
  208.  
  209. function cook_count: TPoint
  210. var
  211. i, invcount, x, y: integer;
  212. clrFound: boolean;
  213. begin
  214. tabBackpack.open;
  215. invcount := tabBackpack.count;
  216. clrFound := findColor(x, y, 65535, tabBackpack.getBounds);
  217. case invcount of
  218. 0: result := [0, 0];
  219. 1..27: result := [invcount-1, 29-invcount];
  220. 28: if clrFound then result := [27, 1] else result := [28, 0];
  221. end;
  222. end;
  223.  
  224. procedure printProgress;
  225. var
  226. secondsElapsed, expPHour, totalEXP: extended;
  227. food: TPoint;
  228. begin
  229. food := cook_count;
  230.  
  231. food_cooked := food_cooked + food.x;
  232. food_burnt := food_burnt + food.y;
  233.  
  234. totalEXP := food_cooked * players[currentPlayer].extendeds[0];
  235. secondsElapsed := (getTimeRunning/1000);
  236. expPHour := (totalEXP * 60 * 60) / secondsElapsed;
  237.  
  238. smartImage.clearArea(intToBox(576, 200, 798, 278));
  239. smartImage.drawBox(intToBox(576, 200, 798, 278), true, 7890014);
  240.  
  241. smartImage.DrawText('Run Time: ' + msToTime(GetTimeRunning, TIME_SHORT), Point(618, 224), upchars, false, 1376386);
  242. smartImage.DrawText('EXP/Hour: ' + toString(round(expPHour)), Point(618, 234), upchars, false, 1376386);
  243. smartImage.DrawText('Total EXP: ' + toString(totalEXP), Point(618, 244), upchars, false, 1376386);
  244. smartImage.DrawText('Items cooked: ' + toString(food_cooked), Point(618, 254), upchars, false, 1376386);
  245. smartImage.DrawText('Items burnt: ' + toString(food_burnt), Point(618, 264), upchars, false, 1376386);
  246. end;
  247.  
  248. function handleBanking: boolean;
  249. begin
  250. printProgress;
  251. if waitFunc(@useBank, 100, randomRange(20000,30000)) then
  252. begin
  253. bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
  254. if bankscreen.withdraw(players[currentPlayer].integers[0], WITHDRAW_AMOUNT_ALL_BUT_ONE, ['']) then
  255. result := bankscreen.close;
  256. end;
  257. end;
  258.  
  259. procedure prepareSelf;
  260. begin
  261. wait(random(500, 1500));
  262. minimap.clickCompass;
  263. wait(random(500, 1500));
  264. mainscreen.setAngle(MS_ANGLE_HIGH);
  265. wait(random(1, 1500));
  266. end;
  267.  
  268. procedure mainLoop;
  269. var
  270. loc: TPoint;
  271. begin
  272.  
  273. if not isLoggedIn then
  274. begin
  275. print('We''re not logged in. respawning client.');
  276. wait(randomRange(5000, 10000));
  277. smartReloadClient((5 * 60000) + random(15000));
  278.  
  279. if (waitClientReady()) then
  280. begin
  281. print('Client succesfully loaded after reload');
  282. end else
  283. begin
  284. print('Client never reloaded after restart..', TDebug.FATAL);
  285. terminateScript;
  286. end;
  287. if not players[currentPlayer].isActive then players.next(false);
  288. if players[currentPlayer].login then prepareSelf;
  289. if not isLoggedIn then
  290. begin
  291. writeln('Terminating, not logged in.');
  292. terminateScript;
  293. end;
  294. end;
  295.  
  296. loc := location;
  297. if loc.equals([-1, -1]) then exit;
  298. wait(randomRange(1, 300));
  299. if walk(true) then
  300. if handleBanking then
  301. if walk(false) then
  302. if tabBackpack.mouseSlot(randomRange(10, 28), mouse_left) then
  303. if useRange then whileCooking;
  304. end;
  305.  
  306. begin
  307.  
  308. if USE_DirectX then smartPlugins := ['d3d9.dll'];
  309.  
  310. smartEnableDrawing := true;
  311. setupsrl;
  312. declarePlayers;
  313. initPaths;
  314.  
  315. if not isLoggedIn then if players[currentPlayer].login then prepareSelf;
  316.  
  317. while players.getActive > 0 do mainLoop;
  318. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement