Skip to content

Commit

Permalink
fixed error when stat-value seems to be below zero (Griffin HP). Fix …
Browse files Browse the repository at this point in the history
…for aberration variants, tweaked extraction process.
  • Loading branch information
cadaei committed Dec 22, 2017
1 parent 8ae95de commit f6f7e6d
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 20 deletions.
10 changes: 6 additions & 4 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ 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)
{
imprintingBonus = Math.Round(Math.Round(imprintingBonusRounded * Values.V.species[speciesI].breeding.maturationTimeAdjusted / (14400 * cuddleIntervalMultiplier))
* 14400 * cuddleIntervalMultiplier / Values.V.species[speciesI].breeding.maturationTimeAdjusted, 5);
// 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);
if (imprintingBonus > 1)
imprintingBonus = 1;
if (Math.Abs(imprintingBonusRounded - imprintingBonus) > 0.01)
Expand Down Expand Up @@ -290,7 +291,8 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
{
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
}
if (maxLD > domFreeMax) { maxLD = domFreeMax; }
if (maxLD > domFreeMax) maxLD = domFreeMax;
if (maxLD < 0) maxLD = 0;

for (int w = 0; w < maxLW + 1; w++)
{
Expand Down Expand Up @@ -342,7 +344,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].IncPerTamedLevel * d) - inputValue) * (Utils.precision(s) == 3 ? 100 : 1)) < 0.15)
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)
{
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.

8 changes: 4 additions & 4 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2741,15 +2741,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 / (1440000 * Values.V.babyCuddleIntervalMultiplier), 2) + "×)";
labelImprintedCount.Text = "(" + Math.Round((double)numericUpDownImprintingBonusTester.Value * Values.V.species[speciesIndex].breeding.maturationTimeAdjusted / (2880000 * 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 / (1440000 * Values.V.babyCuddleIntervalMultiplier)) + "×)";
labelImprintingCuddleCountExtractor.Text = "(" + Math.Round((double)numericUpDownImprintingBonusExtractor.Value * Values.V.species[speciesIndex].breeding.maturationTimeAdjusted / (2880000 * Values.V.babyCuddleIntervalMultiplier)) + "×)";
else labelImprintingCuddleCountExtractor.Text = "";
}

