public void HandleActionQueryItemMana(ObjectGuid queryId) { if (queryId.Full == 0) { ManaQueryTarget = null; return; } // the object could be in the world or on the player, first check player WorldObject wo = GetInventoryItem(queryId); if (wo != null) { wo.QueryItemMana(Session); } else { // We could be wielded - let's check that next. if (EquippedObjects.TryGetValue(queryId, out wo)) { wo.QueryItemMana(Session); } } ManaQueryTarget = queryId.Full; }
public void AuditItemSpells() { // cleans up bugged chars with dangling item set spells // from previous bugs // this is a legacy method, but is still a decent failsafe to catch any existing issues // 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)) { // this can fail for item sets, so disabling this section /*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(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); } } } }