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!

[RUO ALL] easy Skill-Mod Items

Vorspire

Knight
[RUO ALL] easy Skill-Mod Items

RunUO Versions: 1.0 Final | 2.0 RC1| 2.0 RC2 | 2.0 SVN

COMPATIBLE WITH ALL RUNUO VERSIONS

Lokai's Modifications:
http://www.runuo.com/forums/custom-...-ruo-1-0-easy-skill-mod-items.html#post757703

--------------------

This package contains the means to give you a Base Class from which to derive new Skill-Mod Items!

I have included examples that should be enough to get you started!
Please remember that you need to set things like Layers, Names, Hues and Weight, as the BaseSkillModItems do not provide them!

UPDATES
{
  • 21st May, 2008
    {
    • Added Lord_GreyWolf's LanternExample and SkillModEquipableLight scripts ot the package! - Thanks GreyWolf!
    }
}

Abilities:
{
  • Add Any SkillName
  • Breaks the "5-Mod" boundry - Add as many mods as you wish!
  • Shows Modification in Object Properties
  • Derivable "OnFired" Methods
  • Exploit-Proof
  • Extremely Customisable
}

Scripts Supplied:
{
  • ./
    {
    • BaseSkillModItem.cs
    • CustomSkillMod.cs
    }
  • ./Examples/
    {
    • ArmorExample.cs
    • ShieldExample.cs
    • WeaponExample.cs
    • RangedWeaponExample.cs
    • ClothingExample.cs
    • LanternExample.cs
    }
}

Enjoy!

NOTE:These scripts are designed for RunUO 1.0 Final, only minor modifications to one or two lines should be needed to upgrade compatibility.

NOTE:Due to a busy life-style, I may be unable to answer support requests, so please try your best to edit these yourself. Please use another thread for support requests!!!

Regards, Vorspire
 

Attachments

  • Skill-Mod Items.zip
    7 KB · Views: 119

Lokai

Knight
First, let me say, "Good Job" on having an easy way to create custom items with more than 5 skill mods. I have not tested yet, but was impressed with what I have seen.

Can you clarify these 2 things?

Vorspire;757251 said:
  • Derivable "OnFired" Methods
  • Exploit-Proof

I do not see an "OnFired" method.

Thanks!
 

Vorspire

Knight
"OnFired is just an alias type i use. The two "OnFired" methods are:

public void OnSkillModApplied(Mobile m)

and

public void OnSkillModRemoved(Mobile m)
 
great job on the scripts !!!!

by the way - i have found a bug in previous things done this way, where there is a layer conflict with the one built into the mul file, and it does the equiping, then fails with the base on equip, so they get the mods, but not removed

here is a fix for that not to happen, and works a lot better

just change each on equip method to look like this, and works great:

Code:
		public override bool OnEquip( Mobile owner )
		{
			if( owner != null && Layer != Layer.Invalid && base.OnEquip(owner))
			{
				ApplySkillMods( owner );
				InvalidateProperties( );
				return true;
			}
			return false;
		}

this way - if for aby reason they can not normaly equip it - i.e. layer, not enought str, etc etc
they do not get the bonuses
 
and yes - i do really love these :)

here is an addon for you all ready to add in if you want

skill mod equipable lights :)

just add in at end of file with the rest before the last }
and an example also for it - tested and worked very very nicely

