HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Refreshing item in shop

09-14-2003, 09:06 AM#1
Blo0d-Angel
Can you make an item that is out of stock instantly become in-stock because of an event? If so please tell me how. Thanks
09-14-2003, 07:48 PM#2
Blo0d-Angel
Bump. Anyone?
09-15-2003, 05:13 AM#3
Desolate
I'm assuming you want the item to be out of stock until an event happens in the game to make it available for sale?

What you need to do is give the shop the "Sell Items" ability. Don't add the item to the shop unit's "Items Sold" attribute in the Unit Editor yet--we're going to do this through triggers.

The first trigger we need is one that will add the item to the shop, but with a max stock of 0 so that it can't be purchased yet.
Events
- Map initialization
Actions
- Neutral Building - Add [your item] to [your shop] with 0 in stock and a max stock of 0

Then, for the trigger that you want to make the item go on sale, add the action:
Actions
- Neutral Building - Add [your item] to [your shop] with 1 in stock and a max stock of 1
09-15-2003, 06:14 AM#4
Blo0d-Angel
Here is how I need it to work specifically. I want only 3 items of a type to be in play at any one time so I set the stock max to 3 in the editor and give it to the shop in the editor It regenerates so slow that it might as well not be regenerating at all. Every time a unit purchases it it increments a variable that keeps track of how many are in play. If there are 2 in play and one item is used so it is no longer in play I want the shop it have 2 items available for sail. If there are 3 in play there should be no items and each time an item expires a new one appears in shop. Is what I want to do feasible and if so can you give me trigs for it?
09-15-2003, 06:35 PM#5
BadRegistration
You can manipulate the items available in a shop if it is a Marketplace. Follow the first part of Desolate's advice and set up a shop that has "Sell Items".

For what you are looking to accomplish, set up a variable to keep track of the number of times the item has been sold, and set up triggers that go something like this:

Trigger the First
Event:
Elapsed time = .01 seconds
Condition:
None
Action:
Neutral Building - Add item type <the 3-of-a-kind item you desire> to <the building that will sell it> with an initial stock of 1 and a max stock of 1

Second Trigger
Event:
A unit sells an item
Condition:
Selling unit = Whatever shop is selling this 3-of-a-kind item
Actions:
Neutral Building - Remove item type of <the 3-of-a-kinder>
Set <variable that keeps track>=(<variable that keeps track> +1)
If <variable that keeps track> is less than 3 then Neutral Building - Add item type of <that 3-of-a-kinder> with 1 in stock and a max stock value of 1, else do nothing

In this way, when the map starts, that shop starts with 1 of that item. Every time the item is sold, it removes it from stock, BUT if only 2 or less have been sold, it will replace it with another of the desired item. Once three have been sold, it will not replace, the trigger cannot be fired again, and life is good.

Things to consider are making the limited-edition item unpawnable, and undroppable, and adding another trigger to keep 1 guy from hordeing all of this item. But that depends on the map, and what it's all about.

[edit] You could probably also do this without a variable, using an integer comparison of Trigger Evaluation or Trigger Execution count, but honestly I've never used this function, so I'm not sure which is more appropriate.
09-15-2003, 08:04 PM#6
Blo0d-Angel
Ok cool bad. I think my problem was having the item in the shop to begin with instead of adding it with a trig. Also my shop has the ability other than sell item...I forget it's name but it's what seems to be givin to the neutral shops in the game.
09-15-2003, 09:47 PM#7
BadRegistration
I'm not sure if that will cause a problem, but I doubt it. Yes, if you had the item there to begin with, you can't remove it via triggers (to my knowledge).