Weapon Abilities on items with a non-weapon ItemID

Candy Apple

Squire
Nov 14, 2016
293
26
28
45
hello I have a silly question I looked and looked but no luck unless im looking in the wrong place! Im trying to add Skill Bonuses to say a robe and i tried everything in the xml spawner. Id like to make this a drop off of a MOB! However at this point I dont Script yet but know a way around the XML System butim stuck now :(
 

Piotr

Rookie
Oct 1, 2016
81
7
8
30
after combing through the 4 pages of posts on the first link i found three scripts for the system that cannot be downloaded anymore


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

namespace Server
{
    public static class CustomWeaponAbilities
    {
        public static void Initialize()
        {
            EventSink.Login += new LoginEventHandler( EventSink_Login );
        }
      
        private static void EventSink_Login( LoginEventArgs args )
        {
            Mobile from = args.Mobile;
          
            if ( from != null )
            {
                Check(from);
            }
        }
      
        public static void Check(Mobile from)
        {
            BaseWeapon weapon = (BaseWeapon)(from.Weapon);
            Check(weapon,from);
        }
      
        public static void Check(BaseWeapon weapon, Mobile from)
        {
            from.CloseGump(typeof(SpecialAttackGump));
          
            int abilities=0;
          
            if ( from != null )
            {
                abilities=HasAbilities( weapon, from);
              
                if(abilities>0)
                {
                    from.SendGump(new SpecialAttackGump( weapon, from, abilities ));
                }
            }
        }
      
        private static int HasAbilities(BaseWeapon weapon, Mobile from)
        {
            int number = 0;
          
            if(weapon.PrimaryAbility != null)
            {
                if(from.Skills[weapon.DefSkill].Base >= 70.0 || (from.Skills[weapon.GetUsedSkill(from,true)].Base >= 70.0 ))
                {
                    number++;
                }
            }
          
            if(weapon.SecondaryAbility != null)
            {
                if(from.Skills[weapon.DefSkill].Base >= 120.0 || (from.Skills[weapon.GetUsedSkill(from,true)].Base >= 120.0 ))
                {
                    number++;
                }
            }
            if(weapon.ThirdAbility != null)
            {
                if(from.Skills[weapon.DefSkill].Base >= 170.0 || (from.Skills[weapon.GetUsedSkill(from,true)].Base >= 170.0 ))
                {
                    number++;
                }
            }
            if(weapon.FourthAbility != null)
            {
                if(from.Skills[weapon.DefSkill].Base >= 210.0 || (from.Skills[weapon.GetUsedSkill(from,true)].Base >= 210.0 ))
                {
                    number++;
                }
            }
            if(weapon.FifthAbility != null)
            {
                if(from.Skills[weapon.DefSkill].Base >= 240.0 || (from.Skills[weapon.GetUsedSkill(from,true)].Base >= 240.0 ))
                {
                    number++;
                }
            }
          
            return number;
        }
      
        public static bool ServerSideSetAbility(Mobile from, int index)
        {
            if ( index == 0 )
                WeaponAbility.ClearCurrentAbility( from );
            else if ( index >= 1 && index < WeaponAbility.Abilities.Length )
            {
                if(WeaponAbility.SetCurrentAbility( from, WeaponAbility.Abilities[index] ))
                    return true;
            }
            return false;
        }
      
        public static void SetAbilities(BaseWeapon weapon, ref int Primary, ref int Secondary, ref int Third, ref int Fourth, ref int Fifth)
        {
            WeaponAbility prim = weapon.PrimaryAbility;
            WeaponAbility second = weapon.SecondaryAbility;
            WeaponAbility third = weapon.ThirdAbility;
            WeaponAbility forth = weapon.FourthAbility;
            WeaponAbility fifth = weapon.FifthAbility;
          
            for(int i=0;i<WeaponAbility.Abilities.Length;i++)
            {
                WeaponAbility index = WeaponAbility.Abilities[i];
                if(index!=null)
                {
                    if(prim == index)Primary=i;
                    if(second == index)Secondary=i;
                    if(third == index)Third=i;
                    if(forth == index)Fourth=i;
                    if(fifth == index)Fifth=i;
                }
            }
        }
    }
}
Code:
using System;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;

namespace Server.Gumps
{
    public class SpecialAttackGump : Gump
    {
        private BaseWeapon m_weapon;
      
        public int Abilities;
      
        private int Primary;
        private int Secondary;
        private int Third;
        private int Forth;
        private int Fifth;
      
private int PrimaryIcon {get{return Primary<32?0x51FF+Primary:WeaponAbility.Abilities[Primary].CustomGump;}}
private int SecondaryIcon {get{return  Secondary<32?0x51FF+Secondary:WeaponAbility.Abilities[Secondary].CustomGump;}}
private int ThirdIcon {get{return  Third<32?0x51FF+Third:WeaponAbility.Abilities[Third].CustomGump;}}
private int ForthIcon {get{return  Forth<32?0x51FF+Forth:WeaponAbility.Abilities[Forth].CustomGump;}}
private int FifthIcon {get{return  Fifth<32?0x51FF+Fifth:WeaponAbility.Abilities[Fifth].CustomGump;}}
      
        private int PrimaryState = 9781;
        private int SecondaryState = 9781;
        private int ThirdState = 9781;
        private int ForthState = 9781;
        private int FifthState = 9781;
      
        public SpecialAttackGump(BaseWeapon weapon, Mobile from,int abilities): base( 0, 0 )
        {
            m_weapon = weapon;
            Abilities = abilities;
            InitializeGump();
        }

        public SpecialAttackGump(BaseWeapon weapon, Mobile from, int abilities, int primary, int secondary): this( weapon, from, abilities, primary, secondary, 9781, 9781, 9781) {}
        public SpecialAttackGump(BaseWeapon weapon, Mobile from, int abilities, int primary, int secondary, int third, int Forth, int fifth): base( 0, 0 )
        {
            m_weapon = weapon;
            Abilities = abilities;
            PrimaryState = primary;
            SecondaryState = secondary;
            ThirdState = third;
            ForthState = Forth;
            FifthState = fifth;
            InitializeGump();
        }

        private void InitializeGump()
        {
            Closable=false;
            Disposable=true;
            Dragable=true;
            Resizable=false;
          
            AddButton(841,  490, 0x082D, 0x082D, 0, GumpButtonType.Reply, 0);
          
            CustomWeaponAbilities.SetAbilities(m_weapon, ref Primary, ref Secondary, ref Third, ref Forth, ref Fifth);

            AddButton(841,  509, PrimaryIcon, PrimaryIcon, 1, GumpButtonType.Reply, 0);
            AddImage(807,  509, PrimaryState);
          
            if(Abilities >= 2)
            {
                AddButton(841, 550, SecondaryIcon, SecondaryIcon, 2, GumpButtonType.Reply, 0);
                AddImage(807, 550, SecondaryState);
            }
            if(Abilities >= 3)
            {
                AddButton(841, 591, ThirdIcon, ThirdIcon, 3, GumpButtonType.Reply, 0);
                AddImage(807, 591, ThirdState);
            }
            if(Abilities >= 4)
            {
                AddButton(841, 632, ForthIcon, ForthIcon, 4, GumpButtonType.Reply, 0);
                AddImage(807, 632, ForthState);
            }
            if(Abilities >= 5)
            {
                AddButton(841, 673, FifthIcon, FifthIcon, 5, GumpButtonType.Reply, 0);
                AddImage(807, 673, FifthState);
            }
        }
      
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            int idx = info.ButtonID;
            if(idx==0) sender.Mobile.CloseGump(typeof(SpecialAttackGump));
            if(idx==1)
            {
                if(PrimaryState==9781)
                {
                    if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Primary))
                    {
                        PrimaryState=9780;
                        SecondaryState=9781;
                        ThirdState=9781;
                        ForthState=9781;
                        FifthState=9781;
                    }

                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));
                }
                else
                {
                    PrimaryState=9781;
                    WeaponAbility.ClearCurrentAbility( sender.Mobile );
                }
            }
            if(idx==2)
            {
                if(SecondaryState==9781)
                {
                    if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Secondary))
                    {
                        SecondaryState=9780;
                        PrimaryState=9781;
                        ThirdState=9781;
                        ForthState=9781;
                        FifthState=9781;
                    }

                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));
                }
                else
                {
                    SecondaryState=9781;
                    WeaponAbility.ClearCurrentAbility( sender.Mobile );
                }
            }
            if(idx==3)
            {
                if(ThirdState==9781)
                {
                    if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Third))
                    {
                        ThirdState=9780;
                        SecondaryState=9781;
                        PrimaryState=9781;
                        ForthState=9781;
                        FifthState=9781;
                    }

                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));
                  
                }
                else
                {
                    ThirdState=9781;
                    WeaponAbility.ClearCurrentAbility( sender.Mobile );
                }
            }
            if(idx==4)
            {
                if(ForthState==9781)
                {
                    if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Forth))
                    {
                        ForthState=9780;
                        SecondaryState=9781;
                        PrimaryState=9781;
                        ThirdState=9781;
                        FifthState=9781;
                    }

                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));
                }
                else
                {
                    ForthState=9781;
                    WeaponAbility.ClearCurrentAbility( sender.Mobile );
                }
            }
            if(idx==5)
            {
                if(FifthState==9781)
                {
                    if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Fifth))
                    {
                        FifthState=9780;
                        SecondaryState=9781;
                        PrimaryState=9781;
                        ForthState=9781;
                        ThirdState=9781;
                    }

                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));
                }
                else
                {
                    FifthState=9781;
                    WeaponAbility.ClearCurrentAbility( sender.Mobile );
                }
            }
        }
    }
}
Code:
// By LordGreyWolf