Code:
	public abstract class SkillModEquipableLight : BaseEquipableLight
	{
		private Hashtable m_SkillMods = new Hashtable( );
		public Hashtable SkillMods { get { return m_SkillMods; } set { m_SkillMods = value; } }

		[Constructable]
		public SkillModEquipableLight(  int itemID ) : base( 0xA25 ) { }

		public virtual void OnSkillModsApplied( Mobile m ) { }
		public virtual void OnSkillModsRemoved( Mobile m ) { }

		public override bool OnEquip( Mobile owner )
		{
			if( owner != null && Layer != Layer.Invalid && base.OnEquip(owner))
			{
				ApplySkillMods( owner );
				InvalidateProperties( );
				return true;
			}
			return false;
		}

		public override void OnRemoved( object parent )
		{
			if( parent != null && parent is Mobile )
			{
				if( Layer != Layer.Invalid ) RemoveSkillMods( ( Mobile )parent );
			}
			InvalidateProperties( );
			base.OnRemoved( parent );
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			ArrayList strings = new ArrayList( );
			if( m_SkillMods.Count > 0 )
			{
				foreach( CustomSkillMod mod in m_SkillMods.Values )
				{
					if( mod == null ) continue;
					strings.Add( String.Format( "Special {0} bonus: {1}", mod.Skill.ToString( ), mod.Bonus.ToString( ) ) );
				}
			}
			string toAdd = "";
			int amount = strings.Count;
			int current = 1;
			foreach( string str in strings )
			{
				toAdd += str;
				if( current != amount ) toAdd += "\n";
				++current;
			}
			if( toAdd != "" ) list.Add( 1070722, toAdd );
		}

		public void ApplySkillMods( Mobile m )
		{
			if( m_SkillMods.Count > 0 )
			{
				foreach( CustomSkillMod mod in m_SkillMods.Values )
				{
					if( mod == null ) continue;
					mod.Apply( m );
				}
				OnSkillModsApplied( m );
			}
		}

		public void RemoveSkillMods( Mobile m )
		{
			if( m_SkillMods.Count > 0 )
			{
				foreach( CustomSkillMod mod in m_SkillMods.Values )
				{
					if( mod == null ) continue;
					mod.Remove( m );
				}
				OnSkillModsRemoved( m );
			}
		}

		public bool AddSkillMod( SkillName skill, double val )
		{
			if( m_SkillMods.ContainsKey( skill ) ) return false;
			m_SkillMods.Add( skill, new CustomSkillMod( skill, val ) );
			if( m_SkillMods.ContainsKey( skill ) ) return true;
			return false;
		}

		public bool RemoveSkillMod( SkillName skill )
		{
			if( !m_SkillMods.ContainsKey( skill ) ) return false;
			m_SkillMods.Remove( skill );
			if( !m_SkillMods.ContainsKey( skill ) ) return true;
			return false;
		}

		public SkillModEquipableLight( Serial serial ) : base( serial ) { }
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( ( int )0 );
			writer.Write( ( int )m_SkillMods.Count );
			foreach( CustomSkillMod mod in m_SkillMods.Values )
			{
				writer.Write( ( int )mod.Skill );
				writer.Write( ( double )mod.Bonus );
			}
		}
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt( );
			int count = reader.ReadInt( );
			if( count > 0 )
			{
				for( int foo = 0; foo < count; foo++ )
				{
					SkillName skill = ( SkillName )reader.ReadInt( );
					double bonus = ( double )reader.ReadDouble( );

					AddSkillMod( skill, bonus );
				}
			}
		}
	}
 

Attachments

  • LanternExample.cs
    1.3 KB · Views: 28

Lokai

Knight
Vorspire,

I added 13 new types to your file BaseSkillModItem.cs. They are based on the following types:

BaseJewel
BaseBracelet
BaseRing
BaseNecklace
BaseEarrings
GoldBracelet
SilverBracelet
GoldRing
SilverRing
GoldNecklace
SilverNecklace
GoldEarrings
SilverEarrings

I also incorporated Lord_Greywolf's suggested method modifications, and added an Interface to each Type - ISkillModItem - defined as follows:

Code:
    public interface ISkillModItem
    {
        void ApplySkillMods(Mobile m);
        void RemoveSkillMods(Mobile m);
        bool AddSkillMod(SkillName skill, double val);
        bool RemoveSkillMod(SkillName skill);
    }

The advantage of having each Type incorporate the Interface is that, in other scripts written to take advantage of these items, you can use something like this in your code:

Code:
if (testItem is ISkillModItem)
     ((ISkillModItem)testItem).AddSkillMod(SkillName.Fencing, 10.0);

I have posted my BaseSkillModItem.cs file here, and also an Example Jewel script (RingOfTheCrafter). I hope people enjoy these. I have written no credits into these files, so feel free to incorporate them or ignore them as you choose.

:) Thanks!
 

Attachments

  • BaseSkillModItem.cs
    91.1 KB · Views: 36
  • JewelExample.cs
    1.2 KB · Views: 39

Vorspire

Knight
I wrote the original to be "Easy" skill mod items :p that's why i didn't include the interface. Your scripts look great, tahnks for sharing and taking the time to make this system better :)

when i originally started this script, i was using an interface, but removed it due to the fact it's very annoying to have to type-cast everything in your derived scripts ;)

Sometimes, more code is better. I always think of the end-user while writing my scripts, even ones im not gonna release :p

Thanks again :)
 

Lokai

Knight
Vorspire;757251 said:
21st May, 2008


  • {
    • Added Lord_GreyWolf's LanternExample and SkillModEquipableLight scripts ot the package! - Thanks GreyWolf!
    }
}

I just redownloaded the package, and it does not contain Lord_GreyWolf's additions. Looks like strange things continue to happen to zip files here...
 
Top