Skip to content

Commit

Permalink
fixed issue when imprintingBonus was extracted as less than zero. adj…
Browse files Browse the repository at this point in the history
…usted imprinting-extraction-from-torpor-formula. improved imprinting-extraction by also using the food-stat (only works if food has no dom-levels). fix for non-default imprintingStatScaleMultiplier with partly-imprinted algorithm. fix of memory-leak in OCR configuration. removed sorting out of stats according to TE if creature was bred (this will show better where extraction-issues are caused). re-enabled auto-extraction after reading values with OCR.
  • Loading branch information
cadaei committed Jan 27, 2018
1 parent 38dbbe5 commit 4d84630
Show file tree
Hide file tree
Showing 8 changed files with 693 additions and 676 deletions.
18 changes: 14 additions & 4 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Extraction
public List<int> statsWithEff;
public bool validResults;
public bool postTamed;
private bool bred;
public int[] levelDomFromTorporAndTotalRange = new int[] { 0, 0 }, levelWildFromTorporRange = new int[] { 0, 0 }; // 0: min, 1: max
public int[] lowerBoundWilds, lowerBoundDoms, upperBoundDoms;
public int wildFreeMax = 0, domFreeMin = 0, domFreeMax = 0; // unassigned levels
Expand Down Expand Up @@ -181,6 +182,7 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
imprintingChanged = false;
considerWildLevelSteps = considerWildLevelSteps && !bred;

this.bred = bred;
if (bred)
postTamed = true;
else if (autoDetectTamed && stats[7].AddWhenTamed > 0)
Expand All @@ -200,9 +202,14 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
}
else if (extractImprintingFromTorpor)
{
int wildLevelsFromImprintedTorpor = (int)Math.Round(((statIOs[7].Input / (1 + imprintingBonusRounded * 0.2)) / (1 + stats[7].MultAffinity) - stats[7].AddWhenTamed - stats[7].BaseValue) / (stats[7].IncPerWildLevel * stats[7].BaseValue));
double ttt = Stats.calculateValue(speciesI, 7, wildLevelsFromImprintedTorpor, 0, true, 1, 0);
imprintingBonus = (statIOs[7].Input / Stats.calculateValue(speciesI, 7, wildLevelsFromImprintedTorpor, 0, true, 1, 0) - 1) / (0.2 * imprintingBonusMultiplier);
int wildLevelsFromImprintedTorpor = (int)Math.Round(((((statIOs[7].Input / (1 + stats[7].MultAffinity)) - stats[7].AddWhenTamed) / ((1 + imprintingBonusRounded * 0.2 * imprintingBonusMultiplier) * stats[7].BaseValue)) - 1) / stats[7].IncPerWildLevel);
imprintingBonus = ((statIOs[7].Input / (1 + stats[7].MultAffinity) - stats[7].AddWhenTamed) / Stats.calculateValue(speciesI, 7, wildLevelsFromImprintedTorpor, 0, false, 0, 0) - 1) / (0.2 * imprintingBonusMultiplier);

// assuming food has no dom-levels, extract the exact imprinting from this stat. If the difference is less than 0.01, take this (probably more precise) value for the imprinting. (food has higher values and yields more precise results)
int wildLevelsFromImprintedFood = (int)Math.Round(((((statIOs[3].Input / (1 + stats[3].MultAffinity)) - stats[3].AddWhenTamed) / ((1 + imprintingBonusRounded * 0.2 * imprintingBonusMultiplier) * stats[3].BaseValue)) - 1) / stats[3].IncPerWildLevel);
double imprintingBonusFromFood = ((statIOs[3].Input / (1 + stats[3].MultAffinity) - stats[3].AddWhenTamed) / Stats.calculateValue(speciesI, 3, wildLevelsFromImprintedFood, 0, false, 0, 0) - 1) / (0.2 * imprintingBonusMultiplier);
if (Math.Abs(imprintingBonus - imprintingBonusFromFood) < 0.01)
imprintingBonus = imprintingBonusFromFood;
}
else if (Values.V.species[speciesI].breeding != null && Values.V.species[speciesI].breeding.maturationTimeAdjusted > 0)
{
Expand All @@ -211,6 +218,8 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
}
if (!allowMoreThanHundredImprinting && imprintingBonus > 1)
imprintingBonus = 1;
if (imprintingBonus < 0)
imprintingBonus = 0;
if (Math.Abs(imprintingBonusRounded - imprintingBonus) > 0.01)
imprintingChanged = true;
}
Expand Down Expand Up @@ -427,7 +436,8 @@ public int removeOutOfBoundsResults()
}
}
// if more than one parameter is affected by tamingEffectiveness filter all numbers that occure only in one
if (statsWithEff.Count > 1)
// if creature is bred, all TE is 1 anyway, no need to filter then
if (!bred && statsWithEff.Count > 1)
{
for (int es = 0; es < statsWithEff.Count; es++)
{
Expand Down
1,078 changes: 539 additions & 539 deletions ARKBreedingStats/Form1.Designer.cs

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void Form1_Load(object sender, EventArgs e)
tt.SetToolTip(lblExtractorWildLevel, "Wild levels, which are considered for breeding");
tt.SetToolTip(lblTesterWildLevel, "Wild levels, which are considered for breeding");
tt.SetToolTip(cbGuessSpecies, "If checked, the tool will try to guess the species after reading the values from ARK.\nIf the tool recognizes the species-name it will take that, otherwise it will check if the stat-values match a certain species.\n\nUncheck this if the tool repeatedly selects the wrong species after OCR (you have to choose it manually then).");
tt.SetToolTip(cbExtractImprintingFromTorpor, "Enable this to extract the exact imprinting from the torpor-value instead of the number of cuddles.\nThis should allow the extraction if you raised the creature during an event or if you don't know the matureSpeed- or cuddleIntervalMultiplier.");
tt.SetToolTip(cbExtractImprintingFromTorpor, "Enable this to adjust the entered imprinting-value according to the torpor-value instead of the number of cuddles.\nThis should allow the extraction if you raised the creature during an event or if you don't know the matureSpeed- or cuddleIntervalMultiplier.\nIt could lead to issues with stat-values with high numbers, e.g. food, so use this only if the other method doesn't work.");

// was used to calculate the growing-progress. TODO: remove? (UI doesn't show the current weight anymore)
creatureInfoInputExtractor.weightStat = statIOs[4];
Expand Down Expand Up @@ -3563,6 +3563,10 @@ public void doOCR(string imageFilePath = "", bool manuallyTriggered = true)
}
}
}
else
{
extractLevels();
}

lastOCRValues = OCRvalues;
if (tabControlMain.SelectedTab != TabPageOCR)
Expand Down Expand Up @@ -3695,7 +3699,7 @@ private void chkbToggleOverlay_CheckedChanged(object sender, EventArgs e)

if (p.Length == 0)
{
MessageBox.Show("Process for capturing screenshots and for overlay not found. Start the game or change the process in the settings.");
MessageBox.Show("Process for capturing screenshots and for overlay not found. Start the game or change the process in the settings.", "Game started?", MessageBoxButtons.OK, MessageBoxIcon.Error);
chkbToggleOverlay.Checked = false;
return;
}
Expand Down
Loading

0 comments on commit 4d84630

Please sign in to comment.