Exemple #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                m_Quest.OnAccept();
            }
            else if (info.ButtonID == 2)
            {
                m_Quest.OnRefuse();

                sender.Mobile.CloseGump <BaseQuestGump>();
                sender.Mobile.SendGump(new MLQuestConversationGump(m_Quest, MLQuestConverType.Refuse));
            }
        }
        public override void OnResponse(Server.Network.NetState state, RelayInfo info)
        {
            if (m_From != null)
            {
                m_From.CloseGump(typeof(MondainQuestGump));
            }

            switch (info.ButtonID)
            {
            // close quest list
            case (int)Buttons.Close:
                break;

            // close quest
            case (int)Buttons.CloseQuest:
                m_From.SendGump(new MondainQuestGump(m_From));
                break;

            // accept quest
            case (int)Buttons.AcceptQuest:
                if (m_Offer)
                {
                    m_Quest.OnAccept();
                }
                break;

            // refuse quest
            case (int)Buttons.RefuseQuest:
                if (m_Offer)
                {
                    m_Quest.OnRefuse();
                    m_From.SendGump(new MondainQuestGump(m_Quest, Section.Refuse, true));
                }
                break;

            // resign quest
            case (int)Buttons.ResignQuest:
                if (!m_Offer)
                {
                    m_From.SendGump(new MondainResignGump(m_Quest));
                }
                break;

            // accept reward
            case (int)Buttons.AcceptReward:
                if (!m_Offer && m_Section == Section.Rewards && m_Completed)
                {
                    m_Quest.GiveRewards();
                }
                break;

            // refuse reward
            case (int)Buttons.RefuseReward:
                if (!m_Offer && m_Section == Section.Rewards && m_Completed)
                {
                    m_Quest.RefuseRewards();
                }
                break;

            // previous page
            case (int)Buttons.PreviousPage:
                if (m_Section == Section.Objectives || (m_Section == Section.Rewards && !m_Completed))
                {
                    m_Section = (Section)((int)m_Section - 1);
                    m_From.SendGump(new MondainQuestGump(m_Quest, m_Section, m_Offer));
                }
                break;

            // next page
            case (int)Buttons.NextPage:
                if (m_Section == Section.Description || m_Section == Section.Objectives)
                {
                    m_Section = (Section)((int)m_Section + 1);
                    m_From.SendGump(new MondainQuestGump(m_Quest, m_Section, m_Offer));
                }
                break;

            // player complete quest
            case (int)Buttons.Complete:
                if (!m_Offer && m_Section == Section.Complete)
                {
                    if (!m_Quest.Completed)
                    {
                        m_From.SendLocalizedMessage(1074861);     // You do not have everything you need!
                    }
                    else
                    {
                        if (QuestHelper.TryDeleteItems(m_Quest))
                        {
                            if (m_Quester != null)
                            {
                                m_Quest.Quester = m_Quester;
                            }

                            if (!QuestHelper.AnyRewards(m_Quest))
                            {
                                m_Quest.GiveRewards();
                            }
                            else
                            {
                                m_From.SendGump(new MondainQuestGump(m_Quest, Section.Rewards, false, true));
                            }
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(1074861);     // You do not have everything you need!
                        }
                    }
                }
                break;

            // admin complete quest
            case (int)Buttons.CompleteQuest:
                if ((int)m_From.AccessLevel > (int)AccessLevel.Counselor && m_Quest != null)
                {
                    QuestHelper.CompleteQuest(m_From, m_Quest);
                }
                break;

            // show quest
            default:
                if (m_Section != Section.Main || info.ButtonID >= m_From.Quests.Count + ButtonOffset || info.ButtonID < ButtonOffset)
                {
                    break;
                }

                m_From.SendGump(new MondainQuestGump(m_From.Quests[(int)info.ButtonID - ButtonOffset], Section.Description, false));
                break;
            }
        }