Skip to content

Commit

Permalink
added library filtering via tags. last owner and tribe in the extract…
Browse files Browse the repository at this point in the history
…or input and if they're locked will be saved now. added new setting for max server level, creatures that have a risk of hitting this will be marked with a red text in the library. fixed null-exception when importing non-breedable creatures (#666). adjusted top-stat algorithms for breeding-planner if some creatures are filtered out so it shows adjusted top-stat-breeding suggestions. updated griffin values for the classicFlyers-mod (#623). Changed location for additional-values-files, it's now the json-folder of the application, this should make updates of the files more reliable. fixed extraction-issue that could appear with high-level bred creatures.
  • Loading branch information
cadaei committed Apr 15, 2018
1 parent 27edec4 commit af95f23
Show file tree
Hide file tree
Showing 18 changed files with 430 additions and 111 deletions.
12 changes: 12 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@
<setting name="IgnoreSexInBreedingPlan" serializeAs="String">
<value>False</value>
</setting>
<setting name="DefaultOwnerName" serializeAs="String">
<value />
</setting>
<setting name="OwnerNameLocked" serializeAs="String">
<value>False</value>
</setting>
<setting name="DefaultTribeName" serializeAs="String">
<value />
</setting>
<setting name="TribeNameLocked" serializeAs="String">
<value>False</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
50 changes: 38 additions & 12 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,9 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo
// chosen Creature (only consider this one for its sex)
bool considerChosenCreature = chosenCreature != null;

labelTitle.Text = currentSpecies + (considerChosenCreature ? " (only pairings with \"" + chosenCreature.name + "\")" : "");
if (considerChosenCreature && (chosenCreature.neutered || chosenCreature.status != CreatureStatus.Available))
labelTitle.Text += "! Breeding not possible ! (" + (chosenCreature.neutered ? "neutered" : "not available") + ")";

// filter by tags
int crCountF = females.Count;
int crCountM = males.Count;
List<Creature> chosenF, chosenM;
if (considerChosenCreature && chosenCreature.sex == Sex.Female)
chosenF = new List<Creature>();
Expand All @@ -205,11 +203,18 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo
chosenM = new List<Creature>();
else chosenM = filterByTags(males);

bool creaturesTagFilteredOut = (crCountF != chosenF.Count)
|| (crCountM != chosenM.Count);

crCountF = chosenF.Count;
crCountM = chosenM.Count;
if (nudMutationLimit.Value >= 0)
{
chosenF = chosenF.Where(c => c.mutationsMaternal + c.mutationsPaternal <= nudMutationLimit.Value).ToList();
chosenM = chosenM.Where(c => c.mutationsMaternal + c.mutationsPaternal <= nudMutationLimit.Value).ToList();
}
bool creaturesMutationsFilteredOut = (crCountF != chosenF.Count)
|| (crCountM != chosenM.Count);

if (considerChosenCreature)
{
Expand All @@ -219,10 +224,31 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo
chosenM.Add(chosenCreature);
}

labelTitle.Text = currentSpecies + (considerChosenCreature ? " (only pairings with \"" + chosenCreature.name + "\")" : "");
if (considerChosenCreature && (chosenCreature.neutered || chosenCreature.status != CreatureStatus.Available))
labelTitle.Text += "! Breeding not possible ! (" + (chosenCreature.neutered ? "neutered" : "not available") + ")";

string warningText = "";
if (creaturesTagFilteredOut) warningText = "Some creatures are filtered out due to their tags";
if (creaturesMutationsFilteredOut) warningText += (warningText.Length > 0 ? " or mutations" : "Some creatures are filtered out due to their mutations");
if (warningText.Length > 0) setMessageLabelText(warningText + ".\nThe top-stats shown here might not be the top-stats of your entire library", MessageBoxIcon.Warning);


var combinedCreatures = new List<Creature>(chosenF);
combinedCreatures.AddRange(chosenM);
// determine top-stats for choosen creatures.
int[] topStats = new int[7];
foreach (Creature c in combinedCreatures)
{
for (int s = 0; s < 7; s++)
{
if (c.levelsWild[s] > topStats[s])
c.levelsWild[s] = topStats[s];
}
}

if (Properties.Settings.Default.IgnoreSexInBreedingPlan)
{
var combinedCreatures = new List<Creature>(chosenF);
combinedCreatures.AddRange(chosenM);
chosenF = new List<Creature>(combinedCreatures);
chosenM = new List<Creature>(combinedCreatures);
}
Expand Down Expand Up @@ -260,9 +286,9 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo
{
if (breedingMode == BreedingMode.TopStatsLucky)
{
if (female.topBreedingStats[s] || male.topBreedingStats[s])
if (female.levelsWild[s] == topStats[s] || male.levelsWild[s] == topStats[s])
{
if (female.topBreedingStats[s] && male.topBreedingStats[s])
if (female.levelsWild[s] == topStats[s] && male.levelsWild[s] == topStats[s])
tt *= 1.142;
}
else if (bestLevels[s] > 0)
Expand All @@ -272,10 +298,10 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo
{
bestPossLevels[s] = (Int16)Math.Max(female.levelsWild[s], male.levelsWild[s]);
tt *= .01;
if (female.topBreedingStats[s] || male.topBreedingStats[s])
if (female.levelsWild[s] == topStats[s] || male.levelsWild[s] == topStats[s])
{
nrTS++;
eTS += ((female.topBreedingStats[s] && male.topBreedingStats[s]) ? 1 : 0.7);
eTS += ((female.levelsWild[s] == topStats[s] && male.levelsWild[s] == topStats[s]) ? 1 : 0.7);
}
}
}
Expand Down Expand Up @@ -472,7 +498,7 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo
setMessageLabelText("There is already a creature in your library that has all the available top-stats ("
+ bestCreature.name + " " + Utils.sexSymbol(bestCreature.sex) + ")."
+ "\nThe currently selected conservative-breeding-mode might show some suggestions that may seem non-optimal.\n"
+ "Change the breeding-mode to \"High Stats\" for better suggestions.");
+ "Change the breeding-mode to \"High Stats\" for better suggestions.", MessageBoxIcon.Warning);
}
}
else
Expand Down Expand Up @@ -534,7 +560,7 @@ public void ClearControls()
labelInfo.Visible = false;
labelProbabilityBest.Text = "";
offspringPossibilities1.Clear();
setMessageLabelText("");
setMessageLabelText("", MessageBoxIcon.None);
}

public void Clear()
Expand Down
25 changes: 18 additions & 7 deletions ARKBreedingStats/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace ARKBreedingStats
public List<string> hiddenOwners = new List<string>(); // which owners are not selected to be shown
[XmlArray]
internal List<string> hiddenServers = new List<string>();
[XmlArray]
public List<string> dontShowTags = new List<string>(); // which tags are selected to be not shown
public bool showDeads = true;
public bool showUnavailable = true;
public bool showNeutered = true;
Expand All @@ -37,6 +39,7 @@ namespace ARKBreedingStats
public int maxBreedingSuggestions = 10;
public bool considerWildLevelSteps = false;
public int wildLevelStep = 5;
public int maxServerLevel = 450; // on official servers a creature with more than 450 total levels will be deleted

