Vorspire
Knight
New Shard Owners: Future Development Tips
Save yourselves hours of work by consolidating your multiple Item and Mobile scripts into one, easy-to-edit custom parent class...
If you're still interested in making development life easier for yourself in the long-run, follow these simple steps.
=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=
ITEMS - Derive BaseWeapon, BaseClothing, BaseJewelry, etc. from one manageable class...
Editing the Base Item scripts is very simple, all you have to do is change one single reference in each of the Base*.cs files related to Items, like BaseWeapon.cs, BaseArmor.cs BaseJewelry.cs and BaseClothing.cs.
In the steps below, BaseX will represent the Base Item class you are currently editing.
After you have finished editing all of your BaseX scripts, boot up your shard to check for errors.
(Visual Studio users can use F5 to debug the code)
If everything is working fine, congratulations, you're done...at least with Items anyway.
Now in the future, if you ever need to make a custom edit to BaseWeapon, BaseArmor, etc. and you find yourself duplicating the code, you should edit your BaseItem.cs file with the edits, they will be applied to anything that inherits BaseItem (Any classes you edited in the Inheritance steps).
Usually you would have to edit Item.cs in the Core to make global edits to all Items, now you don't have to.
=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=
MOBILES - Derive BaseVendor, BaseCreature, PlayerMobile, etc. from one manageable class...
Editing the Base Mobile scripts is very simple, all you have to do is change one single reference in each of the Base*.cs files related to Mobiles, like BaseVendor.cs, BaseCreature.cs and PlayerMobile.cs.
In the steps below, BaseX will represent the Base Mobile class you are currently editing.
After you have finished editing all of your BaseX scripts, boot up your shard to check for errors.
(Visual Studio users can use F5 to debug the code)
If everything is working fine, congratulations, you're done!
Now in the future, if you ever need to make a custom edit to BaseCreature, BaseVendor, PlayerMobile etc. and you find yourself duplicating the code, you should edit your BaseMobile.cs file with the edits, they will be applied to anything that inherits BaseMobile (Any classes you edited in the Inheritance steps).
Usually you would have to edit Mobile.cs in the Core to make global edits to all Mobiles, now you don't have to.
=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=
If you find any problems with this guide, please post your feedback here so I can make adequate corrections.
Haven't been on here in a while so I thought I'd bring you another 5-AM rambling, hope this helps and good luck
Save yourselves hours of work by consolidating your multiple Item and Mobile scripts into one, easy-to-edit custom parent class...
- Guide: Consolidate Your Future Edits (BaseItem, BaseMobile)
- Author: Vorspire
- Date: 5:25 AM, Saturday, August 7th, 2010
- Version: 1.0.A
- Content: Create, Open, Edit and Save multiple cs script files.
- Support: N/A
- Difficulty: 4/10 - Intermediate
If you're still interested in making development life easier for yourself in the long-run, follow these simple steps.
=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=
ITEMS - Derive BaseWeapon, BaseClothing, BaseJewelry, etc. from one manageable class...
- Create a new cs file and name it BaseItem.cs
- Move BaseItem.cs to your /RunUO/Scripts directory.
- Open BaseItem.cs with the text-editor of your choice.
- Copy and Paste the code below into BaseItem.cs - Make sure you select it all!
Rich (BB code):using System; using Server; using Server.Items; using Server.Mobiles; namespace Server { public abstract class BaseItem : Item { public BaseItem(int itemId) : base(itemId) { //Name = "Base Item"; } public BaseItem(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( ); //Version # switch( version ) { case 0: { } break; } } } }
- Save BaseItem.cs and close the text-editor.
Editing the Base Item scripts is very simple, all you have to do is change one single reference in each of the Base*.cs files related to Items, like BaseWeapon.cs, BaseArmor.cs BaseJewelry.cs and BaseClothing.cs.
In the steps below, BaseX will represent the Base Item class you are currently editing.
- Open your BaseX.cs file with your preferred text-editor.
- In the class declaration, you must change the inheritance from Item to BaseItem (See example below).
Rich (BB code):
using System;
using Server;
...
public class BaseX : Item --> BaseItem
{
...
}
}
After you have finished editing all of your BaseX scripts, boot up your shard to check for errors.
(Visual Studio users can use F5 to debug the code)
If everything is working fine, congratulations, you're done...at least with Items anyway.
Now in the future, if you ever need to make a custom edit to BaseWeapon, BaseArmor, etc. and you find yourself duplicating the code, you should edit your BaseItem.cs file with the edits, they will be applied to anything that inherits BaseItem (Any classes you edited in the Inheritance steps).
Usually you would have to edit Item.cs in the Core to make global edits to all Items, now you don't have to.
=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=
MOBILES - Derive BaseVendor, BaseCreature, PlayerMobile, etc. from one manageable class...
- Create a new cs file and name it BaseMobile.cs
- Move BaseMobile.cs to your /RunUO/Scripts directory.
- Open BaseMobile.cs with the text-editor of your choice.
- Copy and Paste the code below into BaseMobile.cs - Make sure you select it all!
Rich (BB code):using System; using Server; using Server.Items; using Server.Mobiles; namespace Server { public class BaseMobile : Mobile { [Constructable] public BaseMobile( ) : base() { Name = "Base Mobile"; } public BaseMobile(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( ); //Version # switch( version ) { case 0: { } break; } } } }
- Save BaseMobile.cs and close the text-editor.
Editing the Base Mobile scripts is very simple, all you have to do is change one single reference in each of the Base*.cs files related to Mobiles, like BaseVendor.cs, BaseCreature.cs and PlayerMobile.cs.
In the steps below, BaseX will represent the Base Mobile class you are currently editing.
- Open your BaseX.cs file with your preferred text-editor.
- In the class declaration, you must change the inheritance from Mobile to BaseMobile (See example below).
Rich (BB code):
using System;
using Server;
...
public class BaseX : Mobile --> BaseMobile
{
...
}
}
After you have finished editing all of your BaseX scripts, boot up your shard to check for errors.
(Visual Studio users can use F5 to debug the code)
If everything is working fine, congratulations, you're done!
Now in the future, if you ever need to make a custom edit to BaseCreature, BaseVendor, PlayerMobile etc. and you find yourself duplicating the code, you should edit your BaseMobile.cs file with the edits, they will be applied to anything that inherits BaseMobile (Any classes you edited in the Inheritance steps).
Usually you would have to edit Mobile.cs in the Core to make global edits to all Mobiles, now you don't have to.
=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=#-#=
If you find any problems with this guide, please post your feedback here so I can make adequate corrections.
Haven't been on here in a while so I thought I'd bring you another 5-AM rambling, hope this helps and good luck