Example #1
0
 public ItemEnchantment(ItemEnchantmentEntry entry, EnchantSlot slot, DateTime applyTime, int duration)
 {
     Entry = entry;
     Slot = slot;
     ApplyTime = applyTime;
     Duration = duration;
 }
Example #2
0
        internal void SetEnchant(EnchantSlot slot, int id, int timeLeft)
        {
            if (EnchantIds == null)
            {
                EnchantIds = new int[(int)EnchantSlot.End];
            }
            EnchantIds[(int)slot] = id;
            if (slot == EnchantSlot.Temporary)
            {
                EnchantTempTime = timeLeft;
            }
            //switch (slot)
            //{
            //    case EnchantSlot.Permanent:
            //        EnchantPerm = id;
            //        break;
            //    case EnchantSlot.Temporary:
            //        EnchantTemp = id;
            //        EnchantTempTime = timeLeft;
            //        break;
            //    case EnchantSlot.Socket1:
            //        EnchantSock1 = id;
            //        break;
            //    case EnchantSlot.Socket2:
            //        EnchantSock2 = id;
            //        break;
            //    case EnchantSlot.Socket3:
            //        EnchantSock3 = id;
            //        break;
            //    case EnchantSlot.PropSlot0:
            //        EnchantProp0 = id;
            //        break;
            //    case EnchantSlot.PropSlot1:
            //        EnchantProp1 = id;
            //        break;
            //    case EnchantSlot.PropSlot2:
            //        EnchantProp2 = id;
            //        break;
            //    case EnchantSlot.PropSlot3:
            //        EnchantProp3 = id;
            //        break;
            //    case EnchantSlot.PropSlot4:
            //        EnchantProp4 = id;
            //        break;

            //}
        }
