Esempio n. 1
0
 public ItemEnchantment(ItemEnchantmentEntry entry, EnchantSlot slot, DateTime applyTime, int duration)
 {
     Entry     = entry;
     Slot      = slot;
     ApplyTime = applyTime;
     Duration  = duration;
 }
Esempio n. 2
0
		public override SpellFailedReason Initialize()
		{
			if (m_cast.TargetItem == null)
			{
				return SpellFailedReason.ItemGone;
			}

			if (m_cast.TargetItem.Template.Level < Effect.Spell.BaseLevel)
			{
				return SpellFailedReason.TargetLowlevel;
			}

			enchantEntry = EnchantMgr.GetEnchantmentEntry((uint)Effect.MiscValue);
			if (enchantEntry == null)
			{
				log.Error("Spell {0} refers to invalid EnchantmentEntry {1}", Effect.Spell, Effect.MiscValue);
				return SpellFailedReason.Error;
			}
			if (!enchantEntry.CheckRequirements(m_cast.CasterUnit))
			{
				return SpellFailedReason.MinSkill;
			}

			return SpellFailedReason.Ok;
		}
Esempio n. 3
0
 public ItemEnchantment(ItemEnchantmentEntry entry, EnchantSlot slot, DateTime applyTime, int duration)
 {
     Entry = entry;
     Slot = slot;
     ApplyTime = applyTime;
     Duration = duration;
 }
Esempio n. 4
0
 public ItemEnchantment(ItemEnchantmentEntry entry, EnchantSlot slot, DateTime applyTime, int duration)
 {
     this.Entry     = entry;
     this.Slot      = slot;
     this.ApplyTime = applyTime;
     this.Duration  = duration;
 }
Esempio n. 5
0
		public override void Initialize(ref SpellFailedReason failReason)
		{
			if (m_cast.UsedItem.Template.Level < Effect.Spell.BaseLevel)
			{
				failReason = SpellFailedReason.Lowlevel;
			}

			enchantEntry = EnchantMgr.GetEnchantmentEntry((uint)Effect.MiscValue);
			if (enchantEntry == null)
			{
				log.Error("Spell {0} refers to invalid EnchantmentEntry {1}", Effect.Spell, Effect.MiscValue);
				failReason = SpellFailedReason.Error;
			}
			else if (!enchantEntry.CheckRequirements(m_cast.CasterUnit))
			{
				failReason = SpellFailedReason.MinSkill;
			}
		}
Esempio n. 6
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();
            }
        }