[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > WarCraft III Tutorials > General Mapping Tutorials


General Mapping Tutorials This board contains tutorials that provide generic mapping information.
Read the Rules before posting.

Closed Thread
 
Thread Tools
Old 04-07-2011, 01:55 PM   #1 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,535
Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)
Shop Within a Shop

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



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.
    Important things to note

    -->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

    For those who want to use a real model for the shop

    -->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
    Important things to note

    -->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
  • 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...
Here's a sample trigger:
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

For JASS/vJASS, I've created a small library...
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


Changelog

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...

Attached Files
File Type: w3x ClassifiedShop.w3x (18.5 KB, 452 views)

Last edited by Adiktuz; 06-07-2011 at 07:34 AM.
Adiktuz is offline  
Old 04-07-2011, 03:07 PM   #2 (permalink)
Registered User Kino
It is a long road
 
Kino's Avatar
 
Join Date: Oct 2008
Posts: 774
Kino is a jewel in the rough (166)
Shop within a Shop?
We need to go deeper.

On Topic: Really intresting, its basic yet Ive never thought of such a system.
Kino is offline  
Old 04-07-2011, 10:19 PM   #4 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,561
PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)
Great stuff. A really cool technique, and certainly useful.

Some small notes, however.
  • Tell the reader to disable the minimap display as well (of the dummy units), else it will appear on the minimap.
  • Sight radius, food cost, etc. should be also 0. Maybe have them base it off a unit other than peasant, like the phoenix egg or something.
  • You should have the units created at the vendor instead, because when you click on the portrait, then it will shift the camera to the vendor.
  • Hold shift+click the selection scale, and type in 0 instead of 0.10. 0.10 is still slightly visible, while 0 will have no selection.
  • It would be really cool if this could work with multiple heroes. Maybe have some sort of "Select User" ability, so it can tell what the unit should have. (like the ones that the normal shops have, eg: merchants, arcane vaults, etc.)
  • If possible, maybe you can have a cancel button to revert back to select the normal vendor.

The last 2 are moreso simple suggestions. This is still useful as a sample without it. The other ones will probably need a fix, however. Also, make sure your signature is detached from the first post.

Otherwise, nice job and cool technique.
PurgeandFire is offline  
Old 04-08-2011, 02:02 AM   #5 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,535
Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)
yeah, I forgot about the foodcosts etc...

The dummy vendors doesn't show for me, but yeah maybe it would be helpful to remind them...

for the third suggestion, well it depends on the user... but maybe I'll change my suggestion to that one... (never thought about the camera shift since I originally did this on my current project which has a locked camera)

Will update this later (detached signature for now)... ^_^

EDIT: Updated!
Adiktuz is offline  
Old 04-11-2011, 10:52 PM   #6 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,561
PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)
Good job. I like the outcome. ~Approved.

Moved to general mapping. Misc is for external tutorials, but relating to wc3 or this site in some way.
PurgeandFire is offline  
Old 04-12-2011, 01:53 PM   #7 (permalink)
Forum Moderator Orcnet
HIVE WARCHIEF™
 
Orcnet's Avatar
Resource Moderator
 
Join Date: Jul 2010
Posts: 2,496
Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)
Nicely done tutorial, you also provided a map sample for beginners who still cannot apply with triggers and such, and to see its details are promised, I say this one is really useful, good job for sharing this to us.
__________________
Orcnet is offline  
Old 04-12-2011, 01:57 PM   #8 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,535
Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)
my first thought was to upload the vjass system then I thought it was too simple to be approved as a system resource, that's when I thought of writing it up as a tutorial since I've already seen numerous people asking of something like this... so instead of writing it up again and again, we could just link this... ^_^
Adiktuz is offline  
Old 04-12-2011, 02:22 PM   #9 (permalink)
Forum Moderator Orcnet
HIVE WARCHIEF™
 
Orcnet's Avatar
Resource Moderator
 
Join Date: Jul 2010
Posts: 2,496
Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)
Its good to see your helping the hive with your ability, I like it :D
__________________
Orcnet is offline  
Old 04-12-2011, 02:28 PM   #10 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,535
Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)
^.^

and its been a while since I uploaded something... so busy with my map... but if not for that, I wont have thought of this tut...
Adiktuz is offline  
Old 04-12-2011, 02:36 PM   #11 (permalink)
Forum Moderator Orcnet
HIVE WARCHIEF™
 
Orcnet's Avatar
Resource Moderator
 
Join Date: Jul 2010
Posts: 2,496
Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)Orcnet is a splendid one to behold (855)
hahaha! don't worry, well good luck with yah project. as well as your triggering skills!
__________________
Orcnet is offline  
Old 05-11-2011, 01:49 AM   #12 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
For the GUI trigger part...
Isn't suppose the 2nd condition (the "Item Type of Sold Item is equal to Armor") should be INSIDE the IF/THEN/ELSE function ?
It should belong IN the ELSE condition, right ?

Also, you're setting the TempPlayer by using the local variable, right ?
Should it get nulled once you've used it ? (I don't know about this one, my JASS knowledge is minimum, just take a shot lol)
defskull is offline  
Old 05-15-2011, 06:19 AM   #13 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,535
Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)
It was on the else part, the spacing was just a bit off... (fixed it, to avoid confusion)

for the Jass part, TempPlayer was a global (I declared it on the globals block)

and the GUI TempPlayer is not equal to the jass TempPlayer global (you only need one of those scripts, depending on whether you want GUI or vJASS)

EDIT: I've added a note for those who would want to use a real model (to have a portrait) for the dummy shops... ^_^

if anybody wants a test map which shows that kind of sub-shops, just tell me...
Adiktuz is offline  
Old 05-31-2011, 06:46 AM   #14 (permalink)
Registered User deaththekid
Just A Normal Terrainer
 
deaththekid's Avatar
 
Join Date: Apr 2011
Posts: 109
deaththekid has little to show at this moment (2)
this system is like in diablo 2 trrade system because of the category [Armors] [Weapons] [Others] [Misc]
__________________
Join here my project!
http://www.hiveworkshop.com/forums/m...forest-207022/
deaththekid is offline  
Old 06-01-2011, 04:51 AM   #15 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,535
Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)Adiktuz has much of which to be proud (1094)
Updated with notes about how to make an item to return to the main shop menu...

also updated the posted triggers in line with this (the one on the test map is not yet updated)
Adiktuz is offline  
Closed Thread

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 01:25 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle