Replace an Item in a units inventory

Status
Not open for further replies.
Level 5
Joined
Jun 27, 2009
Messages
137
Ok, what I need help with is replacing an item in a heroes inventory without dropping the item. I need it to happen, also, once two buildings are destroyed. I think I know how to do this, but that requires me using variables, and I've never used them before. So if someone could either tell me how to do it without variables, or tell me how to create the variable, then with the trigger, that would really be most helpful.
 
  • Trigger
  • Events
    • Unit - A unit dies
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Dying unit) Equal to x
        • (Dying unit) Equal to y
  • Actions
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions), else do (Actions)
          • If (Conditions)
            • (Item-type of (Item carried by (your unit) in slot (IntegerA)) Equal to Z
          • Then (Actions)
            • Hero - Drop (Item carried by (your unit) of type X)
            • Hero - Create Item and give it to (your unit)
 
Level 10
Joined
Oct 22, 2006
Messages
599
1st. You don't need variables the way you described your problem.

2nd. Replace the "Hero - Drop item carried...." line with the following.
  • Item - Remove (Item carried by (Your Unit) in slot (Integer A))
@Dark_Axl
If the condition is set to "And" then it will check if the diying unit is (e.g.) a Farm And a Tower which can never be true. Using "Or" checks if the unit is one of those two which is what we want.
 
Level 5
Joined
Jun 27, 2009
Messages
137
Ok, I used that trigger, but for some reason, once both of the units are killed, it makes six of the items. I tried bringing the integer number to be 1 to 1, but it just won't make any at all, and still takes away the old item. I tried two, but it makes three of the items, one in the inventory, and two outside of it. Could someone please help?
 
Level 10
Joined
Oct 22, 2006
Messages
599
You probably messed up at something on this line (It's da Condition):
"(Item-type of (Item carried by (your unit) in slot (IntegerA)) Equal to Z"
So... check it. Did you make the change I mentioned above?

In case you try and at the end it won't work, you can upload your map to the Pastebin and post the link here so we can help you.
 
Status
Not open for further replies.
Top