SRL Archive - SRL Suggestions

Minimap Dot Finding Improvement


euphemism

2011-11-14 17:10:33

The dot-finding in SRL hasn't seemed to be working for me, so I wrote this to replace it. It doesn't have friend, team, or clan dots at the moment, but it appears to work very well.



E: Rewrote to provide backwards-compatibility with scripts using the current SRL functions. Supports NPCs, team capes, items, players, friends, and clan members. Team cape (blue) dots, and clan member (orange) dots remain untested; they should work, though. A random player in the game was nice enough to friend me so I could test the friend dot.

Note: I am using FindColorsPie inside GetMiniMapDotsIn because it is awfully convenient. Can I use other include functions like that? Also, FindColorsPie needs a center x and y, but GetMiniMapDotsIn doesn't have that, so I can't add parameters for the center x and y without breaking compatibility with current scripts. Thoughts?



{*******************************************************************************
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
By: euphemism
Description: Results the dots specified by WhatDot in the box x1, y1, x2, y2.
Usage : 'npc', 'yellow', 'n', 'y' : Yellow Dot;
'cape', 'blue', 'team', 't', 'b' : Blue Dot;
'item', 'red', 'i', 'r' : Red Dot;
'player', 'white', 'p', 'w' : White Dot;
'friend', 'green', 'f', 'g' : Green Dot;
*******************************************************************************}
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
DotColor, Radius: Integer;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': DotColor := 61937;
'item', 'i', 'red', 'r': DotColor := 237;
'player', 'p', 'white', 'w': DotColor := 15527148;
'friend', 'f', 'green', 'g': DotColor := 60160;
'team', 't', 'blue', 'b', 'cape': DotColor := 9917996;
'clan', 'c', 'orange', 'o': DotColor := 1604816;
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Radius := Max((x2-x1)/2, (y2-y1)/2);
FindColorsPie(Result, DotColor, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)/2, (y1+y2)/2);
RAaSTPAEx(Result, 1, 1);
end;

YoHoJo

2011-11-14 17:19:25

Wow, debug looks very spiffy looks to be working great, awesome.
What exactly did you change/do that wasn't in SRL?
I see you call FindMMDots doesn't that do all/most of the work, what was edited? Just curious.

euphemism

2011-11-14 17:33:34

From: YoHoJo
Wow, debug looks very spiffy looks to be working great, awesome.
What exactly did you change/do that wasn't in SRL?
I see you call FindMMDots doesn't that do all/most of the work, what was edited? Just curious.


How do you mean? I wrote the function FindMMDots; which, isn't quite like the GetMiniMapDotsIn in SRL.

grats

2011-11-14 17:34:13

From: YoHoJo
Wow, debug looks very spiffy looks to be working great, awesome.
What exactly did you change/do that wasn't in SRL?
I see you call FindMMDots doesn't that do all/most of the work, what was edited? Just curious.


he called it where? it looks like that's where it is written