public double imprintingMultiplier = 1;
public double babyCuddleIntervalMultiplier = 1;
Expand Down Expand Up @@ -89,7 +92,8 @@ public bool mergeCreatureList(List<Creature> creaturesToMerge, bool update = fal
if (old.species != creature.species) continue;

bool recalculate = false;
if (old.status == CreatureStatus.Unavailable && creature.status == CreatureStatus.Alive) {
if (old.status == CreatureStatus.Unavailable && creature.status == CreatureStatus.Alive)
{
old.colors = creature.colors;
old.cooldownUntil = creature.cooldownUntil;
old.domesticatedAt = creature.domesticatedAt;
Expand Down Expand Up @@ -126,32 +130,39 @@ public bool mergeCreatureList(List<Creature> creaturesToMerge, bool update = fal
old.valuesDom = creature.valuesDom;
creaturesWereAdded = true;
recalculate = true;
} else {
}
else
{

if (old.name != creature.name) {
if (old.name != creature.name)
{
old.name = creature.name;
creaturesWereAdded = true;
}

if (!old.levelsWild.SequenceEqual(creature.levelsWild)) {
if (!old.levelsWild.SequenceEqual(creature.levelsWild))
{
old.levelsWild = creature.levelsWild;
recalculate = true;
creaturesWereAdded = true;
}

if (!old.levelsDom.SequenceEqual(creature.levelsDom)) {
if (!old.levelsDom.SequenceEqual(creature.levelsDom))
{
old.levelsDom = creature.levelsDom;
recalculate = true;
creaturesWereAdded = true;
}

if (old.imprintingBonus != creature.imprintingBonus) {
if (old.imprintingBonus != creature.imprintingBonus)
{
old.imprintingBonus = creature.imprintingBonus;
recalculate = true;
creaturesWereAdded = true;
}

if (old.tamingEff != creature.tamingEff) {
if (old.tamingEff != creature.tamingEff)
{
old.tamingEff = creature.tamingEff;
recalculate = true;
creaturesWereAdded = true;
Expand Down
33 changes: 27 additions & 6 deletions ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public partial class CreatureInfoInput : UserControl
private List<Creature> _females;
private List<Creature> _males;
private string[] _ownersTribes;
public bool ownerLock, tribeLock; // if true the OCR will not change these fields
private int[] regionColorIDs;
private bool _tribeLock, _ownerLock;

public CreatureInfoInput()
{
InitializeComponent();
speciesIndex = -1;
textBoxName.Text = "";
parentComboBoxMother.naLabel = " - Mother n/a";
parentComboBoxMother.Items.Add(" - Mother n/a");
parentComboBoxFather.naLabel = " - Father n/a";
Expand Down Expand Up @@ -432,21 +433,41 @@ private void textBoxOwner_Leave(object sender, EventArgs e)
}
}

// if true the OCR will not change these fields
public bool OwnerLock
{
get { return _ownerLock; }
set
{
_ownerLock = value;
textBoxOwner.BackColor = value ? Color.LightGray : SystemColors.Window;
}
}
// if true the OCR will not change these fields
public bool TribeLock
{
get { return _tribeLock; }
set
{
_tribeLock = value;
textBoxTribe.BackColor = value ? Color.LightGray : SystemColors.Window;
}
}

private void lblOwner_Click(object sender, EventArgs e)
{
ownerLock = !ownerLock;
textBoxOwner.BackColor = ownerLock ? Color.LightGray : SystemColors.Window;
OwnerLock = !OwnerLock;
}

private void lblName_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBoxName.Text);
if (textBoxName.Text.Length > 0)
Clipboard.SetText(textBoxName.Text);
}

private void lblTribe_Click(object sender, EventArgs e)
{
tribeLock = !tribeLock;
textBoxTribe.BackColor = tribeLock ? Color.LightGray : SystemColors.Window;
TribeLock = !TribeLock;
}
}
}
28 changes: 15 additions & 13 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public void extractLevels(int speciesI, int level, List<StatIO> statIOs, double
this.bred = bred;
if (bred)
postTamed = true;
//else if (autoDetectTamed && stats[7].AddWhenTamed > 0)
//{
// // torpor is directly proportional to wild level. Check if creature is wild or tamed (doesn't work with creatures that have no additive bonus on torpor, e.g. the Giganotosaurus)
// postTamed = (Math.Round(stats[7].BaseValue * (1 + stats[7].IncPerWildLevel * Math.Round((statIOs[7].Input - stats[7].BaseValue) / (stats[7].BaseValue * stats[7].IncPerWildLevel))), 3) != statIOs[7].Input);
//}
else
postTamed = tamed;

Expand Down Expand Up @@ -335,7 +330,7 @@ private List<double> CalculateImprintingBonus(double imprintingBonusRounded, dou
for (int torporLevel = wildLevelsFromImprintedTorpor.Min; torporLevel <= wildLevelsFromImprintedTorpor.Max; torporLevel++)
{
int support = 0;
MinMaxDouble imprintingBonusFromTorpor = new MinMaxDouble(
MinMaxDouble imprintingBonusRange = new MinMaxDouble(
(((torpor - 0.05) / (1 + stats[7].MultAffinity) - stats[7].AddWhenTamed) / Stats.calculateValue(speciesIndex, 7, torporLevel, 0, false, 0, 0) - 1) / (0.2 * imprintingBonusMultiplier),
(((torpor + 0.05) / (1 + stats[7].MultAffinity) - stats[7].AddWhenTamed) / Stats.calculateValue(speciesIndex, 7, torporLevel, 0, false, 0, 0) - 1) / (0.2 * imprintingBonusMultiplier));

Expand All @@ -348,23 +343,30 @@ private List<double> CalculateImprintingBonus(double imprintingBonusRounded, dou


// NOTE. it's assumed if the IB-food is in the range of IB-torpor, the values are correct. This doesn't have to be true, but is very probable. If extraction-issues appear, this assumption could be the reason.
if (imprintingBonusFromTorpor.Includes(imprintingBonusFromFood)
&& Stats.calculateValue(speciesIndex, 7, torporLevel, 0, true, 1, imprintingBonusFromFood.Mean) == torpor)
//if (imprintingBonusFromTorpor.Includes(imprintingBonusFromFood)
if (imprintingBonusRange.Overlaps(imprintingBonusFromFood))
{
imprintingBonusFromTorpor = imprintingBonusFromFood;
support++;
MinMaxDouble intersectionIB = new MinMaxDouble(imprintingBonusRange);
intersectionIB.SetToInsersectionWith(imprintingBonusFromFood);
if (Stats.calculateValue(speciesIndex, 7, torporLevel, 0, true, 1, intersectionIB.Min) <= torpor
&& Stats.calculateValue(speciesIndex, 7, torporLevel, 0, true, 1, intersectionIB.Max) >= torpor)
{
//imprintingBonusFromTorpor = imprintingBonusFromFood;
imprintingBonusRange.SetToInsersectionWith(imprintingBonusFromFood);
support++;
}
}
}

// if classic method results in value in the possible range, take this, probably most exact value
if (imprintingBonusFromTorpor.Includes(imprintingBonusFromGainPerCuddle)
if (imprintingBonusRange.Includes(imprintingBonusFromGainPerCuddle)
&& Stats.calculateValue(speciesIndex, 7, torporLevel, 0, true, 1, imprintingBonusFromGainPerCuddle) == torpor)
{
imprintingBonusFromTorpor.MinMax = imprintingBonusFromGainPerCuddle;
imprintingBonusRange.MinMax = imprintingBonusFromGainPerCuddle;
support++;
}

imprintingBonusList.Add(imprintingBonusFromTorpor);
imprintingBonusList.Add(imprintingBonusRange);
otherStatsSupportIB.Add(support);
}

Expand Down
Loading

0 comments on commit af95f23

Please sign in to comment.