示例#1
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);
        }
示例#2
0
        /// <summary>
        /// Called when this Item gets equipped.
        /// Requires map context.
        /// </summary>
        public void OnEquip()
        {
            if (IsApplied)
            {
                return;
            }
            IsApplied = true;
            InventorySlot slot            = (InventorySlot)Slot;
            Character     owningCharacter = OwningCharacter;

            if (slot < InventorySlot.Bag1)
            {
                int num = m_template.IsAmmo ? 1 : 0;
            }

            m_template.ApplyStatMods(owningCharacter);
            if (m_template.BondType == ItemBondType.OnEquip)
            {
                Flags |= ItemFlags.Soulbound;
            }
            if (owningCharacter.IsUsingSpell)
            {
                owningCharacter.SpellCast.Cancel(SpellFailedReason.Interrupted);
            }
            for (int index = 0; index < m_template.Resistances.Length; ++index)
            {
                int resistance = m_template.Resistances[index];
                if (resistance > 0)
                {
                    owningCharacter.ModBaseResistance((DamageSchool)index, resistance);
                }
            }

            if (slot == InventorySlot.Invalid)
            {
                owningCharacter.UpdateRangedDamage();
            }
            else if (m_template.InventorySlotType == InventorySlotType.Shield)
            {
                owningCharacter.UpdateBlockChance();
            }
            if (m_template.EquipSpells != null)
            {
                owningCharacter.SpellCast.TriggerAll(owningCharacter, m_template.EquipSpells);
            }
            if (m_template.Set != null)
            {
                Spell[] spellArray =
                    m_template.Set.Boni.Get(owningCharacter.Inventory.GetSetCount(m_template.Set) -
                                            1U);
                if (spellArray != null)
                {
                    owningCharacter.SpellCast.TriggerAll(owningCharacter, spellArray);
                }
            }

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

            m_template.NotifyEquip(this);
        }
示例#3
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);
        }