Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 105.42 KB | None | 0 0
  1. program New;
  2.  
  3. //Below here you are free to touch.
  4.  
  5. //{$define smart} //Comment this line to use the script with regular browser
  6.  
  7. //{$DEFINE RS3} //Comment this line to use the script on Old-School RuneScape
  8. {$IfDef RS3}
  9. {$i srl-6/srl.simba}
  10. {$i sps/lib/sps-rs3.simba}
  11. {$Else}
  12. {$i aerolib/aerolib.simba}
  13. {$I RSWalker/Walker.simba}
  14. {$endif}
  15.  
  16. {$ifdef smart}
  17. {$ifndef lape}
  18. {$i srl/srl/misc/smartgraphics.simba}
  19. {$define SMARTDRAW}
  20. {$endif}
  21. {$endif}
  22. { Changelog
  23. 5.00: Real Anniversary Edition!
  24. * Backported script to Old-School RuneScape!
  25. - Added Aerolib and RSWalker compatibility
  26. - Backported some SRL-6 stuff to Aerolib for compatibility
  27. - Changed colors and stuff to be constants instead of inline
  28. - Compiler directives handle different naming between SRL/AL
  29. - Used some portal finders from version 3.11 (last SRL-5 version of the Essence miner)
  30. Overall it should be pretty good! Let me know of any bugs you find
  31. * Added sanity checks for SPS as it can be quite inaccurate. Also used these for RSW (OSRS)
  32. * Script more accurately detects when the door needs to be opened. it can also ignore door-opening now if it's already opened;
  33. * Middle-of-mine-walking now has adaptive tolerance (helps for OSRS, but RS3 as well)
  34. * 'Deathwalking'! You can start the script from anywhere and it'll get you there (RS3 Only)
  35. This should also help when the script is lost. It'll just home tele instead of logging out.
  36. * Tweaked RS3 Aubury finding, should be less shit now but is still not as good as I want it to be
  37. * Fixed essence counting! It now actually counts essence, instead of assuming full inventory
  38. * There was an infinite loop in bank opening! Shame on me. Fixed of course.
  39. * Added a maximum run timer: if you only want to bot for 20 minutes, that's possible now
  40.  
  41. 4.20:
  42. * 10-year anniversary edition! This script just refuses to die
  43. * Fixed a few compilation bugs for SRL 1300+
  44. * Small bug in portal finding fixed (small offset added)
  45. * Fixed a bug in doorfinding which caused it to never actually open the door
  46. * Changed tolerance in Aubury color finding
  47. * Few other random bug fixes I can't remember, mostly minor
  48.  
  49. 4.10:
  50. * Fixed portal finder 2 crashing script
  51. * Fixed magic coords (messed up a minus-sign)
  52. * Added some stats
  53. * More stability and bug fixes and other cool stuff.
  54.  
  55. 4.01:
  56. * Updated again to compile with Simba 1100 and SRL-6
  57. * Small changes to Aubury mine handling
  58. * There seem to be a few more portal finders from the competition. Can't recall which ones I used though..
  59.  
  60. 4.00: (Unreleased)
  61. * Updated sript to work with SRL-6.
  62. * Updated script to work with RS3
  63. * Disabled lots of stuff that didn't work
  64. * Changed some TPA segmentation stuff in the ess finder
  65. * Very wacky Aubury finding added
  66. * New symbol finder cause SRL's have bad performance
  67. * New detection if we are in store, using polygons!
  68. * Reimplemented part of the door finding
  69. * Fixed an old bug which has been there for 7 years in the mainloop
  70.  
  71. 3.11:
  72. * Added a new portal finder by J J, it is easy and should be more accurate. Thanks! Modified it slightly to accomodate both the script and Lape.
  73. * Added a new doorfinder, 'DoorClosedGenius'. It uses quite a clever way to distinguish the door from the floor at Aubury's store. I'd say, check it out! :)
  74. * Improved the caching of the BlackOffset. Now it doesn't need black but it also works with the tree visible
  75. * Added some wrappers for the wrappers to wrap around the code 8 error. Uses 100% undocumented features.
  76. * Added SRL Stats support! Please fill in your username/password
  77. * Fixed the bug that it would not continue mining if it got a random
  78. * Fixed a very rare bug in the location detection where it would mess up
  79.  
  80. 3.10:
  81. * LAPE compatibility! Simba 992+ SRL 1513+ required. Seems to 'lag' a bit more in Lape though..
  82. * Six hour fix enabled! I don't think the script gets 6 hour runs but if it does, it can handle it
  83. * Fixed blackoffset, so the DDTM should work again (more accuracy @ mapwalk)
  84. * The BlackOffset(R) is now properly cached. (increases speed)
  85. * Re-enabled the old portal finder as backup as it's not bad at all! (increases durability)
  86. * [strike]Replaced the bank opening function with something slightly more accurate[/strike] nope: all of SRL's bankfinding is crap...
  87. * Added a wait so it waits until the character is fully standing, (improves bankfinding, less detectable)
  88. * Added tons of SMART debugging stuff, though I really don't know how to use it.. (makes it easier to fix bugs)
  89. * Better Aubury to bank walking - read: trashed Wizzup's old function (more accuracy, no blue moon inn, increases durability)
  90. * Added 'Freeze' for Aubury store finding, works better with the rotating DTM ;) (better aubury store finding)
  91. * Also added 'Freeze' for the black offset. (idem)
  92. * Extremely ugly/effective portal hack: logout/login for when it's desperate for finding the portal. (increase durability)
  93. * Added essence/hour counter. (looks nice at proggies)
  94. * Fixed doorfinding! New DTM and new Minimap shizzles, tweaked Uptext checking so it actually works most of the time (increases durability)
  95. * Moved script comments around to accomodate users of archaic 80-character terminals (decreases Wizzup complaints)
  96. * More accurate counting of mined ess when pickaxe not equipped
  97. * If the script couldn't find ess, instead of exitting and walking back to the bank,
  98. now it will exit and try to get back to mine for a retry (increases speed, less detectable)
  99. * Added some more random finding here and there (increases durability)
  100. * For extra bonus points: added running+resting.
  101.  
  102. 3.01:
  103. * Tweaked Aubury finding, should work better (faster)
  104. * Also fixed a bug in Aubury finding so it looks for Talk, not (W)alk
  105. * Spiral sort in all object finders now, Wizzup? forgot those >.<
  106. * New magic store detection, accuracy increased a lot! Take a look at lines 114-130 and 179+ if you want to see how it works, quite proud of it
  107. * Commented a LOT throughout the entire script so it's now way easier to understand
  108. * Fixed one small edge case with inside mine handling, should be perfect now
  109. * New doorfinder, uses mainscreen DTM (thanks Demise!). Uses old one as fallback
  110. * Should open doors semi-correctly now when walking Aubury->Bank, tweaked the code behind that a bit
  111. * Added a few range checks so it doesn't click a few pixels outside of minimap when walking bank->Aubury
  112. * Added a bit of waiting, but still likes to mess up by clicking bankers instead of booths
  113. * Doesn't close bank booth all the time now, just 1 in 3 times
  114. * Added a bit of debug lines, too. Can't turn those off yet
  115. * Few other minor tweaks here and there
  116.  
  117.  
  118. 3.00:
  119. * Removed (deprecated) stats system
  120. * Tweaked Aubury and bank finding
  121. * Brand new ess finder
  122. * Great system for walking inside the mine
  123. * Removed newautocolor support
  124. * New Flag function, uses pixelshift for better accuracy
  125. * New portal finder, thanks euphemism!
  126. * Trashed abyss solver
  127. * The script is now polite and congratulates you when levelling up ;-)
  128.  
  129. }
  130. { TODO
  131.  
  132. * Fix door opening (it finds the door but glitches a bit)
  133. * Get rid of weird mouse movements
  134. * Fix Aubury finding RS3
  135. }
  136.  
  137. { Credits:
  138. As I'm a lazy scripter, here some people who helped out in no particular order:
  139. - Wizzup? As this script started out as his back in '07
  140. - WT-Fakawi for his excellent feedback for v3+ and some DDTM code
  141. - J J; euphemism and Brandon for their awesome portal finders
  142. - mixster for some mathematics help at essence location detection
  143. - Wu-Tang Clan for the SPS map used
  144. Several others!
  145. }
  146.  
  147. Const
  148. StartPlayer = 0;
  149. Loads = 12; //Loads before banking/switching players
  150. VersionNumber = '5.00 beta';
  151. TIME_TO_RUN = -1;// Amount of minutes to run script before terminatng
  152. // Set to -1 if you don't care.
  153.  
  154. SRL_User = ''; //Your SRL Stats username
  155. SRL_Pass = ''; //Your SRL Stats password
  156.  
  157. Var
  158. // EssInfo: EssLocArray;
  159. AubTPA: TPointArray;
  160. NoEssFound: Boolean;
  161. EssenceMined, Abyss: Integer;
  162. MiddleDTM1, MiddleDTM2, DTMAuburyDoor : integer;
  163. EssenceDTM : integer;
  164. MageSymbolBMP, TransportSymbolBMP : integer;
  165. AuburyShopPolygon : TPointArray;
  166. AuburyCenter : TPoint;
  167. T3 : Integer; //Aubury shop timer
  168. DeathWalkPath : TPointArray;
  169. {$IfDef RS3}
  170. DWSPS : TSPSArea;
  171. {$EndIf}
  172. {$IfDef Aerolib}
  173. var
  174. RSW : TRSWalker;
  175. {$endif}
  176. //{$DEFINE DEBUG}
  177.  
  178.  
  179.  
  180. Procedure DeclarePlayers;
  181.  
  182. Begin
  183. {$IfDef RS3}
  184. currentPlayer := 0;
  185. setLength(players, 1);
  186. {$EndIf}
  187.  
  188. with {$IfDef RS3} players[0] {$Else} Me {$EndIf} do
  189. begin
  190. {$IfNDef RS3} setLength(booleans, 100); setLength(strings,100); setlength(integers,100);{$endif}
  191. {$IfDef RS3}loginName{$Else}Name{$EndIf} := '';
  192. {$Ifdef RS3}password{$Else}pass{$EndIf} := '';
  193. {$IfDef RS3}isActive{$Else}Active{$EndIf} := True;
  194. {$IfDef RS3}location{$Else}strings[42]{$EndIf} := 'Bank'; //'Bank' if at VEB, 'Lost' if anywhere else
  195. Booleans[0] := True; //True if pick equipped or in toolbelt; Note: nothing else supported atm!
  196. end;
  197. //players.Setup(['wizzup'], PLAYER_FILE); //Replace 'wizzup' by your own character(s)
  198.  
  199. //Players[0].Booleans[0] := True; // Is The Pick Equipped or in toolbelt or whatever?
  200. {
  201. Players[1].Name :='';
  202. Players[1].Pass :='';
  203. Players[1].Nick :=F'';
  204. Players[1].Active := True;
  205. Players[1].Loc := 'Bank';
  206. Players[1].Booleans[0] := True; // Is The Pick Equipped?
  207.  
  208. Players[2].Name :='';
  209. Players[2].Pass :='';
  210. Players[2].Nick :='';
  211. Players[2].Active := True;
  212. Players[2].Loc := 'Bank';
  213. Players[2].Booleans[0] := True; // Is The Pick Equipped?}
  214. {
  215. Players[3].Name :='';
  216. Players[3].Pass :='';
  217. Players[3].Nick :='';
  218. Players[3].Active := True;
  219. Players[3].Loc := 'Bank';
  220. Players[3].Booleans[0] := True; // Is The Pick Equipped? }
  221.  
  222. //Writeln( IntToStr ( length(players) ) + ' Players' );
  223. End;
  224.  
  225.  
  226. // Note: the first ~800 lines or so are just wrappers for other functions in the script
  227. // Don't worry about them, it's just laziness from my side to properly update it
  228. // They are ugly, unnecessary and overall just bad coding practice.
  229. {$ifdef RS3}
  230. (******************************************************************************)
  231. { SRL 5 compatibility library for use with SRL 6. For updating legacy scripts }
  232.  
  233. var
  234. {mmx1, mmx2, mmy1, mmy2, }msx1, msy1, msx2, msy2, mmcx, mmcy, mscx, mscy,
  235. clickLeft, clickRight, __angle_i : integer;
  236.  
  237. var
  238. SineArray, Cosearray: array[0..360] of Extended;
  239. pi_const : extended;
  240.  
  241. function FindNormalRandoms : boolean; //Placeholder. Can be used for anything
  242. begin
  243. exitTreasure();
  244. //claimTicket();
  245. result := false;
  246. end;
  247.  
  248. procedure FFlag(dist : integer);
  249. begin
  250. minimap.waitFlag(dist); //cbf to rewrite 90% of the script
  251. end;
  252.  
  253. procedure MMouse(x, y, randomx, randomy : integer);
  254. begin
  255. Mouse(x, y, randomx, randomy, mouse_move);
  256. end;
  257.  
  258. Procedure FNRWait(ms: Integer);
  259. Var
  260. T: Integer;
  261. Begin
  262. T := GetSystemTime;
  263. While GetSystemTime - T < ms Do
  264. Begin
  265. Wait(200);
  266. FindNormalRandoms;
  267. End;
  268. End;
  269.  
  270. function IntToPoint(const px, py : integer) : tpoint;
  271. begin
  272. result.x := px;
  273. result.y := py;
  274. end;
  275.  
  276. procedure SortATPAFrom(var a: T2DPointArray; const fx, fy : integer); overload;
  277. begin
  278. SortATPAFrom(a, IntToPoint(fx, fy));
  279. end;
  280. {
  281. function GetUpText : string; //I hope UpText is MouseOverText..
  282. begin
  283. result := getMouseOverText;
  284. end;
  285. }
  286. function WaitUpTextMulti(text : TStringArray; waittime : integer) : boolean;
  287. begin
  288. result := isMouseOverText(text, waittime);
  289. end;
  290.  
  291. procedure ClickMouse2(left : boolean);
  292. begin
  293. if left then
  294. fastClick(mouse_left)
  295. else
  296. fastclick(mouse_right);
  297. end;
  298.  
  299. function WaitOptionEx(action1, action2 : string; clickit, waittime : integer) : boolean;
  300. begin
  301. result := chooseOption.select([action1, action2], waittime);
  302. end;
  303. {
  304. function IsUptext(str : string) : boolean;
  305. begin
  306. result := isMouseOverText([str]);
  307. end;
  308. }
  309. function isFlagPresent : boolean;
  310. begin
  311. result := minimap.isFlagPresent;
  312. end;
  313.  
  314. function MouseFlagEx(X, Y, rX, rY, Xmod, Ymod, FlagDist: Integer; //copied from srl 5.
  315. CheckForFlag, CheckForRoadColor: Boolean): Boolean;
  316. var
  317. I: Integer;
  318. P: TPoint;
  319. begin
  320. Result := False;
  321. if (minimap.isFlagPresent) then
  322. if (CheckForFlag) or (minimap.getFlagDistance <= FlagDist) then exit;
  323.  
  324. P := Point(X - Xmod, Y - Ymod);
  325. Xmod := Max(Xmod, 3);
  326. Ymod := Max(Ymod, 3);
  327.  
  328. for I := 0 to 4 do
  329. begin
  330. IncEx(P.X, Xmod + Random(rX));
  331. IncEx(P.Y, Ymod + Random(rY));
  332. if not pointInBox(P, minimap.GetBounds) then Continue;
  333. Mouse(P.X, P.Y, 0, 0, mouse_left);
  334. Result := WaitFunc(@isFlagPresent, 50, 3000);
  335. if (Result) then break;
  336. end;
  337. if (FlagDist > -1) then
  338. minimap.waitFlag(FlagDist);
  339. end;
  340.  
  341. function MFF(X, Y, Xmod, Ymod: Integer): Boolean;
  342. begin
  343. Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, True, False);
  344. end;
  345.  
  346. function FindSymbol(var x, y : integer; symbolnumber : integer) : boolean; //Small change, not backwards compatible
  347. var
  348. p : tpoint;
  349. begin
  350. result := minimap.findSymbol(p, symbolnumber, minimap.getbounds());
  351. x := p.x;
  352. y := p.y;
  353. end;
  354.  
  355. function FindSymbol(var p : tpoint; symbolnumber : integer) : boolean; overload;
  356. begin
  357. result := minimap.findSymbol(p, symbolnumber, minimap.getbounds());
  358. end;
  359.  
  360. function InvCount : integer;
  361. begin
  362. result := tabBackpack.count;
  363. end;
  364.  
  365. procedure LogOut;
  366. begin
  367. players[currentPlayer].logout();
  368. end;
  369.  
  370. procedure Deposit(startslot, endslot : integer; depositall : boolean);
  371. var
  372. i : integer;
  373. bleuh : tintegerarray;
  374. begin
  375. setlength(bleuh, endslot-startslot+1);
  376. for i := startslot to endslot do
  377. bleuh[i-startslot] := i;
  378. bankscreen.deposit(bleuh, [], not depositall);
  379. end;
  380.  
  381. procedure CloseBank;
  382. begin
  383. bankscreen.close();
  384. end;
  385.  
  386. function InvFull : boolean;
  387. begin
  388. result := tabbackpack.isFull;
  389. end;
  390.  
  391. procedure SetRun(run : boolean);
  392. begin
  393. minimap.toggleRun(run);
  394. end;
  395.  
  396. function MFNF(X, Y, Xmod, Ymod: Integer): Boolean;
  397. begin
  398. Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, False, False);
  399. end;
  400.  
  401. procedure MakeCompass(direction : string);
  402. begin
  403. case lowercase(direction) of
  404. 'n': minimap.setAngle(MM_DIRECTION_NORTH);
  405. 'e': minimap.setAngle(MM_DIRECTION_EAST);
  406. 's': minimap.setAngle(MM_DIRECTION_SOUTH);
  407. 'w': minimap.setAngle(MM_DIRECTION_WEST);
  408. end;
  409. end;
  410.  
  411. procedure LoginPlayer;
  412. begin
  413. players[currentplayer].login;
  414. end;
  415.  
  416. function loggedin : boolean;
  417. begin
  418. result := isLoggedIn;
  419. end;
  420.  
  421. function IsUpTextMultiCustom(text : tstringarray) : boolean;
  422. begin
  423. result := isMouseOverText(text);
  424. end;
  425.  
  426. function IsUpTextMulti(text : tstringarray) : boolean;
  427. begin
  428. result := isMouseOverText(text);
  429. end;
  430.  
  431. function ChooseOptionMulti(text : tstringarray) : boolean;
  432. begin
  433. result := chooseoption.select(text);
  434. end;
  435.  
  436. function Cose(Degrees: Integer): Extended;
  437. begin
  438. Result := cosearray[Trunc(FixD(Degrees))];
  439. end;
  440. function Sine(Degrees: Integer): Extended;
  441. begin
  442. Result := sinearray[Trunc(FixD(Degrees))];
  443. end;
  444.  
  445. procedure SRLRandomsReport;
  446. begin
  447. writeln('Thank you for using the SRL-5 compatibility library!');
  448. end;
  449.  
  450. function CreateTPAFromText(Txt: string; Chars: string) : TPointArray;
  451. var
  452. w,h : integer;
  453. begin;
  454. result := TPAFromText(Txt,Chars,w,h);
  455. end;
  456.  
  457. procedure NextPlayer(active : boolean);
  458. begin
  459. players.next(active);
  460. end;
  461.  
  462. function FindColorsTolerance(var pts: TPointArray; col, x1, y1, x2, y2, tol: Integer; setts : tcolorsettings): Boolean; overload;
  463. begin
  464. result := findcolorstolerance(pts, col, inttobox(x1, y1, x2, y2), tol, setts);
  465. end;
  466.  
  467. procedure Mouse(x, y, rx, ry : integer; left : boolean); overload;
  468. var
  469. clickityclick : integer;
  470. begin
  471. if left then
  472. clickityclick := MOUSE_LEFT
  473. else
  474. clickityclick := MOUSE_RIGHT;
  475. Mouse(x, y, rx, ry, clickityclick);
  476. end;
  477.  
  478. procedure Mouse(p : Tpoint; rx, ry, mtype : integer); overload;
  479. begin
  480. Mouse(p.x, p.y, rx, ry, mtype);
  481. end;
  482.  
  483. const //sorry but else my essminer doesnt work as it NEEDS these to be constants
  484. mmx1 = 577;
  485. mmy1 = 12;
  486. mmx2 = 798;
  487. mmy2 = 200;
  488.  
  489. begin
  490. msx1 := mainscreen.getbounds.x1;
  491. msy1 := mainscreen.getbounds.y1;
  492. msx2 := mainscreen.getbounds.x2;
  493. msy2 := mainscreen.getbounds.y2;
  494.  
  495. {mmx1 := minimap.getbounds.x1;
  496. mmy1 := minimap.getbounds.y1;
  497. mmx2 := minimap.getbounds.x2;
  498. mmy2 := minimap.getbounds.y2;}
  499.  
  500. //mmcx := minimap.getcenterpoint.x;
  501. //mmcy := minimap.getcenterpoint.y;
  502. mmcx := 688;
  503. mmcy := 106;
  504.  
  505. mscx := mainscreen.getcenterpoint.x;
  506. mscy := mainscreen.getcenterpoint.y;
  507.  
  508. clickLeft := MOUSE_LEFT;
  509. clickRight := MOUSE_RIGHT;
  510.  
  511. pi_const := Pi; // not necessary, but might as well.
  512. for __angle_i := 0 to 360 do
  513. begin
  514. Sinearray[__angle_i] := Sin(__angle_i * pi_const / 180.0);
  515. Cosearray[__angle_i] := Cos(__angle_i * pi_const / 180.0);
  516. end;
  517. end;
  518. { End of SRL-5 compatibility library. Hacked together by Markus }
  519. (******************************************************************************)
  520.  
  521. {$endif}
  522.  
  523. {$ifdef Aerolib}
  524. (******************************************************************************)
  525. { Aerolib SRL-6 Compatibility layer. Hacked together by Markus. }
  526. { Useful for backporting scripts from SRL-6 back to Aerolib. }
  527.  
  528. function getColor(var p: TPoint): integer; overload;
  529. begin
  530. result := getColor(p.x, p.y);
  531. end;
  532.  
  533. function getPixelShift(b: TBox; time: integer): integer; overload;
  534. begin
  535. result := PixelShift(b, time);
  536. end;
  537.  
  538. procedure MMouse(x, y, randomx, randomy : integer);
  539. begin
  540. Mouse(IntToPoint(x, y), randomx, randomy, mouse_move);
  541. end;
  542.  
  543. function getMouseOverText : string;
  544. begin
  545. result := getUpText;
  546. end;
  547.  
  548. function isMouseOverText(st : TStringArray; t : integer) : boolean;
  549. begin
  550. result := waitUpTextMulti(st, t);
  551. end;
  552.  
  553. procedure ClickMouse2(left : boolean);
  554. begin
  555. if left then
  556. fastClick(mouse_left)
  557. else
  558. fastclick(mouse_right);
  559. end;
  560.  
  561. function FNRWait(WaitTime: Integer): Boolean; // ez
  562. begin
  563. result := WaitEx(waitTime);
  564. end;
  565.  
  566. function FindNormalRandoms : boolean; //Placeholder. Can be used for anything
  567. begin
  568. result := foundRandoms();
  569. end;
  570.  
  571. procedure LogOut; //seriously, why was this renamed >.<
  572. begin
  573. LogoutPlayer;
  574. end;
  575.  
  576. function InvFull : boolean;
  577. begin
  578. result := isInvFull();
  579. end;
  580.  
  581. procedure SetRun(run : boolean);
  582. begin
  583. toggleRunning(run);
  584. end;
  585.  
  586. function MakeCompass(Direction: Variant): Boolean; //srsly why did you rename this.
  587. begin //Honestly, what are we doing here. Cheating or just random namechanges?
  588. result := setCompass(Direction);
  589. end;
  590.  
  591. function loggedin : boolean;
  592. begin
  593. result := isLoggedIn;
  594. end;
  595.  
  596. function InvCount : integer;
  597. begin
  598. result := getInvCount;
  599. end;
  600.  
  601. function findDeformedBitmapToleranceIn(bmp: integer; var x, y: integer; searchBox: TBox; tolerance: integer; range: integer; allowPartialAccuracy: boolean; var accuracy: extended): boolean; overload;
  602. begin
  603. result := findDeformedBitmapToleranceIn(bmp, x, y, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance, range, allowPartialAccuracy, accuracy);
  604. end;
  605.  
  606. procedure gaussBox(out p: TPoint; box: TBox); overload;
  607. begin
  608. gaussBox(p.x, p.y, box.x1, box.y1, box.x2, box.y2);
  609. end;
  610.  
  611. function distance(pnt1, pnt2: TPoint): integer; overload;
  612. begin
  613. result := distance(pnt1.x, pnt1.y, pnt2.x, pnt2.y);
  614. end;
  615.  
  616.  
  617. //from srl-6, needed for portal finder
  618. procedure mouseOval(cx, cy, rx, ry, mouseAction: Integer = MOUSE_MOVE);
  619. var
  620. a: single;
  621. p: TPoint;
  622. begin
  623. a := randomE() * PI * 2;
  624. p.x := cx + round(cos(a) * randomRange(-rx, rx));
  625. p.y := cy + round(sin(a) * randomRange(-ry, ry));
  626. mouse(p, 0,0, mouseAction);
  627. end;
  628.  
  629. procedure mouseOval(P: Tpoint; rx, ry, mouseAction: Integer = MOUSE_MOVE); overload;
  630. begin
  631. mouseOval(P.X, P.Y, rx, ry, mouseAction);
  632. end;
  633.  
  634.  
  635. function MouseFlagEx(X, Y, rX, rY, Xmod, Ymod, FlagDist: Integer; //copied from srl 5.
  636. CheckForFlag, CheckForRoadColor: Boolean): Boolean;
  637. var
  638. I: Integer;
  639. P: TPoint;
  640. begin
  641. Result := False;
  642. if (flagPresent) then
  643. if (CheckForFlag) or (flagDistance <= FlagDist) then exit;
  644.  
  645. P := Point(X - Xmod, Y - Ymod);
  646. Xmod := Max(Xmod, 3);
  647. Ymod := Max(Ymod, 3);
  648.  
  649. for I := 0 to 4 do
  650. begin
  651. IncEx(P.X, Xmod + Random(rX));
  652. IncEx(P.Y, Ymod + Random(rY));
  653. if not pointInBox(P, AREA_MM) then Continue;
  654. Mouse(P, 0, 0, mouse_left);
  655. Result := WaitFunc(@flagPresent, 50, 3000);
  656. if (Result) then break;
  657. end;
  658. if (FlagDist > -1) then
  659. FFlag(FlagDist);
  660. end;
  661.  
  662. function MFF(X, Y, Xmod, Ymod: Integer): Boolean;
  663. begin
  664. Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, True, False);
  665. end;
  666.  
  667.  
  668. function MFNF(X, Y, Xmod, Ymod: Integer): Boolean;
  669. begin
  670. Result := MouseFlagEx(X, Y, 3, 3, Xmod, Ymod, -1, False, False);
  671. end;
  672.  
  673.  
  674. (*
  675. Color.simba copied verbatim from SRL-6
  676. All credits to original developers
  677. *)
  678.  
  679. (*
  680. type TColorSettings
  681. ~~~~~~~~~~~~~~~~~~~
  682.  
  683. A record that provides easy access to the Simba CTS settings.
  684. *)
  685. type
  686. TColorSettings = record
  687. CTS: Integer;
  688. modifier: record
  689. hue, saturation, sensitivity: Extended;
  690. end;
  691. end;
  692.  
  693. function colorSetting(_CTS:Integer): TColorSettings;
  694. var
  695. cs: TColorSettings;
  696. begin
  697. cs.CTS := _CTS;
  698. Result := cs;
  699. end;
  700.  
  701.  
  702. function colorSetting(_CTS:Integer; _hueModifier, _saturationModifier: Extended): TColorSettings; overload;
  703. var
  704. cs: TColorSettings;
  705. begin
  706. cs.create(_CTS, _hueModifier, _saturationModifier);
  707. Result := cs;
  708. end;
  709.  
  710.  
  711. function colorSetting(_CTS:Integer; _sensitivityModifier: Extended): TColorSettings; overload;
  712. var
  713. cs: TColorSettings;
  714. begin
  715. cs.create(_CTS, _sensitivityModifier);
  716. Result := cs;
  717. end;
  718.  
  719. procedure TColorSettings.create(_CTS: Integer; _hueModifier, _saturationModifier: Extended);
  720. begin
  721. Self.CTS := _CTS;
  722. Self.modifier.hue := _hueModifier;
  723. Self.modifier.saturation := _saturationModifier;
  724. end;
  725.  
  726. procedure TColorSettings.create(_CTS: Integer; _sensitivityModifier: Extended); overload;
  727. begin
  728. Self.CTS := _CTS;
  729. Self.modifier.sensitivity := _sensitivityModifier;
  730. end;
  731.  
  732. procedure TColorSettings.retrieve();
  733. begin
  734. Self.CTS := GetToleranceSpeed();
  735. Self.modifier.sensitivity := GetToleranceSpeed3Modifier();
  736. GetToleranceSpeed2Modifiers(Self.modifier.hue, Self.modifier.saturation);
  737. end;
  738.  
  739. procedure TColorSettings.apply();
  740. begin
  741. try
  742. SetColorToleranceSpeed(Self.CTS);
  743. SetToleranceSpeed2Modifiers(Self.modifier.hue, Self.modifier.saturation);
  744. SetToleranceSpeed3Modifier(Self.modifier.sensitivity);
  745. except
  746. writeln('failed setting CTS');
  747. end;
  748. end;
  749.  
  750. function findColorTolerance(var x, y: integer; color: integer; searchBox: TBox; tolerance: integer): boolean; overload;
  751. begin
  752. result := FindColorTolerance(x, y, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance);
  753. end;
  754. function findColorTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
  755. var
  756. cs: TColorSettings;
  757. begin
  758. cs.retrieve();
  759. settings.apply();
  760. Result := findColorTolerance(x, y, color, searchBox, tol);
  761. cs.apply();
  762. end;
  763.  
  764. function findColorsTolerance(var points : TPointArray; const color : Integer; const searchBox: TBox; const tolerance : Integer): Boolean; overload;
  765. begin
  766. result := findColorsTolerance(points, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance);
  767. end;
  768. function findColorsTolerance(var points: TPointArray; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
  769. var
  770. cs: TColorSettings;
  771. begin
  772. cs.retrieve();
  773. settings.apply();
  774. Result := findColorsTolerance(points, color, searchBox, tol);
  775. cs.apply();
  776. end;
  777.  
  778. function findColorSpiralTolerance(var x, y: integer; color: integer; searchBox: TBox; tol: integer): boolean; overload;
  779. begin
  780. result := findColorSpiralTolerance(x, y, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tol);
  781. end;
  782. function findColorSpiralTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
  783. var
  784. cs: TColorSettings;
  785. begin
  786. cs.retrieve();
  787. settings.apply();
  788. Result := findColorSpiralTolerance(x, y, color, searchBox, tol);
  789. cs.apply();
  790. end;
  791.  
  792. function findColorsSpiralTolerance(var x, y: integer; var points: tpointarray; color: integer; searchBox: TBox; tolerance: integer): boolean; overload;
  793. begin
  794. result := findColorsSpiralTolerance(x, y, points, color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tolerance);
  795. end;
  796. function findColorsSpiralTolerance(x, y: Integer; var points: TPointArray; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
  797. var
  798. cs: TColorSettings;
  799. begin
  800. cs.retrieve();
  801. settings.apply();
  802. Result := findColorsSpiralTolerance(x, y, points, color, searchBox, tol);
  803. cs.apply();
  804. end;
  805.  
  806. function countColorTolerance(Color: integer; searchBox: TBox; tol: integer): integer; overload;
  807. begin
  808. Result := CountColorTolerance(color, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, tol);
  809. end;
  810. function countColorTolerance(color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): integer; overload;
  811. var
  812. cs: TColorSettings;
  813. begin
  814. cs.retrieve();
  815. settings.apply();
  816. Result := countColorTolerance(color, searchBox, tol);
  817. cs.apply();
  818. end;
  819.  
  820. function findBitmapTolerance(const bmp: integer; var x, y: integer; const tolerance: integer): boolean;
  821. var
  822. w, h: integer;
  823. begin
  824. getClientDimensions(w, h);
  825. result := findBitmapToleranceIn(bmp, x, y, 0, 0, w-1, h-1, tolerance);
  826. end;
  827. function findBitmapTolerance(const bmp: integer; var x, y: integer; const tolerance: integer; settings: TColorSettings): boolean; overload;
  828. var
  829. cs: TColorSettings;
  830. begin
  831. cs.retrieve();
  832. settings.apply();
  833. result := findBitmapTolerance(bmp, x, y, tolerance);
  834. cs.apply();
  835. end;
  836.  
  837. function findDTMRotated(DTM: Integer; var x, y: integer; searchBox: TBox; sAngle, eAngle, aStep: extended; out aFound: extended): boolean; overload;
  838. begin
  839. result := FindDTMRotated(DTM, x, y, searchBox.x1, searchBox.y1, searchBox.x2, searchBox.y2, sangle, eangle, astep, afound);
  840. end;
  841.  
  842. {$EndIf}
  843. ////////////////////////////////////////////////////////////////////////////////
  844. // Below here, the script itself starts. There should be no reason to touch //
  845. ////////////////////////////////////////////////////////////////////////////////
  846.  
  847. //Constants. All colors etc. are constant so we can easily swap between RS3/OSRS
  848. const
  849. DOOR_DENSITY = 0.4; //tweakme
  850. SPS_MAP_DL_LINK = 'http://i.imgur.com/qDG7TSu.png';
  851. SPS_DWMAP_DL_LINK = 'http://i.imgur.com/fpJEeqj.png';
  852.  
  853. SMARTDEBUGLINES = 7; //Amount of lines -1 you want at your screen.
  854. MAX_DIST_DIFF_SPS_Sym = 20; // How much difference do we allow SPS to have?
  855.  
  856. AUBURY_DIST_TH = 18; // How much until we are out of store?
  857. BANKER_CLICK_TH = 5; //When do we click bankers?
  858.  
  859. // You better leave these alone, they are important
  860. SHOP_WALK_INSIDE = $DEADBEEF;
  861. SHOP_WALK_OUTSIDE = 1337;
  862. SHOP_WALK_NOT = 42;
  863.  
  864. { Bank booth in VEB }
  865. BOOTH_COLOUR = 1394024;
  866. BOOTH_TOL = 3;
  867. BOOTH_HUE = 0.13;
  868. BOOTH_SAT = 2.11;
  869.  
  870. { Banker NPC in VEB (purple ones) }
  871. BANKER_COLOUR = 5517369;
  872. BANKER_TOL = 12;
  873. BANKER_HUE = 0.20;
  874. BANKER_SAT = 0.48;
  875.  
  876. { Door Aubury }
  877. DOOR_COLOR = 3164257;
  878. DOOR_TOL = 10;
  879. DOOR_CTS = 2;
  880. DOOR_MOD1 = 0.11;
  881. DOOR_MOD2 = 0.82;
  882.  
  883. {$IfDef RS3}
  884. MIDDLE_MINE_COLOR = 7369063;
  885. BANK_AUBURY_WAITTIME = 2000;
  886.  
  887. { Pretty clear what these are, right? }
  888. MAGE_SYMBOL_COLOR = 13456947;
  889. TRANSPORT_SYMBOL_COLOR = 1805019;
  890.  
  891. { Aubury himself }
  892. // Note: these are pretty bad at RS3. FIXME
  893. {AUBURY_NPC_COLOR = 10328226;
  894. AUBURY_NPC_TOL = 12;
  895. AUBURY_NPC_CTS = 2;
  896. AUBURY_NPC_MOD1 = 1.16;
  897. AUBURY_NPC_MOD2 = 0.36;}
  898.  
  899. ESS_OBJ_COLOR = 10329774;
  900. ESS_OBJ_CTS = 2;
  901. ESS_OBJ_MOD1 = 0.15;
  902. ESS_OBJ_MOD2 = 0.40;
  903.  
  904. AUBURY_NPC_COLOR = 10657196;
  905. AUBURY_NPC_TOL = 32;
  906. AUBURY_NPC_CTS = 0;
  907. AUBURY_NPC_MOD1 = 0.40;
  908. AUBURY_NPC_MOD2 = 0.48;
  909.  
  910. AUBURY_MIN_RATIO = 0.5;
  911. AUBURY_MAX_RATIO = 2.0;
  912. AUBURY_MIN_POINTS = 3;
  913. {$Else}
  914. MIDDLE_MINE_COLOR = 8487563;
  915. BANK_AUBURY_WAITTIME = 12000;
  916.  
  917. MAGE_SYMBOL_COLOR = 1714669; // grabbed from Aerolib
  918. TRANSPORT_SYMBOL_COLOR = 2779884;
  919.  
  920. ESS_OBJ_COLOR = 8618897;
  921. ESS_OBJ_CTS = 2;
  922. ESS_OBJ_MOD1 = 0.08;
  923. ESS_OBJ_MOD2 = 0.17;
  924.  
  925. AUBURY_NPC_COLOR = 1686228; //Need to optimize this
  926. AUBURY_NPC_TOL = 10;
  927. AUBURY_NPC_CTS = 1;
  928. AUBURY_NPC_MOD1 = 0.2; //dont matter for cts1 but included for syntax compat.
  929. AUBURY_NPC_MOD2 = 0.2;
  930. {$EndIf}
  931.  
  932. var
  933. m_DebugLine : array [0..SMARTDEBUGLINES] of string;
  934. lostReasons : TStringArray;
  935.  
  936. procedure m_DrawSmartLines;
  937. {$IFDEF SMARTDRAW}
  938. var i : integer;
  939. begin
  940. for i := 0 to SMARTDEBUGLINES do
  941. SMART_DrawTextEx(false,15,(SMARTDEBUGLINES-i)*18+50, SmallChars, m_DebugLine[i], clLime);
  942. {$ELSE}
  943. begin
  944. {$ENDIF}
  945. end;
  946.  
  947. procedure m_Debug(s : string);
  948. var i : integer;
  949. begin
  950. {$IFDEF SMARTDRAW}
  951. for i := SMARTDEBUGLINES downto 1 do
  952. m_DebugLine[i] := m_DebugLine[i-1];
  953. m_DebugLine[0] := s;
  954. if (not SMART_DebugSetup) then
  955. SMART_SetupDebug;
  956. SMART_ClearCanvas;
  957. m_DrawSmartLines;
  958. {$ENDIF}
  959. writeln(s);
  960. end;
  961.  
  962. //SRL's flag procedure isn't great IMO, this function uses pixelshift to check
  963. // when we stopped moving.
  964. procedure MFlag; //Working
  965. var
  966. t : integer;
  967. begin
  968. FFlag(5);
  969. t := GetSystemTime;
  970. while (GetSystemTime-t) < 7500 do
  971. if (getPixelShift({$ifdef rs3}minimap.getBounds{$else} AREA_MM {$endif}, 200)) < 1000 then //1000 should do
  972. break;
  973. end;
  974.  
  975. // The function will return True if the point x,y is inside the polygon, or
  976. // False if it is not.
  977. //
  978. // Original C code: http://www.visibone.com/inpoly/inpoly.c.txt
  979. //
  980. // Translation from C by Felipe Monteiro de Carvalho
  981. //
  982. // License: Public Domain
  983. // Sourced from: http://wiki.freepascal.org/Geometry_in_Pascal
  984. function IsPointInPolygon(A : TPoint; APolygon: array of TPoint): Boolean;
  985. var
  986. xnew, ynew: Cardinal;
  987. xold,yold: Cardinal;
  988. x1,y1: Cardinal;
  989. x2,y2: Cardinal;
  990. i, npoints: Integer;
  991. inside: Integer = 0;
  992. begin
  993. Result := False;
  994. npoints := Length(APolygon);
  995. if (npoints < 3) then Exit;
  996. xold := APolygon[npoints-1].X;
  997. yold := APolygon[npoints-1].Y;
  998. for i := 0 to npoints - 1 do
  999. begin
  1000. xnew := APolygon[i].X;
  1001. ynew := APolygon[i].Y;
  1002. if (xnew > xold) then
  1003. begin
  1004. x1:=xold;
  1005. x2:=xnew;
  1006. y1:=yold;
  1007. y2:=ynew;
  1008. end
  1009. else
  1010. begin
  1011. x1:=xnew;
  1012. x2:=xold;
  1013. y1:=ynew;
  1014. y2:=yold;
  1015. end;
  1016. if (((xnew < A.X) = (A.X <= xold)) // edge "open" at left end
  1017. and ((A.Y-y1)*(x2-x1) < (y2-y1)*(A.X-x1))) then
  1018. begin
  1019. inside := not inside;
  1020. end;
  1021. xold:=xnew;
  1022. yold:=ynew;
  1023. end;
  1024. Result := inside <> 0;
  1025. end;
  1026.  
  1027.  
  1028. function MiddlesTPA(atpa : TPointArrayArray) : TPointArray;
  1029. var
  1030. i : integer;
  1031. begin
  1032. setlength(result, length(atpa));
  1033. for i := 0 to high(atpa) do
  1034. result[i] := MiddleTPA(atpa[i]);
  1035. end;
  1036.  
  1037.  
  1038. //Lape already exports a Randomize. I don't like that one so let's abuse one of Lape's features:
  1039. //overload allows you to define functions with the same name but different parameters
  1040. Function Randomize(x, Randomness: Integer): Integer; {$ifdef lape} overload; {$endif}
  1041. Begin
  1042. Result := RandomRange(X - Randomness, X + Randomness);
  1043. End;
  1044.  
  1045.  
  1046. function getPlayerStatus : string;
  1047. begin
  1048. result := {$IfDef RS3} players[currentPlayer].location {$else} Me.strings[42]; {$EndIf}
  1049. end;
  1050.  
  1051. procedure setPlayerStatus(state : string; lostreason : string = '');
  1052. begin
  1053. {$IfDef RS3} players[currentplayer].location {$else} Me.strings[42] {$EndIf} := state;
  1054. if lostreason <> '' then
  1055. begin
  1056. setLength(lostReasons, length(LostReasons)+1);
  1057. lostReasons[high(lostReasons)] := lostreason;
  1058. end;
  1059. end;
  1060.  
  1061.  
  1062. //Working RS3, OSRS
  1063. //Of all of Wizzup's functions in this script, this one changed the least: just one line.
  1064. Function FindBankers(Var Bank: TPoint; Var Angle: Extended): Boolean;
  1065.  
  1066. Var
  1067. I: Integer;
  1068. B, gB: TPointArray;
  1069. aTPA: T2DPointArray;
  1070.  
  1071. Begin
  1072. Result := False;
  1073.  
  1074. //FindColorsSpiralTolerance(MMCX, MMY2, B, 785125, MMX1, MMY1, MMX2, MMY2, 0);
  1075. {$IfDef RS3}
  1076. B := minimap.getDots(MM_DOT_NPC, minimap.getbounds); //Use SRL function = better :) This is the only line I changed.
  1077. {$Else}
  1078. B := getMiniMapDots('NPC');
  1079. {$EndIf}
  1080. aTPA := SplitTPA(B, 10);
  1081. SortATPASize(aTPA, True);
  1082. If Length(aTPA) = 0 Then
  1083. Exit;
  1084. B := aTPA[0];
  1085. For I := 0 To High(B) - 1 Do
  1086. Begin
  1087. If (Abs(B[I].Y - B[I + 1].Y) < 15) And (Abs(B[I].X - B[I + 1].X) < 60) Then
  1088. Begin
  1089. SetLength(gB, Length(gB) + 1);
  1090. gB[High(gB)] := B[I];
  1091. If High(gB) > 3 Then // 4 bankers.
  1092. Begin
  1093. Bank := MiddleTPA(gB);
  1094. Bank.Y := Bank.Y - 8; //second changed line, 5 to 8.
  1095. Angle := Degrees(ArcTan2(gB[0].y - gB[High(gB)].y, gB[0].x - gB[High(gB)].x)) + 90;
  1096. If Angle < 0 Then
  1097. Angle := 90 - (Angle * -1) + 270;
  1098. Result := True;
  1099. Exit;
  1100. End;
  1101. End
  1102. Else
  1103. SetLength(gB, 0);
  1104. End;
  1105. End;
  1106.  
  1107.  
  1108. //Working RS3
  1109. //Based on SRL's getSymbolColor
  1110. function MarkusFindSymbol(var p : tpoint; symbolbmp, symbolcolor : integer) : boolean;
  1111. var
  1112. acc : extended;
  1113. c : integer;
  1114. begin
  1115. if (findDeformedBitmapToleranceIn(symbolbmp, p.x, p.y, {$ifdef rs3}minimap.getbounds(){$else}inttobox(mmx1,mmy1+5,mmx2,mmy2){$endif}, 70, 0, true, acc)) then
  1116. begin
  1117. if (acc > {$ifdef rs3}minimap.{$endif}symbolAccuracy) then
  1118. repeat
  1119. c := c + 5;
  1120. // look for the symbol's color in a small box around where the bitmap was found
  1121. if (findColorTolerance(p.x, p.y, symbolcolor, p.x, p.y, p.x + 15, p.y + 5, c)) then
  1122. begin
  1123. result := getColor(p.x, p.y);
  1124.  
  1125. if (result > 0) then
  1126. begin
  1127. m_debug('Found symbol at '+toStr(p));
  1128. result := true;
  1129. exit;
  1130. end;
  1131. end;
  1132. until(c > 70); // max tolerance
  1133. end;
  1134. end;
  1135.  
  1136. //Working RS3
  1137. {$IfDef RS3}
  1138. function FindMagicSymbol(var p : TPoint) : boolean;
  1139. begin
  1140. result := MarkusFindSymbol(p, MageSymbolBMP, MAGE_SYMBOL_COLOR);
  1141. end;
  1142. {$Else}
  1143. // Taken from Essence miner 3.11; Should be rock solid
  1144. // Magic symbol finder from SRL-5/Aerolib is pretty crap
  1145. Function FindMagicSymbol(Var P: TPoint): Boolean;
  1146. //Could do something nice with the black offset here...
  1147. Var
  1148. I, J, cts: Integer;
  1149. Points, P2: TPointArray;
  1150. aTPA: T2DPointArray;
  1151. MagicSymbolColors, C: TIntegerArray;
  1152. H, S, L: Extended;
  1153.  
  1154. Begin
  1155. cts := GetColorToleranceSpeed;
  1156. ColorToleranceSpeed(2);
  1157. SetColorSpeed2Modifiers(0.20, 2.0);
  1158. Result := False;
  1159. MagicSymbolColors := [2326527, 2925567];
  1160.  
  1161. SetLength(Points, 0);
  1162. For I := 0 To High(MagicSymbolColors) Do
  1163. Begin
  1164. SetLength(P2, 0);
  1165. SetLength(C, 0);
  1166. FindColorsTolerance(P2, MagicSymbolColors[I], MMX1, MMY1, MMX2, MMY2, 18);
  1167. C := GetColors(P2);
  1168. For J := 0 To High(C) Do
  1169. Begin
  1170. ColorToHSL(C[J], H, S, L);
  1171. //If ((H > 8.5) And (H < 9.5)) Or ((H > 5.5) And (H < 7.5)) Then
  1172. If (((H > 5.5) And (H < 10.0)) Or (H < 1.0)) And (S > 85.0) Then //HSL autocolouring
  1173. Begin
  1174. SetLength(Points, Length(Points) + 1);
  1175. Points[High(Points)] := P2[J];
  1176. End;
  1177. End;
  1178. //Points := CombineTPA(Points, P2);
  1179. End;
  1180. {$IFDEF SMARTDRAW} try SMART_DebugTPA(false, Points); except end; {$ENDIF}
  1181. ColorToleranceSpeed(cts);
  1182. aTPA := SplitTPA(Points, 5);
  1183. SortATPASize(aTPA, True);
  1184. If Length(aTPA) = 0 Then
  1185. Exit;
  1186. Result := Length(aTPA[0]) > 2;
  1187. P := MiddleTPA(aTPA[0]);
  1188. If Not Result Then
  1189. m_Debug('No Aubury Shop Symbol');
  1190. End;
  1191. {$EndIf}
  1192.  
  1193. //Working RS3, OSRS
  1194. function FindTransportSymbol(var p : TPoint) : boolean;
  1195. begin
  1196. {$ifdef rs3}
  1197. result := MarkusFindSymbol(p, TransportSymbolBMP, TRANSPORT_SYMBOL_COLOR);
  1198. {$else}
  1199. result := findSymbol(p, SYMBOL_Transportation);
  1200. {$endif}
  1201. end;
  1202.  
  1203.  
  1204. //Working RS3, OSRS
  1205. Function AtMine: Boolean; //Counts the black to see if we are in the mine
  1206. Var
  1207. TPA: TPointArray;
  1208. Begin
  1209. FindColorsTolerance(TPA, 65536, {$ifdef rs3}minimap.getbounds{$else} AREA_MM {$endif}, 7, colorSetting(0));
  1210. Result := Length(TPA) > 2000;
  1211. End;
  1212.  
  1213. //Working RS3, OSRS
  1214. function InAuburyStore : boolean;
  1215. begin
  1216. result := false;
  1217. if (AtMine) then
  1218. exit;
  1219. {$ifdef rs3}
  1220. result := IsPointInPolygon(sps.getplayerpos, AuburyShopPolygon);
  1221. {$else}
  1222. result := IsPointInPolygon(RSW.getMyPos(), AuburyShopPolygon);
  1223. {$EndIf}
  1224. end;
  1225.  
  1226.  
  1227. //Broken
  1228. Function DoorClosedWizzup: Boolean;
  1229. //Note, this doorfinder is the shittiest mankind has ever invented, it only works
  1230. // 1% of the time, IF you are lucky.
  1231. Var
  1232. TP: TPoint;
  1233. TPA: TPointArray;
  1234. aTPA: T2DPointArray;
  1235. I, c: Integer;
  1236.  
  1237.  
  1238. Begin
  1239. Result := False;
  1240. //c := GetColorToleranceSpeed;
  1241. //ColorToleranceSpeed(2);
  1242. //SetColorspeed2Modifiers(0.2, 0.5);
  1243. FindColorsTolerance(TPA, 5208714, inttobox(3, 3, 515, 336), 8, colorSetting(2, 0.2, 0.5));
  1244. //aTPA := TPAToATPAEx(TPA, 50, 50);
  1245. aTPA := SplitTPA(TPA, 3);
  1246. SortATPAFrom(aTPA, IntToPoint(mscx, mscy)); //noob Wizzup forgot this one -.-'
  1247. For I := 0 To {min(15, }High(aTPA) Do // (dont) limit amount of clicks
  1248. Begin
  1249. If Length(aTPA[I]) < 320 Then
  1250. Continue;
  1251. TP := MiddleTPA(aTPA[I]);
  1252. MMouse(TP.X, TP.Y, 0, 0);
  1253. Wait(200);
  1254. If IsUpText('pen') And IsUpText('oor') Then
  1255. Begin
  1256. Result := True;
  1257. Mouse(TP, 0,0, mouse_left);
  1258. m_debug('Door opened with Wizzup? doorfinder. Call the news.');
  1259. //FFlag(0);
  1260. MFlag;
  1261. Break;
  1262. End;
  1263. End;
  1264. //ColorToleranceSpeed(c);
  1265. //SetColorspeed2Modifiers(0.2, 0.2);
  1266. End;
  1267.  
  1268. //Working RS3, sort-of working OSRS
  1269. //Wrote a new one for 4.0
  1270. //Not as genius anymore, but effective.
  1271. function DoorClosedGenius : boolean;
  1272. var
  1273. TPABox, SearchBox : TBox;
  1274. CharTPA : TPointArray;
  1275. TPA : TPointArray;
  1276. ATPA : T2DPointArray;
  1277. i, k : integer;
  1278. t : Integer;
  1279. begin
  1280. MFlag;
  1281. wait(1500+random(500)); //it missed the door once
  1282. {$IfDef RS3}
  1283. SearchBox.x1 := (Mainscreen.getBounds().x2-Mainscreen.getBounds().x1) div 4 +
  1284. MainScreen.getbounds.x1;
  1285. SearchBox.x2 := Mainscreen.getBounds.x2 - (Mainscreen.getBounds().x2-Mainscreen.getBounds().x1) div 4;
  1286. SearchBox.y1 := Mainscreen.getBounds.y1+5;
  1287. SearchBox.y2 := mainscreen.getBounds.y2-5;
  1288. {$Else}
  1289. SearchBox := IntToBox( (MSX2-MSX1) div 4 + MSX1, MSY1, MSX2 - ((MSX2-MSX1) div 4), MSY2-5);
  1290. {$EndIf}
  1291.  
  1292. t := GetSystemTime;
  1293.  
  1294. FindColorsTolerance(TPA, DOOR_COLOR, SearchBox, DOOR_TOL, colorSetting(DOOR_CTS, DOOR_MOD1, DOOR_MOD2));
  1295.  
  1296. aTPA := SpliTTPA(TPA, 4); //split it baby
  1297.  
  1298. for i := 0 to high(atpa) do //Calculate TPA density
  1299. begin
  1300. TPABox := atpa[i].getbounds;
  1301. if ((Extended(length(atpa[i])) / Extended(1+((TPABox.x2-TPAbox.x1) * (TPABox.y2 - TPABox.y1)))) < DOOR_DENSITY) then
  1302. begin
  1303. //Density too low!
  1304. tpa := ClearTPAFromTPA(tpa, atpa[i]);
  1305. end;
  1306. end;
  1307.  
  1308. ATPA := splittpa(TPA, 5); //Now with all invalid points, split the TPA in actual groups
  1309. m_debug('Found around '+ToStr(length(ATPA))+' candidates.');
  1310. SetLength(tpa, 0);
  1311. SetLength(tpa, length(atpa));
  1312.  
  1313. for i:= 0 to high(atpa) do //Calculate middles
  1314. tpa[i] := MiddleTPA(atpa[i]);
  1315. m_Debug('Finding, calculating and filtering took '+tostr(GetSystemTime-t)+' ms.'); //Usually < 700ms Pascalscript. Lape probably way faster
  1316.  
  1317. SortTPAFrom(TPA, {$IfDef RS3}mainscreen.getcenterpoint {$Else} MSCP {$EndIf});
  1318.  
  1319. For I := 0 To min(High(TPA), 5) Do //And interate them!
  1320. Begin
  1321. MMouse(TPA[i].X, TPA[i].Y, 0, 0);
  1322. Wait(200+random(50));
  1323. writeln('UT: '+getMouseOverText);
  1324. If isMouseOverText(['Door'], 250) Then
  1325. begin
  1326. m_debug('Door found, is it closed?');
  1327. If isMouseOverText(['pen'], 0) then
  1328. Begin
  1329. Result := True;
  1330. ClickMouse2(true);
  1331. m_debug('Door opened with the genius2 doorfinder.');
  1332. MFlag;
  1333. exit;
  1334. End else //Else, the door is already closed
  1335. begin
  1336. writeln('not open bcz: '+getMouseOverText);
  1337. m_debug('door already open so not clicked genius2');
  1338. result := true;
  1339. exit;
  1340. end;
  1341. end;
  1342. End;
  1343. end;
  1344.  
  1345. // Broken RS3, OSRS
  1346. function DoorClosedDTM : boolean;
  1347. //I dont want too many DTMs in here, but Demise likes them so much
  1348. //and if she does the hard work, why would I? ;)
  1349. // 2012-10-12:I made my own DTM so I did the hard work xD Pretty accurate though (IF it finds it).
  1350. var
  1351. x, y : integer;
  1352. aFound : extended;
  1353. begin
  1354. result := False;
  1355. exit; //It does't work anyways
  1356.  
  1357. if FindDTMRotated(DTMAuburyDoor, x, y, msx1, msy1, msx2, msy2, -Pi/4, Pi/4, Pi/60, aFound) then
  1358. begin
  1359. MMouse(x, y, 5, 5);
  1360. if WaitUpTextMulti(['Open', 'Door', 'pen D', 'oor'], 500) then //Some small tweaks
  1361. begin
  1362. Result := True;
  1363. ClickMouse2(true);
  1364. m_debug('Door opened with DTM!');
  1365. //Ok, now I need something that puts text in checkbox
  1366. //ExamineInv; //Inventory is empty lololol
  1367. MFlag;
  1368. exit;
  1369. end;
  1370. end;
  1371. m_debug('Door DTM (MS) not found.');
  1372. end;
  1373.  
  1374. //Working OSRS, srsly shit at RS3 (thanks SPS)
  1375. function CalibrateDoor : boolean;
  1376. var
  1377. p, p2: TPoint;
  1378. begin
  1379. m_debug('Calibrating door.');
  1380. result := False;
  1381. {$IfDef RS3}
  1382. if SPS_PosToMM(Point(281, 236), sps.GetPlayerPos, p) then
  1383. if FindMagicSymbol(p2) then
  1384. if (distance(p, p2) > 44) then //44 = 11 tiles
  1385. begin
  1386. result := True;
  1387. m_debug('Calibrated using magic symbol cause distanc is like '+toStr(distance(p, p2)));
  1388. Mouse(Point(p2.x, p2.y+15), mouse_Left);
  1389. MFlag;
  1390. exit;
  1391. end
  1392. result := sps.WalkToPos(Point(281, 236));
  1393. {$Else}
  1394. result := RSW.WalkPath([Point(4820, 2857)]);
  1395. {$EndIf}
  1396. MFlag;
  1397. end;
  1398.  
  1399. //Working RS3, OSRS
  1400. Function FindArrow: Boolean;
  1401.  
  1402. Var
  1403. p : tpoint;
  1404. Begin
  1405. Result := False;
  1406. { If NewAutoColorWorked Then //always returns false
  1407. If FindColor(x, y, srl_AutoGetColor('transport'), MMX1, MMY1, MMX2, MMY2) Then //Kicked new autocolor out
  1408. Begin //Note to self: USE THE BLACK =)
  1409. Result := True;
  1410. WriteLn('Succesfully used NewAutoColor for FindArrow');
  1411. End; }
  1412. If Not Result Then
  1413. If FindTransportSymbol(p) Then
  1414. Result := True;
  1415. If Result Then
  1416. Begin
  1417. Mouse(IntToPoint(p.x, p.y{$ifdef rs3}+15{$endif}), 4, 4, mouse_Left); //rs3 needs small offset
  1418. Wait(1000);
  1419. //FFlag(0);
  1420. MFlag;
  1421. FNRWait(1000);
  1422. End;
  1423. End;
  1424.  
  1425. Function EssenceCount: Integer;
  1426. {$IfNDef RS3}
  1427. var
  1428. essence : TItem;
  1429. {$EndIf}
  1430. Begin
  1431. {$IfDef RS3}
  1432. result := tabBackpack.countDTM(EssenceDTM);
  1433. {$Else}
  1434. essence.DTM := EssenceDTM;
  1435. result := essence.getAmount(true);
  1436. {$EndIf}
  1437. End;
  1438.  
  1439. //Working RS3, OSRS
  1440. function mayorObjectFinder(excludeSmall: boolean; hue, sat: extended; W, H, colour, tolerance, clickType: Integer; mouseOverText, chooseOptions: array of string): boolean;
  1441. var
  1442. i, x, y: integer;
  1443. p: TPoint;
  1444. TPA: TPointArray;
  1445. ATPA: T2DPointArray;
  1446.  
  1447. begin
  1448. if not isLoggedIn() then
  1449. exit;
  1450.  
  1451. findColorsSpiralTolerance(x, y, TPA, colour, {$IfDef RS3}mainScreen.getBounds(){$Else} AREA_MS {$EndIf}, tolerance, colorSetting(2, hue, sat));
  1452. if (Length(TPA) < 1) then exit;
  1453.  
  1454. ATPA := TPAtoATPAEx(TPA, W, H);
  1455. SortATPAFromMidPoint(ATPA,{$IfDef RS3}mainscreen.playerPoint {$Else} MSCP {$EndIf});
  1456. {$ifdef smartdraw}
  1457. smartImage.debugATPA(ATPA);
  1458. {$endif}
  1459.  
  1460. for i := 0 to high(ATPA) do
  1461. begin
  1462. if excludeSmall then
  1463. if length(ATPA[i]) < W then
  1464. continue;
  1465. mouse(MiddleTPA(ATPA[i]), 0,0, MOUSE_MOVE);
  1466. if isMouseOverText(mouseOverText, 500) then
  1467. begin
  1468. fastClick(ClickType);
  1469. if clickType = MOUSE_LEFT then
  1470. begin
  1471. {$ifdef smartdraw}
  1472. smartImage.clearArea(mainscreen.getBounds());
  1473. {$endif}
  1474. exit(true);
  1475. end;
  1476. if {$ifdef rs3}chooseOption.select(chooseOptions) {$else} chooseOptionMulti(chooseOptions) {$endif} then
  1477. begin
  1478. {$ifdef smartdraw}
  1479. smartImage.clearArea(mainscreen.getBounds());
  1480. {$endif}
  1481. exit(true);
  1482. end else
  1483. begin
  1484. gaussBox(p, {$IfDef RS3}mainscreen.getBounds(){$Else} AREA_MS {$EndIf});
  1485. mmouse(p.x, p.y,0,0);
  1486. end;
  1487. end;
  1488. end;
  1489. end;
  1490.  
  1491. //Working RS3, OSRS
  1492. function FindAuburyStore(var p : tpoint) : boolean;
  1493. var
  1494. p2 : TPoint;
  1495. begin
  1496. {$IfDef RS3}
  1497. result := SPS_PosToMM(AuburyCenter, sps.GetPlayerPos, p);
  1498. {$Else}
  1499. result := RSW.PointToMM(RSW.getMyPos(), AuburyCenter, p);
  1500. {$EndIf}
  1501. if (not(result)) then
  1502. result := FindMagicSymbol(p)
  1503. else
  1504. if FindMagicSymbol(p2) then
  1505. begin
  1506. p2.y := p2.y + 10;
  1507. if distance(p, p2) > MAX_DIST_DIFF_SPS_Sym then
  1508. begin
  1509. p := p2; // I trust magic symbol more than
  1510. m_debug('sps fucked up so we used magic symbol');
  1511. end;
  1512. end;
  1513. {$IfNDef RS3}
  1514. if P.y < 15 then
  1515. result := false;
  1516. {$EndIf}
  1517. end;
  1518.  
  1519. //"Working" RS3, OSRS (sort-of)
  1520. function DoorClosed(walk : integer = SHOP_WALK_NOT) : boolean;
  1521. var
  1522. openedDoor : boolean;
  1523. //'Kapstopfunctie'
  1524. var
  1525. p : TPoint;
  1526. begin
  1527. result := False;
  1528. openedDoor := false; // to fix a bug.
  1529.  
  1530. m_Debug('Opening door!');
  1531.  
  1532. if not CalibrateDoor then
  1533. begin
  1534. m_Debug('No calibrate door! but trying regardless because why not.');
  1535. //exit;
  1536. end;
  1537.  
  1538. if DoorClosedDTM then //Most accurate, no weird mouse movements, never works though
  1539. openedDoor := True
  1540. else if DoorClosedGenius then //Very high success rate but takes one or two mouse movements
  1541. openedDoor := True
  1542. else if DoorClosedWizzup then //utter crap
  1543. openedDoor := True;
  1544.  
  1545. result := openedDoor;
  1546. writeln('Door opener result', result);
  1547. if (openedDoor) then
  1548. if (walk = SHOP_WALK_INSIDE) then
  1549. if FindAuburyStore(p) then
  1550. begin
  1551. m_debug('Walking inside');
  1552. mouse(p, 4, 4, mouse_Left);
  1553. MFlag;
  1554. end else
  1555. begin
  1556. m_debug('We are supposed to walk in the store but could not find it.');
  1557. end;
  1558.  
  1559. end;
  1560.  
  1561.  
  1562. //Working RS3, OSRS
  1563. function openBankMayor() : boolean; //If he uses Wizzup's banker NPC finder (uncredited), I can use his bankfinder right? ;)
  1564. var
  1565. bankTimer: {$IfDef RS3}TTimeMarker{$Else}Timer{$EndIf};
  1566. p: TPoint;
  1567. angle: extended;
  1568.  
  1569. begin
  1570. bankTimer.start();
  1571. result := false;
  1572. m_debug('Opening Varrock East Bank');
  1573.  
  1574. repeat
  1575. if (not isLoggedIn) or {$ifdef rs3}bankScreen.isOpen(){$else} isBankOpen{$endif} or {$ifdef RS3} pinScreen.isOpen() {$Else} Interfaces[PINSCREEN].isVisible() {$EndIf} then
  1576. exit;
  1577.  
  1578. {$IfDef RS3}minimap.waitFlag(5);
  1579. minimap.waitPlayerMoving(350);
  1580. {$Else}
  1581. FFlag(5);
  1582. walkingToFlag(350);
  1583. {$EndIf}
  1584.  
  1585.  
  1586. if mayorObjectFinder(true, BOOTH_HUE, BOOTH_SAT, 45, 33, BOOTH_COLOUR, BOOTH_TOL, MOUSE_LEFT, ['ooth', 'ank boo'], ['ank Bank']) then
  1587. if {$ifdef RS3}(bankScreen.isOpen(5000)) or (pinScreen.isOpen(5000)) {$else} Interfaces[PINSCREEN].waitVisible(5000) or Interfaces[BANKSCREEN].waitVisible(5000) {$endif} then
  1588. begin
  1589. result := true;
  1590. exit;
  1591. end;
  1592. if mayorObjectFinder(true, BANKER_HUE, BANKER_SAT, 20, 20, BANKER_COLOUR, BANKER_TOL, MOUSE_RIGHT, ['anker', 'ank Ban'], ['ank Bank']) then
  1593. if {$ifdef RS3}(bankScreen.isOpen(5000)) or (pinScreen.isOpen(5000)) {$else} Interfaces[PINSCREEN].waitVisible(5000) or Interfaces[BANKSCREEN].waitVisible(5000) {$endif} then
  1594. begin
  1595. result := true;
  1596. exit;
  1597. end;
  1598.  
  1599. if findBankers(p, angle) then
  1600. if distance(p, point(mmcx, mmcy)) > BANKER_CLICK_TH then
  1601. mouse(p,0,0, MOUSE_LEFT)
  1602. else
  1603. begin
  1604. {$IfDef RS3}
  1605. minimap.setAngle(randomRange(35, 50));
  1606. {$Else}
  1607. setAngle(randomRange(35,50));
  1608. {$EndIf}
  1609. end;
  1610. until ({$ifdef rs3}bankTimer.getTime(){$else} bankTimer.timeElapsed(){$endif} > 120000) or (not isLoggedIn());
  1611.  
  1612. result := false;
  1613. end;
  1614.  
  1615. //Working RS3, OSRS
  1616. //Semi-working, needs a small difference
  1617. Procedure Bank(attempts : integer = 0);
  1618.  
  1619. Var
  1620. I: Integer;
  1621. P: TPoint;
  1622. A: Extended;
  1623. TempEss: Integer;
  1624.  
  1625. Begin
  1626. //ReportVars[1] := ReportVars[1] + 1; // Banks
  1627. if getPlayerStatus = 'Aubury' then
  1628. exit;
  1629. if (attempts > 8) then
  1630. begin
  1631. setPlayerStatus('Lost', 'No open bank');
  1632. exit;
  1633. end;
  1634.  
  1635. MFlag;
  1636. wait(1200+random(700)); //Small wait is worth it: makes it not misclick the bankers
  1637. //Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
  1638. For I := 0 To 2 Do
  1639. If OpenBankMayor Then //All of SRL's bankfinding is crap but I don't feel like making my own
  1640. Break
  1641. Else
  1642. If FindBankers(P, A) Then
  1643. Begin
  1644. Mouse(p, 0, 0, mouse_left);
  1645. //Wait(4000);
  1646. //FFlag(0);
  1647. MFlag;
  1648. Wait(1500);
  1649. End;
  1650.  
  1651. m_debug('Bank opened!');
  1652.  
  1653. if FindNormalRandoms then
  1654. if (not({$ifdef rs3}bankScreen.isOpen(){$else} isBankOpen{$endif} or {$ifdef RS3} pinScreen.isOpen() {$Else} Interfaces[PINSCREEN].isVisible() {$EndIf})) then
  1655. begin
  1656. Bank(attempts+1); //RECURSION! :p
  1657. exit;
  1658. end;
  1659. If Not {$ifdef rs3}bankScreen.isOpen(){$else} isBankOpen{$endif} or {$ifdef RS3} pinScreen.isOpen() {$Else} Interfaces[PINSCREEN].isVisible() {$EndIf} Then
  1660. Begin
  1661. //LogOut;
  1662. setPlayerStatus('Lost', 'No Bank');
  1663. //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'NoBank';
  1664. //{$ifdef rs3}Players[CurrentPlayer].isActive {$else} Players[CurrentPlayer].Active {$endif} := False;
  1665. Exit;
  1666. End;
  1667.  
  1668. //if PinScreen.isOpen then //fuck bankpins, not supported from now on.
  1669. // PinScreen.enter(players[0].bankPin);
  1670.  
  1671. TempEss := EssenceCount; //Move this one
  1672. EssenceMined := EssenceMined + TempEss;
  1673.  
  1674. {$IfDef RS3}
  1675. Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + TempEss;
  1676. bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
  1677. Inc(Players[CurrentPlayer].Integers[69]);
  1678. {$Else}
  1679. Me.Integers[0] := Me.Integers[0] + TempEss;
  1680. quickDeposit('inv');
  1681. Inc(Me.Integers[69]);
  1682. {$EndIf}
  1683.  
  1684.  
  1685. //if (random(3) = 1) then //RS3 makes it necessary to close it all the time
  1686. {$IfDef RS3}
  1687. CloseBank;
  1688. {$Else}
  1689. closeInterface();
  1690. {$EndIf}
  1691. End;
  1692.  
  1693. // Working RS3, OSRS
  1694. Procedure BankToAubury; //need to add a dtm to this, symbol really isnt accurate at all
  1695. Var
  1696. V: TPoint;
  1697. T: Integer;
  1698. S : String;
  1699. Begin
  1700. if (InvFull) then
  1701. Bank;
  1702. FindNormalRandoms;
  1703. T := getsystemtime;
  1704.  
  1705. {$IfDef RS3}
  1706. //if (minimap.getrunenergy() < 40) then //too bad!
  1707. // RestUntil(85+random(16));
  1708. // No resting in SRL-6??
  1709. {$EndIf}
  1710.  
  1711. SetRun(True);
  1712. {$IfDef RS3}
  1713. if (not(sps.walkToPos(AuburyCenter))) then
  1714. {$Else}
  1715. if (RSW.PointToMM(RSW.GetMyPos(), AuburyCenter, V)) then
  1716. RSW.walkPath([AuburyCenter])
  1717. else
  1718. {$EndIf}
  1719. begin
  1720. m_debug('Could not walk to store using SPS/RSW.'); //Expected for OSRS btw.
  1721. T := GetSystemTime;
  1722. MFNF(Randomize(mmcx+6, 4), Randomize(mmcy+140-85, 4), -1, -1);
  1723. MFlag;
  1724. //Walk is indeed something ike 10, 15 seconds
  1725. //As flag isn't visible, this is the right way to do it
  1726. Wait(BANK_AUBURY_WAITTIME);
  1727. MFlag;
  1728. While (GetSystemTime - T < 60000) Do
  1729. Begin
  1730. FindNormalRandoms;
  1731. //If the store is found we can exit.
  1732. If FindAuburyStore(V) Then
  1733. begin
  1734. MFNF(Randomize(V.x, 4), Randomize(V.y, 4), -1, -1);
  1735. Break;
  1736. end else
  1737. m_debug('Could not find store after click to Aubury...');
  1738. Wait(500);
  1739. End;
  1740.  
  1741. end;
  1742.  
  1743. //60 sec killswitch again, he seems to love those
  1744.  
  1745. MFlag;
  1746.  
  1747. If GetSystemTime - T >= 60000 Then
  1748. Begin
  1749. WriteLn('BankToAuburyTime');
  1750. //{$ifdef rs3} players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Lost';
  1751. setPlayerStatus('Lost', 'Bank to Aubury');
  1752. //LogOut;
  1753. Exit;
  1754. End;
  1755. MFlag;
  1756. //{$ifdef rs3} Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'NearAubury';
  1757. setPlayerStatus('NearAubury');
  1758. T3 := GetSystemTime;
  1759. End;
  1760.  
  1761. // Portal Finders
  1762.  
  1763. //DISABLED
  1764.  
  1765. //NKN
  1766. {
  1767. SetSymbol is the lower portion of the minimap symbol. Looks like a down arrow, the very bottom tip of it.
  1768. This simply sets a ddtm.
  1769. }
  1770. function SetSymbol: Integer;
  1771. var
  1772. dtmMainPoint: TSDTMPointDef;
  1773. dtmSubPoints: TSDTMPointDefArray;
  1774. TempTDTM: TSDTM;
  1775. begin
  1776.  
  1777. //result := 0;
  1778. //exit;
  1779. //DISABLED
  1780.  
  1781. SetArraylength(dtmSubPoints,5);
  1782. dtmMainPoint.x := 2803;
  1783. dtmMainPoint.y := 375;
  1784. dtmMainPoint.AreaSize := 0;
  1785. dtmMainPoint.AreaShape := 0;
  1786. dtmMainPoint.Color := 12552820;
  1787. dtmMainPoint.Tolerance := 40;
  1788.  
  1789. dtmSubPoints[0].x := 2803;
  1790. dtmSubPoints[0].y := 375;
  1791. dtmSubPoints[0].AreaSize := 0;
  1792. dtmSubPoints[0].AreaShape := 0;
  1793. dtmSubPoints[0].Color := 12552820;
  1794. dtmSubPoints[0].Tolerance := 40;
  1795.  
  1796. dtmSubPoints[1].x := 2796;
  1797. dtmSubPoints[1].y := 368;
  1798. dtmSubPoints[1].AreaSize := 0;
  1799. dtmSubPoints[1].AreaShape := 0;
  1800. dtmSubPoints[1].Color := 14461071;
  1801. dtmSubPoints[1].Tolerance := 40;
  1802.  
  1803. dtmSubPoints[2].x := 2809;
  1804. dtmSubPoints[2].y := 367;
  1805. dtmSubPoints[2].AreaSize := 0;
  1806. dtmSubPoints[2].AreaShape := 0;
  1807. dtmSubPoints[2].Color := 14724755;
  1808. dtmSubPoints[2].Tolerance := 40;
  1809.  
  1810. dtmSubPoints[3].x := 2804;
  1811. dtmSubPoints[3].y := 365;
  1812. dtmSubPoints[3].AreaSize := 0;
  1813. dtmSubPoints[3].AreaShape := 0;
  1814. dtmSubPoints[3].Color := 1805019;
  1815. dtmSubPoints[3].Tolerance := 40;
  1816.  
  1817. dtmSubPoints[4].x := 2802;
  1818. dtmSubPoints[4].y := 358;
  1819. dtmSubPoints[4].AreaSize := 0;
  1820. dtmSubPoints[4].AreaShape := 0;
  1821. dtmSubPoints[4].Color := 15254443;
  1822. dtmSubPoints[4].Tolerance := 40;
  1823.  
  1824. TempTDTM.MainPoint := dtmMainPoint;
  1825. TempTDTM.SubPoints := dtmSubPoints;
  1826. Result := AddSDTM(TempTDTM);
  1827. end;
  1828.  
  1829. // By NKN
  1830. {
  1831. It was a pain writing multiple SimilarColor statements in a if statement, so this checks multiple.
  1832. }
  1833.  
  1834. function SimilarColorMulti(color,tolerance:integer; colors:TIntegerArray):boolean;
  1835. var
  1836. i:integer;
  1837. begin
  1838. for i := 0 to high(colors) do
  1839. begin
  1840. if(similarColors(color,colors[i],tolerance)) then
  1841. exit(1);
  1842. end;
  1843. end;
  1844.  
  1845.  
  1846. // Portal finders are bit too specific as they got big updates
  1847. {$IfDef RS3}
  1848. {
  1849. Returns the point it finds the portal at.
  1850. }
  1851. //Working RS3 (and it works like a beauty!)
  1852. //FIXME MouseFindFlag (force flag for symbol)
  1853. function FindPortal3():boolean;
  1854. var
  1855. tpa,final:TpointArray;
  1856. mmLocation, symbolPoint:TPoint;
  1857. symbol,x,y,dist,i:integer;
  1858. colors,clear:TIntegerArray;
  1859. {$IfDef RS3}
  1860. marker:TTimeMarker;
  1861. {$Else}
  1862. marker:Timer;
  1863. {$EndIf}
  1864. box:TBox;
  1865. angle:extended;
  1866. pnt : TPoint;
  1867. begin
  1868. try
  1869. marker.start;
  1870. m_debug('Beginning portal detection');
  1871. symbol := setSymbol; //Sets the DDTM;
  1872. if(FindDTMRotated(symbol,x,y, Minimap.getBounds,-Pi,Pi,Pi/60,Angle)) then
  1873.  
  1874. //if (false = true) then//ie. never
  1875. begin
  1876. SymbolPoint := Point(x,y+5); //We want to detect under the point, as the portal is a few pixels below it.
  1877. m_debug('Symbol position at: '+ToStr(symbolPoint));
  1878. //print('Player position at: ' + ToStr(minimap.getCenterPoint),TDebug.DEBUG);
  1879. dist := Distance(symbolPoint,{$IfDef RS3}minimap.getCenterPoint{$Else}MMCP{$EndIf}); //Calculate the distance between the portal and you.
  1880. //print('Distance between the two points is: ' + ToStr(dist), TDebug.DEBUG);
  1881. if(dist > 25) then //If you're too far away, you'll move.
  1882. begin
  1883. Mouse(inttopoint(x,y),4,4,MOUSE_LEFT);
  1884. {$IfDef RS3}
  1885. minimap.waitFlag();
  1886. minimap.waitPlayerMoving(250);
  1887. {$Else}
  1888. FFlag(0);
  1889. walkingToFlag(250);
  1890. {$EndIf}
  1891. if(FindDTMRotated(symbol,x,y,Minimap.getBounds,-Pi,Pi,Pi/60,Angle)) then //Have to reset the position of the point to calculate a mainscreen point.
  1892. begin
  1893. m_debug('Corrected player position: '+toStr(symbolPoint));
  1894. symbolPoint := Point(x,y+5);
  1895. end else
  1896. begin
  1897. print('Moved onto DTM. Using center point.',TDebug.Warning); //If you cover the tip and the DTM won't work, this'll work instead.
  1898. symbolPoint := Point(minimap.getCenterPoint.x,minimap.getCenterPoint.y+5);
  1899. end;
  1900. end;
  1901. mmLocation := minimap.pointToMainscreen(symbolPoint); //Convert the point to a mainscreen point.
  1902. box := IntToBox(mmLocation.x - 35, mmLocation.y - 35, mmLocation.x + 35, mmLocation.y+25); //Make a small box surrounding it.
  1903. {$IFDEF SMARTDRAW}
  1904. smartImage.drawBox(box,false,clPurple);
  1905. {$ENDIF}
  1906. tpa := tpafrombox(box); //Creates a TPA from every point in the box
  1907. for i := 0 to high(tpa) do
  1908. if(not(similarColorMulti(GetColor(tpa[i]),18,[10722453,9604741,12105129,8091505,14735566,12564912,13353915,16777215,12498100,16248301,7565161]))) then //In the array are the colors of the floor/walls around it. Add more if it becomes unreliable.
  1909. Insert(tpa[i],final);
  1910.  
  1911. pnt := MiddleTPA(final); //Middle of the tpa is our return point.
  1912.  
  1913. Mouse(pnt,4,4, MOUSE_MOVE);
  1914. if (isMouseOverText(['rtal'], 50)) Then
  1915. begin
  1916. Result := true;
  1917. fastClick(MOUSE_LEFT);
  1918. exit;
  1919. end;
  1920. {$IFDEF SMARTDRAW}
  1921. smartImage.debugTPA(final);
  1922. smartImage.drawCross(pnt,5,clRed);
  1923. {$ENDIF}
  1924. //print('Finished finding the portal in: '+ToStr(marker.getTime)+'ms',TDebug.Footer);
  1925. end;
  1926. except
  1927. writeln('SHITTY EXCEPTION BLABLA');
  1928. finally
  1929. FreeDTM(symbol);
  1930. end;
  1931.  
  1932. end;
  1933.  
  1934. //Works crap
  1935. Function FindPortal2(): boolean; //Brandon
  1936. var
  1937. TPA, TPA2, TPA3, TPA4: TPointArray;
  1938. ATPA: T2DPointArray;
  1939. CTS, I: Integer;
  1940. P: TPoint;
  1941. MSBox: TBox;
  1942. Begin
  1943.  
  1944. result := false;
  1945. exit; //it causes crashes
  1946.  
  1947.  
  1948. MSBox := {$IfDef RS3}mainscreen.getbounds();{$Else} AREA_MS; {$EndIf}
  1949.  
  1950. CTS := GetToleranceSpeed;
  1951. SetColorToleranceSpeed(2);
  1952. SetToleranceSpeed2Modifiers(1.59, 0.22);
  1953.  
  1954. FindColorsTolerance(TPA, 8228993, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 19);
  1955.  
  1956. SetToleranceSpeed2Modifiers(0.08, 0.24);
  1957. FindColorsTolerance(TPA2, 8422037, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 22);
  1958.  
  1959. SetToleranceSpeed2Modifiers(3.34, 5.11);
  1960. FindColorsTolerance(TPA3, 14349274, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 10);
  1961.  
  1962. SetToleranceSpeed2Modifiers(0.07, 0.61);
  1963. FindColorsTolerance(TPA4, 12563629, MSBox.X1, MSBox.Y1, MSBox.X2, MSBox.Y2, 10);
  1964.  
  1965. try
  1966. TPA := CombineTPA(CombineTPA(TPA, TPA2), CombineTPA(TPA3, TPA4));
  1967. TPA := ReturnPointsNotInTPA(TPA, MSBox); //not sure the difference between this and InvertTPA(TPA);
  1968. ATPA := TPAToATPAEx(TPA, 38, 38);
  1969. except exit; end;
  1970.  
  1971. SortATPAFromFirstPoint(ATPA, MiddleBox(MSBox));
  1972.  
  1973. For I := 0 To min(4, High(ATPA)) Do
  1974. Begin
  1975. P := MiddleTPA(ATPA[I]);
  1976. Mouse(P, 0,0,MOUSE_MOVE);
  1977. if (isMouseOverText(['rtal'], 50)) Then
  1978. begin
  1979. Result := true;
  1980. fastClick(MOUSE_LEFT);
  1981. exit;
  1982. end;
  1983. End;
  1984. {$IFDEF SMARTDRAW}
  1985. DebugATPA(ATPA);
  1986. {$ENDIF}
  1987.  
  1988. SetColorToleranceSpeed(CTS);
  1989. SetToleranceSpeed2Modifiers(0.2, 0.2);
  1990. End;
  1991. //placeholder
  1992. function FindPortal : boolean;
  1993. begin
  1994. result := False;
  1995. end;
  1996.  
  1997. {$Else}
  1998. //copied these from 3.11 no idea how well they work
  1999.  
  2000. // Enters the portal in the rune essence mine
  2001. //Works semi-decently
  2002. function FindPortal3() : boolean; //By J J, thanks!
  2003. var
  2004. x, y : integer;
  2005. PortalColors: TPointArray;
  2006. Splitted: T2DPointArray;
  2007. P: TPoint;
  2008. i, smallestX, smallestY, biggestX, biggestY, xSize, ySize: Integer;
  2009.  
  2010. begin
  2011. // Attempts to find the portal colors
  2012. ColorToleranceSpeed(2);
  2013. SetColorSpeed2Modifiers(4.71, 2.55);
  2014. if FindColorsSpiralTolerance(MSCX, MSCY, PortalColors, 13489057, MSX1, MSY1, MSX2, MSY2, 10) then
  2015. begin
  2016. (* Colors have been found, they will be drawn on SMART in the color red
  2017. After that it will get splitted into an ATPA with a distance of 3 *)
  2018. {$IFDEF SMARTDRAW} try
  2019. SMART_DrawDotsEx(True, PortalColors, clRed); except end;
  2020. {$ENDIF}
  2021. Splitted := SplitTPA(PortalColors, 3);
  2022. SortATPASize(Splitted, True);
  2023.  
  2024. (* ATPA has been sorted on size, large to small. The biggest one will get
  2025. drawn on SMART in the color cyan. A box around will also be drawn. *)
  2026. {$IFDEF SMARTDRAW} try
  2027. SMART_DrawDotsEx(False, Splitted[0], clAqua);
  2028. SMART_DrawBoxEx(False, False, GetTPABounds(Splitted[0]), clGreen); except end;
  2029. {$ENDIF}
  2030.  
  2031. // Calculating the X and Y size of our best TPA
  2032. smallestX := MSX2;
  2033. smallestY := MSY2;
  2034. for i:=0 to high(Splitted[0]) do
  2035. begin
  2036. // Check if the X is bigger or smaller than our extreme values
  2037. if Splitted[0][i].x < smallestX then
  2038. smallestX := Splitted[0][i].x
  2039. else
  2040. if Splitted[0][i].x > biggestX then
  2041. biggestX := Splitted[0][i].x;
  2042.  
  2043. // Check if the Y is bigger or smaller than our extreme values
  2044. if Splitted[0][i].y < smallestY then
  2045. smallestY := Splitted[0][i].y
  2046. else
  2047. if Splitted[0][i].y > biggestY then
  2048. biggestY := Splitted[0][i].y;
  2049. end;
  2050.  
  2051. (* Calculating the actual size. We take 40% of the size because the outline
  2052. of a circle is two times the radius. To be sure we click on a clickable
  2053. part we take 40% instead of 50%. *)
  2054.  
  2055. //writeln('bigggestX : ' + IntToStr(biggestX) + ' en smallestX: ' + IntToStr(smallestX));
  2056. //writeln('bigggestY : ' + IntToStr(biggestY) + ' en smallestY: ' + IntToStr(smallestY));
  2057. xSize := ((biggestX - smallestX) * 4) div 10;
  2058. ySize := ((biggestY - smallestY) * 4) div 10;
  2059.  
  2060. (* The middle of the biggest TPA will get calculated and we will move the
  2061. mouse to a spot around the middle. We draw this oval on SMART. *)
  2062. P := MiddleTPA(Splitted[0]);
  2063. {$IFDEF SMARTDRAW} try
  2064. SMART_DrawEllipse(False, P, xSize, ySize, False, clYellow); except end;
  2065. {$ENDIF}
  2066. MouseOval(P.x, P.y, xSize, ySize, 2);
  2067.  
  2068. // Checking if the uptext is correct
  2069. if WaitUpTextMulti(['nter', 'ortal', 'Enter', 'Portal', 'tal', 'ter'], 500) then
  2070. begin
  2071. (* The uptext is correct, the portal has been detected! We perform a
  2072. left mouse click and wait until we have stopped moving. Result = true *)
  2073. //ClickMouse2(1);
  2074. //FFlag(0);
  2075. //while IsMoving do
  2076. // Wait(RandomRange(100, 200));
  2077. Result := True;
  2078. x := P.x; //Small modification to account for the rest of the script
  2079. y := P.y;
  2080. ClickMouse2(true);
  2081. m_Debug('Portal found with FindPortal3!');
  2082. end;
  2083.  
  2084. end;
  2085. end;
  2086.  
  2087.  
  2088. //Biggest piece of shit on earth
  2089. function FindPortal2(force : boolean): Boolean; //by euphemism, thanks!
  2090. var
  2091. Area, ColorSpeed, EdgeColor, EdgeTol, GroundColor, GroundTol, I, Match,
  2092. WallColor, WallTol: Integer;
  2093. TestPoint: TPoint;
  2094. EdgeHue, EdgeSat, GroundHue, GroundSat, WallHue, WallSat: Extended;
  2095. CharBox, AreaBox, SearchBox: TBox;
  2096. CharTPA, ColorsTPA, NewTPA, EdgeTPA, SearchTPA: TPointArray;
  2097. ResultsATPA, NewATPA: T2DPointArray;
  2098. var cx, cy: Integer;
  2099. begin
  2100.  
  2101. ColorSpeed := GetColorToleranceSpeed;
  2102. ColorToleranceSpeed(2);
  2103. SetToleranceSpeed2Modifiers(0.37, 1.57);
  2104. Match := 0;
  2105. Result := False;
  2106.  
  2107. CharBox := IntToBox(MSCX - 14, MSCY - 21, MSCX + 12, MSCY + 16);
  2108. CharTPA := TPAFromBox(CharBox);
  2109.  
  2110. //SearchBox := IntToBox(MSX1, MSY1, MSX2, MSY2);
  2111. //SearchBox := IntToBox(201, 123, 320, 231); //FASTER, BUT THIS ONLY WORKS IF YOU ARE ADJACENT TO THE PORTAL
  2112. SearchBox := IntToBox(MSCX - 80, MSCY - 80, MSCX + 80, MSCY + 80);
  2113. SearchTPA := TPAFromBox(SearchBox);
  2114.  
  2115. GroundColor := 7047023; GroundHue := 0.72; GroundSat := 0.22; GroundTol := 43;
  2116. WallColor := 16180721; WallHue := 3.42; WallSat := 7.34; WallTol := 4;
  2117. EdgeColor := 10391949; EdgeHue := 0.16; EdgeSat := 0.23; EdgeTol := 28;
  2118.  
  2119. //Find ground colours
  2120. SetToleranceSpeed2Modifiers(GroundHue, GroundSat);
  2121. if not FindColorsTolerance(NewTPA, GroundColor, SearchBox.x1, SearchBox.y1,
  2122. SearchBox.x2, SearchBox.y2, GroundTol) then
  2123. Exit;
  2124.  
  2125. //Find wall colours
  2126. SetToleranceSpeed2Modifiers(WallHue, WallSat);
  2127. FindColorsTolerance(ColorsTPA, WallColor, SearchBox.x1, SearchBox.y1,
  2128. SearchBox.x2, SearchBox.y2, WallTol);
  2129.  
  2130. //Finds wall colours
  2131. ColorsTPA := CombineTPA(ColorsTPA, NewTPA);
  2132.  
  2133. //Add edge colours, too
  2134. SetToleranceSpeed2Modifiers(EdgeHue, EdgeSat);
  2135. FindColorsTolerance(EdgeTPA, EdgeColor, SearchBox.x1, SearchBox.y1,
  2136. SearchBox.x2, SearchBox.y2, EdgeTol);
  2137.  
  2138. //SearchTPA is the entire box we are searching in,
  2139. //We remove our own character and all other points from it
  2140. AppendTPA(ColorsTPA, EdgeTPA);
  2141. NewTPA := ClearTPAFromTPA(SearchTPA, ColorsTPA);
  2142. ColorsTPA := ClearTPAFromTPA(NewTPA, CharTPA);
  2143.  
  2144. ResultsATPA := SplitTPA(ColorsTPA, 1);
  2145. SetLength(NewATPA, 0);
  2146.  
  2147. //This thing is still a miracle to me (Markus)
  2148. for I := 0 to High(ResultsATPA) do
  2149. begin
  2150.  
  2151. AreaBox := GetTPABounds(ResultsATPA[i]);
  2152. Area := ((AreaBox.X2 - AreaBox.X1) * (AreaBox.Y2 - AreaBox.Y1));
  2153.  
  2154. //Probably filters based on not being too small/large, portals arent big
  2155. if (InRange(Area, 500, 1500) and (InRange(Length(ResultsATPA[i]), 250,
  2156. 1200))) then
  2157. begin
  2158.  
  2159. SetLength(NewATPA, Length(NewATPA) + 1);
  2160. NewATPA[Match] := ResultsATPA[i];
  2161. Inc(Match);
  2162. end;
  2163. end;
  2164.  
  2165. //When no points left, no point to contine
  2166. if Length(NewATPA) = 0 then
  2167. Exit;
  2168.  
  2169. SortATPAFromMidPoint(NewATPA, IntToPoint(MSCX, MSCY));
  2170.  
  2171. //Regular (A)TPA iteration
  2172. for I := 0 to High(NewATPA) do
  2173. begin
  2174.  
  2175. TestPoint := MiddleTPA(NewATPA[i]);
  2176. {$IfDef SMARTDRAW} try
  2177. //Flashes the points, though noone watches it.
  2178. Smart_DrawDotsEx(True, NewATPA[i], clFuchsia);
  2179. m_DrawSmartLines;
  2180. except end;
  2181. {$EndIf}
  2182. MMouse(TestPoint.x, TestPoint.y, 5, 5);
  2183. writeln('P2: '+GetUpText);
  2184. if WaitUpTextMulti(['Enter', 'Portal', 'nter', 'ortal', 'er P'], 500) then
  2185. begin
  2186. Result := True;
  2187. m_debug('Portal found with FindPortal2!');
  2188. cx := TestPoint.x;
  2189. cy := TestPoint.y;
  2190. clickmouse2(true);
  2191. Break;
  2192. end else
  2193. if force then
  2194. begin
  2195. ClickMouse2(false);
  2196. if waitOptionExistsMulti(['eleport', 'all'], 500) then
  2197. begin
  2198. chooseOptionMulti(['eleport', 'all']);
  2199. cx := TestPoint.x;
  2200. cy := TestPoint.y;
  2201. result := true;
  2202. break;
  2203. end
  2204. end;
  2205. end;
  2206. end;
  2207.  
  2208. //by euphemism, try #2
  2209. //Works okay at OSRS after I fixed Euph's bugs
  2210. function FindPortal(): Boolean;
  2211. var
  2212. x1, y1, x2, y2, W, H: Integer;
  2213. CTS, ClientBitmap, I, Len: Integer;
  2214. GrabBox: TBox;
  2215. TPA: TPointArray;
  2216. ATPA: T2DPointArray;
  2217. ITarget, KMTarget: Integer;
  2218. var X, Y: Integer; force : boolean
  2219. begin
  2220.  
  2221. Result := False;
  2222. CTS := GetColorToleranceSpeed;
  2223. SetColorToleranceSpeed(2);
  2224.  
  2225. //Grabs rectangle around player, something like 7x6 tiles
  2226. ClientBitmap := BitmapFromClient(125, 65, 380, 265);
  2227. SetBitmapName(ClientBitmap, 'ClientGrab');
  2228.  
  2229. //Changes Simba's target to the bitmap we just made
  2230. KMTarget := GetKeyMouseTarget;
  2231. ITarget := GetImageTarget;
  2232. SetTargetBitmap(ClientBitmap);
  2233. SetBitmapName(ClientBitmap, 'ClientBitmap');
  2234.  
  2235. //Applies bitmap filters to make it easier to single out portal
  2236. {$IfDef LAPE} //defines could be removed, but this just works.
  2237. InvertBitmap(ClientBitmap);
  2238. PosterizeBitmap(ClientBitmap, 15);
  2239. ContrastBitmap(ClientBitmap, 1);
  2240. BrightnessBitmap(ClientBitmap, 15);
  2241. {$Else}
  2242. GetMufasaBitmap(ClientBitmap).Invert(GetMufasaBitmap(ClientBitmap));
  2243. GetMufasaBitmap(ClientBitmap).Posterize(GetMufasaBitmap(ClientBitmap), 15);
  2244. GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBitmap(ClientBitmap), 1);
  2245. GetMufasaBitmap(ClientBitmap).Brightness(GetMufasaBitmap(ClientBitmap), 15);
  2246. {$EndIf}
  2247.  
  2248. GetClientDimensions(W, H);
  2249.  
  2250. x1 := 0; y1 := 0; x2 := W - 1; y2 := H - 1;
  2251.  
  2252. //Filters out most of the ground, painting it white on bitmap
  2253. SetColorSpeed2Modifiers(0.30, 0.58);
  2254. FindColorsTolerance(TPA, 5135981, x1, y1, x2, y2, 29);
  2255. Len := Length(TPA);
  2256. for I := 0 to (Len - 1) do
  2257. FastSetPixel(ClientBitmap, TPA[i].x, TPA[i].y, clWhite);
  2258.  
  2259. //Filters out most of rocks and trees, painting them white on bitmap
  2260. SetColorSpeed2Modifiers(1.25, 0.21);
  2261. FindColorsTolerance(TPA, 9344658, x1, y1, x2, y2, 20);
  2262. Len := Length(TPA);
  2263. for I := 0 to (Len - 1) do
  2264. FastSetPixel(ClientBitmap, TPA[i].x, TPA[i].y, clWhite);
  2265.  
  2266. //Turns bitmap to greyscale and ups contrast, making portal more or less black, and most everything left a lighter grey
  2267. {$IfDef LAPE}
  2268. GreyScaleBitmap(ClientBitmap);
  2269. ContrastBitmap(ClientBitmap, 4);
  2270. {$Else}
  2271. GetMufasaBitmap(ClientBitmap).GreyScale(GetMufasaBitmap(ClientBitmap));
  2272. GetMufasaBitmap(ClientBitmap).Contrast(GetMufasaBitmap(ClientBitmap), 4);
  2273. {$EndIf}
  2274.  
  2275. //Finds the black of the portal
  2276. SetColorToleranceSpeed(0);
  2277. if not FindColorsTolerance(TPA, 2236962, x1, y1, x2, y2, 34) then
  2278. begin
  2279. SetImageTarget(ITarget);
  2280. SetKeyMouseTarget(KMTarget);
  2281. FreeBitmap(ClientBitmap);
  2282. Exit;
  2283. end;
  2284.  
  2285. SetImageTarget(ITarget);
  2286. SetKeyMouseTarget(KMTarget);
  2287. FreeBitmap(ClientBitmap);
  2288.  
  2289. SplitTPAWrap(TPA, 5, ATPA);
  2290. SortATPASize(ATPA, True);
  2291. Len := Length(ATPA);
  2292.  
  2293.  
  2294. //Loops through black groups to find one with correct dimensions
  2295. for I := 0 to (Len - 1) do
  2296. begin
  2297.  
  2298. GrabBox := GetTPABounds(ATPA[i]);
  2299.  
  2300. W := (GrabBox.x2 - GrabBox.x1);
  2301. H := (GrabBox.y2 - GrabBox.y1);
  2302.  
  2303. if (not (InRange(W, 25, 38) and InRange(H, 15, 38))) then
  2304. Continue;
  2305.  
  2306. TPA[0] := MiddleTPA(ATPA[i]);
  2307. OffSetTPA(TPA, IntToPoint(125, 65));
  2308.  
  2309. X := TPA[0].x;
  2310. Y := TPA[0].y;
  2311.  
  2312. MMouse(x, y, 5, 5);
  2313. m_debug('P1: '+GetUpText);
  2314. if (not(WaitUpTextMulti(['nter', 'ortal', 'Ent', 'Port', 'er P'], 500))) then
  2315. begin
  2316. if force then
  2317. begin
  2318. ClickMouse2(false);
  2319. if not chooseOptionMulti(['eleport', 'all']) then
  2320. continue;
  2321. end;
  2322. end else
  2323. begin
  2324. Result := True;
  2325. m_debug('Portal found with FindPortal!');
  2326. ClickMouse2(true);
  2327. Break;
  2328. end;
  2329. end;
  2330. end;
  2331. {$EndIf}
  2332.  
  2333. procedure WalkToMiddleRoom; forward; //quick 'n dirty
  2334.  
  2335. // Half-working
  2336. Procedure MineToAubury;
  2337.  
  2338. Var
  2339. x, y, T, T2, I: Integer;
  2340.  
  2341. Begin
  2342. FNRWait(1000);
  2343.  
  2344. T := GetSystemTime;
  2345. //1 minute killswitch, again
  2346. // Increased to 2 minutes for login/logout hack
  2347. While GetSystemTime - T < 120000 Do
  2348. Begin
  2349. If GetSystemTime - T > 60000 Then
  2350. begin
  2351. //SetAngle(SRL_ANGLE_LOW); //made it only less accurate
  2352. //Change compass after 60 secs, might help with portal finding
  2353. MakeCompass('E');
  2354. end;
  2355. If Not AtMine Then
  2356. Break;
  2357. FindNormalRandoms;
  2358. If Not FindArrow Then
  2359. Begin
  2360. m_debug('MineToAubury - Could not find the transportation symbol. Force Middle walking');
  2361. WalkToMiddleRoom;
  2362. //FNRWait(5000);
  2363. Continue;
  2364. End;
  2365. FindNormalRandoms;
  2366. //12 tries to find portal, should do.
  2367. //FIXME login/logout hax vs makecompass
  2368. For I := 0 To 3 Do
  2369. Begin
  2370. m_debug('Finding portal 3');
  2371. If FindPortal3() then
  2372. begin
  2373. T2 := GetSystemTime;
  2374.  
  2375. //We should really be out after 10 secs or so
  2376. While AtMine And (GetSystemTime - T2 < 10000) Do
  2377. Begin
  2378. //FindTalk;
  2379. FNRWait(500);
  2380. End;
  2381. Break;
  2382. end;
  2383. m_debug('Finding portal 2');
  2384. If FindPortal2({$IfNDef RS3}(I mod 2 = 1){$EndIf}) Then
  2385. Begin
  2386. T2 := GetSystemTime;
  2387.  
  2388. //We should really be out after 10 secs or so
  2389. While AtMine And (GetSystemTime - T2 < 10000) Do
  2390. Begin
  2391. //FindTalk;
  2392. FNRWait(500);
  2393. End;
  2394. Break;
  2395. End;
  2396. If FindPortal() Then
  2397. Begin
  2398. T2 := GetSystemTime;
  2399. While AtMine And (GetSystemTime - T2 < 10000) Do
  2400. Begin
  2401. //FindTalk;
  2402. FNRWait(500);
  2403. End;
  2404. Break;
  2405. End;
  2406. Wait(250);
  2407. if (i = 3) then
  2408. begin
  2409. {$ifdef rs3}
  2410. //m_Debug('Have you tried logging off and on again? ;-)'); //You get the referrence? Do you? You do? :D
  2411. //logout;
  2412. //LogInPlayer;
  2413. mainscreen.setAngle(MS_ANGLE_HIGH);
  2414. {$else}
  2415. //loginPlayer(false);
  2416. {$endif}
  2417. break;
  2418. end;
  2419. End;
  2420. FNRWait(1000);
  2421. FindNormalRandoms;
  2422. End;
  2423.  
  2424. //120 secs for portal finding is already quite long imo
  2425. If GetSystemTime - T >= 120000 Then
  2426. Begin
  2427. //LogOut;
  2428. if (AtMine) then
  2429. begin
  2430. m_debug('No Portal!');
  2431. //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'No Portal';
  2432. //LogOut;
  2433. setPlayerStatus('Lost', 'No Portal');
  2434. Exit;
  2435. end
  2436. End;
  2437. MakeCompass('N');
  2438. End;
  2439.  
  2440. {
  2441. //Should be replaced by something that works with Aubury shop middle
  2442. function MageSymbolDistance : integer;
  2443. var
  2444. p : TPoint;
  2445. begin
  2446. if not FindMagicSymbol(p) then
  2447. result := MaxInt
  2448. else
  2449. result := Distance(p.x, p.y, mmcx, mmcy);
  2450. end;
  2451. }
  2452.  
  2453. //Working RS3, OSRS
  2454. function FindVEBMM : boolean;
  2455. var
  2456. p : tpoint; a : extended;
  2457. begin
  2458. If FindBankers(P, A) Then
  2459. Begin
  2460. m_debug('Found bankers using NPC dots!');
  2461. Mouse(P, 0, 0, mouse_left);
  2462. FNRWait(3000);
  2463. //FFlag(0);
  2464. MFlag;
  2465. result := true;
  2466. End
  2467. Else
  2468. If FindSymbol(P, {$IfDef RS3}MM_SYMBOL_BANK{$Else} SYMBOL_bank{$EndIf}) Then
  2469. Begin
  2470. m_debug('Found bank using symbol!');
  2471. {$ifdef RS3}
  2472. p.y := p.y + 10;
  2473. {$endif}
  2474. Mouse(P, 0, 0, mouse_left);
  2475. FNRWait(3000);
  2476. //FFlag(0);
  2477. MFlag;
  2478. result := true;
  2479. End Else
  2480. Begin
  2481. m_debug('No Bank :(');
  2482. //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'No Bank';
  2483. //LogOut;
  2484. setPlayerStatus('Lost', 'No Bank MM FindVEBMM');
  2485. result := false;
  2486. End;
  2487. end;
  2488.  
  2489. //working RS3, OSRS
  2490. procedure AuburyToBank;
  2491. var
  2492. T : Integer;
  2493. P : TPoint;
  2494. begin
  2495. t := GetSystemTime; //For the 'killswitch'
  2496. FindNormalRandoms;
  2497. if (not(loggedin)) then
  2498. exit;
  2499.  
  2500. m_debug('AuburyToBank procedure started!');
  2501.  
  2502. if (InvCount < 14) then //14 is more than enough.
  2503. if (not(AtMine)) then
  2504. if (FindAuburyStore(P)) then
  2505. begin
  2506. setPlayerStatus('Aubury');
  2507. //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Aubury'; //This is so the banking won't kick in and it'll go back in
  2508. exit; //Probably couldn't find ess so we exit.
  2509. end;
  2510.  
  2511. while (GetSystemTime-T < 2*60*1000) do //2 minutes
  2512. begin
  2513. //fixme?
  2514. m_debug('Magic Mouse Click');
  2515. Mouse(IntToPoint(MMCX+(15), MMCY-(85-30)), 8, 8, mouse_left); //magic coords, still working in 2016 after updating
  2516. Wait(Randomize(5500, 500)); //Small wait, as flag has changed a tiny bit
  2517. MFlag;
  2518. FindNormalRandoms;
  2519.  
  2520. if (FindAuburyStore(P)) then
  2521. begin
  2522. m_debug('Aubury store found! Distance is '+ToStr(Distance(mmcx,mmcy,p.x,p.y)));
  2523. if (Distance(mmcx,mmcy,p.x,p.y) < AUBURY_DIST_TH) or InAuburyStore then
  2524. begin
  2525. m_debug('The threshold distance to store is too small.. Door closed??');
  2526. if (DoorClosed(SHOP_WALK_INSIDE)) then
  2527. begin
  2528. m_debug('Should have opened door succesfully.');
  2529. end else
  2530. m_Debug('No door opened. Retry walking to bank though.');
  2531. continue;
  2532. end else
  2533. if (FindVEBMM) then
  2534. begin
  2535. m_Debug('Bank found! Should be inside now.');
  2536. //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Bank';
  2537. setPlayerStatus('Bank');
  2538. exit;
  2539. end;
  2540. end else
  2541. begin
  2542. if (FindVEBMM) then
  2543. begin
  2544. m_Debug('Bank found.. Should be inside now.');
  2545. setPlayerStatus('Bank');
  2546. //{$ifdef rs3}Players[CurrentPlayer].location {$else} Players[CurrentPlayer].strings[42] {$endif} := 'Bank';
  2547. //[DONTDOTHISFUCKTHEBANKFINDING]
  2548. wait(750+random(500));
  2549. //[/dont do this]
  2550. exit;
  2551. end;
  2552. end;
  2553. end;
  2554. end;
  2555.  
  2556.  
  2557. //Working! RS3 (probably OSRS too)
  2558. Function FindAuburyText: Boolean; //Hard to test this one, or shall we get legits to say
  2559. var // FindTalk but modded. //Senventior Disthine Molenko? =)
  2560. TPA,Matches : TPointArray;
  2561. TempATPA : T2DPointArray;
  2562. I,CTS,x,y : integer;
  2563. Box : TBox;
  2564.  
  2565. begin;
  2566. //CTS := GetColorToleranceSpeed;
  2567. //ColorToleranceSpeed(1);
  2568. FindColorsTolerance(TPA, 65535, 3, 3, 515, 336, 0);
  2569. if FindTPAinTPA(aubtpa ,TPA,Matches) then //Length check inside the function ;)
  2570. For I := 0 to High(Matches) do //This is all real magic to me..
  2571. begin;
  2572. FindColorsTolerance(TPA,65535,3, Matches[I].y - 1,516,Matches[I].y + 14,0);
  2573. if High(TPA) < 0 then
  2574. Continue;
  2575.  
  2576. TempATPA := FindGapsTPA(TPA,10);
  2577. if Length(TempATPA) > 1 then
  2578. begin;
  2579. SetLength(TPA,Length(TempATPA));
  2580. For x := 0 to High(TempATPA) do
  2581. begin;
  2582. Box := GetTPABounds(TempATPA[x]);
  2583. TPA[x] := Point((Box.x2 + Box.x1) shr 1, Box.y2);
  2584. end;
  2585. SortTPAFrom(TPA,Point(Matches[I].x,Matches[I].y));
  2586. x := TPA[0].x;
  2587. y := TPA[0].y;
  2588. end else
  2589. begin;
  2590. Box := GetTPABounds(TempATPA[0]);
  2591. x := (Box.x2 + Box.x1) shr 1;
  2592. y := Box.y2;
  2593. end;
  2594. y := y + 8;
  2595. MMouse(x, y, 0, 0);
  2596. Wait(100 + Random(50));
  2597. if IsUpTextMulti(['Talk','lk-to']) then //Remember kids, 'alk' matches both 'Talk-to Aubury' AND 'Walk Here'
  2598. begin
  2599. GetMousePos(x, y);
  2600. Mouse(IntToPoint(x, y), 0, 0, mouse_right);
  2601. Wait(450 + Random(125));
  2602. If ChooseOptionMulti(['ele', 'port']) Then
  2603. Begin
  2604. Result := True;
  2605. Exit;
  2606. End;
  2607. end;
  2608. end;
  2609. //ColorToleranceSpeed(CTS);
  2610. end;
  2611.  
  2612. //Working RS3, OSRS
  2613. Function FindAubury: Boolean; //Not the best!
  2614.  
  2615. Var
  2616. I, T, cts: Integer;
  2617. P: TPoint;
  2618. PA: TPointArray;
  2619. aPA: T2DPointArray;
  2620. Middles : TPointArray;
  2621. {$IfDef RS3}
  2622. auburybox : TBox;
  2623. debugATPAS : TPointArrayArray;
  2624. {$EndIf}
  2625.  
  2626. Begin
  2627. Result := False;
  2628. if not loggedin then
  2629. exit;
  2630. //{$ifdef rs3} //FIXME
  2631. //if not(InAuburyStore) then
  2632. // if not(DoorClosed(SHOP_WALK_INSIDE)) then
  2633. // exit;
  2634. //{$endif}
  2635. {
  2636. If sps.SPS_PosToMM(AuburyShopMiddle, sps.getPlayerPos, P) Then //This part locates inside his shop
  2637. Begin
  2638. If (Distance(P.x, P.y, MMCX, MMCY) > 15) Or (Random(20) = 0) Then
  2639. Begin
  2640. //Mouse(P.x + 3, P.y + 10, 2, 2, True);
  2641. DoorClosed; //Just open the door in case we are off
  2642. Wait(1000);
  2643. //FFlag(0);
  2644. MFlag;
  2645. wait(randomize(1200, 200));
  2646. End;
  2647. End;}
  2648.  
  2649. If FindAuburyText Then
  2650. Begin
  2651. Result := True;
  2652. Exit;
  2653. End;
  2654. m_debug('Not found aubury text so lets try with color');
  2655. FindColorsTolerance(PA, AUBURY_NPC_COLOR, {$ifdef rs3}mainscreen.getbounds(){$else}AREA_MS{$endif}, AUBURY_NPC_TOL, colorsetting(AUBURY_NPC_CTS, AUBURY_NPC_MOD1, AUBURY_NPC_MOD2));
  2656. writeln('Pixelz found: '+inttostr(length(pa)));
  2657. aPA := SplitTPA(PA, 5);
  2658. {$IfDef RS3}
  2659. SortATPASize(aPA, true);
  2660. for i := 0 to high(aPA) do
  2661. begin
  2662. auburybox := aPA[i].getBounds();
  2663. //if (auburybox.getWidth() < AUBURY_MAX_WIDTH) and (auburybox.getHeight() < AUBURY_MAX_HEIGHT) then
  2664. if (length(aPA[i]) > 25) then
  2665. if inRange( extended(auburybox.getWidth()) / (auburybox.getHeight()+0.00001), AUBURY_MIN_RATIO, AUBURY_MAX_RATIO) then
  2666. begin
  2667. //setlength(debugATPAS, length(debugATPAS)+1);
  2668. //debugATPAS[high(debugATPAS)] := (aPA[i]);
  2669. Middles.append(MiddleTPA(aPA[i]));
  2670. end;
  2671. end;
  2672. SortTPAFrom(Middles, {$IfDef RS3}mainscreen.getcenterpoint{$Else} MSCP {$EndIf});
  2673. //try debugTPA(Middles); except end;
  2674. {$Else}
  2675. Middles := MiddlesTPA(aPA);
  2676. SortTPAFrom(PA, {$IfDef RS3}mainscreen.getcenterpoint{$Else} MSCP {$EndIf});
  2677. {$EndIf}
  2678. //SortATPAFrom(aPA, mainscreen.getcenterpoint); //Should do MiddlesATPA and then SortTPA (faster)
  2679. writeln('Clusters: '+inttostr(length(apa)));
  2680. For I := 0 To min(4,High(Middles)) Do //Aubury moves too fast, 5 tries is PLENTY
  2681. Begin
  2682. //Wait(200);
  2683. If AtMine Then
  2684. Begin
  2685. Result := True;
  2686. Break;
  2687. End;
  2688. {If Length(aPA[I]) < 3 Then
  2689. begin
  2690. m_debug('ATPA '+inttostr(I)+'/'+inttostr(length(aPA))+' too short! Continuing');
  2691. Continue;
  2692. end;}
  2693. MMouse(Middles[i].X, Middles[i].Y, 3, 3);
  2694. //Wait(150); //Small wait really necessary
  2695. //writeln('ut: '+getMouseOverText);
  2696. If Not WaitUpTextMulti(['bury', 'Talk'], 250) Then //Bug-fix! alk fits 'Walk', too
  2697. Continue; //instead of wait, use Wait until
  2698. clickmouse2(false);
  2699. m_debug('Aubury Uptext matches!');
  2700. Wait(50);
  2701. //writeln('here');
  2702. // writeln(GetChooseOptions('All'));
  2703. If Not ChooseOptionMulti(['elep', 'ort', 'Tel']) Then //Here, this fixes some glitching
  2704. begin
  2705. Continue;
  2706. end;
  2707. T := GetSystemTime;
  2708. While GetSystemTime - T < 15000 Do
  2709. Begin
  2710. Wait(500);
  2711. If AtMine Or (Not FindMagicSymbol(P)) Then //Good enough, it's just location checking
  2712. Break;
  2713. if {$IfNDef RS3} (pos('reach that', GetBlackChatMessage) <> 0) then{$Else}
  2714. chatbox.findtext(['reach that']) <> 0 then //handle door?
  2715. {$EndIf}
  2716. begin
  2717. m_debug('According to chat text, door might be closed.');
  2718. DoorClosed(SHOP_WALK_INSIDE);
  2719. result := False;
  2720. //ColorToleranceSpeed(1);
  2721. exit;
  2722. end;
  2723. End;
  2724. Result := GetSystemTime - T < 10500;
  2725. If AtMine Then
  2726. Result := True;
  2727. If Result Then
  2728. Break;
  2729. End;
  2730. //ColorToleranceSpeed(cts);
  2731. End;
  2732.  
  2733. Function GetCurrentTPA: TPointArray;
  2734.  
  2735. Var
  2736. cts: Integer;
  2737.  
  2738. Begin
  2739. //cts := GetColorToleranceSpeed;
  2740. //ColorToleranceSpeed(1);
  2741. FindColorsTolerance(Result, clWhite, IntToBox(MMX1, MMy1, MMX2, MMY2), 421, colorsetting(1)); //Matches everything besides pure black
  2742. //ColorToleranceSpeed(cts);
  2743. End;
  2744.  
  2745. function AmountOfGaps(ar : TBoolArray) : integer; //Better name: amount of zero-crossings
  2746. var
  2747. prevone : boolean;
  2748. i : integer;
  2749. begin
  2750. prevone := ar[0];
  2751. result := 0;
  2752. for i := 1 to high(ar) do
  2753. begin
  2754. if ar[i] <> prevone then
  2755. inc(result);
  2756. prevone := ar[i];
  2757. end;
  2758. result := result;
  2759. end;
  2760.  
  2761. //Working RS3, OSRS
  2762. procedure WalkToMiddleRoom; //No checks, nothing. Just plain clickin'
  2763. var
  2764. TPA : TPointArray;
  2765. atpa : tpointarrayarray;
  2766. p : TPoint;
  2767. tol : integer;
  2768. begin
  2769. tol := 14;
  2770. while (tol < 50) do
  2771. begin
  2772. FindColorsTolerance(tpa, MIDDLE_MINE_COLOR, IntToBox(MMX1, MMY1, MMX2, MMY2), tol, colorsetting(2, 0.75, 0.05));
  2773. atpa := splittpa(tpa, 3); // ^ dark grey colour in the mine
  2774. sortatpasize(atpa, true);
  2775. IncEx(tol, 5);
  2776. if (length(atpa) = 0) then //should never happen but to prevent AV
  2777. continue; //ok it does happen in osrs..
  2778. p := MiddleTPA(atpa[0]); //should do
  2779. m_debug('Middle walking using tol: '+inttostr(tol-5));
  2780. Mouse(p,0,0, mouse_left);
  2781. wait(500);
  2782. MFlag;
  2783. Wait(500);
  2784. exit;
  2785. end;
  2786. end;
  2787.  
  2788. //Working RS3, FIXME OSRS (needs few tweaks in colors)
  2789. function FindEss : Boolean; //ACA love
  2790. var
  2791. arP : TPointArray;
  2792. ararP: T2DPointArray;
  2793. arL, i : Integer;
  2794. P: TPoint;
  2795. // fx, fy : integer;
  2796. begin
  2797. if not(FindColorsTolerance(arP, ESS_OBJ_COLOR, {$IfDef RS3}mainscreen.getbounds(){$Else} AREA_MS{$EndIf}, 11, colorsetting(ESS_OBJ_CTS, ESS_OBJ_MOD1, ESS_OBJ_MOD2))) then
  2798. begin
  2799. m_debug('Failed to find the ess color, no object found.');
  2800. Exit;
  2801. end;
  2802.  
  2803. ararP := TPAtoATPA(arP, 50); //No Split TPA here, for a good reason!
  2804. arL := Min(10, High(ararP));//and 5 is already a lot, it should find it in 1 try
  2805. //Changed to 10 due to uptext crap
  2806.  
  2807. SortATPASize(ararP, true); //hey, I did this line of code myself, not ACA
  2808.  
  2809. for i := 0 to arL do
  2810. begin
  2811. if (Length(ararP[i]) < 10) then Continue;
  2812. P := MiddleTPA(ararP[i]);
  2813. MMouse(P.x, P.y, 5, 5);
  2814. Wait(500 + Random(100));
  2815. if (WaitUpTextMulti(['ine', 'ure', 'ssen'], 250)) then
  2816. begin;
  2817. Result := True;
  2818. ClickMouse2(True); //mine it!
  2819. //mainscreen.setangle(MS_ANGLE_HIGH);
  2820. Break;
  2821. end;
  2822. end;
  2823.  
  2824. //ColorToleranceSpeed(1);
  2825. //SetColorSpeed2Modifiers(0.2, 0.2);
  2826.  
  2827. if (i = arL + 1) then
  2828. begin
  2829. Writeln('FindEss could not find ess mine.');
  2830. Exit;
  2831. end;
  2832.  
  2833. end;
  2834.  
  2835.  
  2836. { Explanation of the location detection.
  2837.  
  2838. N
  2839. ,,.--'''''`--._
  2840. -----.XXXXXXXXXXXX`-.
  2841. ,,' `.XXXXXXXXXXXXX`.
  2842. ,' :XXXXXXXXXXXXXX`.
  2843. / ;XXXXXXXXXXXXXXXX\
  2844. / ;XXXXXXXXXXXXXXXXX'/
  2845. |' |XXXXXXXXXXXXXXXXX/|
  2846. | :XXXXXX,-.XXXXXXX/ |
  2847. | `----' `-----' |
  2848. W +---. . ,| E
  2849. '.XXX\ ,'X`. # ,--+
  2850. \.XXX`--'XXXXX`. ,'XX/
  2851. \.XXXXXXXXXXXXX: $ ;XXX,'
  2852. `.XXXXXXXXXXXX; |X,''
  2853. `..XXXXXXXX/ |,'
  2854. '-._XXX,' ,XXX=--
  2855. '`-'..../,XX'
  2856. S
  2857.  
  2858. This is the minimap of the mine when you are teleported into the middle.
  2859. Our own player is the depicted with a #. The $ is middle of the essmine.
  2860.  
  2861. What the script does, it draws a broad-bordered circle around our and then
  2862. sorta rolls it out. What happens here is that you get something like this:
  2863.  
  2864. XXXXXXXXXXXXXXXXXXXXX------XXXXXXX--XXXX---XXXXXXXXXXXXX-----------XXXXXXX
  2865. 0 360
  2866.  
  2867. What then happens is, it counts the 'gaps' in the black, or rather, the amount
  2868. of transisitions. That happens like this:
  2869.  
  2870. XXXXXXXXXXXXXXXXXXXXX------XXXXXXX--XXXX---XXXXXXXXXXXXX-----------XXXXXXX
  2871. 1 2 3 4 5 6 7 8
  2872.  
  2873. As you can see, 8 transisitions between black and white.
  2874.  
  2875. If we are detected to be inside the middle. we use one out of the two DTMs
  2876. (as there are 2 different kinds of essmines with 4 rotations = 8 mines) to
  2877. find the middle. After that the angle between $ and # is determined. In the
  2878. pic above, you can see that is around 330 degrees. 330 div 90 = 3, so we are
  2879. standing in the fourth quadrant. The script will then click somewhere at an
  2880. angle of 310 and 330 degrees here. (3*90 + randomrange(40, 50)) to enter.
  2881.  
  2882. But why does this work? Well, lets take a look at if we were teleported to
  2883. the inside of a room:
  2884.  
  2885. N
  2886. ,,.--'''''`--._
  2887. ,,''XXXXXXXXXXXXXX`-.
  2888. ,,'XXXXXXXXXX/\XXXXXXXX`.
  2889. ,'XXXXXXXXXX,' `-----.XXX`.
  2890. /XXXXXXXXXXX; `-.XX\
  2891. /XXXXXXXXXXXX; \X'.
  2892. |'XXXXXXXXXXX( :X|
  2893. |XXXXXXXXXXXXX: ;XX|
  2894. W |XXXXXXXXXXXXX| ,--'XXX| E
  2895. |XXXXXXXXXXXXX; /XXXXXX,|
  2896. '.,----.XXXXX/ # ;XXXXXXX|
  2897. X. `---' |XXXXXX/
  2898. \. ,---. +-XXXX,'
  2899. `. /XXXXX`--'XXXX,''
  2900. `.. (XXXXXXXXXXXX_,'
  2901. '-._ \XXXXXXXX_.'
  2902. '`--.\...,--'
  2903. S
  2904.  
  2905. The border would now look something like this:
  2906.  
  2907. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---------------XXXXXXXXXXXXXXXXXX
  2908. 1 2
  2909.  
  2910. As you can see, just two transitions! So this way, we can pretty accurately
  2911. determine if we are already standing in a room or not.
  2912.  
  2913. Of course there is the corner case. What if we are standing in the 'hallway'
  2914. between the room and the middle? Then we will have around 8 transitions, but
  2915. the DTM of the middle of the mine can obviously not be found.
  2916.  
  2917. The trick then is to just pretend we are inside a room and walk to the middle
  2918. of the room (which uses the darker-grey on the minimap). As usually most of
  2919. the room will be visible on the minimap, that just works :)
  2920.  
  2921. ASCII art created with JavE, ain't doing that by hand!
  2922.  
  2923. }
  2924. //Working RS3, ddtm a bit broken but sometimes works
  2925. //Semi-broken OSRS but workaround works.
  2926. function LocateInsideEssMine : boolean; //returns true if @ mine
  2927. var //VERY BAD CODING PRACTICE INSIDE!!!!
  2928. BlackArr : array [mmx1..mmx2] of array [mmy1..mmy2] of boolean;
  2929. Angles : array[0..359] of boolean;
  2930. i : integer;
  2931. radius, angle : integer;
  2932. tpa : TPointArray;
  2933. p : TPoint;
  2934. x, y : integer;
  2935. aFound : extended;
  2936. begin
  2937.  
  2938. if (not(AtMine)) then
  2939. begin
  2940. FindNormalRandoms;
  2941. if (not(AtMine)) then
  2942. begin
  2943. m_debug('Not inside essmine, exitting...');
  2944. exit;
  2945. //!!!! should handle it here !!!!
  2946. end;
  2947. end;
  2948.  
  2949. //ColorToleranceSpeed(0);
  2950. FindColorsTolerance(tpa, 0, IntToBox(mmx1, mmy1, mmx2, mmy2), 7, colorsetting(0)); //Find all the black!
  2951. //ColorToleranceSpeed(1);
  2952. writeln('found: '+inttostr(length(tpa))+' black');
  2953.  
  2954. for i := 0 to high(tpa) do
  2955. BlackArr[tpa[i].x][tpa[i].y] := True;
  2956.  
  2957. for radius := 70 downto 40 do //Minimap is 75 radius. 50 was determined experimentally
  2958. for angle := 0 to 359 do
  2959. begin
  2960. x := round(Cose(angle-90)*radius+mmcx); //cose and sine use lookup tables, so pretty quick
  2961. y := round(Sine(angle-90)*radius+mmcy);
  2962. if (BlackArr[x][y]) then //Reason for using if, we don't want to set it to false, only to true
  2963. Angles[angle] := True;
  2964. end;
  2965.  
  2966. writeln(AmountOfGaps(angles));
  2967.  
  2968.  
  2969. if(AmountOfGaps(angles) > 4) then //Only then can it really be middle..
  2970. begin
  2971. m_debug('We are standing in the middle');
  2972. if (not(FindDTMRotated(MiddleDTM1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then //DTMs are broken!
  2973. if (not(FindDTMRotated(MiddleDTM2, x, y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, Pi/360, aFound))) then
  2974. begin
  2975. m_debug('Force-walking to the middle of room..');
  2976. WalkToMiddleRoom;
  2977. if FindTransportSymbol(p) then
  2978. begin
  2979. m_debug('We weren''t in the middle indeed');
  2980. //WalkToMiddleRoom;
  2981. m_debug('should be in middle of mine now');
  2982.  
  2983. if (not(FindEss)) then
  2984. begin
  2985. NoEssFound := True;
  2986. WriteLn('No Essence Fake Middle');
  2987. end else
  2988. Result := True; //best thing is, wizzup's code doesnt even use this result
  2989. exit;
  2990. end;
  2991. m_debug('Location detection failed! No middle and no DTMs');
  2992. m_debug('Commencing login/logout hax. Not!');
  2993. LogOut;
  2994. LoginPlayer{$ifndef rs3}(False){$endif};
  2995. FindNormalRandoms;
  2996. {$IfDef RS3}
  2997. mainscreen.setAngle(MS_ANGLE_HIGH);
  2998. {$EndIf}
  2999. //Players[0].Loc := 'NoMine';
  3000. result := LocateInsideEssMine; //I <3 Recursion
  3001. exit;
  3002. end; //else
  3003. m_debug('We are standing at quadrant: '+inttostr(((Trunc(FixD(ArcTan2(y - mmcy, x - mmcx) * 180.0 / pi) / 90.0))+3)mod 4)); //thanks to mixster
  3004. x := Round(Cose((((Trunc(FixD(ArcTan2(y - mmcy, x - mmcx) * 180.0 / pi) / 90.0))+2)mod 4)*90+RandomRange(40,50))*randomrange(48,53))+mmcx; //this will randomize like wtf xd
  3005. y := Round(Sine((((Trunc(FixD(ArcTan2(y - mmcy, x - mmcx) * 180.0 / pi) / 90.0))+2)mod 4)*90+RandomRange(40,50))*randomrange(48,53))+mmcy; //x and y are both randomly generated
  3006. Mouse(IntToPoint(X, Y), 4, 4, mouse_left); //random random random
  3007. Wait(2000);
  3008. //FFlag(0);
  3009. MFlag;
  3010. Wait(500);
  3011. if(not(FindEss)) then //Does at most 5 "wacky" movements, low cost to pay compared to clicking minimap and waiting 5 seconds
  3012. begin
  3013. WalkToMiddleRoom; //Usu
  3014. //Wait(Randomize(750, 250)); //should work with this, too
  3015. if (not(FindEss)) then //Might try changing compass angle
  3016. begin
  3017. NoEssFound := True;
  3018. m_debug('No Essence');
  3019. end;
  3020. end;
  3021. end else
  3022. begin
  3023. m_debug('We are standing in a room');
  3024. m_debug('Fortunately we can walk to the middle.');
  3025. WalkToMiddleRoom;
  3026. m_debug('should be in middle of mine now');
  3027. result := true;
  3028. if (not(FindEss)) then
  3029. begin
  3030. NoEssFound := True;
  3031. m_debug('No Essence Corner');
  3032. result := false;
  3033. end;
  3034. end
  3035. end;
  3036.  
  3037. function DeathWalk : boolean;
  3038. begin
  3039. {$IfDef RS3}
  3040. result := false;
  3041. if (players[currentplayer].integers[12] > 3) then
  3042. begin
  3043. writeln('Maximum amount of deathwalk attempts reached!');
  3044. writeln('Logging out');
  3045. result := False;
  3046. logout;
  3047. players[currentplayer].isactive := false;
  3048. exit;
  3049. end;
  3050. inc(players[currentplayer].integers[12]);
  3051. writeln('Going to walk back to Varrock!');
  3052.  
  3053. if not lodestoneScreen.teleportTo(LOCATION_VARROCK, true) then
  3054. if not lodestoneScreen.teleportTo(LOCATION_LUMBRIDGE, true) then
  3055. exit;
  3056.  
  3057. if not DWSPS.walkPath(DeathWalkPath) then
  3058. //if not DWSPS.blindWalk(DeathWalkPath) then
  3059. exit;
  3060. result := FindVEBMM();
  3061. if (result) then
  3062. begin
  3063. setPlayerStatus('Bank');
  3064. players[currentplayer].integers[12] := 0;
  3065. end;
  3066. //players[currentplayer].location := 'Bank';
  3067. {$Else}
  3068. writeln('No deathwalk in OSRS yet :(');
  3069. result := false; //No deathwalk for OSRS
  3070. LogOut;
  3071. {$EndIf}
  3072. end;
  3073.  
  3074. Procedure PlayerReport;
  3075.  
  3076. Var
  3077. Active, Rand, line: string;
  3078. I: Integer;
  3079.  
  3080. Begin
  3081. {$IfDef RS3}
  3082. For I := 0 To High(Players) Do
  3083. Begin
  3084. If Players[i].isActive Then
  3085. Active := 'T'
  3086. Else
  3087. Active := 'F';
  3088. //If Players[i].Rand <> '' Then
  3089. // Rand := '; Rand: ' + Players[i].Rand
  3090. //Else
  3091. Rand := '';
  3092. WriteLn((IntToStr(I)) + ' : ' + Players[I].NickName + ' = ' +
  3093. Active + '; ' + Players[I].location + rand + '; B: ' + IntToStr(Players[I].Integers[0])
  3094. + ' Essence;'+ ' M : ' + IntToStr(Players[I].skillLevel[SKILL_MINING])); //mining level doesnt seem accurate
  3095. End;
  3096. {$EndIf}
  3097. End;
  3098.  
  3099. Procedure ProgressReport; overload;
  3100.  
  3101. Begin
  3102. WriteLn('----------------------------');
  3103. WriteLn('');
  3104. WriteLn('Wizzup? and Markus Essence Miner, Version ' + VersionNumber {$IfDef RS3}+', on RS3'{$Else}+', on OSRS'{$EndIf});
  3105. Writeln(' 10-year anniversary edition!');
  3106. WriteLn('');
  3107. WriteLn('Worked for '+ TimeRunning);
  3108. WriteLn('Mined ' + IntToStr(EssenceMined) + ' Essence at a rate of '+
  3109. inttostr(Round(Extended(EssenceMined)*60.0*60000/GetTimeRunning))+' essence an hour.'); //Float because of overflow
  3110.  
  3111. If Abyss > 0 Then WriteLn('Solved ' + IntToStr(Abyss) + ' abyssal random events.');//and it will never solve them cause the solver was removed ^-^
  3112.  
  3113. WriteLn('');
  3114. WriteLn('----------------------------');
  3115. WriteLn('');
  3116. PlayerReport;
  3117. WriteLn('');
  3118. WriteLn('----------------------------');
  3119. //stats_Commit;
  3120. //SRLRandomsReport;
  3121. End;
  3122.  
  3123. Procedure ScriptTerminate; //Not used in Simba afaik?
  3124.  
  3125. Begin
  3126. ProgressReport;
  3127. End;
  3128.  
  3129. Procedure InitPlayer;
  3130. Begin
  3131. //GetAllLevels; //Doesnt seem to work?
  3132. {SetChat('on',1);
  3133. SetChat('friends',2);
  3134. SetChat('on',3);}
  3135. MakeCompass('N');
  3136. {$IfDef RS3}mainscreen.SetAngle(MS_ANGLE_HIGH);{$Else}setAngle(ANGLE_HIGH);{$EndIf}
  3137. FindNormalRandoms;
  3138. End;
  3139.  
  3140. procedure DownloadSPSMap;
  3141. var
  3142. MapFile : integer;
  3143. begin
  3144. try
  3145. if not fileExists(IncludePath+'SPS/img/runescape_other/VEM_03.png') then
  3146. begin
  3147. MapFile := createFile(IncludePath+'SPS/img/runescape_other/VEM_03.png');
  3148. closeFile(MapFile);
  3149. MapFile := rewriteFile(IncludePath+'SPS/img/runescape_other/VEM_03.png', false);
  3150. writeFileString(MapFile, getPage(SPS_MAP_DL_LINK));
  3151. m_debug('SPS map has been downloaded!');
  3152. end;
  3153. if not fileExists(IncludePath+'SPS/img/runescape_other/bede2-lumbtovarrock.png') then
  3154. begin
  3155. MapFile := createFile(IncludePath+'SPS/img/runescape_other/bede2-lumbtovarrock.png');
  3156. closeFile(MapFile);
  3157. MapFile := rewriteFile(IncludePath+'SPS/img/runescape_other/bede2-lumbtovarrock.png', false);
  3158. writeFileString(MapFile, getPage(SPS_DWMAP_DL_LINK));
  3159. m_debug('SPS map has been downloaded!');
  3160. end;
  3161. finally
  3162. if (MapFile > 0) then
  3163. closeFile(MapFile);
  3164. end;
  3165. end;
  3166.  
  3167. Procedure SetupScript;
  3168. Begin
  3169. //SetupSRLStats(653, SRL_User, SRL_Pass)
  3170.  
  3171. DeclarePlayers;
  3172. LoginPlayer{$ifndef rs3}(false){$endif};
  3173. InitPlayer;
  3174. AubTPA := CreateTPAFromText('isthin', UpCharsEx); //Selventior Disthine Molenko!
  3175.  
  3176. //CacheBlackOffset := -1; //VERY IMPORTANT DO NOT REMOVE!!
  3177. //DO remove its broken
  3178.  
  3179. //Thanks to Demise for restoring my faith in DTMs :) These two are fully mine
  3180. MiddleDTM1 := DTMFromString('mlwAAAHicY2dgYChhYmCIBuIMIK4B4g4gjgHiOiAOAcr7A7'+ //They are broken though
  3181. 'ELEFsBcTIQxwGxFxD///+fwVyNAwW7aAkyfH79kWECIwMDPwN2zIgHQwEAMRYOKA==');
  3182. MiddleDTM2 := DTMFromString('mggAAAHicY2NgYKhiYmAoAOIGIG4H4glAnAPE4UA5JyB2BW'+
  3183. 'IfIM4G4kwgfvTmHYO9gTCDkQ4XGG/Zuw/Mn8DIwMDPgIkZcWAIAAAOAAyf');
  3184.  
  3185. DTMAuburyDoor := DTMFromString('mAAEAAHic42FgYDAGYnkodoVikJgClG0CxEZAHM8AAfx'+ //Thanks Demise, love you!
  3186. 'AzAvEAlA2NxBLA7EMEEsBsSZUHcg8USDOjrFgyIoxZyhIsGTIjDJlSI0wZciIMmPIibNkiAs0ZN'+
  3187. 'DVVGII8dBh0NYRZ6gNlgObSQpmBGImIjAbFCMDAJFbDpI='); // }
  3188.  
  3189.  
  3190. //Sorry, made my own! But thanks for the inspiration :)
  3191. // Hmm maybe the old one works better on OSRS; idk
  3192. //DTMAuburyDoor := DTMFromString('mlwAAAHicY2dgYHgOxLeA+B0QPwPi21D2USDuYWRgaIHi'+
  3193. //'NiDuheJ6IE4MNWOICTRhyE2wZShOdQCzk8PNGfr7OxlAQASIpYBYEg0z4sDMDHAAACheEeg=');
  3194.  
  3195. SetDTMName(MiddleDTM1, 'Middle DTM 1');
  3196. SetDTMName(MiddleDTM2, 'Middle DTM 2');
  3197. SetDTMName(DTMAuburyDoor, 'Aubury door DTM');
  3198.  
  3199. {$IfDef RS3}
  3200. MageSymbolBMP := BitmapFromString(10, 9, 'meJwtic1KAlEARhe9hZdmmDsuxGQ' +
  3201. '0Hb3K6DTCTGGFP2X+KyKI0cIHSFr2BLVs7UqkKIaEpFUPIPhAHSg4' +
  3202. 'i/OdzzDsqJmXMuta2e3wFBD5H3OmVIiuH79c+5/tE0A0LfXXDcPmi' +
  3203. 'pvWplt+O7cBYRK54tK6Lap1wwmrauXGAGFOnTzXsn/2Ma5fFG9mGf' +
  3204. 'ex0wSESeTazxvvo8uSah3oNW/xBAiTyBX2/N1d9WdSea0XvPtnQJh' +
  3205. 'ELl0kHnwnHATfo+DrSgHCJGqRIyHSQqS0w6SXyLTSNiBMItcvr29T' +
  3206. 'zA==');
  3207.  
  3208. TransportSymbolBMP := BitmapFromString(11, 8, 'meJxzsHdwdnZ2c3Hx9PQEMozLV1j' +
  3209. '3HXDwDQayHewd2gpTgAxnVw8n3winkGT70DT92q1qk+4bTz1rm1bt' +
  3210. '6O6VGRvm6BviktNvUbHXsPGSbuct1e670l23FSbfVZt2RSdvYlxog' +
  3211. 'GflJKOiHfIZF6Qyz0gVnpSquwBUINV5WbZirYFnWHSAt2VOp1rUVE' +
  3212. 'W3Gg0Lf20DU/nYfsmak3LJk/StnW1sbKIDfY3Cc3XMXUxNzezt7W1' +
  3213. 'tbbTCqtSDS0wsrG1tbYGuiwv207NztjC3ALLdgcDN3cHNx97B0cnJ' +
  3214. 'yRkM4oJ8TU1N7ezsgJKeYODu7gHytZuHi4srkBEb6A0A0/NYPw==');
  3215.  
  3216. EssenceDTM := DTMFromString('mlwAAAHicY2dgYOhiYWCYDsSTWSDsaiBuAOIpQDybkYFhFhBPBOIeIJ4OxMuBeAkQe7i6AnUzYcUgeVyAEQ+GAgBPowm2');
  3217.  
  3218. AuburyShopPolygon := [inttopoint(267, 224), inttopoint(275, 232),
  3219. inttopoint(283, 232), inttopoint(290, 224),inttopoint(291, 217),
  3220. inttopoint(285, 209), inttopoint(275, 209), inttopoint(275, 217),
  3221. inttopoint(267, 217)];
  3222. AuburyCenter := IntToPoint(278, 223);
  3223.  
  3224. DeathWalkPath := [[628, 1232], [591, 1179], [574, 1136], [558, 1094], [554, 1044],
  3225. [551, 1005], [498, 992], [438, 970], [371, 941], [374, 882], [384, 830],
  3226. [379, 771], [389, 711], [391, 653], [430, 599], [484, 583],
  3227. [540, 580], [546, 506], [539, 432], [546, 377], [588, 355], [639, 350],
  3228. [699, 351], [724, 388]];
  3229. {$Else}
  3230. //Copied from Aerolib
  3231. MageSymbolBMP := BitmapFromString(8, 7, 'meJxT1/9/8NhJdf3/qkv/L1y2UqHi' +
  3232. 'vzpYBMIAkkBxOBuoAMKAiMOlIBrhgnApuHpkQVbt60BxIAk3CiLIz' +
  3233. 'nMSKC6X+xTIAHIhIhBBIAIA+c9XNA==');
  3234. TransportSymbolBMP := BitmapFromString(5, 4, 'meJxLiHVNQELWeuZABOdqZb0BIrjU' +
  3235. 'lsVrgFyIGiADAGjAFTg=');
  3236.  
  3237. EssenceDTM := DTMFromString('m1gAAAHic42JgYGhlYWBoAeJ+IJ4ExO1AXA7FNUBcB8S9QOzKyMBgAcR2QOwBxMFA7APEDkBsBcRBQBwAxHEREUBTGQniJSCKCEDYJAhGAABxMwnn');
  3238.  
  3239. AuburyShopPolygon := [[4816, 2830], [4823, 2830], [4832, 2839], [4832, 2848], [4824, 2855],
  3240. [4816, 2855], [4806, 2847], [4806, 2837], [4816, 2837]];
  3241. AuburyCenter := IntToPoint(4819, 2843);
  3242.  
  3243. DeathWalkPath := [[4697, 3576], [4739, 3575], [4757, 3545], [4794, 3545], [4835, 3537],
  3244. [4845, 3490], [4829, 3459], [4814, 3429], [4811, 3390], [4795, 3354],
  3245. [4764, 3319], [4763, 3270], [4769, 3231], [4797, 3196],
  3246. [4825, 3158], [4861, 3152], [4894, 3125], [4938, 3118], [4987, 3108],
  3247. [5006, 3069], [5007, 3023], [4986, 2981], [4983, 2929], [4975, 2874],
  3248. [4971, 2827], [4960, 2788], [4944, 2748], [4910, 2735],
  3249. [4872, 2734], [4831, 2736], [4823, 2765]];
  3250. {$EndIf}
  3251. SetDTMName(EssenceDTM, 'Essence DTM');
  3252.  
  3253. {$IfDef RS3}
  3254. DownloadSPSMap;
  3255. sps.setup('VEM_03', RUNESCAPE_OTHER);
  3256. DWSPS.setup('bede2-lumbtovarrock', RUNESCAPE_OTHER);
  3257. {$Else}
  3258. RSW.init('world.png');
  3259. {$EndIf}
  3260. End;
  3261.  
  3262. procedure MainLoop(timeToRun : integer);
  3263. Var
  3264. T, T2, I:integer;// p : tpoint;
  3265. startTime : integer;
  3266. begin
  3267. startTime := GetSystemTime;
  3268. Repeat
  3269.  
  3270. if getPlayerStatus = 'Lost' then
  3271. DeathWalk;
  3272.  
  3273. if getPlayerStatus = 'Bank' then
  3274. BankToAubury;
  3275.  
  3276. If getPlayerStatus = 'NearAubury' then
  3277. begin
  3278. If ((GetSystemTime - T3) > 20000) or InAuburyStore then //Just go for it
  3279. setPlayerStatus('Aubury')
  3280. else
  3281. begin
  3282. m_debug('We zijn godverdomme niet in die winkel maar er wel vlakbij');
  3283. if DoorClosed(SHOP_WALK_INSIDE) then
  3284. begin
  3285. m_debug('We were not in store, so opened the door and walked in');
  3286. end;
  3287. end;
  3288. end;
  3289.  
  3290. If getPlayerStatus = 'Aubury' Then
  3291. Begin
  3292. T2 := GetSystemTime;
  3293. While Not AtMine Do
  3294. Begin
  3295. If GetSystemTime - T2 > 180000 Then
  3296. Begin
  3297. setPlayerStatus('Lost', 'No Aubury');
  3298. Break;
  3299. End;
  3300. //FIXME set angle high if not found after x sec.
  3301. If FindAubury Then
  3302. Begin
  3303. writeln('found aubury..');
  3304. T := GetSystemTime;
  3305. While (Not AtMine) and (GetSystemTime - t < 10000) Do Wait(250);
  3306. If AtMine Then
  3307. Break
  3308. End;
  3309. Wait(500);
  3310. End;
  3311. if AtMine then
  3312. setPlayerStatus('Mine');
  3313. //{$IfDef RS3}Players[CurrentPlayer].location{$Else}players[currentplayer].strings[42]{$EndIf} := 'Mine';
  3314. End;
  3315.  
  3316.  
  3317. If getPlayerStatus = 'Mine' Then
  3318. Begin
  3319. Wait(500);
  3320. If FindNormalRandoms Then
  3321. if (not(loggedin)) then
  3322. begin
  3323. setPlayerStatus('Random Lost');
  3324. //{$IfDef RS3}Players[CurrentPlayer].location{$Else}players[currentplayer].strings[42]{$EndIf} := 'Random lost';
  3325. continue; //Not really what I want, GOTO would be useful but oh well, this works :)
  3326. end;
  3327. LocateInsideEssMine;
  3328. T := GetSystemTime;
  3329. T2 := GetSystemTime;
  3330. While (GetSystemTime - T < 180000) And (InvCount < 28) Do
  3331. Begin
  3332. If NoEssFound Then
  3333. Begin
  3334. m_debug('We did not find any essence...');
  3335. NoEssFound := NoEssFound xor NoEssFound; //wizzup's way of saying = false;
  3336. Break;
  3337. End;
  3338. If GetSystemTime - T2 > 60000 Then
  3339. Begin
  3340. I := Random(14){$IfNDef RS3} + 21 {$EndIf}; //Seems srl 6 removed the (ugly, but necessary) tab hack
  3341. If I = {$IfDef RS3}TAB_BACKPACK{$Else} TAB_INV{$EndIf} Then I := tab_Stats; //BUT AEROLIB STILL HAS IT HAHAHHAHAHAHA (c) Me.
  3342. {$IfDef RS3}
  3343. GameTabs.openTab(I);
  3344. Wait(RandomRange(500, 4000));
  3345. GameTabs.openTab(tab_backpack);
  3346. {$Else}
  3347. GameTab(I);
  3348. Wait(RandomRange(500, 4000));
  3349. GameTab(tab_inv);
  3350. {$EndIf}
  3351. T2 := GetSystemTime;
  3352. End;
  3353.  
  3354. Wait(1000);
  3355. {$ifndef rs3}
  3356. //aerolib only looks for the black chat text.
  3357. if clickContinueEx(true) then
  3358. If LevelUp Then
  3359. Begin
  3360. WriteLn('You levelled up, congratulations!'); //Wizzup? wasn't nice here, but I am
  3361. Break;
  3362. End;
  3363. {$endif}
  3364. If FindNormalRandoms Then //The good observer sees that this is dead code on RS3
  3365. Begin
  3366. {T := GetSystemTime; //WTF is this.
  3367. While GetSystemTime - T < 5000 Do
  3368. Begin
  3369. Wait(250);
  3370. FindNormalRandoms;
  3371. End;}
  3372. FindEss;
  3373. continue;
  3374. End;
  3375. End;
  3376. MineToAubury;
  3377. AuburyToBank;
  3378. Bank;
  3379. End;
  3380.  
  3381. ProgressReport;
  3382.  
  3383. If Not LoggedIn Then
  3384. Begin
  3385. {$IfDef RS3} //srl-6 does support multiplayer lolz
  3386. NextPlayer(False);
  3387. InitPlayer;
  3388. Continue;
  3389. {$Else}
  3390. writeln('AeroLib does not seem to support > 1 player so we gotta give up');
  3391. writeln('Thanks for using Essence Miner, bye!');
  3392. TerminateScript;
  3393. {$EndIf}
  3394. End;
  3395.  
  3396. If ({$IfDef RS3} Players[CurrentPlayer].integers[69] {$Else} Me.Integers[69] {$EndIf} Mod Loads = 0) and (getPlayerStatus = 'Bank') Then
  3397. Begin
  3398. {$IfDef RS3}
  3399. NextPlayer(True);
  3400. InitPlayer;
  3401. {$EndIf}
  3402. Continue;
  3403. End;
  3404.  
  3405. { if (timeToRun > 1) then
  3406. if ((GetSystemTime - startTime) > (timeToRun*60000)) then
  3407. begin
  3408. ProgressReport;
  3409. writeln('Script stopping due to time constraint!');
  3410. writeln('Thanks for running the Essence Miner!');
  3411. end; }
  3412.  
  3413. Until False;
  3414.  
  3415. end;
  3416.  
  3417. begin
  3418. {$IfDef SMART}
  3419. //SRL_SixHourFix:= true;
  3420. //SMART_FIXSPEED := True;
  3421. {$EndIf}
  3422. ActivateClient;
  3423. {$IfDef RS3}
  3424. writeln('Running script on RuneScape 3');
  3425. SetupSRL;
  3426. {$Else}
  3427. writeln('Running script on Old-School RuneScape');
  3428. initAL;
  3429. {$EndIf}
  3430. SetupScript;
  3431.  
  3432. MainLoop(TIME_TO_RUN);
  3433.  
  3434. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement