• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[Item] Trigger Question

Status
Not open for further replies.
Level 6
Joined
Jan 9, 2009
Messages
236
How do you loot an item with a spell when it is within range?
  • health
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Loot
        • Then - Actions
        • Else - Actions
          • Do nothing
Whats next?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ItemRegion = (Region 000 <gen>)
  • Picking Items
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to *loot*
    • Actions
      • Set Point = (Position of (Picked unit))
      • Region - Center ItemRegion on Point
      • Item - Pick every item in ItemRegion and do (Actions)
        • Loop - Actions
          • Hero - Give (Picked item) to (Picked unit)
      • Custom script: call RemoveLocation(udg_Point)
 
Small mistake Maker, Triggering unit instead of Picked unit :D
However, isn't that better to temporary create region on given location and then destroy it?
Like:

  • Picking Items
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to *loot*
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Set ItemRegion = Region centered at Point with <your parameters lets say 200x200>
      • Item - Pick every item in ItemRegion and do (Actions)
        • Loop - Actions
          • Hero - Give (Picked item) to (Triggering unit)
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call DestroyRec(udg_ItemRegion)
 
Level 6
Joined
Jan 9, 2009
Messages
236
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ItemRegion = (Region 000 <gen>)
  • Picking Items
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to *loot*
    • Actions
      • Set Point = (Position of (Picked unit))
      • Region - Center ItemRegion on Point
      • Item - Pick every item in ItemRegion and do (Actions)
        • Loop - Actions
          • Hero - Give (Picked item) to (Picked unit)
      • Custom script: call RemoveLocation(udg_Point)

Thanks bro :D i just had to chang picked unit to triggering unit and it worked!
+rep
 
Status
Not open for further replies.
Top