• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Simple GUI Shop System 1.02

I needed a shop system, so I made one. It's loosely based on Adiktus "Shop within a Shop"
This is a system that lets you add categories to a shop. Instead of having multiple shops, this system lets you give the illusion that there is only one shop.
It's easy to toggle between the main shop and the categories and each category can hold up to 10 items (11 if you hide the select hero button).
A description of how to implement it to your map is in the test map.

It's really simple, GUI, leakless and MUI.

  • ShopSetup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set ShopTable = (Last created hashtable)
      • -------- ShopUnitType is the main shop, the one you place on the map. --------
      • Set ShopUnitType = Shop
      • -------- ShopTotalCategories is the number of categories you want to have INCLUDING YOUR MAIN SHOP. --------
      • -------- So you set ShopTotalCategories to your number of categories plus one. --------
      • Set ShopTotalCategories = 3
      • -------- ShopCategory 1 is your main shop. --------
      • Set ShopCategory[1] = Shop
      • -------- The rest is your categories in numerical order. --------
      • Set ShopCategory[2] = Shop Category 1 (dummy)
      • Set ShopCategory[3] = Shop Category 2 (dummy)
      • -------- ShopSpell 1 is the spell you use for returning to the main shop. --------
      • Set ShopCategoryItem[1] = Return
      • -------- The rest is for the categories in numerical order. --------
      • Set ShopCategoryItem[2] = Category Weapon
      • Set ShopCategoryItem[3] = Category Armor
      • Trigger - Run ShopInit <gen> (ignoring conditions)
  • ShopInit
    • Events
    • Conditions
    • Actions
      • Set ShopTempGroup = (Units owned by Neutral Passive matching ((Unit-type of (Matching unit)) Equal to ShopUnitType))
      • Unit Group - Pick every unit in ShopTempGroup and do (Actions)
        • Loop - Actions
          • Set ShopTempUnit = (Picked unit)
          • Set ShopTempPoint = (Position of ShopTempUnit)
          • Set ShopInteger = (ShopInteger + 1)
          • Set ShopNumber[ShopInteger] = ShopTempUnit
          • Hashtable - Save ShopInteger as 0 of (Key (Picked unit)) in ShopTable
          • Custom script: if udg_ShopGroup[udg_ShopInteger] == null then
          • Custom script: set udg_ShopGroup[udg_ShopInteger] = CreateGroup()
          • Custom script: endif
          • Unit Group - Add ShopTempUnit to ShopGroup[ShopInteger]
          • Trigger - Add to ShopCategory <gen> the event (Unit - (Picked unit) Sells an item (from shop))
          • For each (Integer A) from 2 to ShopTotalCategories, do (Actions)
            • Loop - Actions
              • Unit - Create 1 ShopCategory[(Integer A)] for Neutral Passive at ShopTempPoint facing Default building facing degrees
              • Hashtable - Save ShopInteger as 0 of (Key (Last created unit)) in ShopTable
              • Unit Group - Add (Last created unit) to ShopGroup[ShopInteger]
              • Trigger - Add to ShopCategory <gen> the event (Unit - (Last created unit) Sells an item (from shop))
          • Custom script: call RemoveLocation(udg_ShopTempPoint)
      • Custom script: call DestroyGroup(udg_ShopTempGroup)
  • ShopCategory
    • Events
    • Conditions
    • Actions
      • Set ShopPlayer = (Owner of (Buying unit))
      • Set ShopPersonalInteger = (Load 0 of (Key (Selling unit)) from ShopTable)
      • For each (Integer A) from 1 to ShopTotalCategories, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Sold Item)) Equal to ShopCategoryItem[(Integer A)]
            • Then - Actions
              • Set ShopSoldCatNumber = (Integer A)
            • Else - Actions
      • Unit Group - Pick every unit in ShopGroup[ShopPersonalInteger] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to ShopCategory[ShopSoldCatNumber]
            • Then - Actions
              • Selection - Select (Picked unit) for ShopPlayer
            • Else - Actions
Keywords:
Shop, Category, Categories,
Contents

Shop System 1.0 by Shoto (Map)

Reviews
Simple GUI Shop System 1.02 | Reviewed by Maker | 20th Feb 2013 APPROVED This is a neat little system that allows the user to have more items per shop. Very useful, definitely recommended. A good addition to many maps. One thing you could add...

Moderator

M

Moderator


Simple GUI Shop System 1.02 | Reviewed by Maker | 20th Feb 2013
APPROVED