edit, he logged in and beat me =[


good job though, the debug looks very clean and nice

YoHoJo

2011-11-14 17:35:44

Hurrr sorry I was retarded :D.
I see now, great job, love it, looks very nice!
Huh,that's cool how it even recognizes overlaps at two+ dots, nice!

grats

2011-11-14 17:41:39

yea, it gets those guys at the bank extremely well, I'm impressed
if I saw the screenshot without the code I'd think it was reflection

Coh3n

2011-11-14 18:11:51

What was wrong with the SRL one? Just curious.

Kyle Undefined

2011-11-14 18:25:19

Looks pretty good!

euphemism

2011-11-14 18:51:24

From: Coh3n
What was wrong with the SRL one? Just curious.


Probably nothing, but I could not get it to work.

KingKong

2011-11-14 20:31:38

From: euphemism
Probably nothing, but I could not get it to work.


It happened to me too, but now it works???

NCDS

2011-11-14 20:34:18

From: euphemism
Probably nothing, but I could not get it to work.


That's odd as the InRandom functions rely heavily on GetMinimapDotsEx, which is the 'base' function. If I have some time tonight I'll test them against each other. Or perhaps you may want to post the visual debug of each one to compare?

Coh3n

2011-11-14 21:35:24

From: euphemism
Probably nothing, but I could not get it to work.
I was hoping you'd expand on why it didn't work. Like did it give an error, did it just return no results? Too many? Not enough?

Method

2011-11-14 21:40:36

Here are the various dots, if you'd like to use them as a reference:

Item: Npc: Player: Friend: Teammate: Friend chat user: Clanmate: "P" symbol:
I'm not sure what exactly the last one is used for, if it's used at all, but it is in the game's cache.

euphemism

2011-11-14 21:42:26

From: Coh3n
I was hoping you'd expand on why it didn't work. Like did it give an error, did it just return no results? Too many? Not enough?


If I recall correctly, I tried finding item dots, and it missed one or two, and returned false positives via doors.

Edit: I couldn't recreate the false positives with the doors, but I have managed to show the GetMiniMapDotsIn function missing some dots that mine catches. Green dots are dots found by FindMMDots, and blue dots are dots found by GetMiniMapDotsIn. The blue flags indicate where GetMiniMapDotsIn failed to find a dot.

Test 1
Test 2
Test 3
Test 4

From: NCDS
That's odd as the InRandom functions rely heavily on GetMinimapDotsEx, which is the 'base' function. If I have some time tonight I'll test them against each other. Or perhaps you may want to post the visual debug of each one to compare?


If you will look at the post above this one, I ran a comparison test, and have shown four different instances where GetMiniMapDotsIn failed to find dots; however, I did notice that it appears to do just fine with the NPC dots, which I assume the InRandom functions look for?

Nava2

2011-11-15 19:50:45

Merged your double post!

Uhm, if you implement your system as the old is implemented, I would happily push this into SRL.

I like the results and I like what you've done.

Keep it up, friend. :)

euphemism

2011-11-15 21:55:23

From: Nava2
Merged your double post!

Uhm, if you implement your system as the old is implemented, I would happily push this into SRL.

I like the results and I like what you've done.

Keep it up, friend. :)


I wouldn't have double posted if I had gotten a reply to the thread in the last twenty-four hours. It was the only way I could think of bringing attention to the test I did. I apologize. I will fix it up so that it can be added.

Coh3n

2011-11-15 21:57:10

From: euphemism
I wouldn't have double posted if I had gotten a reply to the thread in the last twenty-four hours. It was the only way I could think of bringing attention to the test I did. I apologize. I will fix it up so that it can be added.
You can bump it by deleting your previous post and reposting if you wish.

Nava2

2011-11-15 22:20:45

From: Coh3n
You can bump it by deleting your previous post and reposting if you wish.


Not sure if non-junior members can delete posts!

But don't worry about it euphemism. Just mentioning it.

Yago

2011-11-15 22:27:47

From: Nava2
Not sure if non-junior members can delete posts!

But don't worry about it euphemism. Just mentioning it.


We can ;)

euphemism

2011-11-15 22:29:31

From: Nava2
Not sure if non-junior members can delete posts!

But don't worry about it euphemism. Just mentioning it.


Quick question, are you wanting me to change it so names and parameters are identical?

Coh3n

2011-11-15 22:41:34

From: euphemism
Quick question, are you wanting me to change it so names and parameters are identical?
Yes. In other words, so scripters using those procedures won't have to update their scripts. ;)

euphemism

2011-11-15 23:27:33

Updated first post with the re-written function.

Nava2

2011-11-16 00:02:05

Pushed.

https://github.com/SRL/SRL-5/commit/fb7e9e5ab60d44bebde36b0e9a02cb42306d7141

Thanks!

coh3n pushed it to SRL4!

euphemism

2011-11-16 00:07:29

From: Nava2
Pushed.

https://github.com/SRL/SRL-5/commit/fb7e9e5ab60d44bebde36b0e9a02cb42306d7141

Thanks!

coh3n pushed it to SRL4!


Lines 1146-1151 I think deal with removing the actual player's dot from the array? If that is the case, it isn't necessary, as this function doesn't find the player's own dot.

Nava2

2011-11-16 00:10:36

From: euphemism
Lines 1146-1151 I think deal with removing the actual player's dot from the array? If that is the case, it isn't necessary, as this function doesn't find the player's own dot.


It doesn't?

euphemism

2011-11-16 00:12:47

From: Nava2
It doesn't?


No, it doesn't. The color it looks for does not appear on the square in the middle of the minimap.