From decfead82367a8097173b1266bcedd18b151a50e Mon Sep 17 00:00:00 2001 From: cadon Date: Mon, 6 May 2024 00:19:25 +0200 Subject: [PATCH 1/6] index fix --- ARKBreedingStats/Pedigree/PedigreeCreature.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ARKBreedingStats/Pedigree/PedigreeCreature.cs b/ARKBreedingStats/Pedigree/PedigreeCreature.cs index d8e804e6..9afaae91 100644 --- a/ARKBreedingStats/Pedigree/PedigreeCreature.cs +++ b/ARKBreedingStats/Pedigree/PedigreeCreature.cs @@ -237,7 +237,7 @@ public Creature Creature + $"{_creature.valuesBreeding[si] * (Utils.Precision(si) == 3 ? 100 : 1),7:#,0.0}" + (Utils.Precision(si) == 3 ? "%" : string.Empty) + (_creature.levelsMutated == null ? string.Empty - : Environment.NewLine + Loc.S("Mutations") + ": " + _creature.levelsMutated[s] + : Environment.NewLine + Loc.S("Mutations") + ": " + _creature.levelsMutated[si] )); } // fonts are strange, and this seems to work. The assigned font-object is probably only used to read out the properties and then not used anymore. From 2c0a229968f27635698d64f59c16cea97cca4114 Mon Sep 17 00:00:00 2001 From: cadon Date: Mon, 6 May 2024 19:20:22 +0200 Subject: [PATCH 2/6] update inheritance after changing mutation levels --- ARKBreedingStats/CreatureInfoInput.cs | 6 +++++- ARKBreedingStats/Form1.cs | 1 - ARKBreedingStats/Form1.extractor.cs | 17 ++++++++++++++--- ARKBreedingStats/Form1.tester.cs | 1 - 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ARKBreedingStats/CreatureInfoInput.cs b/ARKBreedingStats/CreatureInfoInput.cs index 1264e104..e79b2b15 100644 --- a/ARKBreedingStats/CreatureInfoInput.cs +++ b/ARKBreedingStats/CreatureInfoInput.cs @@ -124,6 +124,10 @@ private void UpdateRegionColorImage() PbColorRegion?.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies, regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex)); } + /// + /// Update the creatures displayed on the inheritance control with possible stat inheritances and mutations. + /// + /// internal void UpdateParentInheritances(Creature creature) { if (ParentInheritance == null) return; @@ -854,7 +858,7 @@ internal void Clear(bool keepGeneralInfo = false) ClearColors(); SetRegionColorsExisting(); CreatureGuid = Guid.Empty; - SetArkId(0,false); + SetArkId(0, false); if (!keepGeneralInfo) { textBoxOwner.Clear(); diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index b2e05162..994021c0 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -3163,7 +3163,6 @@ private Creature CreateCreatureFromExtractorOrTester(CreatureInfoInput input) cr.isBred = rbBredExtractor.Checked; for (int s = 0; s < Stats.StatsCount; s++) cr.SetTopStat(s, _statIOs[s].TopLevel.HasFlag(LevelStatusFlags.LevelStatus.TopLevel) || _statIOs[s].TopLevel.HasFlag(LevelStatusFlags.LevelStatus.NewTopLevel)); - } else { diff --git a/ARKBreedingStats/Form1.extractor.cs b/ARKBreedingStats/Form1.extractor.cs index a13f2c43..128fffce 100644 --- a/ARKBreedingStats/Form1.extractor.cs +++ b/ARKBreedingStats/Form1.extractor.cs @@ -1077,7 +1077,6 @@ void SetExistingValueIfNewValueIsEmpty(ref string newValue, ref string oldValue) ExtractLevels(autoExtraction, highPrecisionValues, existingCreature: alreadyExistingCreature, possiblyMutagenApplied: cv.flags.HasFlag(CreatureFlags.MutagenApplied)); UpdateMutationLevels(cv, alreadyExistingCreature); - SetCreatureValuesToInfoInput(cv, creatureInfoInputExtractor); UpdateParentListInput(creatureInfoInputExtractor); // this function is only used for single-creature extractions, e.g. LastExport creatureInfoInputExtractor.AlreadyExistingCreature = alreadyExistingCreature; @@ -1086,8 +1085,13 @@ void SetExistingValueIfNewValueIsEmpty(ref string newValue, ref string oldValue) return creatureExists; } - private void UpdateMutationLevels(CreatureValues cv, Creature alreadyExistingCreature) + /// + /// Tries to determine mutation levels, i.e. separate wild and mutation levels, depending on the ancestry information. + /// + /// True if mutation levels where adjusted, false if no levels were moved. + private bool UpdateMutationLevels(CreatureValues cv, Creature alreadyExistingCreature) { + bool mutationLevelsAdjusted = false; // Do we have enough information to assume the mutation counts are accurate bool AreMutationCountsAccurate(Creature creature) { @@ -1116,6 +1120,7 @@ bool AreMutationLevelsAccurate(Creature creature) { _statIOs[s].LevelMut = mutationLevels; _statIOs[s].LevelWild -= mutationLevels; + mutationLevelsAdjusted = true; } } } @@ -1212,6 +1217,7 @@ bool AreMutationLevelsAccurate(Creature creature) statIo.LevelMut = levels.mutated; statIo.Status = StatIOStatus.Neutral; } + mutationLevelsAdjusted = true; } else { @@ -1239,9 +1245,12 @@ bool AreMutationLevelsAccurate(Creature creature) statIo.LevelMut = levels.mutated; statIo.Status = StatIOStatus.Neutral; } + mutationLevelsAdjusted = true; } } } + + return mutationLevelsAdjusted; } /// @@ -1497,7 +1506,9 @@ private void LbBlueprintPath_Click(object sender, EventArgs e) private void ExtractorStatLevelChanged(StatIO _) { - radarChartExtractor.SetLevels(_statIOs.Select(s => s.LevelWild).ToArray(), _statIOs.Select(s => s.LevelMut).ToArray(), speciesSelector1.SelectedSpecies); + var cr = CreateCreatureFromExtractorOrTester(creatureInfoInputExtractor); + radarChartExtractor.SetLevels(cr.levelsWild, cr.levelsMutated, cr.Species); + creatureInfoInputExtractor.UpdateParentInheritances(cr); } #region OCR label sets diff --git a/ARKBreedingStats/Form1.tester.cs b/ARKBreedingStats/Form1.tester.cs index 926022d9..5ec22a1b 100644 --- a/ARKBreedingStats/Form1.tester.cs +++ b/ARKBreedingStats/Form1.tester.cs @@ -298,7 +298,6 @@ private void SetCreatureValuesLevelsAndInfoToExtractor(Creature c) creatureInfoInputExtractor.SetArkId(c.ArkId, c.ArkIdImported); SetCreatureLevelsToExtractor(c); SetAllExtractorLevelsToStatus(StatIOStatus.Unique); - UpdateParentListInput(creatureInfoInputExtractor); creatureInfoInputExtractor.AlreadyExistingCreature = alreadyExistingCreature; UpdateStatusInfoOfExtractorCreature(); UpdateAddToLibraryButtonAccordingToExtractorValidity(true); From 0f25178fd5b5c0ea5c2e46bb1f9e207de4111751 Mon Sep 17 00:00:00 2001 From: cadon Date: Mon, 6 May 2024 19:27:28 +0200 Subject: [PATCH 3/6] option to not determine mutation levels (and leave all levels in wild) --- ARKBreedingStats/App.config | 3 + ARKBreedingStats/Form1.extractor.cs | 1 + .../Properties/Settings.Designer.cs | 12 ++++ ARKBreedingStats/Properties/Settings.settings | 3 + .../settings/Settings.Designer.cs | 55 ++++++++++++------- ARKBreedingStats/settings/Settings.cs | 2 + 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/ARKBreedingStats/App.config b/ARKBreedingStats/App.config index 0cb1d070..7a0b2ac4 100644 --- a/ARKBreedingStats/App.config +++ b/ARKBreedingStats/App.config @@ -535,6 +535,9 @@ False + + True + diff --git a/ARKBreedingStats/Form1.extractor.cs b/ARKBreedingStats/Form1.extractor.cs index 128fffce..a5ef4d7c 100644 --- a/ARKBreedingStats/Form1.extractor.cs +++ b/ARKBreedingStats/Form1.extractor.cs @@ -1091,6 +1091,7 @@ void SetExistingValueIfNewValueIsEmpty(ref string newValue, ref string oldValue) /// True if mutation levels where adjusted, false if no levels were moved. private bool UpdateMutationLevels(CreatureValues cv, Creature alreadyExistingCreature) { + if (!Properties.Settings.Default.MoveMutationLevelsOnExtractionIfUnique) return false; bool mutationLevelsAdjusted = false; // Do we have enough information to assume the mutation counts are accurate bool AreMutationCountsAccurate(Creature creature) diff --git a/ARKBreedingStats/Properties/Settings.Designer.cs b/ARKBreedingStats/Properties/Settings.Designer.cs index 8f55f315..07c49b4c 100644 --- a/ARKBreedingStats/Properties/Settings.Designer.cs +++ b/ARKBreedingStats/Properties/Settings.Designer.cs @@ -2397,5 +2397,17 @@ public bool CopyNameToClipboardOnImport { this["CopyNameToClipboardOnImport"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool MoveMutationLevelsOnExtractionIfUnique { + get { + return ((bool)(this["MoveMutationLevelsOnExtractionIfUnique"])); + } + set { + this["MoveMutationLevelsOnExtractionIfUnique"] = value; + } + } } } diff --git a/ARKBreedingStats/Properties/Settings.settings b/ARKBreedingStats/Properties/Settings.settings index 395d7ba6..adca4e73 100644 --- a/ARKBreedingStats/Properties/Settings.settings +++ b/ARKBreedingStats/Properties/Settings.settings @@ -602,5 +602,8 @@ False + + True + \ No newline at end of file diff --git a/ARKBreedingStats/settings/Settings.Designer.cs b/ARKBreedingStats/settings/Settings.Designer.cs index 1907c539..991dc4cd 100644 --- a/ARKBreedingStats/settings/Settings.Designer.cs +++ b/ARKBreedingStats/settings/Settings.Designer.cs @@ -282,6 +282,7 @@ private void InitializeComponent() this.label28 = new System.Windows.Forms.Label(); this.cbAutoImportExported = new System.Windows.Forms.CheckBox(); this.groupBox21 = new System.Windows.Forms.GroupBox(); + this.CbCopyNameToClipboardOnImport = new System.Windows.Forms.CheckBox(); this.CbApplyNamingPatternOnImportAlways = new System.Windows.Forms.CheckBox(); this.cbApplyNamePatternOnImportOnNewCreatures = new System.Windows.Forms.CheckBox(); this.label41 = new System.Windows.Forms.Label(); @@ -372,7 +373,7 @@ private void InitializeComponent() this.panel1 = new System.Windows.Forms.Panel(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.CbCopyNameToClipboardOnImport = new System.Windows.Forms.CheckBox(); + this.CbSetMutationLevelsExtractor = new System.Windows.Forms.CheckBox(); this.groupBoxMultiplier.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudTamedDinoCharacterFoodDrain)).BeginInit(); @@ -1857,10 +1858,11 @@ private void InitializeComponent() // // groupBox7 // + this.groupBox7.Controls.Add(this.CbSetMutationLevelsExtractor); this.groupBox7.Controls.Add(this.checkBoxDisplayHiddenStats); this.groupBox7.Location = new System.Drawing.Point(6, 411); this.groupBox7.Name = "groupBox7"; - this.groupBox7.Size = new System.Drawing.Size(317, 43); + this.groupBox7.Size = new System.Drawing.Size(317, 73); this.groupBox7.TabIndex = 2; this.groupBox7.TabStop = false; this.groupBox7.Text = "Extractor"; @@ -2313,8 +2315,8 @@ private void InitializeComponent() this.tabPageGeneral.Controls.Add(this.groupBox31); this.tabPageGeneral.Controls.Add(this.groupBox30); this.tabPageGeneral.Controls.Add(this.GbImgCacheLocalAppData); - this.tabPageGeneral.Controls.Add(this.groupBox16); this.tabPageGeneral.Controls.Add(this.GbSpecies); + this.tabPageGeneral.Controls.Add(this.groupBox16); this.tabPageGeneral.Controls.Add(this.groupBox26); this.tabPageGeneral.Controls.Add(this.groupBox25); this.tabPageGeneral.Controls.Add(this.groupBox20); @@ -2391,7 +2393,7 @@ private void InitializeComponent() this.groupBox30.Controls.Add(this.ClbExportSpreadsheetFields); this.groupBox30.Location = new System.Drawing.Point(329, 413); this.groupBox30.Name = "groupBox30"; - this.groupBox30.Size = new System.Drawing.Size(413, 246); + this.groupBox30.Size = new System.Drawing.Size(413, 197); this.groupBox30.TabIndex = 13; this.groupBox30.TabStop = false; this.groupBox30.Text = "Info to export for spreadsheet"; @@ -2432,7 +2434,7 @@ private void InitializeComponent() this.ClbExportSpreadsheetFields.FormattingEnabled = true; this.ClbExportSpreadsheetFields.Location = new System.Drawing.Point(36, 42); this.ClbExportSpreadsheetFields.Name = "ClbExportSpreadsheetFields"; - this.ClbExportSpreadsheetFields.Size = new System.Drawing.Size(371, 199); + this.ClbExportSpreadsheetFields.Size = new System.Drawing.Size(371, 139); this.ClbExportSpreadsheetFields.TabIndex = 12; // // GbImgCacheLocalAppData @@ -2498,9 +2500,9 @@ private void InitializeComponent() // this.GbSpecies.Controls.Add(this.LbSpeciesSelectorCountLastUsed); this.GbSpecies.Controls.Add(this.NudSpeciesSelectorCountLastUsed); - this.GbSpecies.Location = new System.Drawing.Point(6, 460); + this.GbSpecies.Location = new System.Drawing.Point(329, 616); this.GbSpecies.Name = "GbSpecies"; - this.GbSpecies.Size = new System.Drawing.Size(317, 43); + this.GbSpecies.Size = new System.Drawing.Size(413, 43); this.GbSpecies.TabIndex = 3; this.GbSpecies.TabStop = false; this.GbSpecies.Text = "Species Selection"; @@ -2517,7 +2519,7 @@ private void InitializeComponent() // NudSpeciesSelectorCountLastUsed // this.NudSpeciesSelectorCountLastUsed.ForeColor = System.Drawing.SystemColors.GrayText; - this.NudSpeciesSelectorCountLastUsed.Location = new System.Drawing.Point(252, 19); + this.NudSpeciesSelectorCountLastUsed.Location = new System.Drawing.Point(350, 19); this.NudSpeciesSelectorCountLastUsed.Name = "NudSpeciesSelectorCountLastUsed"; this.NudSpeciesSelectorCountLastUsed.NeutralNumber = new decimal(new int[] { 0, @@ -2693,7 +2695,7 @@ private void InitializeComponent() this.groupBox9.Controls.Add(this.cbLibraryHighlightTopCreatures); this.groupBox9.Controls.Add(this.cbApplyGlobalSpeciesToLibrary); this.groupBox9.Controls.Add(this.cbCreatureColorsLibrary); - this.groupBox9.Location = new System.Drawing.Point(6, 509); + this.groupBox9.Location = new System.Drawing.Point(6, 490); this.groupBox9.Name = "groupBox9"; this.groupBox9.Size = new System.Drawing.Size(317, 229); this.groupBox9.TabIndex = 4; @@ -3675,6 +3677,16 @@ private void InitializeComponent() this.groupBox21.TabStop = false; this.groupBox21.Text = "Auto naming on import"; // + // CbCopyNameToClipboardOnImport + // + this.CbCopyNameToClipboardOnImport.AutoSize = true; + this.CbCopyNameToClipboardOnImport.Location = new System.Drawing.Point(6, 147); + this.CbCopyNameToClipboardOnImport.Name = "CbCopyNameToClipboardOnImport"; + this.CbCopyNameToClipboardOnImport.Size = new System.Drawing.Size(218, 17); + this.CbCopyNameToClipboardOnImport.TabIndex = 5; + this.CbCopyNameToClipboardOnImport.Text = "Always copy name to clipboard on import"; + this.CbCopyNameToClipboardOnImport.UseVisualStyleBackColor = true; + // // CbApplyNamingPatternOnImportAlways // this.CbApplyNamingPatternOnImportAlways.AutoSize = true; @@ -3954,7 +3966,7 @@ private void InitializeComponent() this.customSCCustom.Location = new System.Drawing.Point(6, 139); this.customSCCustom.Name = "customSCCustom"; this.customSCCustom.Size = new System.Drawing.Size(401, 23); - this.customSCCustom.SoundFile = null; + this.customSCCustom.SoundFile = ""; this.customSCCustom.TabIndex = 4; // // customSCWakeup @@ -3962,7 +3974,7 @@ private void InitializeComponent() this.customSCWakeup.Location = new System.Drawing.Point(6, 81); this.customSCWakeup.Name = "customSCWakeup"; this.customSCWakeup.Size = new System.Drawing.Size(401, 23); - this.customSCWakeup.SoundFile = ""; + this.customSCWakeup.SoundFile = null; this.customSCWakeup.TabIndex = 2; // // customSCBirth @@ -3970,7 +3982,7 @@ private void InitializeComponent() this.customSCBirth.Location = new System.Drawing.Point(6, 110); this.customSCBirth.Name = "customSCBirth"; this.customSCBirth.Size = new System.Drawing.Size(401, 23); - this.customSCBirth.SoundFile = ""; + this.customSCBirth.SoundFile = null; this.customSCBirth.TabIndex = 3; // // customSCStarving @@ -3978,7 +3990,7 @@ private void InitializeComponent() this.customSCStarving.Location = new System.Drawing.Point(6, 52); this.customSCStarving.Name = "customSCStarving"; this.customSCStarving.Size = new System.Drawing.Size(401, 23); - this.customSCStarving.SoundFile = null; + this.customSCStarving.SoundFile = ""; this.customSCStarving.TabIndex = 1; // // label20 @@ -4795,15 +4807,15 @@ private void InitializeComponent() this.panel1.Size = new System.Drawing.Size(758, 30); this.panel1.TabIndex = 12; // - // CbCopyNameToClipboardOnImport + // CbSetMutationLevelsExtractor // - this.CbCopyNameToClipboardOnImport.AutoSize = true; - this.CbCopyNameToClipboardOnImport.Location = new System.Drawing.Point(6, 147); - this.CbCopyNameToClipboardOnImport.Name = "CbCopyNameToClipboardOnImport"; - this.CbCopyNameToClipboardOnImport.Size = new System.Drawing.Size(218, 17); - this.CbCopyNameToClipboardOnImport.TabIndex = 5; - this.CbCopyNameToClipboardOnImport.Text = "Always copy name to clipboard on import"; - this.CbCopyNameToClipboardOnImport.UseVisualStyleBackColor = true; + this.CbSetMutationLevelsExtractor.AutoSize = true; + this.CbSetMutationLevelsExtractor.Location = new System.Drawing.Point(13, 42); + this.CbSetMutationLevelsExtractor.Name = "CbSetMutationLevelsExtractor"; + this.CbSetMutationLevelsExtractor.Size = new System.Drawing.Size(309, 17); + this.CbSetMutationLevelsExtractor.TabIndex = 1; + this.CbSetMutationLevelsExtractor.Text = "Set mutation levels if they can be determined uniquely (ASA)"; + this.CbSetMutationLevelsExtractor.UseVisualStyleBackColor = true; // // Settings // @@ -5323,5 +5335,6 @@ private void InitializeComponent() private uiControls.Nud nudOverlayInfoHeight; private uiControls.Nud nudOverlayInfoWidth; private System.Windows.Forms.CheckBox CbCopyNameToClipboardOnImport; + private System.Windows.Forms.CheckBox CbSetMutationLevelsExtractor; } } \ No newline at end of file diff --git a/ARKBreedingStats/settings/Settings.cs b/ARKBreedingStats/settings/Settings.cs index c06fdcf6..f88bb355 100644 --- a/ARKBreedingStats/settings/Settings.cs +++ b/ARKBreedingStats/settings/Settings.cs @@ -284,6 +284,7 @@ private void LoadSettings(CreatureCollection cc) else radioButtonFahrenheit.Checked = true; cbIgnoreSexInBreedingPlan.Checked = Properties.Settings.Default.IgnoreSexInBreedingPlan; checkBoxDisplayHiddenStats.Checked = Properties.Settings.Default.DisplayHiddenStats; + CbSetMutationLevelsExtractor.Checked = Properties.Settings.Default.MoveMutationLevelsOnExtractionIfUnique; CbbAppDefaultFontName.Text = Properties.Settings.Default.DefaultFontName; nudDefaultFontSize.Value = (decimal)Properties.Settings.Default.DefaultFontSize; @@ -568,6 +569,7 @@ private void SaveSettings() Properties.Settings.Default.SpeechRecognition = chkbSpeechRecognition.Checked; Properties.Settings.Default.celsius = radioButtonCelsius.Checked; Properties.Settings.Default.DisplayHiddenStats = checkBoxDisplayHiddenStats.Checked; + Properties.Settings.Default.MoveMutationLevelsOnExtractionIfUnique = CbSetMutationLevelsExtractor.Checked; Properties.Settings.Default.DefaultFontName = CbbAppDefaultFontName.Text; Properties.Settings.Default.DefaultFontSize = (float)nudDefaultFontSize.Value; From 3d7e25264b758c8db415adcb1926b0b22b51a1bf Mon Sep 17 00:00:00 2001 From: cadon Date: Mon, 6 May 2024 21:07:35 +0200 Subject: [PATCH 4/6] consider mutationLevels when determining possible inheritance --- ARKBreedingStats/Pedigree/PedigreeCreation.cs | 162 ++++++++++++++++-- 1 file changed, 144 insertions(+), 18 deletions(-) diff --git a/ARKBreedingStats/Pedigree/PedigreeCreation.cs b/ARKBreedingStats/Pedigree/PedigreeCreation.cs index 0d5756a2..bfaace5d 100644 --- a/ARKBreedingStats/Pedigree/PedigreeCreation.cs +++ b/ARKBreedingStats/Pedigree/PedigreeCreation.cs @@ -307,42 +307,168 @@ internal static void CreateGeneInheritanceLines(Creature offspring, Creature mot { int si = PedigreeCreature.DisplayedStats[s]; if (offspring.valuesDom[si] <= 0) continue; // don't display arrows for non used stats + + var levelMother = mother?.levelsWild[si] ?? -1; + var levelFather = father?.levelsWild[si] ?? -1; + var levelMotherMutated = mother?.levelsMutated?[si] ?? -1; + var levelFatherMutated = father?.levelsMutated?[si] ?? -1; + var levelOffspring = offspring.levelsWild[si]; + var levelOffspringMutated = offspring.levelsMutated?[si] ?? -1; + int better = 0; // if father < mother: 1, if mother < father: -1 - if (mother?.levelsWild != null && father?.levelsWild != null) + if (levelMother != -1 && levelFather != -1) { - if (mother.levelsWild[si] < father.levelsWild[si]) + if (levelMother < levelFather) better = -1; - else if (mother.levelsWild[si] > father.levelsWild[si]) + else if (levelMother > levelFather) better = 1; } - // offspring can have stats that are up to 2 levels higher due to mutations. currently there are no decreasing levels due to mutations - if (mother?.levelsWild != null && offspring.levelsWild[si] >= 0 && - (offspring.levelsWild[si] == mother.levelsWild[si] || - offspring.levelsWild[si] == mother.levelsWild[si] + 2)) + // offspring can have stats that are 2, 4 or 6 levels higher due to mutations. currently there are no decreasing levels due to mutations + bool motherInheritancePossible = false; + bool fatherInheritancePossible = false; + bool motherInheritanceWithMutationPossible = false; + bool fatherInheritanceWithMutationPossible = false; + + if (levelOffspringMutated == -1 || levelMotherMutated == -1 || levelFatherMutated == -1) + { + // ASE mutation mechanic, i.e. offspring has 0, 2, 4 or 6 levels more than one parent + for (int m = 0; m <= Ark.MutationRolls; m++) + { + if (levelOffspring == levelMother + Ark.LevelsAddedPerMutation * m) + { + motherInheritancePossible = true; + if (m > 0) + motherInheritanceWithMutationPossible = true; + } + if (levelOffspring == levelFather + Ark.LevelsAddedPerMutation * m) + { + fatherInheritancePossible = true; + if (m > 0) + fatherInheritanceWithMutationPossible = true; + } + } + } + else + { + // ASA mutation mechanic, i.e. mutations are saved separately and inheritance combines higher wild and higher mutation level + int higherWildLevel, lowerWildLevel, higherMutLevel, lowerMutLevel; + LevelInheritedFrom higherWildLevelFrom = LevelInheritedFrom.None; + LevelInheritedFrom higherMutationLevelFrom = LevelInheritedFrom.None; + if (levelMother > levelFather) + { + higherWildLevel = levelMother; + lowerWildLevel = levelFather; + higherWildLevelFrom = LevelInheritedFrom.Mother; + } + else + { + higherWildLevel = levelFather; + lowerWildLevel = levelMother; + if (levelMother < levelFather) + higherWildLevelFrom = LevelInheritedFrom.Father; + } + + if (levelMotherMutated > levelFatherMutated) + { + higherMutLevel = levelMotherMutated; + lowerMutLevel = levelFatherMutated; + higherMutationLevelFrom = LevelInheritedFrom.Mother; + } + else + { + higherMutLevel = levelFatherMutated; + lowerMutLevel = levelMotherMutated; + if (levelMotherMutated < levelFatherMutated) + higherMutationLevelFrom = LevelInheritedFrom.Father; + } + + var higherInheritancePossible = false; + var lowerInheritancePossible = false; + var higherMutationInheritancePossible = false; + var lowerMutationInheritancePossible = false; + + for (int m = 0; m <= Ark.MutationRolls; m++) + { + if (levelOffspring == higherWildLevel + && levelOffspringMutated == higherMutLevel + Ark.LevelsAddedPerMutation * m) + { + higherInheritancePossible = true; + if (m > 0) + higherMutationInheritancePossible = true; + } + else if (levelOffspring == lowerWildLevel + && levelOffspringMutated == lowerMutLevel + Ark.LevelsAddedPerMutation * m) + { + lowerInheritancePossible = true; + if (m > 0) + lowerMutationInheritancePossible = true; + } + } + + if (higherInheritancePossible) + { + if (higherWildLevelFrom != LevelInheritedFrom.Father) + motherInheritancePossible = true; + if (higherWildLevelFrom != LevelInheritedFrom.Mother) + fatherInheritancePossible = true; + if (higherMutationInheritancePossible) + { + if (higherMutationLevelFrom != LevelInheritedFrom.Father) + motherInheritanceWithMutationPossible = true; + if (higherMutationLevelFrom != LevelInheritedFrom.Mother) + fatherInheritanceWithMutationPossible = true; + } + } + + if (lowerInheritancePossible) + { + if (higherWildLevelFrom == LevelInheritedFrom.Father) + motherInheritancePossible = true; + if (higherWildLevelFrom == LevelInheritedFrom.Mother) + fatherInheritancePossible = true; + if (lowerMutationInheritancePossible) + { + if (higherMutationLevelFrom == LevelInheritedFrom.Father) + motherInheritanceWithMutationPossible = true; + if (higherMutationLevelFrom == LevelInheritedFrom.Mother) + fatherInheritanceWithMutationPossible = true; + } + } + } + + if (motherInheritancePossible) { lines[0].Add(new[] { - PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 33, - PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 42, (better == -1 ? 1 : 2), - (offspring.levelsWild[si] > mother.levelsWild[si] ? 1 : 0) - }); + PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 33, + PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 42, better == -1 ? 1 : 2, + motherInheritanceWithMutationPossible ? 1 : 0 + }); } - if (father?.levelsWild != null && offspring.levelsWild[si] >= 0 && - (offspring.levelsWild[si] == father.levelsWild[si] || - offspring.levelsWild[si] == father.levelsWild[si] + 2)) + if (fatherInheritancePossible) { lines[0].Add(new[] { - PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 83, - PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 74, (better == 1 ? 1 : 2), - (offspring.levelsWild[si] > father.levelsWild[si] ? 1 : 0) - }); + PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 83, + PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 74, better == 1 ? 1 : 2, + fatherInheritanceWithMutationPossible ? 1 : 0 + }); } } } + /// + /// Indicates from which parent the level was inherited. + /// + private enum LevelInheritedFrom + { + None, + Mother, + Father + } + #endregion } } From 10a431753be6f85d7eb21dfe8508678de4f1a340 Mon Sep 17 00:00:00 2001 From: cadon Date: Thu, 9 May 2024 11:25:33 +0200 Subject: [PATCH 5/6] support blueprint remap from mod files --- ARKBreedingStats/values/Values.cs | 10 +++++++++- ARKBreedingStats/values/ValuesFile.cs | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ARKBreedingStats/values/Values.cs b/ARKBreedingStats/values/Values.cs index 181ac810..ed9be196 100644 --- a/ARKBreedingStats/values/Values.cs +++ b/ARKBreedingStats/values/Values.cs @@ -254,6 +254,14 @@ public bool LoadModValues(IEnumerable modFilesToLoad, bool throwExceptio } // mod food data TODO + + // add blueprint remaps of mod file + if (modValues.BlueprintRemapping != null && modValues.BlueprintRemapping.Count > 0) + { + if (BlueprintRemapping == null) BlueprintRemapping = new Dictionary(); + foreach (var kv in modValues.BlueprintRemapping) + BlueprintRemapping[kv.Key] = kv.Value; + } } loadedModsHash = CreatureCollection.CalculateModListHash(loadedMods.Where(m => !m.expansion)); @@ -764,7 +772,7 @@ public bool TryGetSpeciesByClassName(string speciesClassName, out Species recogn public Species SpeciesByBlueprint(string blueprintPath) { if (string.IsNullOrEmpty(blueprintPath)) return null; - if (_blueprintRemapping != null && _blueprintRemapping.TryGetValue(blueprintPath, out var realBlueprintPath)) + if (BlueprintRemapping != null && BlueprintRemapping.TryGetValue(blueprintPath, out var realBlueprintPath)) { blueprintPath = realBlueprintPath; } diff --git a/ARKBreedingStats/values/ValuesFile.cs b/ARKBreedingStats/values/ValuesFile.cs index f7e4b5ca..7f1d8010 100644 --- a/ARKBreedingStats/values/ValuesFile.cs +++ b/ARKBreedingStats/values/ValuesFile.cs @@ -20,6 +20,7 @@ protected static bool IsValidFormatVersion(string version) => || version == "1.13" // introduced remaps for blueprintPaths || version == "1.14-flyerspeed" // introduced isFlyer property for AllowFlyerSpeedLeveling || version == "1.15-asa" // for new properties in ARK: Survival Ascended + || version == "1.16-mod-remap" // support for blueprint remap for mod files ); [JsonProperty] @@ -52,7 +53,7 @@ protected static bool IsValidFormatVersion(string version) => /// This is needed if species are remapped ingame, e.g. if a variant is removed. /// [JsonProperty("remaps")] - protected Dictionary _blueprintRemapping; + public Dictionary BlueprintRemapping; /// /// If this represents values for a mod, the mod-infos are found here. From 965bd78df96e321eae0d1175d36e39da0820f426 Mon Sep 17 00:00:00 2001 From: cadon Date: Thu, 9 May 2024 11:57:12 +0200 Subject: [PATCH 6/6] ver --- ARKBreedingStats/Properties/AssemblyInfo.cs | 2 +- ARKBreedingStats/_manifest.json | 2 +- ARKBreedingStats/json/values/ASA-values.json | 107 ++++++++++--------- ARKBreedingStats/json/values/_manifest.json | 4 +- 4 files changed, 59 insertions(+), 56 deletions(-) diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index 73ee5dec..77f82808 100644 --- a/ARKBreedingStats/Properties/AssemblyInfo.cs +++ b/ARKBreedingStats/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ // Revision // [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.61.1.0")] +[assembly: AssemblyFileVersion("0.61.2.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/_manifest.json b/ARKBreedingStats/_manifest.json index d3cb9044..353419d1 100644 --- a/ARKBreedingStats/_manifest.json +++ b/ARKBreedingStats/_manifest.json @@ -4,7 +4,7 @@ "ARK Smart Breeding": { "Id": "ARK Smart Breeding", "Category": "main", - "version": "0.61.1.0" + "version": "0.61.2.0" }, "SpeciesColorImages": { "Id": "SpeciesColorImages", diff --git a/ARKBreedingStats/json/values/ASA-values.json b/ARKBreedingStats/json/values/ASA-values.json index f54c76a7..002834bf 100644 --- a/ARKBreedingStats/json/values/ASA-values.json +++ b/ARKBreedingStats/json/values/ASA-values.json @@ -1,6 +1,6 @@ { - "version": "38.690.452717", - "format": "1.15-asa", + "version": "38.690.452718", + "format": "1.16-mod-remap", "mod": { "id": "ASA", "tag": "", @@ -309,6 +309,55 @@ ], "immobilizedBy": [ "Chain Bola", "Large Bear Trap", "Plant Species Y" ] }, + { + "name": "Gigantoraptor", + "blueprintPath": "/Game/ASA/Dinos/Gigantoraptor/Gigantoraptor_Character_BP.Gigantoraptor_Character_BP", + "skipWildLevelStats": 512, + "fullStatsRaw": [ + [ 770, 0.2, 0.27, 0.5, 0 ], + [ 350, 0.1, 0.1, 0, 0 ], + [ 950, 0.06, 0, 0.5, 0 ], + [ 150, 0.1, 0.1, 0, 0 ], + [ 3000, 0.1, 0.1, 0, 0.15 ], + null, + null, + [ 320, 0.02, 0.04, 0, 0 ], + [ 1, 0.05, 0.1, 0.5, 0.4 ], + [ 1, 0, 0.01, 0, 0 ], + null, + null + ], + "colors": [ + { "name": "Body Main" }, + { "name": "Neck Main" }, + { "name": "Feather Tips" }, + { "name": "Feather Highlights" }, + { "name": "Legs And Beak" }, + { "name": "Feather Pattern" } + ], + "immobilizedBy": [ "Chain Bola", "Large Bear Trap", "Plant Species Y" ], + "breeding": { + "gestationTime": 0, + "incubationTime": 5999.52004, + "eggTempMin": 26, + "eggTempMax": 32, + "maturationTime": 166666.667, + "matingCooldownMin": 64800, + "matingCooldownMax": 172800 + }, + "taming": { + "nonViolent": true, + "violent": false, + "tamingIneffectiveness": 0.06, + "affinityNeeded0": 6800, + "affinityIncreasePL": 160, + "torporDepletionPS0": 2.8333332, + "foodConsumptionBase": 0.002314, + "foodConsumptionMult": 180.0634, + "babyFoodConsumptionMult": 510 + }, + "displayedStats": 927 + }, { "blueprintPath": "/Game/Aberration/Dinos/Basilisk/Basilisk_Character_BP.Basilisk_Character_BP", "skipWildLevelStats": 512 @@ -2378,55 +2427,6 @@ { "blueprintPath": "/Game/ScorchedEarth/Dinos/Wyvern/Wyvern_Character_BP_ZombiePoison.Wyvern_Character_BP_ZombiePoison", "skipWildLevelStats": 512 - }, - { - "name": "Gigantoraptor", - "blueprintPath": "/Gigantoraptor/Gigantoraptor/Gigantoraptor_Character_BP.Gigantoraptor_Character_BP", - "skipWildLevelStats": 512, - "fullStatsRaw": [ - [ 770, 0.2, 0.27, 0.5, 0 ], - [ 350, 0.1, 0.1, 0, 0 ], - [ 950, 0.06, 0, 0.5, 0 ], - [ 150, 0.1, 0.1, 0, 0 ], - [ 3000, 0.1, 0.1, 0, 0.15 ], - null, - null, - [ 320, 0.02, 0.04, 0, 0 ], - [ 1, 0.05, 0.1, 0.5, 0.4 ], - [ 1, 0, 0.01, 0, 0 ], - null, - null - ], - "colors": [ - { "name": "Body Main" }, - { "name": "Neck Main" }, - { "name": "Feather Tips" }, - { "name": "Feather Highlights" }, - { "name": "Legs And Beak" }, - { "name": "Feather Pattern" } - ], - "immobilizedBy": [ "Chain Bola", "Large Bear Trap", "Plant Species Y" ], - "breeding": { - "gestationTime": 0, - "incubationTime": 5999.52004, - "eggTempMin": 26, - "eggTempMax": 32, - "maturationTime": 166666.667, - "matingCooldownMin": 64800, - "matingCooldownMax": 172800 - }, - "taming": { - "nonViolent": true, - "violent": false, - "tamingIneffectiveness": 0.06, - "affinityNeeded0": 6800, - "affinityIncreasePL": 160, - "torporDepletionPS0": 2.8333332, - "foodConsumptionBase": 0.002314, - "foodConsumptionMult": 180.0634, - "babyFoodConsumptionMult": 510 - }, - "displayedStats": 927 } ], "dyeStartIndex": 128, @@ -2561,5 +2561,8 @@ [ "Dusk Coloring", [ 0.274677, 0.076185, 0.376262, 1.0 ] ], [ "Thistle Coloring", [ 0.791298, 0.545725, 0.723055, 1.0 ] ], [ "Bubblegum Coloring", [ 1.0, 0.520996, 0.623961, 1.0 ] ] - ] + ], + "remaps": { + "/Gigantoraptor/Gigantoraptor/Gigantoraptor_Character_BP.Gigantoraptor_Character_BP": "/Game/ASA/Dinos/Gigantoraptor/Gigantoraptor_Character_BP.Gigantoraptor_Character_BP" + } } diff --git a/ARKBreedingStats/json/values/_manifest.json b/ARKBreedingStats/json/values/_manifest.json index a6c4ad3e..9d145e60 100644 --- a/ARKBreedingStats/json/values/_manifest.json +++ b/ARKBreedingStats/json/values/_manifest.json @@ -398,8 +398,8 @@ "mod": { "id": "919470289", "tag": "SSFlyer", "title": "SSFlyer" } }, "ASA-values.json": { - "version": "38.690.452717", - "format": "1.15-asa", + "version": "38.690.452718", + "format": "1.16-mod-remap", "mod": { "id": "ASA", "tag": "", "title": "Ark: Survival Ascended", "shortTitle": "ASA", "official": true } }, "CrystalIsles-CrystalIsles.json": {