Skip to content

Commit

Permalink
fixed extraction of imprinted creatures. added option for overlay to …
Browse files Browse the repository at this point in the history
…not try to extract every inventory. fixed extraction of wild creatures. fixed taming-food for basilisk.
  • Loading branch information
cadaei committed Jan 15, 2018
1 parent 5080969 commit 5d35ef5
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 45 deletions.
12 changes: 11 additions & 1 deletion ARKBreedingStats/ARKOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class ARKOverlay : Form
private DateTime infoShownAt;
public int InfoDuration;
private bool currentlyInInventory;
private bool inventoryCheckTimerEnabled;

public ARKOverlay()
{
Expand Down Expand Up @@ -78,11 +79,20 @@ public void initLabelPositions()
lblStatus.Location = new Point(50, 10);
}

public bool enableInventoryCheckTimer
{
set
{
inventoryCheckTimerEnabled = value;
inventoryCheckTimer.Enabled = value && timerUpdateTimer.Enabled;
}
}

public bool enableOverlayTimers
{
set
{
inventoryCheckTimer.Enabled = value;
inventoryCheckTimer.Enabled = value && inventoryCheckTimerEnabled;
timerUpdateTimer.Enabled = value;
}
}
Expand Down
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<setting name="playAlarmTimes" serializeAs="String">
<value>60,0</value>
</setting>
<setting name="inventoryCheckTimer" serializeAs="String">
<value>True</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
19 changes: 8 additions & 11 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
}
else if (Values.V.species[speciesI].breeding != null && Values.V.species[speciesI].breeding.maturationTimeAdjusted > 0)
{
// imprinting-interval is 8 h = 28800 s
imprintingBonus = Math.Round(Math.Round(imprintingBonusRounded * Values.V.species[speciesI].breeding.maturationTimeAdjusted / (28800 * cuddleIntervalMultiplier))
* 28800 * cuddleIntervalMultiplier / Values.V.species[speciesI].breeding.maturationTimeAdjusted, 5);
double imprintingGainPerCuddle = Utils.imprintingGainPerCuddle(Values.V.species[speciesI].breeding.maturationTimeAdjusted, cuddleIntervalMultiplier);
imprintingBonus = Math.Round(Math.Round(imprintingBonusRounded / imprintingGainPerCuddle) * imprintingGainPerCuddle, 7);
if (imprintingBonus > 1)
imprintingBonus = 1;
if (Math.Abs(imprintingBonusRounded - imprintingBonus) > 0.01)
Expand Down Expand Up @@ -271,8 +270,8 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
{
statIOs[s].postTame = postTamed;
double inputValue = statIOs[s].Input;
double statBaseValueWild = Values.V.species[speciesI].stats[s].BaseValue;
double statBaseValueTamed = statBaseValueWild * (s == 0 ? (double)Values.V.species[speciesI].TamedBaseHealthMultiplier : 1);
double statBaseValue = Values.V.species[speciesI].stats[s].BaseValue;
if (postTamed) statBaseValue *= (s == 0 ? (double)Values.V.species[speciesI].TamedBaseHealthMultiplier : 1);

double tamingEffectiveness = -1;
double valueWODom = 0; // value without domesticated levels
Expand All @@ -292,22 +291,22 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
}
else
multAffinityFactor = 1;
maxLW = Math.Round(((inputValue / multAffinityFactor - (postTamed ? Values.V.species[speciesI].stats[s].AddWhenTamed : 0)) / (postTamed ? statBaseValueTamed : statBaseValueWild) - 1) / Values.V.species[speciesI].stats[s].IncPerWildLevel); // floor is too unprecise
maxLW = Math.Round(((inputValue / multAffinityFactor - (postTamed ? Values.V.species[speciesI].stats[s].AddWhenTamed : 0)) / statBaseValue - 1) / Values.V.species[speciesI].stats[s].IncPerWildLevel); // floor is too unprecise
}
if (s != 7 && maxLW > levelWildFromTorporRange[1]) { maxLW = levelWildFromTorporRange[1]; } // torpor level can be too high right after taming (torpor bug in the game)

