/// <summary> /// Method for handling the removal of an item's spell from the Enchantment registry /// </summary> /// <param name="guidItem"></param> /// <param name="spellId"></param> public void RemoveItemSpell(ObjectGuid guidItem, uint spellId) { WorldObject item = GetWieldedItem(guidItem); if (item == null) { return; } SpellTable spellTable = DatManager.PortalDat.SpellTable; if (!spellTable.Spells.ContainsKey(spellId)) { Session.Network.EnqueueSend(new GameEventUseDone(Session, errorType: WeenieError.MagicInvalidSpellType)); return; } SpellBase spell = spellTable.Spells[spellId]; // Retrieve enchantment if (EnchantmentManager.HasSpell(spellId)) { EnchantmentManager.Dispel(EnchantmentManager.GetSpell(spellId)); } }
public void AuditItemSpells() { // cleans up bugged chars with dangling item set spells // from previous bugs var allPossessions = GetAllPossessions().ToDictionary(i => i.Guid, i => i); // this is a legacy method, but is still a decent failsafe to catch any existing issues // get active item enchantments var enchantments = Biota.PropertiesEnchantmentRegistry.Clone(BiotaDatabaseLock).Where(i => i.Duration == -1 && i.SpellId != (int)SpellId.Vitae).ToList(); foreach (var enchantment in enchantments) { var table = enchantment.HasSpellSetId ? allPossessions : EquippedObjects; // if this item is not equipped, remove enchantment if (!table.TryGetValue(new ObjectGuid(enchantment.CasterObjectId), out var item)) { var spell = new Spell(enchantment.SpellId, false); log.Error($"{Name}.AuditItemSpells(): removing spell {spell.Name} from {(enchantment.HasSpellSetId ? "non-possessed" : "non-equipped")} item"); EnchantmentManager.Dispel(enchantment); continue; } // is this item part of a set? if (!item.HasItemSet) { continue; } // get all of the equipped items in this set var setItems = EquippedObjects.Values.Where(i => i.HasItemSet && i.EquipmentSetId == item.EquipmentSetId).ToList(); // get all of the spells currently active from this set var currentSpells = GetSpellSet(setItems); // get all of the spells possible for this item set var possibleSpells = GetSpellSetAll((EquipmentSet)item.EquipmentSetId); // get the difference between them var inactiveSpells = possibleSpells.Except(currentSpells).ToList(); // remove any item set spells that shouldn't be active foreach (var inactiveSpell in inactiveSpells) { var removeSpells = enchantments.Where(i => i.SpellSetId == item.EquipmentSetId && i.SpellId == inactiveSpell.Id).ToList(); foreach (var removeSpell in removeSpells) { log.Error($"{Name}.AuditItemSpells(): removing spell {inactiveSpell.Name} from {item.EquipmentSetId}"); EnchantmentManager.Dispel(removeSpell); } } } }
public void AuditItemSpells() { // cleans up bugged chars with dangling item set spells // from previous bugs // get active item enchantments var enchantments = Biota.GetEnchantments(BiotaDatabaseLock).Where(i => i.Duration == -1 && i.SpellId != (int)SpellId.Vitae).ToList(); foreach (var enchantment in enchantments) { // if this item is not equipped, remove enchantment if (!EquippedObjects.TryGetValue(new ObjectGuid(enchantment.CasterObjectId), out var item)) { var spell = new Spell(enchantment.SpellId, false); log.Error($"{Name}.AuditItemSpells(): removing spell {spell.Name} from non-equipped item"); EnchantmentManager.Dispel(enchantment); continue; } // is this item part of a set? if (!item.HasItemSet) { continue; } // get all of the equipped items in this set var setItems = EquippedObjects.Values.Where(i => i.HasItemSet && i.EquipmentSetId == item.EquipmentSetId).ToList(); // get all of the spells currently active from this set var currentSpells = GetSpellSet((EquipmentSet)item.EquipmentSetId, setItems); // get all of the spells possible for this item set var possibleSpells = GetSpellSetAll((EquipmentSet)item.EquipmentSetId); // get the difference between them var inactiveSpells = possibleSpells.Except(currentSpells).ToList(); // remove any item set spells that shouldn't be active foreach (var inactiveSpell in inactiveSpells) { var removeSpells = enchantments.Where(i => i.SpellSetId == (uint)item.EquipmentSetId && i.SpellId == inactiveSpell.Id).ToList(); foreach (var removeSpell in removeSpells) { log.Error($"{Name}.AuditItemSpells(): removing spell {inactiveSpell.Name} from {item.EquipmentSetId}"); EnchantmentManager.Dispel(removeSpell); } } } }
public void EquipDequipItemFromSet(WorldObject item, List <Spell> spells, List <Spell> prevSpells) { // compare these 2 spell sets - // see which spells are being added, and which are being removed var addSpells = spells.Except(prevSpells); var removeSpells = prevSpells.Except(spells); // set spells are not affected by mana // if it's equipped, it's active. foreach (var spell in removeSpells) { EnchantmentManager.Dispel(EnchantmentManager.GetEnchantment(spell.Id, item.EquipmentSetId.Value)); } foreach (var spell in addSpells) { CreateItemSpell(item, spell.Id); } }