Kamras

Member
I'm trying to add a constructable to this hue script, so that I can add additional items in game that reference different hues that are defined in each constructable . Every time I add a constructable at the bottom to reference a different Hue, it compiles but in game it adds an invisible Item. I checked the Base and it looks correct.

I feel this should be a simple thing, but it's the simple things that get me the most.

Constructor I'm adding to the bottom that is causing invisible items when trying to add in game
Code:
    public class EverythingDyeRed  : EverythingDye
    {
        private int TheHue = Utility.RandomMinMax(33,33);
     
        [Constructable]
        public EverythingDyeRed() : base( 0xE2B )
        {
            Weight = 0.0;
            Name = "Everything Dy eRed";
            Movable = true;
        }

        public EverythingDyeRed( 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();
            }
        }

Full Script:
Code:
using Server.Targeting;
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Mobiles;
using System.Collections;

namespace Server.Items
{
       public class EverythingDye : Item, IUsesRemaining
       {
        private int m_UsesRemaining;
     
        #region configuration#
        private int TheHue = Utility.RandomMinMax(1152,1152);
        private string TheName = "Everything Dye - Frost Blue";
        private int Uses = Utility.Random(5, 6);
        #endregion
        #region options
        [CommandProperty(AccessLevel.GameMaster)]
        public int UsesRemaining
        {
            get { return m_UsesRemaining; }
            set { m_UsesRemaining = value; InvalidateProperties(); }
        }
     
        public bool ShowUsesRemaining { get { return true; } set { } }
        #endregion
        #region Constructor
        [Constructable]
        public EverythingDye() : base( 0xE2B )
        {
            Weight = 1.0;
            Movable = true;
            Hue = TheHue;
            Name= TheName;
            UsesRemaining = Uses;
            ShowUsesRemaining = true;
        }

        public EverythingDye( Serial serial ) : base( serial )
        {
   

        }
        public override void OnDoubleClick( Mobile from )
        {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if( from.InRange( this.GetWorldLocation(), 1 ) )
            {
                from.SendMessage( "What do you wish to dye?" );
                from.Target = new DyeTarget( this );
            }
            else
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
            }

        }
     
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~
        }

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

            writer.Write( (int) 0 );
         
            writer.Write((int)m_UsesRemaining);
        }

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

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


          private class DyeTarget : Target
        {
     
     
            private Mobile m_Owner;

            private EverythingDye m_Powder;

            public DyeTarget( EverythingDye charge ) : base ( 10, false, TargetFlags.None )
            {
                    m_Powder=charge;
            }
   
            protected override void OnTarget( Mobile from, object target )
            {
                if ( target == from )
                    from.SendMessage( "This can only be used on pets." );

                else if ( target is PlayerMobile )
                    from.SendMessage( "You cannot dye them." );

                else if (target is BaseJewel || target is BaseArmor || target is BaseClothing || target is BaseShield || target is BaseWeapon || target is EtherealMount || target is BaseSuit || target is BaseContainer || target is Item )
                {
                    Item item = (Item)target;
                    if (item.RootParent == from) // Make sure its in their pack or they are wearing it
                    {
                        item.Hue = m_Powder.TheHue;
                        from.SendMessage( 53, "Your item has now been dyed." );
                        from.PlaySound( 0x23E );

                        --m_Powder.UsesRemaining;

                        if (m_Powder.UsesRemaining == 0)
                        {
                            m_Powder.Delete();
                        }
                    }

                    else
                        from.SendMessage("You can only dye objects that are in your backpack or on your person!");
                } 

                else if ( target is BaseCreature )
                {
                    BaseCreature c = (BaseCreature)target; 
                    if ( c.BodyValue == 400 || c.BodyValue == 401 && c.Controlled == false )
                    {
                        from.SendMessage( "You cannot dye them." );
                    }
                    else if ( c.ControlMaster != from && c.Controlled == false )
                    {
                        from.SendMessage( "This is not your pet." );
                    }
                    else if ( c.Controlled == true && c.ControlMaster == from)
                    {
                        c.Hue = m_Powder.TheHue;
                        from.SendMessage( 53, "Your pet has now been dyed." );
                        from.PlaySound( 0x23E );
                        m_Powder.Delete();
                    }

                }
            }
        }
        #endregion
       }
}
 
I'm trying to add a constructable to this hue script, so that I can add additional items in game that reference different hues that are defined in each constructable . Every time I add a constructable at the bottom to reference a different Hue, it compiles but in game it adds an invisible Item. I checked the Base and it looks correct.

I feel this should be a simple thing, but it's the simple things that get me the most.

Constructor I'm adding to the bottom that is causing invisible items when trying to add in game
Code:
    public class EverythingDyeRed  : EverythingDye
    {
        private int TheHue = Utility.RandomMinMax(33,33);
    
        [Constructable]
        public EverythingDyeRed() : base( 0xE2B )
        {
            Weight = 0.0;
            Name = "Everything Dy eRed";
            Movable = true;
        }

        public EverythingDyeRed( 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();
            }
        }

