SRL Archive - Bugs

DistanceFromFlag not working... MyPos hooks switched?


ZephyrsFury

2010-06-16 04:10:29

I noticed a strange bug with DistanceFromFlag just now when R_FFlag didn't seem to work for me. I did a bit of debug and realised that the hooks used to get your position on the map appears to be switched. ie. the X hook is the Y and vice versa.

Also, R_FFlag I assume is supposed to take the distance in pixels since the SRL version uses pixels however the distance you check is in tiles. Not sure if you want to convert to pixels or leave it as tiles.


function DistanceFromFlag: Integer;
var
MyPos, FlagPos: TTile;
Me: integer;
begin
if not R_FlagExists then Exit;
Me := SmartGetFieldObject(0, hook_static_MyPlayer);
MyPos.y := SmartGetFieldArrayInt(Me, hook_character_WalkQueueX, 0); //this works (notice MyPos.Y)
MyPos.x := SmartGetFieldArrayInt(Me, hook_character_WalkQueueY, 0);
FlagPos := GetDest;
//writeln(inttostr(mypos.X) + ' ' + inttostr(mypos.y));
//writeln(inttostr(FlagPos.X) + ' ' + inttostr(flagpos.y));
Result := Distance(MyPos.x, MyPos.y, FlagPos.x, FlagPos.y);
SmartFreeObject(me);
end;

Also removed some redundant code in R_FFlag:

procedure R_FFlag(Dist: Integer);

var
Tx, Ty, m, d1, d2: Integer;
D: TTile;

begin
if not WaitToMove(1500) then Exit;
while (R_FlagExists) do
begin
d1 := DistanceFromFlag;
WriteLn(d1);
if (d1 < Dist) then Break;
if not (GetSpeed > 0) then Exit;
Wait(100 + Random(30));
if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();
if (Random(100) = 0) then IdleTime(500, 1000, 0.01);
end;
end;

Drakan

2010-06-16 06:39:28

We want it in Tiles. If we wanted it in pixels, we would use SRL's color version :P And thanks, I'll check out the hooks, though it has been working for me.

EDIT: According to RSBot and a couple of other updaters, these hooks appear to be correct. However, the WalkingQueue hooks are flipped.

hook_character_WalkQueueX = 'tc';
hook_character_WalkQueueY = 'Cc';

Use those ones.

ZephyrsFury

2010-06-16 09:07:22

From: drags111
We want it in Tiles. If we wanted it in pixels, we would use SRL's color version :P And thanks, I'll check out the hooks, though it has been working for me.

EDIT: According to RSBot and a couple of other updaters, these hooks appear to be correct. However, the WalkingQueue hooks are flipped.

hook_character_WalkQueueX = 'tc';
hook_character_WalkQueueY = 'Cc';

Use those ones.


Awesome and pixels is just how R_FFlag has always been so just saying.

masterBB

2010-06-16 18:42:09

Aren't tiles a more accurate way?

3Garrett3

2010-06-16 19:34:50

From: masterBB
Aren't tiles a more accurate way?


My scripts use DistanceTo, but all walking procedures use R_FFlag, to my knowledge.