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

[Solved] Weird bug when try to buy items from shop. It is bit of long.

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,139
Hello everyone. I have a system called Team Points. Team Point is the common point that can be used for various upgrades for the team.
For the create this system, first i have created shops, items and this trigger.

Players can be use these upgrade only once, so it can be removed from the shop when it's used (IF THEY HAVE THE REQUIRED TEAM POINTS)

Armor Upgrade
Hit Point Upgrade
Tower Upgrade
Slayer Upgrade
Guardian Upgrade
Guardian Transfer

And these upgrades can be used many times. These upgrades should not be removed from the shop.

Creep Upgrade
Rock
Ogre Mauler
Infernal



  • LichDukkan
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- devil shoplar --------
      • Neutral Building - Add Dragons to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Armor Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Creep Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Hit Point Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Tower Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Slayer Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Guardian Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Guardian Transfer to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Rock to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Ogre Mauler to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Infernal to Lich 0086 <gen> with 1 in stock and a max stock of 1
      • -------- reaper shoplar --------
      • Neutral Building - Add Dragons to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Armor Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Creep Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Hit Point Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Tower Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Slayer Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Guardian Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Guardian Transfer to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Rock to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Ogre Mauler to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Neutral Building - Add Infernal to Lich 0078 <gen> with 1 in stock and a max stock of 1
This trigger adds upgrades to the both liches. Any of the players are able to use these upgrades. My problem is, some of the upgrades "REMOVES" from the shop when we try to use these items when we don't have sufficient team points.

Here is the example.

  • Defense Upgrade
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Armor Upgrade
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Buying unit)) is an ally of ClanDevilPlayer) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[1] Greater than or equal to 500
              • (Current research level of Defense Upgrade Devil for ClanDevilPlayer) Less than ((Max research level of Defense Upgrade Devil for ClanDevilPlayer) - 1)
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[1] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[1]))) using font size 10.00
              • Player - Set the current research level of Defense Upgrade Devil to ((Current research level of Defense Upgrade Devil for ClanDevilPlayer) + 1) for ClanDevilPlayer
              • Set StringTeamPoint[1] = (StringTeamPoint[1] - 500)
            • Else - Actions
              • Neutral Building - Add Armor Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[2] Greater than or equal to 500
              • (Current research level of Defense Upgrade Reaper for ClanReaperPlayer) Less than ((Max research level of Defense Upgrade Reaper for ClanReaperPlayer) - 1)
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[2] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[2]))) using font size 10.00
              • Player - Set the current research level of Defense Upgrade Reaper to ((Current research level of Defense Upgrade Reaper for ClanReaperPlayer) + 1) for ClanReaperPlayer
              • Set StringTeamPoint[2] = (StringTeamPoint[2] - 500)
            • Else - Actions
              • Neutral Building - Add Armor Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Trigger - Run Table Update Lumbers <gen> (ignoring conditions)
When you but this upgrade when your Team Point is 500 or more, it has to remove from the shop and add upgrade.
If you don't have the specific Team Points, it will re-add this item to the shop again.


Additionally i have a several upgrades can be used more than one.

  • Creep Upgrade
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Creep Upgrade
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Buying unit)) is an ally of ClanDevilPlayer) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[1] Greater than or equal to 200
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[1] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[1]))) using font size 10.00
              • Player - Set the current research level of Creep Upgrade orta devil to ((Current research level of Creep Upgrade orta devil for ClanDevilPlayer) + 1) for ClanDevilPlayer
              • Player - Set the current research level of Creep Upgrade alt devil to ((Current research level of Creep Upgrade alt devil for ClanDevilPlayer) + 1) for ClanDevilPlayer
              • Player - Set the current research level of Creep Upgrade ust devil to ((Current research level of Creep Upgrade ust devil for ClanDevilPlayer) + 1) for ClanDevilPlayer
              • Set StringTeamPoint[1] = (StringTeamPoint[1] - 200)
              • Neutral Building - Add Creep Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
            • Else - Actions
              • Neutral Building - Add Creep Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[2] Greater than or equal to 200
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[2] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[2]))) using font size 10.00
              • Player - Set the current research level of Creep Upgrade alt reaper to ((Current research level of Creep Upgrade alt reaper for ClanReaperPlayer) + 1) for ClanReaperPlayer
              • Player - Set the current research level of Creep Upgrade ust reaper to ((Current research level of Creep Upgrade ust reaper for ClanReaperPlayer) + 1) for ClanReaperPlayer
              • Player - Set the current research level of Creep Upgrade orta reaper to ((Current research level of Creep Upgrade orta reaper for ClanReaperPlayer) + 1) for ClanReaperPlayer
              • Set StringTeamPoint[2] = (StringTeamPoint[2] - 200)
              • Neutral Building - Add Creep Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
            • Else - Actions
              • Neutral Building - Add Creep Upgrade to Lich 0078 <gen> with 1 in stock and a max stock of 1
      • Trigger - Run Table Update Lumbers <gen> (ignoring conditions)
