> ************************************************************************** * Shopkeeper DIL for Dummies. * * Version 1.0 * * Original Author Malice * * Last Updated May 1 1998 * ************************************************************************* Note: This document does not explain why this DIL works, it merely shows how to use it. There is an explanation out there that does show you how and why the shopkeeper dil works, but this isn't it. Also, I use defines to make my shopkeepers as I was instructed when I was first shown, so that's what I'll do here. I do want to note that the defines can be named anything, but I've picked the names used here to keep myself from being confused as to what I was defining. =) I am going to use one of my own shopkeepers, Hogan, for example purposes because he's already made and I know he works. =) Step 1: --------- First, figure out what you want your shopkeeper to sell. He can sell pretty much any item from any zone, as long as you know its symbolic name. For Hogan (our example shopkeeper), he is a bartender, so he sells things you would commonly find in a pub, tavern, or bar. His list of items (their symbolic names at which zone) are: grain_alcohol@gobtown1 pretzels@gobtown1 beer_nuts@gobtown1 rum_coke@gobtown1 tuborg@udgaard Now, since I use defines, I make a define for Hogan's products. I called it TAVERN_PROD (for tavern's products). And you use the following setup and just stick the names of your items in where his items are. Each item will have a setup like this: "tuborg@udgaard 15 20" A symbolic name followed by two numbers, with the entire thing in quotes. * In this case, the "tuborg@udgaard" is your item's symbolic name... * The 15 (our first number in the string) is the number of that item that will load into your shop daily... * The 20 (our second number in the string) is the limit available of that item in the shop ever... So this shop would sell tuborgs.. and every mudday, 15 tuborgs will load into our shop to replish our stock.. and the maximum tuborgs we can have at any given time is 20. So I stick all of my items in the setup and I get: #define TAVERN_PROD \ {"grain_alcohol@gobtown1 15 20", \ "pretzels@gobtown1 10 15", \ "beer_nuts@gobtown1 15 20", \ "rum_coke@gobtown1 10 15", \ "tuborg@udgaard 15 20"} The above is my define for Hogan's products that he sells. Each one is in quotes and they have commas separating them. If you put each item on its own separate line, you need to put a space and then a backslash after the comma which separates the items, like it shows above. The entire define is enclosed in curly braces, {}. And then you're finished with the items he sells. =) Step 2: --------- Then you get to decide what kind of dialogue you would like your shopkeeper to say. There are ten separate responses you can make for your shopkeeper. They do go in a specific order and I will list what each do. Response 1: The first response will be used if the shopkeeper doesn't have the particular item you're trying to buy in stock, or if he doesn't sell that item at all. Response 2: The second response is used when the player is trying to sell the shopkeeper something which the player does not have in his inventory. Worn items can't be sold. Response 3: The third response is for when the player is trying to sell the shopkeeper something that is not one of those of his trade type. (This will be more clear when we get to the trade type part.. such as a player trying to sell our bartender a canoe. =) Response 4: The fourth response is for when the player tries to buy something from the shopkeeper, but doesn't have enough money to buy it. Response 5: The fifth response is for when the sale was successful for when the player buys something from the shopkeeper. Response 6: The sixth response is again for when the sale was successful, but this time it's for when the player successfully sells something to the shopkeeper. Response 7: The seventh response is for when the shopkeeper doesn't have enough of the item to sell as the player requests. Such as someone trying to buy 10 tuborgs, but our bartender only has 9. Response 8: The eighth response is for when the shop is closed and a player tries to buy something from or sell something to the shopkeeper. Response 9: The ninth response is for when the player tries to sell an item to the shopkeeper that the shopkeeper doesn't trade with. (This is pretty much just like Response 3, at least that's how it seems. =) Response 10: The tenth (and last!) response is for when the shopkeeper has run out of money and can't afford to buy what the player is trying to sell him. Now.. again, I made a define called TAVERN_MSG (for tavern messages) and I stuck my responses in it. Don't forget, they do go in that specific order! =) And below is our setup with responses in it. * Note: In the responses below, $1n refers to the shopkeeper, $2n refers to the item being sold, bought, etc.. and $3n refers to the person dealing with the shopkeeper. #define TAVERN_MSG \ {"$1n says, 'This is a tavern, I don't sell such an item as that!'", \ "$1n says, '$3n, you don't even have that!'", \ "$1n says, 'I don't trade with things such as $2n! Just buy a beer!'", \ "$1n says, '$3n, you can't afford $2n.'", \ "$1n says, 'Thank you, $3n, here are %s for $2n.'", \ "$1n says, 'Thank you, $3n.'", \ "$1n says, 'I don't have that many $2ns in stock.'", \ "$1n says, 'I'm on break, come back later.'", \ "$1n says, 'I haven't got a use for $2n.'", \ "$1n says, 'I'd like to buy it, but I can't afford it, sorry.'"} \ Just like with the items, the responses are in quotes, and are separated with commas. Since I put each on their own separate line (for neatness's sake), I put a space and a backslash, \, after each. The entire define is enclosed in curly braces,{}. And then you're done with your shopkeeper's messages! =) Don't worry, it just gets simpler from here. =) Step 3: ---------- Now we get to decide when we want our shop to be open. We get to use military time, so 1 refers to 1am, 6 refers to 6am, 12 refers to 12pm (noon), 18 refers to 6pm, and both 0 and 24 refer to 12am (midnight).. etc.. =) And my define for this I named TAVERN_OPEN_TIMES (for when the tavern is open) and I used the following setup: #define TAVERN_OPEN_TIMES {"1","23"} You just have to make your define and stick your times in quotes and enclose them in curly braces. So Hogan will be opened from 1am ("1") until 11pm ("23"). He will close after 11pm and reopen again at 1am. And then your open times are complete =) Step 4: --------- For this step you get to choose your shopkeeper's trade types. And what you pick all depends on what kinds of things you want your shopkeeper to sell and buy. You can find the item types in values.h, but I'll also list them below. (These types are just what you get to choose from, and they are all defined in values.h) 1 ITEM_LIGHT 14 ITEM_TRAP 2 ITEM_SCROLL 15 ITEM_CONTAINER 3 ITEM_WAND 16 ITEM_NOTE 4 ITEM_STAFF 17 ITEM_DRINKCON 5 ITEM_WEAPON 18 ITEM_KEY 6 ITEM_FIREWEAPON 19 ITEM_FOOD 7 ITEM_MISSILE 20 ITEM_MONEY 8 ITEM_TREASURE 21 ITEM_PEN 9 ITEM_ARMOR 22 ITEM_BOAT 10 ITEM_POTION 23 ITEM_SPELL 11 ITEM_WORN 24 ITEM_BOOK 12 ITEM_OTHER 25 ITEM_SHIELD 13 ITEM_TRASH We are making a bartender, so he should sell food and drinks. So I selected ITEM_FOOD, and it's corresponding number is 19. So I made my define TAVERN_ITEM_TYPE (for our tavern's type of items) using the following setup: #define TAVERN_ITEM_TYPE "19" Now, if we had a magic shop, and wanted to sell potions and scrolls, I would make a define called for example MAGIC_ITEM_TYPE and make it like this... #define MAGIC_ITEM_TYPE "2 10" The 2 was our number corresponding to the scrolls, and the 10 corresponded to the potions. That is how you make your shopkeeper sell more than one item type, just stick the corresponding numbers inside quotes with a space separating them. =) And then you're all done with your item types! =) Step 5: ---------- (Not too many more, I promise =) You get to decide how much money your shopkeeper gets to have to buy things with. One platinum piece is equal to 40960. So if I wanted him to have two platinum pieces to spend on buying things from players, I would make a define called TAVERN_MAX_CASH (for the maxinum amount of money our shopkeeper gets) and use the following setup: #define TAVERN_MAX_CASH 81920 (I got 81920 by multiplying the 40960 (one platinum) by 2) And then you're all done with your max cash section =) Step 6: ---------- The sixth thing we get to do is to decide how much profit does our shopkeeper get when he sells his items. Items should have a cost to them already tagged on them, so their whatever their cost is, that is equal to 100%. Now, if your shopkeeper wants to take an extra 10% on the items he's selling so he can support his family, then you would make his selling profit 110. So I made a define called TAVERN_SELL_PROFIT (for his profit when he sells things) and gave him 110% selling profit, and used the following setup: #define TAVERN_SELL_PROFIT 110 And that's all you need to do for that =) Step 7: ----------- This last define is almost exactly like our selling profit, but now, we're doing our buying profit... when a player sells an item to the shopkeeper, he doesn't want to pay full price because it must be used since a player has it. Now the item's cost is 100%, and maybe the shopkeeper only wants to buy items for half its cost. So I would make his buying profit 50, and use the following setup. #define TAVERN_BUY_PROFIT 50 And then you're all done with your defines!!!!!!!!!!! =) [Took long enough, huh? =] All of those defines you can stick anywhere in the zone. I like to stick mine up before the %dil section just to keep them somewhere where I know they all are. You can stick each one on the mob iteself, but I think it looks kind of cluttered so that's why I put them where I put them. And you're going to have a dilcopy stuck on your mob also, which I'll explain now. =) Step 8: ---------- You thought you were finished didn't you?? =) *grin* Okay one last step. Now you get to stick the dil on your shopkeeper mob using all of those cute little defines you just made. The syntax for the dil is: dilcopy shopkeeper@function(products, responses, opentimes, tradetypes, sellprofit, buyprofit, maxcash, closedil, dilparams); Now I left out the explanation for closedil and dilparams because I've never used them, and would be making something up. There may be someone out there like Shai who wrote this neato dil that can explain them, but for now, I'll just show how I make them without using the closedil and dilparams. =) Take your defines from above.. the defines that you made are called: TAVERN_PROD, TAVERN_MSG, TAVERN_OPEN_TIMES, TAVERN_ITEM_TYPE, TAVERN_SELL_PROFIT, TAVERN_BUY_PROFIT, and TAVERN_MAX_CASH. Now all you have to do is stick them in the syntax where they belong like in the below example. dilcopy shopkeeper@function(TAVERN_PROD, TAVERN_MSG, TAVERN_OPEN_TIMES, TAVERN_ITEM_TYPE, TAVERN_SELL_PROFIT, TAVERN_BUY_PROFIT, TAVERN_MAX_CASH, "", ""); For the last two fields, I just put "", "" because I don't make my own unique dil for those. By just putting and empty set of quotes for each, it makes it go to the default. =) And make sure you don't forget that semicolon at the end either *grin* You are pretty much done now. All you have to do is stick your defines either up before %dil or somewhere in %mob if you'd like, and stick the dilcopy onto your mob. And just to make sure I've completely beaten a very dead horse, this is what it would look like in the end. =) %zone sample_zon #define TAVERN_PROD \ {"grain_alcohol@gobtown1 15 20", \ "pretzels@gobtown1 10 15", \ "beer_nuts@gobtown1 15 20", \ "rum_coke@gobtown1 10 15", \ "tuborg@udgaard 15 20"} #define TAVERN_MSG \ {"$1n says, 'This is a tavern, I don't sell such an item as that!'", \ "$1n says, '$3n, you don't even have that!'", \ "$1n says, 'I don't trade with things such as $2n! Just buy a beer!'", \ "$1n says, '$3n, you can't afford $2n.'", \ "$1n says, 'Thank you, $3n, here are %s for $2n.'", \ "$1n says, 'Thank you, $3n.'", \ "$1n says, 'I don't have that many $2ns in stock.'", \ "$1n says, 'I'm on break, come back later.'", \ "$1n says, 'I haven't got a use for $2n.'", \ "$1n says, 'I'd like to buy it, but I can't afford it, sorry.'"} \ #define TAVERN_OPEN_TIMES {"1","23"} #define TAVERN_ITEM_TYPE "19" #define TAVERN_MAX_CASH 81920 #define TAVERN_SELL_PROFIT 110 #define TAVERN_BUY_PROFIT 50 %mobiles bartender names {"hogan","goblin","bartender"} title "Hogan" descr "Hogan stands behind the bar waiting to take your order." extra {} "He looks back at you, patiently waiting for your order." M_AVG_GOBLIN(76,SEX_MALE) alignment -1000 exp 100 money 2 SILVER_PIECE, 2 COPPER_PIECE dilcopy shopkeeper@function(TAVERN_PROD, TAVERN_MSG, TAVERN_OPEN_TIMES, TAVERN_ITEM_TYPE,TAVERN_SELL_PROFIT, TAVERN_BUY_PROFIT, TAVERN_MAX_CASH, "", ""); end If anyone is still confused as to how in god's name we use this, you can email me at garubaja@icontech.com or just send it to malice@valhalla.com and it'll find me from there also. =) I hope it at least helped a teeny bit. =) - Jenn / Malice =