• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Group Items in a radius around a point

Status
Not open for further replies.
Level 4
Joined
Mar 6, 2008
Messages
72
I'm trying to make a Radar-type spell that detects nearby items in fog of war. By detecting, it will periodically create a floating text in the fog visible to the Player with the spell.

However, I can only group items by region, which is a square. I would like to use a function similar to "Unit Groups Select all units around Radius" for items

Is there any way to group items in a circle?
 
Level 11
Joined
Jun 2, 2013
Messages
613
Maybe not in a circle without a bit of math, but you can possibly use something like this:

  • ItemsTrigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set CenterOfSpell = (Target point of ability being cast)
      • Set ItemRegion = (Region centered at CenterOfSpell with size (512.00, 512.00))
      • Item - Pick every item in ItemRegion and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • -------- Your Actions --------
            • Else - Actions
              • -------- Do Nothing --------
      • Custom script: call RemoveLocation(udg_CenterOfSpell)
      • Custom script: call RemoveRect(udg_ItemRegion)
CenterOfSpell is a Point Variable.
ItemRegion is a Region Variable. Set using: Conversion - Convert Point with Size To Region

Hope this helps :D
 
Remember you can always check for distance between locations.
Create a square based on your center of your location and take 2* radious as length.

I created an example, but in JASS, but if you are a bit familiar with triggers you should be able to understand the GUI friendly demo.
 

Attachments

  • Demo.w3x
    25.6 KB · Views: 36
Level 4
Joined
Mar 6, 2008
Messages
72
@PublishedShadow
This is my last resort method. I would prefer circles because I am also detecting a certain Unit-Type in the same radius as well with the Radar.
Thanks for the help though

@IcemanBo
That's right... I forgot that was a possibility. Just goes to show how experience helps with problem-solving

Thank you for going out of your way to create the trigger for me. It works great.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
If there are a lot of items in the radar area it runs the risk of hitting the floating text limit or causing frames to be dropped (multiple hundred items). Not that this will be a problem, but if it is you can stagger the results and tests by mapping all items into an array and testing only a few every "tick" with a couple of ticks a second. I would only recommend implementing this if you run into the mentioned problems.
 
Status
Not open for further replies.
Top