Example #1
0
        /// <summary>Sends a npc text update to the character</summary>
        /// <param name="character">recieving character</param>
        /// <param name="text">class holding all info about text</param>
        public static void SendNPCTextUpdate(Character character, IGossipEntry text)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE))
            {
                packet.Write(text.GossipId);
                int index1;
                for (index1 = 0; index1 < text.GossipTexts.Length; ++index1)
                {
                    GossipTextBase gossipText = text.GossipTexts[index1];
                    packet.WriteFloat(gossipText.Probability);
                    string textMale = gossipText.GetTextMale(character.GossipConversation);
                    string str      = !text.IsDynamic ? gossipText.GetTextFemale(character.GossipConversation) : textMale;
                    packet.WriteCString(textMale);
                    packet.WriteCString(str);
                    packet.Write((uint)gossipText.Language);
                    for (int index2 = 0; index2 < 3; ++index2)
                    {
                        packet.Write(0L);
                    }
                }

                for (; index1 < 8; ++index1)
                {
                    packet.WriteFloat(0);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.Fill((byte)0, 28);
                }

                character.Client.Send(packet, false);
            }
        }
Example #2
0
        public void FinalizeDataHolder()
        {
            NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(NPCSpawnId);
            IGossipEntry  entry1     = GossipMgr.GetEntry(GossipId);

            if (spawnEntry == null)
            {
                ContentMgr.OnInvalidDBData("{0} refers to invalid spawn id: {1}", (object)GetType(),
                                           (object)this);
            }
            else if (entry1 == null)
            {
                ContentMgr.OnInvalidDBData("{0} has invalid GossipId: {1}", (object)GetType(), (object)this);
            }
            else
            {
                NPCEntry entry2 = spawnEntry.Entry;
                if (spawnEntry.DefaultGossip == null)
                {
                    spawnEntry.DefaultGossip = new GossipMenu(entry1);
                }
                else
                {
                    spawnEntry.DefaultGossip.GossipEntry = entry1;
                }
            }
        }
Example #3
0
 public GossipMenu(IGossipEntry textEntry)
 {
     this.m_textEntry = textEntry;
     if (this.m_textEntry == null)
     {
         throw new ArgumentNullException(nameof(textEntry));
     }
 }
Example #4
0
 public GossipMenu(IGossipEntry textEntry)
 {
     m_textEntry = textEntry;
     if (m_textEntry == null)
     {
         throw new ArgumentNullException("textEntry");
     }
 }
Example #5
0
		public GossipMenu(IGossipEntry textEntry)
		{
			m_textEntry = textEntry;
			if (m_textEntry == null)
			{
				throw new ArgumentNullException("textEntry");
			}
		}
Example #6
0
 /// <summary>
 /// Constructor initializing menu with body text ID
 /// </summary>
 /// <param name="bodyTextID">GossipEntry Id</param>
 public GossipMenu(uint bodyTextID)
 {
     m_textEntry = GossipMgr.GetEntry(bodyTextID);
     if (m_textEntry == null)
     {
         m_textEntry = GossipMgr.DefaultGossipEntry;
         LogManager.GetCurrentClassLogger().Warn("Tried to create GossipMenu with invalid GossipEntry id: " + bodyTextID);
     }
 }
Example #7
0
		/// <summary>
		/// Constructor initializing menu with body text ID
		/// </summary>
		/// <param name="bodyTextID">GossipEntry Id</param>
		public GossipMenu(uint bodyTextID)
		{
			m_textEntry = GossipMgr.GetEntry(bodyTextID);
			if (m_textEntry == null)
			{
				m_textEntry = GossipMgr.DefaultGossipEntry;
				LogManager.GetCurrentClassLogger().Warn("Tried to create GossipMenu with invalid GossipEntry id: " + bodyTextID);
			}
		}
Example #8
0
 public GossipMenu(IGossipEntry text, params GossipMenuItemBase[] items)
     : this(text)
 {
     m_gossipItems = new List <GossipMenuItemBase>(items.Length);
     foreach (var item in items)
     {
         CheckItem(item);
         m_gossipItems.Add(item);
     }
 }
Example #9
0
 public GossipMenu(IGossipEntry text, params GossipMenuItemBase[] items)
     : this(text)
 {
     this.m_gossipItems = new List <GossipMenuItemBase>(items.Length);
     foreach (GossipMenuItemBase gossipMenuItemBase in items)
     {
         this.CheckItem(gossipMenuItemBase);
         this.m_gossipItems.Add(gossipMenuItemBase);
     }
 }
Example #10
0
 /// <summary>Constructor initializing menu with body text ID</summary>
 /// <param name="bodyTextID">GossipEntry Id</param>
 public GossipMenu(uint bodyTextID)
 {
     this.m_textEntry = GossipMgr.GetEntry(bodyTextID);
     if (this.m_textEntry != null)
     {
         return;
     }
     this.m_textEntry = (IGossipEntry)GossipMgr.DefaultGossipEntry;
     LogManager.GetCurrentClassLogger()
     .Warn("Tried to create GossipMenu with invalid GossipEntry id: " + (object)bodyTextID);
 }
Example #11
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);
        }