double maxLD = 0;
if (!statIOs[s].DomLevelZero && postTamed && Values.V.species[speciesI].stats[s].BaseValue > 0 && Values.V.species[speciesI].stats[s].IncPerTamedLevel > 0)
{
maxLD = Math.Round((inputValue / ((statBaseValueTamed + Values.V.species[speciesI].stats[s].AddWhenTamed) * (1 + lowerTEBound * Values.V.species[speciesI].stats[s].MultAffinity)) - 1) / Values.V.species[speciesI].stats[s].IncPerTamedLevel); //floor is sometimes too unprecise
maxLD = Math.Round((inputValue / ((statBaseValue + Values.V.species[speciesI].stats[s].AddWhenTamed) * (1 + lowerTEBound * Values.V.species[speciesI].stats[s].MultAffinity)) - 1) / Values.V.species[speciesI].stats[s].IncPerTamedLevel); //floor is sometimes too unprecise
}
if (maxLD > domFreeMax) maxLD = domFreeMax;
if (maxLD < 0) maxLD = 0;

for (int w = 0; w < maxLW + 1; w++)
{
// imprinting bonus is applied to all stats except stamina (s==1) and oxygen (s==2) and speed (s==6)
valueWODom = (postTamed ? statBaseValueTamed : statBaseValueWild) * (1 + Values.V.species[speciesI].stats[s].IncPerWildLevel * w) * (s == 1 || s == 2 || (s == 6 && Values.V.species[speciesI].NoImprintingForSpeed == true) ? 1 : imprintingMultiplier) + (postTamed ? Values.V.species[speciesI].stats[s].AddWhenTamed : 0);
valueWODom = statBaseValue * (1 + Values.V.species[speciesI].stats[s].IncPerWildLevel * w) * (s == 1 || s == 2 || (s == 6 && Values.V.species[speciesI].NoImprintingForSpeed == true) ? 1 : imprintingMultiplier) + (postTamed ? Values.V.species[speciesI].stats[s].AddWhenTamed : 0);
for (int d = 0; d < maxLD + 1; d++)
{
if (withTEff)
Expand All @@ -326,8 +325,6 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
if (tamingEffectivenessMin <= upperTEBound)
{
// test if TE with torpor-level of tamed-creatures results in a valid wild-level
double ttttt = trueTorporLevel(tamingEffectiveness);
double ttt = (trueTorporLevel(tamingEffectiveness) + 1) / (1 + tamingEffectiveness / 2);
if (considerWildLevelSteps && s != 7 && tamingEffectiveness > 0)
{
int preTameLevelMin = (int)((trueTorporLevel(tamingEffectiveness) + 1) / (1 + tamingEffectivenessMax / 2));
Expand All @@ -354,7 +351,7 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
break;
}
}
else if (Math.Abs((valueWODom * (1 + Values.V.species[speciesI].stats[s].MultAffinity) * (1 + Values.V.species[speciesI].stats[s].IncPerTamedLevel * d) - inputValue) * (Utils.precision(s) == 3 ? 100 : 1)) < 0.15)
else if (Math.Abs((valueWODom * (postTamed ? 1 + Values.V.species[speciesI].stats[s].MultAffinity : 1) * (1 + Values.V.species[speciesI].stats[s].IncPerTamedLevel * d) - inputValue) * (Utils.precision(s) == 3 ? 100 : 1)) < 0.15)
{
results[s].Add(new StatResult(w, d));
break; // no other solution with this w possible
Expand Down
8 changes: 4 additions & 4 deletions ARKBreedingStats/Form1.Designer.cs

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

47 changes: 33 additions & 14 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private void tellTamingData(string species, int level)
if (sI >= 0 && Values.V.species[sI].taming != null && Values.V.species[sI].taming.eats != null && Values.V.species[sI].taming.eats.Count > 0)
{
comboBoxSpeciesGlobal.SelectedIndex = sI;
tamingControl1.level = level;
tamingControl1.setLevel(level, false);
tamingControl1.setSpeciesIndex(sI);
if (overlay != null)
overlay.setInfoText(species + " (level " + level.ToString() + ")" + ":\n" + tamingControl1.quickTamingInfos);
Expand Down Expand Up @@ -612,10 +612,9 @@ private bool extractLevels(bool autoExtraction = false)

// display taming info
if (checkBoxQuickWildCheck.Checked)
tamingControl1.level = statIOs[7].LevelWild + 1;
tamingControl1.setLevel(statIOs[7].LevelWild + 1);
else
tamingControl1.level = (int)numericUpDownLevel.Value;
tamingControl1.updateTamingData();
tamingControl1.setLevel((int)numericUpDownLevel.Value);
labelTamingInfo.Text = tamingControl1.quickTamingInfos;
groupBoxTamingInfo.Visible = true;
}
Expand Down Expand Up @@ -1209,7 +1208,10 @@ private void applySettingsToValues()
if (speechRecognition != null)
speechRecognition.setMaxLevel(creatureCollection.maxWildLevel);
if (overlay != null)
{
overlay.InfoDuration = Properties.Settings.Default.OverlayInfoDuration;
overlay.enableInventoryCheckTimer = Properties.Settings.Default.inventoryCheckTimer;
}

oxygenForAll = Properties.Settings.Default.oxygenForAll;
ArkOCR.OCR.screenCaptureApplicationName = Properties.Settings.Default.OCRApp;
Expand Down Expand Up @@ -2645,7 +2647,6 @@ private void setCollectionChanged(bool changed, string species = null)
if (autoSave && changed)
{
// save changes automatically
// backup currentFile if older than 5 min
if (currentFileName != "" && autoSaveMinutes > 0 && (DateTime.Now - lastAutoSaveBackup).TotalMinutes > autoSaveMinutes)
{
string filenameWOExt = Path.GetFileNameWithoutExtension(currentFileName);
Expand Down Expand Up @@ -2744,15 +2745,15 @@ private void numericUpDownImprintingBonusTester_ValueChanged(object sender, Even
updateAllTesterValues();
// calculate number of imprintings
if (Values.V.species[speciesIndex].breeding != null && Values.V.species[speciesIndex].breeding.maturationTimeAdjusted > 0)
labelImprintedCount.Text = "(" + Math.Round((double)numericUpDownImprintingBonusTester.Value * Values.V.species[speciesIndex].breeding.maturationTimeAdjusted / (2880000 * Values.V.babyCuddleIntervalMultiplier), 2) + "×)";
labelImprintedCount.Text = "(" + Math.Round((double)numericUpDownImprintingBonusTester.Value / (100 * Utils.imprintingGainPerCuddle(Values.V.species[speciesIndex].breeding.maturationTimeAdjusted, Values.V.babyCuddleIntervalMultiplier)), 2) + "×)";
else labelImprintedCount.Text = "";
}

private void numericUpDownImprintingBonusExtractor_ValueChanged(object sender, EventArgs e)
{
// calculate number of imprintings
if (Values.V.species[speciesIndex].breeding != null && Values.V.species[speciesIndex].breeding.maturationTimeAdjusted > 0)
labelImprintingCuddleCountExtractor.Text = "(" + Math.Round((double)numericUpDownImprintingBonusExtractor.Value * Values.V.species[speciesIndex].breeding.maturationTimeAdjusted / (2880000 * Values.V.babyCuddleIntervalMultiplier)) + "×)";
labelImprintingCuddleCountExtractor.Text = "(" + Math.Round((double)numericUpDownImprintingBonusExtractor.Value / (100 * Utils.imprintingGainPerCuddle(Values.V.species[speciesIndex].breeding.maturationTimeAdjusted, Values.V.babyCuddleIntervalMultiplier))) + "×)";
else labelImprintingCuddleCountExtractor.Text = "";
}

Expand All @@ -2769,13 +2770,25 @@ private void checkBoxQuickWildCheck_CheckedChanged(object sender, EventArgs e)
if (!enabled)
{
clearAll();

for (int s = 0; s < 8; s++)
{
int lvlWild = (int)Math.Round((statIOs[s].Input - Values.V.species[speciesIndex].stats[s].BaseValue) / (Values.V.species[speciesIndex].stats[s].BaseValue * Values.V.species[speciesIndex].stats[s].IncPerWildLevel));
statIOs[s].LevelWild = (lvlWild < 0 ? 0 : lvlWild);
statIOs[s].LevelDom = 0;
}

tamingControl1.setLevel(statIOs[7].LevelWild + 1, false);
tamingControl1.setSpeciesIndex(comboBoxSpeciesGlobal.SelectedIndex);
labelTamingInfo.Text = tamingControl1.quickTamingInfos;
}
toolStripButtonExtract.Enabled = enabled;
panelWildTamedBred.Enabled = enabled;
checkBoxJustTamed.Enabled = enabled;
groupBoxDetailsExtractor.Enabled = enabled;
numericUpDownLevel.Enabled = enabled;
button2TamingCalc.Visible = !enabled;
groupBoxTamingInfo.Visible = !enabled;
}

/// <summary>
Expand Down Expand Up @@ -3341,6 +3354,12 @@ private void statIOQuickWildLevelCheck(StatIO sIO)
int lvlWild = (int)Math.Round((sIO.Input - Values.V.species[speciesIndex].stats[sIO.statIndex].BaseValue) / (Values.V.species[speciesIndex].stats[sIO.statIndex].BaseValue * Values.V.species[speciesIndex].stats[sIO.statIndex].IncPerWildLevel));
sIO.LevelWild = (lvlWild < 0 ? 0 : lvlWild);
sIO.LevelDom = 0;
if (sIO.statIndex == 7)
{
tamingControl1.setLevel(statIOs[7].LevelWild + 1, false);
tamingControl1.setSpeciesIndex(comboBoxSpeciesGlobal.SelectedIndex);
labelTamingInfo.Text = tamingControl1.quickTamingInfos;
}
}
}

Expand Down Expand Up @@ -3635,12 +3654,10 @@ private List<int> determineSpeciesFromStats(float[] stats, string species)
if (statIOs[4].Input != 0 && baseValue == 0)
likely = false; // having an oxygen value for non-oxygen dino is a disqualifier


if (likely)
possibleDinos.Insert(0, i);
else
possibleDinos.Add(i);

}

if (comboBoxSpeciesGlobal.SelectedIndex >= 0)
Expand All @@ -3655,6 +3672,7 @@ private void chkbToggleOverlay_CheckedChanged(object sender, EventArgs e)
overlay = new ARKOverlay();
overlay.ExtractorForm = this;
overlay.InfoDuration = Properties.Settings.Default.OverlayInfoDuration;
overlay.enableInventoryCheckTimer = Properties.Settings.Default.inventoryCheckTimer;
overlay.initLabelPositions();
}

