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!

Level Items (Redux)

tindin156

Wanderer
Bug found

hi there after having a few ppl test out item i have found an odd bug that i cant fix..here is the bug

this bug is only on basearmor items

say you have 40 points and put half on Physical Resistance makeing it 10 plus
no if you restart the shard and try to but the rest on they well not add to the item but well add in the gump...so taking points but not giving the bonus

i have tested this over and over with different items and point amounts with the newest script release and it keeps happning everytime
 

dracana

Sorceror
tindin156 said:
hi there after having a few ppl test out item i have found an odd bug that i cant fix..here is the bug

this bug is only on basearmor items

say you have 40 points and put half on Physical Resistance makeing it 10 plus
no if you restart the shard and try to but the rest on they well not add to the item but well add in the gump...so taking points but not giving the bonus

i have tested this over and over with different items and point amounts with the newest script release and it keeps happning everytime

Yes, I did have this problem as well. I assume you are using Daat99 OWLTR? If so, you can fix the armor going forward by changing the following in BaseArmor.cs.

Look for...
Code:
			writer.WriteEncodedInt( (int) PhysicalResistance );
			writer.WriteEncodedInt( (int) FireResistance );
			writer.WriteEncodedInt( (int) ColdResistance );
			writer.WriteEncodedInt( (int) PoisonResistance );
			writer.WriteEncodedInt( (int) EnergyResistance );

Replace the above code with...
Code:
			writer.WriteEncodedInt( (int) [B][COLOR="red"]m_[/COLOR][/B]PhysicalResistance );
			writer.WriteEncodedInt( (int) [B][COLOR="red"]m_[/COLOR][/B]FireResistance );
			writer.WriteEncodedInt( (int) [B][COLOR="red"]m_[/COLOR][/B]ColdResistance );
			writer.WriteEncodedInt( (int) [B][COLOR="red"]m_[/COLOR][/B]PoisonResistance );
			writer.WriteEncodedInt( (int) [B][COLOR="Red"]m_[/COLOR][/B]EnergyResistance );

This will not fix any armor that already exists unfortunately :( To fix that armor, you can [dupe the armor, then verify that all attributes were copied, if not, you need to fix those by hand. Luckily it only affects armor, not jewels, weapons, or clothing :)

If I find another way to fix from within my scripts, I will repost, but unfortunately nothing I have tried in my scripts has worked and only the BaseArmor.cs edit works.
 

evany

Sorceror
I got a question. How can i prevent a player putting on a ring if he's wearing already an earring? And can I make a ring raise certain attributes, but not the others???
 

XxX-Brad

Wanderer
Help Pleez?

Ok, well im new to having a shard and i tryed to make a leather level suit and i got the error on shard:

RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed <1 errors, 0 warnings>
- Error: Scripts\Levelable Items 2[1].0\LevelArms.cs: CS1501: <line 26, column 4> No overload for method 'BaseArmor' takes '0' arguments

here is code:

Code:
using System;
using System.Text;
using Server;
using Server.Mobiles;
using Server.ContextMenus;
using System.Collections;
using Server.Gumps;

namespace Server.Items
{
	[FlipableAttribute( 0x13cd, 0x13c5 )]
	public class LevelLeatherArms : BaseArmor, ILevelable // ILevelable is the interface that gives us all the leveling functionality
	{

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

                public override ArmorMaterialType MaterialType{ get{ return ArmorMaterialType.Leather; } }
		public override CraftResource DefaultResource{ get{ return CraftResource.RegularLeather; } }

		public override ArmorMeditationAllowance DefMedAllowance{ get{ return ArmorMeditationAllowance.All; } }

		[Constructable]
		public LevelLeatherArms() : base()
		{
			/* Invalidate the level and refresh the item props
			 * Extremely important to call this method */
			LevelItemManager.InvalidateLevel( this );
		}

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

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

			writer.Write( (int) 0 );

			// DONT FORGET TO SERIALIZE LEVEL, EXPERIENCE, AND POINTS
			writer.Write( m_Experience );
			writer.Write( m_Level );
			writer.Write( m_Points );
		}

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

			int version = reader.ReadInt();

			// DONT FORGET TO DESERIALIZE LEVEL, EXPERIENCE, AND POINTS
			m_Experience = reader.ReadInt();
			m_Level = reader.ReadInt();
			m_Points = reader.ReadInt();
		}

		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 ( LevelItemManager.DisplayExpProp )
				list.Add( 1060659, "Experience\t{0}", m_Experience );
		}

		public override void GetContextMenuEntries(Mobile from, ArrayList 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_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[LevelItemManager.Levels - 1] )
					m_Experience = LevelItemManager.ExpTable[LevelItemManager.Levels - 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 > LevelItemManager.Levels )
					value = LevelItemManager.Levels;

				// 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;
			}
		}
		#endregion
	}
}
any ideas what went wrong? =\
 

