SRL Archive - Reflection Help

Need a little help with Reflection 2, please.


bud_wis_er_420

2011-09-04 16:13:51

I'm having a hard time understanding exactly how I use Reflection 2. I'm new to Reflection and can't figure out how to use it. All I'm asking is if someone could write me a short runnable little script that I can use as an example. Or template if you will. Once I see how it's done I think I will understand. My problem is finding a working R2 script that I can play with and edit to experiment with. Everything I find that works is way to complicated for me to try to break down.
I just want to see Reflection working in it's simplest form. All I'm looking for is something where it finds an item on ground and picks it up. And please a whole script. not just a procedure or function. I need to see how it's all put together. Thank very much for your time in helping me.

Harry

2011-09-04 16:29:20

I'd highly suggest looking at the include files, they are all documented and sorted out. Here's a simple base just ripped out of my PSWC, this should work on its own but you will need to mod it to make it work for your needs.


program ok;
{$DEFINE SMART}
{$i SRL/SRL.scar}
{$i Reflection/Reflection.simba}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := 'Username';
Pass := 'Password';
Nick := 'nick';
Member := False;
Active := True;
end;

end;

const
SERVER = 61; // Enter "0" to pick a random server.
SIGNED = True; // Use the signed RS-client? Leave at True unless you know what you're doing.
MEMBERS = False; // Set to True if using a RS-Members account. False if F2P.


function BodenItems: boolean;
var
Items: TGroundItemArray;
TempMS: TPoint;
iiad: Integer;
begin
Result := False;
if not LoggedIn then
Exit;

Items := R_GetGroundItemsEx([5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 7413, 11966,1515,1359],3);
if GetArrayLength(Items) > 0 then
begin
for iiad := 0 to High(Items) do
case items[iiad].ID of
5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 7413, 11966:
begin
TempMS := R_TileToMSEx(Items[iiad].Tile, 0.5, 0.5, 100);
Mouse(TempMS.X, TempMS.Y, 5, 5, false);
if R_WaitOption('Bird', 500) then
begin
WriteLn('Got birds nest!');
Result := True;
R_FFlag(0);
Wait(500+Random(2000));
end
else
WriteLn('Failed to grab nest. sadfrog.');
end;
1515:
begin
TempMS := R_TileToMSEx(Items[iiad].Tile, 0.5, 0.5, 100);
Mouse(TempMS.X, TempMS.Y, 5, 5, false);
if R_WaitOption('Take Yew', 500) then
begin
WriteLn('Got yew logs off ground!');
Result := True;
R_FFlag(0);
Wait(100+Random(1000));
end
else
WriteLn('Failed to grab yew logs off ground. sadfrog.');
end;
1359:
begin
TempMS := R_TileToMSEx(Items[iiad].Tile, 0.5, 0.5, 100);
Mouse(TempMS.X, TempMS.Y, 5, 5, false);
if R_WaitOption('Take Rune', 500) then
begin
WriteLn('Got Rune hatchet off ground!');
Result := True;
R_FFlag(0);
Wait(100+Random(1000));
end
else
WriteLn('Failed to grab Rune hatchet off ground. sadfrog.');
end;
end;
end;
SetArrayLength(Items,0);
end;

procedure SetUpScript;
begin
ClearDebug;

Smart_Server := SERVER;
Smart_Signed := SIGNED;
Smart_Members:= MEMBERS;

SetUpReflection;
Reincarnate := True;
DeclarePlayers;
LampSkill := 'woodcutting';

ActivateClient;
Wait(1000 + Random(2000));
end;

procedure MainLoop;
begin
CurrentPlayer := RandomPlayerIndex;
LogInPlayer;

repeat
repeat
BodenItems;
if (not LoggedIn) then
begin
WriteLn('Not logged in?');
Wait(500+Random(1000));
if (not LoggedIn) then Break else Wait(1);
end;
if LobbyScreen then
begin
WriteLn('At lobby screen?');
Wait(500+Random(1000));
if (LobbyScreen) then Break else Wait(1);
end;
until(False);
if LobbyScreen then
LeaveLobby;

WriteLn('Detected as logged out, NPlayer');
NextPlayer(Players[CurrentPlayer].Active);
until False;
end;

begin
SetUpScript;
MainLoop;
end.

bud_wis_er_420

2011-09-04 16:35:26

From: Harry
I'd highly suggest looking at the include files, they are all documented and sorted out.


Oh wow I didn't even know those were there. I'm looking into it now. Thx alot, for the script too.