• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] How to grab nearby item?

Status
Not open for further replies.
A whole functionating example with leak cleaning.
  • Grap Near Item
    • Events
      • Unit - A unit cast a spell
    • Conditions
      • (Ability being cast) Equal Grab Item
    • Actions
      • Set Loc = (Position of (Triggering unit))
      • -------- Beaware that, this is a/b's total edge length. Means has half range from the center. Here 300. --------
      • Set Rect = (Region centered at Loc with size (600.00, 600.00))
      • Set Item = (Random item in Rect)
      • Hero - Give Item to (Triggering unit)
      • Custom script: call RemoveLocation(udg_Loc)
      • Custom script: call RemoveRect(udg_Rect)
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
Random item in rect is a rectangular area to search for items.
As there is no items in range you need to use (items in region matching distance to grabbing unit less than ...) to have an items in range function.
You could also put the distance comparison within the picked items function and let it pick the closest item.
 
Status
Not open for further replies.
Top