Guest User

Untitled

a guest
Sep 15th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.74 KB | None | 0 0
  1. (*
  2. R_RangeGuilder
  3. ver 1.0.4
  4. Created by RISK
  5. *)
  6. program R_RangeGuilder;
  7. {$i SRL/SRL/MISC/SMART.simba}
  8. {$i SRL/SRL.simba}
  9. {$i SRL/SRL/MISC/PAINTSMART.simba}
  10. {$i SRL/SRL/MISC/DEBUG.simba}
  11. {$i SPS/SPS.simba}
  12.  
  13. var
  14. breakRounds, totalBreaks, competitionsDone, startingTickets,
  15. expLastReport, comInc, compsLastReport, compsDone, startTickets,
  16. curTickets, gained, expGained, expThisReport, comExp, comComps,
  17. compsThisReport: Integer;
  18.  
  19. const
  20. WORLD = 40; // What world do you wish to auto on? 0 = random
  21.  
  22. STATS_USER = ''; // What is your SRL stats username? Leave blank if you have none
  23. STATS_PASS = ''; // What is your SRL stats password? Leave blank if you have none
  24.  
  25. ENABLE_BREAKS = True; // Do you want to enable taking breaks?
  26. (* Ignore these settings if you aren't taking breaks *)
  27. BREAK_IN = 35; // Break in how many minutes?
  28. BREAK_FOR = 10; // Break for how many minutes?
  29. RAND_IN = 5; // How many minutes in randomness on BREAK_IN?
  30. RAND_FOR = 5; // How many minutes in randomness on BREAK_FOR?
  31. (* *)
  32.  
  33. AUTO_RETALIATE = True; // True = on, False = Off
  34. ENABLE_MOUSE_PAINT = True; // Do you want to have a paint trail behind the mouse?
  35. ENABLE_DEBUG_MODE = False; // Do you want to enable debugging?
  36. // This will disable debug clearing when making a progress report
  37.  
  38. (* Do not edit this segment *)
  39. MIN_CLICK_WAIT = 0;
  40. MAX_CLICK_WAIT = 1;
  41. MIN_TARGET_WAIT = 2;
  42. MAX_TARGET_WAIT = 3;
  43. HOW_MANY_COMPS = 4;
  44. CHECK_FOR_ARROWS = 0;
  45. SCRIPT_VERSION = '1.0.4';
  46. (* *)
  47.  
  48. procedure DeclarePlayers();
  49. begin
  50. HowManyPlayers := 1;
  51. NumberOfPlayers(HowManyPlayers);
  52. CurrentPlayer := 0;
  53.  
  54. with Players[0] do
  55. begin
  56. Name := ''; // What is your character's username?
  57. Pass := ''; // What is your character's password?
  58.  
  59. LampSkill := SKILL_RANGE;
  60. BoxRewards := ['xp', 'exp', 'emote', 'clothes', 'charms'];
  61.  
  62. Integers[HOW_MANY_COMPS] := 500; // How many competitions do you wish to do?
  63. Booleans[CHECK_FOR_ARROWS] := False; // Disable this if you want to use your
  64. // own arrows. Remember they must be bronze!
  65.  
  66. (* These settings are best to leave default, but you can edit them if you desire *)
  67. // If you are experiencing a lot of misclicks, you can raise 'MIN_TARGET_WAIT'
  68. // and 'MAX_TARGET_WAIT' to be customized to your lag and computer
  69. // The same goes for MIN_CLICK_WAIT and MAX_CLICK_WAIT.
  70. Integers[MIN_CLICK_WAIT] := 85;
  71. Integers[MAX_CLICK_WAIT] := 125;
  72. Integers[MIN_TARGET_WAIT] := 800;
  73. Integers[MAX_TARGET_WAIT] := 1200;
  74.  
  75. (* Each of these settings I have adjusted to work well, in what I think, will be
  76. good for everyone's purposes. But everyone has different computers and desire,
  77. so if you truly wish to make the script faster in clicking and wait times or slower,
  78. then you can modify the settings. Here is a short little 'Tutorial' on each
  79. setting:
  80.  
  81. Remember, each of these options are in milliseconds. So 1000 is one second
  82. and so on.
  83.  
  84. MIN_CLICK_WAIT = Minimum amount of time to wait before it clicks the target
  85. again.
  86.  
  87. MAX_CLICK_WAIT = Maximum amount of time to wait before it clicks the target
  88. again.
  89.  
  90. MIN_TARGET_WAIT = The minimum amount of time that the target screen is up before
  91. it attempts to close it. This is to make sure it closes the target screen if it's
  92. open for too long.
  93.  
  94. MAX_TARGET_WAIT = The maximum amount of time that the target screen is up before
  95. it attempts to close it. This is to make sure it closes the target screen if it's
  96. open for too long.
  97. (* *)
  98.  
  99. Active := True;
  100. end;
  101. end;
  102.  
  103. (*
  104.  
  105.  
  106. You do not need to and should not edit beyond this point.
  107.  
  108.  
  109. *)
  110.  
  111. procedure Write(T: string);
  112. begin
  113. WriteLn(TheTime + ': ' + T);
  114. end;
  115.  
  116. (*
  117. BenLand's function, modified by Flight(?) to have a paint trail, re-modified
  118. by RISK to disable the paint option completely if the user is not using SMART
  119. *)
  120. procedure WindMouse2(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
  121. var
  122. veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
  123. lastX, lastY: integer;
  124. sqrt2, sqrt3, sqrt5: extended;
  125. begin
  126. sqrt2:= sqrt(2);
  127. sqrt3:= sqrt(3);
  128. sqrt5:= sqrt(5);
  129. while hypot(xs - xe, ys - ye) > 1 do
  130. begin
  131. dist:= hypot(xs - xe, ys - ye);
  132. wind:= minE(wind, dist);
  133. if dist >= targetArea then
  134. begin
  135. windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
  136. windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
  137. end else
  138. begin
  139. windX:= windX / sqrt2;
  140. windY:= windY / sqrt2;
  141. if (maxStep < 3) then
  142. begin
  143. maxStep:= random(3) + 3.0;
  144. end else
  145. begin
  146. maxStep:= maxStep / sqrt5;
  147. end;
  148. end;
  149. veloX:= veloX + windX;
  150. veloY:= veloY + windY;
  151. veloX:= veloX + gravity * (xe - xs) / dist;
  152. veloY:= veloY + gravity * (ye - ys) / dist;
  153. if hypot(veloX, veloY) > maxStep then
  154. begin
  155. randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
  156. veloMag:= sqrt(veloX * veloX + veloY * veloY);
  157. veloX:= (veloX / veloMag) * randomDist;
  158. veloY:= (veloY / veloMag) * randomDist;
  159. end;
  160. lastX:= Round(xs);
  161. lastY:= Round(ys);
  162. xs:= xs + veloX;
  163. ys:= ys + veloY;
  164. if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
  165. MoveMouse(Round(xs), Round(ys));
  166. step:= hypot(xs - lastX, ys - lastY);
  167. wait(round((maxWait - minWait) * (step / maxStep) + minWait));
  168. lastdist:= dist;
  169.  
  170. {$IFDEF SMART}
  171. if (ENABLE_MOUSE_PAINT) then
  172. SMART_DrawDotsEx(False, [Point(lastX, lastY)], clWhite);
  173. {$ENDIF}
  174.  
  175. end;
  176. if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
  177. MoveMouse(Round(xe), Round(ye));
  178.  
  179. end;
  180.  
  181. (*
  182. Credits to Flight
  183. *)
  184. procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
  185. var
  186. randSpeed: extended;
  187. X,Y,X2,Y2,A,Dist,MP: integer;
  188. begin
  189. SMART_ClearCanvas;
  190. A := MouseSpeed;
  191. GetMousePos(X, Y);
  192. Dist := Distance(X, Y, eX, eY);
  193. MP := Round(Dist/150);
  194. if MP < 0 then
  195. MP := 1;
  196.  
  197. randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
  198. X2 := RandomRange(eX-(A*MP), eX+(A*MP));
  199. Y2 := RandomRange(eY-(A*MP), eY+(A*MP));
  200. WindMouse2(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
  201. GetMousePos(X, Y);
  202. MMouse(eX, eY, ranX, ranY);
  203. MouseSpeed := A;
  204. end;
  205.  
  206. procedure SetCTS(Hue, Saturation: Extended);
  207. begin
  208. SetColorToleranceSpeed(2);
  209. SetColorSpeed2Modifiers(Hue, Saturation);
  210. end;
  211.  
  212. procedure RevertCTS();
  213. begin
  214. SetColorSpeed2Modifiers(0.2, 0.2);
  215. SetColorToleranceSpeed(1);
  216. end;
  217.  
  218. procedure ExitPlayer(Message: string);
  219. begin
  220. Write(Message);
  221. Players[CurrentPlayer].Active := False;
  222. Logout;
  223. end;
  224.  
  225. procedure RClickMM;
  226. begin
  227. if (not(LoggedIn)) then
  228. Exit;
  229. if (FindNormalRandoms) then
  230. SetAngle(SRL_ANGLE_LOW);
  231.  
  232. // Mouses to the minimap and right clicks
  233. MouseBox(MMX1, MMY1, MMX2, MMY2, MOUSE_RIGHT);
  234. Wait(RandomRange(300, 400));
  235. MouseBox(MSX1, MSY1, MSX2, MSY2, MOUSE_MOVE);
  236. end;
  237.  
  238. procedure RClickChat;
  239. begin
  240. if (not(LoggedIn)) then
  241. Exit;
  242. if (FindNormalRandoms) then
  243. SetAngle(SRL_ANGLE_LOW);
  244.  
  245. if (FindNPCChatText('.', Nothing)) then
  246. Exit;
  247.  
  248. // Moves the mouse to the chat and right clicks
  249. MouseBox(MCX1, MCY1, MCX2, MCY2, MOUSE_RIGHT);
  250. Wait(RandomRange(200, 300)); // A random wait
  251. MouseBox(MSX1, MSY1, MSX2, MSY2, MOUSE_MOVE);
  252. end;
  253.  
  254. procedure RandomSpacebar;
  255. begin
  256. if (not(LoggedIn)) then
  257. Exit;
  258. if (FindNormalRandoms) then
  259. SetAngle(SRL_ANGLE_LOW);
  260.  
  261. if (FindNPCChatText('.', Nothing)) then
  262. Exit;
  263.  
  264. // Presses the spacebar
  265. KeyDown(1);
  266. Wait(RandomRange(75, 100));
  267. KeyUp(1);
  268.  
  269. // Waits before backspacing
  270. Wait(RandomRange(750, 1150));
  271.  
  272. // Backspaces to remove the space we have just typed
  273. KeyDown(1);
  274. Wait(RandomRange(300, 400));
  275. KeyUp(1);
  276. end;
  277.  
  278. (*
  279. Credits to Kyle Undefined
  280. *)
  281. function RandomRangeEx(rFrom, rTo : Variant) : Variant;
  282. var
  283. r : Variant;
  284. begin
  285. r := RandomRange(Floor(rFrom), Ceil(rTo));
  286. r := r + RandomE;
  287.  
  288. repeat
  289. begin
  290. if r <= rFrom then
  291. r := r + RandomE
  292. else if r >= rTo then
  293. r := r - RandomE;
  294. end;
  295. until ((r >= rFrom) and (r <= rTo))
  296.  
  297. r := (Trunc(r * 100) / 100.00)
  298.  
  299. Result := r;
  300. end;
  301.  
  302. // 33.0 ~ 46.7
  303. procedure FixCompass();
  304. begin
  305. if (not(LoggedIn)) then
  306. Exit;
  307. if (FindNormalRandoms) then
  308. SetAngle(SRL_ANGLE_LOW);
  309.  
  310. MakeCompass(RandomRangeEx(33.0, 46.7));
  311. end;
  312.  
  313. procedure AntiBan();
  314. begin
  315. if (not(LoggedIn)) then
  316. Exit;
  317. if (FindNormalRandoms) then
  318. SetAngle(SRL_ANGLE_LOW);
  319.  
  320. case (Random(375)) of
  321. 0 : RandomRClick;
  322. 1 :
  323. begin
  324. BoredHuman;
  325. SetAngle(SRL_ANGLE_LOW);
  326. end;
  327. 2 : ExamineInv;
  328. 3 :
  329. begin
  330. HoverSkill('Ranged', False);
  331. Wait(RandomRange(4000, 7000)); // Random wait to 'View' the skill information
  332. end;
  333. 4 : RClickChat;
  334. 5 : RClickMM;
  335. 6 .. 13 : RandomSpaceBar;
  336. 14 .. 39 : Wait(RandomRange(1000, 8000));
  337. 39 .. 70 : MouseSpeed := (RandomRange(10, 14));
  338. end;
  339. end;
  340.  
  341. function GetATPA(Col, Tol, W, H: Integer; Hue, Sat: Extended): T2DPointArray;
  342. var
  343. X, Y: Integer;
  344. TPA: TPointArray;
  345. begin
  346. if (not(LoggedIn)) then
  347. Exit;
  348. if (FindNormalRandoms) then
  349. SetAngle(SRL_ANGLE_LOW);
  350.  
  351. SetCTS(Hue, Sat);
  352. FindColorsSpiralTolerance(X, Y, TPA, Col, MSX1, MSY1, MSX2, MSY2, Tol);
  353. RevertCTS;
  354.  
  355. Result := (SplitTPAEx(TPA, W, H));
  356. end;
  357.  
  358. // Updated 2/26/2012 - Added a maximum pixel limit along side the already in
  359. // place minimum pixel limit to help with mousing over the judge instead of the
  360. // guards
  361. function R_MouseTPA(Text: string; Col, Tol, W, H: Integer; Hue, Sat: Extended): Boolean;
  362. var
  363. R, I, T, maxT, TT, maxTT: Integer;
  364. P: TPoint;
  365. ATPA: T2DPointArray;
  366. begin
  367. if (not(LoggedIn)) then
  368. Exit;
  369. if (FindNormalRandoms) then
  370. SetAngle(SRL_ANGLE_LOW);
  371.  
  372. I := 0;
  373. T := 0;
  374. TT := 0;
  375. maxT := (RandomRange(15000, 25000));
  376. maxTT := (RandomRange(6500, 7500));
  377. Result := False;
  378.  
  379. repeat
  380. MarkTime(T);
  381.  
  382. repeat
  383. if (not(LoggedIn)) then
  384. Exit;
  385. if (FindNormalRandoms) then
  386. SetAngle(SRL_ANGLE_LOW);
  387.  
  388. if (TimeFromMark(T) >= maxT) then
  389. begin
  390. Result := False;
  391. Exit;
  392. end;
  393.  
  394. ATPA := (GetATPA(Col, Tol, W, H, Hue, Sat));
  395. if (Length(ATPA) > 0) then
  396. Break;
  397.  
  398. Write('Object was not detected. Waiting.');
  399. AntiBan;
  400. Wait(RandomRange(500, 1500));
  401. until(False);
  402.  
  403. MarkTime(TT);
  404.  
  405. // What to do if the length of ATPA is greater than 0
  406. SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
  407. if (ENABLE_DEBUG_MODE) then
  408. DebugATPABounds(ATPA);
  409. for I := 0 to High(ATPA) do
  410. begin
  411. if (not(LoggedIn)) then
  412. Exit;
  413. if (FindNormalRandoms) then
  414. SetAngle(SRL_ANGLE_LOW);
  415.  
  416. if ((Length(ATPA[I]) < 15) and (Length(ATPA[I]) > 40)) then
  417. Continue;
  418.  
  419. P := (MiddleTPA(ATPA[I]));
  420. HumanMMouse(P.X, P.Y, 5, 5);
  421. Result := (WaitUpText(Text, RandomRange(750, 1500)));
  422.  
  423. if (Result) then
  424. Break;
  425.  
  426. if (TimeFromMark(TT) >= maxTT) then
  427. begin
  428. Write('Max time passed. Let''s wait and try to find the object again.');
  429. AntiBan;
  430. Wait(RandomRange(500, 1500));
  431. Break;
  432. end;
  433.  
  434. Wait(RandomRange(450, 750));
  435. end;
  436.  
  437. Inc(R);
  438. until((Result) or (R >= (RandomRange(4, 6))) or (not(LoggedIn)));
  439. end;
  440.  
  441. // Non CTS 2 version of R_MouseTPA
  442. function R_MouseObj(Text: string; Col, Tol, W, H: Integer): Boolean;
  443. var
  444. X, Y, I, T, maxT: Integer;
  445. P: TPoint;
  446. TPA: TPointArray;
  447. ATPA: T2DPointArray;
  448. begin
  449. if (not(LoggedIn)) then
  450. Exit;
  451. if (FindNormalRandoms) then
  452. SetAngle(SRL_ANGLE_LOW);
  453.  
  454. I := 0;
  455. T := 0;
  456. maxT := (RandomRange(15000, 25000));
  457.  
  458. MarkTime(T);
  459.  
  460. repeat
  461. if (not(LoggedIn)) then
  462. Exit;
  463. if (FindNormalRandoms) then
  464. SetAngle(SRL_ANGLE_LOW);
  465.  
  466. if (TimeFromMark(T) >= maxT) then
  467. begin
  468. Write('We were unable to find the object.');
  469. Result := False;
  470. Exit;
  471. end;
  472.  
  473. FindColorsSpiralTolerance(X, Y, TPA, Col, MSX1, MSY1, MSX2, MSY2, Tol);
  474. if (Length(TPA) > 0) then
  475. Break;
  476.  
  477. Write('The object is not on the screen. Waiting.');
  478. AntiBan;
  479. Wait(RandomRange(500, 1500));
  480. until(False);
  481.  
  482. // What to do if the length of TPA is greater than 0
  483. ATPA := (TPAToATPAEx(TPA, W, H));
  484. SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
  485. if (ENABLE_DEBUG_MODE) then
  486. DebugATPABounds(ATPA);
  487. for I := 0 to High(ATPA) do
  488. begin
  489. if (not(LoggedIn)) then
  490. Exit;
  491. if (FindNormalRandoms) then
  492. SetAngle(SRL_ANGLE_LOW);
  493.  
  494. P := (MiddleTPA(ATPA[I]));
  495. HumanMMouse(P.X, P.Y, 5, 5);
  496. Result := (WaitUpText(Text, RandomRange(850, 1500)));
  497.  
  498. if (Result) then
  499. Break;
  500.  
  501. AntiBan;
  502. Wait(RandomRange(250, 500));
  503. end;
  504.  
  505. if (not(Result)) then
  506. Write('We were unable to mouse the object.');
  507. end;
  508.  
  509. // Point(2525, 2945), Point(2520, 2979)
  510. // Updated 2/26/2012 thanks to Nebula's tip.
  511. procedure SPS_FixPosition;
  512. var
  513. Path: TPointArray;
  514. begin
  515. if (not(LoggedIn)) then
  516. Exit;
  517. if (FindNormalRandoms) then
  518. SetAngle(SRL_ANGLE_LOW);
  519.  
  520. Path := [Point(2525, 2945), Point(2520, 2979)];
  521.  
  522. if (SPS_WalkPath(Path)) then
  523. begin
  524. FixCompass;
  525. SetAngle(SRL_ANGLE_LOW);
  526. end else
  527. ExitPlayer('SPS repositioning failed. Logging out.');
  528. end;
  529.  
  530. // Created as the main method of fixing our position instead of SPS
  531. procedure DTM_FixPosition;
  532. var
  533. X, Y, DTM, T, maxT: Integer;
  534. E: Extended;
  535. begin
  536. if (not(LoggedIn)) then
  537. Exit;
  538. if (FindNormalRandoms) then
  539. SetAngle(SRL_ANGLE_LOW);
  540.  
  541. T := 0;
  542. maxT := (RandomRange(3000, 5000));
  543.  
  544. DTM := DTMFromString('mggAAAHicY2NgYLAAYi8gFgdiHgYIAPHVgVgAiLWgYiJALAXE1TU6DAnV2gypiaoM2SGODB1VgQx5fYYM/EA5bJgJiBmxYAgAAG0ICHo=');
  545. MarkTime(T);
  546. repeat
  547. if (not(LoggedIn)) then
  548. Exit;
  549. FindNormalRandoms;
  550.  
  551. if (TimeFromMark(T) >= maxT) then
  552. begin
  553. Write('DTM repositioning failed. Let''s try SPS.');
  554. FreeDTM(DTM);
  555. SPS_FixPosition;
  556. end;
  557.  
  558. Wait(RandomRange(75, 200));
  559. until(FindDTMRotated(DTM, X, Y, MMX1, MMY1, MMX2, MMY2, - Pi / 4, Pi / 4, Pi / 60, E));
  560.  
  561. FreeDTM(DTM);
  562.  
  563. HumanMMouse(X, Y, 5, 5);
  564. ClickMouse2(MOUSE_LEFT);
  565. FFlag(5);
  566. FixCompass;
  567. end;
  568.  
  569. // Fixes the chats so that we can detect if we have a new competition or not
  570. procedure FixChats;
  571. begin
  572. if (not(LoggedIn)) then
  573. Exit;
  574. if (FindNormalRandoms) then
  575. SetAngle(SRL_ANGLE_LOW);
  576.  
  577. SetAllChats('All', 'Off', 'Off', 'Off', 'Off', 'Off', '');
  578. end;
  579.  
  580. procedure HandleNoArrows;
  581. begin
  582. if (not(LoggedIn)) then
  583. Exit;
  584. if (FindNormalRandoms) then
  585. SetAngle(SRL_ANGLE_LOW);
  586.  
  587. if (not(FindNPCChatText('standard', Nothing))) then
  588. Exit;
  589.  
  590. ExitPlayer('We have run out of arrows to use.');
  591. Exit;
  592. end;
  593.  
  594. function TargetScreen(): Boolean;
  595. begin
  596. Result := (CountColorTolerance(4500223, MSX1, MSY1, MSX2, MSY2, 10) > 100);
  597. end;
  598.  
  599. procedure CloseTargetScreen();
  600. var
  601. X, Y, DTM, I, T, maxT: Integer;
  602. begin
  603. if (not(LoggedIn)) then
  604. Exit;
  605. if (FindNormalRandoms) then
  606. SetAngle(SRL_ANGLE_LOW);
  607.  
  608. if (not(TargetScreen)) then
  609. Exit;
  610.  
  611. T := 0;
  612. maxT := (RandomRange(150000, 250000));
  613. DTM := DTMFromString('mbQAAAHicY2VgYHjKyMDwFojvQ+l7QKwJFDeEYmUoVpQRZeDk5IRj' +
  614. 'A01FBi6gODpmxILBAAA7xwas');
  615.  
  616. MarkTime(T);
  617.  
  618. while (TargetScreen) do
  619. begin
  620. if (not(LoggedIn)) then
  621. Exit;
  622. if (FindNormalRandoms) then
  623. SetAngle(SRL_ANGLE_LOW);
  624.  
  625. if (TimeFromMark(T) >= maxT) then
  626. begin
  627. FreeDTM(DTM);
  628. ExitPlayer('We were unable to close the target screen.');
  629. Exit;
  630. end;
  631.  
  632. if (FindDTM(DTM, X, Y, MSX1, MSY1, MSX2, MSY2)) then
  633. begin
  634. HumanMMouse(X, Y, 3, 3);
  635. if (not(WaitUpText('Close', RandomRange(500, 800)))) then
  636. begin
  637. FreeDTM(DTM);
  638. Exit;
  639. end;
  640.  
  641. ClickMouse2(MOUSE_LEFT);
  642. for I := 0 to 5 do
  643. begin
  644. if (not(LoggedIn)) then
  645. Exit;
  646. if (FindNormalRandoms) then
  647. SetAngle(SRL_ANGLE_LOW);
  648.  
  649. if (not(TargetScreen)) then
  650. begin
  651. FreeDTM(DTM);
  652. Exit;
  653. end;
  654.  
  655. Wait(RandomRange(500, 600));
  656. end;
  657. end;
  658. end;
  659.  
  660. FreeDTM(DTM);
  661. end;
  662.  
  663. procedure FireAtTargets();
  664. var
  665. minW, maxW, minC, maxC, I, maxI, T, TT, maxT, TTT, maxTTT, TTTT, maxTTTT: Integer;
  666. startP, curP: TPoint;
  667. begin
  668. if (not(LoggedIn)) then
  669. Exit;
  670. if (FindNormalRandoms) then
  671. SetAngle(SRL_ANGLE_LOW);
  672.  
  673. minW := (Players[CURRENTPLAYER].Integers[MIN_TARGET_WAIT]);
  674. maxW := (Players[CURRENTPLAYER].Integers[MAX_TARGET_WAIT]);
  675. minC := (Players[CURRENTPLAYER].Integers[MIN_CLICK_WAIT]);
  676. maxC := (Players[CURRENTPLAYER].Integers[MAX_CLICK_WAIT]);
  677.  
  678. I := 0;
  679. T := 0;
  680. maxT := (RandomRange(150000, 250000));
  681. TT := 0;
  682. TTT := 0;
  683. TTTT := 0;
  684. maxTTTT := (RandomRange(4000, 6000));
  685. maxTTT := (RandomRange(10000, 20000));
  686.  
  687. MarkTime(T);
  688. MarkTime(TTTT);
  689.  
  690. repeat
  691. if (not(LoggedIn)) then
  692. Exit;
  693. if (FindNormalRandoms) then
  694. SetAngle(SRL_ANGLE_LOW);
  695.  
  696. HandleNoArrows;
  697.  
  698. if (TargetScreen) then
  699. CloseTargetScreen;
  700.  
  701. if (TimeFromMark(T) >= maxT) then
  702. begin
  703. ExitPlayer('We were unable to fire at the targets.');
  704. Exit;
  705. end;
  706.  
  707. if (R_MouseObj('Fire-a', 5041405, 10, 10, 10)) then
  708. Break;
  709.  
  710. if (TimeFromMark(TTTT) >= maxTTTT) then
  711. begin
  712. Write('We were unable to find any targets. We might be out of the area.');
  713. DTM_FixPosition;
  714.  
  715. TTTT := 0;
  716. maxTTTT := (RandomRange(4000, 6000));
  717. MarkTime(TTTT);
  718.  
  719. AntiBan;
  720. Wait(RandomRange(550, 850));
  721. end;
  722.  
  723. Write('Unable to mouse over a target. Let''s wait.');
  724. //if (not(CheckCompass))) then
  725. // FixCompass;
  726. AntiBan;
  727. Wait(RandomRange(500, 1500));
  728. until(False);
  729.  
  730. GetMousePos(startP.X, startP.Y);
  731. MarkTime(TT);
  732.  
  733. repeat
  734. if (not(LoggedIn)) then
  735. Exit;
  736. if (FindNormalRandoms) then
  737. SetAngle(SRL_ANGLE_LOW);
  738.  
  739. GetMousePos(curP.X, curP.Y);
  740.  
  741. HandleNoArrows;
  742.  
  743. if (TimeFromMark(TT) >= maxT) then
  744. begin
  745. ExitPlayer('We were unable to fire at the targets.');
  746. Exit;
  747. end;
  748.  
  749. case (Random(30)) of
  750. 1 :
  751. begin
  752. GetMousePos(curP.X, curP.Y);
  753. curP.X := (curP.X + Random(2));
  754. curP.Y := (curP.Y + Random(2));
  755. HumanMMouse(curP.X, curP.Y, 0, 0);
  756. end;
  757.  
  758. 2 :
  759. begin
  760. GetMousePos(curP.X, curP.Y);
  761. curP.X := (curP.X - Random(2));
  762. curP.Y := (curP.Y - Random(2));
  763. HumanMMouse(curP.X, curP.Y, 0, 0);
  764. end;
  765.  
  766. 3 :
  767. begin
  768. GetMousePos(curP.X, curP.Y);
  769. curP.X := (curP.X - Random(2));
  770. curP.Y := (curP.Y + Random(2));
  771. HumanMMouse(curP.X, curP.Y, 0, 0);
  772. end;
  773.  
  774. 4 :
  775. begin
  776. GetMousePos(curP.X, curP.Y);
  777. curP.X := (curP.X + Random(2));
  778. curP.Y := (curP.Y - Random(2));
  779. HumanMMouse(curP.X, curP.Y, 0, 0);
  780. end;
  781. end;
  782.  
  783. // Checking to see if we have clicked to a different position
  784. if (FindNPCChatText('meant', Nothing)) then
  785. begin
  786. Write('We have moved out of the shooting range. Repositioning.');
  787. DTM_FixPosition;
  788. end;
  789.  
  790. // Misclick handling
  791. if (not(IsUpText('Fire-a')) and (not(TargetScreen))) then
  792. begin
  793. if (not(LoggedIn)) then
  794. Exit;
  795. if (FindNormalRandoms) then
  796. SetAngle(SRL_ANGLE_LOW);
  797.  
  798. HandleNoArrows;
  799.  
  800. Wait(RandomRange(500, 1500));
  801.  
  802. if (not(IsUpText('Fire-a')) and (not(TargetScreen))) then
  803. if (not(R_MouseObj('Fire-a', 5041405, 10, 10, 10))) then
  804. begin
  805. DTM_FixPosition;
  806. if (not(R_MouseObj('Fire-a', 5041405, 10, 10, 10))) then
  807. begin
  808. ExitPlayer('We have misclicked and we were unable to fix our position.');
  809. Exit;
  810. end;
  811. end else
  812. begin
  813. GetMousePos(startP.X, startP.Y);
  814. GetMousePos(curP.X, curP.Y);
  815. end;
  816. end;
  817.  
  818. // Target screen handling
  819. if (TargetScreen) then
  820. begin
  821. if (not(LoggedIn)) then
  822. Exit;
  823. if (FindNormalRandoms) then
  824. SetAngle(SRL_ANGLE_LOW);
  825.  
  826. HandleNoArrows;
  827.  
  828. // We have this here to make sure the while .. do loop works properly
  829. I := 0;
  830. maxI := (RandomRange(minW, maxW));
  831. MarkTime(TTT);
  832.  
  833. while (not(I >= maxI)) do
  834. begin
  835. if (not(LoggedIn)) then
  836. Exit;
  837. if (FindNormalRandoms) then
  838. SetAngle(SRL_ANGLE_LOW);
  839.  
  840. // Randomizes the waiting time per 'loop-thru' of the fail-safe
  841. maxI := (RandomRange(minW, maxW));
  842.  
  843. if (TimeFromMark(TTT) >= maxTTT) then
  844. begin
  845. ExitPlayer('Error in detecting the target screen.');
  846. Exit;
  847. end;
  848.  
  849. if (not(TargetScreen)) then
  850. Break;
  851.  
  852. Wait(100);
  853. IncEx(I, 100);
  854. end;
  855.  
  856. if ((I >= maxI) and ((TargetScreen))) then
  857. begin
  858. Write('The target screen has been up for ' + ToStr(maxI) + ' second(s). Closing it.');
  859. CloseTargetScreen;
  860. HumanMMouse(startP.X, startP.Y, 5, 5);
  861. end;
  862. end;
  863.  
  864. // Over the maximum amount of distance from center of target handling
  865. if (Distance(curP.X, curP.Y, startP.X, startP.Y) >= 10) then
  866. begin
  867. Write('Mouse is too far from the center of the target. Fixing it.');
  868. HumanMMouse(startP.X, startP.Y, 5, 5);
  869. end;
  870.  
  871. // Clicking handling
  872. ClickMouse2(MOUSE_LEFT);
  873. Wait(RandomRange(minC, maxC));
  874. until(FindNPCChatText('Sorry', Nothing) or (not(LoggedIn)));
  875. end;
  876.  
  877. function ArrowsEquipped: Boolean;
  878. var
  879. X, Y, DTM: Integer;
  880. begin
  881. if (not(LoggedIn)) then
  882. Exit;
  883. if (FindNormalRandoms) then
  884. SetAngle(SRL_ANGLE_LOW);
  885.  
  886. DTM := DTMFromString('mbQAAAHicY2VgYJjIxMAwG4j7gbgTiGcC8Sug+AsgfgLEb4H4HRAbKCgwuKpzAllMYDpOmJeBH8hDx4xYMBgAAO7dCag=');
  887. GameTab(26);
  888.  
  889. Result := (FindDTM(DTM, X, Y, MIX1, MIY1, MIX2, MIY2));
  890.  
  891. FreeDTM(DTM);
  892. end;
  893.  
  894. procedure EquipArrows();
  895. var
  896. DTM, I, T, maxT: Integer;
  897. P: TPoint;
  898. begin
  899. if (not(LoggedIn)) then
  900. Exit;
  901. if (FindNormalRandoms) then
  902. SetAngle(SRL_ANGLE_LOW);
  903.  
  904. I := 0;
  905. T := 0;
  906. maxT := (RandomRange(15000, 25000));
  907. DTM := DTMFromString('mbQAAAHicY2VgYJjIxMAwG4j7gbgTiGcC8Sug+AsgfgLEb4H4HRAbKCgwuKpzAllMYDpOmJeBH8hDx4xYMBgAAO7dCag=');
  908.  
  909. MarkTime(T);
  910.  
  911. repeat
  912. if (not(LoggedIn)) then
  913. Exit;
  914. if (FindNormalRandoms) then
  915. SetAngle(SRL_ANGLE_LOW);
  916.  
  917.  
  918. if (TimeFromMark(T) >= maxT) then
  919. begin
  920. FreeDTM(DTM);
  921. ExitPlayer('There are no arrows in our inventory and none are equipped. - Perhaps a DTM failure.');
  922. Exit;
  923. end;
  924.  
  925. if (FindDTM(DTM, P.X, P.Y, MIX1, MIY1, MIX2, MIY2)) then
  926. begin
  927. HumanMMouse(P.X, P.Y, 3, 3);
  928. if (WaitUpText('ze ar', RandomRange(750, 1500))) then
  929. begin
  930. ClickMouse2(MOUSE_LEFT);
  931. for I := 1 to 5 do
  932. begin
  933. if (not(LoggedIn)) then
  934. Exit;
  935. if (FindNormalRandoms) then
  936. SetAngle(SRL_ANGLE_LOW);
  937.  
  938. if (not(FindDTM(DTM, P.X, P.Y, MIX1, MIY1, MIX2, MIY2))) then
  939. begin
  940. Write('We have equipped the arrows.');
  941. FreeDTM(DTM);
  942. Exit;
  943. end;
  944.  
  945. Wait(RandomRange(100, 400));
  946. end;
  947. end;
  948. end;
  949.  
  950. Write('There are no arrows in our inventory.');
  951. AntiBan;
  952. Wait(RandomRange(750, 1500));
  953.  
  954. if (ArrowsEquipped) then
  955. begin
  956. Write('We already have arrows equipped.');
  957. Break;
  958. end;
  959. until(False);
  960.  
  961. FreeDTM(DTM);
  962. end;
  963.  
  964. // Remade 2/24/2012 to make it less 'One shot'
  965. // Modified 2/26/2012 - Removed some of the getting a new competition checks
  966. // due to my new obtained knowledge that you don't need to click the green
  967. // button or do anything after that to start a new competition. I'm sorry for
  968. // including it in the first place, I was unaware of this.
  969. procedure GetCompetition();
  970. var
  971. T, TT, TTT, maxT, maxTT, maxTTT, X, Y, iTR, cTR: Integer;
  972. B, BB: Boolean;
  973. begin
  974. if (not(LoggedIn)) then
  975. Exit;
  976. if (FindNormalRandoms) then
  977. SetAngle(SRL_ANGLE_LOW);
  978.  
  979. maxT := (RandomRange(60000, 65000));
  980. maxTT := (RandomRange(4000, 5000));
  981.  
  982. T := 0;
  983. TT := 0;
  984. TTT := 0;
  985. iTR := 0;
  986. cTR := 0;
  987.  
  988. B := False;
  989. BB := False;
  990.  
  991. MarkTime(T);
  992. MarkTime(TT);
  993. repeat
  994.  
  995. repeat // Attempts to mouse and interact with the judge
  996. if (not(LoggedIn)) then
  997. Exit;
  998. if (FindNormalRandoms) then
  999. SetAngle(SRL_ANGLE_LOW);
  1000.  
  1001. if (TargetScreen) then
  1002. CloseTargetScreen;
  1003.  
  1004.  
  1005. // Exits the character if we are unable to get a new competition
  1006. if (TimeFromMark(T) >= maxT) then
  1007. begin
  1008. ExitPlayer('We were unable to get a new competition.');
  1009. Exit;
  1010. end;
  1011.  
  1012. // Fixes the position of our character if we are unable to see the judge
  1013. if (TimeFromMark(TT) >= maxTT) then
  1014. begin
  1015. Write('We might be unable to see the judge. Let''s fix our location.');
  1016. DTM_FixPosition;
  1017. TT := 0;
  1018. maxTT := (RandomRange(4000, 5000));
  1019.  
  1020. AntiBan;
  1021. Wait(RandomRange(500, 850));
  1022. end;
  1023.  
  1024. if (R_MouseTPA('Judge', 6906979, 9, 15, 15, 0.31, 0.08)) then
  1025. begin
  1026. ClickMouse2(MOUSE_RIGHT);
  1027.  
  1028. maxTTT := (RandomRange(1500, 2000));
  1029. MarkTime(TTT);
  1030.  
  1031. // Waits for the option that the judge always has upon right click to show
  1032. while (not(OptionsExist(['k-to Comp'], False))) do
  1033. begin
  1034. if (not(LoggedIn)) then
  1035. Exit;
  1036. if (FindNormalRandoms) then
  1037. SetAngle(SRL_ANGLE_LOW);
  1038.  
  1039. if (TimeFromMark(TTT) >= maxTTT) then
  1040. Break;
  1041.  
  1042. Write('Judge options not detected. Waiting.');
  1043. Wait(100);
  1044. end;
  1045.  
  1046. if ((TimeFromMark(TTT) >= maxTTT) and (not(OptionsExist(['k-to Comp'], False)))) then
  1047. begin
  1048. Write('We might have moused over the wrong object. Trying again.');
  1049. Continue;
  1050. end;
  1051.  
  1052. if (not(WaitOption('ete Comp', RandomRange(850, 1250)))) then
  1053. begin
  1054. Write('We have a competition already.');
  1055. Exit;
  1056. end;
  1057.  
  1058. Break; // Breaks out of the first repeat .. until to complete the procedure
  1059. end;
  1060.  
  1061. Write('Waiting for the object to be on the screen.');
  1062. AntiBan;
  1063. Wait(RandomRange(500, 1500));
  1064. until(False);
  1065.  
  1066. // Handles waiting for the pay confirmation dialogue to appear
  1067. for iTR := 1 to 5 do
  1068. begin
  1069. if (not(LoggedIn)) then
  1070. Exit;
  1071. if (FindNormalRandoms) then
  1072. SetAngle(SRL_ANGLE_LOW);
  1073.  
  1074. B := (FindText(X, Y, '1', StatChars, MCX1, MCY1, MCX2, MCY2));
  1075. if (B) then
  1076. Break;
  1077.  
  1078. Write('Waiting for the pay confirmation dialogue to show.');
  1079. Wait(RandomRange(750, 1250));
  1080. end;
  1081.  
  1082. // Continues if we have timed out after waiting for the pay confirmation dialogue
  1083. if ((iTR >= 5) and (not(B))) then
  1084. Continue;
  1085.  
  1086. // Handles clicking 'Yes' for the pay confirmation dialogue
  1087. // We use MMouse here instead of HumanMMouse as HumanMMouse does not look
  1088. // like a human would when choosing a dialoge option.
  1089. MMouse(X, Y, 25, 7);
  1090. ClickMouse2(MOUSE_LEFT);
  1091.  
  1092. if (B) then
  1093. begin
  1094. Write('We have started a new competition!');
  1095. Exit;
  1096. end;
  1097. until(False);
  1098. end;
  1099.  
  1100. procedure StartGame();
  1101. var
  1102. Checking: Boolean;
  1103. begin
  1104. if (not(LoggedIn)) then
  1105. Exit;
  1106. if (FindNormalRandoms) then
  1107. SetAngle(SRL_ANGLE_LOW);
  1108.  
  1109. Checking := (Players[CURRENTPLAYER].Booleans[CHECK_FOR_ARROWS]);
  1110.  
  1111. GetCompetition;
  1112. if (Checking) then
  1113. EquipArrows;
  1114. end;
  1115.  
  1116. function TicketAmount: Integer;
  1117. var
  1118. DTM: Integer;
  1119. begin
  1120. if (not(LoggedIn)) then
  1121. Exit;
  1122. if (FindNormalRandoms) then
  1123. SetAngle(SRL_ANGLE_LOW);
  1124.  
  1125. DTM := DTMFromString('mbQAAAHicY2VgYMhlYmAoBeJ8IE4E4mQglmZkYJABYnUgVgZicSDOa4sEqmZCwfxAEh0zYsFgAABgUwRn');
  1126.  
  1127. GameTab(25);
  1128. Result := (ItemAmount('inv', 'dtm', DTM, []));
  1129.  
  1130. FreeDTM(DTM);
  1131. end;
  1132.  
  1133. // Five minute report
  1134. procedure ProgressReport;
  1135. var
  1136. XPH, CPH: Integer;
  1137. timeRan: string;
  1138. begin
  1139. if (not(ENABLE_DEBUG_MODE)) then
  1140. ClearDebug;
  1141.  
  1142. compsDone := (competitionsDone);
  1143. timeRan := (MSToTime(GetTimeRunning, Time_Bare));
  1144. startTickets := (startingTickets);
  1145. curTickets := (TicketAmount);
  1146. gained := (curTickets - startTickets);
  1147. expGained := (Gained * 5);
  1148.  
  1149. // Borrowed from Nebula's Range Guilder
  1150. CPH := (Round((competitionsDone) * 3600) / ((GetTimeRunning) / 1000));
  1151. XPH := (Round(gained * 5 * 3600) / ((GetTimeRunning) / 1000));
  1152.  
  1153. WriteLn('__________________________');
  1154. WriteLn('');
  1155. WriteLn(' RISK''s Range Guilder');
  1156. WriteLn(' Script version: ' + SCRIPT_VERSION);
  1157. WriteLn(' Time ran: ' + timeRan);
  1158. WriteLn(' Competitions done: ' + ToStr(compsDone));
  1159. WriteLn(' Competitions/h: ' + ToStr(CPH));
  1160. WriteLn(' Tickets gained: ' + ToStr(gained));
  1161. WriteLn(' EXP gained: ' + ToStr(expGained));
  1162. WriteLn(' EXP/h: ' + ToStr(XPH));
  1163. WriteLn('__________________________');
  1164. end;
  1165.  
  1166. // Created by Echo_, modified by Flight
  1167. function BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer): Boolean;
  1168. var
  1169. realTime, w, x, y, z: Integer;
  1170. begin
  1171. if not LoggedIn then
  1172. Exit;
  1173.  
  1174. w := (BreakIn * 60000);
  1175. x := (BreakFor * 60000);
  1176. y := RandomRange(-randBreakIn * 60000, randBreakIn * 60000);
  1177. z := RandomRange(-randBreakFor * 60000, randBreakFor * 60000);
  1178. realTime := ((x + z) / 60000);
  1179.  
  1180. if (HowManyPlayers = 1) then
  1181. begin
  1182. if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
  1183. else
  1184. if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
  1185. begin
  1186. Writeln('Taking a break for about ' + IntToStr(realTime) + ' minutes.');
  1187. Logout;
  1188. Wait((x) + (z));
  1189. Writeln('Logging in.');
  1190. LoginPlayer;
  1191. Result := LoggedIn;
  1192. FindNormalRandoms;
  1193. IncEx(BreakRounds, (w) + (x));
  1194. IncEx(TotalBreaks, 1);
  1195. Writeln('The next break will occur in about ' + IntToStr(realTime) + ' minutes.');
  1196. end;
  1197. end;
  1198.  
  1199. if (HowManyPlayers > 1) then
  1200. begin
  1201. if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
  1202. else
  1203. if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
  1204. begin
  1205. Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
  1206. Logout;
  1207. IncEx(BreakRounds, (w));
  1208. IncEx(TotalBreaks, 1);
  1209. NextPlayer(True);
  1210. Exit;
  1211. while (LoggedIn) do
  1212. Wait((x) + (z));
  1213. NextPlayer(True);
  1214. end;
  1215. end;
  1216. end;
  1217.  
  1218. procedure MainLoop();
  1219. var
  1220. T, TT, maxComps: Integer;
  1221. begin
  1222. repeat
  1223. maxComps := (Players[CURRENTPLAYER].Integers[HOW_MANY_COMPS]);
  1224. competitionsDone := 0;
  1225. comInc := 0;
  1226. startingTickets := (TicketAmount);
  1227.  
  1228. MarkTime(T);
  1229. MarkTime(TT);
  1230. FixChats;
  1231. Retaliate(AUTO_RETALIATE);
  1232.  
  1233. repeat
  1234. Inc(competitionsDone);
  1235.  
  1236. StartGame;
  1237. Wait(RandomRange(300, 500));
  1238. FireAtTargets;
  1239. Wait(RandomRange(300, 500));
  1240. AntiBan;
  1241.  
  1242.  
  1243. // Stat reporting & 5 minute debug report
  1244. if (TimeFromMark(T) >= 300000) then
  1245. begin
  1246. ProgressReport;
  1247.  
  1248. compsDone := (competitionsDone);
  1249. startTickets := (startingTickets);
  1250. curTickets := (TicketAmount);
  1251. gained := (curTickets - startTickets);
  1252. expGained := (Gained * 5);
  1253.  
  1254. // Stat committing is now in the main loop as 1.0.4 to test if it works
  1255. expThisReport := (expGained);
  1256. compsThisReport := (compsDone);
  1257. if (not(comInc = 0)) then
  1258. begin
  1259. comExp := (expThisReport - expLastReport);
  1260. comComps := (compsThisReport - compsLastReport);
  1261. end else
  1262. begin
  1263. comExp := (expThisReport);
  1264. comComps := (compsThisReport);
  1265. end;
  1266.  
  1267. expLastReport := (expThisReport);
  1268. compsLastReport := (compsThisReport);
  1269.  
  1270.  
  1271. stats_IncVariable('Ranged EXP (Gained)', comExp);
  1272. stats_IncVariable('Total EXP Gained', comExp);
  1273. stats_IncVariable('Competitions Done', comComps);
  1274. if (stats_Commit) then
  1275. Write('We have committed stats to SRL stats!');
  1276.  
  1277. Inc(comInc);
  1278.  
  1279. T := 0;
  1280. end;
  1281.  
  1282. // Breaking
  1283. if (ENABLE_BREAKS) then
  1284. if (BreakHandler(BREAK_IN, BREAK_FOR, RAND_IN, RAND_FOR)) then
  1285. begin
  1286. FixCompass;
  1287. SetAngle(SRL_ANGLE_LOW);
  1288. end;
  1289. until((competitionsDone >= maxComps) or (not(LoggedIn)));
  1290.  
  1291. ExitPlayer('');
  1292. Write('If you have encountered an error, please enable debug mode in the script setup and rerun the script.');
  1293. Write('Thank you!');
  1294. until((AllPlayersInactive));
  1295. end;
  1296.  
  1297. procedure Setup();
  1298. begin
  1299. SMART_Server := WORLD;
  1300. SMART_Members := True;
  1301.  
  1302. AddOnTerminate('ProgressReport');
  1303. SetupSRL;
  1304. SetupSRLStats(836, STATS_USER, STATS_PASS);
  1305. SPS_Setup(RUNESCAPE_SURFACE, ['6_7']);
  1306. MouseSpeed := (RandomRange(10, 12));
  1307. DeclarePlayers;
  1308. LoginPlayer;
  1309. SetAngle(SRL_ANGLE_LOW);
  1310. ClearDebug;
  1311. FixCompass;
  1312.  
  1313. MainLoop;
  1314. end;
  1315.  
  1316. begin
  1317. Setup;
  1318. end.
Add Comment
Please, Sign In to add comment