Example #1
0
        public void SendQuestGiverQuestListMessage(WorldObject questgiver)
        {
            ObjectGuid guid           = questgiver.GetGUID();
            Locale     localeConstant = _session.GetSessionDbLocaleIndex();

            QuestGiverQuestListMessage questList = new QuestGiverQuestListMessage();

            questList.QuestGiverGUID = guid;

            QuestGreeting questGreeting = Global.ObjectMgr.GetQuestGreeting(questgiver.GetTypeId(), questgiver.GetEntry());

            if (questGreeting != null)
            {
                questList.GreetEmoteDelay = questGreeting.EmoteDelay;
                questList.GreetEmoteType  = questGreeting.EmoteType;
                questList.Greeting        = questGreeting.Text;

                if (localeConstant != Locale.enUS)
                {
                    QuestGreetingLocale questGreetingLocale = Global.ObjectMgr.GetQuestGreetingLocale(questgiver.GetTypeId(), questgiver.GetEntry());
                    if (questGreetingLocale != null)
                    {
                        ObjectManager.GetLocaleString(questGreetingLocale.Greeting, localeConstant, ref questList.Greeting);
                    }
                }
            }

            for (var i = 0; i < _questMenu.GetMenuItemCount(); ++i)
            {
                QuestMenuItem questMenuItem = _questMenu.GetItem(i);

                uint  questID = questMenuItem.QuestId;
                Quest quest   = Global.ObjectMgr.GetQuestTemplate(questID);
                if (quest != null)
                {
                    ClientGossipText text = new ClientGossipText();
                    text.QuestID         = questID;
                    text.ContentTuningID = quest.ContentTuningId;
                    text.QuestType       = questMenuItem.QuestIcon;
                    text.QuestFlags      = (uint)quest.Flags;
                    text.QuestFlagsEx    = (uint)quest.FlagsEx;
                    text.Repeatable      = quest.IsRepeatable();
                    text.QuestTitle      = quest.LogTitle;

                    if (localeConstant != Locale.enUS)
                    {
                        QuestTemplateLocale localeData = Global.ObjectMgr.GetQuestLocale(quest.Id);
                        if (localeData != null)
                        {
                            ObjectManager.GetLocaleString(localeData.LogTitle, localeConstant, ref text.QuestTitle);
                        }
                    }

                    questList.QuestDataText.Add(text);
                }
            }

            _session.SendPacket(questList);
        }
Example #2
0
        public void SendGossipMenu(uint titleTextId, ObjectGuid objectGUID)
        {
            _interactionData.Reset();
            _interactionData.SourceGuid = objectGUID;

            GossipMessagePkt packet = new GossipMessagePkt();

            packet.GossipGUID = objectGUID;
            packet.GossipID   = (int)_gossipMenu.GetMenuId();
            packet.TextID     = (int)titleTextId;

            foreach (var pair in _gossipMenu.GetMenuItems())
            {
                ClientGossipOptions opt  = new ClientGossipOptions();
                GossipMenuItem      item = pair.Value;
                opt.ClientOption = (int)pair.Key;
                opt.OptionNPC    = item.MenuItemIcon;
                opt.OptionFlags  = (byte)(item.IsCoded ? 1 : 0); // makes pop up box password
                opt.OptionCost   = (int)item.BoxMoney;           // money required to open menu, 2.0.3
                opt.Text         = item.Message;                 // text for gossip item
                opt.Confirm      = item.BoxMessage;              // accept text (related to money) pop up box, 2.0.3
                opt.Status       = GossipOptionStatus.Available;
                packet.GossipOptions.Add(opt);
            }

            for (byte i = 0; i < _questMenu.GetMenuItemCount(); ++i)
            {
                QuestMenuItem item    = _questMenu.GetItem(i);
                uint          questID = item.QuestId;
                Quest         quest   = Global.ObjectMgr.GetQuestTemplate(questID);
                if (quest != null)
                {
                    ClientGossipText text = new ClientGossipText();
                    text.QuestID         = questID;
                    text.ContentTuningID = quest.ContentTuningId;
                    text.QuestType       = item.QuestIcon;
                    text.QuestFlags      = (uint)quest.Flags;
                    text.QuestFlagsEx    = (uint)quest.FlagsEx;
                    text.Repeatable      = quest.IsRepeatable();

                    text.QuestTitle = quest.LogTitle;
                    Locale locale = _session.GetSessionDbLocaleIndex();
                    if (locale != Locale.enUS)
                    {
                        QuestTemplateLocale localeData = Global.ObjectMgr.GetQuestLocale(quest.Id);
                        if (localeData != null)
                        {
                            ObjectManager.GetLocaleString(localeData.LogTitle, locale, ref text.QuestTitle);
                        }
                    }

                    packet.GossipText.Add(text);
                }
            }

            _session.SendPacket(packet);
        }