dracana

Sorceror
XxX-Brad said:
Ok, well im new to having a shard and i tryed to make a leather level suit and i got the error on shard:

RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed <1 errors, 0 warnings>
- Error: Scripts\Levelable Items 2[1].0\LevelArms.cs: CS1501: <line 26, column 4> No overload for method 'BaseArmor' takes '0' arguments

here is code:

Code:
using System;
using System.Text;
using Server;
using Server.Mobiles;
using Server.ContextMenus;
using System.Collections;
using Server.Gumps;

namespace Server.Items
{
	[FlipableAttribute( 0x13cd, 0x13c5 )]
	public class LevelLeatherArms : BaseArmor, ILevelable // ILevelable is the interface that gives us all the leveling functionality
	{

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

                public override ArmorMaterialType MaterialType{ get{ return ArmorMaterialType.Leather; } }
		public override CraftResource DefaultResource{ get{ return CraftResource.RegularLeather; } }

		public override ArmorMeditationAllowance DefMedAllowance{ get{ return ArmorMeditationAllowance.All; } }

		[Constructable]
		public LevelLeatherArms() : base()
		{
			/* Invalidate the level and refresh the item props
			 * Extremely important to call this method */
			LevelItemManager.InvalidateLevel( this );
		}

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

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

			writer.Write( (int) 0 );

			// DONT FORGET TO SERIALIZE LEVEL, EXPERIENCE, AND POINTS
			writer.Write( m_Experience );
			writer.Write( m_Level );
			writer.Write( m_Points );
		}

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

			int version = reader.ReadInt();

			// DONT FORGET TO DESERIALIZE LEVEL, EXPERIENCE, AND POINTS
			m_Experience = reader.ReadInt();
			m_Level = reader.ReadInt();
			m_Points = reader.ReadInt();
		}

		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 ( LevelItemManager.DisplayExpProp )
				list.Add( 1060659, "Experience\t{0}", m_Experience );
		}

		public override void GetContextMenuEntries(Mobile from, ArrayList 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_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[LevelItemManager.Levels - 1] )
					m_Experience = LevelItemManager.ExpTable[LevelItemManager.Levels - 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 > LevelItemManager.Levels )
					value = LevelItemManager.Levels;

				// 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;
			}
		}
		#endregion
	}
}
any ideas what went wrong? =\

You have to change one of two things. Either you should derive your item class from another armor item directly or from BaseArmor (like you are doing), but if you are working off of BaseArmor as your item parent class you need to give your item an item id.

For example, you either need to change this line...
Code:
	public class LevelLeatherArms : BaseArmor, ILevelable // ILevelable is the interface that gives us all the leveling functionality
to...
Code:
	public class LevelLeatherArms : [COLOR="red"][B]LeatherArms[/B][/COLOR], ILevelable // ILevelable is the interface that gives us all the leveling functionality

OR
You need to change this line...
Code:
		public LevelLeatherArms() : base()
to...
Code:
		public LevelLeatherArms() : base([B][COLOR="Red"]0x13CD[/COLOR][/B])

All of my sample scripts are done using the first method (deriving my item class from another item class), so you can use the samples for an example if needed.

Hope this helps!
 

tindin156

Wanderer
dracana said:
You need to change this line...
Code:
		public LevelLeatherArms() : base()
to...
Code:
		public LevelLeatherArms() : base([B][COLOR="Red"]0x13CD[/COLOR][/B])


this does not need to be done as you are calling it already from
Code:
public class LevelLeatherArms : [COLOR="Red"]LeatherArms[/COLOR], ILevelable // ILevelable is the interface that gives us all the leveling functionality
 

dracana

