Item re-name Deed

Discussion in 'Script Support' started by renthar, Oct 12, 2017 at 9:32 AM.

  1. renthar

    renthar Sorceror

    Joined:
    Mar 22, 2006
    Messages:
    22
    Likes Received:
    0
    Just a warning, I'm very new to runuo but I have been trying to get an item re-name deed to work on my shard. This is based on the item engraver script, I have just changed it to be a single use deed.

    However I'm not sure how to set it to be deleted when the item has been named. Currently the deed will delete simply when you target the item, but in case someone targets the wrong item or something I'd prefer it after naming. Every time I try to do this I get errors though, I'm guessing it's just a small mistake or something? really not sure how to do it.

    Also, with this type of script is it possible to modify the "m_engtarg.Name = text;" line to modify a different stat, like item id or hue?

    Thanks for reading!

    Code:
    using System;
    using Server;
    using Server.Targeting;
    using Server.Items;
    using Server.Prompts;
    
    namespace Server.Items
    {
        public class ItemEngraver : Item
        {
            [Constructable]
            public ItemEngraver() : base( 0x14F0 )
            {
                Weight = 1.0;
                Name = "item rename deed";
                LootType = LootType.Blessed;
            }
    
            public override void OnDoubleClick( Mobile from )
            {
                if(!IsChildOf(from.Backpack)) from.SendMessage( "This must be in your backpack to use it." );
                else
                {
                    from.SendMessage( "Target the item you wish to name. The rename deed will be DELETED upon targeting" );
                    from.Target = new InternalTarget( this );
                }
            }
            private class InternalTarget : Target
            {
                private ItemEngraver m_ItemEngraver;
                private Item m_engtarg;
    
                public InternalTarget( ItemEngraver engrave ) : base( 1, false, TargetFlags.None )
                {
                    m_ItemEngraver = engrave;
                }
                protected override void OnTarget( Mobile from, object targeted )
                {
                    // put in else if statements to have it not engrave certain things, like baseweapons, or basearmor, etc etc
                    if ( targeted is Item )
                    {
                        m_engtarg = (Item)targeted;
                        if(!m_engtarg.IsChildOf(from.Backpack)) from.SendMessage( "This must be in your backpack to change its name." );
                        else
                        {
                            from.SendMessage( "What would you like to rename the item?" );
                            m_ItemEngraver.InvalidateProperties();
                            from.Prompt = new RenameContPrompt( m_engtarg );
                            m_ItemEngraver.Delete();
                        }
                    }
                    else from.SendMessage( "You cannot rename that." );
                }
            }
           
    public class RenameContPrompt : Prompt
        {
            private Item m_engtarg;
    
            public RenameContPrompt( Item rcont )
            {
                m_engtarg = rcont;
            }
            public override void OnResponse( Mobile from, string text )
            {
                m_engtarg.Name = text;
                from.SendMessage( "You have renamed the item." );
                //m_ItemEngraver.Delete();
            }
        }
           
            public ItemEngraver(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();
            }
        }
    }
    
     
  2. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
    Try this code

    Code:
    using System;
    using Server;
    using Server.Targeting;
    using Server.Items;
    using Server.Prompts;
    
    namespace Server.Items
    {
        public class ItemEngraver : Item
        {
            [Constructable]
            public ItemEngraver() : base( 0x14F0 )
            {
                Weight = 1.0;
                Name = "item rename deed";
                LootType = LootType.Blessed;
            }
    
            public override void OnDoubleClick( Mobile from )
            {
                if(!IsChildOf(from.Backpack)) from.SendMessage( "This must be in your backpack to use it." );
                else
                {
                    from.SendMessage( "Target the item you wish to name. The rename deed will be DELETED upon targeting" );
                    from.Target = new InternalTarget( this );
                }
            }
            private class InternalTarget : Target
            {
                private ItemEngraver m_ItemEngraver;
                private Item m_engtarg;
    
                public InternalTarget( ItemEngraver engrave ) : base( 1, false, TargetFlags.None )
                {
                    m_ItemEngraver = engrave;
                }
                protected override void OnTarget( Mobile from, object targeted )
                {
                    // put in else if statements to have it not engrave certain things, like baseweapons, or basearmor, etc etc
                    if ( targeted is Item )
                    {
                        m_engtarg = (Item)targeted;
                        if(!m_engtarg.IsChildOf(from.Backpack)) from.SendMessage( "This must be in your backpack to change its name." );
                        else
                        {
                            from.SendMessage( "What would you like to rename the item?" );
                            m_ItemEngraver.InvalidateProperties();
                            from.Prompt = new RenameContPrompt( m_engtarg, m_ItemEngraver );
                            //m_ItemEngraver.Delete();
                        }
                    }
                    else from.SendMessage( "You cannot rename that." );
                }
            }
          
    public class RenameContPrompt : Prompt
        {
            private Item m_engtarg;
            private ItemEngraver m_itemeng;
    
            public RenameContPrompt( Item rcont, ItemEngraver reng )
            {
                m_engtarg = rcont;
                m_itemeng = reng;
            }
            public override void OnResponse( Mobile from, string text )
            {
                m_engtarg.Name = text;
                from.SendMessage( "You have renamed the item." );
                m_itemeng.Delete();
            }
        }
          
            public ItemEngraver(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();
            }
        }
    }
     
  3. renthar

    renthar Sorceror

    Joined:
    Mar 22, 2006
    Messages:
    22
    Likes Received:
    0
    That gives errors :<
     
  4. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
    in ->> public class RenameContPrompt : Prompt

    try to change private ItemEngraver m_itemeng;
    to private Item m_itemeng;

    Anyway, post errors, I can't understand this way
     
  5. renthar

    renthar Sorceror

    Joined:
    Mar 22, 2006
    Messages:
    22
    Likes Received:
    0
    Is there any way to copy errors related to the script? My runuo just floods with random stuff from other scripts that are unrelated to this
     
  6. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
    Do you have a lot of errors? Anyway I don't know. Maybe you can just copy all errors on Word or Notepad and search for specific ones.
     
  7. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    I would do something like this.

    But you should add some rules on renaming items in the script. As it is now you can rename stacks of items like 60.000 bandages with one deed. It is even possible to create new rares of already existing ones with this script. (like server birth, if you use it) If you release a series of christmas globes you can get new ones made with this script. In short you might kill the rares market on your server.

    -Grim
     

    Attached Files:

    #7 Grimoric, Oct 12, 2017 at 11:13 AM
    Last edited: Oct 12, 2017 at 11:18 AM
  8. renthar

    renthar Sorceror

    Joined:
    Mar 22, 2006
    Messages:
    22
    Likes Received:
    0
    Thanks I'll look this over and see how you did it :) I might add some, although its for an RP shard with only about 15-20 people on. We can easily regulate how people use them, as they will be rare to get anyway. I had planned to make 2 more deeds that let people input their own custom hue/itemID as well, is it possible to do that using this script as a template?
     
  9. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    Version 2

    I have also added a deed check before rename of the item, this was made to stop an exploit from happening then a player click the deed, get target, trade it, and use on his item. This would had result in the other player loses the deed he just got in the trade.

    -Grim
     

    Attached Files:

    #9 Grimoric, Oct 12, 2017 at 11:45 AM
    Last edited: Oct 12, 2017 at 12:00 PM
  10. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    Images might be hard sins you need to make a layout for the player to select from.
    Hue with color should be easy there is code made for dye tubs that does this.

    m_target.ItemID
    m_target.Hue

    -Grim
     
  11. renthar

    renthar Sorceror

    Joined:
    Mar 22, 2006
    Messages:
    22
    Likes Received:
    0
    Thanks for the help! I'm having trouble to get either of those to work, I guess it isn't as simple as replacing "m_target.Name" :p I'll keep trying as I compare with the dye tub code
     
  12. Vorspire

    Vorspire Knight

    Joined:
    Jan 25, 2005
    Messages:
    12,875
    Likes Received:
    677
  13. renthar

    renthar Sorceror

    Joined:
    Mar 22, 2006
    Messages:
    22
    Likes Received:
    0
    Is there a reason why changing m_target.Name to m_target.Hue won't work? Isn't it just setting a different prop on the item? I'm trying to look at other examples but don't really know how to translate that into the script I'm working on

    I appreciate the responses, I think I might have an easier time doing this through xml in-game though :p it's a little out of my league
     
  14. Vorspire

    Vorspire Knight

    Joined:
    Jan 25, 2005
    Messages:
    12,875
    Likes Received:
    677
    I'm not sure where you're at with your code, s you'll have to post the full current script you're working with.
     
  15. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    Something like this with standard color panel.

    -Grim
     

    Attached Files:

Share This Page