RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Xml Level Items

LordHogFred

Knight
This system is a replica of the level item system written by dracana.
I take no credit for any of the inner workings of the system, nor for the idea of the system.
For information on the system please see the original thread: HERE.
This modification also requires that you are using the Xml Spawner which can be found: HERE.

I have modified the system to work via Xml Attachments instead of requiring items to be specifically defined as level items. If the XmlLevelItem attachment is added to any item it will start acting like a level item.
The uploaded archive contains the XmlLevelItem attachment and the original system scripts modified to work with the xml attachment.

For the system to work correctly the following changes to BaseWeapons.cs, BaseArmor.cs, BaseClothing.cs and BaseJewel.cs are needed.

At the top of each of the scripts add:
Code:
using Server.Engines.XmlSpawner2;

In each of the scripts find:
Code:
        [CommandProperty( AccessLevel.GameMaster )]
        public int MaxHitPoints
        {
            get{ return m_MaxHitPoints; }
            set{ m_MaxHitPoints = value; InvalidateProperties(); }
        }

Above it add:
Code:
        public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
        {
            base.GetContextMenuEntries(from, list);

            XmlLevelItem levitem = XmlAttach.FindAttachment(this, typeof(XmlLevelItem)) as XmlLevelItem;

            if (levitem != null)
            {
                list.Add(new LevelInfoEntry(from, this, AttributeCategory.Melee));
            }
        }

Hopefully this will make using and distributing level items much easier.

Enjoy :)
 

Attachments

  • XmlLevelItems.zip
    14.8 KB · Views: 204

Iraq-

Sorceror
**ERROR FIXXED** Read Down Further

Code:
Errors:
+ Customs/My Customs/XmlLevelItems/XmlLevelItem.cs:
    CS0103: Line 23: The name 'ChangeName' does not exist in the current context

I really like the concept of using this system as an XmlAttachment. I can't find any method called ChangeName anywhere (except for where it's called). Perhaps something wasn't included?

*Temporarily Fixed this by just commenting out the ChangeName method call... Since I don't know the effect this will have, I'd like to uncomment it in the future when perhaps you can shed to light on what the ChangeName method should look like. - Thanks.
 

Iraq-

Sorceror
Yeah, I'm guessing that too. I'm not exactly surehow to attach the xmllevelitem attachment to the peices of armor/clothes/weapons/jewels, though still. Or I'd test it out by now. I tried [addatt xmllevelitem, but it came back with "Attachment xmllevelitem not added".
 

Iraq-

