Exemple #1
0
 public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, int attackTime, float atackRange)
     : this(slot, minDmg, maxDmg, attackTime, DamageSchoolMask.Physical)
 {
     this.IsWeapon = true;
     this.MaxRange = atackRange;
     this.MinRange = 0.0f;
 }
Exemple #2
0
 public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, int attackTime, DamageSchoolMask dmgType)
 {
     InventorySlotMask = slot;
     AttackTime        = attackTime;
     MaxRange          = Unit.DefaultMeleeAttackRange;
     Damages           = new[] { new DamageInfo(dmgType, minDmg, maxDmg) };
 }
Exemple #3
0
		public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, int attackTime, DamageSchoolMask dmgType)
		{
			InventorySlotMask = slot;
			AttackTime = attackTime;
			MaxRange = Unit.DefaultMeleeAttackRange;
			Damages = new[] { new DamageInfo(dmgType, minDmg, maxDmg) };
		}
Exemple #4
0
 public GenericWeapon(InventorySlotTypeMask slot, DamageInfo[] damages, SkillId skill, float minRange, float maxRange, int attackTime)
 {
     InventorySlotMask = slot;
     Damages           = damages;
     Skill             = skill;
     MinRange          = minRange;
     MaxRange          = maxRange;
     AttackTime        = attackTime;
 }
Exemple #5
0
		public GenericWeapon(InventorySlotTypeMask slot, DamageInfo[] damages, SkillId skill, float minRange, float maxRange, int attackTime)
		{
			InventorySlotMask = slot;
			Damages = damages;
			Skill = skill;
			MinRange = minRange;
			MaxRange = maxRange;
			AttackTime = attackTime;
		}
Exemple #6
0
 public GenericWeapon(InventorySlotTypeMask slot, DamageInfo[] damages, SkillId skill, float minRange,
                      float maxRange, int attackTime)
 {
     this.InventorySlotMask = slot;
     this.Damages           = damages;
     this.Skill             = skill;
     this.MinRange          = minRange;
     this.MaxRange          = maxRange;
     this.AttackTime        = attackTime;
     this.IsWeapon          = true;
 }
Exemple #7
0
 public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, int attackTime,
                      DamageSchoolMask dmgType)
 {
     this.InventorySlotMask = slot;
     this.AttackTime        = attackTime;
     this.MaxRange          = Unit.DefaultMeleeAttackRange;
     this.Damages           = new DamageInfo[1]
     {
         new DamageInfo(dmgType, minDmg, maxDmg)
     };
     this.IsWeapon = true;
 }
Exemple #8
0
        /// <summary>
        /// Disarms the weapon of the given type (WeaponMainHand, WeaponRanged or WeaponOffHand)
        /// </summary>
        public void SetDisarmed(InventorySlotType type)
        {
            var m = type.ToMask();

            if (m_DisarmMask.HasAnyFlag(m))
            {
                return;
            }

            m_DisarmMask |= m;

            SetWeapon(type, null);
        }
Exemple #9
0
        /// <summary>
        /// Rearms the weapon of the given type (WeaponMainHand, WeaponRanged or WeaponOffHand)
        /// </summary>
        public void UnsetDisarmed(InventorySlotType type)
        {
            var m = type.ToMask();

            if (!m_DisarmMask.HasAnyFlag(m))
            {
                return;
            }

            m_DisarmMask &= ~m;

            SetWeapon(type, GetOrInvalidateItem(type));
        }
Exemple #10
0
 public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, DamageSchoolMask dmgType)
     : this(slot, minDmg, maxDmg, GenericWeapon.Fists.AttackTime, dmgType)
 {
     this.IsWeapon = true;
 }
Exemple #11
0
 public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg)
     : this(slot, minDmg, maxDmg, DamageSchoolMask.Physical)
 {
     this.IsWeapon = true;
 }
