Opywang

Member
I'm using this code for attribute bonus deed, but I am unable to do resistance for some reason if anybody can help it'll be greatly appreciated.

Runuo forum has the answer, and the script I need, but the forum is down so I am unable to get over there to find it.

I know it says bonus mana increase deed, but I am trying to convert this into Physical resistance, fire, energy, and etc.

Code:
//Add BonusMana to an item
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server;

namespace Server.Items
{
    public class BonusManaIncreaseTarget : Target
    {           
        private BonusManaIncreaseDeed m_Deed;

        public BonusManaIncreaseTarget( BonusManaIncreaseDeed deed ) : base( 1, false, TargetFlags.None )
        {
            m_Deed = deed;
        }
       
        protected override void OnTarget( Mobile from, object target )
        {
            int BonusManaAdd = 5; //Amount ofBonus Mana to be added
            int BonusManaCap = 1000; //Limit ofBonus Mana that an item can have
           
            //Change to false if you don't want it to be used on any of these items
      bool allowWeapon = true;
            bool allowArmor = true;
            bool allowJewel = true;
            bool allowClothing = true;
            bool allowSpellbook = true;
            bool allowTalisman = true;
            bool allowQuiver = true;
           
            if ( target is BaseWeapon && allowWeapon)
            {
                Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((BaseWeapon)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((BaseWeapon)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
                    return;
            }
            else if ( target is BaseArmor && allowArmor )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((BaseArmor)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((BaseArmor)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
               
            }
            else if ( target is BaseClothing && allowClothing )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((BaseClothing)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((BaseClothing)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseTalisman && allowTalisman )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((BaseTalisman)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((BaseTalisman)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseJewel && allowJewel )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((BaseJewel)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((BaseJewel)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is Spellbook && allowSpellbook )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((Spellbook)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((Spellbook)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseQuiver && allowQuiver )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        BonusManaAdd = BonusManaToAdd(((BaseQuiver)item).Attributes.BonusMana, BonusManaAdd, BonusManaCap, from);
                        if( BonusManaAdd > 0 )
                        {
                            ((BaseQuiver)item).Attributes.BonusMana += BonusManaAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else
            {
                from.SendMessage( "You cannot use this deed on that!" );
            }
        }
       
        public int BonusManaToAdd(int itemBonusMana, int BonusManaAdd ,int BonusManaCap, Mobile from)
        {
            int ret = 0;
            if(itemBonusMana < BonusManaCap)
            {
                if( (itemBonusMana + BonusManaAdd ) > BonusManaCap )
                {
                    ret = BonusManaAdd - ( (itemBonusMana + BonusManaAdd ) - BonusManaCap );
                    from.SendMessage("You increase theBonus Mana on the item and it has now reached it's max. +"+ret+"Bonus Mana has been added.");
                }
                else{
                    from.SendMessage( "You increase theBonus Mana on the item. +"+BonusManaAdd+"Bonus Mana has been added." );
                    ret = BonusManaAdd;
                }
            }
            else
            {
                from.SendMessage( "That item has reached the maximum amount ofBonus Mana." );
            }
           
            return ret;
        }
    }

    public class BonusManaIncreaseDeed : Item
    {
        [Constructable]
        public BonusManaIncreaseDeed() : base( 0x14F0 )
        {
            Weight = 1.0;
            Name = "+5 Bonus Mana Increase Deed";
            LootType = LootType.Blessed;
        }

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

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

            writer.Write( (int) 0 ); // version
        }

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

            int version = reader.ReadInt();
        }

        public override bool DisplayLootType{ get{ return false; } }

        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
            {
                from.SendMessage("Which item would you like to increaseBonus Mana?"  );
                from.Target = new BonusManaIncreaseTarget( this );
            }
        }   
    }
}
 
Last edited by a moderator:
Sorry that I post a long script I don't know how to upload CS lol.

Anyway I tried to mess with it, and I keep messing it up for some reason, and I am not sure how to add right thank you if you can help.
 
Hello !

What is wrong with what you are trying ? It's not easy to find a solution without knowing what goes wrong ;)

Maybe is it because Physical Resistance (and the other ones) aren't in Attributes ?
You could try to apply the bonus on the item itself :
Code:
((BaseArmor)item).PhysicalBonus += BonusPhysicalAdd;

Just a supposition, not sure it's the issue as I haven't tested it.
 
O.K. wow! lol. I tried many things, and for some reason it keep giving me errors, but I am able to fix all the other stats except resistance bonus for armors.

Here is the original notepad, and I check I do have this PhysicalBonus in my folder, and it should work, but I am not sure why I'm not able to get it to work.

Maybe somebody can get it fix for me I'd appreciated it, and I will continue to try to make it work. This is stanima increase bonus, and I would like to convert this into PhysicalBunus, and make it work.

Code:
//Add BonusStam to an item
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server;

namespace Server.Items
{
    public class BonusStamIncreaseTarget : Target
    {          
        private BonusStamIncreaseDeed m_Deed;

        public BonusStamIncreaseTarget( BonusStamIncreaseDeed deed ) : base( 1, false, TargetFlags.None )
        {
            m_Deed = deed;
        }
      
        protected override void OnTarget( Mobile from, object target )
        {
            int BonusStamAdd = 2; //Amount ofBonus Stam to be added
            int BonusStamCap = 100000; //Limit ofBonus Stam that an item can have
          
            //Change to false if you don't want it to be used on any of these items
      bool allowWeapon = true;
            bool allowArmor = false;
            bool allowJewel = false;
            bool allowClothing = false;
            bool allowSpellbook = true;
            bool allowTalisman = false;
            bool allowQuiver = false;
          
            if ( target is BaseWeapon && allowWeapon)
            {
                Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((BaseWeapon)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((BaseWeapon)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
                    return;
            }
            else if ( target is BaseArmor && allowArmor )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((BaseArmor)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((BaseArmor)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
              
            }
            else if ( target is BaseClothing && allowClothing )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((BaseClothing)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((BaseClothing)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseTalisman && allowTalisman )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((BaseTalisman)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((BaseTalisman)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseJewel && allowJewel )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((BaseJewel)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((BaseJewel)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is Spellbook && allowSpellbook )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((Spellbook)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((Spellbook)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseQuiver && allowQuiver )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Stam to that item there!" );
                    }
                    else
                    {
                        BonusStamAdd = BonusStamToAdd(((BaseQuiver)item).Attributes.BonusStam, BonusStamAdd, BonusStamCap, from);
                        if( BonusStamAdd > 0 )
                        {
                            ((BaseQuiver)item).Attributes.BonusStam += BonusStamAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else
            {
                from.SendMessage( "You cannot use this deed on that!" );
            }
        }
      
        public int BonusStamToAdd(int itemBonusStam, int BonusStamAdd ,int BonusStamCap, Mobile from)
        {
            int ret = 0;
            if(itemBonusStam < BonusStamCap)
            {
                if( (itemBonusStam + BonusStamAdd ) > BonusStamCap )
                {
                    ret = BonusStamAdd - ( (itemBonusStam + BonusStamAdd ) - BonusStamCap );
                    from.SendMessage("You increase theBonus Stam on the item and it has now reached it's max. +"+ret+"Bonus Stam has been added.");
                }
                else{
                    from.SendMessage( "You increase theBonus Stam on the item. +"+BonusStamAdd+"Bonus Stam has been added." );
                    ret = BonusStamAdd;
                }
            }
            else
            {
                from.SendMessage( "That item has reached the maximum amount ofBonus Stam." );
            }
          
            return ret;
        }
    }

    public class BonusStamIncreaseDeed : Item
    {
        [Constructable]
        public BonusStamIncreaseDeed() : base( 0x14F0 )
        {
            Weight = 1.0;
            Name = "+2 Bonus Stam Increase Deed";
            LootType = LootType.Blessed;
        }

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

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

            writer.Write( (int) 0 ); // version
        }

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

            int version = reader.ReadInt();
        }

        public override bool DisplayLootType{ get{ return false; } }

        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
            {
                from.SendMessage("Which item would you like to increaseBonus Stam?"  );
                from.Target = new BonusStamIncreaseTarget( this );
            }
        }  
    }
}
[doublepost=1521804497][/doublepost]O.K. here I try to carefully convert it, but it has many error, and I am not able to fix them, but I will share what I have done, and maybe somebody can look at it, and see what the problem is.

Here is the picture I took a screen shot of the errors.
https://gyazo.com/f6103509900bfc83ddc81204e1c32a4e

Code:
//Add PhysicalBonus to an item
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server;

namespace Server.Items
{
    public class PhysicalBonusIncreaseTarget : Target
    {          
        private PhysicalBonusIncreaseDeed m_Deed;

        public PhysicalBonusIncreaseTarget( PhysicalBonusIncreaseDeed deed ) : base( 1, false, TargetFlags.None )
        {
            m_Deed = deed;
        }
      
        protected override void OnTarget( Mobile from, object target )
        {
            int PhysicalBonusAdd = 5; //Amount ofBonus Mana to be added
            int PhysicalBonusCap = 100000; //Limit ofBonus Mana that an item can have
          
            //Change to false if you don't want it to be used on any of these items
      bool allowWeapon = true;
            bool allowArmor = false;
            bool allowJewel = false;
            bool allowClothing = false;
            bool allowSpellbook = true;
            bool allowTalisman = false;
            bool allowQuiver = false;
          
            if ( target is BaseWeapon && allowWeapon)
            {
                Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((BaseWeapon)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((BaseWeapon)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
                    return;
            }
            else if ( target is BaseArmor && allowArmor )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((BaseArmor)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((BaseArmor)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
              
            }
            else if ( target is BaseClothing && allowClothing )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((BaseClothing)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((BaseClothing)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseTalisman && allowTalisman )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((BaseTalisman)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((BaseTalisman)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseJewel && allowJewel )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((BaseJewel)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((BaseJewel)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is Spellbook && allowSpellbook )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((Spellbook)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((Spellbook)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else if ( target is BaseQuiver && allowQuiver )
            {
                    Item item = (Item)target;
                    if( item.RootParent != from )
                    {
                        from.SendMessage( "You cannot addBonus Mana to that item there!" );
                    }
                    else
                    {
                        PhysicalBonusAdd = PhysicalBonustoAdd(((BaseQuiver)item).Attributes.PhysicalBonus, PhysicalBonusAdd, PhysicalBonusCap, from);
                        if( PhysicalBonusAdd > 0 )
                        {
                            ((BaseQuiver)item).Attributes.PhysicalBonus += PhysicalBonusAdd;
                            m_Deed.Delete();
                        }
                    }
            }
            else
            {
                from.SendMessage( "You cannot use this deed on that!" );
            }
        }
      
        public int PhysicalBonustoAdd(int itemPhysicalBonus, int PhysicalBonusAdd ,int PhysicalBonusCap, Mobile from)
        {
            int ret = 0;
            if(itemPhysicalBonus < PhysicalBonusCap)
            {
                if( (itemPhysicalBonus + PhysicalBonusAdd ) > PhysicalBonusCap )
                {
                    ret = PhysicalBonusAdd - ( (itemPhysicalBonus + PhysicalBonusAdd ) - PhysicalBonusCap );
                    from.SendMessage("You increase theBonus Mana on the item and it has now reached it's max. +"+ret+"Bonus Mana has been added.");
                }
                else{
                    from.SendMessage( "You increase theBonus Mana on the item. +"+PhysicalBonusAdd+"Bonus Mana has been added." );
                    ret = PhysicalBonusAdd;
                }
            }
            else
            {
                from.SendMessage( "That item has reached the maximum amount ofBonus Mana." );
            }
          
            return ret;
        }
    }

    public class PhysicalBonusIncreaseDeed : Item
    {
        [Constructable]
        public PhysicalBonusIncreaseDeed() : base( 0x14F0 )
        {
            Weight = 1.0;
            Name = "+5 Bonus Mana Increase Deed";
            LootType = LootType.Blessed;
        }

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

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

            writer.Write( (int) 0 ); // version
        }

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

            int version = reader.ReadInt();
        }

        public override bool DisplayLootType{ get{ return false; } }

        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
            {
                from.SendMessage("Which item would you like to increaseBonus Mana?"  );
                from.Target = new PhysicalBonusIncreaseTarget( this );
            }
        }  
    }
}
 
Last edited:

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back