Mirco
2019-02-17 19:08:31
Hi all.
I have taken a script that my father created (a stall thieving script) and im trying to implement and create variables and a function which recognises an NPC and talks to them when they pop up ( sort of like a random event )
Please pm me if you have the time to help me out, thanks.
daileyj93
2019-02-18 09:01:55
Lipcot
2019-02-18 09:08:58
Does it have kind of unique colors? you could just make a function to search for the colors it has and every x amount of time check if he's around
Dan the man
2019-02-19 18:59:59
If you aren't using the SRL include, you could use a similar method that the SRL.DismissRandom() function uses.
The function searches for the overhead text that includes your display name, then uses the minimap to get the main screen point of the NPC. Instead of using the minimap (because that method is exclusive to SRL), you could use the overhead text to identify if a random is after you, then have a bank of NPC objects to search through (colours to identify them uniquely). The benefit of this is you aren't having to search every colour for every potential random event multiple times a minute, but rather relying on the common denominator: your screen name.
Mirco
2019-02-20 03:20:48
From: Dan the man
If you aren't using the SRL include, you could use a similar method that the SRL.DismissRandom() function uses.
The function searches for the overhead text that includes your display name, then uses the minimap to get the main screen point of the NPC. Instead of using the minimap (because that method is exclusive to SRL), you could use the overhead text to identify if a random is after you, then have a bank of NPC objects to search through (colours to identify them uniquely). The benefit of this is you aren't having to search every colour for every potential random event multiple times a minute, but rather relying on the common denominator: your screen name.
Hi dan, that's a great way of explaining it. thank you! Would you have any time spare to help me write it please? I could pay you!
Dan the man
2019-02-20 20:32:38
I don't have too much time unfortunately. That link to the SRL.DismissRandom that Dailey posted is a good guide to use. It shows you how to detect the overhead text, and colour finding should be simple enough for the randoms themselves.
You are welcome to post your script here or on Discord if you are having issues. Discord is a lot more active and a lot of people on there are very helpful.
daileyj93
2019-02-21 11:00:59
Also, the dismissRandom function I linked to previously detects the center point of the main-screen chat that has your name in it (line 223). If you move the mouse to a point about 20px below this, and the the upText says "Talk-to" then your mouse is most likely over the NPC. This way you could avoid trying to detect all the possible colors of the NPCs that might pop up. I have used this method reliably in crowded places like the Karamja fishing docks, because the yellow NPC dot does not always show up on top of the white player dots, which affects the reliability of the Minimap-to-Mainscreen method used in SRL's version of dismissRandom.