SRL Archive - Reflection Help

Trouble opening door


KillerTHC

2010-12-06 21:29:55

Im having trouble opening a door because there are 2 closed doors near me and when I do find the door I want, it clicks on the tile in front of the door(which happens to be the objects tile) and not the door it self. I have tried with different heights and various amounts of random x and y variations. Yet I still cannot get it to open the door every time…

OpenDoor function
function OpenDoor(RandomX, RandomX, Height: Integer): Boolean;
var
I: Integer;
DoorObjs: TRSObjectArray;
DoorTile: TTile;
begin
DoorTile := Tile(2949,3450);//Tile from debugging objects near the player
DoorObjs := GetObjectsByID([DoorClosedID], OBJECT_TYPE_WALLOBJECT, 10);
for I := 0 to High(DoorObjs) do
begin
if (DoorObjs[I].Tile.x = DoorTile.x) and (DoorObjs[I].Tile.y = DoorTile.y) then
begin
TP := TileToMS(DoorObjs[I].Tile, Height);
if TP.x > 0 then
begin
Mouse(TP.x, TP.y, RandomX, RandomX, False);
if not R_ChooseOptionMulti(['Open','open','pen']) then
begin
WriteLn('Reflection ChooseOptionMulti failed, using SRL');
Result := ChooseOptionMulti(['Open','open','pen']);
Exit;
end else
begin
Result := True;
Exit;
end;
end;
end;
end;
end;

Cstrike

2010-12-06 21:47:51

I shrunk some of the code down for you and fixed the RandomX/RandomY (was that a typo? If not I apologize). Should help with the debugging:

function OpenDoor(RandomX, RandomY, Height: Integer): Boolean;
var
I: Integer;
DoorObjs: TRSObjectArray;
DoorTile: TTile;
begin
DoorTile := Tile(2949,3450);//Tile from debugging objects near the player
DoorObjs := GetObjectsByID([DoorClosedID], OBJECT_TYPE_WALLOBJECT, 10);
if high(DoorObjs) < 0 then // Failsafe to prevent simba from crashing
Exit;
for I := 0 to High(DoorObjs) do
if (DoorObjs[I].Tile.x = DoorTile.x) and (DoorObjs[I].Tile.y = DoorTile.y) then
begin
if TileOnMS(DoorObjs[I].Tile, Height) then // Make sure its there
begin
TP := TileToMSEx(DoorObjs[I].Tile, 0.0, 0.0, Height);
if TP.x > 0 then
begin
Mouse(TP.x, TP.y, RandomX, RandomY, False);
wait (150+random(450));
if not R_ChooseOptionMulti(['Open']) then
begin
WriteLn('Reflection ChooseOptionMulti failed, using SRL');
Result := ChooseOptionMulti(['Open']);
if Result then Writeln('SRL ChooseOption worked');
Exit;
end else
begin
Result := True;
Exit;
end;
end else Writeln('TP.x is < 1');
end else Writeln('Tile was not on MS');
end else Writeln('Not on the tile we want');
end;


Looks like you're going to want to use TileToMSEx (Tile, XOffset, YOffset, height)

Try a height of 200-300.


Now where is the door located if you're facing north? X and Y offset should be between 0.0–>1.0,

Bottom left of a tile while facing north is 0.0, 0.0 offsets, top right of a tile is 1.0/1.0 offsets if I recall correctly.

I edited it in the code above, mess around with it and if youre stuck, post a picture :)
EDIT: Get the new one above, I messed up.

KillerTHC

2010-12-07 15:44:54

Thanks CStrike! This works well for opening the door, im almost done the beta version of FaladorSmith that includes both smelting and smithing.

marpis

2010-12-07 15:55:11

Take the 2 tiles on both sides of the door, and click (x1 + x2)/2, (y1 + y2)/2 :)

Cstrike

2010-12-07 16:26:31

From: marpis
Take the 2 tiles on both sides of the door, and click (x1 + x2)/2, (y1 + y2)/2 :)


If TileToMSEx breaks, this is the way to go :) !

Bad Boy JH

2010-12-07 18:14:19

if TileToMsEx breaks then TileToMs will break cause it uses TileToMsEx with offsets of 0.5.

KillerTHC

2010-12-07 18:53:17

From: marpis
Take the 2 tiles on both sides of the door, and click (x1 + x2)/2, (y1 + y2)/2 :)


Would I still use TileToMS with the mean(averaged) tile?