using System;
using Server;
using Server.Gumps;

namespace Server.Commands
{
    public class SpecialAttackCommands
    {
        public static void Initialize()
        {
            CommandSystem.Register( "SetPrimaryAbility", AccessLevel.Player, new CommandEventHandler( SetPrimaryAbility_OnCommand ) );
            CommandSystem.Register( "SetSecondaryAbility", AccessLevel.Player, new CommandEventHandler( SetSecondaryAbility_OnCommand ) );
            CommandSystem.Register( "SetThirdAbility", AccessLevel.Player, new CommandEventHandler( SetThirdAbility_OnCommand ) );
            CommandSystem.Register( "SetFourthAbility", AccessLevel.Player, new CommandEventHandler( SetFourthAbility_OnCommand ) );
            CommandSystem.Register( "SetFifthAbility", AccessLevel.Player, new CommandEventHandler( SetFifthAbility_OnCommand ) );
            CommandSystem.Register( "Set1", AccessLevel.Player, new CommandEventHandler( SetPrimaryAbility_OnCommand ) );
            CommandSystem.Register( "Set2", AccessLevel.Player, new CommandEventHandler( SetSecondaryAbility_OnCommand ) );
            CommandSystem.Register( "Set3", AccessLevel.Player, new CommandEventHandler( SetThirdAbility_OnCommand ) );
            CommandSystem.Register( "Set4", AccessLevel.Player, new CommandEventHandler( SetFourthAbility_OnCommand ) );
            CommandSystem.Register( "Set5", AccessLevel.Player, new CommandEventHandler( SetFifthAbility_OnCommand ) );
        }

