Esempio n. 1
0
        /// <remarks>
        /// Cancels only the QuestBase of it can be canceled.
        /// This is not yet implamented in any QuestBase of kro2, but most likely
        /// in the future there are going to be certain QuestBases that supports that.
        ///
        /// For example a chain of QuestBase events.
        /// </remarks>
        /// <param name="cpkt"></param>
        private void CM_QUESTCONFIRMCANCEL(CMSG_QUESTCONFIRMCANCEL cpkt)
        {
            if (QuestBaseID > 0)
            {
                try
                {
                    QuestBase myQuestBase = this.character.QuestObjectives[QuestBaseID];
                    if (myQuestBase != null)
                    {
                        //Removes the quest
                        this.character.QuestObjectives[QuestBaseID] = null;

                        //Invalidates all stepinfo
                        QuestBase.InvalidateQuest(myQuestBase, this.character);

                        //Send over new quest list
                        SMSG_QUESTINFO spkt3 = new SMSG_QUESTINFO();
                        spkt3.SessionId = this.character.id;
                        foreach (QuestBase Quest in this.character.QuestObjectives)
                        {
                            List <Saga.Quests.Objectives.ObjectiveList.StepInfo> Steps =
                                QuestBase.GetSteps(this.character, Quest.QuestId);

                            spkt3.AddQuest(Quest.QuestId, (byte)Steps.Count);
                            for (int i = 0; i < Steps.Count; i++)
                            {
                                Saga.Quests.Objectives.ObjectiveList.StepInfo currentStep =
                                    Steps[i];

                                uint nextstep = (i + 1 < Steps.Count) ? Steps[i + 1].StepId : 0;
                                spkt3.AddQuestStep(currentStep.StepId, currentStep.State, nextstep, Quest.isnew);
                            }
                        }
                        this.Send((byte[])spkt3);

                        //Remove all waypoints
                        SMSG_REMOVENAVIGATIONPOINT spkt = new SMSG_REMOVENAVIGATIONPOINT();
                        spkt.QuestID   = QuestBaseID;
                        spkt.SessionId = this.character.id;
                        this.Send((byte[])spkt);

                        //Updates all new icons
                        CommonFunctions.RefreshPersonalRequests(this.character);
                        CommonFunctions.UpdateNpcIcons(this.character);
                    }
                }
                finally
                {
                    //Reset our Quest Base Id
                    QuestBaseID = 0;
                }
            }
            else
            {
                QuestBaseID = cpkt.QuestID;
            }
        }