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

[General] Items being bought with different forms of currency?

Status
Not open for further replies.
Level 2
Joined
Aug 24, 2011
Messages
14
This is probably simple to some of you, but I can't quite figure out this on my own.

How do you buy an item from a shop, using (lets say for my purposes) a gem?
You have the gem in your inventory, and you want to buy an awesomely-uber-cool weapon only exchangeable through gems.

And for those really smart, how about you want to buy an overlyexcessivedescriptiveword piece of armor, only exchangeable through two types of gems, say an opal and a topaz.

Regards.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Triggering:

  • Trigger
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to (your item)
    • Actions
      • Set tempUnit = (Buying unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempUnit has an item of type Gem) Equal to False
        • Then - Actions
          • Item - Remove (Sold Item)
        • Else - Actions
          • Item - Remove (Item carried by tempUnit of type Gem)
And for the item that requires 2 gems:

  • Trigger
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to (your item)
    • Actions
      • Set tempUnit = (Buying unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempUnit has an item of type Gem) Equal to False
        • Then - Actions
          • Item - Remove (Sold Item)
        • Else - Actions
          • Item - Remove (Item carried by tempUnit of type Gem)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (tempUnit has an item of type Gem) Equal to True
            • Then - Actions
              • Item - Remove (Item carried by tempUnit of type Gem)
            • Else - Actions
              • Hero - Create (your item) and give it to tempUnit
 
Level 2
Joined
Aug 24, 2011
Messages
14
Wow, thank you very very much. I have one more question if you don't mind, what should I classify the items that are bought with gems as? Because I don't want it to be bought with gold whatsoever, or even have the option of being bought with gold.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
@Bean
If you need 2 gems, why don't you use ItemCounter of Integer variable ?
By looping each slot in the inventory of the unit, you can retrieve how many Gems the unit has.
What if the item needs 3 gems instead ?

I'm quite unsure on your approach, and I'm not saying yours is wrong.
Maybe because you have a different approach, just curious.
 
Status
Not open for further replies.
Top