• 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.

[Spell] Picking up an item with a spell.

Status
Not open for further replies.
Level 30
Joined
Nov 29, 2012
Messages
6,637
Auto Pickup

Refer yourself at last post of this thread and there it is, just change the distance to 200.

EDIT: Ok got it wrong.... well, try to make first your ability targetable to items then when ability is being cast equal to your abiliy or spell, then check in conditions maybe if type target is item then order it to pick it up. Something like that?

ALso set maybe in conditions if the distance is 200 as what you said
 
Level 5
Joined
Feb 22, 2013
Messages
161
Event Spell effect
Cond your ability
Action
Give (random item within 200 range of triggering unit) to triggering unit

I am on a phone so only pseudo code is available.

It doesn't list an option for an item within range I don't think. Only within a certain region.
 
Level 7
Joined
Sep 8, 2011
Messages
211
An action like "Give (random item within 200 range of triggering unit) to triggering unit" doesn't exist, only give random item in region.

Hm I could do it that way, but considering the player will be in first person it is a little fiddly targeting an item.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Okay. I knew that GUI wouldn't be so convenient :/

Here is a JASS method. Create a 200x200 rect at map init. At spell cast move the rect to the caster's pos. Enum the items in the rect and add them to an item array. Pick a random integer between 0 and max index and give that item in that index to the unit.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Okay here are the custom scripts. You will need a rect variable for this. It will be called Rect

Event Spell effect
Cond your ability
Action
  • Custom script: local unit u = GetTriggerUnit ()
  • Custom script: if udg_Rect == null then
  • Custom script: set udg_Rect = Rect (0, 0, 200, 200)
  • Custom script: endif
  • Custom script: call MoveRectTo (udg_Rect, GetUnitX (u), GetUnitY (u))
  • Custom script: call UnitAddItem (u, RandomItemInRectSimpleBJ (udg_Rect))
  • Custom script: set u = null
 
Last edited:
Status
Not open for further replies.
Top