Sorceror
tindin156 said:
this does not need to be done as you are calling it already from
Code:
public class LevelLeatherArms : [COLOR="Red"]LeatherArms[/COLOR], ILevelable // ILevelable is the interface that gives us all the leveling functionality

It depends on which change is desired... I might not have clarified enough, but if the first change is made you do not need to make the second change (and vice-versa).
 

bby

Wanderer
is this posible?

i want to make verything in game lvlable like say when u buy somthing from a vendor thats likes stock no nothin on it exept a few resist when u would put it on as u would fight it would lvl up and gain exp and u could use sp just like the kryss and all the othere items
 

dracana

Sorceror
bby said:
i want to make verything in game lvlable like say when u buy somthing from a vendor thats likes stock no nothin on it exept a few resist when u would put it on as u would fight it would lvl up and gain exp and u could use sp just like the kryss and all the othere items

This would definitely be possible. but not tested. I originally modified this script from OutkastDev's item leveling system, which leveled items in the same manner as this version. I never tested modifying the base scripts (to any extremes), but in theory, you should be able to make the same changes to the basewepon.cs, basejewel.cs, basearmor.cs, as are found in the sample item scripts.

There are earlier posts on this subject... check them out to see if they help. Someday I will ge around to testing and releasing these changes myself! :)
 

Shadow82

Sorceror
coo

Sounds Cool, and just a minor request. but why not make levelable pets? Personally i think that would be neat :p
 

dracana

Sorceror
Shadow82 said:
Sounds Cool, and just a minor request. but why not make levelable pets? Personally i think that would be neat :p

Thx! Yeah, I love the idea of pet levelling, however this is already part of RoninGT's awesome taming system (FSATS). I recommend you check that script out. Don't be concerned if you don't need all feature, It was designed to allow you to turn features on/off!
 

MontegroJC

Wanderer
Nice script, 1 problem though, I tryed making some items using the edited parts of the LevelKryss, and when I try to add it it says Usage: *item name*:confused:
 

dracana

Sorceror
MontegroJC said:
Nice script, 1 problem though, I tryed making some items using the edited parts of the LevelKryss, and when I try to add it it says Usage: *item name*:confused:

Can you post the code of your item script?
 

MontegroJC

Wanderer
ok here is one,
Code:
using System;
using System.Text;
using Server;
using Server.Mobiles;
using Server.ContextMenus;
using System.Collections;
using Server.Gumps;

namespace Server.Items
{
	[FlipableAttribute( 0x27A2, 0x27ED )]
	public class YellowLightSaber : Kryss, ILevelable // ILevelable is the interface that gives us all the leveling functionality
	{
		/* These private variables store the exp, level, and *
		 * points for the item */
		private int m_Experience;
		private int m_Level;
		private int m_Points;

		public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.CrushingBlow; } }
		public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.ArmorIgnore; } }

		public override int AosStrengthReq{ get{ return 40; } }
		public override int AosMinDamage{ get{ return 16; } }
		public override int AosMaxDamage{ get{ return 18; } }
		public override int AosSpeed{ get{ return 35; } }

		public override int OldStrengthReq{ get{ return 40; } }
		public override int OldMinDamage{ get{ return 16; } }
		public override int OldMaxDamage{ get{ return 18; } }
		public override int OldSpeed{ get{ return 35; } }

		public override int DefHitSound{ get{ return 0x23B; } }
		public override int DefMissSound{ get{ return 0x23A; } }

		public override int InitMinHits{ get{ return 31; } }
		public override int InitMaxHits{ get{ return 90; } }

		[Constructable]
		public YellowLightSaber() : base( 0x27A2 )
		{
			Hue = 1161;
			Name = "Yellow Lightsaber";
			/* Invalidate the level and refresh the item props
			 * Extremely important to call this method */
			LevelItemManager.InvalidateLevel( this );
			Layer = Layer.TwoHanded;
		}


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

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

			writer.Write( (int) 0 );

			// DONT FORGET TO SERIALIZE LEVEL, EXPERIENCE, AND POINTS
			writer.Write( m_Experience );
			writer.Write( m_Level );
			writer.Write( m_Points );
		}

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

			int version = reader.ReadInt();

			// DONT FORGET TO DESERIALIZE LEVEL, EXPERIENCE, AND POINTS
			m_Experience = reader.ReadInt();
			m_Level = reader.ReadInt();
			m_Points = reader.ReadInt();
		}

		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 ( LevelItemManager.DisplayExpProp )
				list.Add( 1060659, "Experience\t{0}", m_Experience );
		}

		public override void GetContextMenuEntries(Mobile from, ArrayList 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_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[LevelItemManager.Levels - 1] )
					m_Experience = LevelItemManager.ExpTable[LevelItemManager.Levels - 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 > LevelItemManager.Levels )
					value = LevelItemManager.Levels;

				// 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;
			}
		}
		#endregion
	}
}
 

