HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

I need help with adding a unit to a variable.

02-28-2010, 10:14 AM#1
ray_sloth
I honestly have no idea how this question is posed, but I'm trying to create an item and give it to a specific hero unit upon the hero unit's creation. If I wanted to assign this specific unit to a variable, how the heck do I do that? alot of the tutorials that I've stumbled across on google have simply told me "Just add the unit to the variable.".

I suppose this is two questions in one thread.

Question one: How do you assign a unit that hasn't been added to the map (I mean physically placed there.)

Question two: Is there an easier way to do this outside of triggers


Little frustrated cause google sucks at finding a decent tutorial (found a bunch of world of warcraft websites) and the methods I've tried for the past two days straight haven't worked. (my eyes hurt)
02-28-2010, 12:22 PM#2
Anitarf
First, create the unit.
Then, set the variable to "last crated unit".
02-28-2010, 01:27 PM#3
ray_sloth
thanks so much for the answer!

Errrr, wait a moment, are you asking me to create a unit through a trigger?

I already have the unit created in the object editor. It's purchasable from a... shop/thing.







Argh!!! My brain is fried! I keep hitting the "Add Reply" button when I finish my post edit!!!!



edit: Anitarf, where'd you goooooooooooooooooooooooooooooooooooooooooooooo?! ;_;
02-28-2010, 03:22 PM#4
Deaod
Theres an event called "A Unit sells a unit". Just fiddle with that. From what i gathered you dont even need a variable.
02-28-2010, 03:56 PM#5
ray_sloth
Oh cool, thank you Deaod for that info. I did a search based off of that and it turns out I can associate that event with a condition of "Unit - type of (selling unit)) Equal to Mygivenbuildingthatcreatestheunit"

Cheers.

Gonna test it right now.


edit: I tested the aforementioned event and condition with the action: Hero - create specifieditem and give it to (Last created unit)

and it didn't work. I tried a few other combinations of events/conditions/actions, but they gave the same result which was the inventory staying empty for the hero upon creation.

edit: I guess a temporary fix would be to give the hero the items after it learns it's first spell. *shrug*, i'll keep messing with this world editor. Thank you so much for this info.
02-28-2010, 06:43 PM#6
Anopob
Last created unit is only for a unit that's actually CREATED through triggers.

Since your event is about a unit selling another unit, to reference the unit being purchased (aka the mercenary/hero), use "Sold Unit".
02-28-2010, 09:07 PM#7
ray_sloth
Yay! It worked, thank you for the info Anopob!