Example #12
0
        /// <summary>
        /// Sends a npc text update to the character
        /// </summary>
        /// <param name="character">recieving character</param>
        /// <param name="text">class holding all info about text</param>
        public static void SendNPCTextUpdate(Character character, IGossipEntry text)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE))
            {
                packet.Write(text.GossipId);

                var i = 0;
                for (; i < text.GossipTexts.Length; i++)
                {
                    var entry = text.GossipTexts[i];
                    packet.WriteFloat(entry.Probability);

                    var    maleText = entry.GetTextMale(character.GossipConversation);
                    string femaleText;
                    if (text.IsDynamic)
                    {
                        // generated dynamically anyway
                        femaleText = maleText;
                    }
                    else
                    {
                        femaleText = entry.GetTextFemale(character.GossipConversation);
                    }
                    packet.WriteCString(maleText);
                    packet.WriteCString(femaleText);


                    packet.Write((uint)entry.Language);

                    for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++)
                    {
                        // TODO: Emotes
                        //packet.Write((uint)entry.Emotes[emoteIndex]);
                        //packet.Write(entry.EmoteDelays[emoteIndex]);
                        packet.Write(0L);
                    }
                }

                for (; i < 8; i++)
                {
                    packet.WriteFloat(0);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.Fill(0, 4 * 7);
                }

                character.Client.Send(packet, addEnd: false);
            }
        }
Example #13
0
		public GossipMenu(IGossipEntry text, List<GossipMenuItemBase> items)
			: this(text)
		{
			m_gossipItems = items;
		}
Example #14
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public GossipMenu()
 {
     m_textEntry = GossipMgr.DefaultGossipEntry;
 }
Example #15
0
 public GossipMenu(IGossipEntry text, List <GossipMenuItemBase> items)
     : this(text)
 {
     m_gossipItems = items;
 }
Example #16
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public GossipMenu()
		{
			m_textEntry = GossipMgr.DefaultGossipEntry;
		}
Example #17
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);
            }
        }
Example #18
0
		/// <summary>
		/// Sends a npc text update to the character
		/// </summary>
		/// <param name="character">recieving character</param>
		/// <param name="text">class holding all info about text</param>
		public static void SendNPCTextUpdate(Character character, IGossipEntry text)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE))
			{
				packet.Write(text.GossipId);

				var i = 0;
				for (; i < text.GossipTexts.Length; i++)
				{
					var entry = text.GossipTexts[i];
					packet.WriteFloat(entry.Probability);

					var maleText = entry.GetTextMale(character.GossipConversation);
					string femaleText;
					if (text.IsDynamic)
					{
						// generated dynamically anyway
						femaleText = maleText;
					}
					else
					{
						femaleText = entry.GetTextFemale(character.GossipConversation);
					}
					packet.WriteCString(maleText);
					packet.WriteCString(femaleText);


					packet.Write((uint)entry.Language);

					for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++)
					{
						// TODO: Emotes
						//packet.Write((uint)entry.Emotes[emoteIndex]);
						//packet.Write(entry.EmoteDelays[emoteIndex]);
						packet.Write(0L);
					}
				}

				for (; i < 8; i++)
				{
					packet.WriteFloat(0);
					packet.WriteByte(0);
					packet.WriteByte(0);
					packet.Fill(0, 4 * 7);
				}

				character.Client.Send(packet);
			}
		}
Example #19
0
		/// <summary>
		/// Sends a npc text update to the character
		/// </summary>
		/// <param name="character">recieving character</param>
		/// <param name="text">class holding all info about text</param>
		public static void SendNPCTextUpdate(Character character, IGossipEntry text)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE))
			{
				packet.Write(text.GossipId);

				var i = 0;
				for (; i < text.GossipEntries.Length; i++)
				{
					var entry = text.GossipEntries[i];
					packet.WriteFloat(entry.Probability);

					var isMaleTextEmpty = string.IsNullOrEmpty(entry.TextMale);
					var isFemaleTextEmpty = string.IsNullOrEmpty(entry.TextFemale);

					if (isMaleTextEmpty && isFemaleTextEmpty)
					{
						packet.WriteCString(" ");
						packet.WriteCString(" ");
					}
					else if (isMaleTextEmpty)
					{
						packet.WriteCString(entry.TextFemale);
						packet.WriteCString(entry.TextFemale);
					}
					else if (isFemaleTextEmpty)
					{
						packet.WriteCString(entry.TextMale);
						packet.WriteCString(entry.TextMale);
					}
					else
					{
						packet.WriteCString(entry.TextMale);
						packet.WriteCString(entry.TextFemale);
					}

					packet.Write((uint)entry.Language);

					for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++)
					{
						// TODO: Emotes
						//packet.Write((uint)entry.Emotes[emoteIndex]);
						//packet.Write(entry.EmoteDelays[emoteIndex]);
						packet.Write(0L);
					}
				}

				for (; i < 8; i++)
				{
					packet.WriteFloat(0);
					packet.WriteByte(0);
					packet.WriteByte(0);
					packet.Fill(0, 4 * 7);
				}

				character.Client.Send(packet);
			}
		}
Example #20
0
		public GossipMenu(IGossipEntry text, params GossipMenuItemBase[] items)
			: this(text)
		{
			m_gossipItems = new List<GossipMenuItemBase>(items.Length);
			foreach (var item in items)
			{
				CheckItem(item);
				m_gossipItems.Add(item);
			}
		}
Example #21
0
 /// <summary>Default constructor</summary>
 public GossipMenu()
 {
     this.m_textEntry = (IGossipEntry)GossipMgr.DefaultGossipEntry;
 }