HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item order in shop

05-18-2009, 07:02 PM#1
Slin
I have a problem with the order items appear in shops. My map has a large number of item shops and some items appear in multiple shops. Somehow I can't set the order the items appear in some of the shops. They seems to behave randomly and sometimes change when I change the order in another item shop. Does anyone have any clue on what's causing this?
05-18-2009, 07:08 PM#2
Rising_Dusk
You're probably using the marketplace triggers employed by the blizzard.j script file. You should make sure that you don't run the "Use Marketplace Trigger" (Whatever it's called) in any map initialization triggers.
05-18-2009, 07:21 PM#3
Slin
Quote:
Originally Posted by Rising_Dusk
You're probably using the marketplace triggers employed by the blizzard.j script file. You should make sure that you don't run the "Use Marketplace Trigger" (Whatever it's called) in any map initialization triggers.

Thanks for the quick reply. I've looked through all the code run at initialization but couldn't find anything like that.
05-18-2009, 07:39 PM#4
Rising_Dusk
Then it is likely because of how you have the items inside of the shops oriented in the "Item Editor" inside the object editor. There are two fields at the top where it shows X and Y.
Table:
0,01,02,03,0
0,11,12,13,1
0,21,22,23,2
0,31,32,33,3
Those are the coordinates in X,Y format for the command card in the shops. Make sure you order the items in the object editor properly, otherwise they may also jump around seemingly-randomly. (If they all have the same coordinate pair, for instance)
05-18-2009, 07:55 PM#5
Slin
Thank you for the fast reply again.

But if all items have the same coordinate, then they should be ordered in the order they are entered in the shop right? Why does this only work when you have 1 shop with the item? I'm guessing the World Editor sets the coordinate attributes of the items to fit the shops it find so only the last one sticks.

So an item cannot be in different shops at different positions in an easy way?
05-18-2009, 08:01 PM#6
Rising_Dusk
Unfortunately, there's no reliable way (that I am aware of) to have the same shop types be ordered how you want when you want them ordered. If all items have the same coordinate, it sometimes works that they end up in the order they are put in the shop, but that 'refreshes' when you buy items or some such. I don't know all of the exacts offhand, but I just know I could never get it to work myself.
05-18-2009, 08:16 PM#7
rain9441
Perhaps it is ordered similarily to how abilities with the same tooltip location and/or spell book abilities are ordered. It would be worth testing...

My theory:

Items whose coordinates are the same will be assigned a priority P upon first being seen or loaded into the map. All values of P are unique and increasing as items are loaded. If two items have the same X/Y coordinates on the command card, whichever one has the lower P value will take precedence and be placed at the X/Y location, while the item with the next highest P value will be placed at an arbitrary location (most likely one to the right of the position it is supposed to be at, wrapping around to the other side and increasing Y by 1 if necessary). If there exists an item whos location is X+1/Y, you have a new collision, and again, will follow the same procedure (Lowest P value is placed, higher P value is moved).

This would mean that you could maybe "preload" items on map init to force priorities. Then items could in theory be placed at different locations for different item shops. That would take a lot of thought and effort to maintain though.

How to preload an item? Not sure, try just adding an item of that type to the map, or create a shop on map init, add the items in the order you want, than remove the shop.

I use this approach to put abilities in spellbooks at arbitrary locations, and have a strict map oninit preloading schema that involves preloading "empty dummy abilities" between certain other abilities and adding/removing them from units appropriately to create a really nice organized spellbook.

Again, this is my theory for how items are placed on the command card for shops, it may or may not actually be the case, but you could test it.

If you want to try it. Add 10 new distinct dummy items to a new dummy shop, all with the coordinates of 1,1. Make an on map init trigger that sleeps for 1 second and then places the shop with the tiems. Load the map, check the order in which they appear. Then make a trigger that happens on map init and add one of each of those 10 items (doesn't have to be to a shop, just add it to the map somewhere) in some order you would like to see them in (Do not sleep for 1 second though). See if the ordering changed, and see if the order of items in the shop matches that of the order you placed them on map init.