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!

[RunUO 2.0 RC1] Levelable Items System 3.0

Lord Dio

Sorceror
Orbit Storm;841280 said:
...Is there any way to restrict items that are levelable, to weapons only? Or at the very least.. remove the 'item is levelable' part of the code, and require a "item level deed" to make it levelable?

I'd much rather have all my armor/weapons/jewelry/etc remain the same; while adding a deed that when dbl-clicked, uses a targeting function and will make any item targeted, levelable...

I like this idea as well. Has anyone accomplished this yet?
 

Orbit Storm

Sorceror
Hehe.. still looking for it as well.

I love the idea of this system, still; but I hate the thought of every one of my players having tons of levelable gear.. I do believe that would make my server a bit too over-powered.

Not to mention; this system, as-is.. would completely ruin the value of systems like Daat99's OWLTR.. Granted, you don't HAVE to incorporate every item as levelable.. but what is the point of having just a few, and then editing lootpacks? It'd be much nicer to have a simple script, that permits players to make an item levelable, via an in-game deed. I've seen that sort of method on several servers; but never seen anything released.
 

Lord Dio

Sorceror
I by no means am a great or even a good scripter, but I'm trying to mess around with this idea and come up with something. I added the level system script data to my BaseBashing to test it on a variety of weapons instead of a single weapon. I'm sure you could probably just add the data to BaseWeapon and not have to add it to every single weapon or weapon type script.

I also added an extra bit of code that I would use for "enabling" leveling on a weapon. "CanLevel = true/false"

BaseBashing.cs
Code:
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Mobiles;
using Server.ContextMenus;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;

namespace Server.Items
{
	public abstract class BaseBashing : BaseMeleeWeapon, ILevelable
	{
		public override int DefHitSound{ get{ return 0x233; } }
		public override int DefMissSound{ get{ return 0x239; } }

