private void cboSpec_TextChanged(object sender, EventArgs e) { // Raise the SpecializationChanged Event when the DropDownList's Value changes. // The entire SkillControl is passed as an argument so the handling event can evaluate its contents. if (!_objSkill.CharacterObject.Created || _objSkill.ExoticSkill) { bool blnFound = false; foreach (SkillSpecialization objSpec in _objSkill.Specializations) { if (objSpec.Name == cboSpec.Text) { blnFound = true; break; } } if (!blnFound) { _objSkill.Specializations.Clear(); if (cboSpec.Text != string.Empty) { SkillSpecialization objSpec = new SkillSpecialization(cboSpec.Text); _objSkill.Specializations.Add(objSpec); } SpecializationChanged(this); } } }
/// <summary> /// Load the Attribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { string strId; if (objNode.TryGetField("id", out strId)) { Id = Guid.Parse(strId); } _strName = objNode["name"].InnerText; _strSkillGroup = objNode["skillgroup"].InnerText; _strSkillCategory = objNode["skillcategory"].InnerText; _blnIsGrouped = Convert.ToBoolean(objNode["grouped"].InnerText); _blnDefault = Convert.ToBoolean(objNode["default"].InnerText); _intRating = Convert.ToInt32(objNode["rating"].InnerText); bool basefail = false; try { _intBase = Convert.ToInt32(objNode["base"].InnerText); } catch { _intBase = _intRating; basefail = true; } try { _intKarma = Convert.ToInt32(objNode["karma"].InnerText); } catch { _intKarma = 0; } if (!basefail) { if (_intRating != _intKarma + _intBase) { _intBase = _intRating - _intKarma; } } _intFreeLevels = Convert.ToInt32(objNode["freelevels"].InnerText); _intRatingMaximum = Convert.ToInt32(objNode["ratingmax"].InnerText); _blnKnowledgeSkill = Convert.ToBoolean(objNode["knowledge"].InnerText); try { _blnExoticSkill = Convert.ToBoolean(objNode["exotic"].InnerText); } catch { } try { _blnBuyWithKarma = Convert.ToBoolean(objNode["buywithkarma"].InnerText); } catch { } if (objNode["spec"].InnerText.Contains("Hold-Outs")) objNode["spec"].InnerText = "Holdouts"; _strSkillSpec = objNode["spec"].InnerText; if (_strSkillSpec != "") { SkillSpecialization objSpec = new SkillSpecialization(_strSkillSpec); _lstSpecializations.Add(objSpec); _strSkillSpec = ""; } _blnAllowDelete = Convert.ToBoolean(objNode["allowdelete"].InnerText); _strAttribute = objNode["attribute"].InnerText; if (objNode.InnerXml.Contains("skillspecializations")) { XmlNodeList nodSpecializations = objNode.SelectNodes("skillspecializations/skillspecialization"); foreach (XmlNode nodSpecialization in nodSpecializations) { SkillSpecialization objSpec = new SkillSpecialization(""); objSpec.Load(nodSpecialization); _lstSpecializations.Add(objSpec); } } try { _strSource = objNode["source"].InnerText; _strPage = objNode["page"].InnerText; } catch { } if (objNode["folded"] != null) { foreach (XmlNode foldNode in objNode["folded"].ChildNodes) { Skill s = new Skill(_objCharacter); s.Load(foldNode); _fold.Add(s); } } }
/// <summary> /// Load the Attribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode) { _strName = objNode["name"].InnerText; _strSkillGroup = objNode["skillgroup"].InnerText; _strSkillCategory = objNode["skillcategory"].InnerText; _blnIsGrouped = Convert.ToBoolean(objNode["grouped"].InnerText); _blnDefault = Convert.ToBoolean(objNode["default"].InnerText); _intRating = Convert.ToInt32(objNode["rating"].InnerText); try { _intBase = Convert.ToInt32(objNode["base"].InnerText); } catch { _intBase = _intRating; } try { _intKarma = Convert.ToInt32(objNode["karma"].InnerText); } catch { _intKarma = 0; } _intFreeLevels = Convert.ToInt32(objNode["freelevels"].InnerText); _intRatingMaximum = Convert.ToInt32(objNode["ratingmax"].InnerText); _blnKnowledgeSkill = Convert.ToBoolean(objNode["knowledge"].InnerText); try { _blnExoticSkill = Convert.ToBoolean(objNode["exotic"].InnerText); } catch { } try { _blnBuyWithKarma = Convert.ToBoolean(objNode["buywithkarma"].InnerText); } catch { } if (objNode["spec"].InnerText.Contains("Hold-Outs")) objNode["spec"].InnerText = "Holdouts"; _strSkillSpec = objNode["spec"].InnerText; if (_strSkillSpec != "") { SkillSpecialization objSpec = new SkillSpecialization(_strSkillSpec); _lstSpecializations.Add(objSpec); _strSkillSpec = ""; } _blnAllowDelete = Convert.ToBoolean(objNode["allowdelete"].InnerText); _strAttribute = objNode["attribute"].InnerText; if (objNode.InnerXml.Contains("skillspecializations")) { XmlNodeList nodSpecializations = objNode.SelectNodes("skillspecializations/skillspecialization"); foreach (XmlNode nodSpecialization in nodSpecializations) { SkillSpecialization objSpec = new SkillSpecialization(""); objSpec.Load(nodSpecialization); _lstSpecializations.Add(objSpec); } } try { _strSource = objNode["source"].InnerText; _strPage = objNode["page"].InnerText; } catch { } }
private void cmdChangeSpec_Click(object sender, EventArgs e) { if (_objSkill.CharacterObject.Karma < _objSkill.CharacterObject.Options.KarmaSpecialization) { MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } XmlDocument objXmlDocument = new XmlDocument(); objXmlDocument = XmlManager.Instance.Load("skills.xml"); // When the selected Knowledge Skill is changed, check the Skill file and build the pre-defined list of its Specializations (if any). List<ListItem> lstSpecializations = new List<ListItem>(); XmlNode objXmlSkill; if (_objSkill.KnowledgeSkill) { objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/knowledgeskills/skill[name = \"" + _objSkill.Name + "\"]"); if (objXmlSkill == null) objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/knowledgeskills/skill[translate = \"" + _objSkill.Name + "\"]"); } else { objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + _objSkill.Name + "\"]"); if (objXmlSkill == null) objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[translate = \"" + _objSkill.Name + "\"]"); } if (objXmlSkill != null) { if (!_blnSkipRefresh) cboKnowledgeSkillCategory.SelectedValue = objXmlSkill["category"].InnerText; cboSpec.Items.Clear(); foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec")) { bool blnFound = false; foreach(SkillSpecialization objSpecialization in _objSkill.Specializations) { if (objSpecialization.Name == objXmlSpecialization.InnerText) { blnFound = true; break; } } if (!blnFound) { ListItem objItem = new ListItem(); if (objXmlSpecialization["translate"] != null) objItem.Name = objXmlSpecialization["translate"].InnerText; else objItem.Name = objXmlSpecialization.InnerText; objItem.Value = objItem.Name; lstSpecializations.Add(objItem); } } } if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSkillSpecialization").Replace("{0}", _objSkill.CharacterObject.Options.KarmaSpecialization.ToString()))) return; frmSelectItem frmPickItem = new frmSelectItem(); frmPickItem.DropdownItems = lstSpecializations; frmPickItem.ShowDialog(); if (frmPickItem.DialogResult == DialogResult.Cancel) { return; } string strSelectedValue = frmPickItem.SelectedItem; // charge the karma and add the spec SkillSpecialization objSpec = new SkillSpecialization(strSelectedValue); _objSkill.Specializations.Add(objSpec); // Create the Expense Log Entry. ExpenseLogEntry objEntry = new ExpenseLogEntry(); objEntry.Create(_objSkill.CharacterObject.Options.KarmaSpecialization * -1, LanguageManager.Instance.GetString("String_ExpenseLearnSpecialization") + " " + _objSkill.Name + " (" + strSelectedValue + ")", ExpenseType.Karma, DateTime.Now); _objSkill.CharacterObject.ExpenseEntries.Add(objEntry); _objSkill.CharacterObject.Karma -= _objSkill.CharacterObject.Options.KarmaSpecialization; ExpenseUndo objUndo = new ExpenseUndo(); objUndo.CreateKarma(KarmaExpenseType.AddSpecialization, objSpec.InternalId); objEntry.Undo = objUndo; lblSpec.Text = _objSkill.Specialization; this.Height = lblSpec.Height + 10; RatingChanged(this); }
private void cboSpec_TextChanged(object sender, EventArgs e) { // Raise the SpecializationChanged Event when the DropDownList's Value changes. // The entire SkillControl is passed as an argument so the handling event can evaluate its contents. if (!_objSkill.CharacterObject.Created || _objSkill.ExoticSkill) { bool blnFound = false; foreach (SkillSpecialization objSpec in _objSkill.Specializations) { if (objSpec.Name == cboSpec.Text) { blnFound = true; break; } } if (!blnFound) { _objSkill.Specializations.Clear(); if (cboSpec.Text != string.Empty) { SkillSpecialization objSpec = new SkillSpecialization(cboSpec.Text); _objSkill.Specializations.Add(objSpec); } SpecializationChanged(this); } } }
private void cmdChangeSpec_Click(object sender, EventArgs e) { if (_objSkill.CharacterObject.Karma < _objSkill.CharacterObject.Options.KarmaSpecialization) { MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } XmlDocument objXmlDocument = new XmlDocument(); objXmlDocument = XmlManager.Instance.Load("skills.xml"); // When the selected Knowledge Skill is changed, check the Skill file and build the pre-defined list of its Specializations (if any). List <ListItem> lstSpecializations = new List <ListItem>(); XmlNode objXmlSkill; if (_objSkill.KnowledgeSkill) { objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/knowledgeskills/skill[name = \"" + _objSkill.Name + "\"]"); if (objXmlSkill == null) { objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/knowledgeskills/skill[translate = \"" + _objSkill.Name + "\"]"); } } else { objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + _objSkill.Name + "\"]"); if (objXmlSkill == null) { objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[translate = \"" + _objSkill.Name + "\"]"); } } if (objXmlSkill != null) { if (!_blnSkipRefresh) { cboKnowledgeSkillCategory.SelectedValue = objXmlSkill["category"].InnerText; } cboSpec.Items.Clear(); foreach (XmlNode objXmlSpecialization in objXmlSkill.SelectNodes("specs/spec")) { bool blnFound = false; foreach (SkillSpecialization objSpecialization in _objSkill.Specializations) { if (objSpecialization.Name == objXmlSpecialization.InnerText) { blnFound = true; break; } } if (!blnFound) { ListItem objItem = new ListItem(); if (objXmlSpecialization["translate"] != null) { objItem.Name = objXmlSpecialization["translate"].InnerText; } else { objItem.Name = objXmlSpecialization.InnerText; } objItem.Value = objItem.Name; lstSpecializations.Add(objItem); } } } if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseSkillSpecialization").Replace("{0}", _objSkill.CharacterObject.Options.KarmaSpecialization.ToString()))) { return; } frmSelectItem frmPickItem = new frmSelectItem(); frmPickItem.DropdownItems = lstSpecializations; frmPickItem.ShowDialog(); if (frmPickItem.DialogResult == DialogResult.Cancel) { return; } string strSelectedValue = frmPickItem.SelectedItem; // charge the karma and add the spec SkillSpecialization objSpec = new SkillSpecialization(strSelectedValue); _objSkill.Specializations.Add(objSpec); // Create the Expense Log Entry. ExpenseLogEntry objEntry = new ExpenseLogEntry(); objEntry.Create(_objSkill.CharacterObject.Options.KarmaSpecialization * -1, LanguageManager.Instance.GetString("String_ExpenseLearnSpecialization") + " " + _objSkill.Name + " (" + strSelectedValue + ")", ExpenseType.Karma, DateTime.Now); _objSkill.CharacterObject.ExpenseEntries.Add(objEntry); _objSkill.CharacterObject.Karma -= _objSkill.CharacterObject.Options.KarmaSpecialization; ExpenseUndo objUndo = new ExpenseUndo(); objUndo.CreateKarma(KarmaExpenseType.AddSpecialization, objSpec.InternalId); objEntry.Undo = objUndo; lblSpec.Text = _objSkill.Specialization; this.Height = lblSpec.Height + 10; RatingChanged(this); }
/// <summary> /// Create a Critter, put them into Career Mode, link them, and open the newly-created Critter. /// </summary> /// <param name="strCritterName">Name of the Critter's Metatype.</param> /// <param name="intForce">Critter's Force.</param> private void CreateCritter(string strCritterName, int intForce) { // The Critter should use the same settings file as the character. Character objCharacter = new Character(); objCharacter.SettingsFile = _objSpirit.CharacterObject.SettingsFile; // Override the defaults for the setting. objCharacter.IgnoreRules = true; objCharacter.IsCritter = true; objCharacter.BuildMethod = CharacterBuildMethod.Karma; objCharacter.BuildPoints = 0; if (txtCritterName.Text != string.Empty) objCharacter.Name = txtCritterName.Text; // Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book. bool blnRunningWild = false; blnRunningWild = (objCharacter.Options.Books.Contains("RW")); if (!blnRunningWild) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Ask the user to select a filename for the new character. string strForce = LanguageManager.Instance.GetString("String_Force"); if (_objSpirit.EntityType == SpiritType.Sprite) strForce = LanguageManager.Instance.GetString("String_Rating"); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*"; saveFileDialog.FileName = strCritterName + " (" + strForce + " " + _objSpirit.Force.ToString() + ").chum5"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { string strFileName = saveFileDialog.FileName; objCharacter.FileName = strFileName; } else return; // Code from frmMetatype. ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml"); XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + strCritterName + "\"]"); // If the Critter could not be found, show an error and get out of here. if (objXmlMetatype == null) { MessageBox.Show(LanguageManager.Instance.GetString("Message_UnknownCritterType").Replace("{0}", strCritterName), LanguageManager.Instance.GetString("MessageTitle_SelectCritterType"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Set Metatype information. if (strCritterName == "Ally Spirit") { objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0)); objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0)); objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0)); objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0)); objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0)); objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0)); objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0)); objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0)); objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0)); objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0)); objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0)); objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } else { int intMinModifier = -3; if (objXmlMetatype["category"].InnerText == "Mutant Critters") intMinModifier = 0; objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3)); objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3)); objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3)); objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3)); objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3)); objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3)); objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3)); objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3)); objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3)); objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3)); objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3)); objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } // If we're working with a Critter, set the Attributes to their default values. objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0)); objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0)); objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0)); objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0)); objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0)); objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0)); objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0)); objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0)); objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0)); objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0)); objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0)); objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0)); // Sprites can never have Physical Attributes or WIL. if (objXmlMetatype["category"].InnerText.EndsWith("Sprite")) { objCharacter.BOD.AssignLimits("0", "0", "0"); objCharacter.AGI.AssignLimits("0", "0", "0"); objCharacter.REA.AssignLimits("0", "0", "0"); objCharacter.STR.AssignLimits("0", "0", "0"); objCharacter.WIL.AssignLimits("0", "0", "0"); objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); } objCharacter.Metatype = strCritterName; objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText; objCharacter.Metavariant = ""; objCharacter.MetatypeBP = 0; if (objXmlMetatype["movement"] != null) objCharacter.Movement = objXmlMetatype["movement"].InnerText; // Load the Qualities file. XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml"); // Determine if the Metatype has any bonuses. if (objXmlMetatype.InnerXml.Contains("bonus")) objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, strCritterName, objXmlMetatype.SelectSingleNode("bonus"), false, 1, strCritterName); // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) objCharacter.Weapons.Add(objWeapon); } foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) objCharacter.Weapons.Add(objWeapon); } // Add any Critter Powers the Metatype/Critter should have. XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + objCharacter.Metatype + "\"]"); objXmlDocument = XmlManager.Instance.Load("critterpowers.xml"); foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); if (objXmlPower.Attributes["select"] != null) strForcedValue = objXmlPower.Attributes["select"].InnerText; objPower.Create(objXmlCritterPower, objCharacter, objNode, intRating, strForcedValue); objCharacter.CritterPowers.Add(objPower); } // Set the Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill")) { if (objXmlSkill.InnerText.Contains("Exotic")) { Skill objExotic = new Skill(objCharacter); objExotic.ExoticSkill = true; objExotic.Attribute = "AGI"; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objExotic.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Name = objXmlSkill.InnerText; objCharacter.Skills.Add(objExotic); } else { foreach (Skill objSkill in objCharacter.Skills) { if (objSkill.Name == objXmlSkill.InnerText) { if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objSkill.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } } // Set the Skill Group Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group")) { foreach (SkillGroup objSkill in objCharacter.SkillGroups) { if (objSkill.Name == objXmlSkill.InnerText) { objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } // Set the Knowledge Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge")) { Skill objKnowledge = new Skill(objCharacter); objKnowledge.Name = objXmlSkill.InnerText; objKnowledge.KnowledgeSkill = true; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objKnowledge.Specializations.Add(objSpec); } objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText; if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6) objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); objCharacter.Skills.Add(objKnowledge); } // If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums. if (intForce > 0) { int intMaxRating = intForce; // Determine the highest Skill Rating the Critter has. foreach (Skill objSkill in objCharacter.Skills) { if (objSkill.RatingMaximum > intMaxRating) intMaxRating = objSkill.RatingMaximum; } // Now that we know the upper limit, set all of the Skill Rating Maximums to match. foreach (Skill objSkill in objCharacter.Skills) objSkill.RatingMaximum = intMaxRating; foreach (SkillGroup objGroup in objCharacter.SkillGroups) objGroup.RatingMaximum = intMaxRating; // Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills. objCharacter.MaxSkillRating = intMaxRating; } // Add any Complex Forms the Critter comes with (typically Sprites) XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml"); foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform")) { string strForceValue = ""; if (objXmlComplexForm.Attributes["select"] != null) strForceValue = objXmlComplexForm.Attributes["select"].InnerText; XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]"); TreeNode objNode = new TreeNode(); ComplexForm objProgram = new ComplexForm(objCharacter); objProgram.Create(objXmlProgram, objCharacter, objNode, strForceValue); objCharacter.ComplexForms.Add(objProgram); } // Add any Gear the Critter comes with (typically Programs for A.I.s) XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml"); foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear")) { int intRating = 0; if (objXmlGear.Attributes["rating"] != null) intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); string strForceValue = ""; if (objXmlGear.Attributes["select"] != null) strForceValue = objXmlGear.Attributes["select"].InnerText; XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]"); TreeNode objNode = new TreeNode(); Gear objGear = new Gear(objCharacter); List<Weapon> lstWeapons = new List<Weapon>(); List<TreeNode> lstWeaponNodes = new List<TreeNode>(); objGear.Create(objXmlGearItem, objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue); objGear.Cost = "0"; objGear.Cost3 = "0"; objGear.Cost6 = "0"; objGear.Cost10 = "0"; objCharacter.Gear.Add(objGear); } // If this is a Mutant Critter, count up the number of Skill points they start with. if (objCharacter.MetatypeCategory == "Mutant Critters") { foreach (Skill objSkill in objCharacter.Skills) objCharacter.MutantCritterBaseSkills += objSkill.Rating; } // Add the Unarmed Attack Weapon to the character. try { objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]"); TreeNode objDummy = new TreeNode(); Weapon objWeapon = new Weapon(objCharacter); objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null); objCharacter.Weapons.Add(objWeapon); } catch { } objCharacter.Alias = strCritterName; objCharacter.Created = true; objCharacter.Save(); string strOpenFile = objCharacter.FileName; objCharacter = null; // Link the newly-created Critter to the Spirit. _objSpirit.FileName = strOpenFile; if (_objSpirit.EntityType == SpiritType.Spirit) tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Spirit_OpenFile")); else tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Sprite_OpenFile")); FileNameChanged(this); GlobalOptions.Instance.MainForm.LoadCharacter(strOpenFile, true); }
/// <summary> /// A Metatype has been selected, so fill in all of the necessary Character information. /// </summary> void MetatypeSelected() { if (lstMetatypes.Text != "") { ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter); XmlDocument objXmlDocument = XmlManager.Instance.Load(_strXmlFile); XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + lstMetatypes.SelectedValue + "\"]"); XmlNode objXmlMetavariant = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + lstMetatypes.SelectedValue + "\"]/metavariants/metavariant[name = \"" + cboMetavariant.SelectedValue + "\"]"); int intForce = 0; if (nudForce.Visible) intForce = Convert.ToInt32(nudForce.Value); // Set Metatype information. if (cboMetavariant.SelectedValue.ToString() != "None") { _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetavariant["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["bodaug"].InnerText, intForce, 0)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetavariant["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["agiaug"].InnerText, intForce, 0)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetavariant["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["reaaug"].InnerText, intForce, 0)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetavariant["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["straug"].InnerText, intForce, 0)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetavariant["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["chaaug"].InnerText, intForce, 0)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetavariant["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["intaug"].InnerText, intForce, 0)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetavariant["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["logaug"].InnerText, intForce, 0)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetavariant["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["wilaug"].InnerText, intForce, 0)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetavariant["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetavariant["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["magaug"].InnerText, intForce, 0)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetavariant["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["resaug"].InnerText, intForce, 0)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetavariant["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["edgaug"].InnerText, intForce, 0)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetavariant["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["essaug"].InnerText, intForce, 0)); } else if (_strXmlFile != "critters.xml" || lstMetatypes.SelectedValue.ToString() == "Ally Spirit") { _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } else { int intMinModifier = -3; if (cboCategory.SelectedValue.ToString() == "Mutant Critters") intMinModifier = 0; _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } // If we're working with a Critter, set the Attributes to their default values. if (_strXmlFile == "critters.xml") { _objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0)); _objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0)); _objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0)); _objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0)); _objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0)); _objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0)); _objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0)); _objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0)); _objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0)); _objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0)); _objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0)); _objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0)); } // Sprites can never have Physical Attributes or WIL. if (lstMetatypes.SelectedValue.ToString().EndsWith("Sprite")) { _objCharacter.BOD.AssignLimits("0", "0", "0"); _objCharacter.AGI.AssignLimits("0", "0", "0"); _objCharacter.REA.AssignLimits("0", "0", "0"); _objCharacter.STR.AssignLimits("0", "0", "0"); _objCharacter.WIL.AssignLimits("0", "0", "0"); _objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); _objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); } // If this is a Shapeshifter, a Metavariant must be selected. Default to Human if None is selected. if (cboCategory.SelectedValue.ToString() == "Shapeshifter" && cboMetavariant.SelectedValue.ToString() == "None") cboMetavariant.SelectedValue = "Human"; _objCharacter.Metatype = lstMetatypes.SelectedValue.ToString(); _objCharacter.MetatypeCategory = cboCategory.SelectedValue.ToString(); if (cboMetavariant.SelectedValue.ToString() == "None") { _objCharacter.Metavariant = ""; _objCharacter.MetatypeBP = Convert.ToInt32(lblBP.Text); } else { _objCharacter.Metavariant = cboMetavariant.SelectedValue.ToString(); _objCharacter.MetatypeBP = Convert.ToInt32(lblMetavariantBP.Text); } if (objXmlMetatype["movement"] != null) _objCharacter.Movement = objXmlMetatype["movement"].InnerText; // Load the Qualities file. XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml"); if (cboMetavariant.SelectedValue.ToString() == "None") { // Determine if the Metatype has any bonuses. if (objXmlMetatype.InnerXml.Contains("bonus")) objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, lstMetatypes.SelectedValue.ToString(), objXmlMetatype.SelectSingleNode("bonus"), false, 1, lstMetatypes.SelectedValue.ToString()); // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } } // If a Metavariant has been selected, locate it in the file. if (cboMetavariant.SelectedValue.ToString() != "None") { // Determine if the Metavariant has any bonuses. if (objXmlMetavariant.InnerXml.Contains("bonus")) { objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metavariant, cboMetavariant.SelectedValue.ToString(), objXmlMetavariant.SelectSingleNode("bonus"), false, 1, cboMetavariant.SelectedValue.ToString()); } // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetavariant.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } foreach (XmlNode objXmlQualityItem in objXmlMetavariant.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } } // Run through the character's Attributes one more time and make sure their value matches their minimum value. if (_strXmlFile == "metatypes.xml") { _objCharacter.BOD.Value = _objCharacter.BOD.TotalMinimum; _objCharacter.AGI.Value = _objCharacter.AGI.TotalMinimum; _objCharacter.REA.Value = _objCharacter.REA.TotalMinimum; _objCharacter.STR.Value = _objCharacter.STR.TotalMinimum; _objCharacter.CHA.Value = _objCharacter.CHA.TotalMinimum; _objCharacter.INT.Value = _objCharacter.INT.TotalMinimum; _objCharacter.LOG.Value = _objCharacter.LOG.TotalMinimum; _objCharacter.WIL.Value = _objCharacter.WIL.TotalMinimum; } // Add any Critter Powers the Metatype/Critter should have. XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]"); objXmlDocument = XmlManager.Instance.Load("critterpowers.xml"); foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); if (objXmlPower.Attributes["select"] != null) strForcedValue = objXmlPower.Attributes["select"].InnerText; objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Add any Critter Powers the Metavariant should have. if (cboMetavariant.SelectedValue.ToString() != "None") { foreach (XmlNode objXmlPower in objXmlMetavariant.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); if (objXmlPower.Attributes["select"] != null) strForcedValue = objXmlPower.Attributes["select"].InnerText; objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } } // If this is a Blood Spirit, add their free Critter Powers. if (chkBloodSpirit.Checked) { XmlNode objXmlCritterPower; TreeNode objNode; CritterPower objPower; bool blnAddPower = true; // Energy Drain. foreach (CritterPower objFindPower in _objCharacter.CritterPowers) { if (objFindPower.Name == "Energy Drain") { blnAddPower = false; break; } } if (blnAddPower) { objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Energy Drain\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Fear. blnAddPower = true; foreach (CritterPower objFindPower in _objCharacter.CritterPowers) { if (objFindPower.Name == "Fear") { blnAddPower = false; break; } } if (blnAddPower) { objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Fear\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Natural Weapon. objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Natural Weapon\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "DV " + intForce.ToString() + "P, AP 0"); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); // Evanescence. blnAddPower = true; foreach (CritterPower objFindPower in _objCharacter.CritterPowers) { if (objFindPower.Name == "Evanescence") { blnAddPower = false; break; } } if (blnAddPower) { objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Evanescence\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } } // Remove the Critter's Materialization Power if they have it. Add the Possession or Inhabitation Power if the Possession-based Tradition checkbox is checked. if (chkPossessionBased.Checked) { foreach (CritterPower objCritterPower in _objCharacter.CritterPowers) { if (objCritterPower.Name == "Materialization") { _objCharacter.CritterPowers.Remove(objCritterPower); break; } } // Add the selected Power. XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + cboPossessionMethod.SelectedValue.ToString() + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Set the Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill")) { if (objXmlSkill.InnerText.Contains("Exotic")) { Skill objExotic = new Skill(_objCharacter); objExotic.ExoticSkill = true; objExotic.Attribute = "AGI"; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objExotic.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Name = objXmlSkill.InnerText; _objCharacter.Skills.Add(objExotic); } else { foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.Name == objXmlSkill.InnerText) { if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objSkill.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } } // Set the Skill Group Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group")) { foreach (SkillGroup objSkill in _objCharacter.SkillGroups) { if (objSkill.Name == objXmlSkill.InnerText) { objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } // Set the Knowledge Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge")) { Skill objKnowledge = new Skill(_objCharacter); objKnowledge.Name = objXmlSkill.InnerText; objKnowledge.KnowledgeSkill = true; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objKnowledge.Specializations.Add(objSpec); } objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText; if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6) objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); _objCharacter.Skills.Add(objKnowledge); } // If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums. if (intForce > 0) { int intMaxRating = intForce; // Determine the highest Skill Rating the Critter has. foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.RatingMaximum > intMaxRating) intMaxRating = objSkill.RatingMaximum; } // Now that we know the upper limit, set all of the Skill Rating Maximums to match. foreach (Skill objSkill in _objCharacter.Skills) objSkill.RatingMaximum = intMaxRating; foreach (SkillGroup objGroup in _objCharacter.SkillGroups) objGroup.RatingMaximum = intMaxRating; // Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills. _objCharacter.MaxSkillRating = intMaxRating; } // Add any Complex Forms the Critter comes with (typically Sprites) XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml"); foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform")) { string strForceValue = ""; if (objXmlComplexForm.Attributes["select"] != null) strForceValue = objXmlComplexForm.Attributes["select"].InnerText; XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]"); TreeNode objNode = new TreeNode(); ComplexForm objProgram = new ComplexForm(_objCharacter); objProgram.Create(objXmlProgram, _objCharacter, objNode, strForceValue); _objCharacter.ComplexForms.Add(objProgram); } // Add any Gear the Critter comes with (typically Programs for A.I.s) XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml"); foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear")) { int intRating = 0; if (objXmlGear.Attributes["rating"] != null) intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); string strForceValue = ""; if (objXmlGear.Attributes["select"] != null) strForceValue = objXmlGear.Attributes["select"].InnerText; XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]"); TreeNode objNode = new TreeNode(); Gear objGear = new Gear(_objCharacter); List<Weapon> lstWeapons = new List<Weapon>(); List<TreeNode> lstWeaponNodes = new List<TreeNode>(); objGear.Create(objXmlGearItem, _objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue); objGear.Cost = "0"; objGear.Cost3 = "0"; objGear.Cost6 = "0"; objGear.Cost10 = "0"; _objCharacter.Gear.Add(objGear); } // If this is a Mutant Critter, count up the number of Skill points they start with. if (_objCharacter.MetatypeCategory == "Mutant Critters") { foreach (Skill objSkill in _objCharacter.Skills) _objCharacter.MutantCritterBaseSkills += objSkill.Rating; } if (cboMetavariant.Text != "None") { int x = 0; int.TryParse(lblMetavariantBP.Text, out x); //_objCharacter.BuildKarma = _objCharacter.BuildKarma - x; } else { int x = 0; int.TryParse(lblBP.Text, out x); //_objCharacter.BuildKarma = _objCharacter.BuildKarma - x; } this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectMetatype"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectMetatype"), MessageBoxButtons.OK, MessageBoxIcon.Information); } _objCharacter.Movement = (_objCharacter.AGI.TotalValue * 2).ToString() + "/" + (_objCharacter.AGI.TotalValue * 4).ToString(); }
/// <summary> /// Create a Critter, put them into Career Mode, link them, and open the newly-created Critter. /// </summary> /// <param name="strCritterName">Name of the Critter's Metatype.</param> /// <param name="intForce">Critter's Force.</param> private void CreateCritter(string strCritterName, int intForce) { // The Critter should use the same settings file as the character. Character objCharacter = new Character(); objCharacter.SettingsFile = _objSpirit.CharacterObject.SettingsFile; // Override the defaults for the setting. objCharacter.IgnoreRules = true; objCharacter.IsCritter = true; objCharacter.BuildMethod = CharacterBuildMethod.Karma; objCharacter.BuildPoints = 0; if (txtCritterName.Text != string.Empty) { objCharacter.Name = txtCritterName.Text; } // Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book. bool blnRunningWild = false; blnRunningWild = (objCharacter.Options.Books.Contains("RW")); if (!blnRunningWild) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Ask the user to select a filename for the new character. string strForce = LanguageManager.Instance.GetString("String_Force"); if (_objSpirit.EntityType == SpiritType.Sprite) { strForce = LanguageManager.Instance.GetString("String_Rating"); } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*"; saveFileDialog.FileName = strCritterName + " (" + strForce + " " + _objSpirit.Force.ToString() + ").chum5"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { string strFileName = saveFileDialog.FileName; objCharacter.FileName = strFileName; } else { return; } // Code from frmMetatype. ImprovementManager objImprovementManager = new ImprovementManager(objCharacter); XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml"); XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + strCritterName + "\"]"); // If the Critter could not be found, show an error and get out of here. if (objXmlMetatype == null) { MessageBox.Show(LanguageManager.Instance.GetString("Message_UnknownCritterType").Replace("{0}", strCritterName), LanguageManager.Instance.GetString("MessageTitle_SelectCritterType"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Set Metatype information. if (strCritterName == "Ally Spirit") { objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0)); objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0)); objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0)); objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0)); objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0)); objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0)); objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0)); objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0)); objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0)); objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0)); objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0)); objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } else { int intMinModifier = -3; if (objXmlMetatype["category"].InnerText == "Mutant Critters") { intMinModifier = 0; } objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3)); objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3)); objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3)); objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3)); objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3)); objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3)); objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3)); objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3)); objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3)); objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3)); objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3)); objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } // If we're working with a Critter, set the Attributes to their default values. objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0)); objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0)); objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0)); objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0)); objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0)); objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0)); objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0)); objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0)); objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0)); objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0)); objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0)); objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0)); // Sprites can never have Physical Attributes or WIL. if (objXmlMetatype["category"].InnerText.EndsWith("Sprite")) { objCharacter.BOD.AssignLimits("0", "0", "0"); objCharacter.AGI.AssignLimits("0", "0", "0"); objCharacter.REA.AssignLimits("0", "0", "0"); objCharacter.STR.AssignLimits("0", "0", "0"); objCharacter.WIL.AssignLimits("0", "0", "0"); objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); } objCharacter.Metatype = strCritterName; objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText; objCharacter.Metavariant = ""; objCharacter.MetatypeBP = 0; if (objXmlMetatype["movement"] != null) { objCharacter.Movement = objXmlMetatype["movement"].InnerText; } // Load the Qualities file. XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml"); // Determine if the Metatype has any bonuses. if (objXmlMetatype.InnerXml.Contains("bonus")) { objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, strCritterName, objXmlMetatype.SelectSingleNode("bonus"), false, 1, strCritterName); } // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List <Weapon> objWeapons = new List <Weapon>(); List <TreeNode> objWeaponNodes = new List <TreeNode>(); Quality objQuality = new Quality(objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) { strForceValue = objXmlQualityItem.Attributes["select"].InnerText; } QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) { objSource = QualitySource.MetatypeRemovable; } objQuality.Create(objXmlQuality, objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) { objCharacter.Weapons.Add(objWeapon); } } foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List <Weapon> objWeapons = new List <Weapon>(); List <TreeNode> objWeaponNodes = new List <TreeNode>(); Quality objQuality = new Quality(objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) { strForceValue = objXmlQualityItem.Attributes["select"].InnerText; } QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) { objSource = QualitySource.MetatypeRemovable; } objQuality.Create(objXmlQuality, objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) { objCharacter.Weapons.Add(objWeapon); } } // Add any Critter Powers the Metatype/Critter should have. XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + objCharacter.Metatype + "\"]"); objXmlDocument = XmlManager.Instance.Load("critterpowers.xml"); foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) { intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); } if (objXmlPower.Attributes["select"] != null) { strForcedValue = objXmlPower.Attributes["select"].InnerText; } objPower.Create(objXmlCritterPower, objCharacter, objNode, intRating, strForcedValue); objCharacter.CritterPowers.Add(objPower); } // Set the Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill")) { if (objXmlSkill.InnerText.Contains("Exotic")) { Skill objExotic = new Skill(objCharacter); objExotic.ExoticSkill = true; objExotic.Attribute = "AGI"; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objExotic.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) { objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); } objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Name = objXmlSkill.InnerText; objCharacter.Skills.Add(objExotic); } else { foreach (Skill objSkill in objCharacter.Skills) { if (objSkill.Name == objXmlSkill.InnerText) { if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objSkill.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) { objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); } objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } } // Set the Skill Group Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group")) { foreach (SkillGroup objSkill in objCharacter.SkillGroups) { if (objSkill.Name == objXmlSkill.InnerText) { objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } // Set the Knowledge Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge")) { Skill objKnowledge = new Skill(objCharacter); objKnowledge.Name = objXmlSkill.InnerText; objKnowledge.KnowledgeSkill = true; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objKnowledge.Specializations.Add(objSpec); } objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText; if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6) { objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); } objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); objCharacter.Skills.Add(objKnowledge); } // If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums. if (intForce > 0) { int intMaxRating = intForce; // Determine the highest Skill Rating the Critter has. foreach (Skill objSkill in objCharacter.Skills) { if (objSkill.RatingMaximum > intMaxRating) { intMaxRating = objSkill.RatingMaximum; } } // Now that we know the upper limit, set all of the Skill Rating Maximums to match. foreach (Skill objSkill in objCharacter.Skills) { objSkill.RatingMaximum = intMaxRating; } foreach (SkillGroup objGroup in objCharacter.SkillGroups) { objGroup.RatingMaximum = intMaxRating; } // Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills. objCharacter.MaxSkillRating = intMaxRating; } // Add any Complex Forms the Critter comes with (typically Sprites) XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml"); foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform")) { string strForceValue = ""; if (objXmlComplexForm.Attributes["select"] != null) { strForceValue = objXmlComplexForm.Attributes["select"].InnerText; } XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]"); TreeNode objNode = new TreeNode(); ComplexForm objProgram = new ComplexForm(objCharacter); objProgram.Create(objXmlProgram, objCharacter, objNode, strForceValue); objCharacter.ComplexForms.Add(objProgram); } // Add any Gear the Critter comes with (typically Programs for A.I.s) XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml"); foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear")) { int intRating = 0; if (objXmlGear.Attributes["rating"] != null) { intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); } string strForceValue = ""; if (objXmlGear.Attributes["select"] != null) { strForceValue = objXmlGear.Attributes["select"].InnerText; } XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]"); TreeNode objNode = new TreeNode(); Gear objGear = new Gear(objCharacter); List <Weapon> lstWeapons = new List <Weapon>(); List <TreeNode> lstWeaponNodes = new List <TreeNode>(); objGear.Create(objXmlGearItem, objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue); objGear.Cost = "0"; objGear.Cost3 = "0"; objGear.Cost6 = "0"; objGear.Cost10 = "0"; objCharacter.Gear.Add(objGear); } // If this is a Mutant Critter, count up the number of Skill points they start with. if (objCharacter.MetatypeCategory == "Mutant Critters") { foreach (Skill objSkill in objCharacter.Skills) { objCharacter.MutantCritterBaseSkills += objSkill.Rating; } } // Add the Unarmed Attack Weapon to the character. try { objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]"); TreeNode objDummy = new TreeNode(); Weapon objWeapon = new Weapon(objCharacter); objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null); objCharacter.Weapons.Add(objWeapon); } catch { } objCharacter.Alias = strCritterName; objCharacter.Created = true; objCharacter.Save(); string strOpenFile = objCharacter.FileName; objCharacter = null; // Link the newly-created Critter to the Spirit. _objSpirit.FileName = strOpenFile; if (_objSpirit.EntityType == SpiritType.Spirit) { tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Spirit_OpenFile")); } else { tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Sprite_OpenFile")); } FileNameChanged(this); GlobalOptions.Instance.MainForm.LoadCharacter(strOpenFile, true); }
/// <summary> /// A Metatype has been selected, so fill in all of the necessary Character information. /// </summary> void MetatypeSelected() { if (cboTalents.SelectedIndex == -1) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectTalent"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectTalent"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if ((cboSkill1.SelectedIndex == -1 && cboSkill1.Visible) || (cboSkill2.SelectedIndex == -1 && cboSkill2.Visible)) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectSkill"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectSkill"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (cboSkill1.Visible && cboSkill2.Visible && cboSkill1.SelectedValue.ToString() == cboSkill2.SelectedValue.ToString()) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_Duplicate"), LanguageManager.Instance.GetString("MessageTitle_Metatype_Duplicate"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (lstMetatypes.Text != "") { ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter); XmlDocument objXmlDocument = XmlManager.Instance.Load(_strXmlFile); XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + lstMetatypes.SelectedValue + "\"]"); XmlNode objXmlMetavariant = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + lstMetatypes.SelectedValue + "\"]/metavariants/metavariant[name = \"" + cboMetavariant.SelectedValue + "\"]"); int intForce = 0; if (nudForce.Visible) intForce = Convert.ToInt32(nudForce.Value); // Set Metatype information. if (cboMetavariant.SelectedValue.ToString() != "None") { _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetavariant["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["bodaug"].InnerText, intForce, 0)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetavariant["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["agiaug"].InnerText, intForce, 0)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetavariant["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["reaaug"].InnerText, intForce, 0)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetavariant["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["straug"].InnerText, intForce, 0)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetavariant["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["chaaug"].InnerText, intForce, 0)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetavariant["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["intaug"].InnerText, intForce, 0)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetavariant["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["logaug"].InnerText, intForce, 0)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetavariant["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["wilaug"].InnerText, intForce, 0)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetavariant["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetavariant["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["magaug"].InnerText, intForce, 0)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetavariant["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["resaug"].InnerText, intForce, 0)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetavariant["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["edgaug"].InnerText, intForce, 0)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetavariant["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetavariant["essaug"].InnerText, intForce, 0)); _objCharacter.MetatypeBP = Convert.ToInt32(lblMetavariantBP.Text); } else if (_strXmlFile != "critters.xml" || lstMetatypes.SelectedValue.ToString() == "Ally Spirit") { _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } else { int intMinModifier = -3; if (cboCategory.SelectedValue.ToString() == "Mutant Critters") intMinModifier = 0; _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } // If we're working with a Critter, set the Attributes to their default values. if (_strXmlFile == "critters.xml") { _objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0)); _objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0)); _objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0)); _objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0)); _objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0)); _objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0)); _objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0)); _objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0)); _objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0)); _objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0)); _objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0)); _objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0)); } // Sprites can never have Physical Attributes or WIL. if (lstMetatypes.SelectedValue.ToString().EndsWith("Sprite")) { _objCharacter.BOD.AssignLimits("0", "0", "0"); _objCharacter.AGI.AssignLimits("0", "0", "0"); _objCharacter.REA.AssignLimits("0", "0", "0"); _objCharacter.STR.AssignLimits("0", "0", "0"); _objCharacter.WIL.AssignLimits("0", "0", "0"); _objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); _objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); } // If this is a Shapeshifter, a Metavariant must be selected. Default to Human if None is selected. if (cboCategory.SelectedValue.ToString() == "Shapeshifter" && cboMetavariant.SelectedValue.ToString() == "None") cboMetavariant.SelectedValue = "Human"; _objCharacter.Metatype = lstMetatypes.SelectedValue.ToString(); _objCharacter.MetatypeCategory = cboCategory.SelectedValue.ToString(); if (cboMetavariant.SelectedValue.ToString() == "None") { _objCharacter.Metavariant = ""; } else { _objCharacter.Metavariant = cboMetavariant.SelectedValue.ToString(); } if (objXmlMetatype["movement"] != null) // TODO: Replace with Walk/Run _objCharacter.Movement = objXmlMetatype["movement"].InnerText; // Load the Qualities file. XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml"); if (cboMetavariant.SelectedValue.ToString() == "None") { // Determine if the Metatype has any bonuses. if (objXmlMetatype.InnerXml.Contains("bonus")) objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, lstMetatypes.SelectedValue.ToString(), objXmlMetatype.SelectSingleNode("bonus"), false, 1, lstMetatypes.SelectedValue.ToString()); // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } } // If a Metavariant has been selected, locate it in the file. if (cboMetavariant.SelectedValue.ToString() != "None") { // Determine if the Metavariant has any bonuses. if (objXmlMetavariant.InnerXml.Contains("bonus")) objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metavariant, cboMetavariant.SelectedValue.ToString(), objXmlMetavariant.SelectSingleNode("bonus"), false, 1, cboMetavariant.SelectedValue.ToString()); // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetavariant.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); objQuality.ContributeToLimit = false; string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } foreach (XmlNode objXmlQualityItem in objXmlMetavariant.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); objQuality.ContributeToLimit = false; _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } } // Run through the character's Attributes one more time and make sure their value matches their minimum value. if (_strXmlFile == "metatypes.xml") { _objCharacter.BOD.Value = _objCharacter.BOD.TotalMinimum; _objCharacter.AGI.Value = _objCharacter.AGI.TotalMinimum; _objCharacter.REA.Value = _objCharacter.REA.TotalMinimum; _objCharacter.STR.Value = _objCharacter.STR.TotalMinimum; _objCharacter.CHA.Value = _objCharacter.CHA.TotalMinimum; _objCharacter.INT.Value = _objCharacter.INT.TotalMinimum; _objCharacter.LOG.Value = _objCharacter.LOG.TotalMinimum; _objCharacter.WIL.Value = _objCharacter.WIL.TotalMinimum; _objCharacter.BOD.Base = _objCharacter.BOD.TotalMinimum; _objCharacter.AGI.Base = _objCharacter.AGI.TotalMinimum; _objCharacter.REA.Base = _objCharacter.REA.TotalMinimum; _objCharacter.STR.Base = _objCharacter.STR.TotalMinimum; _objCharacter.CHA.Base = _objCharacter.CHA.TotalMinimum; _objCharacter.INT.Base = _objCharacter.INT.TotalMinimum; _objCharacter.LOG.Base = _objCharacter.LOG.TotalMinimum; _objCharacter.WIL.Base = _objCharacter.WIL.TotalMinimum; _objCharacter.BOD.Karma = 0; _objCharacter.AGI.Karma = 0; _objCharacter.REA.Karma = 0; _objCharacter.STR.Karma = 0; _objCharacter.CHA.Karma = 0; _objCharacter.INT.Karma = 0; _objCharacter.LOG.Karma = 0; _objCharacter.WIL.Karma = 0; _objCharacter.EDG.Karma = 0; _objCharacter.MAG.Karma = 0; _objCharacter.RES.Karma = 0; } // Add any Critter Powers the Metatype/Critter should have. XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]"); objXmlDocument = XmlManager.Instance.Load("critterpowers.xml"); foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); if (objXmlPower.Attributes["select"] != null) strForcedValue = objXmlPower.Attributes["select"].InnerText; objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Add any Critter Powers the Metavariant should have. if (cboMetavariant.SelectedValue.ToString() != "None") { foreach (XmlNode objXmlPower in objXmlMetavariant.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); if (objXmlPower.Attributes["select"] != null) strForcedValue = objXmlPower.Attributes["select"].InnerText; objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } } // If this is a Blood Spirit, add their free Critter Powers. if (chkBloodSpirit.Checked) { XmlNode objXmlCritterPower; TreeNode objNode; CritterPower objPower; bool blnAddPower = true; // Energy Drain. foreach (CritterPower objFindPower in _objCharacter.CritterPowers) { if (objFindPower.Name == "Energy Drain") { blnAddPower = false; break; } } if (blnAddPower) { objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Energy Drain\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Fear. blnAddPower = true; foreach (CritterPower objFindPower in _objCharacter.CritterPowers) { if (objFindPower.Name == "Fear") { blnAddPower = false; break; } } if (blnAddPower) { objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Fear\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Natural Weapon. objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Natural Weapon\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, "DV " + intForce.ToString() + "P, AP 0"); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); // Evanescence. blnAddPower = true; foreach (CritterPower objFindPower in _objCharacter.CritterPowers) { if (objFindPower.Name == "Evanescence") { blnAddPower = false; break; } } if (blnAddPower) { objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"Evanescence\"]"); objNode = new TreeNode(); objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } } // Remove the Critter's Materialization Power if they have it. Add the Possession or Inhabitation Power if the Possession-based Tradition checkbox is checked. if (chkPossessionBased.Checked) { foreach (CritterPower objCritterPower in _objCharacter.CritterPowers) { if (objCritterPower.Name == "Materialization") { _objCharacter.CritterPowers.Remove(objCritterPower); break; } } // Add the selected Power. XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + cboPossessionMethod.SelectedValue.ToString() + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); objPower.Create(objXmlCritterPower, _objCharacter, objNode, 0, ""); objPower.CountTowardsLimit = false; _objCharacter.CritterPowers.Add(objPower); } // Set the Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill")) { if (objXmlSkill.InnerText.Contains("Exotic")) { Skill objExotic = new Skill(_objCharacter); objExotic.ExoticSkill = true; objExotic.Attribute = "AGI"; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objExotic.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objExotic.Name = objXmlSkill.InnerText; _objCharacter.Skills.Add(objExotic); } else { foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.Name == objXmlSkill.InnerText) { if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objSkill.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)) > 6) objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } } // Set the Skill Group Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group")) { foreach (SkillGroup objSkill in _objCharacter.SkillGroups) { if (objSkill.Name == objXmlSkill.InnerText) { objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); break; } } } // Set the Knowledge Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge")) { Skill objKnowledge = new Skill(_objCharacter); objKnowledge.Name = objXmlSkill.InnerText; objKnowledge.KnowledgeSkill = true; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objKnowledge.Specializations.Add(objSpec); } objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText; if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6) objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); _objCharacter.Skills.Add(objKnowledge); } // If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums. if (intForce > 0) { int intMaxRating = intForce; // Determine the highest Skill Rating the Critter has. foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.RatingMaximum > intMaxRating) intMaxRating = objSkill.RatingMaximum; } // Now that we know the upper limit, set all of the Skill Rating Maximums to match. foreach (Skill objSkill in _objCharacter.Skills) objSkill.RatingMaximum = intMaxRating; foreach (SkillGroup objGroup in _objCharacter.SkillGroups) objGroup.RatingMaximum = intMaxRating; // Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills. _objCharacter.MaxSkillRating = intMaxRating; } // Add any Complex Forms the Critter comes with (typically Sprites) XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml"); foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform")) { string strForceValue = ""; if (objXmlComplexForm.Attributes["select"] != null) strForceValue = objXmlComplexForm.Attributes["select"].InnerText; XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]"); TreeNode objNode = new TreeNode(); ComplexForm objProgram = new ComplexForm(_objCharacter); objProgram.Create(objXmlProgram, _objCharacter, objNode, strForceValue); _objCharacter.ComplexForms.Add(objProgram); } // Add any Gear the Critter comes with (typically Programs for A.I.s) XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml"); foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear")) { int intRating = 0; if (objXmlGear.Attributes["rating"] != null) intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(nudForce.Value), 0)); string strForceValue = ""; if (objXmlGear.Attributes["select"] != null) strForceValue = objXmlGear.Attributes["select"].InnerText; XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]"); TreeNode objNode = new TreeNode(); Gear objGear = new Gear(_objCharacter); List<Weapon> lstWeapons = new List<Weapon>(); List<TreeNode> lstWeaponNodes = new List<TreeNode>(); objGear.Create(objXmlGearItem, _objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue); objGear.Cost = "0"; objGear.Cost3 = "0"; objGear.Cost6 = "0"; objGear.Cost10 = "0"; _objCharacter.Gear.Add(objGear); } // If this is a Mutant Critter, count up the number of Skill points they start with. if (_objCharacter.MetatypeCategory == "Mutant Critters") { foreach (Skill objSkill in _objCharacter.Skills) _objCharacter.MutantCritterBaseSkills += objSkill.Rating; } // begin priority based character settings // Load the Priority information. XmlDocument objXmlDocumentPriority = XmlManager.Instance.Load(_strPrioritiesXmlFile); // Set the character priority selections _objCharacter.MetatypePriority = cboHeritage.Text.ToString(); _objCharacter.AttributesPriority = cboAttributes.Text.ToString(); _objCharacter.SpecialPriority = cboTalent.Text.ToString(); _objCharacter.SkillsPriority = cboSkills.Text.ToString(); _objCharacter.ResourcesPriority = cboResources.Text.ToString(); // Set starting nuyen XmlNodeList objXmResourceList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Resources\" and gameplayoption = \"" + _objCharacter.GameplayOption + "\" and value = \"" + cboResources.SelectedValue + "\"]"); if (objXmResourceList.Count > 0) { _objCharacter.Nuyen = Convert.ToInt32(objXmResourceList[0]["resources"].InnerText.ToString()); _objCharacter.StartingNuyen = _objCharacter.Nuyen; } // Set starting positive qualities foreach (XmlNode objXmlQualityItem in objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Talent\" and value = \"" + cboTalent.SelectedValue + "\"]/talents/talent[value = \"" + cboTalents.SelectedValue + "\"]/qualities/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); _objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in objWeapons) _objCharacter.Weapons.Add(objWeapon); } // Set starting magic XmlNodeList objXmlTalentList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Talent\" and value = \"" + cboTalent.SelectedValue + "\"]/talents/talent[value = \"" + cboTalents.SelectedValue + "\"]"); if (objXmlTalentList[0]["magic"] != null) { _objCharacter.MAG.Value = Convert.ToInt32(objXmlTalentList[0]["magic"].InnerText); _objCharacter.MAG.MetatypeMinimum = Convert.ToInt32(objXmlTalentList[0]["magic"].InnerText); if (_objCharacter.MAG.Value > 0) _objCharacter.MAGEnabled = true; if (objXmlTalentList[0]["spells"] != null) { _objCharacter.SpellLimit = Convert.ToInt32(objXmlTalentList[0]["spells"].InnerText); } else { _objCharacter.SpellLimit = 0; } } if (objXmlTalentList[0]["maxmagic"] != null) _objCharacter.MAG.MetatypeMaximum = Convert.ToInt32(objXmlTalentList[0]["magic"].InnerText); // Set starting resonance objXmlTalentList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Talent\" and value = \"" + cboTalent.SelectedValue + "\"]/talents/talent[value = \"" + cboTalents.SelectedValue + "\"]"); if (objXmlTalentList[0]["resonance"] != null) { _objCharacter.RES.Value = Convert.ToInt32(objXmlTalentList[0]["resonance"].InnerText); _objCharacter.RES.MetatypeMinimum = Convert.ToInt32(objXmlTalentList[0]["resonance"].InnerText); _objCharacter.RESEnabled = true; _objCharacter.CFPLimit = Convert.ToInt32(objXmlTalentList[0]["cfp"].InnerText); } if (objXmlTalentList[0]["maxresonance"] != null) _objCharacter.RES.MetatypeMaximum = Convert.ToInt32(objXmlTalentList[0]["resonance"].InnerText); // Set starting talent tabs switch (cboTalents.SelectedValue.ToString()) { case "Magician": _objCharacter.MagicianEnabled = true; break; case "Aspected Magician": _objCharacter.MagicianEnabled = true; break; case "Adept": _objCharacter.AdeptEnabled = true; break; case "Mystic Adept": _objCharacter.MagicianEnabled = true; _objCharacter.AdeptEnabled = true; break; case "Technomancer": _objCharacter.TechnomancerEnabled = true; break; default: break; } // Set Free Skills/Skill Groups int intFreeLevels = 0; bool blnGroup = (cboTalents.SelectedValue.ToString() == "Aspected Magician"); if (cboTalent.SelectedValue.ToString() == "A") intFreeLevels = 5; else if (cboTalent.SelectedValue.ToString() == "B") intFreeLevels = 4; else if (cboTalent.SelectedValue.ToString() == "C") intFreeLevels = 2; foreach (Skill objSkill in _objCharacter.Skills) { if (cboSkill1.Visible && objSkill.Name == cboSkill1.Text && !blnGroup) { objSkill.FreeLevels = intFreeLevels; if (objSkill.Rating < intFreeLevels) objSkill.Rating = intFreeLevels; _objCharacter.PriorityBonusSkill1 = cboSkill1.Text.ToString(); } else if (cboSkill2.Visible && objSkill.Name == cboSkill2.Text && !blnGroup) { objSkill.FreeLevels = intFreeLevels; if (objSkill.Rating < intFreeLevels) objSkill.Rating = intFreeLevels; _objCharacter.PriorityBonusSkill2 = cboSkill2.Text.ToString(); } else { objSkill.FreeLevels = 0; if (blnGroup) { // if this skill is a magical skill not belonging to the selected group, reduce the skill maximum to 0 if (objSkill.SkillGroup == "Conjuring" || objSkill.SkillGroup == "Enchanting" || objSkill.SkillGroup == "Sorcery") { if (objSkill.SkillGroup != cboSkill1.SelectedValue.ToString()) objSkill.RatingMaximum = 0; else { if (_objCharacter.IgnoreRules) objSkill.RatingMaximum = 12; else objSkill.RatingMaximum = 6; } _objCharacter.PriorityBonusSkillGroup = cboSkill1.Text.ToString(); } } } } foreach (SkillGroup objSkillGroup in _objCharacter.SkillGroups) { if (cboSkill1.Visible && objSkillGroup.Name == cboSkill1.Text && blnGroup) { objSkillGroup.FreeLevels = intFreeLevels; if (objSkillGroup.Base < intFreeLevels) objSkillGroup.Base = intFreeLevels; _objCharacter.PriorityBonusSkillGroup = cboSkill1.Text.ToString(); } else objSkillGroup.FreeLevels = 0; if (blnGroup) { // if this skill is a magical skill not belonging to the selected group, reduce the skill maximum to 0 if (objSkillGroup.Name == "Conjuring" || objSkillGroup.Name == "Enchanting" || objSkillGroup.Name == "Sorcery") { if (objSkillGroup.Name != cboSkill1.SelectedValue.ToString()) objSkillGroup.RatingMaximum = 0; else { if (_objCharacter.IgnoreRules) objSkillGroup.RatingMaximum = 12; else objSkillGroup.RatingMaximum = 6; } } } } // Ignore Rules if (_objCharacter.IgnoreRules) { foreach (Skill objSkill in _objCharacter.Skills) { objSkill.RatingMaximum = 99; } foreach (SkillGroup objSkillGroup in _objCharacter.SkillGroups) { objSkillGroup.RatingMaximum = 99; } } // Set Special Attributes _objCharacter.Special = Convert.ToInt32(lblSpecial.Text); _objCharacter.TotalSpecial = Convert.ToInt32(lblSpecial.Text); // Set Attributes XmlNodeList objXmlPriorityList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Attributes\" and value = \"" + cboAttributes.SelectedValue + "\"]"); if (objXmlPriorityList[0]["attributes"] != null) { _objCharacter.Attributes = Convert.ToInt32(objXmlPriorityList[0]["attributes"].InnerText); _objCharacter.TotalAttributes = _objCharacter.Attributes; } // Set Skills and Skill Groups objXmlPriorityList = objXmlDocumentPriority.SelectNodes("/chummer/priorities/priority[category = \"Skills\" and value = \"" + cboSkills.SelectedValue + "\"]"); if (objXmlPriorityList[0]["skills"] != null) { _objCharacter.SkillPoints = Convert.ToInt32(objXmlPriorityList[0]["skills"].InnerText); _objCharacter.SkillPointsMaximum = _objCharacter.SkillPoints; _objCharacter.SkillGroupPoints = Convert.ToInt32(objXmlPriorityList[0]["skillgroups"].InnerText); _objCharacter.SkillGroupPointsMaximum = _objCharacter.SkillGroupPoints; } // Load the Priority information. XmlNode objXmlGameplayOption = objXmlDocumentPriority.SelectSingleNode("/chummer/gameplayoptions/gameplayoption[name = \"" + _objCharacter.GameplayOption + "\"]"); string strKarma = objXmlGameplayOption["karma"].InnerText; string strNuyen = objXmlGameplayOption["maxnuyen"].InnerText; string strContactMultiplier = objXmlGameplayOption["contactmultiplier"].InnerText; _objCharacter.MaxKarma = Convert.ToInt32(strKarma); _objCharacter.MaxNuyen = Convert.ToInt32(strNuyen); _objCharacter.ContactMultiplier = Convert.ToInt32(strContactMultiplier); // Set free contact points _objCharacter.ContactPoints = _objCharacter.CHA.Value * _objCharacter.ContactMultiplier; // Set starting karma _objCharacter.BuildKarma = _objCharacter.MaxKarma; // Set starting movement rate _objCharacter.Movement = (_objCharacter.AGI.TotalValue * 2).ToString() + "/" + (_objCharacter.AGI.TotalValue * 4).ToString(); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show(LanguageManager.Instance.GetString("Message_Metatype_SelectMetatype"), LanguageManager.Instance.GetString("MessageTitle_Metatype_SelectMetatype"), MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void cmdAddExoticSkill_Click(object sender, EventArgs e) { frmSelectExoticSkill frmPickExoticSkill = new frmSelectExoticSkill(); frmPickExoticSkill.ShowDialog(this); if (frmPickExoticSkill.DialogResult == DialogResult.Cancel) return; XmlDocument objXmlDocument = XmlManager.Instance.Load("skills.xml"); XmlNode nodSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + frmPickExoticSkill.SelectedExoticSkill + "\"]"); int i = panActiveSkills.Controls.Count; Skill objSkill = new Skill(_objCharacter); SkillSpecialization objSkillSpec = new SkillSpecialization(frmPickExoticSkill.SelectedExoticSkillSpecialisation); objSkill.Attribute = nodSkill["attribute"].InnerText; objSkill.Specializations.Add(objSkillSpec); if (_objCharacter.MaxSkillRating > 0) objSkill.RatingMaximum = _objCharacter.MaxSkillRating; SkillControl objSkillControl = new SkillControl(); objSkillControl.SkillObject = objSkill; objSkillControl.Width = 510; // Attach an EventHandler for the RatingChanged and SpecializationChanged Events. objSkillControl.RatingChanged += objActiveSkill_RatingChanged; objSkillControl.SpecializationChanged += objSkill_SpecializationChanged; objSkillControl.SkillKarmaClicked += objSkill_KarmaClicked; objSkillControl.SkillName = frmPickExoticSkill.SelectedExoticSkill; objSkillControl.DiceRollerClicked += objSkill_DiceRollerClicked; objSkillControl.DeleteSkill += objSkill_DeleteExoticSkill; objSkillControl.SkillCategory = nodSkill["category"].InnerText; if (nodSkill["default"].InnerText == "Yes") objSkill.Default = true; else objSkill.Default = false; objSkill.ExoticSkill = true; _objCharacter.Skills.Add(objSkill); objSkillControl.SkillRatingMaximum = 12; // Set the SkillControl's Location since scrolling the Panel causes it to actually change the child Controls' Locations. objSkillControl.Location = new Point(0, objSkillControl.Height * i + panActiveSkills.AutoScrollPosition.Y); panActiveSkills.Controls.Add(objSkillControl); _blnIsDirty = true; UpdateWindowTitle(); }
void TestMetatype(string strFile) { XmlDocument objXmlDocument = XmlManager.Instance.Load(strFile); pgbProgress.Minimum = 0; pgbProgress.Value = 0; pgbProgress.Maximum = objXmlDocument.SelectNodes("/chummer/metatypes/metatype").Count; foreach (XmlNode objXmlMetatype in objXmlDocument.SelectNodes("/chummer/metatypes/metatype")) { pgbProgress.Value++; Application.DoEvents(); objXmlDocument = XmlManager.Instance.Load(strFile); Character _objCharacter = new Character(); ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter); try { int intForce = 0; if (objXmlMetatype["forcecreature"] != null) intForce = 1; // Set Metatype information. if (strFile != "critters.xml" || objXmlMetatype["name"].InnerText == "Ally Spirit") { _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["bodaug"].InnerText, intForce, 0)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["agiaug"].InnerText, intForce, 0)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["reaaug"].InnerText, intForce, 0)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["strmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["straug"].InnerText, intForce, 0)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chamax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["chaaug"].InnerText, intForce, 0)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["intaug"].InnerText, intForce, 0)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["logaug"].InnerText, intForce, 0)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["wilaug"].InnerText, intForce, 0)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["magaug"].InnerText, intForce, 0)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["resaug"].InnerText, intForce, 0)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["edgaug"].InnerText, intForce, 0)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } else { int intMinModifier = -3; if (objXmlMetatype["category"].InnerText == "Mutant Critters") intMinModifier = 0; _objCharacter.BOD.AssignLimits(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 3)); _objCharacter.AGI.AssignLimits(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 3)); _objCharacter.REA.AssignLimits(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 3)); _objCharacter.STR.AssignLimits(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 3)); _objCharacter.CHA.AssignLimits(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 3)); _objCharacter.INT.AssignLimits(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 3)); _objCharacter.LOG.AssignLimits(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 3)); _objCharacter.WIL.AssignLimits(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 3)); _objCharacter.INI.AssignLimits(ExpressionToString(objXmlMetatype["inimin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["iniaug"].InnerText, intForce, 0)); _objCharacter.MAG.AssignLimits(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 3)); _objCharacter.RES.AssignLimits(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 3)); _objCharacter.EDG.AssignLimits(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, intMinModifier), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3), ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 3)); _objCharacter.ESS.AssignLimits(ExpressionToString(objXmlMetatype["essmin"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0), ExpressionToString(objXmlMetatype["essaug"].InnerText, intForce, 0)); } // If we're working with a Critter, set the Attributes to their default values. if (strFile == "critters.xml") { _objCharacter.BOD.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["bodmin"].InnerText, intForce, 0)); _objCharacter.AGI.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["agimin"].InnerText, intForce, 0)); _objCharacter.REA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["reamin"].InnerText, intForce, 0)); _objCharacter.STR.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["strmin"].InnerText, intForce, 0)); _objCharacter.CHA.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["chamin"].InnerText, intForce, 0)); _objCharacter.INT.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["intmin"].InnerText, intForce, 0)); _objCharacter.LOG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["logmin"].InnerText, intForce, 0)); _objCharacter.WIL.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["wilmin"].InnerText, intForce, 0)); _objCharacter.MAG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["magmin"].InnerText, intForce, 0)); _objCharacter.RES.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["resmin"].InnerText, intForce, 0)); _objCharacter.EDG.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["edgmin"].InnerText, intForce, 0)); _objCharacter.ESS.Value = Convert.ToInt32(ExpressionToString(objXmlMetatype["essmax"].InnerText, intForce, 0)); } // Sprites can never have Physical Attributes or WIL. if (objXmlMetatype["name"].InnerText.EndsWith("Sprite")) { _objCharacter.BOD.AssignLimits("0", "0", "0"); _objCharacter.AGI.AssignLimits("0", "0", "0"); _objCharacter.REA.AssignLimits("0", "0", "0"); _objCharacter.STR.AssignLimits("0", "0", "0"); _objCharacter.WIL.AssignLimits("0", "0", "0"); _objCharacter.INI.MetatypeMinimum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); _objCharacter.INI.MetatypeMaximum = Convert.ToInt32(ExpressionToString(objXmlMetatype["inimax"].InnerText, intForce, 0)); } _objCharacter.Metatype = objXmlMetatype["name"].InnerText; _objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText; _objCharacter.Metavariant = ""; _objCharacter.MetatypeBP = 400; if (objXmlMetatype["movement"] != null) _objCharacter.Movement = objXmlMetatype["movement"].InnerText; // Load the Qualities file. XmlDocument objXmlQualityDocument = XmlManager.Instance.Load("qualities.xml"); // Determine if the Metatype has any bonuses. if (objXmlMetatype.InnerXml.Contains("bonus")) objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Metatype, objXmlMetatype["name"].InnerText, objXmlMetatype.SelectSingleNode("bonus"), false, 1, objXmlMetatype["name"].InnerText); // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/positive/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); _objCharacter.Qualities.Add(objQuality); } foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/negative/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objXmlQualityItem.InnerText + "\"]"); TreeNode objNode = new TreeNode(); List<Weapon> objWeapons = new List<Weapon>(); List<TreeNode> objWeaponNodes = new List<TreeNode>(); Quality objQuality = new Quality(_objCharacter); string strForceValue = ""; if (objXmlQualityItem.Attributes["select"] != null) strForceValue = objXmlQualityItem.Attributes["select"].InnerText; QualitySource objSource = new QualitySource(); objSource = QualitySource.Metatype; if (objXmlQualityItem.Attributes["removable"] != null) objSource = QualitySource.MetatypeRemovable; objQuality.Create(objXmlQuality, _objCharacter, objSource, objNode, objWeapons, objWeaponNodes, strForceValue); _objCharacter.Qualities.Add(objQuality); } // Run through the character's Attributes one more time and make sure their value matches their minimum value. if (strFile == "metatypes.xml") { _objCharacter.BOD.Value = _objCharacter.BOD.TotalMinimum; _objCharacter.AGI.Value = _objCharacter.AGI.TotalMinimum; _objCharacter.REA.Value = _objCharacter.REA.TotalMinimum; _objCharacter.STR.Value = _objCharacter.STR.TotalMinimum; _objCharacter.CHA.Value = _objCharacter.CHA.TotalMinimum; _objCharacter.INT.Value = _objCharacter.INT.TotalMinimum; _objCharacter.LOG.Value = _objCharacter.LOG.TotalMinimum; _objCharacter.WIL.Value = _objCharacter.WIL.TotalMinimum; } // Add any Critter Powers the Metatype/Critter should have. XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]"); objXmlDocument = XmlManager.Instance.Load("critterpowers.xml"); foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + objXmlPower.InnerText + "\"]"); TreeNode objNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); string strForcedValue = ""; int intRating = 0; if (objXmlPower.Attributes["rating"] != null) intRating = Convert.ToInt32(objXmlPower.Attributes["rating"].InnerText); if (objXmlPower.Attributes["select"] != null) strForcedValue = objXmlPower.Attributes["select"].InnerText; objPower.Create(objXmlCritterPower, _objCharacter, objNode, intRating, strForcedValue); _objCharacter.CritterPowers.Add(objPower); } // Set the Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/skill")) { if (objXmlSkill.InnerText.Contains("Exotic")) { Skill objExotic = new Skill(_objCharacter); objExotic.ExoticSkill = true; objExotic.Attribute = "AGI"; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objExotic.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)) > 6) objExotic.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); objExotic.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); objExotic.Name = objXmlSkill.InnerText; _objCharacter.Skills.Add(objExotic); } else { foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.Name == objXmlSkill.InnerText) { if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objSkill.Specializations.Add(objSpec); } if (Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)) > 6) objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); break; } } } } // Set the Skill Group Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/group")) { foreach (SkillGroup objSkill in _objCharacter.SkillGroups) { if (objSkill.Name == objXmlSkill.InnerText) { objSkill.RatingMaximum = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); objSkill.Rating = Convert.ToInt32(ExpressionToString(objXmlSkill.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); break; } } } // Set the Knowledge Skill Ratings for the Critter. foreach (XmlNode objXmlSkill in objXmlCritter.SelectNodes("skills/knowledge")) { Skill objKnowledge = new Skill(_objCharacter); objKnowledge.Name = objXmlSkill.InnerText; objKnowledge.KnowledgeSkill = true; if (objXmlSkill.Attributes["spec"] != null) { SkillSpecialization objSpec = new SkillSpecialization(objXmlSkill.Attributes["spec"].InnerText); objKnowledge.Specializations.Add(objSpec); } objKnowledge.SkillCategory = objXmlSkill.Attributes["category"].InnerText; if (Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText) > 6) objKnowledge.RatingMaximum = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); objKnowledge.Rating = Convert.ToInt32(objXmlSkill.Attributes["rating"].InnerText); _objCharacter.Skills.Add(objKnowledge); } // If this is a Critter with a Force (which dictates their Skill Rating/Maximum Skill Rating), set their Skill Rating Maximums. if (intForce > 0) { int intMaxRating = intForce; // Determine the highest Skill Rating the Critter has. foreach (Skill objSkill in _objCharacter.Skills) { if (objSkill.RatingMaximum > intMaxRating) intMaxRating = objSkill.RatingMaximum; } // Now that we know the upper limit, set all of the Skill Rating Maximums to match. foreach (Skill objSkill in _objCharacter.Skills) objSkill.RatingMaximum = intMaxRating; foreach (SkillGroup objGroup in _objCharacter.SkillGroups) objGroup.RatingMaximum = intMaxRating; // Set the MaxSkillRating for the character so it can be used later when they add new Knowledge Skills or Exotic Skills. _objCharacter.MaxSkillRating = intMaxRating; } // Add any Complex Forms the Critter comes with (typically Sprites) XmlDocument objXmlProgramDocument = XmlManager.Instance.Load("complexforms.xml"); foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform")) { int intRating = 0; if (objXmlComplexForm.Attributes["rating"] != null) intRating = Convert.ToInt32(ExpressionToString(objXmlComplexForm.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); string strForceValue = ""; if (objXmlComplexForm.Attributes["select"] != null) strForceValue = objXmlComplexForm.Attributes["select"].InnerText; XmlNode objXmlProgram = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = \"" + objXmlComplexForm.InnerText + "\"]"); TreeNode objNode = new TreeNode(); ComplexForm objProgram = new ComplexForm(_objCharacter); objProgram.Create(objXmlProgram, _objCharacter, objNode, strForceValue); _objCharacter.ComplexForms.Add(objProgram); } // Add any Gear the Critter comes with (typically Programs for A.I.s) XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml"); foreach (XmlNode objXmlGear in objXmlCritter.SelectNodes("gears/gear")) { int intRating = 0; if (objXmlGear.Attributes["rating"] != null) intRating = Convert.ToInt32(ExpressionToString(objXmlGear.Attributes["rating"].InnerText, Convert.ToInt32(intForce), 0)); string strForceValue = ""; if (objXmlGear.Attributes["select"] != null) strForceValue = objXmlGear.Attributes["select"].InnerText; XmlNode objXmlGearItem = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlGear.InnerText + "\"]"); TreeNode objNode = new TreeNode(); Gear objGear = new Gear(_objCharacter); List<Weapon> lstWeapons = new List<Weapon>(); List<TreeNode> lstWeaponNodes = new List<TreeNode>(); objGear.Create(objXmlGearItem, _objCharacter, objNode, intRating, lstWeapons, lstWeaponNodes, strForceValue); objGear.Cost = "0"; objGear.Cost3 = "0"; objGear.Cost6 = "0"; objGear.Cost10 = "0"; _objCharacter.Gear.Add(objGear); } // If this is a Mutant Critter, count up the number of Skill points they start with. if (_objCharacter.MetatypeCategory == "Mutant Critters") { foreach (Skill objSkill in _objCharacter.Skills) _objCharacter.MutantCritterBaseSkills += objSkill.Rating; } } catch { txtOutput.Text += _objCharacter.Metatype + " general failure\n"; } } }