예제 #1
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                from.SendGump(new FileSelectionGump(this, from));
            }

            if (!m_HandleDblClick || m_Dialog == null || !Active || m_Users.Contains(from) || !from.CheckAlive(false))
            {
                return;
            }

            DialogInit match = null;

            foreach (DialogInit init in m_Dialog.Init)
            {
                if (init.ReactToDoubleClick)
                {
                    match = init;
                    break;
                }
            }

            if (match != null && match.DoFunctionTrigger(this, from))
            {
                StartConversation(from, match);
            }
        }
예제 #2
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (m_Dialog == null)
            {
                return;
            }

            DialogInit match = null;

            foreach (DialogInit init in m_Dialog.Init)
            {
                if (init.ReactToKeywords)
                {
                    foreach (string key in init.Keywords)
                    {
                        if (e.Speech.IndexOf(key) > -1)
                        {
                            match = init;
                            break;
                        }
                    }

                    if (match != null)
                    {
                        break;
                    }
                }
            }

            if (match != null && match.DoFunctionTrigger(this, e.Mobile))
            {
                e.Handled = true;
                StartConversation(e.Mobile, match);
            }
        }
예제 #3
0
        /// <summary>
        /// Begins a conversation with a player by sending them the first gump
        /// </summary>
        /// <param name="m">The mobile beginning the conversation</param>
        /// <param name="init">The DialogInit object specifying the starting condition</param>
        private void StartConversation(Mobile m, DialogInit init)
        {
            if (!Verify(m))
            {
                return;
            }

            DialogSpeech speech = m_Dialog.GetSpeech(init.Speech);

            if (!VerifySpeech(m, speech))
            {
                return;
            }

            m_Users.Add(m);

            SendSpeechGump(speech, m);
        }
예제 #4
0
        public override void OnMovement(Mobile m, Point3D oldLocation)
        {
            if (!m.Player || m_Dialog == null || !m_HandleItem || !Active || m_Users.Contains(m) || !m.CheckAlive(false))
            {
                base.OnMovement(m, oldLocation);
                return;
            }

            // Trigger only when entering the range region: oldLocation not in range and new location in range

            if (!(this.InRange(m.Location, m_Dialog.Range) && !this.InRange(oldLocation, m_Dialog.Range)))
            {
                base.OnMovement(m, oldLocation);
                return;
            }

            DialogInit match = null;

            foreach (DialogInit init in m_Dialog.Init)
            {
                if (init.ReactToItemInBackpack && init.ItemType != null && m.Backpack != null)
                {
                    Item target = m.Backpack.FindItemByType(init.ItemType, true);

                    if (target != null)
                    {
                        if (target.Amount >= init.AmountBackpack)
                        {
                            match = init;
                            break;
                        }
                    }
                }
            }

            if (match != null && match.DoFunctionTrigger(this, m))
            {
                StartConversation(m, match);
            }
            else
            {
                base.OnMovement(m, oldLocation);
            }
        }
예제 #5
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (m_Dialog == null || !m_HandleItemGiven || !Active || m_Users.Contains(from))
            {
                this.SayTo(from, "*shakes head*");
                return(false);
            }

            DialogInit match = null;

            foreach (DialogInit init in m_Dialog.Init)
            {
                if (init.ReactToItemGiven && init.ItemGivenType != null)
                {
                    if (dropped.GetType() == init.ItemGivenType && dropped.Amount >= init.AmountGiven)
                    {
                        match = init;
                        break;
                    }
                }
            }

            if (match != null && match.DoFunctionTrigger(this, from))
            {
                StartConversation(from, match);

                // If dropped more than needed, just take what's required
                if (dropped.Amount > match.AmountGiven)
                {
                    dropped.Amount -= match.AmountGiven;
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                this.SayTo(from, "*shakes head*");
                return(false);
            }
        }
예제 #6
0
		/// <summary>
		/// Begins a conversation with a player by sending them the first gump
		/// </summary>
		/// <param name="m">The mobile beginning the conversation</param>
		/// <param name="init">The DialogInit object specifying the starting condition</param>
		private void StartConversation( Mobile m, DialogInit init )
		{
			if ( ! Verify( m ) )
				return;

			DialogSpeech speech = m_Dialog.GetSpeech( init.Speech );

			if ( ! VerifySpeech( m, speech ) )
				return;

			m_Users.Add( m );

			SendSpeechGump( speech, m );
		}