Example #1
0
		public void RemoveProcHandler(IProcHandler handler)
		{
			if (m_procHandlers != null)
			{
				m_procHandlers.Remove(handler);
			}
		}
Example #2
0
		public AddProcHandler(IProcHandler handler)
		{
			ProcHandler = handler;
		}
Example #3
0
		public void AddProcHandler(IProcHandler handler)
		{
			if (m_procHandlers == null)
			{
				m_procHandlers = new List<IProcHandler>(5);
			}
			m_procHandlers.Add(handler);
		}
Example #4
0
        /// <summary>
        /// Called when this Item gets unequipped.
        /// Requires map context.
        /// </summary>
        public void OnUnEquip(InventorySlot slot)
        {
            if (!IsApplied)
            {
                return;
            }
            IsApplied = false;
            if (!m_template.IsAmmo)
            {
                m_owner.SetVisibleItem(slot, null);
            }
            m_template.RemoveStatMods(m_owner);
            if (m_template.EquipSpells != null)
            {
                foreach (Spell equipSpell in m_template.EquipSpells)
                {
                    if (equipSpell.IsAura)
                    {
                        m_owner.Auras.Remove(equipSpell);
                    }
                }
            }

            for (int index = 0; index < m_template.Resistances.Length; ++index)
            {
                int resistance = m_template.Resistances[index];
                if (resistance > 0)
                {
                    m_owner.ModBaseResistance((DamageSchool)index, -resistance);
                }
            }

            if (slot == InventorySlot.Invalid)
            {
                m_owner.UpdateRangedDamage();
            }
            else if (m_template.InventorySlotType == InventorySlotType.Shield)
            {
                m_owner.UpdateBlockChance();
            }
            if (m_template.Set != null)
            {
                Spell[] spellArray =
                    m_template.Set.Boni.Get(m_owner.Inventory.GetSetCount(m_template.Set) - 1U);
                if (spellArray != null)
                {
                    foreach (Spell index in spellArray)
                    {
                        Aura aura = m_owner.Auras[index, true];
                        if (aura != null)
                        {
                            aura.Remove(false);
                        }
                    }
                }
            }

            if (m_hitProc != null)
            {
                m_owner.RemoveProcHandler(m_hitProc);
                m_hitProc = null;
            }

            m_owner.PlayerAuras.OnBeforeUnEquip(this);
            if (m_owner.Inventory.m_ItemEquipmentEventHandlers != null)
            {
                foreach (IItemEquipmentEventHandler equipmentEventHandler in m_owner.Inventory
                         .m_ItemEquipmentEventHandlers)
                {
                    equipmentEventHandler.OnBeforeUnEquip(this);
                }
            }

            m_template.NotifyUnequip(this);
        }
Example #5
0
        /// <summary>
        /// Called when this Item gets unequipped.
        /// Requires map context.
        /// </summary>
        public void OnUnEquip(InventorySlot slot)
        {
            if (!IsApplied)
            {
                return;
            }
            IsApplied = false;

            if (!m_template.IsAmmo)
            {
                m_owner.SetVisibleItem(slot, null);
            }
            m_template.RemoveStatMods(m_owner);

            // remove triggered buffs
            if (m_template.EquipSpells != null)
            {
                foreach (var spell in m_template.EquipSpells)
                {
                    if (spell.IsAura)
                    {
                        m_owner.Auras.Remove(spell);
                    }
                }
            }

            // remove procs
            if (m_template.HitSpells != null)
            {
                foreach (var spell in m_template.HitSpells)
                {
                    m_owner.RemoveProcHandler(spell.SpellId);
                }
            }

            // resistances
            for (var i = 0; i < m_template.Resistances.Length; i++)
            {
                var res = m_template.Resistances[i];
                if (res > 0)
                {
                    m_owner.ModBaseResistance((DamageSchool)i, -res);
                }
            }

            // ammo
            if (slot == InventorySlot.Invalid)
            {
                // ammo
                m_owner.UpdateRangedDamage();
            }

            // block rating
            else if (m_template.InventorySlotType == InventorySlotType.Shield)
            {
                m_owner.UpdateBlockChance();
            }

            // set boni
            if (m_template.Set != null)
            {
                var setCount = m_owner.Inventory.GetSetCount(m_template.Set);
                var boni     = m_template.Set.Boni.Get(setCount - 1);
                if (boni != null)
                {
                    foreach (var bonus in boni)
                    {
                        var aura = m_owner.Auras[bonus, true];
                        if (aura != null)
                        {
                            aura.Remove(false);
                        }
                    }
                }
            }

            // enchants
            if (m_enchantments != null)
            {
                foreach (var enchant in m_enchantments)
                {
                    if (enchant != null)
                    {
                        SetEnchantUnequipped(enchant);
                    }
                }
            }

            // hit proc
            if (m_hitProc != null)
            {
                m_owner.RemoveProcHandler(m_hitProc);
                m_hitProc = null;
            }

            m_owner.PlayerAuras.OnBeforeUnEquip(this);
            if (m_owner.Inventory.m_ItemEquipmentEventHandlers != null)
            {
                foreach (var handler in m_owner.Inventory.m_ItemEquipmentEventHandlers)
                {
                    handler.OnBeforeUnEquip(this);
                }
            }

            m_template.NotifyUnequip(this);
        }
