wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-03-2010, 08:13 PM   #1
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default GetNearest

Requires: GroupUtils

GetNearest is a very simple library that allows you to find the nearest unit, destructable, or item to a specified point within a specified radius. You can use a boolexpr filter as well, just like native Enum functions.

I made this because the concept behind FindFuncs seemed useful. You can still find the nearest tree by using IsDestructableTree within a boolexpr.

GetNearestUnit can easily be recreated using PruneGroup, along with more generalized functionality. SortUtils should be used when actual sorting of units by values is required. This library is just meant to be small and easy to use.

Expand JASS:

Last edited by grim001 : 02-05-2010 at 03:41 AM.
grim001 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-04-2010, 03:00 PM   #2
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,727

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Isn't the Pow() function classically slower than just multiplying the numbers together? I seem to recall something like that. Anyways, this fixes most of the problems I had with Michael Peppers submission (lack of textmacros, etc). I can kind of see it being niche useful, but I'll let it sit here to get some more feedback before doing anything with it.
__________________
Rising_Dusk is offline   Reply With Quote
Old 02-04-2010, 03:07 PM   #3
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Yes, Pow is slower then a*a.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]

Last edited by Anachron : 02-04-2010 at 03:08 PM.
Anachron is offline   Reply With Quote
Old 02-04-2010, 03:53 PM   #4
Archmage Owenalacaster
Laughs Derisively
 
Archmage Owenalacaster's Avatar


Project Member: PoC
 
Join Date: Jun 2006
Posts: 649

Submissions (1)

Archmage Owenalacaster is a jewel in the rough (180)Archmage Owenalacaster is a jewel in the rough (180)Archmage Owenalacaster is a jewel in the rough (180)

Race-Building Contest #1 Winner

Default

When you resize the rect, shouldn't it account for the map boundaries? While this is never an issue for units and items, it is not uncommon for destructables to be placed beyond the playable map area.
__________________
I enjoy small text.
Resources: Custom Race System
JademusSreg.950, North American region on StarCraft 2
Archmage Owenalacaster is offline   Reply With Quote
Old 02-04-2010, 04:00 PM   #5
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Rising_Dusk
Isn't the Pow() function classically slower than just multiplying the numbers together?

Depends on a lot of factors, like whether you would have to declare extra locals, perform extra set operations or make extra native calls without using Pow. I guess I'll benchmark it because I'm curious.

Quote:
Originally Posted by Archmage Owenalacaster
When you resize the rect, shouldn't it account for the map boundaries? While this is never an issue for units and items, it is not uncommon for destructables to be placed beyond the playable map area.

As far as practical usage goes, I guess this is important. I'll make all the functions filter out stuff outside of map boundries.
grim001 is offline   Reply With Quote
Old 02-05-2010, 03:38 AM   #6
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

I did a benchmark comparing GetNearestDestructable using Pow versus multiplication in the enum. There were 100 trees within range of the enumeration, and the test was repeated 100,000 times. The benchmark showed that the multiplication version was 0.0697% slower, which is such a small difference that it amounts to noise. In this case I'm going to go with the one that looks better.

I also fixed a couple typos, optimized the code a bit, and made sure that none of the functions will return stuff outside the playable map area.
grim001 is offline   Reply With Quote
Old 02-05-2010, 02:09 PM   #7
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,074

Submissions (19)

Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)Anitarf has a brilliant future (884)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Well, in this case, using multiplication requires you to declare additional locals or do the x - GetUnitX(u) calculation twice, so using Pow likely is faster. Otherwise, I believe I've seen other people post test results where Pow(x,2) was slightly slower than x*x while Pow(x,3) was slightly faster than its multiplication counterpart.

Either way, as your test shows, the difference is inconsequential in the context of this function.
__________________
Anitarf is offline   Reply With Quote
Old 02-05-2010, 04:00 PM   #8
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,727

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

*Shrug* Don't need a benchmark and two posts to tell me so, it was just something that came to mind as a possible improvement. I can think of nothing else this really needs, so if it works as listed and no other reviewer can think of anything, we can approve it.
__________________
Rising_Dusk is offline   Reply With Quote
Old 02-21-2010, 06:27 PM   #9
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,727

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Going to go ahead and approve this, then.
__________________
Rising_Dusk is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 11:18 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services