• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Giving items to Units

Status
Not open for further replies.
Level 1
Joined
May 9, 2005
Messages
3
I cannot figure out how to give items to a unit with inventory, not a hero. Because there is no trigger that I know of for giving a unit an item.

What i want to do is when a unit is created it is given an item that would be created once it finished its training
 
Level 4
Joined
Jan 3, 2005
Messages
91
1) just try using the hero triggers, i think it should work anyways.

2) after creating a unit, create the item next to that unit and then order your created unit to "rightclick" on the item.
success,

klovadis

[Edit: Dont forget to give "itembags" ability to your units first]
 
Level 4
Joined
Jan 9, 2005
Messages
106
yes whatever unit you are trying to give the items to has to have an inventory, once you have set that in the object editor then make a trigger something like this:

  • event
    Unit - A Unit Finishes training a unit
    Condition
    //if there is no specific unit then dont specify the unit here, if there is only a specific unit trained you want to have the item then:
    (unit trained) is equal to (IGetTheItems)
    Action
    Hero - Create "Item for the Unit" and give it to (trained unit)

remember you can always specify for special units with the "action" "if/then/else" string (if unit one then item 1, if unit 2 then item 2)

hope this helps :)
 
Level 5
Joined
Jul 20, 2004
Messages
156
First in the Object Editor you would give your unit an inventory at the top where it says "Abilities".

Then create your trigger and after it says "Unit - Create 1 (your unit)" add Set DropUnit for Last created unit. Then whenever you want the item dropped on your unit, you would do the following trigger. But just to get this right, you said that once a unit finishes training, you wanted the item dropped on the unit. So:

Events
Unit - A unit finishes construction

Conditions
Unit - Trained unit equal to (your unit)

Actions
Unit - Create 1 DropItemDummy
Unit - Set expiration timer on Last created unit to 1.00 seconds
Item - Create (your item) at position of DropItemDummy
Set ItemDropped to Last dropped item
Unit - Order DropItemDummy to right-click ItemDropped
Unit - Order DropItemDummy to drop ItemDropped on (your unit)

Have fun!

Edit: I had started writing this before someone else had posted... but I had to go somewhere so I couldn't finish. Anyway, I hope that this can still help you.
 
Status
Not open for further replies.
Top