- Joined
- Oct 16, 2008
- Messages
- 10,450
Shop Within a Shop
by Adiktuz
Description:
This tutorial will teach you on how to create a shop within a shop. In this tutorial, I will teach you on how to create a shop which sells Weapons and Armors
Tools Needed:
-World Editor (NewGenWE as much as possible)
-Knowledge on how to create basic shops
-Knowledge on how to create items
-A bit of triggering knowledge
April 8, 2011 - 9:59am GMT+8
-Made the dummy shops show the select user ability
-Set some other attributes of the shops to 0
I've attached a test map below...
by Adiktuz
Description:
This tutorial will teach you on how to create a shop within a shop. In this tutorial, I will teach you on how to create a shop which sells Weapons and Armors
Tools Needed:
-World Editor (NewGenWE as much as possible)
-Knowledge on how to create basic shops
-Knowledge on how to create items
-A bit of triggering knowledge
Part 1 - Creating the Shops
- The first thing that you need to do is to open up your object editor and create the main shop, this would be the shop that is visible to the user. Make sure you add the abilities, Sell Item and Select Unit
- Next, create the dummy shops. The dummy shops are the shops that are within the main shop. These dummy shops are also the ones that will sell the items.
-->Set the model for these units to none.mdl, shadow to none, movement type to none, and size of selection circle, collision size, food cost, sight radius to 0.
-->Also add the ability, Sell Item. And also add the items you want the shop to sell.
-->Make sure have them configured not to show on the minimap (Object Data -> Minimap display -> false)
-->For this tutorial, create two dummy shops, one for weapons, one for armors
-->make sure you create the shop in a place that the hero cannot go
-->you might also need a trigger which will prevent the camera from going to that area (just if you want)
- Next, go to the ability editor and create a new ability based on Select Unit. Set the activation range to 999999999 and cast range to 9999999. If you want the selector to show up on the shop, just check the corresponding checkbox.
-->Add this ability to the dummy shops- That's it for now, for the shops.
Part 2 - Creating the Selection Items
Now that we've made the shops, its time to create the dummy items that will enable us to access the sub-shops.
- Go to the item editor and create an item for each sub-shop that the main shop will have
-->Make sure they have no gold cost, set Stock maximum to 1, Stock replenish to a low value, and Stock Start Delay to 0
-->For this tutorial, make two, one for weapon and one for armor
-->You can also make the item of type Power-Up, and set it to use upon pickup, though you need to create a dummy ability which will act as the ability of the item, doing this would allow you to remove the RemoveItem part, and will also allow you to access the shops when inventory is full.
- Now add these items to the items sold by the main shop
- Also, create an item which will be used to go back to the main shop menu
- Be sure to add the item to the items sold by each dummy shop
- If you use the vjass library, don't forget to set the RETURN_ITEM to the rawcode of the item
Part 3 - Setting up the triggers [For GUI]Now that the shops and accessor items are set-up, its time for the triggers
Here's a sample trigger:
- Create a new trigger
- Set the event to Unit - A unit sells an item (from shop)
- On the actions create an in-then-else equal to the number of sub-shops
- On each If - Condition, put, Item Type of Item Sold is equal to blahblah
- On the Then - Action, put, Selection - Select Blahblah for Player
Note:
If you use the GUI way, be sure to add the dummy shops into the map and set the variables to them...
And be sure to create the variables, I assume you already know how...
Also, the triggers on the test map is not updated, so just copy the triggers here...
For JASS/vJASS, I've created a small library...
- Events
- Unit - A unit sells an item (from shop)
- Actions
- set TempPlayer = Owner of Buying Unit
- set TempInt = Player Number of TempPlayer
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Item Type of Sold Item is equal to Weapon
- Then - Actions
- Selection - Clear Selection for TempPlayer
- Item - Remove Sold Item
- Selection - Select WeaponDummyShop for TempPlayer
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Item Type of Sold Item is equal to Armor
- Then - Actions
- Selection - Clear Selection for TempPlayer
- Item - Remove Sold Item
- Selection - Select ArmorDummyShop for TempPlayer
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Item Type of Sold Item is equal to Back
- Then - Actions
- Selection - Clear Selection for TempPlayer
- Item - Remove Sold Item
- Selection - Select MainShop[TempInt] for TempPlayer
- Else - Actions
JASS:library ShopAllocation initializer init globals private integer array ITEMS private unit array SHOPS private hashtable ShopHash = InitHashtable() private unit Shop = null private player TempPlayer = null private unit array SHOPS_MAIN private integer RETURN_ITEM = 'I000' //change this to the rawcode of the item endglobals private function ChangeShop takes nothing returns boolean local integer temp = GetItemTypeId(GetSoldItem()) set TempPlayer = GetOwningPlayer(GetBuyingUnit()) set Shop = LoadUnitHandle(ShopHash, temp, 0) if Shop != null then call RemoveItem(GetSoldItem()) if (GetLocalPlayer() == TempPlayer) then call ClearSelection() call SelectUnit(Shop, true) set SHOPS_MAIN[GetPlayerId(TempPlayer)] = GetTriggerUnit() endif endif if temp == RETURN_ITEM then call ClearSelection() call SelectUnit(SHOPS_MAIN[GetPlayerId(TempPlayer)], true) endif return false endfunction //Use this function to link dummy shops to their accessor item function AllocateShop takes unit u, integer id returns nothing call SaveUnitHandle(ShopHash, id, 0, u) endfunction private function init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SELL_ITEM) call TriggerAddCondition(t, Condition(function ChangeShop)) endfunction endlibrary
NOTES:
--> I suggest placing the dummy shops right next to the vendor so that the camera won't move when you click the dummy portrait
April 8, 2011 - 9:59am GMT+8
-Made the dummy shops show the select user ability
-Set some other attributes of the shops to 0
I've attached a test map below...
Attachments
Last edited: