SRL Archive - Help and Support

Picking a random of..


Torrent of Flame

2009-01-26 14:14:40

function WalkingPointsAll(where: string; whatpath: string): TPointArray;
begin
case Lowercase(where) of

'pathtohighpoint': begin
case Lowercase(whatpath) of
'leftstairs': begin
SetLength(Result, 7);
Result[0] := Point(3214, 3217);
Result[1] := Point(3213, 3210);
Result[2] := Point(3206, 3210);
Result[3] := Point(3206, 3209);
Result[4] := Point(3206, 3213);
Result[5] := Point(3206, 3218);
Result[6] := Point(3208, 3223);
end;
'rightstairs': begin
SetLength(Result, 3);
Result[0] := Point(3215, 3220);
Result[1] := Point(3212, 3228);
Result[2] := Point(3206, 3228);
end;
end;
end;
end;
end;

procedure ClimbToHighestPoint;
var TP, TP2: TPoint;
begin
if not (LoggedIn) then
Exit;
Path := WalkingPointsAll('pathtohighpoint',{random of right or left stairs} );
for i := 0 to 3 do
begin
WalkToTile(Path[i], 2, 1);
end;


How can I get it so that the it picks the left stairs route or the right stairs route at random?

Thanks :)

MasterKill

2009-01-26 14:19:50

Just an example of how to do it:

procedure ClimbToHighestPoint;
var TP, TP2: TPoint;
Whatpath: String;
begin
if not (LoggedIn) then
Exit;
Case Random(2) of
0: whatpath := 'rightstairs';
1: WhatPath := 'leftstairs';
End;
Path := WalkingPointsAll('pathtohighpoint',Whatpath);
for i := 0 to High(Path) do
begin
WalkToTile(Path[i], 2, 1);
end;

Good luck.

A G E N T

2009-01-26 16:56:32

I would say:

function WalkingPointsAll(where: string; whatpath: string): TPointArray;
begin
case Lowercase(where) of

'pathtohighpoint': begin
case Lowercase(whatpath) of
'0','leftstairs': DoStuff;
'1','rightstairs': DoStuff;
end;
end;
end;
end;
So that you can call it as WalkingPointsAll('pathtohighpoint', 'leftstairs') if you want to tell it which one (and make it obvious in the code), or WalkingPointsAll('pathtohighpoint',IntToStr(Random(2))); for random.

Torrent of Flame

2009-01-27 11:48:36

Thank you both. I think I will run with MasterKill's way though ^^

Sir R. M8gic1an

2009-01-27 14:17:02


function WalkingPointsAll(where: string; whatpath: string): TPointArray;
begin
case Lowercase(where) of

'pathtohighpoint':
begin
if Random(2) = 0 then
begin
SetLength(Result, 7);
Result[0] := Point(3214, 3217);
Result[1] := Point(3213, 3210);
Result[2] := Point(3206, 3210);
Result[3] := Point(3206, 3209);
Result[4] := Point(3206, 3213);
Result[5] := Point(3206, 3218);
Result[6] := Point(3208, 3223);
end else begin
SetLength(Result, 3);
Result[0] := Point(3215, 3220);
Result[1] := Point(3212, 3228);
Result[2] := Point(3206, 3228);
end;
end;
end;

end;

That might be the best way, as it would not require any extra vars; also if is better than case when there are only two options;

~RM

Torrent of Flame

2009-01-27 14:50:16

Rasta, That would work but I need the var, as different walks means different places are gone to, so different things need to be done.

NiCbaZ

2009-01-27 15:26:37

Il show you my system.

function Walk(where: string): boolean;
var
Tiles: TPointArray;

begin
SetAngle(True);
case where of
'ToMine':
begin

case Players[currentplayer].Strings[0] of

'lumbridge swamp':
begin
case random(2) of
0:Tiles := [Point(3093, 3236), Point(3095, 3227), Point(3099, 3217),
Point(3105, 3209), Point(3114, 3208), Point(3122, 3207),
Point(3135, 3202), Point(3139, 3193), Point(3139, 3184),
Point(3141, 3175), Point(3144, 3166), Point(3145, 3157),
Point(3146, 3147)];
1: Tiles:= [Point(3093, 3236), Point(3095, 3227), Point(3099, 3217),
Point(3105, 3209), Point(3114, 3208), Point(3122, 3207),
Point(3135, 3202), Point(3139, 3193), Point(3139, 3184),
Point(3141, 3175), Point(3144, 3166), Point(3145, 3157),
Point(3146, 3147)];
end;
end;
end;
For I:= 0 to High(Tiles) do
begin
if not WalkToTile(Tiles[I],2,2) then
begin
Writeln(' Lost');
Exit;
end else
begin
Wait(300+random(300));
Walked(' Step '+ IntToStr(I));
end;
end;
end;

That prob wont compile, because i wrote 70% of that in this post.