SRL Archive - OSR Help

Help


justleveling

2012-01-04 04:21:47

I'm currently working on a script that requires interaction with a NPC.

In order to reach the NPC, the bot must check if a door is open or not, also after talking to the NPC the bot must check the door again (to make sure its open) before attempting to leave the room.

I've tried using FindObjCustom but im really not having any luck.
So far I'm using this but its resulting in the mouse going crazy:

  If FindObjCustom(X, Y, ['Open'], [8832711], 3) Then
Mouse(X, Y, 1, 1, False);
WaitOption('Open', 1000);

Is there a function or easier way i can get it to check the door?
I can't isolate the area the bot searches because the NPC walks around and that might result in the bot isolating the wrong area.


Anyone run into this problem before / got a fix? lmk please :D

I'm off to work atm ill be back in a few hours, will post how i solved this if I figure it out after :)

ShawnjohnSJ

2012-01-04 04:23:44

I'm not one hundred percent on this, but are the Mouse and WaitOption procedure's both supposed to be inside the IF command? If so, you need a begin and end to group it together. Not sure if that'll solve your problem or not.

justleveling

2012-01-04 04:27:13

the idea i had was: (i think i failed to implement it)

if (search for door and Open door appears) then {
right click door
click open
} else {
(search for door and Close door appears) then {
do nothing
}

except the searching for door is failing really bad and I wanted to know if there's an easier way to check for the doors (and to see if there open) other then this?

Grihmm

2012-01-04 04:44:32

Make a bitmap of the door open and closed.
if DoorOpen then
blah blah

cause

2012-01-04 05:12:28

You're on the right track for sure.

 
If FindObjCustom(X, Y, ['pen'], [8832711], 3)
Then
begin
Mouse(X, Y, 1, 1, False);
end
else
WriteLn('door is open');

If you're going to use it as a function make sure you have it set Result := True in the begin end and Result := False in the else. But that should work for you, this is assuming you've already made sure you are where your supposed to be (aka it could not find the door but be in a totally different area and still debug you that the door is open :P )

justleveling

2012-01-04 05:40:15

From: Grihmm
Make a bitmap of the door open and closed.
if DoorOpen then
blah blah


No idea how to do this, ill look into it when i get home.


From: cause
You're on the right track for sure.

 
If FindObjCustom(X, Y, ['pen'], [8832711], 3)
Then
begin
Mouse(X, Y, 1, 1, False);
end
else
WriteLn('door is open');

If you're going to use it as a function make sure you have it set Result := True in the begin end and Result := False in the else. But that should work for you, this is assuming you've already made sure you are where your supposed to be (aka it could not find the door but be in a totally different area and still debug you that the door is open :P )


Is it normal for the mouse to go over half the brown things in the room before locating the door? (the room has a brown outline on the wall which matches the colour of the door lol)

Another thing I've noticed across several scripts is that you guys never use the first letter when searching for text (as you done in example), why is this?

Ill get back into working on this when i get home in 3 hours and post results if i make a break through :)

bg5

2012-01-04 06:08:43

Is it normal for the mouse to go over half the brown things in the room before locating the door? (the room has a brown outline on the wall which matches the colour of the door lol)


Yes ,it's normal. That's how this function work ,first it finds pixel of color you want ,second it move mouse to this point to read text in upper left corner. So it will hover all points until it find correct text.

To avoid this you can try to find color ,which specific only for doors ,decrease tolerance or make dtm.

Grihmm

2012-01-04 06:17:51

http://villavu.com/forum/showthread.php?t=58935

Look at this guide. Specifically, look at the if…then statements.

justleveling

2012-01-07 09:19:32

Thanks for your help everyone!

I figured out a temporary fix for the problem (to avoid the door all together) but sadly I'm not going through with this script because its a failed idea.. I left it running for a hour and realised it wasn't as profitable as I thought and there are plenty other ways which would be easier to make rsgp =[