        [Usage( "SetPrimaryAbility" )]
        [Aliases( "Set1" )]
        [Description( "Sets your Weapons Primary Ability Active." )]
        private static void SetPrimaryAbility_OnCommand( CommandEventArgs e )
        {
            Mobile from = e.Mobile;
            if(!from.HasGump(typeof(SpecialAttackGump)))return;
            SpecialAttackGump gump = (SpecialAttackGump)from.FindGump(typeof(SpecialAttackGump));
            gump.OnResponse(from.NetState,new RelayInfo(1,null,null));
        }

        [Usage( "SetSecondaryAbility" )]
        [Aliases( "Set2" )]
        [Description( "Sets your Weapons Secondary Ability Active." )]
        private static void SetSecondaryAbility_OnCommand( CommandEventArgs e )
        {
            Mobile from = e.Mobile;
            if(!from.HasGump(typeof(SpecialAttackGump)))return;
            SpecialAttackGump gump = (SpecialAttackGump)from.FindGump(typeof(SpecialAttackGump));
            if(gump.Abilities<2)return;
            gump.OnResponse(from.NetState,new RelayInfo(2,null,null));
        }

        [Usage( "SetThirdAbility" )]
        [Aliases( "Set3" )]
        [Description( "Sets your Weapons Third Ability Active." )]
        private static void SetThirdAbility_OnCommand( CommandEventArgs e )
        {
            Mobile from = e.Mobile;
            if(!from.HasGump(typeof(SpecialAttackGump)))return;
            SpecialAttackGump gump = (SpecialAttackGump)from.FindGump(typeof(SpecialAttackGump));
            if(gump.Abilities<3)return;
            gump.OnResponse(from.NetState,new RelayInfo(3,null,null));
        }

        [Usage( "SetFourthAbility" )]
        [Aliases( "Set4" )]
        [Description( "Sets your Weapons Fourth Ability Active." )]
        private static void SetFourthAbility_OnCommand( CommandEventArgs e )
        {
            Mobile from = e.Mobile;
            if(!from.HasGump(typeof(SpecialAttackGump)))return;
            SpecialAttackGump gump = (SpecialAttackGump)from.FindGump(typeof(SpecialAttackGump));
            if(gump.Abilities<4)return;
            gump.OnResponse(from.NetState,new RelayInfo(4,null,null));
        }

        [Usage( "SetFifthAbility" )]
        [Aliases( "Set5" )]
        [Description( "Sets your Weapons Fifth Ability Active." )]
        private static void SetFifthAbility_OnCommand( CommandEventArgs e )
        {
            Mobile from = e.Mobile;
            if(!from.HasGump(typeof(SpecialAttackGump)))return;
            SpecialAttackGump gump = (SpecialAttackGump)from.FindGump(typeof(SpecialAttackGump));
            if(gump.Abilities<5)return;
            gump.OnResponse(from.NetState,new RelayInfo(5,null,null));
        }
    }
}
Digging up an old thead, but this is really interesting. Thank you for this!

Would you be able to create a command that would display the gump? I tried this script and it works fine, but the gump only shows up when you equip a weapon. Once you close the gump, you have to re-equip the weapon in order to display it again.