Full Script:
Code:
using Server.Targeting;
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Mobiles;
using System.Collections;

namespace Server.Items
{
       public class EverythingDye : Item, IUsesRemaining
       {
        private int m_UsesRemaining;
    
        #region configuration#
        private int TheHue = Utility.RandomMinMax(1152,1152);
        private string TheName = "Everything Dye - Frost Blue";
        private int Uses = Utility.Random(5, 6);
        #endregion
        #region options
        [CommandProperty(AccessLevel.GameMaster)]
        public int UsesRemaining
        {
            get { return m_UsesRemaining; }
            set { m_UsesRemaining = value; InvalidateProperties(); }
        }
    
        public bool ShowUsesRemaining { get { return true; } set { } }
        #endregion
        #region Constructor
        [Constructable]
        public EverythingDye() : base( 0xE2B )
        {
            Weight = 1.0;
            Movable = true;
            Hue = TheHue;
            Name= TheName;
            UsesRemaining = Uses;
            ShowUsesRemaining = true;
        }

        public EverythingDye( Serial serial ) : base( serial )
        {
  

        }
        public override void OnDoubleClick( Mobile from )
        {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if( from.InRange( this.GetWorldLocation(), 1 ) )
            {
                from.SendMessage( "What do you wish to dye?" );
                from.Target = new DyeTarget( this );
            }
            else
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
            }

        }
    
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~
        }

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

            writer.Write( (int) 0 );
        
            writer.Write((int)m_UsesRemaining);
        }

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

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


          private class DyeTarget : Target
        {
    
    
            private Mobile m_Owner;

            private EverythingDye m_Powder;

            public DyeTarget( EverythingDye charge ) : base ( 10, false, TargetFlags.None )
            {
                    m_Powder=charge;
            }
  
            protected override void OnTarget( Mobile from, object target )
            {
                if ( target == from )
                    from.SendMessage( "This can only be used on pets." );

                else if ( target is PlayerMobile )
                    from.SendMessage( "You cannot dye them." );

                else if (target is BaseJewel || target is BaseArmor || target is BaseClothing || target is BaseShield || target is BaseWeapon || target is EtherealMount || target is BaseSuit || target is BaseContainer || target is Item )
                {
                    Item item = (Item)target;
                    if (item.RootParent == from) // Make sure its in their pack or they are wearing it
                    {
                        item.Hue = m_Powder.TheHue;
                        from.SendMessage( 53, "Your item has now been dyed." );
                        from.PlaySound( 0x23E );

                        --m_Powder.UsesRemaining;

                        if (m_Powder.UsesRemaining == 0)
                        {
                            m_Powder.Delete();
                        }
                    }

                    else
                        from.SendMessage("You can only dye objects that are in your backpack or on your person!");
                }

                else if ( target is BaseCreature )
                {
                    BaseCreature c = (BaseCreature)target;
                    if ( c.BodyValue == 400 || c.BodyValue == 401 && c.Controlled == false )
                    {
                        from.SendMessage( "You cannot dye them." );
                    }
                    else if ( c.ControlMaster != from && c.Controlled == false )
                    {
                        from.SendMessage( "This is not your pet." );
                    }
                    else if ( c.Controlled == true && c.ControlMaster == from)
                    {
                        c.Hue = m_Powder.TheHue;
                        from.SendMessage( 53, "Your pet has now been dyed." );
                        from.PlaySound( 0x23E );
                        m_Powder.Delete();
                    }

                }
            }
        }
        #endregion
       }
}


Just out of curiousity.

Why are you adding custom properties for things that already exist within all items? Like Name and Hue properties.

In the constructor you should just be setting Name = "Everything Else - Blue" and the Hue should be set to the Blue hue color you want using Hue = 33 (or whatever number hue you want)

Also, you dont want to make your BaseClass constructable, because you shouldnt need to be calling the base class of an item. I doubt you would be adding [add everythingpotion in game because you dont have the configurations for it.

You would instead be adding [add everythingdyered
 
Those will be for unique hue items, I was just using that hue as an example. It was mainly only for like 5 hues. I can modify them in game easy enough from the original but that does nothing for adding them to vendors for using custom tokens.
[doublepost=1483933406][/doublepost]But you are correct, no reason to reference a BaseClass constructor :) Was more aiming to not have to make more files, but sometimes it's not avoidable . lol
 
Those will be for unique hue items, I was just using that hue as an example. It was mainly only for like 5 hues. I can modify them in game easy enough from the original but that does nothing for adding them to vendors for using custom tokens.
[doublepost=1483933406][/doublepost]But you are correct, no reason to reference a BaseClass constructor :) Was more aiming to not have to make more files, but sometimes it's not avoidable . lol

I would take a look at how the pigments of Tokuno work and mirror your classes based off that. It may be a bigger help for you.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back