Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.52 KB | None | 0 0
  1. program Anth_Herblore;
  2. {$DEFINE SMART}
  3. {$i AeroLib/AeroLib.Simba}
  4. {$i Reflection/Reflection.Simba}
  5.  
  6. type
  7. EPotType = (guam, mrntl, tmin, hldr, rnrr, tdflx, irit,
  8. avnt, kwrm, snpdr, cdtne, lntdme, dwarf, trstl); // Cheers Olly
  9.  
  10. const
  11. P_USERNAME = '';
  12. P_PASSWORD = '';
  13. P_PIN = '';
  14.  
  15. POT_TO_MAKE = rnrr; // One above ^^^
  16. CLEAN = 'yes'; // {yes, no, only}
  17.  
  18. BANKTYPE = 'chest';
  19. // (booth, npc, chest, cellar}
  20.  
  21. ScriptVersion = '1.1';
  22.  
  23. // BREAK SETTINGS - Thank you Flight!
  24. USEBREAKS = true;
  25. cBREAK_IN = 120; // How long before we take a break? (minutes)
  26. cBREAK_FOR = 15; // How long will we break for? (minutes)
  27. cR_BREAK_IN = 25; // Random minutes to add/subtract from how long until we break
  28. cR_BREAK_FOR = 15; // Random minutes to add/subjtract from break duraction
  29.  
  30. type
  31. TPotInfo = record
  32. toClean: String;
  33. Cleaned: String;
  34. UnfPot: String;
  35. XP: Extended;
  36. end;
  37. TPotInfoArray = array of TPotInfo;
  38.  
  39. const
  40. PotInfo: TPotInfoArray = [
  41. ['Grimy guam leaf', 'Guam leaf', 'Guam potion (unf)', 2.5],
  42. ['Grimy marentill', 'Marrentill', 'Marrentill potion (unf)', 3.8],
  43. ['Grimy tarromin', 'Tarromin', 'Tarromin potion (unf)', 5],
  44. ['Grimy harralander', 'Harralander', 'Harralander potion (unf)', 6.3],
  45. ['Grimy ranarr weed', 'Ranarr weed', 'Ranarr potion (unf)', 7.5],
  46. ['Grimy toadflax', 'Toadflax', 'Toadflax potion (unf)', 8],
  47. ['Grimy irit leaf', 'Irit leaf', 'Irit potion (unf)', 8.8],
  48. ['Grimy avantoe', 'Avantoe', 'Avantoe potion (unf)', 10],
  49. ['Grimy kwuarm', 'Kwuarm', 'Kwuarm potion (unf)', 11.3],
  50. ['Grimy snapdragon', 'Snapdragon', 'Snapdragon potion (unf)', 11.8],
  51. ['Grimy cadantine', 'Cadantine', 'Cadantine potion (unf)', 12.5],
  52. ['Grimy lantadyme', 'Lantadyme', 'Lantadyme potion (unf)', 13.1],
  53. ['Grimy dwarf weed', 'Dwarf weed', 'Dwarf weed potion (unf)', 13.8],
  54. ['Grimy torstol', 'Torstol', 'Torstol potion (unf)', 15]];
  55.  
  56. var
  57. info: TPotInfo;
  58. LocP: TReflectLocalPlayer;
  59. VialB, GHerbB, CHerbB: TReflectBankItem;
  60. VialI, GHerbI, CHerbI, PotI: TReflectInvItem;
  61. Grimies: TReflectInvItemArray;
  62. TotalDone, TotalCleaned, x, y: Integer;
  63. XP: Extended;
  64. ToClean, Cleaned, UnfPot: string;
  65. pnt: TPoint;
  66. T: TReflectTimer;
  67.  
  68. procedure declarePlayer();
  69. begin
  70. Me.Name := P_USERNAME;
  71. Me.Pass := P_PASSWORD;
  72. Me.Pin := P_PIN;
  73. Me.Nick := '';
  74. Me.Active := True;
  75. Me.Member := True;
  76. end;
  77.  
  78. procedure Draw(text: string);
  79. var
  80. DonePH, XPPH, CleanedPH: integer;
  81. TillBreak, BreakNo, DoingBreak: string;
  82. FillBox: TBox;
  83. begin
  84. DonePH := Round(((TotalDone) * 3600) / (GetTimeRunning / 1000));
  85. XPPH := Round(((TotalCleaned * XP) * 3600) / (GetTimeRunning / 1000));
  86. CleanedPH := Round(((TotalCleaned) * 3600) / (GetTimeRunning / 1000));
  87. TillBreak := 'Time until break: ' + msToTime(getTimeUntilBreak(), Time_Bare);
  88. DoingBreak := 'Time breaking for: ' + msToTime(break_RealTime, Time_Bare);
  89. BreakNo := 'Breaks Taken: ' + IntToStr(break_Count);
  90. FillBox := InttoBox(5, 345, 515, 502);
  91. OS_Smart.__Graphics.Clear;
  92. OS_Smart.__Graphics.DrawBox(FillBox, True, clNavy);
  93. OS_Smart.__Graphics.DrawClippedText('Status : ' + text, 'SmallChars', point(350, 365), clGray);
  94. OS_Smart.__Graphics.DrawClippedText('AHerblore - Version. ' + ScriptVersion, 'SmallChars', point(10, 365), clGray);
  95. OS_Smart.__Graphics.DrawClippedText('Run Time : ' + TimeRunning, 'SmallChars', point(10, 385), clGray);
  96. OS_Smart.__Graphics.DrawClippedText(IntToStr(TotalDone) + ' Total Done ', 'SmallChars', point(10, 405), clGray);
  97. OS_Smart.__Graphics.DrawClippedText(IntToStr(DonePH) + ' Done (P/H)', 'SmallChars', point(350, 405), clGray);
  98. OS_Smart.__Graphics.DrawClippedText(IntToStr(TotalCleaned) + ' Total Cleaned ', 'SmallChars', point(10, 425), clGray);
  99. OS_Smart.__Graphics.DrawClippedText(IntToStr(CleanedPH) + ' Cleaned (P/H) ', 'SmallChars', point(350, 425), clGray);
  100. OS_Smart.__Graphics.DrawClippedText(Floattostr(TotalCleaned * XP) + ' Herblore exp gained.', 'SmallChars', point(10, 445), clGray);
  101. OS_Smart.__Graphics.DrawClippedText(IntToStr(XPPH) + ' Herblore XP (P/H)', 'SmallChars', point(350, 445), clGray);
  102. OS_Smart.__Graphics.DrawClippedText(TillBreak, 'SmallChars', point(10, 465), clGray);
  103. OS_Smart.__Graphics.DrawClippedText(DoingBreak, 'SmallChars', point(10, 485), clGray);
  104. OS_Smart.__Graphics.DrawClippedText(BreakNo, 'SmallChars', point(350, 485), clGray);
  105. end;
  106.  
  107. procedure setupPlayer();
  108. begin
  109. Draw('Logging In');
  110. if (not isLoggedIn()) then
  111. loginPlayer(false);
  112. if (isLoggedIn()) then
  113. begin
  114. setAngle(ANGLE_HIGH);
  115. LocP.Active := True;
  116. LocP.Create;
  117. end;
  118. end;
  119.  
  120. procedure setup();
  121. begin
  122. setupPlayer();
  123. mouseSpeed := Random(18, 25);
  124. writeln('MouseSpeed set at: ' + intToStr(mouseSpeed));
  125. setupBreak(cBREAK_IN, cBREAK_FOR, cR_BREAK_IN, cR_BREAK_FOR);
  126. info := PotInfo[Ord(POT_TO_MAKE)];
  127. end;
  128.  
  129. procedure customMouse(point: TPoint);
  130. begin
  131. case random(0, 6) of
  132. 0..2: BrakeMMouse(point, random(2), random(2), true);
  133. 3: BrakeMMouse(point, random(2), random(2), false);
  134. 4..5: MissMouse(point, random(2), random(2));
  135. 6: HumanMMouse(point, random(2), random(2));
  136. end;
  137. end;
  138.  
  139. procedure beHuman(i: Integer);
  140. begin
  141. if not (pointInBox(getMousePnt(), intToBox(1, 1, 765, 500))) then
  142. exit;
  143. case Random(I) of
  144. 0..3: MMouseoffClient('rand');
  145. 4..5: hoverSkill(SKILL_HERBLORE, false);
  146. 5..20: SleepAndMoveMouse(200 + Random(2000));
  147. end;
  148. end;
  149.  
  150. procedure L_Click();
  151. begin
  152. sleep(20 + random(100));
  153. FastClick(Mouse_Left);
  154. end;
  155.  
  156. procedure R_Click(upstr: string; upwait: integer; textstr: string; waiti: integer);
  157. begin
  158. if (waitUptext(upstr, upwait)) then
  159. begin
  160. sleep(20 + random(30));
  161. fastClick(MOUSE_RIGHT);
  162. WaitOption(textstr, waiti);
  163. end;
  164. end;
  165.  
  166. procedure C_Click(upstr: string; upwait: integer; textstr: string; waiti: integer);
  167. begin
  168. case random(0, 12) of
  169. 0..11: L_Click;
  170. 12: R_Click(upstr, upwait, textstr, waiti);
  171. end;
  172. end;
  173.  
  174. function findObject(COL, TOL, PIXELS: Integer; HUE, SAT: Extended): Boolean;
  175. var
  176. WhatEver: TColEx;
  177. TPA: TPointArray;
  178. ATPA: T2DPointArray;
  179. I: Integer;
  180. box: TBox;
  181. x, y: Integer;
  182. begin
  183. WhatEver.Create(Col, Tol, Hue, Sat);
  184. if not WhatEver.FindAllIn(Area_MS, TPA) then
  185. Exit(False);
  186. ATPA := ClusterTPA(TPA, 10);
  187. SortATPAFromMidPoint(ATPA, Point(MSCX, MSCY));
  188. if (length(ATPA) <= 0) then
  189. begin
  190. result := False;
  191. exit;
  192. end;
  193. for I := 0 to high(ATPA) do
  194. begin
  195. if (length(ATPA[I]) >= PIXELS) then
  196. begin
  197. box := intToBox(ATPA[I].getBounds().X1, ATPA[I].getBounds().Y1 - 25, ATPA[I].getBounds().X2, ATPA[I].getBounds().Y2);
  198. if (box.x1 < 0) then
  199. box.x1 := 0;
  200. if (box.y1 < 0) then
  201. box.y1 := 0;
  202. pnt := MiddleTPA(ATPA[I]);
  203. result := True;
  204. exit;
  205. end;
  206. end;
  207. result := False;
  208. end;
  209.  
  210. procedure openBank();
  211. var
  212. Bank: TReflectObject;
  213. BankChest: TReflectObject;
  214. BankNPC: TReflectNPC;
  215. TPA: TPointArray;
  216. ATPA: T2DPointArray;
  217. tCol: TColEx;
  218. begin
  219. if (isBankOpen()) then
  220. exit;
  221. if (Interfaces[PINSCREEN].isVisible()) then
  222. inPin(P_PIN);
  223. T.Restart;
  224. begin
  225. if (BANKTYPE = 'chest') then
  226. begin
  227. BankChest.Find(objGame, 'Bank chest', 10);
  228. Draw('Found Bank');
  229. Reflect.Mouse.Move(Bank.GetMSPoint, 5, 5);
  230. Draw('Opening Bank');
  231. C_Click('est', 250, 'Use Bank Chest', 300);
  232. end;
  233. if (BANKTYPE = 'booth') then
  234. begin
  235. Bank.Find(objGame, 'Bank booth', 10);
  236. Draw('Found Bank');
  237. Reflect.Mouse.Move(Bank.GetMSPoint, 5, 5);
  238. Draw('Opening Bank');
  239. R_Click('ooth', 250, 'Bank booth', 300);
  240. end;
  241. if (BANKTYPE = 'npc') then
  242. begin
  243. BankNPC.Find('Banker');
  244. Reflect.Mouse.Move(BankNPC.GetMSPoint, 3, 3);
  245. Pnt := BankNPC.GetMSpoint;
  246. customMouse(Pnt);
  247. R_Click('anker', 250, 'ank Bank', 300);
  248. Draw('Opening Bank');
  249. end;
  250. if (BANKTYPE = 'cellar') then
  251. begin
  252. if (findObject(660063, 4, 20, 0.08, 0.85)) then
  253. ; customMouse(pnt);
  254. R_Click('est', 250, 'ank', 300);
  255. Draw('Opening Bank');
  256. end;
  257. end;
  258. if (not isBankOpen()) then
  259. repeat
  260. sleep(250 + random(200));
  261. until (isBankOpen()) or (T.ElapsedTime > 5000);
  262. end;
  263.  
  264. procedure doBank();
  265. begin
  266. if getInvCount > 0 then
  267. begin
  268. Draw('Depositing');
  269. quickDeposit('inv');
  270. end;
  271. if (CLEAN = 'only') then
  272. begin
  273. if not GHerbB.Find(info.toClean) then
  274. begin
  275. Draw('Low on materials!');
  276. closeinterface;
  277. logoutplayer;
  278. TerminateScript;
  279. end
  280. else
  281. begin
  282. Draw('Withdrawing');
  283. GHerbB.Find(info.toClean);
  284. GHerbB.Withdraw( - 1);
  285. end;
  286. end;
  287. if (CLEAN = 'yes') then
  288. begin
  289. if not GHerbB.Find(info.ToClean) or not VialB.Find('Vial of water') then
  290. begin
  291. Draw('Low on materials!');
  292. closeinterface;
  293. logoutplayer;
  294. TerminateScript;
  295. end
  296. else
  297. begin
  298. Draw('Withdrawing');
  299. case random(0, 1) of
  300. 0:
  301. begin
  302. GHerbB.Find(info.ToClean);
  303. GHerbB.Withdraw( - 14);
  304. VialB.Find('Vial of water');
  305. VialB.Withdraw( - 1);
  306. end;
  307. 1:
  308. begin
  309. VialB.Find('Vial of water');
  310. VialB.Withdraw( - 14);
  311. GHerbB.Find(info.ToClean);
  312. GHerbB.Withdraw( - 1);
  313. end;
  314. end;
  315. end;
  316. end;
  317. if (CLEAN = 'no') then
  318. begin
  319. if not CHerbB.Find(info.Cleaned) or not VialB.Find('Vial of water') then
  320. begin
  321. Draw('Low on materials!');
  322. closeinterface;
  323. logoutplayer;
  324. TerminateScript;
  325. end
  326. else
  327. begin
  328. Draw('Withdrawing');
  329. case random(0, 1) of
  330. 0:
  331. begin
  332. CHerbB.Find(info.Cleaned);
  333. CHerbB.Withdraw( - 14);
  334. VialB.Find('Vial of water');
  335. VialB.Withdraw( - 1);
  336. end;
  337. 1:
  338. begin
  339. VialB.Find('Vial of water');
  340. VialB.Withdraw( - 14);
  341. CHerbB.Find(info.Cleaned);
  342. CHerbB.Withdraw( - 1);
  343. end;
  344. end;
  345. end;
  346. end;
  347. closeInterface;
  348. Draw('Closing Bank');
  349. end;
  350.  
  351. procedure CleanHerbs;
  352. var
  353. strArr: TStringArray;
  354. id, I: Integer;
  355. begin
  356. Grimies.GetAll;
  357. setArrayLength(strArr, 1);
  358. strArr := [info.ToClean] for I := 0 to High(Grimies) do
  359. if inStrArrEx(Grimies[I].GetName, strArr, id) then
  360. begin
  361. pnt := Grimies[I].GetPoint;
  362. customMouse(pnt);
  363. L_Click;
  364. sleep(randomRange(20, 200));
  365. Draw('Cleaning Herbs');
  366. end;
  367. end;
  368.  
  369. procedure Make;
  370. begin
  371. if (CLEAN = 'only') then
  372. begin
  373. cleanHerbs;
  374. TotalCleaned += 28;
  375. end;
  376. if (CLEAN = 'yes') then
  377. begin
  378. CleanHerbs;
  379. while GHerbI.Find(info.ToClean) do wait(randomRange(50,500));
  380. case random(0, 1) of
  381. 0:
  382. begin
  383. if CHerbI.Find(info.Cleaned) then
  384. begin
  385. Pnt := CHerbI.GetPoint;
  386. customMouse(pnt);
  387. L_Click;
  388. end;
  389. if VialI.Find('Vial of water') then
  390. begin
  391. Pnt := VialI.GetPoint;
  392. customMouse(pnt);
  393. L_Click;
  394. end;
  395. end;
  396. 1:
  397. begin
  398. if VialI.Find('Vial of water') then
  399. begin
  400. Pnt := VialI.GetPoint;
  401. customMouse(pnt);
  402. L_Click;
  403. end;
  404. if CHerbI.Find(info.Cleaned) then
  405. begin
  406. Pnt := CHerbI.GetPoint;
  407. customMouse(pnt);
  408. L_Click;
  409. end;
  410. end;
  411. end;
  412. begin
  413. waitChatChange();
  414. Wait(randomRange(100,300)); // Human reaction time
  415. gaussMouseBox(105, 385, 420, 440, Mouse_Move);
  416. if (waitUptext('ake', 870)) then
  417. begin
  418. fastClick(MOUSE_RIGHT);
  419. waitOption('Make All', 300);
  420. end;
  421. Draw('Making Potions');
  422. T.Restart;
  423. wait(randomRange(2000, 4000));
  424. repeat
  425. beHuman(500);
  426. wait(randomRange(1000, 2000));
  427. if not PotI.Find(info.UnfPot) then
  428. exit;
  429. until (getInvCount = 14) or (T.ElapsedTime > 15000);
  430. if not VialI.Find('Vial of water') then
  431. TotalDone += 14;
  432. TotalCleaned += 14;
  433. end;
  434. end;
  435. if (CLEAN = 'no') then
  436. begin
  437. case random(0, 1) of
  438. 0:
  439. begin
  440. if CHerbI.Find(info.Cleaned) then
  441. begin
  442. Pnt := CHerbI.GetPoint;
  443. customMouse(pnt);
  444. L_Click;
  445. end;
  446. if VialI.Find('Vial of water') then
  447. begin
  448. Pnt := VialI.GetPoint;
  449. customMouse(pnt);
  450. L_Click;
  451. end;
  452. end;
  453. 1:
  454. begin
  455. if VialI.Find('Vial of water') then
  456. begin
  457. Pnt := VialI.GetPoint;
  458. customMouse(pnt);
  459. L_Click;
  460. end;
  461. if CHerbI.Find(info.Cleaned) then
  462. begin
  463. Pnt := CHerbI.GetPoint;
  464. customMouse(pnt);
  465. L_Click;
  466. end;
  467. end;
  468. end;
  469. begin
  470. waitChatChange();
  471. Wait(randomRange(100,300)); // Human reaction time
  472. gaussMouseBox(105, 385, 420, 440, Mouse_Move);
  473. if (waitUptext('ake', 870)) then
  474. begin
  475. fastClick(MOUSE_RIGHT);
  476. waitOption('Make All', 300);
  477. end;
  478. Draw('Making Potions');
  479. T.Restart;
  480. wait(randomRange(2000, 4000));
  481. repeat
  482. beHuman(500);
  483. Wait(randomRange(1000, 2000));
  484. if not PotI.Find(info.UnfPot) then
  485. exit;
  486. until (getInvCount = 14) or (T.ElapsedTime > 15000);
  487. if not VialI.Find('Vial of water') then
  488. TotalDone += 14;
  489. end;
  490. end;
  491. end;
  492.  
  493. function getState(): Integer;
  494. begin
  495. if (getTimeRunning >= getTimeUntilBreak) and (USEBREAKS) then
  496. exit(5);
  497. if (not isLoggedIn()) then
  498. exit(0);
  499. if ((getCurrentTab <> TAB_INV) and (not isBankOpen())) then
  500. exit(1);
  501. if (not isInvFull()) and (not isBankOpen()) then
  502. exit(2);
  503. if (isBankOpen()) then
  504. exit(3)
  505. if (isInvFull()) and (not LocP.isAnimating) then
  506. exit(4);
  507. end;
  508.  
  509. procedure executeState(State: Integer);
  510. begin
  511. case (State) of
  512. 0: setupPlayer();
  513. 1: gameTab(TAB_INV);
  514. 2: openBank();
  515. 3: doBank();
  516. 4: Make();
  517. 5: breakHandler();
  518. end;
  519. sleep(Random(50, 100));
  520. end;
  521.  
  522. begin
  523. declarePlayer();
  524. InitAL();
  525. Reflect.Setup;
  526. setup;
  527. repeat
  528. executeState(getState());
  529. until (false);
  530. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement