Пример #1
0
        public static void CastSpell(PlayerSocket socket, Packet packet)
        {
            byte castSpellID = packet.ReadByte();

            IMobile m     = socket.Mobile;
            ISpell  spell = World.GetSpellByCastID(castSpellID);

            if (spell == null)
            {
                return;
            }

            if (spell.SpellTargetType == SpellTargetType.Location)
            {
                int  X = packet.ReadInt16();
                int  Y = packet.ReadInt16();
                byte Z = packet.ReadByte();
                m.CastSpell(spell, new Point3D(X, Y, Z));
            }
            else
            if (spell.SpellTargetType == SpellTargetType.Player)
            {
                byte    playerType = packet.ReadByte();
                int     playerID   = packet.ReadInt16();
                IMobile target     = null;
                switch (playerType)
                {
                case 0:     //NPC/Mob
                    target = m.Map.GetMobile(playerID);
                    break;

                case 1:     //Players
                    if (Listener.Instance.PlayerSockets[playerID] != null)
                    {
                        target = Listener.Instance.PlayerSockets[playerID].Mobile;
                    }
                    break;
                }
                m.CastSpell(spell, target);
            }
        }