		public override SkillName DefSkill{ get{ return SkillName.Macing; } }
		public override WeaponType DefType{ get{ return WeaponType.Bashing; } }
		public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.Bash1H; } }

        //edit
        /* These private variables store the exp, level, and *
         * points for the item */
        private int m_Experience;
        private int m_Level;
        private int m_Points;
        private int m_MaxLevel;

        [COLOR="RoyalBlue"]private bool m_CanLevel = false;[/COLOR]

        //end

		public BaseBashing( int itemID ) : base( itemID )
		{
            //edit
            MaxLevel = LevelItems.DefaultMaxLevel;

            /* Invalidate the level and refresh the item props
             * Extremely important to call this method */
            LevelItemManager.InvalidateLevel(this);
            //end
		}

		public BaseBashing( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

            writer.Write((int)1);

            // Version 1
            writer.Write(m_MaxLevel);

            // Version 0
            // DONT FORGET TO SERIALIZE LEVEL, EXPERIENCE, AND POINTS
            writer.Write(m_Experience);
            writer.Write(m_Level);
            writer.Write(m_Points);
            
            [COLOR="RoyalBlue"]writer.Write((bool)m_CanLevel);[/COLOR]
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

            switch (version)
            {
                case 1:
                    {
                        m_MaxLevel = reader.ReadInt();

                        goto case 0;
                    }
                case 0:
                    {
                        // DONT FORGET TO DESERIALIZE LEVEL, EXPERIENCE, AND POINTS
                        m_Experience = reader.ReadInt();
                        m_Level = reader.ReadInt();
                        m_Points = reader.ReadInt();
                        
                        [COLOR="RoyalBlue"]m_CanLevel = (bool)reader.ReadBool();[/COLOR]

                        break;
                    }
            }
		}

		public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
		{
			base.OnHit( attacker, defender, damageBonus );

			defender.Stam -= Utility.Random( 3, 3 ); // 3-5 points of stamina loss
		}

		public override double GetBaseDamage( Mobile attacker )
		{
			double damage = base.GetBaseDamage( attacker );

			if ( !Core.AOS && (attacker.Player || attacker.Body.IsHuman) && Layer == Layer.TwoHanded && (attacker.Skills[SkillName.Anatomy].Value / 400.0) >= Utility.RandomDouble() )
			{
				damage *= 1.5;

				attacker.SendMessage( "You deliver a crushing blow!" ); // Is this not localized?
				attacker.PlaySound( 0x11C );
			}

			return damage;
		}

        //start level stuff
        #region level stuff
 
        public override void GetProperties(ObjectPropertyList list)
        {


                base.GetProperties(list);

              
                
                /* 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}", m_Level);


                if (LevelItems.DisplayExpProp)
                    list.Add(1060659, "Experience\t{0}", m_Experience);
            
        }

        public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
        {

                base.GetContextMenuEntries(from, list);

               
                
                /* Context Menu Entry to display the gump w/
                 * all info */

                list.Add(new LevelInfoEntry(from, this, AttributeCategory.Melee));
                
        }

        // ILevelable Members that MUST be implemented
        #region ILevelable Members

        // This one will return our private m_MaxLevel variable.
        [CommandProperty(AccessLevel.GameMaster)]
        public int MaxLevel
        {
            get
            {
                return m_MaxLevel;
            }
            set
            {
                // This keeps gms from setting the level to an outrageous value
                if (value > LevelItems.MaxLevelsCap)
                    value = LevelItems.MaxLevelsCap;

                // This keeps gms from setting the level to 0 or a negative value
                if (value < 1)
                    value = 1;

                // Sets new level.
                if (m_MaxLevel != value)
                {
                    m_MaxLevel = value;
                }
            }
        }

        // This one will return our private m_Experience variable.
        [CommandProperty(AccessLevel.GameMaster)]
        public int Experience
        {
            get
            {
                return m_Experience;
            }
            set
            {
                m_Experience = value;

                // This keeps gms from setting the level to an outrageous value
                if (m_Experience > LevelItemManager.ExpTable[LevelItems.MaxLevelsCap - 1])
                    m_Experience = LevelItemManager.ExpTable[LevelItems.MaxLevelsCap - 1];

                // Anytime exp is changed, call this method
                LevelItemManager.InvalidateLevel(this);
            }
        }

        // This one will return our private m_Level variable.
        [CommandProperty(AccessLevel.GameMaster)]
        public int Level
        {
            get
            {
                return m_Level;
            }
            set
            {
                // This keeps gms from setting the level to an outrageous value
                if (value > LevelItems.MaxLevelsCap)
                    value = LevelItems.MaxLevelsCap;

                // This keeps gms from setting the level to 0 or a negative value
                if (value < 1)
                    value = 1;

                // Sets new level.
                if (m_Level != value)
                {
                    m_Level = value;
                }
            }
        }

        // This one will return our private m_Points variable.
        [CommandProperty(AccessLevel.GameMaster)]
        public int Points
        {
            get
            {
                return m_Points;
            }
            set
            {
                //Sets new points.
                m_Points = value;
            }
        }

        [CommandProperty(AccessLevel.GameMaster)]
        public bool CanLevel
        {
            get { return m_CanLevel; }
            set { m_CanLevel = value; }
        }

        #endregion
    } 
        #endregion
    //end level stuff
}

Then I tried creating a deed basically based off of the spell channeling deed:
ItemLevelDeed.cs
Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server;

namespace Server.Items
{
    public class ItemLevelTarget : Target
    {
        private ItemLevelDeed m_Deed;

        public ItemLevelTarget(ItemLevelDeed deed)
            : base(1, false, TargetFlags.None)
        {
            m_Deed = deed;
        }

        protected override void OnTarget(Mobile from, object target)
        {
            if (target is BaseWeapon)
            {
                Item item = (Item)target;
                if (item is BaseWeapon)
                {
                    if (m_CanLevel = true) from.SendMessage("This item is already levelable!");
                    else
                    {
                        if (item.RootParent != from) from.SendMessage("The item must be in your pack.");
                        else
                        {
                            m_CanLevel = true;
                            from.SendMessage("You apply the level deed.");
                            m_Deed.Delete();
                        }
                    }
                }
            }
            else from.SendMessage("You can not apply this deed to that");
        }
    }