For example i am going to the test now. When i click to the armor upgrade, one of the items from the shop REMOVED from the shop.
On secondary click nothing happend.
After this point, one of the items removes from the shop when everytime i have click on the armor upgrade.

It is complicated, i don't know how to explain. Just ask me for any details you want to learn.

This is how my system works.

When you click on the Creep Upgrade game checks Team Point (integer) value. When you have the required teampoint, it will add this upgrade into the shop again.
But many of the upgrades can be used only once. When you click on the Hit Point Upgrade when you have 600 Team Points, it will apply upgrade and removes the item from shop. But if you don't have required Team Points, game should add this upgrade again into the shop.

--- WHY I FEEL I NEED TO MANUALLY ADD AND REMOVE ITEMS TO THE SHOP ---

When i will add these upgrades as standard items, there are no way to check this >>> If the Team Point value lesser or equal to X, DO NOT BUY ITEM.

When you click the item, it simply checks your gold and lumber. If you have required lumber or gold, you can buy it. If you don't, you cannot. This is why i have created my own buy system.


I do not have to remove and add items. You can suggest different solution if you want.


This is the trigger of clicked item. (CHECK ATTACHMENT)

  • Slayer Upgrade Copy
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Slayer Upgrade
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Buying unit)) is an ally of ClanDevilPlayer) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[1] Greater than or equal to 300
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[1] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[1]))) using font size 10.00
              • Player - Set the current research level of Hero Slayers Upgrade Devil to ((Current research level of Hero Slayers Upgrade Devil for ClanDevilPlayer) + 1) for ClanDevilPlayer
              • Set StringTeamPoint[1] = (StringTeamPoint[1] - 300)
              • Neutral Building - Remove Slayer Upgrade from Lich 0086 <gen>
            • Else - Actions
              • Neutral Building - Add Slayer Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
              • Game - Display to (Player group((Triggering player))) the text: Bunun için yeterli...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[2] Greater than or equal to 300
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[2] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[2]))) using font size 10.00
              • Player - Set the current research level of Hero Slayers Upgrade Reaper to ((Current research level of Hero Slayers Upgrade Reaper for ClanReaperPlayer) + 1) for ClanReaperPlayer
              • Set StringTeamPoint[2] = (StringTeamPoint[2] - 300)
              • Neutral Building - Remove Slayer Upgrade from Lich2 0105 <gen>
            • Else - Actions
              • Neutral Building - Add Slayer Upgrade to Lich2 0105 <gen> with 1 in stock and a max stock of 1
              • Game - Display to (Player group((Triggering player))) the text: Bunun için yeterli...
      • Trigger - Run Table Update Lumbers <gen> (ignoring conditions)
This is the trigger of removed item. (CHECK ATTACHMENT)

  • Dragons
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Dragons
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Buying unit)) is an ally of ClanDevilPlayer) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[1] Greater than or equal to 300
            • Then - Actions
              • Set TP_EjderDevil = True
              • Floating Text - Change text of FloatTeamPoints[1] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[1]))) using font size 10.00
              • Set StringTeamPoint[1] = (StringTeamPoint[1] - 300)
            • Else - Actions
              • Neutral Building - Add Dragons to Lich 0086 <gen> with 1 in stock and a max stock of 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[2] Greater than or equal to 300
            • Then - Actions
              • Set TP_EjderReaper = True
              • Floating Text - Change text of FloatTeamPoints[2] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[2]))) using font size 10.00
              • Set StringTeamPoint[2] = (StringTeamPoint[2] - 300)
            • Else - Actions
              • Neutral Building - Add Dragons to Lich2 0105 <gen> with 1 in stock and a max stock of 1
      • Trigger - Run Table Update Lumbers <gen> (ignoring conditions)
And additionally i have shrinked and added map for the testing purpose. You can download the map and see what happens when you try to buy items.
 

Attachments

  • annen.png
    annen.png
    375.9 KB · Views: 6
  • ayritest.w3x
    201.3 KB · Views: 5
Last edited:
Level 18
Joined
Oct 17, 2012
Messages
821
The trigger below will stop items that are added to shops via trigger from disappearing after purchasing them.
  • Shop Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call PauseTimer(bj_stockUpdateTimer)
      • Custom script: call DisableTrigger(bj_stockItemPurchased)
 
Level 17
Joined
Jun 2, 2009
Messages
1,139
I recall there being some issues/jank/limitations with modifying marketplace sold items.

