SRL Archive - Reflection Development

function R_AdjustTo(Tile: TTile; Height: Integer): Boolean;


Home

2011-08-21 14:10:37

This function will adjust your mainscreen angle and compass angle to direction of the tile.

Enjoy!

(*
R_AdjustTo
~~~~~~~~~~~~~~

.. code-block:: pascal

function R_AdjustTo(Tile: TTile; Height: Integer): Boolean;

Adjusts compass angle and mainscreen angle to tile

.. note::

by Home

*)


function R_AdjustTo(Tile: TTile; Height: Integer): Boolean;
var
Mark: Integer;
Left: Boolean;
begin
if (R_DistanceFromTile(Tile) <= 14) and not R_TileOnMS(Tile, Height) then begin
case R_DistanceFromTile(Tile) of
13..14: R_SetCameraAngle(0);
11..12: R_SetCameraAngle(5);
9..10: R_SetCameraAngle(10);
7..8: R_SetCameraAngle(20);
5..6: R_SetCameraAngle(40);
end;
if not R_TileOnMS(Tile, Height) then
R_MakeCompass(Round(Degrees(ArcTan2(MMCY - Tile.Y, MMCX - Tile.X)) + 90 + R_GetMinimapAngleDeg));
if not R_TileOnMS(Tile, Height) then begin
MarkTime(Mark);
case Random(1) of
0:
begin
KeyDown(VK_Right)
Left := False;
end;
1:
begin
KeyDown(VK_Left)
Left := True;
end;
end;
repeat
Wait(RandomRange(100, 150));
until (R_TileOnMs(Tile, Height)) or (TimeFromMark(Mark) > 14000)
if Left then KeyUp(VK_Left)
else
KeyUp(VK_Right);
end;
end;
Result := R_TileOnMs(Tile, Height);
end;


~Home

Brandon

2011-08-21 18:30:17

I remember doing those for Objects such as Doors and hard to click stuff..

These detect if your adjacent to a tile.. and if so, what direction you need to change the compass to inorder to face the tile..

Basically for clicking doors, I walk to a tile that is adjacent to the door.. preferably the one right before it, then I use the adjacenttile() to check if I am adjacent to the door.. if I am then I use R_MakeCompass(AdjacentDirection()) and it changes my compass to face the object.. then u just click. Works for that Maze Random perfectly.. I am able to click the Maze Random doors/gates 100% of the time.


Function AdjacentTile(Tile: TTile): Boolean;
var
MyPos, NewTile: TTile;

begin
MyPos:= R_GetMyPos;
NewTile := Point((MyPos.x - Distance(Tile.X, 0, MyPos.X, 0)), MyPos.y);
if(NewTile = Tile) then
begin
Result:= true;
end;

NewTile := Point((MyPos.x + Distance(Tile.X, 0, MyPos.X, 0)), MyPos.y);
if(NewTile = Tile) then
begin
Result:= true;
end;

NewTile := Point(MyPos.X, (MyPos.y - Distance(0, Tile.Y, 0, MyPos.Y)));
if(NewTile = Tile) then
begin
Result:= true;
end;

NewTile := Point(MyPos.X, (MyPos.Y + Distance(0, Tile.Y, 0, MyPos.Y)));
if(NewTile = Tile) then
begin
Result:= true;
end;
end;

Function AdjacentDirection(Tile: TTile): string;
var
MyPos, NewTile: TTile;

begin
MyPos:= R_GetMyPos;
NewTile := Point((MyPos.x - Distance(Tile.X, 0, MyPos.X, 0)), MyPos.y);
if(NewTile = Tile) then
begin
Result:= 'w';
end;

NewTile := Point((MyPos.x + Distance(Tile.X, 0, MyPos.X, 0)), MyPos.y);
if(NewTile = Tile) then
begin
Result:= 'e';
end;

NewTile := Point(MyPos.X, (MyPos.y - Distance(0, Tile.Y, 0, MyPos.Y)));
if(NewTile = Tile) then
begin
Result:= 's';
end;

NewTile := Point(MyPos.X, (MyPos.Y + Distance(0, Tile.Y, 0, MyPos.Y)));
if(NewTile = Tile) then
begin
Result:= 'n';
end;
end;

Flight

2011-08-21 20:16:30

I've been wanting something like this for a long, long time. I had done ACR in the past, but that only adjust the compass based on a screen TPoint. Thank you!

Echo_

2011-08-22 08:29:14

This looks really nice Home :thumbsup:

Yago

2011-08-22 09:35:17

If this works then I support it!

Home

2011-08-22 09:40:08

From: Yago
If this works then I support it!


Works for me :P


~Home

Yago

2011-08-22 09:55:46

From: Home
Works for me :P


~Home


Lol then rep+