Sorceror
Thanks, that did work. Also, I got [AddAtt XMLLevelItem to work, just not on any items that were already created before I've added this system. Dunno what's with that.

Also, tried leveling the item, but no experience was gained. I'm assuming I'll need to follow the directions on the original versions OP.

* Yep, got to add the stuff from OP to BaseCreature. -- Mine works now.
* Also, the [addatt xmllevelitem wasn't working because I was using it on Clothing, you'll need to change your scripts to allow BaseClothing to work as well.
* Other thoughts: BaseShield should also be added to both scripts, if you want them too. <-- BaseShield derives from BaseArmor, so an edit there is unnecessary!

Last Problems:
1) Level-related properties are not displaying on mouse over. (level, exp). [I've got the settings set "true" to display.]
2) My settings are not being recognized.. I've got starting maxlevel set to 10 in settings, yet it starts with maxlevel at 100.

Fixed the level items starting with maxlevel being incorrect. The default constructor is this package is adding the level attachment with a default maxlevel set to 200, and if the maxlevel was > the capmaxlevel, then it would get set down to the capmaxlevel. Since I had my capmaxlevel at 100, and the default constructor's maxlevel was 200, it was cutting it back to 100. To fix this, simply change the default constructor (in XmlLevelItem.cs) to 10. (or even better, change it to LevelItems.MaxLevel).

* Only one problem still persists! Level-related properties are not displaying. (level/exp).

Fixed the displaying of level-related properties on mouse over. :D To do this, simply go back into each of the Base files that you've edited (armor, weapon, clothing, and jewel), and edit inside of the "public override void GetProperties( ObjectPropertyList list )" after "base.GetProperties( list );" insert this:
Code:
                    XmlLevelItem levitem = XmlAttach.FindAttachment(this, typeof(XmlLevelItem)) as XmlLevelItem;

                    if (levitem != null)
                    {
                        /* Display level in the properties context menu.
                        * Will display experience as well, if DisplayExpProp.
                        * is set to true in LevelItemManager.cs */
                        list.Add(1060658, "Level\t{0}", levitem.Level);
                        if (LevelItems.DisplayExpProp)
                            list.Add(1060659, "Experience\t{0}", levitem.Experience);
                }

*Note: The level will display in different locations on the items depending on where you place the above code within the GetProperties method. I've placed mine at the top, above the rest of the attributes because it seems much more fluid than if you place it at the bottom.

Another thing I've found is that the DoubleArtifactCost has been altered. Here is the GetPointCost method you should have in your ItemExperienceGump.cs:
Code:
        public static int GetPointCost(Item m_Item, int xp)
        {
            int cost = xp;

            if (LevelItems.DoubleArtifactCost)
            {
                if (m_Item is BaseWeapon)
                {
                    if (((BaseWeapon)m_Item).ArtifactRarity >= 10)
                        cost *= 2;
                }
                else if (m_Item is BaseArmor)
                {
                    if (((BaseArmor)m_Item).ArtifactRarity >= 10)
                        cost *= 2;
                }
                else if (m_Item is BaseJewel)
                {
                    if (((BaseJewel)m_Item).ArtifactRarity >= 10)
                        cost *= 2;
                }
                else
                {
                    if (((BaseClothing)m_Item).ArtifactRarity >= 10)
                        cost *= 2;
                }
            }

            return cost;
        }

Without altering the above method, the systems default is cost*=3, and only applies to artifactrartiy >= 55.

And there you have it :D This system is now fully functioning! I've been sure to explain my processes in full and leave my original problems intact so that you guys can also succeed with this system. :)

Enjoy!
 

Tresdni

Squire
I'm having the same issue with the level not showing on the item (don't really mind the xp not showing, since it shows in the information gump).

What I did, was had the system add the attachment onequip, so no worry to have to spawn each item, or distribute them. They all simply have it attached on their own.
 

LordHogFred

Knight
Sorry about the hiccups guys.
I thought I'd removed all my custom methods from it. The ChangeName method should be fine to remove, all it does is change the name of the weapon to have a different prefix based on it's level. I used the cliloc string building stuff from the Ultima.dll in order to get that stuff working, so have a look at implementing that if you want to keep it (there's a post on it somewhere, I'll post it when I can find it).
Also thanks to Iraq- for the hotfix :).
 

Tresdni

Squire
Tried your fix...but this happens.

Errors:
+ Items/Weapons/BaseWeapon.cs:
CS1501: Line 196: No overload for method 'Add' takes '4' arguments
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

Iraq-

Sorceror
I've added one more fix to this system to allow for the DoubleArtifactCost to work. Read Post #7!

@Tresdni: My fix has only 3 arguments in the add method. Since yours is saying '4' perhaps something got jumbled up upon implementation?

Thanks for the response LordHogFred. We figured that was the case. All is well. On a semi-related note, I saw on the boards you said you wrote the deed to attach the xmlattachment for xmllevelitem to any item. If you did, could you post it here for all of us? It'd save us about 10 minutes :D
 

Iraq-

Sorceror
While I was messing around with XMLQuestNpc I found something today for you to check out Tresdni:
Code:
STEP 11: (recommended but not required)
---------------------------------------
To allow attachment properties on weapons/armor to be automatically displayed in the properties list on mouseover/click, these changes must be made to BaseWeapon.cs (Scripts/Items/Weapons/BaseWeapon.cs), BaseArmor.cs (Scripts/Items/Armor/BaseArmor.cs) and BaseJewel.cs (Scripts/Items/Jewels/BaseJewel.cs) described below. (note, you dont have to make this mod if you dont want to, the spawner and other items will work just fine without it, players just wont automatically see attachment properties on items with attachments).