Try making these abilities instead, which are not automatically removed on use. Might need to give each player their own shop dummy then.
Do i need to duplicate 1 shop into 10 shops? Is there no other way to do that?
The trigger below will stop items that are added to shops via trigger from disappearing after purchasing them.
  • Shop Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call PauseTimer(bj_stockUpdateTimer)
      • Custom script: call DisableTrigger(bj_stockItemPurchased)
But some of the upgrades can be used many times, some of them are not. By the way can you check the post again? I have updated and added additional information at the bottom.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
Do i need to duplicate 1 shop into 10 shops? Is there no other way to do that?
As long as the shops are invulnerable and can't be targeted with abilities then you could probably create them all on the same location with a trigger and then locally hide 9 of the 10 for each player so they only see 1. Might be safe from a desync.
 
Level 17
Joined
Jun 2, 2009
Messages
1,139
As long as the shops are invulnerable and can't be targeted with abilities then you could probably create them all on the same location with a trigger and then locally hide 9 of the 10 for each player so they only see 1. Might be safe from a desync.
I have recently updated post. Could you check it again? Maybe we can find another solution for this.
 
Level 17
Joined
Jun 2, 2009
Messages
1,139
Yesterday i did many tests and still i couldn't find the what is wrong with the trigger.
Is anyone can suggest me another idea? I can remove this system and create new one

This is what i want.

Your team have a common resource called TP (team points)

When you try to buy upgrade, for example you are trying to buy Hit Point Upgrade
If you have the sufficient TP, you will buy the upgrade, it affects all units and Hit Point Upgrade removes from the shop
If you do not have the sufficient TP, simply do nothing. Do not remove the item from the shop. Because it can't be used yet.

This is the trigger of clicked item.

  • Slayer Upgrade Copy
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Slayer Upgrade
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Buying unit)) is an ally of ClanDevilPlayer) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[1] Greater than or equal to 300
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[1] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[1]))) using font size 10.00
              • Player - Set the current research level of Hero Slayers Upgrade Devil to ((Current research level of Hero Slayers Upgrade Devil for ClanDevilPlayer) + 1) for ClanDevilPlayer
              • Set StringTeamPoint[1] = (StringTeamPoint[1] - 300)
              • Neutral Building - Remove Slayer Upgrade from Lich 0086 <gen>
            • Else - Actions
              • Neutral Building - Add Slayer Upgrade to Lich 0086 <gen> with 1 in stock and a max stock of 1
              • Game - Display to (Player group((Triggering player))) the text: Bunun için yeterli...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[2] Greater than or equal to 300
            • Then - Actions
              • Floating Text - Change text of FloatTeamPoints[2] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[2]))) using font size 10.00
              • Player - Set the current research level of Hero Slayers Upgrade Reaper to ((Current research level of Hero Slayers Upgrade Reaper for ClanReaperPlayer) + 1) for ClanReaperPlayer
              • Set StringTeamPoint[2] = (StringTeamPoint[2] - 300)
              • Neutral Building - Remove Slayer Upgrade from Lich2 0105 <gen>
            • Else - Actions
              • Neutral Building - Add Slayer Upgrade to Lich2 0105 <gen> with 1 in stock and a max stock of 1
              • Game - Display to (Player group((Triggering player))) the text: Bunun için yeterli...
      • Trigger - Run Table Update Lumbers <gen> (ignoring conditions)
This is the trigger of removed item.

  • Dragons
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Dragons
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Buying unit)) is an ally of ClanDevilPlayer) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[1] Greater than or equal to 300
            • Then - Actions
              • Set TP_EjderDevil = True
              • Floating Text - Change text of FloatTeamPoints[1] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[1]))) using font size 10.00
              • Set StringTeamPoint[1] = (StringTeamPoint[1] - 300)
            • Else - Actions
              • Neutral Building - Add Dragons to Lich 0086 <gen> with 1 in stock and a max stock of 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StringTeamPoint[2] Greater than or equal to 300
            • Then - Actions
              • Set TP_EjderReaper = True
              • Floating Text - Change text of FloatTeamPoints[2] to (|cffadff2fTeam Points|r: + (String(StringTeamPoint[2]))) using font size 10.00
              • Set StringTeamPoint[2] = (StringTeamPoint[2] - 300)
            • Else - Actions
              • Neutral Building - Add Dragons to Lich2 0105 <gen> with 1 in stock and a max stock of 1
      • Trigger - Run Table Update Lumbers <gen> (ignoring conditions)
And additionally i have shrinked and added map for the testing purpose in my first post. You can download the map and see what happens when you try to buy items.
 

Attachments

  • annen.png
    annen.png
    375.9 KB · Views: 9
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,139
Finally i have solved.

1-) Shop was a hero before, duplicated any of the shops as a new shop
2-) Changed their race from Neutral Passive to Player 1 and Player 7

I know sounds stupid but it worked. I was started to think about it step by step and solved.
 
Last edited:
Status
Not open for further replies.
Top