• 🏆 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!

Buying An Item (Hero Only, Not Units)

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
Usualy only heroes can bought items, unless those units have the stash ability in their inventory, anyway you can disable that in the object editor (Shop) and change his ability to select unit
Normal units (if un-edited) have "Unit Inventory (Race)", it just has to be researched at the main hall for your race. If you want to make it really easy just remove the units ability to have an inventory.

Here is how to refund your item and remove it. You'll have to store the item-type's into an array variable, and store the item's cost into an integer variable. And last make an integer variable, then set it to how many items you have stored.
NOTE: Make sure both arrays have the same number for a single item, like the trigger below.
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Stored_Item[1] = Potion of Mana
      • Set Item_Cost[1] = 200
      • Set Stored_Item[2] = Potion of Healing
      • Set Item_Cost[2] = 150
      • Set Stored_Item[3] = Orb of Fire
      • Set Item_Cost[3] = 400
      • Set Stored_Item_Count = 3
This second trigger will remove the item from the unit and refund your gold. If you need it to take lumber just add that below the gold. This checks to see if the item it picked up is one of the stored item's you have already set, and if so, removes the item and refunds you.
  • Untitled Trigger 002
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
    • Actions
      • For each (Integer Temp_Integer) from 1 to Stored_Item_Count, do (Actions)
        • Loop - Actions
          • Set Temp_Item = (Item being manipulated)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of Temp_Item) Equal to Stored_Item[Temp_Integer]
            • Then - Actions
              • Item - Remove Temp_Item
              • Player - Add Item_Cost[Temp_Integer] to (Owner of (Triggering unit)) Current gold
            • Else - Actions
 
Status
Not open for further replies.
Top