Difference between revisions of "Chapter 8"
MrSugarCube (talk | contribs) |
MrSugarCube (talk | contribs) |
||
Line 233: | Line 233: | ||
That's about all it takes to make a menu. Of course, you can put any commands you want after the ''ON='' section, and there can be much more than one line. In fact, for most menus, there will be. That was easy, wasn't it? :) | That's about all it takes to make a menu. Of course, you can put any commands you want after the ''ON='' section, and there can be much more than one line. In fact, for most menus, there will be. That was easy, wasn't it? :) | ||
+ | |||
+ | |||
+ | ==InsideUO== | ||
+ | UO comes with almost 4000 gumps. You aren't going to want to try each one in a script until you figure out which is which. You're going to need some sort of a program that shows you the gump. That program is InsideUO, which has come to be as useful to SPHERE scripting as a sword to a warrior. Here's a link to download it: | ||
+ | |||
+ | |||
+ | [http://uo.stratics.com/heptazane/insideuo/index.shtml Download InsideUO] | ||
+ | |||
+ | |||
+ | It's a zip file so you need WinZip or a similar tool to extract it. Unzip it to your main SPHERE directory (where SphereSvr.exe is). If you are running a Linux server, just unzip it to somewhere on your Windows computer. It doesn't run in Linux, sorry. Now, when you run the program, you will need to enter the paths of your MUL files. In most cases, that's your the folder where you installed UO (hopefully). Go to the View menu and select File Paths. Sometimes, it will automatically detect the location of your files, in which case you don't have to do anything. | ||
+ | |||
+ | |||
+ | Now, click on the GUMPS button along the sidebar and wait for it to load the index file. It will have a huge list of gumps from 00000001 to some other large number. Look down through them, write some interesting ones down, because you won't want to search back through the list every time you need a specific gump ID. | ||
+ | |||
+ | |||
+ | Also, you're going to be needing backgrounds, which come in 9 parts. I'll explain that when we get there, but if you see a series of items, which look like they'd fit together, write that down, because it would make an excellent background. | ||
+ | |||
+ | |||
+ | One more thing to note before we move on to the next section: The gump IDs you see here are in HEXADECIMAL. SPHERE will only accept gump IDs in decimal. This is one of those times when you need to break out the Windows Calculator and do some conversions. | ||
+ | |||
+ | |||
+ | '''Note:''' InsideUO is a popular tool for viewing the contents of the UO files but it is not the only one out there. Check out the [[Third Party Tools]] page for a list of other programs which you may want to use. |
Revision as of 10:15, 2 June 2009
(WIP)
Skill Menus
One of the most common requests by newbie admins is the ability to create new things via the craft skills. I've noticed that it is also one of the first things that players check out about a shard. If your shard has awesome craftable items, chances are the player will stick around longer and gain skill so he can see them. Craftable houses are the ultimate in cool. And this section will show you how to make one. First, we'll just look at how the crafting system works.
There are about 9 built-in section names, for each of the various crafting skills. This script is called from within the server, and if those sections don't exist, you will receive many scary errors. Here is the list, which I grabbed from the top of sphereskill.scp.
// Hard coded ref names: (called directly form server) // sm_alchemy = dclick on alch tools // sm_summon // sm_polymorph = polymorph menus // sm_cartography = dclick on blank map // sm_bowcraft = knife on wood // sm_bolts = dclick on arrows or shafts // sm_blacksmith = dclick on tool // sm_carpentry = dclick on carp tool // sm_tailor_leather = dclick on sewing kit // sm_tailor_cloth // sm_tinker = dclick on tinker tools. // sm_inscription = dclick on blank scroll // sm_cook = ??? NOT USED YET
Here is the syntax of a SKILLMENU section, like every other section in a SPHERE script:
[SKILLMENU sm_alchemy]
Now, a skill menu is the little box that pops up that contains the pictures of the items that you can scroll through and select. There are several attributes of this box which obviously need defined. The first is the title. It goes immediately underneath the [SKILLMENU] tag.
[SKILLMENU sm_alchemy] What sort of potion do you want to make?
That line will be displayed across the top of the menu, as the title. In the case of the alchemy skill, we simply want to ask the user what type of potion he wishes to make. The next parts of the script are a little shaky, and contain some new constructs that you may or may not recognize. In reality, it's just a series of events, which occur depending on which menu item the user picks. Here's the part of the rest of the alchemy script:
[SKILLMENU sm_alchemy] What sort of potion do you want to make? ON=i_potion_Agility <name> (<resmake>) MAKEITEM=i_potion_Agility ON=i_potion_AgilityGreat <name> (<resmake>) MAKEITEM=i_potion_AgilityGreat ON=i_potion_CureLess <name> (<resmake>) MAKEITEM=i_potion_CureLess ON=i_potion_Cure <name> (<resmake>) MAKEITEM=i_potion_Cure ON=i_potion_CureGreat <name> (<resmake>) MAKEITEM=i_potion_CureGreat ON=i_potion_ExplosionLess <name> (<resmake>) MAKEITEM=i_potion_ExplosionLess ON=i_potion_Explosion <name> (<resmake>) MAKEITEM=i_potion_Explosion ON=i_potion_ExplosionGreat <name> (<resmake>) MAKEITEM=i_potion_ExplosionGreat ON=i_potion_HealLess <name> (<resmake>) MAKEITEM=i_potion_HealLess
As you can see, we still use the ON= event construction for these menus as well. The different is what follows. Let's dissect it:
ON=i_potion_HealLess <name> (<resmake>)
This line tells the server a number of things. The first parameter, immediately following the = sign, is the ID of the item to display. So, what will be displayed here is the DISPID of the i_potion_HealLess item. It happens to be a yellow potion. As soon as you specify this item, it becomes the default item for the rest of that line. The server knows that <NAME> refers to the name of the potion item, and that <RESMAKE> is a string which tells what it takes to make that item. Both of those are specified in the script for i_potion_HealLess (which is in sphere_item_provisions_potions.scp) and can easily be changed there (looks for NAME= to change the name and SKILLMAKE= to change the skill and difficulty).
MAKEITEM=i_potion_HealLess
Well if this isn't obvious, you shouldn't be reading this chapter. It simply begins the construction of the specific item. Wait, you may be asking, how does the server know which skill to use or how much skill is required, or even what to consume (1 empty bottle) when creating this item. Well, I'm glad you asked. To answer that, we need to look at the script for the item we're constructing. Ah, here it is....
[ITEMDEF i_potion_HealLess] NAME=Lesser Heal ID=i_bottle_YELLOW RESOURCES=i_reag_ginseng, i_bottle_EMPTY SKILLMAKE=ALCHEMY 0.1 TYPE=T_POTION TDATA1=i_bottle_empty ON=@Create MORE1 = s_heal MORE2 = 50.0
The two important lines are the RESOURCES and SKILLMAKE lines. These two lines work with the skill system to tell SPHERE what items are used to make this item. Basically, it says that when you create the item, you need 1 i_reag_ginseng and 1 i_bottle_empty. Incidentally, if you don't have the resources to make an item, it won't even appear on the list when you look at the SKILLMENU in-game. The next line tells the server which and how much skill is required to make this item. In this case, it says we need 0.1 in the alchemy skill. It IS just a lesser heal, after all.
Take your new i_potion_HealLess to a store and try to sell it. Magically, it seems to have a price. Where did that price come from? Well, it came from the RESOURCES. The value of a lesser heal potion is the combined value of the i_reag_ginseng and the i_bottle_EMPTY. Both of these are defined in sphere_item_resources.scp. This brings us to a point so important, I am going to put it in bold: An item MUST have either a VALUE or resources with a VALUE, or it will not appear in a SKILLMENU! Many newbie scripters ask on the boards about why their item is not appearing in an otherwise perfect SKILLMENU section. It has nothing to do with the SKILLMENU. Look at your item scripts before whining to us on the boards.
Another important point is this: You may have any number of lines between ON= events in a [SKILLMENU] section. It just happens that MAKEITEM does everything for us that we need it to do, so most scripts only have one line. However, you could print out a SYSMESSAGE or KILL a player within a SKILLMENU, just as easily as you could do it in any other event.
Now that we know this fact, let's build that craftable house I was referring to! First, we need to figure out what sort of RESOURCES we might want to use to craft a house. I would say a large amount of wood, maybe some metal for a doorknob, a deed to write on, and some magic just for the heck of it. We'll take a resources like that looks like this:
RESOURCES=1000 i_board, 100 i_ingot_iron, 5 i_reag_garlic, i_deed
We also need a SKILLMAKE definition, and for this we'll use the Carpentry skill. Say, 95.0. Then we'll put those lines into the ITEMDEF for the deed we want to make craftable:
[ITEMDEF i_craftable_deed] ID=i_deed NAME=Deed to a Small Stone House RESOURCES=1000 i_board, 100 i_ingot_iron, 5 i_reag_garlic, i_deed SKILLMAKE=CARPENTRY 95.0 CATEGORY=Provisions - Deeds SUBSECTION=House Deeds DESCRIPTION=Small Stone House ON=@Create MORE1 = i_multi_house_stone_small
This, if you haven't figured it out, is a copy of item 04202, which has been renamed and edited. You can find the original script in sphere_item_deed.scp. Now, our item has a SKILLMAKE definition, and a VALUE definition (through the RESOURCES). It is craftable. We need to stick it into one of the existing Carpentry [SKILLMENU] sections now. Let's look at one of them:
[SKILLMENU sm_carpentry] Carpentry ON=i_board boards MAKEITEM=i_board ON=i_chair_throne Chairs SKILLMENU=sm_wood_chairs ON=i_chest_wooden_brass Containers & Shields SKILLMENU=sm_wood_containers_shields ON=i_table_nightstand Table SKILLMENU=sm_wood_tables ON=i_staff_gnarled Weapons & Tools SKILLMENU=sm_wood_weapons_tools ON=i_armoir_dk Furniture SKILLMENU=sm_wood_furniture ON=i_portrait_7 Paintings SKILLMENU=sm_wood_paintings ON=i_trophy_deerhead Trophies SKILLMENU=sm_wood_trophies ON=i_saddle Rancher Types SKILLMENU=sm_wood_rancher ON=i_BED_9 Beds SKILLMENU=sm_wood_beds ON=i_bulletin_board Miscellaneous SKILLMENU=sm_wood_misc
Like I said earlier, you can have any lines after an ON= section. In this case, it just happens to be a SKILLMENU line which opens up another menu. This is a hierarchical menu, because you choose from upper menu options like these, and go through lower menus, until you finally reach an item you can craft. Now, we're going to add the following two lines to the end of this script:
ON=i_craftable_deed <name> (<resmake>) MAKEITEM=i_craftable_deed
Guess what? We're done. That's all you need to do. Now, in most cases, you would make a new [SKILLMENU sm_houses] or something similar, and then add all of your items to that. In that case, the line you'd add to the main Carpentry menu (or one of the submenus) is the following:
ON=i_deed Craftable Houses SKILLMENU=sm_houses
That's all. Easy, isn't it? It's one of the easiest things to script, and one of the coolest. Unfortunately, it is so easy and repetitive that it takes FOREVER to make a good crafting system. If you are going to create one for your shard, start now. You should be finished in about a month. :)
Menus
If you paid attention in the previous section, this section should be very simple for you. It is so much easier to make a simple menu than a skillmenu. And, when you see how to read from buttons in a GUMP, you will see how similar it is to this. Basically, in SPHERE, there are occasions when you may want to bring up a menu for the user to choose from. Say, when they choose the "Help Desk from Hell" option on your help menu.
Do that. Right now. See how a menu pops up and asks if the user really wants to go to the help desk from hell? He can choose Yes, or No, and something different will happen in each case. Here's what the script for that menu might look like:
[MENU m_helpdesk] Do you REALLY want to go to the Help Desk from Hell? You will be stuck until a GM comes to free you! ON=0 Yes SRC.GO Help Desk from Hell ON=0 No SRC.SYSMESSAGE Help request cancelled. ON=0 I'm a monkey. Kill me. SRC.KILL
It looks awfully familiar, doesn't it? Here's what each part does. (I'll only take the first four lines, because the next ones are self-explanatory if you understand the first four.
[MENU m_helpdesk]
This is rather obvious. In a script, you would call this menu like this:
MENU m_helpdesk
Difficult eh? :)
Do you REALLY want...
Like the skillmenu, this is the title of this section. The next thing I am about to discuss will determine where it is displayed.
ON=0 Yes
Aha, this is the new part. Remember what the first parameter to this section in a [SKILLMENU] was? Well, it's the same thing. That is the ITEM ID that the menu is supposed to display. However, we don't want a scrolling item-based menu, but rather a menu where we can select an option from a list. When you put a 0 for the ITEM ID, SPHERE will automatically assume that you want to create a text-based MENU. However, the catch is, you must put 0 for EVERY SINGLE OPTION in your menu, or else you will get a scrolling item menu like a SKILLMENU. In our case, we want to give the user options in text format, because our menu wouldn't make much sense with scrolling items for its purposes.
SRC.GO Help Desk of Hell
You know what this does. I just want to point out that the user of the menu is SRC, and the default object is whatever the MENU was called upon.
That's about all it takes to make a menu. Of course, you can put any commands you want after the ON= section, and there can be much more than one line. In fact, for most menus, there will be. That was easy, wasn't it? :)
InsideUO
UO comes with almost 4000 gumps. You aren't going to want to try each one in a script until you figure out which is which. You're going to need some sort of a program that shows you the gump. That program is InsideUO, which has come to be as useful to SPHERE scripting as a sword to a warrior. Here's a link to download it:
It's a zip file so you need WinZip or a similar tool to extract it. Unzip it to your main SPHERE directory (where SphereSvr.exe is). If you are running a Linux server, just unzip it to somewhere on your Windows computer. It doesn't run in Linux, sorry. Now, when you run the program, you will need to enter the paths of your MUL files. In most cases, that's your the folder where you installed UO (hopefully). Go to the View menu and select File Paths. Sometimes, it will automatically detect the location of your files, in which case you don't have to do anything.
Now, click on the GUMPS button along the sidebar and wait for it to load the index file. It will have a huge list of gumps from 00000001 to some other large number. Look down through them, write some interesting ones down, because you won't want to search back through the list every time you need a specific gump ID.
Also, you're going to be needing backgrounds, which come in 9 parts. I'll explain that when we get there, but if you see a series of items, which look like they'd fit together, write that down, because it would make an excellent background.
One more thing to note before we move on to the next section: The gump IDs you see here are in HEXADECIMAL. SPHERE will only accept gump IDs in decimal. This is one of those times when you need to break out the Windows Calculator and do some conversions.
Note: InsideUO is a popular tool for viewing the contents of the UO files but it is not the only one out there. Check out the Third Party Tools page for a list of other programs which you may want to use.