SRL Archive - Reflection Help

GetFlag Broken (Therefore WalkToTile, R_FFlag as well)


Runescapian321

2009-08-28 01:53:34

It's not completely broken, just occasionally malfunctions. I think this may be the main reason some scripts, even though they should be flawless, have the tendency to fail every once in a while. Or maybe it's just me, run this script


program GetFlagTest;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl\srl/reflection/reflection.scar}

procedure DoTest;
var
FlagP : TPoint;
begin
repeat
writeln(BoolToStr(GetFlag(FlagP)));
writeln(IntToStr(FlagP.x)+','+IntToStr(FlagP.y));
wait(1000);
until(false);
end;

begin
Smart_Members := false;
Smart_Signed := true;
Smart_Server := 30;
SetupSRL;
SetupReflection;
Dotest;
end.


And just click around the minimap (I think it occurs in some places more often than others). Sooner or later you'll find a spot where if you try walking to it, GetFlag will return false (Though I believe it still returns the correct tile) even though the flag is clearly present.

EDIT:

Temp fix here, it's not the most efficient but it should get the job done until the problem is completely solved.

{*******************************************************************************
function GetFlag(var TFlag: TPoint): Boolean;
By: TheGuyWhoGotOn modded by Timer and Tad
Description: Gets your destination (Tiles)
*******************************************************************************}
function GetFlag(var TFlag: TPoint): Boolean;

var
xFlag, yFlag: LongInt;

begin
xFlag := SmartGetFieldInt(0, FlagX);
yFlag := SmartGetFieldInt(0, FlagY);
TFlag := Point((SmartGetFieldInt(0, BaseX) + xFlag), (SmartGetFieldInt(0, BaseY) + yFlag));
WaitToMove(150);
Result := CharacterMoving;
end;

Smarter Child

2009-08-28 02:08:28

It was saying false only when i wasn't moving, for a while. But then, after a little bit, even though im moving its resulting as false..Your not alone, I think GetFlag needs to be modified.

ZephyrsFury

2009-08-28 13:47:00

This is probably why my scripts like to click multiple times on the same tile for no apparent reason.

Bobarkinator

2009-08-28 15:27:30

From: ZephyrsFury
This is probably why my scripts like to click multiple times on the same tile for no apparent reason.


I've noticed that as well.

Gu3st...

2009-08-28 15:29:31

From: Bobarkinator
I've noticed that as well.

Me too.
Sometimes my script would output something like "could not walk to bank" and then when I log on to the account I was using I see that he in fact was inside the bank…

Runescapian321

2009-08-28 23:12:01

Possibly a temp fix:

{*******************************************************************************
function GetFlag(var TFlag: TPoint): Boolean;
By: TheGuyWhoGotOn modded by Timer and Tad
Description: Gets your destination (Tiles)
*******************************************************************************}
function GetFlag(var TFlag: TPoint): Boolean;

var
xFlag, yFlag: LongInt;

begin
xFlag := SmartGetFieldInt(0, FlagX);
yFlag := SmartGetFieldInt(0, FlagY);
TFlag := Point((SmartGetFieldInt(0, BaseX) + xFlag), (SmartGetFieldInt(0, BaseY) + yFlag));
WaitToMove(150);
Result := CharacterMoving;
end;

mormonman

2009-08-29 01:40:37

Umm… Tad, why do you even have the xflag, yflag, and tflag, they don't do anything. You pretty much just made the WaitToMove function over again.

Runescapian321

2009-08-29 01:44:11

From: mormonman
Umm… Tad, why do you even have the xflag, yflag, and tflag, they don't do anything. You pretty much just made the WaitToMove function over again.


xflag and yflag were there originally (to return TFlag, the point where the flag is). And I've never needed something like WaitToMove so I forgot there was one, will edit :p

mormonman

2009-08-29 01:45:26

I know that they were there originally, I was saying that your *fix* didn't do anything to the function. Pretty much used a completely different method for it.

Runescapian321

2009-08-29 01:47:33

From: mormonman
I know that they were there originally, I was saying that your *fix* didn't do anything to the function. Pretty much used a completely different method for it.


No I just changed the method of returning whether or not a flag is present (because apparently the flag hooks aren't working in that respect, or something). I left TFlag so you still know what point the flag is at (I'm not sure why, but xflag and yflag always have the correct values, but for some reason the old one used to return false even if there was a flag).

ZephyrsFury

2009-08-29 06:37:31

Don't add WaitToMove there. GetFlag isn't just used in R_FFlag.

Runescapian321

2009-08-29 07:07:43

From: ZephyrsFury
Don't add WaitToMove there. GetFlag isn't just used in R_FFlag.


WaitToMove does basically the same thing that GetFlag would return. If you're moving, a flag is present. It's not the best fix, but until someone figures out what's wrong with the current GetFlag, it's the best thing I can think of.

kyleisntwild

2009-08-30 03:15:31

Ah yes. I have noticed this problem for a while. My potato picker has to walk a lot and the walking will never work 100%. At first, the only logical explanation I could think of was the randomization of tiles was pushing it off the view of the minimap, but after making sure it was impossible for this to happen, the walking still messed up. It looks like what you described is my problem.

What happens is it walks one or two tiles and then outprints that it has finished walking all tiles in the path array which is completely false. I have it retry walking multiple times and it manages to make it to the location most of the time… but it slows the script WAY down because it sometimes takes 3 or 4 tries… Adding R_Flag; helps a bit, but it still messes up occasionally and looks extremely bot like.

