SRL Archive - OSR Help

Checking if monster has spawned.


cool13bro

2012-03-11 18:31:07

So, I was working on a script again after quitting after I got frustrated, and I just can't figure out how to do it, spent hours looking through scripts and tuts for the solution (maybe I'm not looking at the right thing).

I need my mouse to wait for an npc to spawn and then attack, basically my mouse goes nuts looking everywhere for the npc color (using ACA) and doesn't wait for the monster to respawn. I posted a while ago about this, and I got replies saying to use waittimeuntil, or some command like that. I really couldn't figure it out. I really tried but failed.

Stuff i've done to fix the problem:
-put a delay in (really unefficient, sometimes goes on waiting even after the monster the spawn, sometimes clicks too early and then another wait)
-put a boolean statement to check if the monsters there. (way too inexperienced in simba to even get that functioning)

I have programmed in other languages, so even a little guidance may help, I'm just very new to simba.

Thanks.

cool13bro

2012-03-11 18:32:47

Sorry, realised afterwards i posted in wrong section (probably because my mind is fried). Any mod want to move it for me please. :)

x[Warrior]x3500

2012-03-11 18:38:24

i can help u over skype / team viewer if you want.

cool13bro

2012-03-11 18:41:06

ah, don't have either. I can post my noobish standard script here if you can help like that.

x[Warrior]x3500

2012-03-11 18:43:30

well the issue is that u are sorta vague. wat npc, where?

cool13bro

2012-03-11 18:45:47

Lesser Demon, Wizard's Tower. It's really a first script I thought would be easy to tackle.. it's not meant to really get stats or cash, just a practice script.

masterBB

2012-03-11 18:47:05

Just check for the yellow color on the minimap. If it appears in the cage. Then search for the npc on screen.

x[Warrior]x3500

2012-03-11 18:49:46

one sec, i am movin my character there :). i will update this post with a solution.

edit: yup do wat masterbb said. i would check for the yellow in the area below the character (mmcy(-5)->mmy2). then if you wanted u could also chekc the color of the demon with an atpa (with uptext).

edit2:

if(findcolortolerance(x,y,60899,mmx1,mmcy+5,mmx2,mmy2,5))then
writeln('demon found');

cool13bro

2012-03-11 18:59:07

I understand what you guys are saying. When looking for that yellow dot, wouldn't it get confused with the other wizard thats on the top floor. Not logged in atm so i dont know his name. Also how could i confine the color finder to only the minimap?

Just ask if you guys want me to post what I have so far

Sin

2012-03-11 19:03:28

Use my function, FindNearestNPC, it's in the snippets section.

cool13bro

2012-03-11 19:14:00

From: Sin
Use my function, FindNearestNPC, it's in the snippets section.


Wow, why has no one recommended this function to me.. Looks like exactly what I need. The only thing I'm unfamiliar with are the parameter of FindColorSpiralTolerance. You used it in your function and I'm assuming I might have to change the values (it's also helpful for the future).

Sin

2012-03-11 19:29:55

Nah don't change the parameters.


function FindNearestNPC(var x,y:Integer;Click,DoWait:Boolean):Boolean;
var
x,y:Integer;
begin
if FindColorSpiralTolerance(x,y,65536,558,6,690,153,4) then
begin
Result := True;
if (Click = True) and (Result = True) then
Mouse(x,y,1,1,True);
if DoWait = True then
begin
FFlag(1);
Wait(750 + random(200));
end;
end;
end;
function FindNearestNPC(var x,y:Integer;Click,DoWait:Boolean):Boolean;

x,y returns the values of the monster locations.
Click is a boolean(True/False) to click there
DoWait is another boolean which if clicked then will find the flag and wait until it walks there.

cool13bro

2012-03-11 23:06:02

I'm not sure I'm using it right. Would you be kind enough to break down the code, or explain to me how to implement this into my code. Sorry, really new to this.

Also, what is the keyboard key to stop a script? I forget now, and everytime I test this and the mouse fucks up, it always causes a problem.

Sin

2012-03-11 23:31:52

Basically -

Repeat
Wait(100)
Until(FindNearestNpc(x,y,False,False));