public void SendQuestGiverQuestListMessage(WorldObject questgiver) { ObjectGuid guid = questgiver.GetGUID(); Locale localeConstant = _session.GetSessionDbLocaleIndex(); QuestGiverQuestListMessage questList = new(); 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(); text.QuestID = questID; text.ContentTuningID = quest.ContentTuningId; text.QuestType = questMenuItem.QuestIcon; text.QuestFlags = (uint)quest.Flags; text.QuestFlagsEx = (uint)quest.FlagsEx; text.Repeatable = quest.IsAutoComplete() && quest.IsRepeatable() && !quest.IsDailyOrWeekly() && !quest.IsMonthly(); 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); }
public void SendGossipMenu(uint titleTextId, ObjectGuid objectGUID) { _interactionData.Reset(); _interactionData.SourceGuid = objectGUID; GossipMessagePkt packet = new(); packet.GossipGUID = objectGUID; packet.GossipID = (int)_gossipMenu.GetMenuId(); packet.TextID = (int)titleTextId; foreach (var pair in _gossipMenu.GetMenuItems()) { ClientGossipOptions opt = new(); 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(); text.QuestID = questID; text.ContentTuningID = quest.ContentTuningId; text.QuestType = item.QuestIcon; text.QuestFlags = (uint)quest.Flags; text.QuestFlagsEx = (uint)quest.FlagsEx; text.Repeatable = quest.IsAutoComplete() && quest.IsRepeatable() && !quest.IsDailyOrWeekly() && !quest.IsMonthly(); 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); }
public bool SearchAndSelectQuest(QuestArc target) { for (int i = 0; i < categories.Length; i++) { QuestMenuItem item = categories[i].SearchItem(target, true); //method will open category if found if (item != null) { ViewQuest(item.targetQuest); EventSystem.current.SetSelectedGameObject(item.itemButton.gameObject); return(true); } } return(false); }
/// <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); } }
public void UpdateCategory() { float containerHeight = originalHeight; float itemHeight = itemPrefab.GetComponent <QuestMenuItem>().rect.rect.height; float currentY = (containerHeight + verticalOffset) * -1; //if player completed a quest and it should no longer be here, remove it for (int i = itemList.Count - 1; i >= 0; i--) { QuestMenuItem item = itemList[i]; if ((!displayCompleted && item.targetQuest.rewarded) || (!displayActive && !item.targetQuest.rewarded)) { itemList.Remove(item); item.gameObject.SetActive(false); } } if (questsToDisplay.quests == null) { return; } //check if quest to add is already here and if not, add it for (int i = 0; i < questsToDisplay.quests.Count; i++) { if ((displayActive && !questsToDisplay.quests[i].rewarded) || (displayCompleted && questsToDisplay.quests[i].rewarded)) { bool found = false; for (int y = 0; y < itemList.Count; y++) { if (itemList[y].targetQuest == questsToDisplay.quests[i]) { found = true; } } if (!found) { Debug.Log("Created Quest Menu Item"); QuestMenuItem item = pooler.SpawnTargetObject(itemPrefab, 10, transform).GetComponent <QuestMenuItem>(); item.rect.anchoredPosition = new Vector2(horizontalOffset, currentY); itemList.Add(item); item.SetupItem(questsToDisplay.quests[i], questMenu); item.gameObject.SetActive(false); } } } //update positions for active quests that always appear before completed ones if (displayActive) { for (int i = itemList.Count - 1; i >= 0; i--) { if (!itemList[i].targetQuest.rewarded) { itemList[i].gameObject.SetActive(true); itemList[i].rect.anchoredPosition = new Vector2(horizontalOffset, currentY); currentY -= itemHeight + verticalOffset; } } } //update pos for completed if (displayCompleted) { for (int i = itemList.Count - 1; i >= 0; i--) { if (itemList[i].targetQuest.rewarded) { itemList[i].gameObject.SetActive(true); itemList[i].rect.anchoredPosition = new Vector2(horizontalOffset, currentY); currentY -= itemHeight + verticalOffset; } } } if (open) { Open(true, false); } }