Author Topic: Custom vendors  (Read 12020 times)

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Custom vendors
« 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.

rpc190

  • Posts: 44
  • Map Maker
    • View Profile
Re: Custom vendors
« Reply #1 on: October 08, 2015, 11:14:01 PM »
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:

Code: [Select]
<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.




Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #2 on: October 09, 2015, 10:04:46 AM »
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.

rpc190

  • Posts: 44
  • Map Maker
    • View Profile
Re: Custom vendors
« Reply #3 on: October 12, 2015, 07:48:56 PM »
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.

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #4 on: October 13, 2015, 01:32:03 PM »
I already tried that and it didn't work. Doesn't matter, I'll just change it in the xml. Thanks for your help.

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #5 on: November 20, 2015, 09:45:51 PM »
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?

rpc190

  • Posts: 44
  • Map Maker
    • View Profile
Re: Custom vendors
« Reply #6 on: November 20, 2015, 11:39:34 PM »
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.

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #7 on: November 21, 2015, 10:56:19 AM »
Works like a charm, thank you :)

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #8 on: December 28, 2015, 04:56:59 PM »
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?

rpc190

  • Posts: 44
  • Map Maker
    • View Profile
Re: Custom vendors
« Reply #9 on: December 28, 2015, 10:20:08 PM »
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.

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #10 on: December 29, 2015, 01:15:29 AM »
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. :(

rpc190

  • Posts: 44
  • Map Maker
    • View Profile
Re: Custom vendors
« Reply #11 on: December 30, 2015, 10:31:25 PM »
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

Flemse

  • Posts: 67
  • Maggot Crusher.
    • View Profile
Re: Custom vendors
« Reply #12 on: January 10, 2016, 08:29:55 PM »
We figured it out! :) Thank you a lot for all your help.