Example #6
0
        /// <summary>
        /// Called when this Item gets equipped.
        /// Requires map context.
        /// </summary>
        public void OnEquip()
        {
            if (IsApplied)
            {
                return;
            }
            IsApplied = true;

            var slot = (InventorySlot)Slot;
            var chr  = OwningCharacter;

            if (slot < InventorySlot.Bag1 && !m_template.IsAmmo)
            {
                chr.SetVisibleItem(slot, this);
            }
            m_template.ApplyStatMods(chr);

            // binding
            if (m_template.BondType == ItemBondType.OnEquip)
            {
                Flags |= ItemFlags.Soulbound;
            }

            // spell casting
            if (chr.IsUsingSpell)
            {
                // equipping items cancels SpellCasts
                chr.SpellCast.Cancel();
            }

            // Apply resistance boni
            for (var i = 0; i < m_template.Resistances.Length; i++)
            {
                var res = m_template.Resistances[i];
                if (res > 0)
                {
                    chr.ModBaseResistance((DamageSchool)i, res);
                }
            }
            foreach (var enchant in GetAllEnchantments())
            {
                foreach (var effect in enchant.Entry.Effects)
                {
                    if (effect.Type == ItemEnchantmentType.Resistance)
                    {
                        // add resistances
                        chr.ModBaseResistance((DamageSchool)effect.Misc, effect.MaxAmount);
                    }
                }
            }

            // ammo
            if (slot == InventorySlot.Invalid)
            {
                // ammo
                chr.UpdateRangedDamage();
            }

            // block rating
            else if (m_template.InventorySlotType == InventorySlotType.Shield)
            {
                chr.UpdateBlockChance();
            }

            // cast spells
            if (m_template.EquipSpells != null)
            {
                chr.SpellCast.TriggerAll(chr, m_template.EquipSpells);
            }

            // add procs
            if (m_template.HitSpells != null)
            {
                foreach (var spell in m_template.HitSpells)
                {
                    chr.AddProcHandler(m_hitProc = new ItemHitProcHandler(this, spell));
                }
            }

            // set boni
            if (m_template.Set != null)
            {
                var setCount = chr.Inventory.GetSetCount(m_template.Set);
                var boni     = m_template.Set.Boni.Get(setCount - 1);
                if (boni != null)
                {
                    chr.SpellCast.TriggerAll(chr, boni);
                }
            }

            // enchants
            if (m_enchantments != null)
            {
                foreach (var enchant in m_enchantments)
                {
                    if (enchant != null)
                    {
                        SetEnchantEquipped(enchant);
                    }
                }
            }

            m_owner.PlayerAuras.OnEquip(this);
            if (m_owner.Inventory.m_ItemEquipmentEventHandlers != null)
            {
                foreach (var handler in m_owner.Inventory.m_ItemEquipmentEventHandlers)
                {
                    handler.OnEquip(this);
                }
            }

            m_template.NotifyEquip(this);
        }
Example #7
0
 public AddProcHandler(IProcHandler handler)
 {
     this.ProcHandler = handler;
 }
Example #8
0
 public AddProcHandler(IProcHandler handler)
 {
     ProcHandler = handler;
 }