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!

Basic item that can only be equiped by only one character

Mortis

Knight
This is a basic item that bonds to one character by serial. It can be used as a base to make other items similar. Weapons, Armor or whatever.

This particular item bonds when first equipped.
Some of the code may look old. Because it is. This was made/created April 10, 2002 with a few recent edits as to item name but still compiles and works in SVN 952. Report any bugs.

The person interested in this wanted it OnDoubleClick So DonationWeapon.cs is on doubleclick and BondedSword.cs is on equip.
 

Attachments

  • BondedSword.cs
    3.1 KB · Views: 56
  • DonationWeapon.cs
    6.2 KB · Views: 45

duponthigh

Sorceror
This is a basic item that bonds to one character by serial. It can be used as a base to make other items similar. Weapons, Armor or whatever.

This particular item bonds when first equipped.
Some of the code may look old. Because it is. This was made/created April 10, 2002 with a few recent edits as to item name but still compiles and works in SVN 952. Report any bugs.

Code:
using System;
using Server.Network;
using Server.Items;
 
namespace Server.Items
{
    [FlipableAttribute( 0xF61, 0xF60 )]
    public class Soulsword : BaseSword
    {
 
        private int BoundToSoul = 0;// Start binding value as zero.
 
        public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.ArmorIgnore; } }
        public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.ConcussionBlow; } }
 
        public override int AosStrengthReq{ get{ return 35; } }
        public override int AosMinDamage{ get{ return 15; } }
        public override int AosMaxDamage{ get{ return 16; } }
        public override int AosSpeed{ get{ return 30; } }
        public override float MlSpeed{ get{ return 3.50f; } }
 
        public override int OldStrengthReq{ get{ return 25; } }
        public override int OldMinDamage{ get{ return 5; } }
        public override int OldMaxDamage{ get{ return 33; } }
        public override int OldSpeed{ get{ return 35; } }
 
        public override int DefHitSound{ get{ return 0x237; } }
        public override int DefMissSound{ get{ return 0x23A; } }
 
        public override int InitMinHits{ get{ return 31; } }
        public override int InitMaxHits{ get{ return 110; } }
 
        [Constructable]
        public Soulsword() : base( 0xF61 )
        {
            Weight = 7.0;
 
            Name = "a soul sword";
 
            BoundToSoul = 0; // Create item with value at zero. Will show in [props as ParentEntity and RootParentEntitty as null.
        }
                public override bool OnEquip( Mobile from )
              {
                  if(BoundToSoul == 0) //Check to see if bound to a serial.
                  {
                      BoundToSoul = from.Serial; //Bind to a serial on first time equipped.
 
                        this.Name = from.Name.ToString() + " [Soul Bound]";//Change item name and add who it is bound to.
 
                      from.Emote( "* " + from.Name + " feels a weird energy overwhelming his body *" );
 
 
              base.OnEquip( from );
 
              return true; //Allow it to bind to the first player to equip it after creation.
                    //Will show in [props as ParentEntity and RootParentEntitty as [m] Serial, "Player Name"
 
 
              }
                  else if(BoundToSoul == from.Serial) //Check to see if sword is bound to who is equiping it.
              {
 
                  from.Emote( "* " + from.Name + " draws uppon the power of the soul *" );
 
 
              base.OnEquip( from );
 
              return true; //Allow player who had bound to sword to equip it.
 
 
              }
              else
              {
                  from.Emote( "* The sword refuses to allow you equip it *" );
 
            return false; //Disallow any one else from equiping the sword.
        }
    }
        public Soulsword( Serial serial ) : base( serial )
        {
        }
 
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
 
            writer.Write( (int) 0 ); // version
                writer.Write( (int) BoundToSoul );//Serialize who it is bound to.
        }
 
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
 
            int version = reader.ReadInt();
                BoundToSoul = reader.ReadInt();//Read on startup who it is bound to.
        }
    }
}


Thanks so much.im just a beginner coder but hope to be great one day like one of you guys.allways apperciate the help.Thank you for your time to read my post also :)
 
Top