コード例 #1
0
 public CQuest()
 {
     this.QuestID          = new int();
     this.Version          = new int();
     this.QuestInformation = new CQuestInformation();
     this.Precondition     = new CQuestPrecondition();
     this.QuestRules       = new CQuestRules();
     this.Reward           = new CQuestReward();
     this.QuestPenalty     = new CQuestPenalty();
     this.Additional       = new CQuestAdditional();
     this.Target           = new CQuestTarget();
 }
コード例 #2
0
 public CQuest(int questID, int Version, CQuestInformation questInformation, CQuestPrecondition precondition, CQuestRules questRules, CQuestReward reward, CQuestAdditional additional, CQuestTarget target, CQuestPenalty penalty)
 {
     this.QuestID          = questID;
     this.Version          = Version;
     this.QuestInformation = questInformation;
     this.Precondition     = precondition;
     this.QuestRules       = questRules;
     this.Reward           = reward;
     this.Additional       = additional;
     this.Target           = target;
     this.QuestPenalty     = penalty;
 }
コード例 #3
0
        //public string Trigger;

        public object Clone()
        {
            CQuestInformation copy = new CQuestInformation();

            copy.Title       = (string)this.Title.Clone();
            copy.Description = (string)this.Description.Clone();
            //copy.TypeOfHolder = (string)this.TypeOfHolder.Clone();
            //copy.NameOfHolder = (string)this.NameOfHolder.Clone();
            copy.onWin    = (string)this.onWin.Clone();
            copy.onFailed = (string)this.onFailed.Clone();
            //copy.Trigger = (string)this.Trigger.Clone();
            foreach (KeyValuePair <int, QuestItemInfo> item in this.Items)
            {
                copy.Items.Add(item.Key, (QuestItemInfo)item.Value.Clone());
            }
            return(copy);
        }
