示例#1
0
 public static void LoadGemsEditorFiles()
 {
     try
     {
         DbcStores.InitFiles();
         Item.LoadData();
         GemProperties.LoadData();
         SpellItemEnchantment.LoadData();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        internal void InitializeTemplate()
        {
            if (Names == null)
            {
                Names = new string[(int)ClientLocale.End];
            }

            if (Descriptions == null)
            {
                Descriptions = new string[(int)ClientLocale.End];
            }

            if (DefaultDescription == null)
            {
                DefaultDescription = "";
            }

            if (string.IsNullOrEmpty(DefaultName) || Id == 0)
            {
                // something's off with these entries
                return;
            }

            ItemId = (ItemId)Id;
            //Faction = (FactionId)Faction; // faction, 3.2.2
            RequiredSkill = SkillHandler.Get(RequiredSkillId);
            Set = ItemMgr.GetSet(SetId);
            Lock = LockEntry.Entries.Get(LockId);
            RequiredFaction = FactionMgr.Get(RequiredFactionId);
            RequiredProfession = SpellHandler.Get(RequiredProfessionId);
            SubClassMask = (ItemSubClassMask)(1 << (int)SubClass);
            EquipmentSlots = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType);
            InventorySlotMask = (InventorySlotTypeMask)(1 << (int)InventorySlotType);
            IsAmmo = InventorySlotType == InventorySlotType.Ammo;
            IsKey = Class == ItemClass.Key;
            IsBag = InventorySlotType == InventorySlotType.Bag;
            IsContainer = Class == ItemClass.Container || Class == ItemClass.Quiver;

            // enchantables can't be stacked
            IsStackable = MaxAmount > 1 && RandomSuffixId == 0 && RandomPropertiesId == 0;
            IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon;
            SetIsWeapon();

            if (ToolCategory != 0)// && TotemCategory != TotemCategory.SkinningKnife)
            {
                ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this;
            }

            if (GemPropertiesId != 0)
            {
                GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId);
                if (GemProperties != null)
                {
                    GemProperties.Enchantment.GemTemplate = this;
                }
            }

            if (Sockets == null)
            {
                Sockets = new SocketInfo[ItemConstants.MaxSocketCount];
            }
            else if (Sockets.Contains(sock => sock.Color != 0))
            {
                HasSockets = true;
            }

            if (Damages == null)
            {
                Damages = DamageInfo.EmptyArray;
            }

            if (Resistances == null)
            {
                Resistances = new int[(int)DamageSchool.Count];
            }

            if (SocketBonusEnchantId != 0)
            {
                SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(SocketBonusEnchantId);
            }

            switch (Class)
            {
                case ItemClass.Weapon:
                    ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get((uint)SubClass);
                    break;
                case ItemClass.Armor:
                    ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get((uint)SubClass);
                    break;
            }

            if (SheathType == SheathType.Undetermined)
            {
                // TODO: Read sheath-id from Item.dbc
            }

            // spells
            if (Spells != null)
            {
                ArrayUtil.Prune(ref Spells);
                for (int i = 0; i < 5; i++)
                {
                    Spells[i].Index = (uint)i;
                    Spells[i].FinalizeAfterLoad();
                }
            }
            else
            {
                Spells = ItemSpell.EmptyArray;
            }

            UseSpell = Spells.Where(itemSpell => itemSpell.Trigger == ItemSpellTrigger.Use && itemSpell.Spell != null).FirstOrDefault();
            if (UseSpell != null)
            {
                UseSpell.Spell.RequiredTargetType = RequiredTargetType;
                UseSpell.Spell.RequiredTargetId = RequiredTargetId;
            }

            EquipSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Equip && spell.Spell != null).Select(itemSpell =>
                    itemSpell.Spell).ToArray();

            SoulstoneSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Soulstone && spell.Spell != null).Select(itemSpell =>
                    itemSpell.Spell).FirstOrDefault();

            HitSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.ChanceOnHit && spell.Spell != null).Select(itemSpell =>
                    itemSpell.Spell).ToArray();

            if (UseSpell != null && (UseSpell.Id == SpellId.Learning || UseSpell.Id == SpellId.Learning_2))
            {
                // Teaching
                TeachSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Consume).FirstOrDefault();
            }

            ConsumesAmount =
                (Class == ItemClass.Consumable ||
                Spells.Contains(spell => spell.Trigger == ItemSpellTrigger.Consume)) &&
                (UseSpell == null || !UseSpell.HasCharges);

            IsHearthStone = UseSpell != null && UseSpell.Spell.IsHearthStoneSpell;

            IsInventory = InventorySlotType != InventorySlotType.None &&
                InventorySlotType != InventorySlotType.Bag &&
                InventorySlotType != InventorySlotType.Quiver &&
                InventorySlotType != InventorySlotType.Relic;

            // find set
            if (SetId != 0)
            {
                var set = ItemMgr.Sets.Get((uint)SetId);
                if (set != null)
                {
                    ArrayUtil.Add(ref set.Templates, this);
                }
            }

            // truncate arrays
            if (Mods != null)
            {
                ArrayUtil.TruncVals(ref Mods);
            }
            else
            {
                Mods = StatModifier.EmptyArray;
            }

            IsCharter = Flags.HasFlag(ItemFlags.Charter);

            RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this);

            if (IsCharter)
            {
                Creator = () => new PetitionCharter();
            }
            else if (IsContainer)
            {
                Creator = () => new Container();
            }
            else
            {
                Creator = () => new Item();
            }
        }