Expand Down Expand Up @@ -3870,9 +3888,9 @@ private void button2TamingCalc_Click(object sender, EventArgs e)
{
tamingControl1.setSpeciesIndex(comboBoxSpeciesGlobal.SelectedIndex);
if (checkBoxQuickWildCheck.Checked)
tamingControl1.level = statIOs[7].LevelWild + 1;
tamingControl1.setLevel(statIOs[7].LevelWild + 1);
else
tamingControl1.level = (int)numericUpDownLevel.Value;
tamingControl1.setLevel((int)numericUpDownLevel.Value);
tabControlMain.SelectedTab = tabPageTaming;
}

Expand All @@ -3881,13 +3899,14 @@ private void labelImprintedCount_Click(object sender, EventArgs e)
// set imprinting-count to closes integer
if (Values.V.species[speciesIndex].breeding != null && Values.V.species[speciesIndex].breeding.maturationTimeAdjusted > 0)
{
int cuddleCount = (int)Math.Round((double)numericUpDownImprintingBonusTester.Value * Values.V.species[speciesIndex].breeding.maturationTimeAdjusted / (2880000 * Values.V.babyCuddleIntervalMultiplier));
double imprintingGainPerCuddle = Utils.imprintingGainPerCuddle(Values.V.species[speciesIndex].breeding.maturationTimeAdjusted, Values.V.babyCuddleIntervalMultiplier);
int cuddleCount = (int)Math.Round((double)numericUpDownImprintingBonusTester.Value / (100 * imprintingGainPerCuddle));
double imprintingBonus;
do
{
imprintingBonus = Math.Round(cuddleCount * 2880000 * Values.V.babyCuddleIntervalMultiplier / Values.V.species[speciesIndex].breeding.maturationTimeAdjusted, 3);
imprintingBonus = Math.Round(100 * cuddleCount * imprintingGainPerCuddle, 5);
cuddleCount--;
} while (imprintingBonus > 100);
} while (imprintingBonus > 100); // TODO some mods allow more than 100% imprinting
numericUpDownImprintingBonusTester.Value = (decimal)imprintingBonus;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.24.4")]
[assembly: AssemblyFileVersion("0.24.5")]
Loading

0 comments on commit 5d35ef5

Please sign in to comment.