SRL Archive - OSR Help

Falling into a trap


jman1208

2012-07-19 16:43:49

I'm trying to make it so the script checks if i fell into the trap after it clicks Jump but i can't seem to get it working. Also when you fall into the pit you get damage taken, i also tried so it checks for hp bar but none are working. I appreciate any help this is holding me back

Function FallCheck: boolean;
var
xas, yas: Integer;
theChat: String;

begin
xas:=MSCX;
yas:=MSCY;
theChat := GetChatBoxText(8, clBlack);
if(ExecRegExpr('You Fall', theChat) OR ExecRegExpr('onto the spik', theChat)) then
begin
FellIntoTrap := True;
writeln('We fell into the trap');
end;

if(ExecRegExpr('manage to cross', theChat) OR ExecRegExpr('off safely ', theChat)) then
begin
FellIntoTrap := false;
writeln('We didnt fall into the trap');
end;

repeat
if (FellIntoTrap) then
begin
if (FindObjCustom(xas, yas, ['limb'], [1062452], 20)) then
begin
CheckAndClick('limb', xas,yas, 'L')
writeLn('Climbing out of pit');
FellIntoTrap := false;
end;
end;
until Not (FellIntoTrap);
if NOT(FellIntoTrap) then
begin

writeLn('Yay we didnt fall in!');

end;
end;

Function JumpLeaves:boolean;
begin

if (FindJumpLeaves(x, y)) then
begin
CheckAndClick('Jump', x, y, 'L')
Wait(6000);
FallCheck;
end;

putonajonny

2012-07-19 21:37:18

How about something like this:
function FallCheck: boolean;
var
xas, yas: Integer;
begin
xas := MSCX;
yas := MSCY;
Result := FindChatBoxText('You Fall', 8, clMessage) or FindChatBoxText('onto the spik', 8, clMessage);
if (Result) then
WriteLn('You fell into the trap')
else
WriteLn('You did not fall, Yay!');
end;

function GetOutOfTrap: Boolean;
Var
x, y, xas, yas : integer;
begin
if (FindObjCustom(xas, yas, ['limb'], [1062452], 20)) then
begin
if(WaitUpText('limb', 200+Random(500)))then
begin
GetMousePos(x, y);
if((x = xas) and (y = yas))then
ClickMouse2(mouse_Left)
else
Mouse(xas, yas, 3, 3, mouse_Left);
end;
writeLn('Climbing out of pit');
Result := DidRedClick;
end;
end;

function JumpLeaves: boolean;
var
Tries, x, y : integer;
begin
if (FindJumpLeaves(x, y)) then
begin
CheckAndClick('Jump', x, y, 'L') Wait(6000);
Tries := 0;
if (FallCheck) then
while ((not GetOutOfTrap) and (Tries < 5)) do
inc(Tries);
end;
end;

If you don't understand what any of the code does then just ask :)

x[Warrior]x3500

2012-07-19 22:50:49

also, you can use a mmpercentblack (or something similar to that) to find out what percent of the MM is black. typically in traps > 90% is black, but out of them 0% is black

jman1208

2012-07-19 23:40:38

From: putonajonny
How about something like this:


If you don't understand what any of the code does then just ask :)



Thanks! Its almost working well but the only issue i'm having right now is that there's 3 rocks it can choose inside the cave and you can only get to 1 depending on where you fall, so it will click on rocks on another wall sometimes and not the one directly infront or closest. But for now i have a quick fix it changes angles after 3 tries. This is what i got now


function FallCheck: boolean;
var
xas, yas: Integer;
begin
xas := MSCX;
yas := MSCY;
Result := (DungeonColor(x, y));
if (Result) then
begin
WriteLn('You fell into the trap')
end;
if Not (result) then
begin
WriteLn('You did not fall, Yay!');
end;
end;
function GetOutOfTrap: Boolean;
Var
Trys, x, y, xas, yas : integer;
begin
Result := (FindJumpLeaves(x,y));
SetAngle(SRL_Angle_High);
MakeCompass('n');
If Not (result) then

begin
repeat
if (Trys > 5) then
begin
ChangeAngle;
writeLN('Changing angle tried too long')
Trys := 0;
end;
writeLN('Trying to get out of cave');
if (FindObjCustom(xas, yas, ['limb'], [1062452], 20)) then
begin
if(WaitUpText('limb', 200+Random(500)))then
begin

