SRL Archive - OSR Help

little memory blank for case =p


ogustuce

2012-12-10 14:13:39

what i want to do is to mak is do 0,1,2,3 in order. to what do i write?
ex:

case random(3) of -> execute randomly 0 to 3
case (3) of -> execute 3

what do i write there to make it do 0,1,2,3 in order?

(sorry for the noob question)

footballjds

2012-12-10 14:23:31

From: ogustuce
what i want to do is to mak is do 0,1,2,3 in order. to what do i write?
ex:

case random(3) of -> execute randomly 0 to 3
case (3) of -> execute 3

what do i write there to make it do 0,1,2,3 in order?

(sorry for the noob question)


sorry, I cannot comprehend what you're asking. Could you try re-phrasing and giving more detail? Using complete sentences usually helps. "to what do i write" isn't possibly understandable. I'd love to help :)

ogustuce

2012-12-10 14:29:10

hmm okay, ill try. lets take this procedure :

Procedure BankMap;
Var
x,y,InBank: integer;
aFound:extended;
Begin
if (LoggedIn) then
begin
writeln('Dont see bank, trying again');
case random(3) of //what should i write there to make the script do 0,1,2,3 in order instead of random
0: begin
writeln('try1');
ToPot := [Point(2300, 3323)];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
end;
1: begin
writeln('try2');
ToPot := [Point(2313, 3323)];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
end;
2: begin
writeln('try3');
ToPot := [Point(2290, 3322)];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
end;
3: begin
writeln('try4');
InBank := DTMFromString('mQwAAAHicY2ZgYHgIxJ+B+DwQWzAyMCQDcRIQtzWWMCQK8zLMkhdlMALK8UMxIxIGAgA1mQbE');
if FindDTMRotated(InBank, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
mouse(5,5,x,y,Mouse_left);
wait(randomrange(1000,2000));
end;
FreeDtm(InBank);
end;

end;
end;
end;

footballjds

2012-12-10 14:34:00

use a for loop


procedure BankMap;
var
x,y,InBank: integer;
aFound: extended;
begin
if (LoggedIn) then
begin
writeln('Dont see bank, trying again');
for i := 0 to 3 do
begin
case i of //what should i write there to make the script do 0,1,2,3 in order instead of random
0: begin
writeln('try1');
ToPot := [Point(2300, 3323)];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
end;
1: begin
writeln('try2');
ToPot := [Point(2313, 3323)];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
end;
2: begin
writeln('try3');
ToPot := [Point(2290, 3322)];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
end;
3: begin
writeln('try4');
InBank := DTMFromString('mQwAAAHicY2ZgYHgIxJ+B+DwQWzAyMCQDcRIQtzWWMCQK8zLMkhdlMALK8UMxIxIGAgA1mQbE');
if FindDTMRotated(InBank, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
mouse(5,5,x,y,Mouse_left);
wait(randomrange(1000,2000));
end;
FreeDtm(InBank);
end;
end;
end;
end;
end;

it'd be even better to create an array of points and then loop through the array to walk to them. However the above uses the logic you requested :)

ogustuce

2012-12-10 14:42:16

kk thanks!

Olly

2012-12-10 14:47:39

As what footballjds said you could also do something like this

procedure this;
var
Points: TPointArray;
i: integer;
begin
Points := [Point(150,150), Point(200,200), Point(350,350)];

For i := 0 to high(Points) do
begin
writeln('Attempting to SPS walk to bank attempt number '+tostr(i));
sps_walktopos(points[i]);
while ismoving do
wait(100 + Random(100));
end;
end;

ogustuce

2012-12-10 15:07:50

doesnt really fit in my script but thanks =)

Wardancer

2012-12-10 15:34:33

I'm not use what your procedure is about. Are you trying to walk to bank and the script is coded to try to go from different locations? If so, I would add a Break; to the loop to avoid any possible issue/save memory.

I would write something like:

procedure BankMap;
var
i, x, y, InBank: integer;
aFound: extended;
TPA : TPointArray;
begin
if not (LoggedIn) then
Exit;
TPA := [Point(2300, 3323), Point(2313, 3323), Point(2290, 3322)];
writeln('Can''t see the bank, trying again');
for i := 0 to high(TPA) do
begin
writeln('Attempt ' + IntToStr(i + 1));
ToPot := TPA[i];
SPS_WalkPath(ToPot);
Wait(RandomRange(2000,3000));
InBank := DTMFromString('mQwAAAHicY2ZgYHgIxJ+B+DwQWzAyMCQDcRIQtzWWMCQK8zLMkhdlMALK8UMxIxIGAgA1mQbE');
if FindDTMRotated(InBank, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
mouse(5, 5, x, y, Mouse_left);
wait(randomrange(1000,2000)); //Is this waiting for the bank to bank? You might prefer something like WaitFunc(@BankScreen, 10, 3000);
FreeDTM(InBank);
Break;
end;
end;
end;

I'll repeat a tip that I read on another thread that helped me a great deal. Don't just copy the procedure (anyway I probably made it typo somewhere). Try to understand it.

ogustuce

2012-12-12 23:06:30

its a failsafe actually. the SPS(point) at the bank is inaccurate. sometimes it clicks right and lead inside the bank but sometimes its off and click outside the bank. my idea was: if cant find bankbooth dtm then begin the failsafe procedure to lead inside the bank.

the dtm 'inbank' was DTM to find on the mainscreen that is inside the bank in case that the sps failsafes fails