• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Buying Items with Items

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
Buying Items with Items

I'm having a problem with this trigger where when the hero has the wrong amount of gold, it still gives the hero the item. The trick is that when i try to fix this by having the trigger subtract 1 from the charge count (its a stackable item) that if there is only one charge, it wont remove it. When I do and if/then/else to have it remove the item when there are multiple charges on the item and have it remove the item, it removes all charges as well. I tried making it so that if the charges count was less than or equal to 1, that it would remove the item but that didn't seem to work.

Here is the trigger below, please if anyone could help me fix this I will gladly put you in the credits!

  • Buy Deadly Trap
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Deadly Trap
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item-type of (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Wood)) Equal to Wood) and ((Charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Wood)) Greater than or equal to 15)
          • ((Item-type of (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Gold)) Equal to Gold) and ((Charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Gold)) Greater than or equal to 17)
        • Then - Actions
          • Item - Set charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Wood) to ((Charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Wood)) - 15)
          • Item - Set charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Gold) to ((Charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Gold)) - 17)
        • Else - Actions
          • Game - Display to (Player group((Owner of Players_Hero[(Player number of (Owner of (Buying unit)))]))) the text: You need more Resou...
          • Wait 0.01 game-time seconds
          • If (((Players_Hero[(Player number of (Owner of (Buying unit)))] has an item of type Deadly Trap) Equal to True) and ((Charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Deadly Trap)) Equal to 1)) then do (Item - Remove (Sold Item)) else do (Item - Set charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Deadly Trap) to ((Charges remaining in (Item carried by Players_Hero[(Player number of (Owner of (Buying unit)))] of type Deadly Trap)) - 1))
EDIT: Ok I fixed it. Maybe this post will at least help someone else who is trying something like this.
 
Last edited:
Status
Not open for further replies.
Top