SRL Archive - OSR Help

Failsafe with ladders


Rodelol

2013-04-22 22:28:34

I made my first own simple script and im kinda stuck at failsafe now.
Going down ladder doesn't always work due to missclicking so my script fails.

At the moment it looks like this:

procedure GoDown;
Var x, y: integer;
begin
writeln('Goin doown!');
if (FindObjCustom(x, y, ['limb-down', 'adder'], [403770, 202786], 5)) then
begin
ClickMouse2(mouse_right);
wait(50+random(75));
WaitOptionEx('limb-down', 'adder', ClickLeft, 150);
sleep(3000);

Now what i was thinking about was some scanner to see if im in a cave and if i can see alot of black on the minimap.. Any suggestions :)?
I imagine this is pretty simple but i couldn't find a way so far so decided to ask here :)

I guess i could just click the ladder again when down to see if theres an option to climb-up but i doubt thats the best way to do it..

The Mayor

2013-04-22 22:39:05

From: Rodelol
I made my first own simple script and im kinda stuck at failsafe now.
Going down ladder doesn't always work due to missclicking so my script fails.

At the moment it looks like this:

procedure GoDown;
Var x, y: integer;
begin
writeln('Goin doown!');
if (FindObjCustom(x, y, ['limb-down', 'adder'], [403770, 202786], 5)) then
begin
ClickMouse2(mouse_right);
wait(50+random(75));
WaitOptionEx('limb-down', 'adder', ClickLeft, 150);
sleep(3000);

Now what i was thinking about was some scanner to see if im in a cave and if i can see alot of black on the minimap.. Any suggestions :)?
I imagine this is pretty simple but i couldn't find a way so far so decided to ask here :)

I guess i could just click the ladder again when down to see if theres an option to climb-up but i doubt thats the best way to do it..



You are on the right track with the black on the MM :)


 
Function IsInDungeon: Boolean;
Var
B: Integer;

Begin
B:= CountColorTolerance(394752, MMX1, MMY1, MMX2, MMY2, 30) // Counts the black colour on the MM
WriteLn('CountColour: ' + IntToStr(B))
If B > 5000 Then // If the count is greater then 5000 then it results true
Begin
WriteLn('We are inside the dungeon');
Result:= True
End;
End;


So for example, you could:
 
procedure Go Down;

Begin
Repeat
// ladder finding stuff
Until (IsInDungeon = True)
End;

Or even
 
While Not IsInDungeon Do
Begin
//Find ladder stuff here
End;

Rodelol

2013-04-22 22:54:16

Thanks alot this was very helpful :) Now back to finding more bugs ^^

The Mayor

2013-04-22 23:05:11

From: Rodelol
Thanks alot this was very helpful :) Now back to finding more bugs ^^


No problem :)

Also, I should have mentiond that you shouldn't have infinite loops. E.g., If the ladder is off screen, and it can't find the ladder after X tries then it exits.


Procedure Go Down;
Var
i: Integer;

Begin
Repeat
i := i + 1 // it will increase i by 1 after each attempt
// ladder finding stuff
Until (IsInDungeon = True) Or (i >= 5);
End;

So now it will break out of the loop if it fails after 5 attempts.