• 🏆 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] Modify item sold/made stock

Hello,

My context :
I got a player-controlled building selling items like the melee race shop.
I want to manipulate the building item stock, add or reduce the stock amount.

I've seen some native such as AddItemToStock, but I couldn't make it work.

Question: Is this possible with player building or does this only work with neutral merchant?
 
Level 13
Joined
Dec 20, 2012
Messages
154
I am doing something similar in my altered melee map The Bandit's Crucible.


Your custom shop also needs the Sell Items ability in order for Neutral Building - Add/Remove Item-Type (From Marketplace) to work.

Under Techtree - Items Made of your shop should contains only items that you want the shop to always have like Scroll of Town Portal, Tome of Retraining, etc.

My custom item shop
Upon finishing building a Black Market, starts with an additional random set of items. The item pool refresh randomly from a range between 220-300 seconds with 60% chance for a new set of items.

  • Bandit Market Add Item Pool
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Black Market (Arcane Vault)
    • Actions
      • Set TempUnit = (Constructed structure)
      • Unit Group - Add TempUnit to TempBlackMarketItemPool
      • Unit Group - Pick every unit in TempBlackMarketItemPool and do (Actions)
        • Loop - Actions
          • Set TempUnit = No unit
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set TempInt2 = (Random integer number between 1 and 100)
              • Neutral Building - Remove Scroll of Regeneration from (Picked unit)
              • Neutral Building - Remove Spider Silk Broach from (Picked unit)
              • Neutral Building - Remove Healing Salve from (Picked unit)
              • Neutral Building - Remove Wand of Illusion from (Picked unit)
              • Neutral Building - Remove Scroll of Mana from (Picked unit)
              • Neutral Building - Remove Sentry Wards from (Picked unit)
              • Neutral Building - Remove Vampiric Potion from (Picked unit)
              • Neutral Building - Remove Lesser Replenishment Potion from (Picked unit)
              • Neutral Building - Remove Wand of Mana Stealing from (Picked unit)
              • -------- Give a 20% chance for item variation 1. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 20
                • Then - Actions
                  • Neutral Building - Add Scroll of Regeneration to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Spider Silk Broach to (Picked unit) with 2 in stock and a max stock of 2
                • Else - Actions
              • -------- Give a 20% chance for item variation 2. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 40
                  • TempInt2 Greater than 20
                • Then - Actions
                  • Neutral Building - Add Healing Salve to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Wand of Illusion to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • -------- Give a 20% chance for item variation 3. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 60
                  • TempInt2 Greater than 40
                • Then - Actions
                  • Neutral Building - Add Scroll of Mana to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Sentry Wards to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • -------- Give a 20% chance for item variation 4. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 80
                  • TempInt2 Greater than 60
                • Then - Actions
                  • Neutral Building - Add Vampiric Potion to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Lesser Replenishment Potion to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • -------- Give a 20% chance for item variation 5. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 100
                  • TempInt2 Greater than 80
                • Then - Actions
                  • Neutral Building - Add Wand of Mana Stealing to (Picked unit) with 1 in stock and a max stock of 1
                  • Neutral Building - Add Lesser Replenishment Potion to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • Unit Group - Remove (Picked unit) from TempBlackMarketItemPool
            • Else - Actions
  • Bandit Market Item Pool
    • Events
      • Time - Every (Random real number between 220.00 and 300.00) seconds of game time
    • Conditions
    • Actions
      • Set TempBlackMarketItemPool = (Units of type Black Market (Arcane Vault))
      • Unit Group - Pick every unit in TempBlackMarketItemPool and do (Actions)
        • Loop - Actions
          • Set TempInt = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • TempInt Less than or equal to 60
            • Then - Actions
              • Set TempInt2 = (Random integer number between 1 and 100)
              • Neutral Building - Remove Scroll of Regeneration from (Picked unit)
              • Neutral Building - Remove Spider Silk Broach from (Picked unit)
              • Neutral Building - Remove Healing Salve from (Picked unit)
              • Neutral Building - Remove Wand of Illusion from (Picked unit)
              • Neutral Building - Remove Scroll of Mana from (Picked unit)
              • Neutral Building - Remove Sentry Wards from (Picked unit)
              • Neutral Building - Remove Vampiric Potion from (Picked unit)
              • Neutral Building - Remove Lesser Replenishment Potion from (Picked unit)
              • Neutral Building - Remove Wand of Mana Stealing from (Picked unit)
              • -------- Give a 20% chance for item variation 1. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 20
                • Then - Actions
                  • Neutral Building - Add Scroll of Regeneration to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Spider Silk Broach to (Picked unit) with 2 in stock and a max stock of 2
                • Else - Actions
              • -------- Give a 20% chance for item variation 2. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 40
                  • TempInt2 Greater than 20
                • Then - Actions
                  • Neutral Building - Add Healing Salve to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Wand of Illusion to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • -------- Give a 20% chance for item variation 3. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 60
                  • TempInt2 Greater than 40
                • Then - Actions
                  • Neutral Building - Add Scroll of Mana to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Sentry Wards to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • -------- Give a 20% chance for item variation 4. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 80
                  • TempInt2 Greater than 60
                • Then - Actions
                  • Neutral Building - Add Vampiric Potion to (Picked unit) with 2 in stock and a max stock of 2
                  • Neutral Building - Add Lesser Replenishment Potion to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • -------- Give a 20% chance for item variation 5. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInt2 Less than or equal to 100
                  • TempInt2 Greater than 80
                • Then - Actions
                  • Neutral Building - Add Wand of Mana Stealing to (Picked unit) with 1 in stock and a max stock of 1
                  • Neutral Building - Add Lesser Replenishment Potion to (Picked unit) with 1 in stock and a max stock of 1
                • Else - Actions
              • Floating Text - Create floating text that reads New items have arri... above (Picked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Show (Last created floating text) for (All allies of (Owner of (Picked unit)))
              • Floating Text - Hide (Last created floating text) for (All enemies of (Owner of (Picked unit)))
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempBlackMarketItemPool)

Free free to check my map in world editor or Hive's preview triggers.
 
Level 18
Joined
Mar 16, 2008
Messages
721
There is a difference between "shops" vs "marketplaces." There is a thread somewhere on Hive about this but I can't find it.

The stock settings will affect shops,
but the triggers do not affect shops.
You can't add items to shops with triggers - only marketplaces.

If you want to manipulate the stock of an item sold in a shop then you need to edit that item's stock settings in Object Editor.

What Chaosium said applies to marketplaces.
What Flek said about abilities applies to both and the 2nd part appplies to shops only.

There might be a better way but this is my understanding.
 
Thank you for the answers, I managed to accomplish my idea.
I wanted to have some kind of shared stock for different items. See linked gif.
23-09-12-18-19-49.gif
d stock for
 
Level 20
Joined
Feb 27, 2019
Messages
592
Adding an item to a marketplace with -1 in stock will display 0 and hide the stock replenish interval if that is something youre interested in.
 
Top