Ejemplo n.º 1
0
        /// <title>Saga.ClearWaypoints</title>
        /// <code>
        /// Saga.ClearWaypoints(cid, QuestID, StepId, State);
        /// </code>
        /// <description>
        /// Removes all waypoints for a the specified quest.
        /// </description>
        /// <example>
        /// function QUEST_STEP_2(cid)
        ///	    -- Talk to mischa
        ///     local NPCIndex = 1000;
        ///     local ret = Saga.GetNPCIndex(cid);
        ///
        ///     Saga.AddWaypoint(cid, QuestID, NPCIndex, -12092, -6490, -8284, 1);
        ///     if ret == NPCIndex then
        ///         Saga.StepComplete(cid, QuestID, 102);
        ///     else
        ///         return  -1;
        ///     end
        ///
        ///     Saga.ClearWaypoints(cid, QuestID);
        ///     return 0;
        /// end
        /// </example>
        public static void ClearWayPoints(uint CID, uint QID)
        {
            QuestBase quest;
            Character value;
            if (LifeCycle.TryGetById(CID, out value))
            {
                quest = value.QuestObjectives[QID];
                Predicate<Saga.Quests.Objectives.ObjectiveList.Waypoint> FindGuidancePoints =
                    delegate(Saga.Quests.Objectives.ObjectiveList.Waypoint objective)
                    {
                        return objective.Quest == QID;
                    };

                if (quest != null) quest.IsWaypointsCleared = true;
                int count = value.QuestObjectives.GuidancePoints.RemoveAll(FindGuidancePoints);
                if (count > 0)
                {
                    SMSG_REMOVENAVIGATIONPOINT spkt = new SMSG_REMOVENAVIGATIONPOINT();
                    spkt.SessionId = value.id;
                    spkt.QuestID = QID;
                    value.client.Send((byte[])spkt);
                }
            }
        }
Ejemplo n.º 2
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;
            }
        }