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

Item Disappears in Shop

Status
Not open for further replies.
Level 8
Joined
Jul 18, 2010
Messages
332
I have this item in my map which has a max stock of 5 and is placed in the shops in my map using triggers. I triggered them so that when it has no more stocks available it will just be removed in the shop. And when I trigger them they have 5 in stock and a max stock of 5. But how come when a hero buys the item even if it still has 5 stocks left, it disappears? I have a trigger which removes some items immediately on all shops when they are bought so no one can buy it again but this item that I'm talking about is not part of them. Anybody know why this happens?
 
Level 5
Joined
Oct 27, 2007
Messages
158
I have this item in my map which has a max stock of 5 and is placed in the shops in my map using triggers. I triggered them so that when it has no more stocks available it will just be removed in the shop. And when I trigger them they have 5 in stock and a max stock of 5. But how come when a hero buys the item even if it still has 5 stocks left, it disappears? I have a trigger which removes some items immediately on all shops when they are bought so no one can buy it again but this item that I'm talking about is not part of them. Anybody know why this happens?

Blizzard by default initializes marketplaces to remove an item from stock whenever a purchase for that item is made. It does not matter how many stock that particular item has at that time. The default behavior is that the default trigger assumes the stock is 1. In order to circumvent this you need to understand how Blizzard sets this up.

You can circumvent the item sell trigger by changing the player who owns the marketplace to something other than neutral passive. Changing the shop to anything else than a marketplace will not bypass this. The trigger is setup to trigger whenever an item is sold by a unit owned by player neutral passive. The other way (if you really need the owner to be neutral passive) is to disable the trigger by using custom script code in your trigger setup. Add the lines below to the action part of your trigger setup.

  • Custom script: call DestroyTrigger(bj_stockItemPurchased)
  • Custom script: set bj_stockItemPurchased = null
The trigger action can't be removed from memory since there's no reference with which we can remove it. So this will leak a trigger action. It's no big deal in this case. If you want to keep the trigger around simply disable it instead.

  • Custom script: call DisableTrigger(bj_stockItemPurchased)
Furthermore a timer is used to periodically update an item in all marketplaces that can interfere. By default the marketplace can generate items that are dropped by creeps. It updates the availability of a certain item type and ilvl when a unit intended to drop something drops a certain item. This behavior occurs when you setup loot tables in the map editor or use the jass function UnitDropItem directly. You can disable this behavior by using the following custom script code in your trigger setup.

  • Custom script: call PauseTimer(bj_stockUpdateTimer)
  • Custom script: call DestroyTimer(bj_stockUpdateTimer)
  • Custom script: set bj_stockUpdateTimer = null
The other option here is to use something else than a marketplace or use a custom unit based on the marketplace.
 
Level 8
Joined
Jul 18, 2010
Messages
332
My shop is based on goblin merchant. Is that the same as market place? This is my trigger by the way.
  • Neutral Building - Add Victor Jr. Pet Card to Limited Edition Pets 0123 <gen> with 5 in stock and a max stock of 5
  • Neutral Building - Add Victor Jr. Pet Card to Limited Edition Pets 0124 <gen> with 5 in stock and a max stock of 5
  • Quest - Display to (All players) the Quest Update message: |cff77bbffNew Pet: ...
 
Level 5
Joined
Oct 27, 2007
Messages
158
My shop is based on goblin merchant. Is that the same as market place? This is my trigger by the way.
  • Neutral Building - Add Victor Jr. Pet Card to Limited Edition Pets 0123 <gen> with 5 in stock and a max stock of 5
  • Neutral Building - Add Victor Jr. Pet Card to Limited Edition Pets 0124 <gen> with 5 in stock and a max stock of 5
  • Quest - Display to (All players) the Quest Update message: |cff77bbffNew Pet: ...

No, they're different. But all units owned by player neutral passive that can sell items are affected by the default sell trigger. If your Goblin Merchant shops are owned by player neutral passive you need to disable or destroy the trigger that is used by default when the shop sells an item. Alternatively you can change the owner of the shop to someone else than player neutral passive.

If you want the shops to be owned by player neutral passive then add this one custom script code line to your shop setup trigger actions to be able to override the default behavior when an item gets sold.

  • Custom script: call DisableTrigger(bj_stockItemPurchased)
 
Status
Not open for further replies.
Top