This is a neat little system that allows the user to have more items per shop.
Very useful, definitely recommended. A good addition to many maps.

One thing you could add is Skip remaining actions when the correct
shop category item and unit types are found.
[td]
[/td]



Simple GUI Shop System 1.02 | Reviewed by Maker | 18th Feb 2013
Needs Fix

Required changes
  • Units of type x function leaks, don't use it
  • Destroy ShopTempGroup outside the unit group loop
  • If you have more than 2 shops, the system won't work by default.
    The shop groups are not created
[td]
[/td]
 
What about using AddItemToStock?

Init

Category 1

Category 2

Cancel

  • Init
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Shop) and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • Set ShopInteger = (ShopInteger + 1)
          • Set ShopNumber[ShopInteger] = (Picked unit)
          • Unit Group - Add (Picked unit) to ShopGroup[ShopInteger]
          • -------- Here, we create the dummy shops that hold items. --------
          • Unit - Create 1 Shop Category 1 (dummy) for Neutral Passive at TempPoint facing Default building facing degrees
          • Unit Group - Add (Last created unit) to ShopGroup[ShopInteger]
          • -------- Repeat these two steps for every category you're using. --------
          • Unit - Create 1 Shop Category 2 (dummy) for Neutral Passive at TempPoint facing Default building facing degrees
          • Unit Group - Add (Last created unit) to ShopGroup[ShopInteger]
          • Custom script: call RemoveLocation(udg_TempPoint)
  • Category 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Category 1
    • Actions
      • For each (Integer A) from 1 to ShopInteger, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Casting unit) Equal to ShopNumber[(Integer A)]
            • Then - Actions
              • Unit Group - Pick every unit in ShopGroup[(Integer A)] and do (Actions)
                • Loop - Actions
                  • -------- The unit type and the cast spell must match! --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to Shop Category 1 (dummy)
                    • Then - Actions
                      • Selection - Select (Picked unit)
                    • Else - Actions
            • Else - Actions
  • Category 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Category 2
    • Actions
      • For each (Integer A) from 1 to ShopInteger, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Casting unit) Equal to ShopNumber[(Integer A)]
            • Then - Actions
              • Unit Group - Pick every unit in ShopGroup[(Integer A)] and do (Actions)
                • Loop - Actions
                  • -------- The unit type and the cast spell must match! --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to Shop Category 2 (dummy)
                    • Then - Actions
                      • Selection - Select (Picked unit)
                    • Else - Actions
            • Else - Actions
  • Cancel
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to cancel
    • Actions
      • For each (Integer A) from 1 to ShopInteger, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in ShopGroup[(Integer A)] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Equal to (Casting unit)
                • Then - Actions
                  • Unit Group - Pick every unit in ShopGroup[(Integer A)] and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Picked unit)) Equal to Shop
                        • Then - Actions
                          • Selection - Select (Picked unit)
                        • Else - Actions
                • Else - Actions
Review:
@Trigger Init
-Cache picked unit to increase speed.Ex. set myunit = picked unit
or just use this:
  • Set ShopInteger = (ShopInteger + 1)
  • Set ShopNumber[ShopInteger] = (Picked unit)
  • Set TempPoint = (Position of (ShopNumber[ShopInteger]))
  • Unit Group - Add (ShopNumber[ShopInteger]) to ShopGroup[ShopInteger]
-Units of Type Shop leaks
-0.01 loop is very fast,make it 0.03
@Category 1
-Use custom integer,then replace Integer A in case some trigger uses Integer A and accidentally collides w/ your system
-Cache picked unit again
@Category 2
-Just like Category 1
@Cancel
-Cache picked unit
-Use Triggering Unit instead of Casting Unit
-You are enumarating (picking) the group inside the group
Overall Review:
-Add Prefixes(to prevent variable collision)
-Add Return ability
-Lacks Configuration

Note:
Configuration is a must.Configuration easily makes the users create their own w/o looking inside the object editor.Just like this:http://www.hiveworkshop.com/forums/spells-569/compressed-tavern-v1-4-a-223378/?prev=status=a&u=Almia
Or this:
http://www.hiveworkshop.com/forums/...d713672ee03eea635908ce5d9&dateline=1360745136

I would like to suggest looking this:http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/shop-within-shop-193048/
w/c is faster than yours
 
