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!

Minimum requirements for items

Tiea1

Sorceror
Minimum requirements for items

I know this is an old post but I was trying to put a min taming and str req for players to use these items but keep coming up with errors. I'll post the Bracelet script and error.

Code:
using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
	public class BraceletOfControlling : SilverBracelet
	{
	
		[Constructable]
		public BraceletOfControlling()
		{
			Name = "Bracelet of Controlling";
			Attributes.StrReq = 100;
                                                Attributes.MinTaming = 105.0;
		}

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

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

			writer.Write( (int) 0 );
		}

		public override bool OnEquip( Mobile from )
		{
			if ( from is PlayerMobile )
			{
				PlayerMobile m = (PlayerMobile)from;
				m.FollowersMax += 1;
				this.Movable = false;
			}
			return base.OnEquip( from );
		}

		public override void OnRemoved( object parent )
		{
			if ( parent is PlayerMobile )
			{
				PlayerMobile mm = (PlayerMobile)parent;
				if (!((mm.FollowersMax - 1) < mm.Followers))
				{
					this.Movable = true;
					mm.FollowersMax -= 1;
				}
				else
				{
					mm.SendMessage( "You must reduce your followers before you can remove this." );
				}
			}
			return;
		}

		public override void OnDoubleClick( Mobile fromm ) 
		{
			if ( this.Parent == fromm ) 
			{
				if ( fromm is PlayerMobile )
				{
					PlayerMobile mmm = (PlayerMobile)fromm;
					if (!((mmm.FollowersMax - 1) < mmm.Followers))
					{
						this.Movable = true;
						mmm.AddToBackpack( this );
					}
					else
					{
						mmm.SendMessage( "You must reduce your followers before you can remove this." );
					}
				}
			}
			return;
		}

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

			int version = reader.ReadInt();
		}
	}
}

Error
Code:
RunUO - [www.runuo.com] Version 2.0, Build 3567.2838
Core: Running on .NET Framework Version 2.0.50727
Core: Running with arguments: -debug
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (21errors, 0 warnings)
Errors:
 + Customs/Deco/BraceletOfControlling.cs:
    CS0117: Line 18: 'Server.AosAttributes' does not contain a definition for 'S
trReq'
    CS0117: Line 19: 'Server.AosAttributes' does not contain a definition for 'M
inTaming'
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.

Thanks in advance. :)
 

Tabain

Sorceror
Untested.

Code:
        public override bool OnEquip(Mobile from)
        {
            if (from is PlayerMobile)
            {
                if (from.Skills[SkillName.AnimalTaming].Value >= 105.0 && from.Str >= 100)
                {
                    from.FollowersMax += 1;
                    this.Movable = false;
                }
                else
                {
                    from.SendMessage("You do not meet the requirements to equip this.");
                    return false;
                }
            }
            return base.OnEquip(from);
        }
 

Murzin

Knight
for equipping methods or removing methods, you want to code the things to STOP them from equipping the item.

you do not want to check if they CAN equip it, you want to check if they CANNOT that way its much better.

that way you can do the else with your changes and return your changes and true.
 

Tiea1

Sorceror
Tabain;848363 said:
Untested.

Code:
        public override bool OnEquip(Mobile from)
        {
            if (from is PlayerMobile)
            {
                if (from.Skills[SkillName.AnimalTaming].Value >= 105.0 && from.Str >= 100)
                {
                    from.FollowersMax += 1;
                    this.Movable = false;
                }
                else
                {
                    from.SendMessage("You do not meet the requirements to equip this.");
                    return false;
                }
            }
            return base.OnEquip(from);
        }

Thank you, I added this in and it seems to work great except it does not show the str req when pointed at, it says str req 10, but it does say "You do not meet the requirements to equip this." I tried changeing the 100 here to 100.0 but that did not work.
Code:
 if (from.Skills[SkillName.AnimalTaming].Value >= 105.0 && from.Str >= 100)

for equipping methods or removing methods, you want to code the things to STOP them from equipping the item.

you do not want to check if they CAN equip it, you want to check if they CANNOT that way its much better.

that way you can do the else with your changes and return your changes and true.

Thanks for the tip Murzin but I'm still not sure how to do what you suggest.
 

clark71822

Sorceror
Tiea1;848353 said:
I know this is an old post but I was trying to put a min taming and str req for players to use these items but keep coming up with errors. I'll post the Bracelet script and error.

