Skip to content

Commit

Permalink
fix for imprinting when extracting bred creatures. improved OCR. fixe…
Browse files Browse the repository at this point in the history
…s for overlay.
  • Loading branch information
cadaei committed May 13, 2017
1 parent 1c41cb9 commit 34f6b06
Show file tree
Hide file tree
Showing 20 changed files with 532 additions and 417 deletions.
22 changes: 15 additions & 7 deletions ARKBreedingStats/ARKOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,24 @@ public ARKOverlay()
theOverlay = this;


if (ArkOCR.OCR.currentResolutionW == 0 && !ArkOCR.OCR.setResolution())
MessageBox.Show("Couldn't calibrate for the current resolution, sorry.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (!ArkOCR.OCR.setResolution())
MessageBox.Show("No calibration-info for this resolution found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

labelInfo.Location = new Point(ArkOCR.OCR.currentResolutionW - (labelInfo.Width + 30), 40); ;
labelInfo.Location = new Point(ArkOCR.OCR.ocrConfig.resolutionWidth - (labelInfo.Width + 30), 40);

InfoDuration = 10;
}

public void initLabelPositions()
{
for (int statIndex = 0; statIndex < 8; statIndex++)
{
Rectangle r = ArkOCR.OCR.ocrConfig.labelRectangles[statIndex];
labels[statIndex].Location = this.PointToClient(new Point(r.Left + r.Width + 6, r.Top - 10));
}
lblStatus.Location = new Point(50, 10);
}

void inventoryCheckTimer_Tick(object sender, EventArgs e)
{
if (OCRing == true)
Expand Down Expand Up @@ -103,14 +113,12 @@ public void setStatLevels(float[] wildValues, float[] tamedValues, Color[] color
statIndex = 9; // skip torpor and imprinting, index:9: level
labels[labelIndex].Text = "[w" + wildValues[statIndex];
if (tamedValues[statIndex] != 0)
labels[labelIndex].Text += " + d" + tamedValues[statIndex];
labels[labelIndex].Text += "+d" + tamedValues[statIndex];
labels[labelIndex].Text += "]";
labels[labelIndex].Location = this.PointToClient(ArkOCR.OCR.lastLetterPositions[ArkOCR.OCR.ocrConfig.labelNames[statIndex]]);

if (statIndex < 8)
labels[labelIndex].ForeColor = colors[statIndex];
}
lblStatus.Location = new Point(labels[0].Location.X - 100, 10);
lblExtraText.Location = new Point(labels[0].Location.X - 100, 40);
lblBreedingProgress.Text = "";
}
Expand All @@ -120,7 +128,7 @@ internal void setExtraText(string p)
lblExtraText.Visible = true;
labelInfo.Visible = false;
//Point loc = this.PointToClient(ArkOCR.OCR.lastLetterPositions["NameAndLevel"]);
Point loc = this.PointToClient(new Point(ArkOCR.OCR.ocrConfig.labelRectangles[8].X, ArkOCR.OCR.ocrConfig.labelRectangles[9].Y));
Point loc = this.PointToClient(new Point(ArkOCR.OCR.ocrConfig.labelRectangles[9].X, ArkOCR.OCR.ocrConfig.labelRectangles[9].Y + 30));

loc.Offset(0, 30);

Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<value>10</value>
</setting>
<setting name="OCRWhiteThreshold" serializeAs="String">
<value>155</value>
<value>160</value>
</setting>
<setting name="ocrFile" serializeAs="String">
<value>json/ocr.json</value>
Expand Down
10 changes: 2 additions & 8 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public partial class BreedingPlan : UserControl
public StatWeighting statWeighting;
public bool breedingPlanNeedsUpdate;
public CreatureCollection creatureCollection;
private double matingIntervallMultiplier;
private double incubationSpeedMultiplier;
private double matureSpeedMultiplier;

public BreedingPlan()
{
Expand Down Expand Up @@ -413,7 +410,7 @@ private void setBreedingData(string species = "")
{
string incubationMode;
TimeSpan babyTime, maturationTime, nextMatingMin, nextMatingMax;
if (Raising.getRaisingTimes(speciesIndex, matingIntervallMultiplier, incubationSpeedMultiplier, matureSpeedMultiplier, out incubationMode, out incubationTime, out babyTime, out maturationTime, out nextMatingMin, out nextMatingMax))
if (Raising.getRaisingTimes(speciesIndex, out incubationMode, out incubationTime, out babyTime, out maturationTime, out nextMatingMin, out nextMatingMax))
{
TimeSpan totalTime = incubationTime;
DateTime until = DateTime.Now.Add(totalTime);
Expand Down Expand Up @@ -652,11 +649,8 @@ private void createIncubationEntry(bool startNow = true)
}
}

public void setEvent(bool eventActive)
public void updateBreedingData()
{
matingIntervallMultiplier = eventActive ? creatureCollection.MatingIntervalMultiplier / creatureCollection.MatingIntervalMultiplierEvent : 1;
incubationSpeedMultiplier = eventActive ? creatureCollection.EggHatchSpeedMultiplier / creatureCollection.EggHatchSpeedMultiplierEvent : 1;
matureSpeedMultiplier = eventActive ? creatureCollection.BabyMatureSpeedMultiplier / creatureCollection.BabyMatureSpeedMultiplierEvent : 1;
setBreedingData(currentSpecies);
}

Expand Down
54 changes: 27 additions & 27 deletions ARKBreedingStats/CreatureInfoInput.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void dhmInputGrown_TextChanged(object sender, EventArgs e)
{
updateMaturation = false;
numericUpDownWeight.Value = Values.V.species[speciesIndex].breeding != null && Values.V.species[speciesIndex].breeding.maturationTimeAdjusted > 0 ?
(decimal)(weightStat.Input * dhmInputGrown.Timespan.TotalSeconds / Values.V.species[speciesIndex].breeding.maturationTimeAdjusted) : 0;
(decimal)(weightStat.Input * dhmInputGrown.Timespan.TotalSeconds / Values.V.species[speciesIndex].breeding.maturationTimeAdjusted) : 0; // todo. remove? baby-weight is no more shown?
updateMaturationPercentage();
updateMaturation = true;
}
Expand Down
15 changes: 6 additions & 9 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ public int filterResultsByFixed(int dontFix = -1)
return -1; // -1 is good for this function. A value >=0 means the stat with that index is faulty
}

public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double lowerTEBound, double upperTEBound, bool autoDetectTamed, bool tamed, bool justTamed, bool bred, double imprintingBonusRounded, double imprintingBonusMultiplier, double cuddleIntervalMultiplier, double maturationSpeedMultiplier, bool considerWildLevelSteps, int wildLevelSteps, out bool imprintingChanged)
public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double lowerTEBound, double upperTEBound, bool autoDetectTamed, bool tamed, bool justTamed, bool bred, double imprintingBonusRounded, double imprintingBonusMultiplier, double cuddleIntervalMultiplier, bool considerWildLevelSteps, int wildLevelSteps, out bool imprintingChanged)
{
validResults = true;
imprintingChanged = false;
considerWildLevelSteps = considerWildLevelSteps && !bred;

if (bred)
postTamed = true;
Expand All @@ -180,12 +181,8 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
imprintingBonus = 1;
else if (Values.V.species[speciesI].breeding != null && Values.V.species[speciesI].breeding.maturationTimeAdjusted > 0)
{
double maturationTimeAdjusted;
if (maturationSpeedMultiplier > 0)
maturationTimeAdjusted = Values.V.species[speciesI].breeding.maturationTimeAdjusted / maturationSpeedMultiplier;
else maturationTimeAdjusted = Values.V.species[speciesI].breeding.maturationTimeAdjusted;

imprintingBonus = Math.Round(Math.Round(imprintingBonusRounded * maturationTimeAdjusted / (14400 * cuddleIntervalMultiplier)) * 14400 * cuddleIntervalMultiplier / maturationTimeAdjusted, 5);
imprintingBonus = Math.Round(Math.Round(imprintingBonusRounded * Values.V.species[speciesI].breeding.maturationTimeAdjusted / (14400 * cuddleIntervalMultiplier))
* 14400 * cuddleIntervalMultiplier / Values.V.species[speciesI].breeding.maturationTimeAdjusted, 5);
if (imprintingBonus > 1)
imprintingBonus = 1;
if (Math.Abs(imprintingBonusRounded - imprintingBonus) > 0.01)
Expand Down Expand Up @@ -294,14 +291,14 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
{
if (tamingEffectiveness <= upperTEBound)
{
// test if TE with torpor-level results in a valid wild-level
// test if TE with torpor-level of tamed-creatures results in a valid wild-level
if (considerWildLevelSteps && s != 7 && tamingEffectiveness > 0
&& (int)Math.Ceiling((trueTorporLevel(tamingEffectiveness) + 1) / (1 + tamingEffectiveness / 2)) % wildLevelSteps != 0)
continue;

results[s].Add(new StatResult(w, d, tamingEffectiveness));
}
else { continue; }
else continue;
}
else
{
Expand Down
Loading

0 comments on commit 34f6b06

Please sign in to comment.