Example #1
0
		public static void HandleGossipHello(IRealmClient client, RealmPacketIn packet)
		{
			var targetEntityId = packet.ReadEntityId();

			var chr = client.ActiveCharacter;
			var target = chr.Region.GetObject(targetEntityId) as Unit;

			if (target == null)
				return;

			if (chr.GossipConversation != null)
			{
				chr.GossipConversation = null;
			}

			var menu = target.GossipMenu;
			if (menu == null)
				return;

			if (target is NPC)
			{
				if (!((NPC)target).CanInteractWith(chr))
				{
					return;
				}
			}
			else if (!chr.Role.IsStaff)
			{
				return;
			}
			chr.OnInteract(target);
			var conversation = new GossipConversation(menu, chr, target, menu.KeepOpen);
			client.ActiveCharacter.GossipConversation = conversation;
			conversation.DisplayCurrentMenu();
		}
Example #2
0
		/// <summary>
		/// Generate the menu's text dynamically
		/// </summary>
		public override string GetText(GossipConversation convo)
		{
			var text = RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuText) + GossipTextHelper.Newline;

			if (!GOMgr.Loaded || !NPCMgr.Loaded)
			{
				if (!convo.Speaker.HasUpdateAction(action => action is PeriodicLoadMapTimer))
				{
					// already loading
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusNoData);
				}
				else
				{
					// not loading yet
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusDataLoading);
				}
			}
			else if (!Editor.Map.IsSpawned)
			{
				if (Editor.Map.IsSpawning)
				{
					// already spawning
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusSpawning);
				}
				else
				{
					// not spawning yet
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusNotSpawned);
				}
			}
			return text;
		}
 public override string GetConfirmText(GossipConversation convo)
 {
     if (this.ConfirmText != null)
     {
         return(this.ConfirmText.Translate(convo.User.Locale));
     }
     return("");
 }
Example #4
0
 public override string GetTextFemale(GossipConversation convo)
 {
     if (convo == null)
     {
         return("<invalid context>");
     }
     return(this.StringGetter(convo));
 }
Example #5
0
		public override string GetText(GossipConversation convo)
		{
			return Text.Translate(convo.User.Locale);
		}
Example #6
0
 public abstract string GetTextFemale(GossipConversation convo);
Example #7
0
		public virtual void OnSelect(GossipConversation convo)
        {
        }
Example #8
0
		public override string GetTextFemale(GossipConversation convo)
		{
			return TextFemale;
		}
Example #9
0
		/// <summary>
		/// Called before menu is sent to Character
		/// </summary>
		protected internal virtual void OnDisplay(GossipConversation convo)
		{
		}
 public override string GetText(GossipConversation convo)
 {
     return(this.Text.Translate(convo.User.Locale));
 }
Example #11
0
		/// <summary>
		/// Handle what happens when clicking on the Teleport option
		/// </summary>
		void HandleTeleport(GossipConversation convo)
		{
			convo.Character.TeleportTo(m_point);
		}
Example #12
0
 public abstract string GetConfirmText(GossipConversation convo);
Example #13
0
			/// <summary>
			/// Move the Waypoint over to the Character
			/// </summary>
			void HandleMoveOver(GossipConversation convo)
			{
				m_Point.MoveWP(m_wp, convo.Character.Position);
			}
Example #14
0
			/// <summary>
			/// Insert a new WP
			/// </summary>
			void HandleInsert(GossipConversation convo)
			{
				m_Point.InsertAfter(m_wp, convo.Character.Position, convo.Character.Orientation);
			}
Example #15
0
			/// <summary>
			/// Remove the WP
			/// </summary>
			void HandleRemove(GossipConversation convo)
			{
				m_Point.RemoveWP(m_wp);

				// the WP is now gone, so let's send the Menu again (without this Item in it)
				convo.Invalidate();
			}
Example #16
0
			/// <summary>
			/// Go to the WP
			/// </summary>
			void HandleGoto(GossipConversation convo)
			{
				convo.Character.TeleportTo(m_Point.Region, m_wp.Position);
			}
Example #17
0
		public void OnSelect(GossipConversation convo)
		{
			m_Handler(convo);
		}
Example #18
0
			public PeriodicLoadMapTimer(GossipConversation convo)
			{
				m_Convo = convo;
				Delay = 1000;
				Callback = OnTick;
			}
