Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.59 KB | None | 0 0
  1. program new;
  2. {$DEFINE SMART}
  3. {$i SRL\SRL.scar}
  4. {$i Reflection\Reflection.Simba}
  5.  
  6.  
  7. const
  8. {Setup}
  9. S_World = 10;
  10. S_Membs = True;
  11. S_Signed = True;
  12. {Player Info}
  13. DontEat = 0;
  14.  
  15. procedure DeclarePlayers;
  16. begin
  17. HowManyPlayers := 1;
  18. NumberOfPlayers(HowManyPlayers);
  19. CurrentPlayer := 0;
  20.  
  21. with Players[0] do
  22. begin
  23. Name := '';
  24. Pass := '';
  25. Active := True;
  26. Arrays[DontEat] := []; //Slots not to eat (whole number, between 1 and 28), seperated by commas
  27. end;
  28. end;
  29.  
  30.  
  31. {*******************************************************************************
  32. function NavigateObstacle(HueModifier, SatModifier: Extended; Color, Tolerance,
  33. ATPADist, MouseRan: Integer; Split: Boolean;
  34. Uptext: string): Boolean;
  35. By: TomTuff
  36. Description: Navigates an agility obstacle. HueModifier and SatModifier are the
  37. Hue and Sat mods for CTS 2. Color is the color to search for. Tolerance is the
  38. color tolerance. ATPA dist is the distance to use when splitting the TPA to an
  39. ATPA. MouseRan is the how much randomness there should be to mousing. If you
  40. want to use SplitTPA, Split should be true. If split is false, TPAtoATPA will be
  41. used. Uptext is the text to search for. Returns true if the uptext is found, and
  42. then after clicking the red crosshair is found.
  43. *******************************************************************************}
  44. function NavigateObstacle(HueModifier, SatModifier: Extended; Color, Tolerance,
  45. ATPADist, MouseRan: Integer; Split: Boolean;
  46. Uptext: string): Boolean;
  47. var
  48. TPA: TPointArray;
  49. ATPA: T2DPointArray;
  50. x, y, i, CTS: Integer;
  51. HueMod, SatMod: Extended;
  52. begin
  53. if not(LoggedIn) then
  54. Exit;
  55. CTS := GetColorToleranceSpeed;
  56. GetColorspeed2Modifiers(HueMod, SatMod);
  57. SetColorToleranceSpeed(2);
  58. SetColorspeed2Modifiers(HueModifier, SatModifier);
  59. FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
  60. SetColorspeed2Modifiers(HueMod, SatMod);
  61. SetColorToleranceSpeed(CTS);
  62. if (Length(TPA) < 1) then
  63. Exit;
  64. SortTPAFrom(TPA, Point(MSCX, MSCY));
  65. if Split then
  66. ATPA := SplitTPA(TPA, ATPADist)
  67. else
  68. ATPA := TPAtoATPA(TPA, ATPADist);
  69. for i := 0 to High(ATPA) do
  70. begin
  71. MiddleTPAEx(ATPA[i], x, y);
  72. MMouse(x - MouseRan, y - MouseRan, (2* MouseRan), (2 * MouseRan));
  73. Wait(300 + Random(300));
  74. if WaitUptext(Uptext, 1250) then
  75. begin
  76. ClickMouse2(True);
  77. Result := DidRedClick;
  78. end;
  79. if Result then
  80. Break;
  81. end;
  82. end;
  83.  
  84.  
  85. function AttemptObstacleAndSwivel(Hue, Sat: Extended; Color, Tol, ATPADist,
  86. MouseRan: Integer; Split: Boolean;
  87. Uptext: string; Attempts, SwivelPer, RanSwiv: Integer): Boolean;
  88. var
  89. i: Integer;
  90. begin
  91. for i := 1 to Attempts do
  92. begin
  93. if NavigateObstacle(Hue, Sat, Color, Tol, ATPADist, MouseRan, Split, Uptext) then
  94. begin
  95. Result := True;
  96. Exit;
  97. end;
  98. R_FindRandoms;
  99. MakeCompass(rs_GetCompassAngleDegrees + SwivelPer - RanSwiv + Random(2 * RanSwiv));
  100. Wait(800 + Random(200));
  101. end;
  102. end;
  103.  
  104.  
  105. function WalkAndWait(Tile: TTile): Boolean;
  106. var
  107. T: Integer;
  108. begin
  109. if not(LoggedIn) then
  110. Exit;
  111. if not(WalkToTile(Tile, 0, 0)) then
  112. Exit;
  113. T := GetSystemTime + 6000;
  114. while (LoggedIn and (GetSystemTime < T)) do
  115. begin
  116. if not(CharacterMoving) then
  117. begin
  118. Result := True;
  119. Exit;
  120. end;
  121. WaitNone;
  122. end;
  123. end;
  124.  
  125.  
  126. function IntInArr(Int: Integer; Arr: TVariantArray): Boolean;
  127. var
  128. i: Integer;
  129. begin
  130. for i := 0 to High(Arr) do
  131. if (Int = Arr[i]) then
  132. begin
  133. Result := True;
  134. Exit;
  135. end;
  136. end;
  137.  
  138.  
  139. function EatFood: Boolean;
  140. var
  141. Box: TBox;
  142. i, StartCount, T: Integer;
  143. begin
  144. if not(LoggedIn) then
  145. Exit;
  146. StartCount := InvCount;
  147. for i := 1 to 28 do
  148. begin
  149. if IntInArr(i, Players[CurrentPlayer].Arrays[DontEat]) then
  150. Continue;
  151. if not(ExistsItem(i)) then
  152. Continue;
  153. Box := InvBox(i);
  154. MMouse(Box.X1, Box.Y1, (Box.X2 - Box.X1), (Box.Y2 - Box.Y1));
  155. if WaitUptext('Eat', 500) then
  156. begin
  157. ClickMouse2(True);
  158. T := GetSystemTime + 1500;
  159. while (GetSystemTime < T) and not(Result) and LoggedIn do
  160. begin
  161. if (InvCount <> StartCount) then
  162. Result := True;
  163. WaitNone;
  164. end;
  165. end;
  166. if Result then
  167. Break;
  168. end;
  169. end;
  170.  
  171.  
  172. function UnderAttack: Boolean;
  173. var
  174. Me: TMe;
  175. NPCs: TNPCArray;
  176. i: Integer;
  177. begin
  178. if not(LoggedIn) then
  179. Exit;
  180. Me := GetMe;
  181. if not(Me.InFight) then
  182. Exit;
  183. Result := True;
  184. NPCs := GetAllNPCs(False);
  185. for i := 0 to High(NPCs) do
  186. begin
  187. if InteractingWithMe(NPCs[i]) then
  188. begin
  189. Result := False;
  190. Exit;
  191. end;
  192. end;
  193. end;
  194.  
  195.  
  196. function WaitInBoxEx(Boxes: TBoxArray; MaxTime, WaitBetween, RanWait: Integer): Boolean;
  197. var
  198. T, i: Integer;
  199. begin
  200. if not(LoggedIn) then
  201. Exit;
  202. T := GetSystemTime + MaxTime;
  203. while (GetSystemTime < T) do
  204. begin
  205. R_FindRandoms;
  206. for i := 0 to High(Boxes) do
  207. begin
  208. Result := MeInBox(Boxes[i]);
  209. if Result then
  210. Break;
  211. end;
  212. if Result then
  213. Break;
  214. Wait(WaitBetween + Random(RanWait));
  215. end;
  216. end;
  217.  
  218.  
  219. function WaitInBox(X1, Y1, X2, Y2, MaxTime, WaitBetween, RanWait: Integer): Boolean;
  220. begin
  221. Result := WaitInBoxEx([IntToBox(X1, Y1, X2, Y2)], MaxTime, WaitBetween, RanWait);
  222. end;
  223.  
  224.  
  225. function RecoverFromRopeSwing: Boolean;
  226. var
  227. T: Integer;
  228. MyPos: TTile;
  229. begin
  230. if not(LoggedIn) then
  231. Exit;
  232. if (HPPercent < 70) then
  233. if not(EatFood) then
  234. Exit;
  235. if WalkAndWait(Tile(3005, 10362)) then
  236. begin
  237. if AttemptObstacleAndSwivel(0.10, 0.73, 3358531, 15, 35, 5, False, 'mb-up', 16, 45, 8) then
  238. begin
  239. T := GetSystemTime + 9000;
  240. while (GetSystemTime < T) and LoggedIn do
  241. begin
  242. MyPos := GetMyPos;
  243. if (MyPos.Y < 10000) then
  244. begin
  245. Result := True;
  246. Wait(200 + Random(400));
  247. Exit;
  248. end;
  249. R_FindRandoms;
  250. Wait(200 + Random(50));
  251. end;
  252. end;
  253. end;
  254. end;
  255.  
  256.  
  257. function RecoverFromBalance: Boolean; //slightly redundant from above, but oh well
  258. var
  259. T: Integer;
  260. MyPos: TTile;
  261. Ex: Boolean;
  262. begin
  263. if not(LoggedIn) then
  264. Exit;
  265. if (HPPercent < 70) then
  266. if not(EatFood) then
  267. Exit;
  268. if WalkToTile(Tile(3003, 10346), 1, 3) then
  269. begin
  270. if WalkAndWait(Tile(3005, 10362)) then
  271. begin
  272. if AttemptObstacleAndSwivel(0.10, 0.73, 3358531, 15, 35, 5, False, 'mb-up', 16, 45, 6) then
  273. begin
  274. T := GetSystemTime + 9000;
  275. while (GetSystemTime < T) and LoggedIn do
  276. begin
  277. MyPos := GetMyPos;
  278. if (MyPos.Y < 10000) then
  279. begin
  280. Ex := False;
  281. Break;
  282. end;
  283. R_FindRandoms;
  284. Wait(200 + Random(50));
  285. end;
  286. if Ex then
  287. Exit;
  288. Result := WalkAndWait(Tile(2995, 3961));
  289. end;
  290. end;
  291. end;
  292. end;
  293.  
  294.  
  295. function R_ClimbRocks: Boolean; //Decided to incorporate attempts and compass rotating into the function itself, looks cleaner.
  296. label FuncStart;
  297. var
  298. Rocks: TTileArray;
  299. ChosenTile: TTile;
  300. Pt: TPoint;
  301. Attempts: Integer;
  302. begin
  303. if not(LoggedIn) then
  304. Exit;
  305. Rocks := [Tile(2993, 3936), Tile(2994, 3936), Tile(2995, 3936)];
  306. FuncStart:
  307. ChosenTile := Rocks[Random(2)];
  308. Pt := TileToMS(ChosenTile, 0);
  309. MMouse(Pt.x - 4, Pt.y - 4, 8, 8);
  310. if WaitUptext('mb Roc', 1250) then
  311. begin
  312. Wait(80 + Random(30));
  313. ClickMouse2(True);
  314. Result := DidRedClick;
  315. end;
  316. if Result then
  317. Exit;
  318. Inc(Attempts);
  319. if (Attempts > 16) then
  320. Exit;
  321. MakeCompass(rs_GetCompassAngleDegrees + 45 - 6 + Random(12));
  322. goto FuncStart;
  323. end;
  324.  
  325.  
  326. procedure MainLoop;
  327. label RopeSwing, BalanceLog, LavaPit; //<3 labels
  328. var
  329. MyPos: TTile;
  330. begin
  331. if not(LoggedIn) then
  332. begin
  333. LoginPlayer;
  334. Wait(3000 + Random(1000));
  335. end;
  336. repeat
  337. SetAngle(True);
  338. {PIPE}
  339. if WalkAndWait(Tile(3004, 3937)) then
  340. begin
  341. if AttemptObstacleAndSwivel(0.56, 0.07, 6119010, 6, 30, 5, False, 'ze-thr', 16, 45, 6) then
  342. begin
  343. if not(WaitInBox(3003, 3951, 3005, 3949, 15000, 500, 200)) then
  344. Logout;
  345. end else Logout;
  346. end else Logout;
  347. {/PIPE}
  348. {SWING}
  349. RopeSwing:
  350. if WalkAndWait(Tile(3005, 3953)) then
  351. begin
  352. if AttemptObstacleAndSwivel(0.16, 1.07, 795432, 10, 5, 0, True, 'on Rop', 16, 45, 6) then
  353. begin
  354. if WaitInBoxEx([IntToBox(3004, 3959, 3006, 3958), IntToBox(3003, 10357, 3006, 10354)], 15000, 500, 200) then
  355. begin
  356. MyPos := GetMyPos;
  357. if (MyPos.Y > 10000) then
  358. if RecoverFromRopeSwing then
  359. goto RopeSwing
  360. else
  361. Logout;
  362. end else Logout;
  363. end else Logout;
  364. end else Logout;
  365. {/SWING}
  366. if LoggedIn then
  367. Wait(600 + Random(400));
  368. {LAVA}
  369. LavaPit:
  370. if AttemptObstacleAndSwivel(0.17, 0.73, 2376274, 10, 10, 4, True, 'ss Step', 16, 45, 6) then
  371. begin
  372. if WaitInBoxEx([IntToBox(2995, 3961, 2996, 3959), IntToBox(3001, 3964, 3003, 3962)], 15000, 500, 200) then
  373. begin
  374. if MeInBox(IntToBox(3001, 3964, 3003, 3962)) then
  375. goto LavaPit
  376. end else Logout;
  377. end else Logout;
  378. {/LAVA}
  379. {LOG}
  380. BalanceLog:
  381. if WalkAndWait(Tile(3001, 3946)) then
  382. begin
  383. if AttemptObstacleAndSwivel(0.06, 0.39, 932195, 10, 30, 5, False, 'cross L', 16, 45, 6) then
  384. begin
  385. if WaitInBoxEx([IntToBox(2993, 3946, 2995, 3944), IntToBox(2994, 10349, 3002, 10342)], 15000, 500, 200) then
  386. begin
  387. MyPos := GetMyPos;
  388. if (MyPos.Y > 10000) then
  389. if RecoverFromBalance then
  390. goto BalanceLog
  391. else Logout;
  392. end else Logout;
  393. end else Logout;
  394. end else Logout;
  395. {/LOG}
  396. {ROCKS}
  397. if WalkAndWait(Tile(2996, 3937)) then
  398. begin
  399. if (R_ClimbRocks or AttemptObstacleAndSwivel(0.00, 0.13, 4539720, 5, 30, 5, False, 'mb Roc', 16, 45, 6)) then //Reflection primary func for this one because it was very difficult with color
  400. begin
  401. if not(WaitInBox(2993, 3933, 2996, 3932, 15000, 500, 200)) then
  402. Logout;
  403. end else Logout;
  404. end else Logout;
  405. {/ROCKS}
  406. until(not(LoggedIn));
  407. end;
  408.  
  409.  
  410. begin
  411. Smart_Server := S_World;
  412. Smart_Members := S_Membs;
  413. Smart_Signed := S_Signed;
  414. Smart_SuperDetail := False;
  415. SetupSRL;
  416. DeclarePlayers;
  417. MainLoop;
  418. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement