[Spell] Picking up an item with a spell.

Status
Not open for further replies.
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
 
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.
 
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.
 
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.
 
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.
Back
Top