Level 7
Joined
May 11, 2010
Messages
278
I've uploaded an updated version.
Here are the new triggers:

  • Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- ShopUnitType is the main shop, the one you place on the map. --------
      • Set ShopUnitType = Shop
      • -------- ShopTotalCategories is the number of categories you want to have INCLUDING YOUR MAIN SHOP. --------
      • -------- So you set ShopTotalCategories to your number of categories plus one. --------
      • Set ShopTotalCategories = 3
      • -------- ShopCategory 1 is your main shop. --------
      • Set ShopCategory[1] = Shop
      • -------- The rest is your categories in numerical order. --------
      • Set ShopCategory[2] = Shop Category 1 (dummy)
      • Set ShopCategory[3] = Shop Category 2 (dummy)
      • -------- ShopSpell 1 is the spell you use for returning to the main shop. --------
      • Set ShopSpell[1] = Return
      • -------- The rest is for the categories in numerical order. --------
      • Set ShopSpell[2] = Category 1
      • Set ShopSpell[3] = Category 2
      • Trigger - Run Init <gen> (ignoring conditions)
  • Init
    • Events
    • Conditions
    • Actions
      • Set ShopTempGroup = (Units of type ShopUnitType)
      • Unit Group - Pick every unit in ShopTempGroup and do (Actions)
        • Loop - Actions
          • Set ShopTempUnit = (Picked unit)
          • Set ShopTempPoint = (Position of ShopTempUnit)
          • Set ShopInteger = (ShopInteger + 1)
          • Set ShopNumber[ShopInteger] = ShopTempUnit
          • For each (Integer A) from 2 to ShopTotalCategories, do (Actions)
            • Loop - Actions
              • Unit - Add ShopSpell[(Integer A)] to ShopTempUnit
          • Unit Group - Add ShopTempUnit to ShopGroup[ShopInteger]
          • For each (Integer A) from 2 to ShopTotalCategories, do (Actions)
            • Loop - Actions
              • Unit - Create 1 ShopCategory[(Integer A)] for Neutral Passive at ShopTempPoint facing Default building facing degrees
              • Unit - Add ShopSpell[1] to (Last created unit)
              • Unit Group - Add (Last created unit) to ShopGroup[ShopInteger]
          • Custom script: call RemoveLocation(udg_ShopTempPoint)
          • Custom script: call DestroyGroup(udg_ShopTempGroup)
  • Category Clicked
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • For each (Integer A) from 1 to ShopTotalCategories, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Casting unit)) Equal to ShopUnitType
                  • (Unit-type of (Casting unit)) Equal to ShopCategory[(Integer A)]
            • Then - Actions
              • Trigger - Run Select Shop <gen> (checking conditions)
            • Else - Actions
  • Select Shop
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to ShopTotalCategories, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to ShopSpell[(Integer A)]
            • Then - Actions
              • Set ShopCastSpellNumber = (Integer A)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ShopCastSpellNumber Equal to 1
                • Then - Actions
                  • For each (Integer A) from 1 to ShopInteger, do (Actions)
                    • Loop - Actions
                      • Unit Group - Pick every unit in ShopGroup[(Integer A)] and do (Actions)
                        • Loop - Actions
                          • Set ShopTempUnit = (Picked unit)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ShopTempUnit Equal to (Casting unit)
                            • Then - Actions
                              • Selection - Select ShopNumber[(Integer A)]
                            • Else - Actions
                • Else - Actions
                  • For each (Integer A) from 1 to ShopInteger, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Casting unit) Equal to ShopNumber[(Integer A)]
                        • Then - Actions
                          • Unit Group - Pick every unit in ShopGroup[(Integer A)] and do (Actions)
                            • Loop - Actions
                              • Set ShopTempUnit = (Picked unit)
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Unit-type of ShopTempUnit) Equal to ShopCategory[ShopCastSpellNumber]
                                • Then - Actions
                                  • Selection - Select ShopTempUnit
                                • Else - Actions
                        • Else - Actions
            • Else - Actions
(Did i just put hiddens in hiddens? We need to go deeper)

However, I'm unsure about the function
  • Selection - Select Unit
Does it select the unit for all players? Because if it does I'd need to use "select unit for player" but i'm not sure how to refer to the clicking player. Both "Triggering Player" and "Owner of Triggering unit" returns Player 16, owner of the shop.
 
Level 7
Joined
May 11, 2010
Messages
278
Remade the system, inspired by Shop within a Shop. The description has been updated and new test map is up.

@Almia: Encapsulation method is Jass, wich i don't do. I do GUI. This spell is categorised as GUI and as such I do not intend to make it Jass.
 
Top