Code:
using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
    public class BraceletOfControlling : SilverBracelet
    {
       [COLOR=Blue]public override int AosStrengthReq{ get{ return 100; } }[/COLOR]
        [COLOR=Blue]public override int OldStrengthReq{ get{ return 100; } }[/COLOR]
        [Constructable]
        public BraceletOfControlling()
        {
            Name = "Bracelet of Controlling";
            Attributes.StrReq = 100;
                                                Attributes.MinTaming = 105.0;
        }

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

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

            writer.Write( (int) 0 );
        }

        public override bool OnEquip( Mobile from )
        {
            if ( from is PlayerMobile )
            {
                PlayerMobile m = (PlayerMobile)from;
                m.FollowersMax += 1;
                this.Movable = false;
            }
            return base.OnEquip( from );
        }

        public override void OnRemoved( object parent )
        {
            if ( parent is PlayerMobile )
            {
                PlayerMobile mm = (PlayerMobile)parent;
                if (!((mm.FollowersMax - 1) < mm.Followers))
                {
                    this.Movable = true;
                    mm.FollowersMax -= 1;
                }
                else
                {
                    mm.SendMessage( "You must reduce your followers before you can remove this." );
                }
            }
            return;
        }

        public override void OnDoubleClick( Mobile fromm ) 
        {
            if ( this.Parent == fromm ) 
            {
                if ( fromm is PlayerMobile )
                {
                    PlayerMobile mmm = (PlayerMobile)fromm;
                    if (!((mmm.FollowersMax - 1) < mmm.Followers))
                    {
                        this.Movable = true;
                        mmm.AddToBackpack( this );
                    }
                    else
                    {
                        mmm.SendMessage( "You must reduce your followers before you can remove this." );
                    }
                }
            }
            return;
        }

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

            int version = reader.ReadInt();
        }
    }
}
The code I added above in blue is what you need to get the strength requirement to display when you mouseover the item. You might only need one or the other, depending on the era of the shard you're scripting for, but it don't hurt to have both. :)
 

Tiea1

Sorceror
clark71822;848398 said:
The code I added above in blue is what you need to get the strength requirement to display when you mouseover the item. You might only need one or the other, depending on the era of the shard you're scripting for, but it don't hurt to have both. :)

I did as you sugested and got the following errors.

Code:
RunUO - [www.runuo.com] Version 2.0, Build 3567.2838
Core: Running on .NET Framework Version 2.0.50727
Core: Running with arguments: -debug
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
 + Customs/Deco/BraceletOfControlling.cs:
    CS0115: Line 9: 'Server.Items.BraceletOfControlling.AosStrengthReq': no suit
able method found to override
    CS0115: Line 10: 'Server.Items.BraceletOfControlling.OldStrengthReq': no sui
table method found to override
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.

Below is the script with the mods.
Code:
using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
	public class BraceletOfControlling : SilverBracelet
	{
	      public override int AosStrengthReq{ get{ return 100; } }
                           public override int OldStrengthReq{ get{ return 100; } }
		[Constructable]
		public BraceletOfControlling()
		{
			Name = "Bracelet of Controlling";
			Attributes.StrReq = 100;
                                                Attributes.MinTaming = 105.0;

		}

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

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

			writer.Write( (int) 0 );
		}

		 public override bool OnEquip(Mobile from)
        {
            if (from is PlayerMobile)
            {
                if (from.Skills[SkillName.AnimalTaming].Value >= 105.0 && from.Str >= 100.0)
                {
                    from.FollowersMax += 1;
                    this.Movable = false;
                }
                else
                {
                    from.SendMessage("You do not meet the requirements to equip this.");
                    return false;
                }
            }
            return base.OnEquip(from);
        }

		public override void OnRemoved( object parent )
		{
			if ( parent is PlayerMobile )
			{
				PlayerMobile mm = (PlayerMobile)parent;
				if (!((mm.FollowersMax - 1) < mm.Followers))
				{
					this.Movable = true;
					mm.FollowersMax -= 1;
				}
				else
				{
					mm.SendMessage( "You must reduce your followers before you can remove this." );
				}
			}
			return;
		}

		public override void OnDoubleClick( Mobile fromm ) 
		{
			if ( this.Parent == fromm ) 
			{
				if ( fromm is PlayerMobile )
				{
					PlayerMobile mmm = (PlayerMobile)fromm;
					if (!((mmm.FollowersMax - 1) < mmm.Followers))
					{
						this.Movable = true;
						mmm.AddToBackpack( this );
					}
					else
					{
						mmm.SendMessage( "You must reduce your followers before you can remove this." );
					}
				}
			}
			return;
		}

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

			int version = reader.ReadInt();
		}
	}
}
 

clark71822

Sorceror
Looks like basejewel.cs doesn't have methods for AosStrengthReq and OldStrengthReq, so it looks like in order to get it to show like you want, it may require a bit more coding to do so. I'm still a noob as far as scripting goes, so I couldn't be much more help lol. Good luck, though :)
 

Tiea1

Sorceror
clark71822;848403 said:
Looks like basejewel.cs doesn't have methods for AosStrengthReq and OldStrengthReq, so it looks like in order to get it to show like you want, it may require a bit more coding to do so. I'm still a noob as far as scripting goes, so I couldn't be much more help lol. Good luck, though :)

Thank you hun, all help is always appreciated. :)
 
like he basicaly said, you have to script the requirements into basejewel script and serialize and deserialize it also with versioning

look at basearmor and how it does it
 
Top