That's step #11 in xmlspawner2 installation process. If your problem is still persisting, perhaps make sure you've got these mods on your server.
 

Iraq-

Sorceror
Here you go.

This deed will make the item (armor/weapon/jewel/clothing) levelable if it isn't already, and then delete itself.
It also checks to make sure it's in the players backpack, and the targeted item is either equipped or in their backpack.
 

Attachments

  • LevelItemDeed.cs
    2.5 KB · Views: 84

Johan Smith

Wanderer
Heyas, I'm trying this out on a clean install of RunUO 2.0 Final along with the appropriate XML Spawner and this is what i'm getting when I try to fire up the server:

Code:
RunUO - [www.runuo.com] Version 2.0, Build 3567.2838
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (4 errors, 0 warnings)
Errors:
+ Items/Armor/BaseArmor.cs:
    CS0246: Line 281: The type or namespace name 'ContextMenuEntry' could not be
found (are you missing a using directive or an assembly reference?)
+ Items/Clothing/BaseClothing.cs:
    CS0246: Line 61: The type or namespace name 'ContextMenuEntry' could not be
found (are you missing a using directive or an assembly reference?)
+ Items/Jewels/BaseJewel.cs:
    CS0246: Line 33: The type or namespace name 'ContextMenuEntry' could not be
found (are you missing a using directive or an assembly reference?)
    CS0246: Line 33: The type or namespace name 'List' could not be found (are y
ou missing a using directive or an assembly reference?)
+ Items/Weapons/BaseWeapon.cs:
    CS0246: Line 230: The type or namespace name 'ContextMenuEntry' could not be
found (are you missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

I took a look at line 33 for my BaseJewel.cs file and this is what i come up with (I've truncated the file so not to bombard with probably useless info):

Code:
using System;
using Server.Engines.Craft;
using Server.Engines.XmlSpawner2;

namespace Server.Items
{
    public enum GemType
    {
        None,
        StarSapphire,
        Emerald,
        Sapphire,
        Ruby,
        Citrine,
        Amethyst,
        Tourmaline,
        Amber,
        Diamond
    }

    public abstract class BaseJewel : Item, ICraftable
    {
        private int m_MaxHitPoints;
        private int m_HitPoints;

        private AosAttributes m_AosAttributes;
        private AosElementAttributes m_AosResistances;
        private AosSkillBonuses m_AosSkillBonuses;
        private CraftResource m_Resource;
        private GemType m_GemType;
 
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
        {
            base.GetContextMenuEntries(from, list);

            XmlLevelItem levitem = XmlAttach.FindAttachment(this, typeof(XmlLevelItem)) as XmlLevelItem;

            if (levitem != null)
            {
                list.Add(new LevelInfoEntry(from, this, AttributeCategory.Melee));
            }
        }
 
        [CommandProperty( AccessLevel.GameMaster )]
        public int MaxHitPoints
        {
            get{ return m_MaxHitPoints; }
            set{ m_MaxHitPoints = value; InvalidateProperties(); }
        }

        [CommandProperty( AccessLevel.GameMaster )]
        public int HitPoints
        {
            get
            {
                return m_HitPoints;
            }
            set
            {
                if ( value != m_HitPoints && MaxHitPoints > 0 )
                {
                    m_HitPoints = value;

                    if ( m_HitPoints < 0 )
                        Delete();
                    else if ( m_HitPoints > MaxHitPoints )
                        m_HitPoints = MaxHitPoints;

                    InvalidateProperties();
                }
            }
        }

I'm still green to coding so I'm not sure what I could be missing with ContextMenuEntry. Any ideas?

-Johan
 

Iraq-

Sorceror
Change the top to this:
Code:
using System;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Items;
using Server.Engines.Craft;
using Server.Engines.XmlSpawner2;
 
Top