dracana

Sorceror
MontegroJC said:
ok here is one,
Code:
using System;
using System.Text;
using Server;
using Server.Mobiles;
using Server.ContextMenus;
using System.Collections;
using Server.Gumps;

namespace Server.Items
{
	[FlipableAttribute( 0x27A2, 0x27ED )]
	public class YellowLightSaber : Kryss, ILevelable // ILevelable is the interface that gives us all the leveling functionality
	{
		/* These private variables store the exp, level, and *
		 * points for the item */
		private int m_Experience;
		private int m_Level;
		private int m_Points;

		public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.CrushingBlow; } }
		public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.ArmorIgnore; } }

		public override int AosStrengthReq{ get{ return 40; } }
		public override int AosMinDamage{ get{ return 16; } }
		public override int AosMaxDamage{ get{ return 18; } }
		public override int AosSpeed{ get{ return 35; } }

		public override int OldStrengthReq{ get{ return 40; } }
		public override int OldMinDamage{ get{ return 16; } }
		public override int OldMaxDamage{ get{ return 18; } }
		public override int OldSpeed{ get{ return 35; } }

		public override int DefHitSound{ get{ return 0x23B; } }
		public override int DefMissSound{ get{ return 0x23A; } }

		public override int InitMinHits{ get{ return 31; } }
		public override int InitMaxHits{ get{ return 90; } }

		[Constructable]
		public YellowLightSaber() : base( 0x27A2 )
		{
			Hue = 1161;
			Name = "Yellow Lightsaber";
			/* Invalidate the level and refresh the item props
			 * Extremely important to call this method */
			LevelItemManager.InvalidateLevel( this );
			Layer = Layer.TwoHanded;
		}


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

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

			writer.Write( (int) 0 );

			// DONT FORGET TO SERIALIZE LEVEL, EXPERIENCE, AND POINTS
			writer.Write( m_Experience );
			writer.Write( m_Level );
			writer.Write( m_Points );
		}

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

			int version = reader.ReadInt();

			// DONT FORGET TO DESERIALIZE LEVEL, EXPERIENCE, AND POINTS
			m_Experience = reader.ReadInt();
			m_Level = reader.ReadInt();
			m_Points = reader.ReadInt();
		}

		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 ( LevelItemManager.DisplayExpProp )
				list.Add( 1060659, "Experience\t{0}", m_Experience );
		}

		public override void GetContextMenuEntries(Mobile from, ArrayList 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_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[LevelItemManager.Levels - 1] )
					m_Experience = LevelItemManager.ExpTable[LevelItemManager.Levels - 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 > LevelItemManager.Levels )
					value = LevelItemManager.Levels;

				// 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;
			}
		}
		#endregion
	}
}


Change this line...
Code:
public YellowLightSaber() : base( 0x27A2 )

to...
Code:
public YellowLightSaber() : base( )

The base item id is already derived from Kryss, so that is not needed. That should fix the issue.
 

MontegroJC

Wanderer
Thank you very much :) A little late perhapse (Sorry to say I looked over the LevelKryss script and this script multiple times and found it after 2 hours ^^)
 

Arek

Sorceror
Great script! I'm planning on implementing it on a shard of my own. I'd like to make all items on my shard Levelable (I've already figured that part out), but I'd like to make Artifacts on my shard spawn as already having gained some levels (say, 10 for the sake of demonstration), and have no points remaining. Any ideas how I would go about this? My eventual plan is to have artis spawn at a random level, thus reducing the number of uber-uber weapons available, and giving players something to go out and hunt for (An artifact spawning on my shard at level 1 should be possible, but incredibly rare).

--Arek
 
Top