Esempio n. 1
0
        public static void HandleItemUse(WorldSession session, ClientItemUse itemUse)
        {
            Item item = session.Player.Inventory.GetItem(itemUse.Location);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            ItemSpecialEntry itemSpecial = GameTableManager.Instance.ItemSpecial.GetEntry(item.Entry.ItemSpecialId00);

            if (itemSpecial == null)
            {
                throw new InvalidPacketValueException();
            }

            if (itemSpecial.Spell4IdOnActivate > 0u)
            {
                if (itemSpecial.PrerequisiteIdGeneric00 > 0 && !PrerequisiteManager.Instance.Meets(session.Player, itemSpecial.PrerequisiteIdGeneric00))
                {
                    session.Player.SendGenericError(Game.Static.GenericError.UnlockItemFailed); // TODO: Confirm right error message.
                    return;
                }

                if (session.Player.Inventory.ItemUse(item))
                {
                    session.Player.CastSpell(itemSpecial.Spell4IdOnActivate, new SpellParameters
                    {
                        PrimaryTargetId = itemUse.TargetUnitId,
                        Position        = itemUse.Position
                    });
                }
            }
        }
Esempio n. 2
0
        public static void HandleItemUse(WorldSession session, ClientItemUse itemUse)
        {
            Item item = session.Player.Inventory.GetItem(itemUse.Location);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            ItemSpecialEntry itemSpecial = GameTableManager.ItemSpecial.GetEntry(item.Entry.ItemSpecialId00);

            if (itemSpecial == null)
            {
                throw new InvalidPacketValueException();
            }

            if (itemSpecial.Spell4IdOnActivate > 0u)
            {
                if (session.Player.Inventory.ItemUse(item))
                {
                    session.Player.CastSpell(itemSpecial.Spell4IdOnActivate, new SpellParameters
                    {
                        PrimaryTargetId = itemUse.TargetUnitId,
                        Position        = itemUse.Position
                    });
                }
            }
        }