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

Shops that only allow certain types of players

Status
Not open for further replies.
Level 5
Joined
Jul 15, 2018
Messages
111
Hello, I am trying to create a shop where only players who have joined a guild can buy from it. When players join a guild they set the classinterger variable. Am I approaching the problem from the right angle in terms of maximizing optimization? Thanks in advance.

  • Hero Store
    • Events
      • Unit - Warrior Master 0014 <gen> Sells an item (from shop)
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Champion's Battleaxe
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Hero manipulating item) is A Hero) Equal to True
          • classinteger[(Player number of (Owner of (Hero manipulating item)))] Equal to 3
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • heroClassBolean[(Player number of (Owner of (Hero manipulating item)))] Equal to 0
            • Then - Actions
              • Hero - Give (Sold Item) to (Triggering unit)
              • Set heroClassBolean[(Player number of (Owner of (Hero manipulating item)))] = 1
            • Else - Actions
              • Game - Display to tempPG for 5.00 seconds the text: |c00FF0000You can only choose class once|r
              • Hero - Drop (Item being manipulated) from (Hero manipulating item)
              • Custom script: call DestroyForce ( udg_tempPG )
        • Else - Actions
          • Game - Display to tempPG for 5.00 seconds the text: |c00FF0000You can't use this
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Custom script: call DestroyForce ( udg_tempPG )
 
Level 13
Joined
Oct 12, 2016
Messages
769
For one, if you want the shop available to specific allied players, I suggest giving it the abilities racial shops have like the Arcane Vault.
This makes it so only people allied to the shop owner can buy those items.

Also, I would suggest removing the item purchased and refunding the gold amount rather than dropping it on the ground.
How would they get the gold back for their mistake?
Then again, if this is for powerups with no cost, that may not matter much.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
It would be marginally more efficient to store Hero manipulating item and Player number (Owner of (Hero manipulating item)) in variables and re-use them as necessary throughout the trigger. I also believe you do not need to do Hero - Give (sold item) to triggering unit, since the unit bought the item from the shop, and instead of dropping it on the ground if they can't use it (they can pick it right back up again in that case), you should do Item - Remove/Destroy (Item being manipulated).

In this instance I'm also not entirely sure that Triggering Unit is going to return what you think it will. It might get the buying unit, it might get the shop itself. You will have to see. You're destroying the force, but you never set it equal to anything... so you gotta do that each time before displaying the error message.
 
Status
Not open for further replies.
Top