GetMousePos(x, y);
inc(Trys);
if((x = xas) and (y = yas))then
ClickMouse2(mouse_Left)

else
wait(300);
Mouse(xas, yas, 3, 3, mouse_Left);


end;
end;
until (FindJumpLeaves(x,y));
end else
if (result) then
begin
writeLn('Were out!');
exit;
end;
end;


putonajonny

2012-07-20 07:09:03

For this part:
   if (Result) then
begin
WriteLn('You fell into the trap')
end;
if Not (result) then
begin
WriteLn('You did not fall, Yay!');
end
You can shorten it by using an if else statement, and you don't need the begins and ends if you are just doing one thing:
if (Result) then
WriteLn('You fell into the trap')//Notice there is no ; here
else
WriteLn('You did not fall, Yay!');

I am assuming this is where you end up if you fail:
What do you have to click to get out?

jman1208

2012-07-20 08:29:19

From: putonajonny
For this part:
   if (Result) then
begin
WriteLn('You fell into the trap')
end;
if Not (result) then
begin
WriteLn('You did not fall, Yay!');
end
You can shorten it by using an if else statement, and you don't need the begins and ends if you are just doing one thing:
if (Result) then
WriteLn('You fell into the trap')//Notice there is no ; here
else
WriteLn('You did not fall, Yay!');

I am assuming this is where you end up if you fail:
What do you have to click to get out?



You have to click the rocks closest to you because you can't walk inside

putonajonny

2012-07-20 13:10:24

This part?
And not this one:

x[Warrior]x3500

2012-07-20 13:39:48

- autocolor climbing rocks
- sort by dist (or use findColorsSpriralTol of the mscx/mscy)
- create atpa
- atpa[0] should be the rocks, use middle x/y of atpa[0] and check for uptext

Joe

2012-07-20 14:01:02

have this picture come up when you fall in

jman1208

2012-07-20 18:29:33

From: x[Warrior]x3500
- autocolor climbing rocks
- sort by dist (or use findColorsSpriralTol of the mscx/mscy)
- create atpa
- atpa[0] should be the rocks, use middle x/y of atpa[0] and check for uptext

Ok thanks, i've never used atpa's before( this is my second script, i'm still fairly new) ill try to find a tutorial and see if i can figure it out

From: putonajonny
This part?
And not this one:


Yes exactly

Getdropped

2012-07-25 02:27:36

From: jman1208
Ok thanks, i've never used atpa's before( this is my second script, i'm still fairly new) ill try to find a tutorial and see if i can figure it out



Yes exactly


If you do not want to use FindColorsSpiralTolerance then i would suggest useing ACA and color the rocks(dark brown) this could also be used in order to tell if you fell you could search for the uptext that the rocks have i'm assuming 'limb' (climb) but honestly FindColorsSpiralTolerance will be more accurate however if you are looking for the quick fix going with ACA would be the way ;) GL

EDIT: On second thought ACA is showing that alot of the surrounding rocks have similar colors…

x[Warrior]x3500

2012-07-25 13:18:09

From: getdropped69
If you do not want to use FindColorsSpiralTolerance then i would suggest useing ACA and color the rocks(dark brown) this could also be used in order to tell if you fell you could search for the uptext that the rocks have i'm assuming 'limb' (climb) but honestly FindColorsSpiralTolerance will be more accurate however if you are looking for the quick fix going with ACA would be the way ;) GL

EDIT: On second thought ACA is showing that alot of the surrounding rocks have similar colors…


his aca should look something like this: http://puu.sh/LBRs with a distance of about 10-15

Nebula

2012-07-25 13:20:45

How does the minimap look before&after? could use PercentColorMM.

Getdropped

2012-07-26 00:45:54

From: Nebula
How does the minimap look before&after? could use PercentColorMM.


or even a count color if it turns mostly black that would be easier. There are so many different ways you could go at this it is really up to your preference ;) but thats why we are he to show you the tools :p just woundering where exactly is that trap any ways i dont think i have ever been where ever it is.

x[Warrior]x3500

2012-07-26 01:03:17

From: getdropped69
or even a count color if it turns mostly black that would be easier. There are so many different ways you could go at this it is really up to your preference ;) but thats why we are he to show you the tools :p just woundering where exactly is that trap any ways i dont think i have ever been where ever it is.


its in the elven lands (dont know exactly what its called - far far west on world map - west of ardy, south west of tree gnome stronghold)

Olly

2012-07-27 21:17:59

Trying to make a grenwaller :P?