コード例 #4
0
        //! Парсит файл квестов и заносит результат в target
        void parseQuestsFile(string sPath, NPCQuestDict variable_target)
        {
            if (!File.Exists(sPath))
            {
                return;
            }
            doc = XDocument.Load(sPath);

            foreach (XElement item in doc.Root.Elements())
            {
                int QuestID = int.Parse(item.Element("QuestID").Value);
                int Version = new int();
                Version = int.Parse(item.Element("Version").Value);

                CQuestInformation  information  = new CQuestInformation();
                CQuestTarget       target       = new CQuestTarget();
                CQuestPrecondition precondition = new CQuestPrecondition();
                CQuestRules        questRules   = new CQuestRules();
                CQuestReward       reward       = new CQuestReward();
                CQuestAdditional   additional   = new CQuestAdditional();
                CQuestPenalty      penalty      = new CQuestPenalty();

                information.Description = common.decode(item.Element("QuestInformation").Element("Description").Value.Trim());
                information.Title       = common.decode(item.Element("QuestInformation").Element("Title").Value.Trim());
                information.onWin       = item.Element("QuestInformation").Element("onWin").Value.Trim();
                information.onFailed    = item.Element("QuestInformation").Element("onFailed").Value.Trim();

                additional.Holder = item.Element("Additional").Element("Holder").Value.Trim();

                foreach (XElement qitem in item.Element("QuestInformation").Element("Items").Elements())
                {
                    string title       = qitem.Element("title").Value;
                    string description = common.decode(qitem.Element("description").Value);
                    int    itemID      = int.Parse(qitem.Element("itemID").Value);
                    string activation  = qitem.Element("activation").Value;
                    information.Items.Add(itemID, new QuestItemInfo(title, description, activation));
                }

                target.QuestType = int.Parse(item.Element("Target").Element("QuestType").Value);
                if (!item.Element("Target").Element("ObjectType").Value.Equals(""))
                {
                    target.ObjectType = int.Parse(item.Element("Target").Element("ObjectType").Value);
                }
                if (!item.Element("Target").Element("NumOfObjects").Value.Equals(""))
                {
                    target.NumOfObjects = int.Parse(item.Element("Target").Element("NumOfObjects").Value);
                }
                if (!item.Element("Target").Element("ObjectAttr").Value.Equals(""))
                {
                    int Target_ObjectAttr = int.Parse(item.Element("Target").Element("ObjectAttr").Value);
                    if (Target_ObjectAttr < 0)
                    {
                        Target_ObjectAttr = 0;
                    }
                    target.ObjectAttr = Target_ObjectAttr;
                }

                foreach (string at in item.Element("Target").Element("AObjectAttrs").Value.ToString().Split(','))
                {
                    if (!at.Equals(""))
                    {
                        target.AObjectAttrs.Add(int.Parse(at));
                    }
                }

                if (!item.Element("Target").Element("onFin").Value.Equals(""))
                {
                    target.onFin = int.Parse(item.Element("Target").Element("onFin").Value);
                }
                else
                {
                    target.onFin = 1;
                }

                if (!item.Element("Target").Element("AreaName").Value.Equals(""))
                {
                    target.AreaName = item.Element("Target").Element("AreaName").Value;
                }

                if (!item.Element("Target").Element("ObjectName").Value.Equals(""))
                {
                    target.ObjectName = item.Element("Target").Element("ObjectName").Value;
                }

                if (!item.Element("Target").Element("IsGroup").Value.Equals(""))
                {
                    target.IsGroup = int.Parse(item.Element("Target").Element("IsGroup").Value);
                }
                else
                {
                    target.IsGroup = 0;
                }

                if (!item.Element("Target").Element("IsClan").Value.Equals(""))
                {
                    target.IsClan = false;
                }
                else if (!item.Element("Target").Element("IsClan").Value.Equals("0"))
                {
                    target.IsClan = false;
                }
                else if (!item.Element("Target").Element("IsClan").Value.Equals("1"))
                {
                    target.IsClan = true;
                }
                else
                {
                    target.IsClan = false;
                }

                if (!item.Element("Target").Element("Time").Value.Equals(""))
                {
                    float Time = float.Parse(item.Element("Target").Element("Time").Value);
                    target.Time = Time;
                }
                else
                {
                    target.Time = 0.0f;
                }

                if (!item.Element("Precondition").Element("Repeat").Value.Equals(""))
                {
                    precondition.Repeat = int.Parse(item.Element("Precondition").Element("Repeat").Value);
                }

                if (!item.Element("Precondition").Element("TakenPeriod").Value.Equals(""))
                {
                    precondition.TakenPeriod = double.Parse(item.Element("Precondition").Element("TakenPeriod").Value);
                }

                if (!item.Element("QuestRules").Element("NumOfItems").Value.Equals(""))
                {
                    foreach (string itemNum in item.Element("QuestRules").Element("NumOfItems").Value.Split(','))
                    {
                        questRules.NumOfItems.Add(int.Parse(itemNum));
                    }
                }
                if (!item.Element("QuestRules").Element("TypeOfItems").Value.Equals(""))
                {
                    foreach (string itemType in item.Element("QuestRules").Element("TypeOfItems").Value.Split(','))
                    {
                        questRules.TypeOfItems.Add(int.Parse(itemType));
                    }
                }

                questRules.TeleportTo = item.Element("QuestRules").Element("TeleportTo").Value.ToString();
                if (!item.Element("QuestRules").Element("MaxGroup").Value.Equals(""))
                {
                    questRules.MaxGroup = int.Parse(item.Element("QuestRules").Element("MaxGroup").Value);
                }
                if (!item.Element("QuestRules").Element("MinGroup").Value.Equals(""))
                {
                    questRules.MinGroup = int.Parse(item.Element("QuestRules").Element("MinGroup").Value);
                }

                if (!item.Element("QuestRules").Element("MaxMember").Value.Equals(""))
                {
                    questRules.MaxMember = int.Parse(item.Element("QuestRules").Element("MaxMember").Value);
                }
                if (!item.Element("QuestRules").Element("MinMember").Value.Equals(""))
                {
                    questRules.MinMember = int.Parse(item.Element("QuestRules").Element("MinMember").Value);
                }

                if (!item.Element("QuestRules").Element("AttrOfItems").Value.Equals(""))
                {
                    foreach (string itemType in item.Element("QuestRules").Element("AttrOfItems").Value.Split(','))
                    {
                        questRules.AttrOfItems.Add(int.Parse(itemType));
                    }
                }
                if (!item.Element("QuestRules").Element("Scenarios").Value.Equals(""))
                {
                    foreach (string itemType in item.Element("QuestRules").Element("Scenarios").Value.Split(','))
                    {
                        questRules.Scenarios.Add(int.Parse(itemType));
                    }
                }
                reward.TeleportTo = item.Element("Reward").Element("TeleportTo").Value.ToString();

                string text_rew_exp = item.Element("Reward").Element("Expirience").Value;

                /*
                 * reward.Expirience = 0;
                 * if (!text_rew_exp.Equals(""))
                 * {
                 *  if (text_rew_exp.Contains(','))
                 *  {
                 *      //After change from three skills role play
                 *      foreach (string element_rew_exp in text_rew_exp.Split(','))
                 *          reward.Expirience += int.Parse(element_rew_exp);
                 *  }
                 *  else
                 *      reward.Expirience = int.Parse(text_rew_exp);
                 * }
                 */

                if (!item.Element("Reward").Element("Expirience").Value.Equals(""))
                {
                    foreach (string itemNum in item.Element("Reward").Element("Expirience").Value.Split(','))
                    {
                        reward.Expirience.Add(int.Parse(itemNum));
                    }
                }

                if (!item.Element("Reward").Element("NumOfItems").Value.Equals(""))
                {
                    foreach (string itemNum in item.Element("Reward").Element("NumOfItems").Value.Split(','))
                    {
                        reward.NumOfItems.Add(int.Parse(itemNum));
                    }
                }
                if (!item.Element("Reward").Element("TypeOfItems").Value.Equals(""))
                {
                    foreach (string itemType in item.Element("Reward").Element("TypeOfItems").Value.Split(','))
                    {
                        reward.TypeOfItems.Add(int.Parse(itemType));
                    }
                }

                if (!item.Element("Reward").Element("AttrOfItems").Value.Equals(""))
                {
                    foreach (string itemType in item.Element("Reward").Element("AttrOfItems").Value.Split(','))
                    {
                        if (!item.Element("Reward").Element("Credits").Value.Equals(""))
                        {
                            reward.Credits = float.Parse(item.Element("Reward").Element("Credits").Value);
                        }
                    }
                }


                if (!item.Element("Reward").Element("EventCodes").Value.Equals(""))
                {
                    foreach (string events in item.Element("Reward").Element("EventCodes").Value.Split(','))
                    {
                        reward.NumOfItems.Add(int.Parse(events));
                    }
                }

                try
                {
                    foreach (string fraction in item.Element("Reward").Element("Fractions").Value.Split(','))
                    {
                        if (!fraction.Equals(""))
                        {
                            reward.Fractions.Add(int.Parse(fraction));
                        }
                    }
                }
                catch
                {
                }

                try
                {
                    reward.Unlimited = int.Parse(item.Element("Reward").Element("Unlimited").Value);
                }
                catch
                {
                }

                try
                {
                    reward.Difficulty = int.Parse(item.Element("Reward").Element("Difficulty").Value);
                }
                catch
                {
                    reward.Difficulty = 1;
                }
                //foreach (string fraction in item.Element("Reward").Element("Reputation").Value.Split(','))
                //    if (!fraction.Equals(""))
                //        reward.Reputation.Add(int.Parse(fraction.Split(':')[0]),int.Parse(fraction.Split(':')[1]));

                if (!item.Element("Reward").Element("KarmaPK").Value.Equals(""))
                {
                    reward.KarmaPK = int.Parse(item.Element("Reward").Element("KarmaPK").Value);
                }

                foreach (XElement effect in item.Element("Reward").Element("Effects").Elements())
                {
                    reward.Effects.Add(new CEffect(int.Parse(effect.Element("id").Value.ToString()),
                                                   int.Parse(effect.Element("stack").Value.ToString())));
                }

                if (!item.Element("Additional").Element("ShowProgress").Value.ToString().Equals(""))
                {
                    additional.ShowProgress = int.Parse(item.Element("Additional").Element("ShowProgress").Value.ToString());
                }
                else
                {
                    additional.ShowProgress = this.SHOW_JOURNAL | this.SHOW_MESSAGE_CLOSE | this.SHOW_MESSAGE_TAKE | this.SHOW_MESSAGE_PROGRESS;
                }

                if (!item.Element("Additional").Element("IsSubQuest").Value.Equals(""))
                {
                    additional.IsSubQuest = int.Parse(item.Element("Additional").Element("IsSubQuest").Value);
                }
                if (!item.Element("Additional").Element("ListOfSubQuest").Value.Equals(""))
                {
                    foreach (string quest in item.Element("Additional").Element("ListOfSubQuest").Value.Split(','))
                    {
                        additional.ListOfSubQuest.Add(int.Parse(quest));
                    }
                }

                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Penalty
                string text_pen_exp = item.Element("Penalty").Element("Expirience").Value;

                penalty.Expirience = 0;
                if (!text_pen_exp.Equals(""))
                {
                    if (text_pen_exp.Contains(','))
                    {
                        //After change from three skills role play
                        foreach (string element_pen_exp in text_pen_exp.Split(','))
                        {
                            penalty.Expirience += int.Parse(element_pen_exp);
                        }
                    }
                    else
                    {
                        penalty.Expirience = int.Parse(text_pen_exp);
                    }
                }

                if (!item.Element("Penalty").Element("NumOfItems").Value.Equals(""))
                {
                    foreach (string itemNum in item.Element("Penalty").Element("NumOfItems").Value.Split(','))
                    {
                        penalty.NumOfItems.Add(int.Parse(itemNum));
                    }
                }
                if (!item.Element("Penalty").Element("TypeOfItems").Value.Equals(""))
                {
                    foreach (string itemType in item.Element("Penalty").Element("TypeOfItems").Value.Split(','))
                    {
                        penalty.TypeOfItems.Add(int.Parse(itemType));
                    }
                }
                if (!item.Element("Penalty").Element("Credits").Value.Equals(""))
                {
                    penalty.Credits = float.Parse(item.Element("Penalty").Element("Credits").Value);
                }

                //foreach (string fraction in item.Element("Penalty").Element("Reputation").Value.Split(','))
                //    if (!fraction.Equals(""))
                //        reward.Reputation.Add(int.Parse(fraction.Split(':')[0]), int.Parse(fraction.Split(':')[1]));
                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Penalty

                if (!variable_target.ContainsKey(QuestID))
                {
                    variable_target.Add(QuestID, new CQuest(QuestID, Version, information, precondition, questRules, reward, additional, target, penalty));
                }
            }
        }