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.
Also removed some redundant code in R_FFlag:
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;