SRL Archive - Help and Support

Couple things [Reflection]...


Runescapian321

2009-05-18 02:52:54

See/Download the whole script here - http://www.villavu.com/forum/showthread.php?t=45152

1) I use a variation of WalkToTileMS to chop trees. Basically it just clicks the tiles on which the trees are standing. Problem is, even though I've included randomness on the tiles, it always clicks the same tile to chop the tree.

{*******************************************************************************
Function ChopItMS(Tile: TPoint; Randomness, FlagD: Integer): Boolean;
By: Nava2 edited by Runescapian to chop trees instead
Description: Walks to the tile using the mainscreen. Similar to SRLs version.
Thanks to lordsaturn for the idea.
*******************************************************************************}
function ChopItMS(Tile: TPoint; Randomness, FlagD: Integer): Boolean;

var
P: TPoint;
T : Integer;

begin
Result := False;
Tile := Point(RandomRange(Tile.X - Randomness, Tile.X + Randomness), RandomRange(Tile.Y - Randomness, Tile.Y + Randomness));
P := TileToMS(Tile, Random(5));
if not TileOnMS(Tile, 0) then Exit;
MMouse(P.x, P.y, 5, 5);
Wait(RandomRange(80, 100));
GetMousePos(P.x, P.y);
if Pos('hop', GetUpText) <> 0 then
Mouse(P.x, P.y, 0, 0, True)
else
begin
Mouse(P.x, P.y, 0, 0, False);
Wait(RandomRange(80, 100));
ChooseOption('hop');
end;
T := GetSystemTime;
Wait(RandomRange(80, 100));
R_FFlag(FlagD);
Result := (GetSystemTime - T) < 60000;
End;

Function ChopTrees: boolean;
var
ChopTime,Chopping,strikes: integer;
TreeInfo1, TreeInfo2, TreeInfo3, TreeInfo4: UID;
begin
if not(loggedin) then
begin
SwitchPlayer(true);
exit;
end;
Distat('Chopping Trees');
SetRun(true);
MarkTime(ChopTime);
repeat
if not(loggedin) then loginplayer;
TreeInfo1 := GetObjectAt(randomrange(2968,2969),3194);
if (TreeInfo1.objtype = 5553) then
begin
ChopItMS(point(2968+random(1),3194),0,0); //Note the +random(1)
FindNormalRandoms;
R_FindRandoms;
wait(3000+Random(500));
strikes := 0;
MarkTime(Chopping);
repeat
if not(GetAnimation > 840) then
break;
if (InvFull) then
break;
DoAntiban;
FindNormalRandoms;
R_FindRandoms;
Distat(InttoStr(InvCount)+' Inventory Spots filled');
until(TimeFromMark(chopping) > 600000);
end else
begin
TreeInfo2 := GetObjectAt(2970,3194);
if (TreeInfo2.objtype = 5552) then
begin
ChopItMS(point(2970+random(1),3193+random(1)),0,0);
wait(3000+Random(500));
strikes := 0;
FindNormalRandoms;
R_FindRandoms;
MarkTime(Chopping);
repeat
if not(GetAnimation > 840) then
break;
if (InvFull) then
break;
DoAntiban;
FindNormalRandoms;
R_FindRandoms;
Distat(InttoStr(InvCount)+' Inventory Spots filled');
until(TimeFromMark(Chopping) > 600000);
end else
begin
TreeInfo3 := GetObjectAt(2973,3196);
if (TreeInfo3.objtype = 5551) then
begin
ChopItMS(point(2973+random(1),3195+random(1)),0,0);
wait(3000+Random(500));
FindNormalRandoms;
R_FindRandoms;
strikes := 0;
MarkTime(Chopping);
repeat
if not(GetAnimation > 840) then
break;
if (InvFull) then
break;
DoAntiban;
FindNormalRandoms;
R_FindRandoms;
Distat(InttoStr(InvCount)+' Inventory Spots filled');
until(TimeFromMark(Chopping) > 600000);
end else
begin
TreeInfo4 := GetObjectAt(2968,3192);
if (TreeInfo4.objtype = 5551) then
begin
ChopItMS(point(2968+random(1),3191+random(1)),0,0);
wait(3000+Random(500));
strikes := 0;
FindNormalRandoms;
R_FindRandoms;
MarkTime(Chopping);
repeat
if not(GetAnimation > 840) then
break;
if (InvFull) then
break;
DoAntiban;
FindNormalRandoms;
R_FindRandoms;
Distat(InttoStr(InvCount)+' Inventory Spots filled');
until(TimeFromMark(Chopping) > 600000);
end else
begin
WalkToTile(point(2969,3195),0,0);
Inc(strikes);
FindNormalRandoms;
R_FindRandoms;
debug('strikes = '+IntToStr(strikes));
if (strikes > 100) then
begin
writeln('Haven''t found any trees for a while. Next Player.');
Players[CurrentPlayer].strings[0] := 'Didn''t find trees for a while';
SwitchPlayer(false);
result := false;
exit;
end;
wait(1000+random(500));
end;
end;
end;
end;
until(InvFull) or (TimeFromMark(choptime) > 3600000);
if (InvFull) then
result := true;
end;
2) There's a large delay when my script is trying to open a door.