Example #19
0
		/// <summary>
		/// Handle what happens when clicking on the Remove option
		/// </summary>
		private void HandleRemove(GossipConversation convo)
		{
			m_point.RemoveSpawnLater();
		}
Example #20
0
		static void OnLoadClicked(GossipConversation convo)
		{
			GOMgr.LoadAllLater();
			NPCMgr.LoadAllLater();

			var chr = convo.Character;
			chr.SendSystemMessage(RealmLangKey.PleaseWait);

			convo.Character.AddUpdateAction(new PeriodicLoadMapTimer(convo));
		}
Example #21
0
		/// <summary>
		/// Handle what happens when clicking on the Add WP button
		/// </summary>
		private void HandleAddWP(GossipConversation convo)
		{
			var chr = convo.Character;
			m_point.InsertAfter(null, chr.Position, chr.Orientation);
		}
Example #22
0
		private static string OnTextQuery(GossipConversation convo)
		{
			return ((DynamicTextGossipMenu)convo.CurrentMenu).GetText(convo);
		}
Example #23
0
 /// <summary>
 /// Called before menu is sent to Character
 /// </summary>
 protected internal virtual void OnDisplay(GossipConversation convo)
 {
 }
Example #24
0
		internal void NotifyClose(GossipConversation convo)
		{
		}
Example #25
0
 public override string GetTextFemale(GossipConversation convo)
 {
     return(TextFemale);
 }
Example #26
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);
            }
        }
Example #27
0
		public override string GetConfirmText(GossipConversation convo)
		{
			if (ConfirmText != null)
				return ConfirmText.Translate(convo.User.Locale);
			return "";
		}
Example #28
0
 internal void NotifyClose(GossipConversation convo)
 {
 }
Example #29
0
 public override string GetTextMale(GossipConversation convo)
 {
     return(this.TextMale);
 }
Example #30
0
		public abstract string GetTextFemale(GossipConversation convo);
Example #31
0
		/// <summary>
		/// Lets the Character gossip with the given speaker
		/// </summary>
		public void StartGossip(GossipMenu menu, WorldObject speaker)
		{
			GossipConversation = new GossipConversation(menu, this, speaker, menu.KeepOpen);
			GossipConversation.DisplayCurrentMenu();
		}
Example #32
0
		public override string GetTextFemale(GossipConversation convo)
		{
			if (convo == null) return "<invalid context>";
			return StringGetter(convo);
		}
Example #33
0
 public override string GetConfirmText(GossipConversation convo)
 {
     return(ConfirmText);
 }
Example #34
0
		/// <summary>
		/// Lets the Character gossip with herself
		/// </summary>
		public void StartGossip(GossipMenu menu)
		{
			GossipConversation = new GossipConversation(menu, this, this, menu.KeepOpen);
			GossipConversation.DisplayCurrentMenu();
		}
Example #35
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, uint bodyTextID,
											   IList<GossipMenuItemBase> gossipItems,
											   IList<QuestMenuItem> questItems)
		{
			var owner = convo.Speaker;
			var chr = convo.Character;

			if (bodyTextID == 0)
			{
				// Client won't display the gossip if text id is 0
				bodyTextID = 1;
			}
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GOSSIP_MESSAGE))
			{
				packet.Write(owner.EntityId);
				packet.Write(0);				// new Flag field since 2.4.0 - menu id
				packet.Write(bodyTextID);

				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(chr))
						{
							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);
			}
		}
 private static string OnTextQuery(GossipConversation convo)
 {
     return(((DynamicTextGossipMenu)convo.CurrentMenu).GetText(convo));
 }
Example #37
0
		public override string GetConfirmText(GossipConversation convo)
		{
			return ConfirmTexts.Localize(convo.User.Locale);
		}
Example #38
0
 public override string GetText(GossipConversation convo)
 {
     return SpawnPoint.ToString();
 }
Example #39
0
		public override string GetConfirmText(GossipConversation convo)
		{
			return ConfirmText;
		}
Example #40
0
		public abstract string GetConfirmText(GossipConversation convo);
Example #41
0
		public override string GetText(GossipConversation convo)
		{
			return "";
		}
Example #42
0
 public override string GetConfirmText(GossipConversation convo)
 {
     return(ConfirmTexts.Localize(convo.User.Locale));
 }
Example #43
0
 public override string GetConfirmText(GossipConversation convo)
 {
     return(GetConfirmTextCallback(convo, (M)convo.CurrentMenu));
 }