    public class ItemLevelDeed : Item
    {
        [Constructable]
        public ItemLevelDeed()
            : base(0x14F0)
        {
            Name = "an item level deed";
            Hue = 0x492;
        }

        public ItemLevelDeed(Serial serial) : base(serial) { }
        public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); }
        public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); }

        public override bool DisplayLootType { get { return false; } }

        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack)) from.SendLocalizedMessage(1042001);
            else
            {
                from.SendMessage("Target the item you want to make levelable");
                from.Target = new ItemLevelTarget(this);
            }
        }
    }
}

The problem I'm running into is, what bit of code do I need to restrict to keep all basebashing weapons from being levelable before applying the deed to them.

I was thinking something like this in basecreature:
Code:
   if ( !Summoned && !IsDeadBondedPet && willKill && (BaseWeapon).m_CanLevel = true )
    LevelItemManager.CheckItems( from, this );

I don't even know if that code would work,but that's the general idea. However, that would only not allow the weapon to actually level. You would still see the info in the weapons details and be able to access the level gump.

any ideas?
 

Orbit Storm

Sorceror
Well.. I'm not the greatest of scripters either; but I'll look at it and do some research..

It'd be great if someone who has already done this before; or would know how to.. could lend a hand =)
 

sam690826

Wanderer
thank you

i don't know how to compile a script !
so i looked this script for a longtime!

now it's working fine in Runuo 2.0 final after merge!:)
 

nikkor1132

Sorceror
it is 100% possible to make a leveling deed for this system i have seen many shards with them i
have tryed to make one a few times but i have failed by all means i am not the best scriptor but.

Like orbit said if some one could lend a hand that would rock i would love to get my hands on a working deed for all weps i know this thred is vary old post but i wanted to shed some light on it because i have yet to see any one post a deed.

Seen people post there trys and fails but all im trying to say is it would be nice to see a working deed! Lets try to put our heads together on this if possible and come up with one for every one that uses this system!
 

nikkor1132

Sorceror
if any one comes up with a working deed let me know i will buy it if i have to!
 

LordHogFred

Knight
I have rewritten this system using XML Attachments. This means that anything can be made levelable by just adding the item level attachment to the item. Making a deed that would add this would be very easy with the attachment implementation. If anyone is interested let me know and I'll get it posted, that is as long as the original author doesn't mind.
 

nikkor1132

Sorceror
I have rewritten this system using XML Attachments. This means that anything can be made levelable by just adding the item level attachment to the item. Making a deed that would add this would be very easy with the attachment implementation. If anyone is interested let me know and I'll get it posted, that is as long as the original author doesn't mind.

o god thanks fianly some more help lol yes i would love the XML Attachments and a deed i been trying just to make a deed and edit baseweapon but i dont got alot of luck lol so if you could do that that would rock! :D i been a scriptor for a few years now but just join here on RunUO to help and post some my customs.

If you have a skype let me have it if you dont mined maybe we can collab on some scripts =) if you want to.
 

evany

Sorceror
I can't make it work with 2.2...

I compile the scipts, but i had to update this part to make it work:

Code:
public override void GetDamageTypes( Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy, out int chaos, out int direct )

But when i equip any weapon my character wont attack. If i hold a normal katana it attacks normally.

I had to switch to the first system you made that I am using with RunUO 1.0 that works (after a few adjustments).
 

Sether67

Sorceror
Ive got it to work with all the level items script but some how my character won't swing when I attacked with one level weapon, for example blade of insanity and/or a normal level kryss, but I do swing with any non level weapons, what did I do wrong?
 

Sether67

Sorceror
but now, even tho i swing for 5 mins, i didn't get one exp point on my levelable blade of the righteous, what's up with that?

/edit nevermind it's set to get xp on kill and not on hit, my bad.
 
Any insight as to where to begin to make levelable items created only by exception crafting? I'm guessing in craftitem.cs
Any help would be great.

Thanks,

Jason
 
Top