示例#1
0
        /// <summary>
        /// Auto-equips the weapon if the mobile can equip it.
        /// Else, the item is added to the mobile backpack.
        /// </summary>
        /// <param name="item">Item to equip</param>
        /// <param name="mustEquip">Forces the item to be equipped</param>
        /// <param name="m">Mobile to be equipped</param>
        /// <param name="t">Type of the item</param>
        private static void EquipItem(BaseWeapon item, bool mustEquip, Mobile m, Type t)
        {
            Container pack = m.Backpack;
            Layer layer = item.Layer;
            Item equips = m.FindItemOnLayer(layer);

            item.Quality = WeaponQuality.Exceptional;

            if (mustEquip)
            {
                if (equips != null)
                    pack.DropItem(equips);
            }

            if (pack.FindItemByType(t) != null || equips == item)
            {
                m.EquipItem(equips);
                return;
            }
            else
            {
                if (!Core.AOS)
                {
                    item.LootType = LootType.Regular;
                }

                if (mustEquip)
                {
                    if (equips != null)
                        pack.DropItem(equips);
                }

                if (m != null && m.EquipItem(item))
                    return;

                if (!mustEquip && pack != null)
                    pack.DropItem(item);
                else
                    item.Delete();
            }
        }
示例#2
0
        private static void StackWith(BaseWeapon toStack, List<BaseWeapon> itemList, int startIndex)
        {
            if (toStack == null || toStack.Deleted)
                return;

            for (int i = startIndex; i < itemList.Count; i++)
            {
                BaseWeapon item = itemList[i];
                if (ValidateWeapon(toStack, item))
                {
                    item.Amount += toStack.Amount;
                    toStack.Delete();
                    return;
                }
            }
        }