Exemple #12
0
 public GenericWeapon(InventorySlotTypeMask slot, int damageCount)
 {
     this.InventorySlotMask = slot;
     this.Damages           = new DamageInfo[damageCount];
     this.IsWeapon          = true;
 }
Exemple #13
0
		/// <summary>
		/// Rearms the weapon of the given type (WeaponMainHand, WeaponRanged or WeaponOffHand)
		/// </summary>
		public void UnsetDisarmed(InventorySlotType type)
		{
			var m = type.ToMask();
			if (!m_DisarmMask.HasAnyFlag(m))
			{
				return;
			}

			m_DisarmMask &= ~m;

			SetWeapon(type, GetOrInvalidateItem(type));
		}
Exemple #14
0
		/// <summary>
		/// Disarms the weapon of the given type (WeaponMainHand, WeaponRanged or WeaponOffHand)
		/// </summary>
		public void SetDisarmed(InventorySlotType type)
		{
			var m = type.ToMask();
			if (m_DisarmMask.HasAnyFlag(m))
			{
				return;
			}

			m_DisarmMask |= m;

			SetWeapon(type, null);
		}
Exemple #15
0
		public bool MayCarry(InventorySlotTypeMask itemMask)
		{
			return (itemMask & DisarmMask) == 0;
		}
Exemple #16
0
 public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, int attackTime)
     : this(slot, minDmg, maxDmg, attackTime, DamageSchoolMask.Physical)
 {
     IsWeapon = true;
 }
Exemple #17
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 (TotemCategory != 0// && TotemCategory != TotemCategory.SkinningKnife)
				)
			{
				ArrayUtil.Set(ref ItemMgr.FirstTotemsPerCat, (uint)TotemCategory, 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();
			}
		}
Exemple #18
0
 public static bool HasAnyFlag(this InventorySlotTypeMask flags, InventorySlotType type)
 {
     return((flags & type.ToMask()) != InventorySlotTypeMask.None);
 }
Exemple #19
0
 public static bool HasAnyFlag(this InventorySlotTypeMask flags, InventorySlotTypeMask otherFlags)
 {
     return((flags & otherFlags) != InventorySlotTypeMask.None);
 }
Exemple #20
0
		public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, int attackTime)
			: this(slot, minDmg, maxDmg, attackTime, DamageSchoolMask.Physical)
		{
		}
Exemple #21
0
		public GenericWeapon(InventorySlotTypeMask slot, float minDmg, float maxDmg, DamageSchoolMask dmgType)
			: this(slot, minDmg, maxDmg, Fists.AttackTime, dmgType)
		{
		}
Exemple #22
0
		public GenericWeapon(InventorySlotTypeMask slot, int damageCount)
		{
			InventorySlotMask = slot;
			Damages = new DamageInfo[damageCount];
		}
Exemple #23
0
 public bool MayCarry(InventorySlotTypeMask itemMask)
 {
     return((itemMask & DisarmMask) == 0);
 }
Exemple #24
0
		public static bool HasAnyFlag(this InventorySlotTypeMask flags, InventorySlotTypeMask otherFlags)
		{
			return (flags & otherFlags) != 0;
		}
Exemple #25
0
		/// <summary>
		/// </summary>
		/// <returns>Whether a match was found</returns>
		public bool Iterate(InventorySlotTypeMask slots, Func<Item, bool> callback)
		{
			for (var sType = InventorySlotType.Head; sType < InventorySlotType.End; sType++)
			{
				if (!slots.HasAnyFlag(sType))
				{
					continue;
				}
				foreach (var slot in ItemMgr.GetEquipmentSlots(sType))
				{
					var item = this[slot];
					if (item != null && !callback(item))
					{
						return true;
					}
				}
			}
			return false;
		}
Exemple #26
0
 public GenericWeapon(InventorySlotTypeMask slot, int damageCount)
 {
     InventorySlotMask = slot;
     Damages           = new DamageInfo[damageCount];
 }