• 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.

[Trigger] Restricting purchases or refunding

Status
Not open for further replies.
Level 2
Joined
Nov 27, 2008
Messages
13
For my map I have 4 different types (weapon/armor/helm/trinket) of unique equipment, each of which has several pieces but only one piece of a type may be used at a time. I'm not allowing players to drop items and there will be none picked up, only buying and sell back to buy others. Preventing players from picking up another item of the same type is easy, but preventing them from wasting their gold by buying an item they can't use is giving me trouble. I developed a good way to check if they already have the same type and remove the item if they do, but they still lose the gold. I can't find any way to prevent them from buying or refund their gold if they do.

And I searched, but all I was able to find was triggers to prevent picking up items off the ground.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
The Thing you need is: Dummies.

You create several dummies, each one for one armor. Then you can get the unit type of the sold unit, and see if the player should not buy this armor.
You can give the gold back, that the player payed for the equipment like this, and all should be fine.

Things you need would be:

Unit Comparisson - Unit Type of (Sold Unit)
Unit Comparisson - Unit Type of (Buying Unit)
Item Type Comparisson - Item Type of (Item Being Manipulated)

Item Action (Remove Item) - Remove (Item Being Manipulated)
Player Action (Property) - Set (Owner of Buying Unit) Gold to (Owner of Buying Unit Gold + The Price of the Item)
 
Level 2
Joined
Nov 27, 2008
Messages
13
To get the gold cost, you could set the HP of each item to its gold cost, so you can get it by trigger

Yup I noticed. I ended up just using a variable to track what gold each player is SUPPOSED to have, and then when they make a purchase if it's not allowed it resets their gold to the variable or updates the variable to their new total when the purchase is allowed.
 
Status
Not open for further replies.
Top