Example #3
0
        public bool HasGem(Asda2ItemId id)
        {
            if (m_enchantments != null && m_template.HasSockets)
            {
                for (EnchantSlot enchantSlot = EnchantSlot.Socket1; enchantSlot <= EnchantSlot.Bonus; ++enchantSlot)
                {
                    if (m_enchantments[(int)enchantSlot] != null &&
                        m_enchantments[(int)enchantSlot].Entry.GemTemplate != null &&
                        m_enchantments[(int)enchantSlot].Entry.GemTemplate.ItemId == id)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #4
0
        /// <summary>
        /// Applies a set of random enchants in the prop slots between from and to
        /// </summary>
        public bool ApplyRandomEnchants(List <ItemRandomEnchantEntry> entries, EnchantSlot from, EnchantSlot to)
        {
            var slot = from;

            if (m_enchantments != null)
            {
                while (m_enchantments[(int)slot] != null && m_enchantments.Length > (int)++slot)
                {
                }

                if (slot > to)
                {
                    // no more free slots
                    return(false);
                }
            }

            var applied = false;

            foreach (var entry in entries)
            {
                if (Utility.Random(0, 100f) < entry.ChancePercent)
                {
                    var enchant = EnchantMgr.GetEnchantmentEntry(entry.EnchantId);
                    if (enchant != null)
                    {
                        ApplyEnchant(enchant, slot, 0, 0, true);
                        applied = true;
                        // ReSharper disable PossibleNullReferenceException
                        while (m_enchantments[(int)slot] != null && ++slot <= to)
                        {
                        }
                        // ReSharper restore PossibleNullReferenceException

                        if (slot > to)
                        {
                            // no more free slots
                            return(true);
                        }
                    }
                }
            }
            return(applied);
        }
Example #5
0
        /// <summary>
        /// Applies a set of random enchants in the prop slots between from and to
        /// </summary>
        public bool ApplyRandomEnchants(List <ItemRandomEnchantEntry> entries, EnchantSlot from, EnchantSlot to)
        {
            EnchantSlot enchantSlot = from;

            if (m_enchantments != null)
            {
                do
                {
                    ;
                }while(m_enchantments[(int)enchantSlot] != null &&
                       m_enchantments.Length > (int)++enchantSlot);
                if (enchantSlot > to)
                {
                    return(false);
                }
            }

            bool flag = false;

            foreach (ItemRandomEnchantEntry entry in entries)
            {
                if (Utility.Random(0.0f, 100f) < (double)entry.ChancePercent)
                {
                    ItemEnchantmentEntry enchantmentEntry = EnchantMgr.GetEnchantmentEntry(entry.EnchantId);
                    if (enchantmentEntry != null)
                    {
                        ApplyEnchant(enchantmentEntry, enchantSlot, 0, 0, true);
                        flag = true;
                        do
                        {
                            ;
                        }while(m_enchantments[(int)enchantSlot] != null && ++enchantSlot <= to);
                        if (enchantSlot > to)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(flag);
        }
Example #6
0
        /// <summary>
        /// Adds a new the <see cref="T:WCell.RealmServer.Items.Enchanting.ItemEnchantment" /> to the given Slot.
        /// Will remove any existing Enchantment in that slot.
        /// </summary>
        /// <param name="enchantSlot"></param>
        public void ApplyEnchant(ItemEnchantmentEntry enchantEntry, EnchantSlot enchantSlot, int duration, int charges,
                                 bool applyBoni)
        {
            if (m_enchantments == null)
            {
                m_enchantments = new ItemEnchantment[12];
            }
            if (m_enchantments[(int)enchantSlot] != null)
            {
                RemoveEnchant(enchantSlot);
            }
            ItemEnchantment enchant = new ItemEnchantment(enchantEntry, enchantSlot, DateTime.Now, duration);

            m_enchantments[(int)enchantSlot] = enchant;
            m_record.SetEnchant(enchantSlot, (int)enchant.Entry.Id, duration);
            SetEnchantId(enchantSlot, enchantEntry.Id);
            SetEnchantDuration(enchantSlot, duration);
            if (charges > 0)
            {
                SetEnchantCharges(enchantSlot, charges - 1);
            }
            Character owningCharacter = OwningCharacter;

            if (owningCharacter == null)
            {
                return;
            }
            EnchantMgr.ApplyEnchantToItem(this, enchant);
            if (enchant.Entry.GemTemplate != null)
            {
                owningCharacter.Inventory.ModUniqueCount(enchant.Entry.GemTemplate, 1);
            }
            OnOwnerReceivedNewEnchant(enchant);
            if (!applyBoni || !IsEquippedItem)
            {
                return;
            }
            SetEnchantEquipped(enchant);
        }
Example #7
0
        /// <summary>
        /// Is called before adding the given amount of the given Item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="amount"></param>
        /// <param name="err"></param>
        internal void CheckUniqueness(IMountableItem item, ref int amount, ref InventoryError err, bool isNew)
        {
            ItemTemplate template = item.Template;

            if (!isNew)
            {
                return;
            }
            if (template.UniqueCount > 0 &&
                this.OwnerInventory.GetUniqueCount(template.ItemId) + amount > template.UniqueCount)
            {
                amount -= template.UniqueCount;
                if (amount < 1)
                {
                    err = InventoryError.CANT_CARRY_MORE_OF_THIS;
                    return;
                }
            }

            if (item.Enchantments == null)
            {
                return;
            }
            for (EnchantSlot enchantSlot = EnchantSlot.Socket1; enchantSlot < EnchantSlot.Bonus; ++enchantSlot)
            {
                ItemEnchantment enchantment = item.Enchantments[(uint)enchantSlot];
                if (enchantment != null && enchantment.Entry.GemTemplate != null &&
                    (enchantment.Entry.GemTemplate.UniqueCount > 0 &&
                     this.OwnerInventory.GetUniqueCount(enchantment.Entry.GemTemplate.ItemId) >=
                     enchantment.Entry.GemTemplate.UniqueCount))
                {
                    err = InventoryError.CANT_CARRY_MORE_OF_THIS;
                    break;
                }
            }
        }
Example #8
0
		public ItemEnchantmentEntry GetEnchant(EnchantSlot slot)
		{
			if (EnchantIds != null)
			{
				return EnchantMgr.GetEnchantmentEntry((uint)EnchantIds[(int)slot]);
			}
			return null;
		}
Example #9
0
 /// <summary>
 /// The time until the given Enchantment expires or <see cref="F:System.TimeSpan.Zero" /> if not temporary
 /// </summary>
 /// <param name="enchantSlot"></param>
 /// <returns></returns>
 public TimeSpan GetRemainingEnchantDuration(EnchantSlot enchantSlot)
 {
     return(m_enchantments[(uint)enchantSlot].RemainingTime);
 }
Example #10
0
 public void SetEnchantCharges(EnchantSlot slot, int value)
 {
     SetInt32(GetEnchantSlot(slot, EnchantInfoOffset.Charges) + 2, value);
 }
Example #11
0
 public void SetEnchantDuration(EnchantSlot slot, int value)
 {
     SetInt32(GetEnchantSlot(slot, EnchantInfoOffset.Duration) + 1, value);
 }
Example #12
0
 public void SetEnchantId(EnchantSlot slot, uint value)
 {
     SetUInt32(GetEnchantSlot(slot, EnchantInfoOffset.Id), value);
 }
Example #13
0
 private static int GetEnchantSlot(EnchantSlot slot, EnchantInfoOffset offset)
 {
     return((int)(22 + (int)slot * 3 + offset));
 }
Example #14
0
 public ItemEnchantmentEntry GetEnchant(EnchantSlot slot)
 {
   if(EnchantIds != null)
     return EnchantMgr.GetEnchantmentEntry((uint) EnchantIds[(int) slot]);
   return null;
 }
Example #15
0
		internal void SetEnchant(EnchantSlot slot, int id, int timeLeft)
		{
			if (EnchantIds == null)
			{
				EnchantIds = new int[(int)EnchantSlot.End];
			}
			EnchantIds[(int)slot] = id;
			if (slot == EnchantSlot.Temporary)
			{
				EnchantTempTime = timeLeft;
			}
			//switch (slot)
			//{
			//    case EnchantSlot.Permanent:
			//        EnchantPerm = id;
			//        break;
			//    case EnchantSlot.Temporary:
			//        EnchantTemp = id;
			//        EnchantTempTime = timeLeft;
			//        break;
			//    case EnchantSlot.Socket1:
			//        EnchantSock1 = id;
			//        break;
			//    case EnchantSlot.Socket2:
			//        EnchantSock2 = id;
			//        break;
			//    case EnchantSlot.Socket3:
			//        EnchantSock3 = id;
			//        break;
			//    case EnchantSlot.PropSlot0:
			//        EnchantProp0 = id;
			//        break;
			//    case EnchantSlot.PropSlot1:
			//        EnchantProp1 = id;
			//        break;
			//    case EnchantSlot.PropSlot2:
			//        EnchantProp2 = id;
			//        break;
			//    case EnchantSlot.PropSlot3:
			//        EnchantProp3 = id;
			//        break;
			//    case EnchantSlot.PropSlot4:
			//        EnchantProp4 = id;
			//        break;

			//}
		}
Example #16
0
	private void _OpenTooltip(EnchantSlot enchantslot)
	{
		if( true == TooltipMgr.Instance.IsOpenAny())
		{
			TooltipMgr.Instance.Clear();
			return;
		}
		
		if( null != enchantslot && null != enchantslot.getItem && 0 < enchantslot.getItem.ItemID)
		{
			TooltipMgr.Instance.OpenTooltip( TooltipMgr.eOPEN_DLG.normal, enchantslot.getItem.ItemID);
		}
	}
Example #17
0
 private static int GetEnchantSlot(EnchantSlot slot, EnchantInfoOffset offset)
 {
     return((int)ItemFields.ENCHANTMENT_1_1 + ((int)slot * 3) + (int)offset);
 }
Example #18
0
        public void SetEnchantId(EnchantSlot slot, uint value)
        {
            var enchBase = GetEnchantSlot(slot, EnchantInfoOffset.Id);

            SetUInt32(enchBase, value);
        }
Example #19
0
        public void SetEnchantCharges(EnchantSlot slot, int value)
        {
            var enchBase = GetEnchantSlot(slot, EnchantInfoOffset.Charges);

            SetInt32(enchBase + 2, value);
        }
Example #20
0
        public void SetEnchantDuration(EnchantSlot slot, int value)
        {
            var enchBase = GetEnchantSlot(slot, EnchantInfoOffset.Duration);

            SetInt32(enchBase + 1, value);
        }