/lib/mapwalk/MapWalk.simba

http://github.com/Drags111/Reflection_Dev · Unknown · 858 lines · 661 code · 197 blank · 0 comment · 0 complexity · 6f2fa300b63121fbca42508f76d1bc77 MD5 · raw file

  1. (*
  2. MapWalk
  3. =======
  4. Contains routines for walking the runescape minimap.
  5. *)
  6. (*
  7. R_GetMinimapAngleDeg
  8. ~~~~~~~~~~~~~~~~~~~~
  9. .. code-block:: pascal
  10. function R_GetMinimapAngleDeg: extended;
  11. Returns the current Map angle in degrees. North: 0 deg, increases in the
  12. counter clockwise direction
  13. .. note::
  14. by BenLand100
  15. *)
  16. function R_GetMinimapAngleDeg: extended;
  17. begin
  18. Result := SmartGetFieldFloat(0, hook_static_MapAngle) * 45.0 / 2048.0;
  19. end;
  20. (*
  21. R_GetMinimapAngleRad
  22. ~~~~~~~~~~~~~~~~~~~~
  23. .. code-block:: pascal
  24. function R_GetMinimapAngleRad: extended;
  25. Returns the current Map angle in radians. North: 0 deg, increases in the
  26. counter clockwise direction
  27. .. note::
  28. by BenLand100
  29. *)
  30. function R_GetMinimapAngleRad: extended;
  31. begin
  32. Result := SmartGetFieldFloat(0, hook_static_MapAngle) * pi / 8192.0;
  33. end;
  34. (*
  35. R_GetCamPosX
  36. ~~~~~~~~~~~~
  37. .. code-block:: pascal
  38. function R_GetCamPosX: integer;
  39. Camera Position X
  40. .. note::
  41. by lordsaturn
  42. *)
  43. function R_GetCamPosX: integer;
  44. begin
  45. Result := SmartGetFieldInt(0, hook_static_CamPosX);
  46. end;
  47. (*
  48. R_GetCamPosY
  49. ~~~~~~~~~~~~
  50. .. code-block:: pascal
  51. function R_GetCamPosY: integer;
  52. Camera Position Y
  53. .. note::
  54. by lordsaturn
  55. *)
  56. function R_GetCamPosY: integer;
  57. begin
  58. Result := SmartGetFieldInt(0, hook_static_CamPosY);
  59. end;
  60. (*
  61. R_GetCameraAngle
  62. ~~~~~~~~~~~~~~~~
  63. .. code-block:: pascal
  64. function R_GetCameraAngle: Integer;
  65. Returns the Camera Angle. 0 = lowest, 100 = highest.
  66. .. note::
  67. by Drags111
  68. *)
  69. function R_GetCameraAngle: Integer;
  70. var
  71. D: Extended;
  72. begin
  73. D := (SmartGetFieldInt(0, hook_static_CameraPitch) / 1024.0);
  74. Result := Round((D - 1) * 50);
  75. end;
  76. (*
  77. R_SetCameraAngle
  78. ~~~~~~~~~~~~~~~~
  79. .. code-block:: pascal
  80. function R_SetCameraAngle(Angle: Integer): Boolean;
  81. Sets the Camera Angle. 0 = lowest, 100 = highest.
  82. .. note::
  83. by Drags111
  84. *)
  85. function R_SetCameraAngle(Angle: Integer): Boolean;
  86. var
  87. C, T: Integer;
  88. begin
  89. Result := False;
  90. if(Angle = R_GetCameraAngle)then
  91. begin
  92. Result := True;
  93. Exit;
  94. end;
  95. if(Angle < R_GetCameraAngle)then
  96. C := VK_DOWN
  97. else
  98. C := VK_UP;
  99. KeyDown(C);
  100. MarkTime(T);
  101. while(TimeFromMark(T) < 5000)do
  102. begin
  103. if(C = VK_DOWN) and (Angle >= R_GetCameraAngle)then
  104. Break;
  105. if(C = VK_UP) and (Angle <= R_GetCameraAngle)then
  106. Break;
  107. wait(10+Random(10));
  108. end;
  109. KeyUp(C);
  110. end;
  111. (*
  112. R_TileToMM
  113. ~~~~~~~~~~
  114. .. code-block:: pascal
  115. function R_TileToMM(tile: TTile): TPoint;
  116. Converts the global tile position to a screen location on the minimap, taking
  117. map rotation into account.
  118. .. note::
  119. by BenLand100
  120. *)
  121. function R_TileToMM(tile: TTile): TPoint;
  122. var
  123. angle, x, y: extended;
  124. temp: TPoint;
  125. begin
  126. angle:= -R_GetMinimapAngleRad;
  127. temp := R_GetMyPos();
  128. x:= (tile.x - temp.x) * 4 - 2;
  129. y:= (temp.y - tile.y) * 4 - 2;
  130. result.x:= round(x*cos(angle) + y*sin(angle)) + 628;
  131. result.y:= round(y*cos(angle) - x*sin(angle)) + 87;
  132. end;
  133. (*
  134. R_TileOnMM
  135. ~~~~~~~~~~
  136. .. code-block:: pascal
  137. function R_TileOnMM(Tile: TTile): boolean;
  138. Checks if the Tile is on the MM.
  139. .. note::
  140. by Drags111
  141. *)
  142. function R_TileOnMM(Tile: TTile): boolean;
  143. var
  144. P: TPoint;
  145. begin
  146. P := R_TileToMM(Tile);
  147. Result := rs_OnMinimap(P.x, P.y);
  148. end;
  149. (*
  150. R_GetDest
  151. ~~~~~~~~~
  152. .. code-block:: pascal
  153. function R_GetDest: TTile;
  154. Returns the tile of the Flag destination.
  155. .. note::
  156. by Drags111
  157. *)
  158. function R_GetDest: TTile;
  159. begin
  160. Result.X := SmartGetFieldInt(0, hook_static_BaseX) + SmartGetFieldInt(0, hook_static_DestX);
  161. Result.Y := SmartGetFieldInt(0, hook_static_BaseY) + SmartGetFieldInt(0, hook_static_DestY);
  162. end;
  163. (*
  164. R_GetLocDest
  165. ~~~~~~~~~~~~
  166. .. code-block:: pascal
  167. function R_GetLocDest: TTile;
  168. Returns the local tile of the Flag destination.
  169. .. note::
  170. by Drags111
  171. *)
  172. function R_GetLocDest: TTile;
  173. begin
  174. Result.X := SmartGetFieldInt(0, hook_static_DestX);
  175. Result.Y := SmartGetFieldInt(0, hook_static_DestY);
  176. end;
  177. (*
  178. R_FlagExists
  179. ~~~~~~~~~~~~
  180. .. code-block:: pascal
  181. function R_FlagExists: Boolean;
  182. Returns true if there is a flag.
  183. .. note::
  184. by Drags111
  185. *)
  186. function R_FlagExists: Boolean;
  187. var
  188. xFlag: LongInt;
  189. begin
  190. xFlag := SmartGetFieldInt(0, hook_static_DestX);
  191. Result := (xFlag) > -1;
  192. end;
  193. (*
  194. R_DistanceTile
  195. ~~~~~~~~~~~~~~
  196. .. code-block:: pascal
  197. function R_DistanceTile(T, TT: TTile): Integer;
  198. Returns the distance between two tiles.
  199. .. note::
  200. by mormonman
  201. *)
  202. function R_DistanceTile(T, TT: TTile): Integer;
  203. begin
  204. Result := Distance(T.x, T.y, TT.X, TT.Y);
  205. end;
  206. (*
  207. R_DistanceFromTile
  208. ~~~~~~~~~~~~~~~~~~
  209. .. code-block:: pascal
  210. function R_DistanceFromTile(TheTile: TTile): Integer;
  211. Returns the distance between your player and the tile.
  212. .. note::
  213. by Widget
  214. *)
  215. function R_DistanceFromTile(TheTile: TTile): Integer;
  216. var
  217. MyPos: TTile;
  218. begin
  219. MyPos := R_GetMyPos;
  220. Result := R_DistanceTile(MyPos, TheTile);
  221. end;
  222. (*
  223. R_DistanceFromFlag
  224. ~~~~~~~~~~~~~~~~~~
  225. .. code-block:: pascal
  226. function R_DistanceFromFlag: Integer;
  227. Returns the distance your char is from the flag.
  228. .. note::
  229. by Drags111
  230. *)
  231. function R_DistanceFromFlag: Integer;
  232. var
  233. MyPos, FlagPos: TTile;
  234. Me: integer;
  235. begin
  236. if not R_FlagExists then Exit;
  237. Me := SmartGetFieldObject(0, hook_static_MyPlayer);
  238. MyPos.x := SmartGetFieldArrayInt(Me, hook_character_WalkQueueX, 0);
  239. MyPos.y := SmartGetFieldArrayInt(Me, hook_character_WalkQueueY, 0);
  240. FlagPos := R_GetLocDest;
  241. Result := Distance(MyPos.x, MyPos.y, FlagPos.x, FlagPos.y);
  242. SmartFreeObject(me);
  243. end;
  244. (*
  245. R_RandomizeTile
  246. ~~~~~~~~~~~~~~~
  247. .. code-block:: pascal
  248. function R_RandomizeTile(Tile: TTile; rX, rY: Integer): TTile;
  249. Randomizes a tile using rX and rY.
  250. .. note::
  251. by lordsaturn
  252. *)
  253. function R_RandomizeTile(Tile: TTile; rX, rY: Integer): TTile;
  254. begin
  255. Result := Point(RandomRange(Tile.X-rX, Tile.X+rX),
  256. RandomRange(Tile.Y-rY, Tile.Y+rY));
  257. end;
  258. (*
  259. R_MakeCompass
  260. ~~~~~~~~~~~~~
  261. .. code-block:: pascal
  262. function R_MakeCompass(setAngle: Variant): Boolean;
  263. MakesCompass to degress set (Degress or n, e, s, w).
  264. .. note::
  265. by Timer
  266. *)
  267. function R_MakeCompass(setAngle: Variant): Boolean;
  268. var
  269. StartAngle, Angle, DirectionDeg, i: Extended;
  270. Bool : Boolean;
  271. Mark : Integer;
  272. begin
  273. StartAngle := (R_GetMinimapAngleDeg);
  274. if(StartAngle < 0)Or(Not LoggedIn)then
  275. Exit;
  276. case varType(setAngle) of
  277. varString:
  278. begin
  279. case (LowerCase(setAngle)) of
  280. 'n': DirectionDeg := -1;
  281. 'w': DirectionDeg := 90;
  282. 's': DirectionDeg := 180;
  283. 'e': DirectionDeg := 270;
  284. end;
  285. end;
  286. varDouble, varSingle:
  287. DirectionDeg := setAngle;
  288. end;
  289. if((MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0)then
  290. begin
  291. Result := True;
  292. Exit;
  293. end;
  294. Bool := (Round((360 - StartAngle) + DirectionDeg) mod 360 > Round((StartAngle + 360) - DirectionDeg) mod 360);
  295. if(Bool)then
  296. KeyDown(VK_LEFT)
  297. else
  298. KeyDown(VK_RIGHT);
  299. Wait(Random(40));
  300. MarkTime(Mark);
  301. repeat
  302. Wait(16);
  303. Angle := R_GetMinimapAngleDeg;
  304. If ((TimeFromMark(Mark) > 6000) and (i < 1.0)) or
  305. ((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
  306. ((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
  307. i := i + 1.0;
  308. until ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
  309. or (TimeFromMark(Mark) > 14000)
  310. or (Angle < 0);
  311. if(Bool)then
  312. KeyUp(VK_Left)
  313. else
  314. KeyUp(VK_Right);
  315. Wait(Random(100) + 40);
  316. Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i));
  317. end;
  318. (*
  319. R_Flag
  320. ~~~~~~
  321. .. code-block:: pascal
  322. procedure R_Flag;
  323. Waits Till A COMPLETE Stop. (Not dependant on Flag hooks)
  324. .. note::
  325. by Drags111
  326. *)
  327. procedure R_Flag;
  328. var
  329. Ticker: Integer;
  330. begin
  331. Ticker := (GetSystemTime + 30000);
  332. if not R_WaitToMove(1500) then Exit;
  333. while (R_GetMotion > 0) do
  334. begin
  335. Wait(10 + Random(10));
  336. if SRL_Procs[SRL_AntiBan] <> nil then
  337. SRL_Procs[SRL_AntiBan]();
  338. if (GetSystemTime > Ticker) then
  339. Exit;
  340. end;
  341. Wait(500 + Random(50));
  342. end;
  343. (*
  344. R_FFlag
  345. ~~~~~~~
  346. .. code-block:: pascal
  347. procedure R_FFlag(Dist: Integer);
  348. Waits till you are within the distance specified from the flag.
  349. .. note::
  350. by ZephyrsFury
  351. *)
  352. procedure R_FFlag(Dist: Integer);
  353. var
  354. Tx, Ty, m, d1, d2: Integer;
  355. D: TTile;
  356. begin
  357. if not R_WaitToMove(1500) then Exit;
  358. if(Dist = 0)then
  359. begin
  360. R_Flag;
  361. Exit;
  362. end;
  363. while (R_FlagExists) do
  364. begin
  365. D := R_GetLocDest;
  366. d1 := R_DistanceFromFlag;
  367. if (d1 >= Dist) then
  368. begin
  369. if not (R_GetMotion > 0) then Exit;
  370. Inc(m);
  371. Wait(100 + Random(30));
  372. if SRL_Procs[SRL_AntiBan] <> nil then
  373. SRL_Procs[SRL_AntiBan]();
  374. if (Random(100) = 0) then IdleTime(500, 1000, 0.01);
  375. if (m mod 100 = 0) then
  376. if (d1 = d2) then
  377. begin
  378. if (FindColor(Tx, Ty, 255, MMX1, MMY1, MMX2, MMY2)) then
  379. Mouse(Tx, Ty + 14, 0, 0, True)
  380. else
  381. Mouse(MMCX, MMCY, 0, 0, True);
  382. end else d2 := d1;
  383. end else Break;
  384. end;
  385. end;
  386. (*
  387. R_WalkToTileEx
  388. ~~~~~~~~~~~~~~
  389. .. code-block:: pascal
  390. function R_WalkToTileEx(Tile: TTile; Randomness, FlagDist: Integer; UseFFlag: Boolean): Boolean;
  391. Walks to the tile using minimap.
  392. .. note::
  393. by Wizzup, TheGuyWhoGotOn, and Drags111
  394. *)
  395. function R_WalkToTileEx(Tile: TTile; Randomness, FlagDist: Integer; UseFFlag: Boolean): Boolean;
  396. var
  397. wTile: TPoint;
  398. t: Integer;
  399. begin
  400. Result := False;
  401. Tile := R_RandomizeTile(Tile, Randomness, Randomness);
  402. wTile := R_TileToMM(Tile);
  403. if not rs_OnMiniMap(wTile.X, wTile.Y) then
  404. Exit;
  405. Mouse(wTile.x, wTile.y, 1, 1, true);
  406. Wait(RandomRange(80, 100));
  407. t := getsystemtime;
  408. if UseFFlag then R_FFlag(FlagDist);
  409. Result := (GetSystemTime - t) < 60000;
  410. end;
  411. (*
  412. R_WalkToTile
  413. ~~~~~~~~~~~~
  414. .. code-block:: pascal
  415. function R_WalkToTile(Tile: TPoint; Randomness, FlagDist: Integer): Boolean;
  416. Walks to the tile using minimap.
  417. .. note::
  418. by Drags111
  419. *)
  420. function R_WalkToTile(Tile: TPoint; Randomness, FlagDist: Integer): Boolean;
  421. begin
  422. Result := R_WalkToTileEx(Tile, Randomness, FlagDist, true);
  423. end;
  424. (*
  425. R_WalkToTileMS
  426. ~~~~~~~~~~~~
  427. .. code-block:: pascal
  428. function R_WalkToTileMS(Tile: TPoint; FlagDist: Integer): Boolean;
  429. Walks to the tile using mainscreen.
  430. .. note::
  431. by mormonman
  432. *)
  433. function R_WalkToTileMS(Tile:TTile; FlagDist: Integer): boolean;
  434. var
  435. P: TPoint;
  436. x, y, t: Integer;
  437. begin
  438. if not LoggedIn then
  439. Exit;
  440. P := R_TileToMS(Tile, 50);
  441. if not PointInBox(Point(P.x,P.y), IntToBox(MSX1, MSY1, MSX2, MSY2)) then
  442. Exit;
  443. MMouse(P.x, P.y, 5, 5);
  444. GetMousePos(x, y);
  445. if R_WaitUpText('Walk here', 300) then
  446. Mouse(x, y, 0, 0, True) else
  447. begin
  448. Mouse(x, y, 0, 0, False);
  449. Wait(RandomRange(400, 500));
  450. R_ChooseOption('Walk here');
  451. end;
  452. Wait(RandomRange(120, 180));
  453. t := getsystemtime;
  454. R_FFlag(FlagDist);
  455. Result := (GetSystemTime - t) < 60000;
  456. end;
  457. (*
  458. R_WalkPathEx
  459. ~~~~~~~~~~~~
  460. .. code-block:: pascal
  461. function R_WalkPathEx(Path: TTileArray; Randomness, FlagDistance: Integer; Inverted: Boolean): Boolean;
  462. Walks the Path of TTileArray from start to finish in a human-like style. It
  463. looks for the next tile in path and clicks it as soon as it comes up on the
  464. screen, just like a legit player would. This does make it more beneficial to
  465. use paths where the tiles are closer together, so it seems more active. All
  466. personal preference.
  467. -Path: The array of Tiles to use as the path.
  468. -Randomness: The amount of variance you want when walking to tiles.
  469. -FlagDist: The amount of distance from your player to the next tile before continuing walking.
  470. -Inverted: If you want it to reverse the path (Walk from end to start).
  471. .. note::
  472. by Drags111
  473. *)
  474. function R_WalkPathEx(Path: TTileArray; Randomness, FlagDist: Integer; Inverted: Boolean): Boolean;
  475. var
  476. Index, Timer, Tries: Integer;
  477. begin
  478. if Inverted then InvertTPA(Path);
  479. while R_DistanceFromTile(Path[High(Path)]) > (FlagDist + Randomness + 1) do
  480. begin
  481. for Index := High(Path) downto 0 do
  482. if R_TileOnMM(Path[Index]) then
  483. Break;
  484. if (Index = -1) then
  485. Break;
  486. if R_WalkToTileEx(Path[Index], Randomness, 0, false) then
  487. begin
  488. Timer := (GetSystemTime + 30000);
  489. while R_DistanceFromTile(Path[Index]) > FlagDist do
  490. begin
  491. Wait(500 + Random(100));
  492. if SRL_Procs[SRL_AntiBan] <> nil then
  493. SRL_Procs[SRL_AntiBan]();
  494. if (GetSystemTime > Timer) or (R_GetMotion = 0) or ((Index <> High(Path)) and (R_TileOnMM(Path[Index+1]))) then
  495. Break;
  496. end;
  497. if (not (R_DistanceFromTile(Path[Index]) <= 5)) and
  498. ((Index <> High(Path)) and (not R_TileOnMM(Path[Index+1]))) then
  499. Inc(Tries);
  500. end else
  501. begin
  502. Inc(Tries);
  503. wait(800+Random(600));
  504. end;
  505. if Tries >= 10 then Break;
  506. end;
  507. R_FFlag(FlagDist);
  508. Result := R_DistanceFromTile(Path[High(Path)]) <= (FlagDist + Randomness + 1);
  509. end;
  510. (*
  511. R_WalkPath
  512. ~~~~~~~~~~
  513. .. code-block:: pascal
  514. function R_WalkPath(Path: TTileArray): boolean;
  515. Walks the path. See WalkToPathEX for more info.
  516. .. note::
  517. by Drags111
  518. *)
  519. function R_WalkPath(Path: TTileArray): boolean;
  520. begin
  521. Result := R_WalkPathEx(Path, 3, 5, false);
  522. end;
  523. (*
  524. R_WindPath
  525. ~~~~~~~~~~
  526. .. code-block:: pascal
  527. function R_WindPath(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended): TPointArray;
  528. Generates a blind path of points!
  529. .. note::
  530. by JuKKa
  531. *)
  532. function R_WindPath(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended): TPointArray;
  533. var
  534. veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
  535. lastX, lastY: integer;
  536. sqrt2, sqrt3, sqrt5: extended;
  537. begin
  538. sqrt2:= sqrt(2);
  539. sqrt3:= sqrt(3);
  540. sqrt5:= sqrt(5);
  541. while hypot(xs - xe, ys - ye) > 1 do
  542. begin
  543. dist:= hypot(xs - xe, ys - ye);
  544. wind:= minE(wind, dist);
  545. if dist >= targetArea then
  546. begin
  547. windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
  548. windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
  549. end else
  550. begin
  551. windX:= windX / sqrt2;
  552. windY:= windY / sqrt2;
  553. if (maxStep < 3) then
  554. begin
  555. maxStep:= random(3) + 3.0;
  556. end else
  557. begin
  558. maxStep:= maxStep / sqrt5;
  559. end;
  560. end;
  561. veloX:= veloX + windX;
  562. veloY:= veloY + windY;
  563. veloX:= veloX + gravity * (xe - xs) / dist;
  564. veloY:= veloY + gravity * (ye - ys) / dist;
  565. if hypot(veloX, veloY) > maxStep then
  566. begin
  567. randomDist:= maxStep / 2.0 + random(round(maxStep) / 2);
  568. veloMag:= sqrt(veloX * veloX + veloY * veloY);
  569. veloX:= (veloX / veloMag) * randomDist;
  570. veloY:= (veloY / veloMag) * randomDist;
  571. end;
  572. lastX:= Round(xs);
  573. lastY:= Round(ys);
  574. xs:= xs + veloX;
  575. ys:= ys + veloY;
  576. SetArrayLength(Result, GetArrayLength(Result) + 1);
  577. Result[ High(Result) ] := Point(Round(xs), Round(ys));
  578. step:= hypot(xs - lastX, ys - lastY);
  579. lastdist:= dist;
  580. end;
  581. end;
  582. (*
  583. R_WindPathMS
  584. ~~~~~~~~~~
  585. .. code-block:: pascal
  586. function R_WindPathMS(StartTile, TargetTile: TTile): TPointArray;
  587. Generates a blind path of onscreen points!
  588. .. note::
  589. by mormonman
  590. *)
  591. function R_WindPathMS(StartTile, TargetTile: TTile): TPointArray;
  592. begin
  593. Result := R_WindPath(StartTile.x, StartTile.y, TargetTile.x, TargetTile.y,
  594. 5.0, 2.5, 0.0, 0.0, 1.5, 1.0);
  595. end;
  596. (*
  597. R_WindWalk
  598. ~~~~~~~~~~
  599. .. code-block:: pascal
  600. function R_WindWalk(T: TTile): Boolean;
  601. Walks blindly using WindPath! Does NOT consider walls or obstacles.
  602. .. note::
  603. by JuKKa
  604. *)
  605. function R_WindWalk(T: TTile): Boolean;
  606. var
  607. I, Tries: Integer;
  608. M, P: TPoint;
  609. CTRLPoints: TPointArray;
  610. begin
  611. P := T;
  612. repeat
  613. M := R_GetMyPos;
  614. CtrlPoints := R_WindPath(M.x, M.y, P.X, P.Y, 5.0, 2.5, 0.0, 0.0, 4.5, 2.5);
  615. Inc(Tries);
  616. if(Tries > 20)then
  617. begin
  618. R_Debug('Failed more than 20 times', 'R_WindWalk');
  619. Exit;
  620. end;
  621. for I:= High(CtrlPoints) downto 0 do
  622. if R_WalkToTile(CtrlPoints[i],0, 10) then
  623. begin
  624. Result := I = High(CtrlPoints);
  625. Break;
  626. end;
  627. until(Result);
  628. end;
  629. (*
  630. R_WindWalkMS
  631. ~~~~~~~~~~
  632. .. code-block:: pascal
  633. function R_WindWalkMS(T: TTile): Boolean;
  634. Walks blindly using WindPathMS! Does NOT consider walls or obstacles.
  635. .. note::
  636. by mormonman
  637. *)
  638. function R_WindWalkMS(T: TTile): Boolean;
  639. var
  640. I, Tries: Integer;
  641. M, P: TPoint;
  642. CTRLPoints: TPointArray;
  643. begin
  644. P := T;
  645. repeat
  646. M := R_GetMyPos;
  647. CtrlPoints := R_WindPathMS(M, P);
  648. Inc(Tries);
  649. if(Tries > 20)then
  650. begin
  651. R_Debug('Failed more than 20 times', 'R_WindWalkMS');
  652. Exit;
  653. end;
  654. for I:= High(CtrlPoints) downto 0 do
  655. if R_WalkToTileMS(CtrlPoints[i], 1) then
  656. begin
  657. Result := I = High(CtrlPoints);
  658. Break;
  659. end;
  660. until(Result);
  661. end;