Making the ore
Firstly, open
sphere_d_item_ore.scp. You will see something like:
[DEFNAME COLOR_ORE]
color_o_iron 0123
This is a defname. It's an easier way to remember something. You will also see them in items and characters as
DEFNAME=c_man or
DEFNAME=i_sword_long. What this is doing is assigning the name color_o_whatever to the number after it. So later on when you type
COLOR= you can simply put
COLOR=color_o_whatever instead of
COLOR=0123. For this exercise we are not going to edit default scripts, so open up a new empty script file called "
custom_ore.scp" and setup our own defname. We are going to make a custom ore called Pyrite, a metallic yellowish color.
[DEFNAME custom_ore]
color_o_pyrite 0789
Now, look at sphere_d_item_ore.scp again. Next thing you will see is an ore definition. We're going to add one to our custom script like so:
[ITEMDEF i_ore_pyrite]
ID=i_ore_iron
NAME="Pyrite Ore"
SKILLMAKE=MINING 100.0
TDATA1=i_ingot_pyrite
VALUE=9
CATEGORY=Items by Professions
SUBSECTION=Blacksmiths
DESCRIPTION=Ore (Pyrite)
ON=@Create
COLOR=color_o_pyrite
Now a quick line by line explanation of that. The
ITEMDEF says this script will be an item.
i_ore_pyrite is the name of this item script. You may be confused on numbers, that's ok, I was too at first. Older Sphere versions required you have like
[4009] and similar as your item script 'names'. Those were very difficult to navigate because who wants to remember what 4009 is? The newer scripting style let's you use any name you want for the item script name (and any other type of script for that matter). For this example we will use
i_ore_pyrite since it follows the pattern of all the other ore names.
You'll still see scripts using those numbers from old, and probably wonder why. For example, the iron ore script uses
[ITEMDEF 019b7]. 019b7 is the unique ID given to the graphic (the picture) for iron ore in your .mul files you get when installing Ultima Online. You don't have to know these numbers, don't panic. This tells Sphere to use that graphic for iron ore. Notice you've used
ITEMDEF i_ore_pyrite though, and therefore don't have a graphic assigned to your new ore. This is where the
ID= line comes in. If you have an
ID line in your script, Sphere knows to use that graphic for the item or npc script. In our case, we used
i_ore_iron for our ID. This tells Sphere to use the graphic
i_ore_iron for our pyrite ore. But wait you say, that's not a number! That's ok, because Sphere will now lookup the iron ore script to find the number. It's like a game of leap frog, if you use defnames (such as
i_ore_iron) in another script, Sphere leapfrogs back script to script until it finds that unique number, in this case
019b7, then assigns that graphic. I could also have easily used
ID=019b7 for our pyrite ore, but who wants to remember numbers? :) Be careful with using defnames that force Sphere to leapfrog back too many times. If Sphere has to go back over 16 or so scripts to find the real value of a defname, it will assume it's stuck in an infinite loop and error on you. This is Sphere's built-in protection against scripts going wild and running away with all your resources.
The
NAME= line of a script is just what it sounds like. The name of the item or npc. In our case we used
Pyrite ore. When you single click on the ore in game, it will show this name.
The
SKILLMAKE= line of a script is only needed if you plan to allow players to craft or make this item in game. In the case of ore, it's the skill required to dig it up. We will use
MINING 100.0. This means you need 100.0 in mining to be able to find this ore. If you wanted to require another skill in addition to mining, you could easily do that like:
SKILLMAKE=MINING 100.0, MAGERY 50.0 (this would require 100.0 mining and 50.0 magery to find the ore).
In the case of ore, we will need a
TDATA1= line. This is what the ore will turn into when smelted at a forge. We will want it to create
i_ingot_pyrite, our pyrite ingots we will make next. Different item scripts of different types will also require TDATA entries, many won't require them at all. You can find a great explanation of different
TDATA entries and their purposes at the Sphere Reference Project listed in the Links section of this help file.
The
VALUE= line of a script tells Sphere what it's value is, ie - how much it's worth. We want pyrite to be fairly valuable, so we used
9 for ours. Feel free to play around with these numbers and a vendor to sell the item to.
Next we want to be able to have our ore listed by Axis GM Tool, so we can add it more easily in game if we need to. The
CATEGORY,
SUBSECTION, and
DESCRIPTION lines are Axis entry lines.
CATEGORY will be the main place it shows up in Axis,
SUBSECTION will be the section inside
CATEGORY it will be listed under, and
DESCRIPTION will be the name that shows up for the actual item. You don't need these in a script, but if you want to make it with Axis you do.
Next we have
ON=@CREATE. This is a trigger that fires when the item or npc is created and sets certain variables on the item. Not everything is possible to set under
@Create, you cannot do most functions of scripting here, for example
IF statements are not allowed in this trigger. It's only for setting variables to the item or npc when it's created. You can change things like color, name, type, etc here. We want to set our ore to the color of pyrite ore as defined previously in our
DEFNAME, so we use
COLOR=color_o_pyrite.
Now we've got a finished and working ore script. But ore by itself is pretty useless, so we'll want to be able to do something with it, preferably smelt it into ingots :)
Making the ingots
Scroll down a little way in sphere_d_item_ore.scp and you will see the start of the ingot item scripts. We will want to make one of these in our
custom_ore.scp for our pyrite metal.
[ITEMDEF i_ingot_pyrite]
ID=i_ingot_iron
NAME="Pyrite Ingot"
RESOURCES=i_ore_pyrite
SKILLMAKE=MINING 100.0
TDATA1=90.0
TDATA2=110.0
CATEGORY=Items by Professions
SUBSECTION=Blacksmiths
DESCRIPTION=Pyrite Ingot
ON=@Create
COLOR=color_o_pyrite
We already know what most of this does from our ore script. The
ITEMDEF is the start of our item, and the name of the item script is
i_ingot_pyrite. The
ID is pointing to the iron ingot script, which has the unique graphic id for iron ingots (which is 01bef). The name is Pyrite Ingot, and the skill required to smelt it is 100.0 mining. We know that
CATEGORY,
SUBSECTION, and
DESCRIPTION are lines to add our script to Axis, and we know that we're setting the color to our pyrite metal color under
@Create. Now for the rest of it:
The
RESOURCES= line is telling us what other items are required to make this. In our case, you need pyrite ore in order to make pyrite ingots. Similarly, if we were making a bow, we would need to have a log or two. If we wanted to require more than one pyrite ore to make a single pyrite ingot, we could write it as:
RESOURCES=2 i_ore_pyrite, which would require 2 pyrite ore for a single pyrite ingot.
The
TDATA1 and
TDATA2 lines are again, different for each type of script. In an ingot script,
TDATA1 is the mining skill required to try to smelt ore into this ingot.
TDATA2 is the mining skill required to get the maximum amount of ingots per ore smelted, ie - if set to 110.0 as we have it, you will always end up failing and wasting some ore when smelting it unless you have 110.0 mining. You can learn further about
TDATAs for different items by reading the Sphere Reference Project listed in the Links section of this help file.
Making the the ore minable
Now that we have our ore and ingot scripts all ready to go, how do we mine them? Sphere won't know to let people mine up a custom ore simply because you have a custom ore. It has to be told that it is something minable. You do this by creating a region resource for it, and adding the resource to the regions you want it mined in. Scroll down even farther in
sphere_d_item_ore.scp and you will see the resource scripts. This is where your Sphere version is going to make a difference.
For version 55i yours will look like this:
[REGIONRESOURCE mr_pyrite]
SKILL_LO=95.0
SKILL_HI=100.0
AMOUNT_LO=3
AMOUNT_HI=8
REAP=i_ore_pyrite
REGEN=60*60*10
For version 99f and higher yours will look like this:
[REGIONRESOURCE mr_pyrite]
SKILL=95.0,100.0
AMOUNT=3,8
REAP=i_ore_pyrite
REAPAMOUNT=2,6
REGEN=60*60*10
The
REGIONRESOURCE signifies we are defining a resource script for a region.
mr_pyrite is what we will call this resource script. The
SKILL_LO and
SKILL_HI are the skill required to find the ore.
SKILL=x,x is the same thing, written on one line. First number is low, second is high.
AMOUNT_LO and
AMOUNT_HI are the amounts you will find in that vein of ore.
AMOUNT=x,x is the same thing, written on one line, low then high. You won't always find the same exact amount of ore in each vein you mine, it will be random depending on the amount.
REAP is what item you will get when you successfully mine it, in our case: pyrite ore.
REAPAMOUNT is how much you will get each time you mine, up to the total
AMOUNT.
REGEN is the amount of time it takes for the ore to respawn in that vein, in seconds.
Now we have a region resource, we need to tell Sphere where it should be located. You can close
sphere_d_item_ore.scp now, you are done referencing it and
custom_ore.scp, it is finished. Open
sphere_d_region.scp and scroll down about half way to
[REGIONTYPE r_default_rock t_rock]. This is similar to a typedef script, in that it's a set of triggers or events, only this is set on a region. You can add resources to a region here. The
r_default_rock is already placed on caves and other minable places in
sphere_d_map.scp, so all we'll need to do is add our new region resource to it.
[REGIONTYPE r_default_rock t_rock]
// other resources already listed go here
RESOURCES=10.0 mr_pyrite
You'll want to leave all the
mr_whatever lines already in it and add your new one at the bottom. The numbers are a weight given to your odds of finding it. I don't think they're actual percentages, I'm sure there's a magical calculation used to figure out what they literally do, but suffice to say.. the higher the number the more of that resource you will find. Feel free to adjust these numbers higher or lower to suit your shard's needs.
Since editing default files is not a great idea, I suggest you do as I did, and copy the entire
[REGIONTYPE] section you just modified, and place it in a custom script to load after the default
sphere_d_region.scp and your new
custom_ore.scp. This will replace the default regiontype entry.