I was thinking I was going to have to make some sort of custom walking procedure, having it check to see if its in a box centered around the tile I want it to click before it moves on to the next one. But hopefully the problem can be resolved now that you have posted about it.

Runescapian321

2009-08-30 03:31:37

From: kyleisntwild
Ah yes. I have noticed this problem for a while. My potato picker has to walk a lot and the walking will never work 100%. At first, the only logical explanation I could think of was the randomization of tiles was pushing it off the view of the minimap, but after making sure it was impossible for this to happen, the walking still messed up. It looks like what you described is my problem.

What happens is it walks one or two tiles and then outprints that it has finished walking all tiles in the path array which is completely false. I have it retry walking multiple times and it manages to make it to the location most of the time… but it slows the script WAY down because it sometimes takes 3 or 4 tries… Adding R_Flag; helps a bit, but it still messes up occasionally and looks extremely bot like.

I was thinking I was going to have to make some sort of custom walking procedure, having it check to see if its in a box centered around the tile I want it to click before it moves on to the next one. But hopefully the problem can be resolved now that you have posted about it.


Try the temp fix and tell me if it helps :)

mormonman

2009-08-30 04:27:11

From: Tad
WaitToMove does basically the same thing that GetFlag would return. If you're moving, a flag is present. It's not the best fix, but until someone figures out what's wrong with the current GetFlag, it's the best thing I can think of.


No, when you click on any object, or attack/talk to an NPC, there is no flag.


Edit: This is the one from RsBot. Notice the warning.

/**
* Gets the destination tile. Where the flag is. WARNING: This method can
* return null.
*/
public RSTile getDestination() { // ngovil21
if (Bot.getClient().getDestX() <= 0) {
return null;
}
return new RSTile(getClient().getDestX() + getClient().getBaseX(),
getClient().getDestY() + getClient().getBaseY());
}

kyleisntwild

2009-08-30 05:40:53

From: Tad
Try the temp fix and tell me if it helps :)


I tried the temp fix and got similar results to when I had just R_Flag. It waits till it gets there, and stops moving, then continues. Works, but looks detectable to me.

Runescapian321

2009-08-30 05:45:46

From: mormonman
No, when you click on any object, or attack/talk to an NPC, there is no flag.


Edit: This is the one from RsBot. Notice the warning.

/**
* Gets the destination tile. Where the flag is. WARNING: This method can
* return null.
*/
public RSTile getDestination() { // ngovil21
if (Bot.getClient().getDestX() <= 0) {
return null;
}
return new RSTile(getClient().getDestX() + getClient().getBaseX(),
getClient().getDestY() + getClient().getBaseY());
}


Oh, yeah. But where in the include is GetFlag used for such situations? And do you have any better solution :cartman:?

From: kyleisntwild
I tried the temp fix and got similar results to when I had just R_Flag. It waits till it gets there, and stops moving, then continues. Works, but looks detectable to me.


I dunno. It helped my script a lot – It used to fail walking after about 1.5 hours. Now I got 3, 3, and 9 hours all stopped by randoms. Maybe something else is wrong?

Blumblebee

2009-08-30 06:46:06

cant you simply work around it? Ex. While not Distance From TileClicked do SleepandMoveMouse(RandomRange(150, 1500)); or something similiar? Realistically flag isnt needed much if your using reflection is it? (I dont use reflection but thats my views)

Runescapian321

2009-08-30 07:06:20

From: Blumblebee
cant you simply work around it? Ex. While not Distance From TileClicked do SleepandMoveMouse(RandomRange(150, 1500)); or something similiar? Realistically flag isnt needed much if your using reflection is it? (I dont use reflection but thats my views)


Well in this case we're using flag to detect whether or not we're moving, and the location of the flag (where we're moving to). Using the location of the flag, we measure the distance between that and our current point (basically what you said), so therein lies the problem :p

By the way, mormonman, wouldn't a WaitToMove be better in most cases seeing as the only thing GetFlag is really used for is checking whether you are moving (and the location of the flag, but that's working fine, no need to change it)? Or is it used somewhere I'm not aware of?

Method

2009-08-30 11:02:56

From: mormonman
No, when you click on any object, or attack/talk to an NPC, there is no flag.


Edit: This is the one from RsBot. Notice the warning.

/**
* Gets the destination tile. Where the flag is. WARNING: This method can
* return null.
*/
public RSTile getDestination() { // ngovil21
if (Bot.getClient().getDestX() <= 0) {
return null;
}
return new RSTile(getClient().getDestX() + getClient().getBaseX(),
getClient().getDestY() + getClient().getBaseY());
}


If you have to walk to the location of the npc, player, or object, yes there is a flag. Also, that function only returns null if a flag isn't on the minimap, which seems like the intended behavior to me. Returning a RSTile with random or empty coordinates would be pointless.

mormonman

2009-08-30 11:05:42

Of course Method is right, I never argue with you. I think this error comes from client lag. It will return -1 and then false and screw it all up.

ZephyrsFury

2009-08-30 11:07:48

I'm pretty sure the flag doesn't appear when you're interacting with ground items at least.

mormonman

2009-08-30 21:37:19

From: ZephyrsFury
I'm pretty sure the flag doesn't appear when you're interacting with ground items at least.


It might be invisible.