Esempio n. 1
0
        /// <summary>Handles client's npc text query</summary>
        /// <param name="client">realm client</param>
        /// <param name="packet">packet incoming</param>
        public static void HandleNPCTextQuery(IRealmClient client, RealmPacketIn packet)
        {
            uint id = packet.ReadUInt32();

            packet.ReadEntityId();
            IGossipEntry entry = GossipMgr.GetEntry(id);

            if (entry == null)
            {
                return;
            }
            QueryHandler.SendNPCTextUpdate(client.ActiveCharacter, entry);
        }
Esempio n. 2
0
        /// <summary>Sends a page to the character</summary>
        /// <param name="chr">recieving character</param>
        /// <param name="owner">EntityID of sender</param>
        public static void SendPageToCharacter(GossipConversation convo, IList <QuestMenuItem> questItems)
        {
            WorldObject speaker     = convo.Speaker;
            Character   character   = convo.Character;
            GossipMenu  currentMenu = convo.CurrentMenu;
            IList <GossipMenuItemBase> gossipItems = currentMenu.GossipItems;
            IGossipEntry gossipEntry = currentMenu.GossipEntry;

            if (gossipEntry.IsDynamic)
            {
                QueryHandler.SendNPCTextUpdate(character, gossipEntry);
            }
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_GOSSIP_MESSAGE))
            {
                packet.Write(speaker.EntityId);
                packet.Write(0);
                packet.Write(gossipEntry.GossipId);
                long position = packet.Position;
                packet.Position += 4L;
                int num = 0;
                if (gossipItems != null)
                {
                    for (int index = 0; index < gossipItems.Count; ++index)
                    {
                        GossipMenuItemBase gossipMenuItemBase = gossipItems[index];
                        if (gossipMenuItemBase.Action == null || gossipMenuItemBase.Action.CanUse(convo))
                        {
                            packet.Write(index);
                            packet.Write((byte)gossipMenuItemBase.Icon);
                            packet.Write(gossipMenuItemBase.Input);
                            packet.Write((uint)gossipMenuItemBase.RequiredMoney);
                            packet.WriteCString(gossipMenuItemBase.GetText(convo));
                            packet.WriteCString(gossipMenuItemBase.GetConfirmText(convo));
                            ++num;
                        }
                    }
                }

                if (questItems != null)
                {
                    packet.WriteUInt(questItems.Count);
                    for (int index = 0; index < questItems.Count; ++index)
                    {
                        QuestMenuItem questItem = questItems[index];
                        packet.Write(questItem.ID);
                        packet.Write(questItem.Status);
                        packet.Write(questItem.Level);
                        packet.Write(0);
                        packet.Write((byte)0);
                        packet.WriteCString(questItem.Text);
                    }
                }
                else
                {
                    packet.Write(0);
                }

                packet.Position = position;
                packet.Write(num);
                character.Client.Send(packet, false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sends a page to the character
        /// </summary>
        /// <param name="chr">recieving character</param>
        /// <param name="owner">EntityID of sender</param>
        public static void SendPageToCharacter(GossipConversation convo,
                                               IList <QuestMenuItem> questItems)
        {
            var speaker = convo.Speaker;
            var chr     = convo.Character;

            var menu        = convo.CurrentMenu;
            var gossipItems = menu.GossipItems;
            var gossipEntry = menu.GossipEntry;

            if (gossipEntry.IsDynamic)
            {
                // not cached
                QueryHandler.SendNPCTextUpdate(chr, gossipEntry);
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GOSSIP_MESSAGE))
            {
                packet.Write(speaker.EntityId);
                packet.Write(0);                                                // new Flag field since 2.4.0 - menu id
                packet.Write(gossipEntry.GossipId);

                var countPos = packet.Position;
                packet.Position += 4;
                var count = 0;
                if (gossipItems != null)
                {
                    for (var i = 0; i < gossipItems.Count; i++)
                    {
                        var item = gossipItems[i];
                        if (item.Action != null && !item.Action.CanUse(convo))
                        {
                            continue;
                        }

                        packet.Write(i);
                        packet.Write((byte)item.Icon);
                        packet.Write(item.Input);
                        packet.Write((uint)item.RequiredMoney);
                        packet.WriteCString(item.GetText(convo));
                        packet.WriteCString(item.GetConfirmText(convo));
                        count++;
                    }
                }

                if (questItems != null)
                {
                    packet.WriteUInt(questItems.Count);
                    for (int i = 0; i < questItems.Count; i++)
                    {
                        var item = questItems[i];
                        packet.Write(item.ID);
                        packet.Write(item.Status);
                        packet.Write(item.Level);
                        packet.Write(0);                     // quest flags
                        packet.Write((byte)0);               // 3.3.3 flag (blue question or yelloe exclamation mark)
                        packet.WriteCString(item.Text);
                    }
                }
                else
                {
                    packet.Write(0);
                }

                packet.Position = countPos;
                packet.Write(count);

                chr.Client.Send(packet);
            }
        }