Пример #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;
            }
        }
Пример #2
0
        /// <summary>
        /// Inserts a new quests into the questlist.
        /// </summary>
        public static void InsertQuest(uint cid, uint QID, byte slot)
        {
            QuestBase oldQuest;
            QuestBase newQuest;
            Character Character;


            if (LifeCycle.TryGetById(cid, out Character))
            {
                newQuest = Character.QuestObjectives[QID];
                if (newQuest == null)
                {
                    if (Singleton.Quests.TryFindQuests(QID, out newQuest))
                    {
                        if (slot == 1)
                        {
                            oldQuest = Character.QuestObjectives.OfficialQuest;
                            Character.QuestObjectives.OfficialQuest = newQuest;
                            newQuest.questtype = slot;
                        }
                        else if (slot == 2)
                        {
                            oldQuest = Character.QuestObjectives.PersonalQuest;
                            Character.QuestObjectives.PersonalQuest = newQuest;
                            newQuest.questtype = slot;
                        }


                        List <Saga.Quests.Objectives.ObjectiveList.StepInfo> Steps2 =
                            QuestBase.GetSteps(Character, QID);

                        if (Steps2.Count == 0)
                        {
                            newQuest.OnStart(Character.id);
                        }
                        if (Steps2.Count > 0)
                        {
                            newQuest.isnew  = true;
                            Steps2[0].State = 1;
                        }

                        SMSG_QUESTREMOVE spkt4 = Character.Tag as SMSG_QUESTREMOVE;
                        if (spkt4 != null)
                        {
                            Character.client.Send((byte[])spkt4);
                            Character.Tag = null;
                        }

                        // Send new Quest list
                        SMSG_QUESTINFO spkt3 = new SMSG_QUESTINFO();
                        spkt3.SessionId = Character.id;
                        foreach (QuestBase Quest in Character.QuestObjectives)
                        {
                            List <Saga.Quests.Objectives.ObjectiveList.StepInfo> Steps =
                                QuestBase.GetSteps(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);
                                if (Quest.isnew == true)
                                {
                                    Quest.isnew = false;
                                }
                            }
                        }
                        Character.client.Send((byte[])spkt3);

                        newQuest.CheckQuest(Character);

                        /*
                         * // Send waypoint contruction
                         * SMSG_SENDNAVIGATIONPOINT spkt2 = new SMSG_SENDNAVIGATIONPOINT();
                         * spkt2.SessionId = Character.id;
                         * spkt2.QuestID = QID;
                         * foreach (Saga.Quests.Objectives.ObjectiveList.Waypoint waypoint in QuestBase.UserGetWaypoints(Character, QID))
                         * {
                         *
                         *  //Predicate to search the npc
                         *  Predicate<MapObject> IsNpc = delegate(MapObject match)
                         *  {
                         *      return match.ModelId == waypoint.NpcId;
                         *  };
                         *
                         *  MapObject myObject = Character.currentzone.Regiontree.SearchActor(IsNpc, SearchFlags.Npcs);
                         *  if ( myObject != null )
                         *  {
                         *      spkt2.AddPosition(waypoint.NpcId, myObject.Position.x, myObject.Position.y, myObject.Position.z);
                         *      if ( Point.IsInSightRangeByRadius(Character.Position, myObject.Position))
                         *      {
                         *          BaseMob temp = (BaseMob)myObject;
                         *          Common.Actions.UpdateIcon(Character, temp);
                         *      }
                         *  }
                         * }
                         * Character.client.Send((byte[])spkt2);*/
                    }
                    else
                    {
                        Console.WriteLine("Quest not found");
                    }
                }
            }
            else
            {
                Trace.TraceError("Character not found");
            }
        }