Hammerwatch Forum
Custom mapping and Mods => Editor Discussion => Topic started by: Flemse on October 05, 2015, 08:49:14 PM
-
I'm having some trouble creating a custom vendor. I'm trying to create a vendor that only holds one custom item, which should enable a flag on the item I have made. I've already made it as a pickup, and the GUI works as intended, but I can't figure out how to put it in a vendor.
Any help is much appreciated.
-
Okay I think I know what you're going for, here's how to do it.
Your custom campaign should be a full directory containing the same folder found within C:/..../Hammerwatch/editor. If not, well read this thread on how to make it so: http://hammerwatch.com/forum/index.php?topic=2026.0
So once you have that setup, the Tweak is where most of the script for each shop is. I've attached the script they used to the gamble shop in the desert campaign. You should probably just copy that into your Tweak folder and rename it whatever you want. Now let's at setting up the shop, it should look something like this:
<tweak>
<params>
<dictionary>
</dictionary>
</params>
<upgrades>
<dictionary id="shopid" cost="99" cat="shopcategory" shared="true"
name="shopname" desc="shopdescription" />
</upgrades>
</tweak>
Some of these are self explanatory, what's mostly important are dictionary id and cat.
Dictionary ID will be the global event that is fired whenever this is purchased. More on this in a moment.
Cat refers to which vendor to hold the item, which you must reference in your Shop script within the Hammerwatch editor.
For your item to appear you will need to create a GlobalEventTrigger script with Event: set to match your Dictoinary ID. Then attach that to a SpawnObject script that will create your item.
Hopefully this is what you were looking for.
-
Oh my, you are exactly right(except that I needed to set a global flag, not spawn the object), and I had already done it ... but I did not copy it to my campaign folder, I was editing in the assets folder! What a dumb mistake. It works now, thanks for your help.
Short side question you might be able to answer. I made an entry into the english.xml for name and description of the item:
<string name="flower-uname">Flower</string>
<string name="flower-udesc">A faul smelling flower</string>
But the name just show up in-game as flower-uname and description as flower-udesc. And i remembered to edit the right place this time :) It's not a big issue, I could just change it in the shared.xml file, but if you have any idea what I'm doing wrong here, I'd be nice to fix.
-
I only once ever tried to use that technique for strings and it didn't work. Maybe copy the whole english.txt to your map folder if you haven't tried that. I've always just named things in their .xml.
-
I already tried that and it didn't work. Doesn't matter, I'll just change it in the xml. Thanks for your help.
-
Hello again, I'm having trouble making an item you can buy over and over, like for example the extra lives. When I buy the item it just dissapears from the vendor.
Any idea how to make the item appear so you can buy it again?
-
Attach a ChangeUpgrades script to your EventTrigger that fires when your item is purchased. Set the Change to Set and the Category to whatever the dictionary id is for your item.
-
Works like a charm, thank you :)
-
Hello again :) testing this I found out it seems to reset all player skills. Changing it to add or remove doesn't work(don't fully understand the ChangeUpgrade element). Any way to do it without this unfortunate side effect?
-
Ah my mistake.
It should work with it set to remove. Make sure the ChangeUpgrades category is set to the same as your Tweak item. Also note that making the purchase will pause the game in single player until the shop window is closed. You must close and reopen the shop window for the item to restock.
-
Sadly, it doesn't work. It works just fine when I set it to set, the vendor gets restocked and I can buy the item again, but the player loses all upgrades. And when I set it to either Remove or Add the item does not get restocked, but the player keeps the upgrades. :(
-
I'm not sure what to tell you, so I linked a working version of a repeatable custom vendor event. Hopefully you can discern what is going wrong by comparing it with what you have.
https://www.dropbox.com/s/xwk3qy9uoi6a57m/Custom%20Vendor.zip?dl=0 (https://www.dropbox.com/s/xwk3qy9uoi6a57m/Custom%20Vendor.zip?dl=0)
-
We figured it out! :) Thank you a lot for all your help.