SRL Archive - News and General

How to Find Player after tele?


Brandon

2011-07-10 22:46:48

K guys Im using reflection2 beta to write a script.. so far everything is fine (well except object clicking :c) But I wanna know how to find a player after teleport…

I have:

Procedure FillPrayer;
var
InvItem: TInvItem; MyPos: TTile;
begin
if(R_ItemExists(HouseTab, InvItem)) then
Repeat
R_ClickItemBy(HouseTab, true, '');
WaitForAnimation(5000);
Until(CharacterAnimating);
MyPos:= GetMyPos;
If((MyPos = PointToTile(3439,3454)) or (MyPos = PointToTile(3436, 3453))) then
begin
Wait
end;
end;
How do I wait until the player appears in the house?? Every house is different so the Box the player appears in will be different if I were to use SelfInBox: TBox.. to check if they're in the house.. So How would I go about this? Thing is when the player teleports, they animate.. then the screen goes black and u see the house interface thing saying "Home Sweet Home" and during that time, animation is -1.. so basically it doesn't wait till u appear because your no longer animating but rather the function just continues on :c
Help..

Tlachtli

2011-07-10 22:54:50

I'd say add a BMP of the "Home Sweet Home" splash and wait until it is no longer found before proceeding. Once the splash is gone, you can assume the char is in the house.

As for doing it specifically with R2, I'm not sure.

Brandon

2011-07-10 23:03:56

From: Tlachtli
I'd say add a BMP of the "Home Sweet Home" splash and wait until it is no longer found before proceeding. Once the splash is gone, you can assume the char is in the house.

As for doing it specifically with R2, I'm not sure.


The BMP isn't fast enough.. it doesn't detect it even when in a Repeat loop.. Well it fails when the thing shows up really fast and then disappears.. If I lag a little (so Rare :c), the BMP works.. I tried to check if its an interface but its not cuz Not even RSBot is finding it even when its on screen.. Only thing I can think of is to wait until I appear at the portal meaning I'd have to loop findrsobject but it finds it before the character even appears..

Sex

2011-07-10 23:04:53

Afaik teleporting might be an animation, so just wait til the player is no longer animating :p.

Brandon

2011-07-10 23:12:37

From: Sex
Afaik teleporting might be an animation, so just wait til the player is no longer animating :p.


LOL… that is the problem.. I did wait until they stop animating.. but this isn't just teleing.. its teleing to the house.. when you tele to teh house, there is a screen that says "Homesweet Home" and shows a picture of a house.. During the time that the picture is on screen, it will return animation as -1 meaning the player isn't animating.. and if the house has a dungeon, it shows the picture of the house first, then it shows the dungeon, then the player will appear at a portal.. all of which will return the animation as -1.. and I can't put a timer because each computer is different (lag or not), each house is different (Some with a dungeon and some without)..

So Im not sure how to actually tell when the player has appeared in a house.

BraK

2011-07-10 23:36:55

Check if mini is Black until it's not? Does the Animation happen after the wait period? Get creative and check a couple place the are in the user Interface. The inface disappears while at that waiting screen, yes? check for the inventory or some tabs.

~BraK

Smarter Child

2011-07-10 23:41:28

Function DidWeTele: boolean;
begin
Result := R_TileOnMM(Point(0, 0));
end;

Just use a tile that you know will be on the MM after the teleport.

Yago

2011-07-10 23:44:12

Heres something I sue in my scripts:


Function TeleWorked(WaitTime: Integer): Boolean;

var
OriginalTile, NewTile: TTile;
Timer: Integer;

begin
OriginalTile := R_GetMyPos;
MarkTime(Timer);
while (WaitTime >= TimeFromMark(Timer)) and (OriginalTile = R_GetMyPos) do
Wait(50);
Result := (OriginalTile <> NewTile);
end;

Just make sure your player isn't running or anything when you tele…

Edit: Also, you'll need a wait after this because while you tele you're in random tiles so just add a wait to make sure the script doesn't keep on going while the screen is black…

Brandon

2011-07-10 23:49:10

I got it.. I had to do:

  Repeat
R_ClickItemBy(8013, true, '');
if(ValidInterface(399)) then
begin
Writeln(GetInterfaceText(399, 1)); //Should be No Place Like Home;
end;
Until(false);

Thats the only interface that disappears… All the others remain the same so If I checked for invent, it would still show up as an interface -___- which is odd because it's not on screen.. Chatbox still showed up as an interface even though it wasn't on screen either.. The only one that changed was interface 399 which shows up depending on how slow your computer is.. Had to use a computer that was 512mb ram to get it to stay on screen long enough… how bad :/

Yago

2011-07-10 23:52:37

From: ggzz
I got it.. I had to do:

  Repeat
R_ClickItemBy(8013, true, '');
if(ValidInterface(399)) then
begin
Writeln(GetInterfaceText(399, 1)); //Should be No Place Like Home;
end;
Until(false);

Thats the only interface that disappears… All the others remain the same so If I checked for invent, it would still show up as an interface -___- which is odd because it's not on screen.. Chatbox still showed up as an interface even though it wasn't on screen either.. The only one that changed was interface 399 which shows up depending on how slow your computer is.. Had to use a computer that was 512mb ram to get it to stay on screen long enough… how bad :/


Lol at the RAM thingy…

You could use Mines :)

Nava2

2011-07-11 01:57:46

Just check if the tile is different from before you click the portal! Easiest solution. :) Do that and check the black on the screen (just use four or five pts around the screen, use get colours and see if they're black).

KingKong

2011-07-11 02:01:59

So you want to know when you're player is in the house? simple:
get the tile of your player befor he teleports, then check if the character is still on that tile, if not then you're in da house!

E: beaten by nava :(

BraK

2011-07-11 07:25:48

Old antirandom was get Black in minimap. :) Can't beat the Classics. ;)

~BraK

Yago

2011-07-11 12:58:11

Or use mines :) which is what you guys posted…

Brandon

2011-07-11 14:39:29

From: Yago
Or use mines :) which is what you guys posted…


I eventually used a mix of them:


Procedure TeleToHouse;
var
InvItem: TInvItem; MyPos: TTile;
NewTile: TTile;
Timer, PrevCount: Integer;

begin
if(R_ItemExists(HouseTab, InvItem)) then
Repeat
R_ClickItemBy(HouseTab, true, '');
WaitForAnimation(5000);
Until(CharacterAnimating);
Repeat
PrevCount:= R_CountItem(8013);
MyPos := GetMyPos;
R_ClickItemBy(8013, true, '');
WaitForAnimation(7000);
Until((GetInterfaceText(399,1) = 'There''s no place like home...') or (R_CountItem(8013) = PrevCount - 1) or CharacterAnimating);

writeln('We Successfully teleported');

Repeat
wait(2000);
Until(ValidInterface(399))

Repeat
wait(2000);
NewTile := GetMyPos;
writeln(tostr(GetMyPos));
Until((MyPos <> NewTile) and (ValidInterface(399) = false));
wait(1000);
end;

TomTuff

2011-07-11 15:07:14

pseudocode:

T := GetSystemTime + 6000;
while (GetSystemTime < T) and not(result) do
Result := not(FindColor(Black, MainScreen));