public void ResendGump(AbilityType abilityType)
        {
            if (Engine.Player == null)
            {
                return;
            }

            int twoHandSerial = Engine.Player.GetLayer(Layer.TwoHanded);

            Item twoHandItem = Engine.Items.GetItem(twoHandSerial);

            if (twoHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == twoHandItem.ID);

                if (wd != null)
                {
                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            int oneHandSerial = Engine.Player.GetLayer(Layer.OneHanded);

            Item oneHandItem = Engine.Items.GetItem(oneHandSerial);

            if (oneHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == oneHandItem.ID);

                if (wd != null)
                {
                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            ResendGump(5, 11, abilityType);
        }
        public void SetAbility(AbilityType abilityType)
        {
            if (Engine.Player == null)
            {
                return;
            }

            switch (abilityType)
            {
            case AbilityType.Primary when !IsPrimaryEnabled:
                Enabled = AbilityType.Primary;
                break;

            case AbilityType.Secondary when !IsSecondaryEnabled:
                Enabled = AbilityType.Secondary;
                break;

            default:
                Enabled = AbilityType.None;
                break;
            }

            int twoHandSerial = Engine.Player.GetLayer(Layer.TwoHanded);

            Item twoHandItem = Engine.Items.GetItem(twoHandSerial);

            if (twoHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == twoHandItem.ID);

                if (wd != null)
                {
                    UOC.SetWeaponAbility(abilityType == AbilityType.Primary ? wd.Primary : wd.Secondary, abilityType);
                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            int oneHandSerial = Engine.Player.GetLayer(Layer.OneHanded);

            Item oneHandItem = Engine.Items.GetItem(oneHandSerial);

            if (oneHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == oneHandItem.ID);

                if (wd != null)
                {
                    UOC.SetWeaponAbility(abilityType == AbilityType.Primary ? wd.Primary : wd.Secondary, abilityType);
                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            // Fists etc
            ResendGump(5, 11, abilityType);
            UOC.SetWeaponAbility(abilityType == AbilityType.Primary ? 5 : 11, abilityType);
        }
        public bool CheckHands(int serial)
        {
            if (!Options.CurrentOptions.CheckHandsPotions)
            {
                return(false);
            }

            Item item = Engine.Items?.GetItem(serial);

            if (item == null || !_potionTypes.Contains(item.ID))
            {
                return(false);
            }

            // Explosion / Conflagaration pot doesn't need hand free
            if (item.ID == 0xf0d && item.Hue == 0 || item.ID == 0xf06 && item.Hue == 1161)
            {
                return(false);
            }

            if (_checkHandsInProgress)
            {
                UOC.SystemMessage(Strings.Arm___Disarm_already_in_progress___, (int)UOC.SystemMessageHues.Red);
                return(false);
            }

            _checkHandsInProgress = true;

            Item leftHand  = Engine.Player?.Equipment.FirstOrDefault(i => i.Layer == Layer.TwoHanded);
            Item rightHand = Engine.Player?.Equipment.FirstOrDefault(i => i.Layer == Layer.OneHanded);

            if (leftHand == null && rightHand != null)
            {
                //OSI crossbow in OneHanded layer??
                leftHand  = rightHand;
                rightHand = null;
            }

            WeaponData leftHandWD = null;

            if (leftHand != null)
            {
                leftHandWD = GetWeaponData(leftHand.ID);
            }

            if ((!(leftHandWD?.Twohanded ?? false) && leftHand?.Properties != null &&
                 !(leftHand.Properties?.Any(p => p.Cliloc == 1061171 /* Two-Handed Weapon */) ?? false) ||
                 leftHand?.Properties != null &&
                 !(leftHand.Properties?.All(p => p.Cliloc != 1072792 /* Balanced */) ?? false)) &&
                (rightHand == null || leftHand == null))
            {
                _checkHandsInProgress = false;
                return(false);
            }

            if (leftHand == null)
            {
                _checkHandsInProgress = false;
                return(false);
            }

            ActionPacketQueue.EnqueueDragDrop(leftHand.Serial, 1, Engine.Player.GetLayer(Layer.Backpack),
                                              QueuePriority.High);
            ActionPacketQueue.EnqueuePackets(
                new BasePacket[]
            {
                new UseObject(serial), new DragItem(leftHand.Serial, 1),
                new EquipRequest(leftHand.Serial, leftHand.Layer, (int)Engine.Player?.Serial)
            }, QueuePriority.High).ContinueWith(t => _checkHandsInProgress = false);

            return(true);
        }
        public void CheckAbility(int abilityIndex)
        {
            int twoHandSerial = Engine.Player.GetLayer(Layer.TwoHanded);

            Item twoHandItem = Engine.Items.GetItem(twoHandSerial);

            AbilityType abilityType = AbilityType.None;

            if (twoHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == twoHandItem.ID);

                if (wd != null)
                {
                    if (wd.Primary == abilityIndex)
                    {
                        abilityType = AbilityType.Primary;
                    }
                    else if (wd.Secondary == abilityIndex)
                    {
                        abilityType = AbilityType.Secondary;
                    }

                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            int oneHandSerial = Engine.Player.GetLayer(Layer.OneHanded);

            Item oneHandItem = Engine.Items.GetItem(oneHandSerial);

            if (oneHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == oneHandItem.ID);

                if (wd != null)
                {
                    if (wd.Primary == abilityIndex)
                    {
                        abilityType = AbilityType.Primary;
                    }
                    else if (wd.Secondary == abilityIndex)
                    {
                        abilityType = AbilityType.Secondary;
                    }

                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            if (abilityIndex == 5)
            {
                abilityType = AbilityType.Primary;
            }
            else if (abilityIndex == 11)
            {
                abilityType = AbilityType.Secondary;
            }

            ResendGump(5, 11, abilityType);
        }