|
||
|
|||||||
| RunUO Post Archive The Archvie |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Master of the Internet
|
This Was Written By Ashenfall
I just updated it for the forum changes which can mess you up no credit should be given to me at ALL! *DISCLAIMER!!!* This turtorial was written to provide a little guidance and suggest a way in which the default ores could be modified. THIS IS NOT EASY. If you are new to programming in C# or are looking for a "drop it in and go" solution, you've come to the wrong place. I suggest you find a scripter for your shard. If you are looking for a little help because you are stuck, or if you are eager to learn how the resource systems work in RunUO then read on... This tutorial may not be 100% accurate, but it worked for me! -10/10/03 Fixed a couple minor things for B35 -9/8/03 Added prospector tool changes. -As of Beta 34, this information is still accurate. Keep in mind, however, that you must follow all of the directions given. If you partially complete this tutorial, your scripts will not compile. Always be sure you have backups of all of your scripts before making any changes. -Updated for B28. Added basearmor and baseweapon changes. -As of Beta 26, adding new resources has changed a bit in RunUO. I struggled for a few days trying to figure out how to add new ores to my shard, and I finally think I figured it out... *-----------------------------------------------------------------------------------* First off, you'll need a good script editor. You can use wordpad or notepad, but I suggest using something called "UltraEdit". It does syntax hilighting and stuff for C#, but its most useful function is the find and replace features. I spent a couple years using it on Sphere shards, and it's even more useful on RunUO. Also, of course, you'll need the latest copy (Beta 26 at this time) of RunUO. As you work through the different sections, please be aware that simple things, like capitalization and ordering, are very important!. One simple mistake in puntuation or Capitalization could generate hundreds of errors when you try to compile. Take your time and be thorough. 1. Layout Make up a basic list of the new ore system you want, starting with the most common ore and ending with the least common one. Print it out, or use a second monitor to keep it open....you'll need to refer to this several times. 2. Oreinfo.cs Open Up \scripts\misc\oreinfo.cs. Find the section near the beginning that looks like this: Code:
namespace Server.Items
{
public enum CraftResource
{
None = 0,
Iron = 1,
DullCopper,
ShadowIron,
Copper,
Bronze,
Sandstone,
//added by soad: I found it very useful to write down the hue numbers i was going to use along with the names and order. // Scroll down until you find this section: Code:
public static rea donly CraftAttributeInfo Blank; public static readonly CraftAttributeInfo DullCopper, ShadowIron, Copper, Bronze, Golden, Agapite, Verite, Valorite; Scroll down a little into the very next section and look for some code that looks like this: Code:
static CraftAttributeInfo()
{
Blank = new CraftAttributeInfo();
CraftAttributeInfo dullCopper = DullCopper = new CraftAttributeInfo();
dullCopper.ArmorPhysicalResist = 6;
dullCopper.ArmorDurability = 50;
dullCopper.ArmorLowerRequirements = 20;
dullCopper.WeaponDurability = 100;
dullCopper.WeaponLowerRequirements = 50;
Scroll down a bit more, and you'll see a large block of code that looks like this: Code:
public class CraftResources
{
private static CraftResourceInfo[] m_MetalInfo = new CraftResourceInfo[]
{
new CraftResourceInfo( 0x000, 1053109, "Iron", CraftAttributeInfo.Blank, CraftResource.Iron, typeof( IronIngot ), typeof( IronOre ), typeof( Granite ) ),
new CraftResourceInfo( 0x973, 1053108, "Dull Copper", CraftAttributeInfo.DullCopper, CraftResource.DullCopper, typeof( DullCopperIngot ), typeof( DullCopperOre ), typeof( DullCopperGranite ) ),
new CraftResourceInfo( 0x966, 1053107, "Shadow Iron", CraftAttributeInfo.ShadowIron, CraftResource.ShadowIron, typeof( ShadowIronIngot ), typeof( ShadowIronOre ), typeof( ShadowIronGranite ) ),
new CraftResourceInfo( 0x96D, 1053106, "Copper", CraftAttributeInfo.Copper, CraftResource.Copper, typeof( CopperIngot ), typeof( CopperOre ), typeof( CopperGranite ) ),
new CraftResourceInfo( 0x972, 1053105, "Bronze", CraftAttributeInfo.Bronze, CraftResource.Bronze, typeof( BronzeIngot ), typeof( BronzeOre ), typeof( BronzeGranite ) ),
new CraftResourceInfo( 0x8AB, 0, "Sandstone", CraftAttributeInfo.Sandstone, CraftResource.Sandstone, typeof( SandstoneIngot ), typeof( SandstoneOre ), typeof( SandstoneGranite ) ),
Code:
new CraftResourceInfo( 0x96D, 1053106, "Copper", CraftAttributeInfo.Copper, CraftResource.Copper, typeof( CopperIngot ), typeof( CopperOre ), typeof( CopperGranite ) ), You'll need to add one of these lines for each new ore. When it comes to the CliLoc names for the new ores, use zero, and the server will use the common name instead. Here's an example: Code:
new CraftResourceInfo( 0x8AB, 0, "Sandstone", CraftAttributeInfo.Sandstone, CraftResource.Sandstone, typeof( SandstoneIngot ), typeof( SandstoneOre ), typeof( SandstoneGranite ) ), Code:
public static CraftResourceType GetType( CraftResource resource )
{
if ( resource >= CraftResource.Iron && resource <= CraftResource.Platinum )
return CraftResourceType.Metal;
Continuing along, there is this section: Code:
public static CraftResource GetFromOreInfo( OreInfo info )
{
if ( info.Name.IndexOf( "Spined" ) >= 0 )
return CraftResource.SpinedLeather;
else if ( info.Name.IndexOf( "Horned" ) >= 0 )
return CraftResource.HornedLeather;
else if ( info.Name.IndexOf( "Barbed" ) >= 0 )
return CraftResource.BarbedLeather;
else if ( info.Name.IndexOf( "Leather" ) >= 0 )
return CraftResource.RegularLeather;
if ( info.Level == 0 )
return CraftResource.Iron;
else if ( info.Level == 1 )
return CraftResource.DullCopper;
else if ( info.Level == 2 )
return CraftResource.ShadowIron;
else if ( info.Level == 3 )
return CraftResource.Copper;
else if ( info.Level == 4 )
return CraftResource.Bronze;
else if ( info.Level == 5 )
return CraftResource.Sandstone;
else if ( info.Level == 6 )
Finally, near the end of the script, there is a section like this: Code:
// NOTE: This class is only for compatability with very old RunUO versions.
// No changes to it should be required for custom resources.
public class OreInfo
{
public static readonly OreInfo Iron = new OreInfo( 0, 0x000, "Iron" );
public static readonly OreInfo DullCopper = new OreInfo( 1, 0x973, "Dull Copper" );
public static readonly OreInfo ShadowIron = new OreInfo( 2, 0x966, "Shadow Iron" );
public static readonly OreInfo Copper = new OreInfo( 3, 0x96D, "Copper" );
public static readonly OreInfo Bronze = new OreInfo( 4, 0x972, "Bronze" );
public static readonly OreInfo Sandstone = new OreInfo( 5, 0x8A5, "Sandstone" );
OreInfo(OreNumber,Hue,CommonName) Save your finished file into your custom script directory, erase or save your old script elsewhere (for backup). 3. Mining.cs Open \scripts\engines\harvest\mining.cs. Scroll till you see this: Code:
res = new HarvestResource[]
{
new HarvestResource( 00.0, 00.0, 100.0, 1007072, typeof( IronOre ), typeof( Granite ) ),//0
new HarvestResource( 30.0, 25.0, 105.0, 1007073, typeof( DullCopperOre ), typeof( DullCopperGranite ), typeof( DullCopperElemental ) ),//1
new HarvestResource( 35.0, 30.0, 110.0, 1007074, typeof( ShadowIronOre ), typeof( ShadowIronGranite ), typeof( ShadowIronElemental ) ),//2
new HarvestResource( 40.0, 35.0, 115.0, 1007075, typeof( CopperOre ), typeof( CopperGranite ), typeof( CopperElemental ) ),//3
new HarvestResource( 42.0, 40.0, 120.0, 1007076, typeof( BronzeOre ), typeof( BronzeGranite ), typeof( BronzeElemental ) ),//4
new HarvestResource( 44.0, 45.0, 125.0, "you dig some sandstone ore and put it in your backpack", typeof( SandstoneOre ), typeof( SandstoneGranite ), typeof( SandstoneElemental ) ),//5
HarvestResource=(necessaryskilltofind,minskill used for success, maxskill used for success, SuccessMessage, TypeofOre, TypeOfGranite, MonsterTypesAssociated) Fill in lines for all of your ores. The very next section deals with Veins and percent chance. Should look like this: Code:
veins = new HarvestVein[]
{
new HarvestVein( 16.0, 0.0, res[0], null ), // Iron
new HarvestVein( 7.0, 0.5, res[1], res[0] ), // Dull Copper
new HarvestVein( 6.0, 0.5, res[2], res[0] ), // Shadow Iron
new HarvestVein( 5.0, 0.5, res[3], res[0] ), // Copper
new HarvestVein( 5.0, 0.5, res[4], res[0] ), // Bronze
new HarvestVein( 4.5, 0.5, res[5], res[0] ), // Sandstone
new <Resource>(PercentChanceToFind,PercentChanceIfFoun dToInstead GetFallbackResource, ResourceToFind, FallbackResource) In the example above, There's a 5.0 percent chance to find copper ore, and a fifty percent chance that if you do find it, it will come out as iron ore anyways. Add your ores to the list, making sure that first argument (the percentage) adds up to 100 when you're done. Save your finished file into your custom script directory, erase or save your old script elsewhere (for backup). 4. Ore.cs Open up \scripts\items\resources\blacksmithing\ore.cs. This is where you'll actually define those piles of ore. Skip down to this section: Code:
case 0:
{
OreInfo info;
switch ( reader.ReadInt() )
{
case 0: info = OreInfo.Iron; break;
case 1: info = OreInfo.DullCopper; break;
case 2: info = OreInfo.ShadowIron; break;
case 3: info = OreInfo.Copper; break;
case 4: info = OreInfo.Bronze; break;
case 5: info = OreInfo.Sandstone; break;
Code:
public override int LabelNumber
{
get
{
if ( m_Resource >= CraftResource.DullCopper && m_Resource <= CraftResource.Platinum )
return 1042845 + (int)(m_Resource - CraftResource.DullCopper);
The next part requires a little math skill. Find this section: Code:
if ( targeted.GetType().IsDefined( typeof( ForgeAttribute ), false ) )
{
double maxSkill = 50 * ( 1 + ( (double)CraftResources.GetIndex( m_Ore.Resource ) / 32 ) );
double minSkill = maxSkill - 50;
Most of the rest of the file contains these large blocks of code that look like this: Code:
public class DullCopperOre : BaseOre
{
[Constructable]
public DullCopperOre() : this( 1 )
{
}
[Constructable]
public DullCopperOre( int amount ) : base( CraftResource.DullCopper, amount )
{
}
public DullCopperOre( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override Item Dupe( int amount )
{
return base.Dupe( new DullCopperOre( amount ), amount );
}
public override BaseIngot GetIngot()
{
return new DullCopperIngot();
}
5. Ingots.cs Open up \scripts\items\resources\blacksmithing\ingots.cs. This file is nearly identical to the Ore.cs file. Follow the same instructions you did in step 4 to set up your new ingots. 6.Granite.cs New granite types...If you wanted these in, like I did...Open up \scripts\items\resources\masonry\granite.cs. In this file there are chunks of code, similar to the ore and ingots that define the granite types. Copy and paste, then find and replace. 7. New Ore Elementals Open up an ore elemental script like \scripts\mobiles\monsters\Ore Elementals\copperelemental.cs. Do a find and replace on the whole file, replacing the word copper with the ore of your choice. Save the file as with a descriptive name in your custom scripts folder. Go back and edit it later when you're feeling more creative. 8. BS menu If everything went well up until this point, your shard should compile. If it doesn't compile, fix your problems. Your ores should now be minable. they should be smeltable. they should have the proper names, and proper colors. To make the new ores craftable into armor and weapons, you must add them to the blacksmith gump. Open up scripts\engines\craft\DefBlacksmithy.cs. Scroll down to near the end and you'll see something that looks kinda like this: Code:
// Add every material you want the player to be able to chose from // This will overide the overidable material AddSubRes( typeof( IronIngot ), "IRON", 00.0, 1044267 ); AddSubRes( typeof( DullCopperIngot ), "DULLCOPPER", 20.0, 1044268 ); AddSubRes( typeof( ShadowIronIngot ), "SHADOWIRON", 35.0, 1044268 ); AddSubRes( typeof( CopperIngot ), "COPPER", 40.0, 1044268 ); AddSubRes( typeof( BronzeIngot ), "BRONZE", 45.0, 1044268 ); AddSubRes( typeof( SandstoneIngot ), "SANDSTONE", 50.0, 1044268 ); 9. Basweapon.cs and Basearmor.cs Changes to these files are required if you want the name of the crafted armors to display properly, and to adjust for AR bonuses if you have AoS turned off. Here's a brief overview of what needs done... in Basearmor.cs Notice this section: Code:
switch ( m_Resource )
{
case CraftResource.DullCopper: ar += 2; break;
case CraftResource.ShadowIron: ar += 4; break;
case CraftResource.Copper: ar += 6; break;
case CraftResource.Bronze: ar += 8; break;
case CraftResource.Gold: ar += 10; break;
case CraftResource.Agapite: ar += 12; break;
case CraftResource.Verite: ar += 14; break;
case CraftResource.Valorite: ar += 16; break;
case CraftResource.SpinedLeather: ar += 10; break;
case CraftResource.HornedLeather: ar += 13; break;
case CraftResource.BarbedLeather: ar += 16; break;
Then there's this section: Code:
OreInfo info;
switch ( reader.ReadInt() )
{
default:
case 0: info = OreInfo.Iron; break;
case 1: info = OreInfo.DullCopper; break;
case 2: info = OreInfo.ShadowIron; break;
case 3: info = OreInfo.Copper; break;
case 4: info = OreInfo.Bronze; break;
case 5: info = OreInfo.Sandstone; break;
Finally, the really important part... Code:
public override void AddNameProperty( ObjectPropertyList list )
{
string oreType;//modified to use a string instead of the int
if ( Hue == 0 )
{
oreType = "";
}
else
{
switch ( m_Resource )
{
case CraftResource.DullCopper: oreType = "dull copper"; break; // dull copper
case CraftResource.ShadowIron: oreType = "shadow iron"; break; // shadow iron
case CraftResource.Copper: oreType = "copper"; break; // copper
case CraftResource.Bronze: oreType = "bronze"; break; // bronze
case CraftResource.Sandstone: oreType = "sandstone"; break; // sandstone
Code:
string oreType;//modified to use a string instead of the int
if ( Hue == 0 )
{
oreType = "";
At the end of those blocks of code, you'll see where it "assigns" the name to the armor. It looks a little like this: Code:
if ( m_Quality == ArmorQuality.Exceptional )
{
//if ( oreType != 0 )
list.Add( 1053100, "{0}\t{1}", oreType, GetNameString() ); // exceptional ~1_oretype~ ~2_armortype~
//else
// list.Add( 1050040, GetNameString() ); // exceptional ~1_ITEMNAME~
}
else
{
//if ( oreType != 0 )
list.Add( 1053099, "{0}\t{1}", oreType, GetNameString() ); // ~1_oretype~ ~2_armortype~
//else if ( Name == null )
// list.Add( LabelNumber );
//else
// list.Add( Name );
}
* You do the same thing for the AddNameProperty at the bottom of Baseweapon.cs. My AddNameProperty in BaseWeapon.cs looks like this: Code:
public override void AddNameProperty( ObjectPropertyList list )
{
string oreType;//changed from int to string
if ( Hue == 0 )
{
oreType = "";
}
else
{
switch ( m_Resource )
{
case CraftResource.DullCopper: oreType = "dull copper"; break; // dull copper
case CraftResource.ShadowIron: oreType = "shadow iron"; break; // shadow iron
case CraftResource.Copper: oreType = "copper"; break; // copper
case CraftResource.Bronze: oreType = "bronze"; break; // bronze
case CraftResource.Sandstone: oreType = "sandstone"; break; // sandstone
case CraftResource.Silver: oreType = "silver"; break; // silver
case CraftResource.Gold: oreType = "golden"; break; // golden
case CraftResource.Opal: oreType = "opal"; break; // opal
case CraftResource.Rain: oreType = "rain"; break; // rain
case CraftResource.Magnus: oreType = "magnus"; break; // magnus
case CraftResource.Obsidian: oreType = "obsidian"; break; // obsidian
case CraftResource.Moonstone: oreType = "moonstone"; break; // moonstone
case CraftResource.Amethyst: oreType = "amethyst"; break; // amethyst
case CraftResource.Flourine: oreType = "flourine"; break; // flourine
case CraftResource.Elven: oreType = "elven"; break; // elven
case CraftResource.Bloodstone: oreType = "bloodstone"; break; // bloodstone
case CraftResource.Blackrock: oreType = "blackrock"; break; // blackrock
case CraftResource.Mithryl: oreType = "mithryl"; break; // mithryl
case CraftResource.Jade: oreType = "jade"; break; // jade
case CraftResource.Agapite: oreType = "agapite"; break; // agapite
case CraftResource.Sunstone: oreType = "sunstone"; break; // sunstone
case CraftResource.Verite: oreType = "verite"; break; // verite
case CraftResource.Hematite: oreType = "hematite"; break; // hematite
case CraftResource.Bluerock: oreType = "bluerock"; break; // bluerock
case CraftResource.Phantom: oreType = "phantom"; break; // phantom
case CraftResource.Valorite: oreType = "valorite"; break; // valorite
case CraftResource.Anubis: oreType = "anubis"; break; // anubis
case CraftResource.Phoenix: oreType = "phoenix"; break; // phoenix
case CraftResource.Divine: oreType = "divine"; break; // divine
case CraftResource.Platinum: oreType = "platinum"; break; // platinum
case CraftResource.SpinedLeather: oreType = "spined"; break; // spined
case CraftResource.HornedLeather: oreType = "horned"; break; // horned
case CraftResource.BarbedLeather: oreType = "barbed"; break; // barbed
default: oreType = ""; break;
}
}
//if ( oreType != 0 )
list.Add( 1053099, "{0}\t{1}", oreType, GetNameString() ); // ~1_oretype~ ~2_armortype~
//else if ( Name == null )
// list.Add( LabelNumber );
//else
// list.Add( Name );
}
Code:
public virtual CraftResource DefaultResource{ get{ return CraftResource.Iron; } }
10. Prospector tool changes //added by soad: Prospectors Tool is in scripts/items/skill items/harvest tools (i had a hard time finding it) The ProspectorTool.cs file is fairly easy to change. Look for this section: Code:
else if ( veinIndex >= (def.Veins.Length - 1) )
{
from.SendLocalizedMessage( 1049061 ); // You cannot improve valorite ore through prospecting.
}
else
{
bank.Vein = def.Veins[veinIndex + 1];
from.SendLocalizedMessage( 1049050 + veinIndex );
--UsesRemaining;
if ( UsesRemaining <= 0 )
{
from.SendLocalizedMessage( 1049062 ); // You have used up your prospector's tool.
Delete();
}
}
Code:
else if ( veinIndex >= (def.Veins.Length - 1) )
{
from.SendMessage( "You cannot improve Platinum ore through prospecting." ); // You cannot improve valorite ore through prospecting.
}
Code:
bank.Vein = def.Veins[veinIndex + 1];
//from.SendLocalizedMessage( 1049050 + veinIndex );
switch ( veinIndex )
{
case 0: from.SendLocalizedMessage( 1049050 ); break;//Dull Copper
case 1: from.SendLocalizedMessage( 1049051 ); break;//Shadow Iron
case 2: from.SendLocalizedMessage( 1049052 ); break;//Copper
case 3: from.SendLocalizedMessage( 1049053 ); break;//Bronze
case 4: from.SendMessage( "You sift through the ore and find sandstone ore can be mined there" ); break;
case 5: from.SendMessage( "You sift through the ore and find silver ore can be mined there" ); break;
case 6: from.SendLocalizedMessage( 1049054 ); break;//Gold
Enjoy!!! // Added by soad: Also if you would like to customize the tinker menu then go to DefTinkering.cs (should be same place as defblacksmithy.cs was) then follow the same steps. However since you get no bonuses from this I just delete all except iron ![]() ENJOY!!! |
|
|
|
|
|
#3 (permalink) |
|
Forum Newbie
Join Date: Feb 2006
Posts: 18
|
This is a cool script and I like the new leather types.
I'm trying to learn how to script and I am going through them by example. I wanted to add a few twist to the leather attributes, like +5 to hiding or something like that. I'm trying to figure out how to do it. For example: Looking at the dull copper "dullCopper.ArmorPhysicalResist = 6;" that AshenFall did. That line gives the AR PR 6. I'm trying to find what command would corepond to for a skill base increase like the ArmorPhysicalResist? The reason I ask is, because I search up and down RunUO cannot find any script example that relates to ArmorPhysicalResist. Hence I cannot use that example to make armor to add Skill increase. I did find CraftResourceInfo that have ArmorPhysicalResist listed in there. Could this be the file to change/modify? Thank in advance in reading this, any info shared is a learning experience for me. ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|