Expand Down Expand Up @@ -3877,11 +3877,11 @@ 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 / (1440000 * Values.V.babyCuddleIntervalMultiplier));
int cuddleCount = (int)Math.Round((double)numericUpDownImprintingBonusTester.Value * Values.V.species[speciesIndex].breeding.maturationTimeAdjusted / (2880000 * Values.V.babyCuddleIntervalMultiplier));
double imprintingBonus;
do
{
imprintingBonus = Math.Round(cuddleCount * 1440000 * Values.V.babyCuddleIntervalMultiplier / Values.V.species[speciesIndex].breeding.maturationTimeAdjusted, 3);
imprintingBonus = Math.Round(cuddleCount * 2880000 * Values.V.babyCuddleIntervalMultiplier / Values.V.species[speciesIndex].breeding.maturationTimeAdjusted, 3);
cuddleCount--;
} while (imprintingBonus > 100);
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.2")]
[assembly: AssemblyFileVersion("0.24.3")]
1 change: 1 addition & 0 deletions ARKBreedingStats/StatIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public double Input
get { return (double)this.numericUpDownInput.Value / (percent ? 100 : 1); }
set
{
if (value > (double)numericUpDownInput.Maximum) value = (double)numericUpDownInput.Maximum;
this.numericUpDownInput.Value = (decimal)value * (percent ? 100 : 1);
this.labelFinalValue.Text = (value * (percent ? 100 : 1)).ToString("N1");
}
Expand Down
10 changes: 7 additions & 3 deletions ARKBreedingStats/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ public static double calculateValue(int speciesIndex, int stat, int levelWild, i
{
if (speciesIndex >= 0)
{
double add = 0, domMult = 1, imprintingM = 1, tamedBaseHP = 1;
double add = 0, domMultAffinity = 0, domMult = 1, imprintingM = 1, tamedBaseHP = 1;
if (dom)
{
add = Values.V.species[speciesIndex].stats[stat].AddWhenTamed;
domMult = (tamingEff >= 0 ? (1 + tamingEff * Values.V.species[speciesIndex].stats[stat].MultAffinity) : 1) * (1 + levelDom * Values.V.species[speciesIndex].stats[stat].IncPerTamedLevel);
domMultAffinity = Values.V.species[speciesIndex].stats[stat].MultAffinity;
if (domMultAffinity >= 0)
domMultAffinity *= tamingEff;
domMult = (tamingEff >= 0 ? (1 + domMultAffinity) : 1) * (1 + levelDom * Values.V.species[speciesIndex].stats[stat].IncPerTamedLevel);
if (imprintingBonus > 0 && stat != 1 && stat != 2 && (stat != 6 || Values.V.species[speciesIndex].NoImprintingForSpeed == false))
imprintingM = 1 + 0.2 * imprintingBonus * Values.V.imprintingStatScaleMultiplier;
if (stat == 0)
tamedBaseHP = (float)Values.V.species[speciesIndex].TamedBaseHealthMultiplier;
}
return Math.Round((Values.V.species[speciesIndex].stats[stat].BaseValue * tamedBaseHP * (1 + Values.V.species[speciesIndex].stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, Utils.precision(stat), MidpointRounding.AwayFromZero);
double result = Math.Round((Values.V.species[speciesIndex].stats[stat].BaseValue * tamedBaseHP * (1 + Values.V.species[speciesIndex].stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, Utils.precision(stat), MidpointRounding.AwayFromZero);
return result >= 0 ? result : 0;
}
else
return 0;
Expand Down
6 changes: 4 additions & 2 deletions ARKBreedingStats/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,17 @@ public void applyMultipliers(CreatureCollection cc, bool eventMultipliers = fals
species[sp].stats[s].BaseValue = (double)species[sp].statsRaw[s][0];
// don't apply the multiplier if AddWhenTamed is negative (e.g. Giganotosaurus, Griffin)
species[sp].stats[s].AddWhenTamed = (double)species[sp].statsRaw[s][3] * (species[sp].statsRaw[s][3] > 0 ? cc.multipliers[s][0] : 1);
species[sp].stats[s].MultAffinity = (double)species[sp].statsRaw[s][4] * cc.multipliers[s][1];
// don't apply the multiplier if MultAffinity is negative (e.g. Aberration variants)
species[sp].stats[s].MultAffinity = (double)species[sp].statsRaw[s][4] * (species[sp].statsRaw[s][4] > 0 ? cc.multipliers[s][1] : 1);
species[sp].stats[s].IncPerTamedLevel = (double)species[sp].statsRaw[s][2] * cc.multipliers[s][2];
species[sp].stats[s].IncPerWildLevel = (double)species[sp].statsRaw[s][1] * cc.multipliers[s][3];

if (cc.singlePlayerSettings && statMultipliersSP[s] != null)
{
// don't apply the multiplier if AddWhenTamed is negative (e.g. Giganotosaurus, Griffin)
species[sp].stats[s].AddWhenTamed *= statMultipliersSP[s][0] != null && species[sp].stats[s].AddWhenTamed > 0 ? (double)statMultipliersSP[s][0] : 1;
species[sp].stats[s].MultAffinity *= statMultipliersSP[s][1] != null ? (double)statMultipliersSP[s][1] : 1;
// don't apply the multiplier if MultAffinity is negative (e.g. Aberration variants)
species[sp].stats[s].MultAffinity *= statMultipliersSP[s][1] != null && species[sp].stats[s].MultAffinity > 0 ? (double)statMultipliersSP[s][1] : 1;
species[sp].stats[s].IncPerTamedLevel *= statMultipliersSP[s][2] != null ? (double)statMultipliersSP[s][2] : 1;
species[sp].stats[s].IncPerWildLevel *= statMultipliersSP[s][3] != null ? (double)statMultipliersSP[s][3] : 1;
}
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/json/values.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ARKBreedingStats/ver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
275.4,0.24.2
276.12,0.24.3

0 comments on commit f6f7e6d

Please sign in to comment.