Function HandleDoor: boolean;
var
DoorInfo: UID;
begin
if not(loggedin) then
begin
SwitchPlayer(true);
exit;
end;
FindNormalRandoms;
R_FindRandoms;
DoorInfo := GetObjectAt(2951,3214);
if (DoorInfo.ObjType = 1533) then
begin
debug('DOOR CLOSED, attempting to open');
if (ClickDoor(DoorInfo.objtype,'w','pen')) then
begin
wait(2000+random(1000));
debug('Opened door');
Inc(DoorsOpened);
result := true;
exit;
end;
result := false;
writeln('Failed opening closed door. Next Player.');
Players[CurrentPlayer].strings[0] := 'Door opening failed';
switchplayer(false);
exit;
end;
result := true;
end;

When it detects the door as open (not ID = 1533), it does that really quickly, but when it's closed, it takes a good bit of time (5-8 seconds) for it to open it. I guess this is because of ClickDoor, any suggestions on how to speed it up?

Method

2009-05-18 03:05:00

You want Random(2) instead of Random(1) for the first problem. Random(1) always returns 0.

I don't know about the second issue.

Runescapian321

2009-05-18 03:18:34

Oh lol. Thanks :) I was doing randomrange(2746,2747) before, I guess that would always return 2746?

Floor66

2009-05-18 09:13:05

Idk, but indeed Random(1) will give only 1 answer which is 0.

Nava2

2009-05-18 09:45:29

From: Runescapian
Oh lol. Thanks :) I was doing randomrange(2746,2747) before, I guess that would always return 2746?


No, that would give you a range between them. :)

For the door, you may want to use FindObjectEx and change teh last param. it does something with the search area. idk what. its hard to read atm.

lordsaturn

2009-05-18 20:41:57

From: Nava2
No, that would give you a range between them. :)

For the door, you may want to use FindObjectEx and change teh last param. it does something with the search area. idk what. its hard to read atm.

Drugs are bad for nava2. ;)

and FindObjectEx lets you specify the number of tiles from your character to search for the object. 5 works well for the mainscreen, 18 or so for the minimap. If FindObject is called, the function will search the entire 104x104 tile loaded map.

Nava2

2009-05-19 02:41:13

From: lordsaturn
Drugs are bad for nava2. ;)

and FindObjectEx lets you specify the number of tiles from your character to search for the object. 5 works well for the mainscreen, 18 or so for the minimap. If FindObject is called, the function will search the entire 104x104 tile loaded map.


So.. THATS what I meant…

I was only a little drunk.

Bobarkinator

2009-05-19 04:42:20

From: lordsaturn
Drugs are bad for nava2. ;)

and FindObjectEx lets you specify the number of tiles from your character to search for the object. 5 works well for the mainscreen, 18 or so for the minimap. If FindObject is called, the function will search the entire 104x104 tile loaded map.


FindObject is rather retarded as that takes 6 or 7 seconds to complete. I would never use it in a script.

Runescapian321

2009-05-19 05:05:59

So I guess it wouldn't be much of an improvement over the 5-8 sec delay I'm getting now? :\

mormonman

2009-05-19 05:10:29

From: Runescapian
So I guess it wouldn't be much of an improvement over the 5-8 sec delay I'm getting now? :\


no, use findobjectex.

Nava2

2009-05-19 05:59:20

Use Ex. Its MUCH faster.

Tniffoc

2009-05-19 06:21:09

Just a question, when does reflection plan to settle down? I know that it keeps changing and my code gets out-dated. Also, my walking will randomly fail… Hence, I don't like reflection which seems to be one of the most powerful tools out at the moment. Maybe I just suck. Anybody willing to give me a code review?

Method

2009-05-19 07:29:34

What major updates have there been in the past month? For the most part, I think everyone has finished up the basics of reflection and moved on to other things (like developing SRL in Nava2, Saturn, and Zeph's cases).

To "catch up" on the code, simply go through the include files and ask questions if you have any while browsing.