コード例 #1
0
        public static void HandleCliQueryNPCText(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            byte[] guidMask = { 4, 7, 3, 6, 0, 1, 5, 2 };
            byte[] guidBytes = { 5, 6, 7, 1, 2, 3, 0, 4 };

            var gossipTextId = packet.Read<int>();
            var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);

            var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid));

            if (gossipData != null)
            {
                PacketWriter queryNPCTextResponse = new PacketWriter(ServerMessage.QueryNPCTextResponse);
                BitPack BitPack = new BitPack(queryNPCTextResponse);

                queryNPCTextResponse.WriteInt32(gossipTextId);
                queryNPCTextResponse.WriteInt32(0);
                queryNPCTextResponse.WriteFloat(1);

                for (int i = 0; i < 7; i++)
                    queryNPCTextResponse.WriteUInt32(0);

                queryNPCTextResponse.WriteInt32(gossipData.BroadCastText.Id);

                for (int i = 0; i < 7; i++)
                    queryNPCTextResponse.WriteUInt32(0);

                BitPack.Write(1);
                BitPack.Flush();

                var size = (uint)queryNPCTextResponse.BaseStream.Length - 13;
                queryNPCTextResponse.WriteUInt32Pos(size, 8);

                session.Send(ref queryNPCTextResponse);
            }
        }
コード例 #2
0
        public static void HandleQueryGameObject(ref PacketReader packet, ref WorldClass session)
        {
            byte[] guidMask = { 4, 6, 7, 5, 3, 2, 1, 0 };
            byte[] guidBytes = { 0, 2, 3, 5, 6, 1, 4, 7 };

            BitUnpack BitUnpack = new BitUnpack(packet);

            var hasData = false;
            var id = packet.Read<int>();
            var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);

            PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse);
            BitPack BitPack = new BitPack(queryGameObjectResponse);

            GameObject gObject = DataMgr.FindGameObject(id);
            if (hasData = (gObject != null))
            {
                GameObjectStats stats = gObject.Stats;

                BitPack.Write(hasData);
                BitPack.Flush();

                queryGameObjectResponse.WriteInt32(stats.Id);
                queryGameObjectResponse.WriteInt32(0);
                queryGameObjectResponse.WriteInt32(stats.Type);
                queryGameObjectResponse.WriteInt32(stats.DisplayInfoId);

                queryGameObjectResponse.WriteCString(stats.Name);

                for (int i = 0; i < 3; i++)
                    queryGameObjectResponse.WriteCString("");

                queryGameObjectResponse.WriteCString(stats.IconName);
                queryGameObjectResponse.WriteCString(stats.CastBarCaption);
                queryGameObjectResponse.WriteCString("");

                foreach (var v in stats.Data)
                    queryGameObjectResponse.WriteInt32(v);

                queryGameObjectResponse.WriteFloat(stats.Size);
                queryGameObjectResponse.WriteUInt8((byte)stats.QuestItemId.Count);

                foreach (var v in stats.QuestItemId)
                    queryGameObjectResponse.WriteInt32(v);

                queryGameObjectResponse.WriteInt32(stats.ExpansionRequired);

                var size = (uint)queryGameObjectResponse.BaseStream.Length - 13;
                queryGameObjectResponse.WriteUInt32Pos(size, 9);

                session.Send(ref queryGameObjectResponse);
            }
            else
            {
                BitPack.Write(hasData);
                Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id);
            }
        }