• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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)
 
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.
Back
Top