private void listViewSpeciesBP_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSpeciesBP.SelectedIndices.Count > 0) { determineBestBreeding(); if (bestLevels.Count > 6) { // display top levels in species int? levelStep = creatureCollection.getWildLevelStep(); Creature crB = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep); crB.name = "Best possible levels (" + currentSpecies + ")"; bool totalLevelUnknown = false; for (int s = 0; s < 7; s++) { crB.levelsWild[s] = bestLevels[s]; crB.valuesBreeding[s] = Stats.calculateValue(speciesIndex, s, crB.levelsWild[s], 0, true, 1, 0); if (crB.levelsWild[s] == -1) { totalLevelUnknown = true; } crB.topBreedingStats[s] = (crB.levelsWild[s] > 0); } crB.levelsWild[7] = crB.levelsWild.Sum(); crB.recalculateCreatureValues(levelStep); pedigreeCreatureBestPossibleInSpecies.totalLevelUnknown = totalLevelUnknown; pedigreeCreatureBestPossibleInSpecies.Creature = crB; } } }
private void setParents(int comboIndex) { if (comboIndex < 0 || comboIndex >= breedingPairs.Count) { pedigreeCreatureBest.Clear(); pedigreeCreatureWorst.Clear(); lbBreedingPlanInfo.Visible = false; lbBPProbabilityBest.Text = ""; return; } int? levelStep = creatureCollection.getWildLevelStep(); Creature crB = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep); Creature crW = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep); Creature mother = breedingPairs[comboIndex].Female; Creature father = breedingPairs[comboIndex].Male; crB.Mother = mother; crB.Father = father; crW.Mother = mother; crW.Father = father; double probabilityBest = 1; bool totalLevelUnknown = false; // if stats are unknown, total level is as well (==> oxygen, speed) for (int s = 0; s < 7; s++) { crB.levelsWild[s] = statWeights[s] < 0 ? Math.Min(mother.levelsWild[s], father.levelsWild[s]) : Math.Max(mother.levelsWild[s], father.levelsWild[s]); crB.valuesBreeding[s] = Stats.calculateValue(speciesIndex, s, crB.levelsWild[s], 0, true, 1, 0); crB.topBreedingStats[s] = (crB.levelsWild[s] == bestLevels[s]); crW.levelsWild[s] = statWeights[s] < 0 ? Math.Max(mother.levelsWild[s], father.levelsWild[s]) : Math.Min(mother.levelsWild[s], father.levelsWild[s]); crW.valuesBreeding[s] = Stats.calculateValue(speciesIndex, s, crW.levelsWild[s], 0, true, 1, 0); crW.topBreedingStats[s] = (crW.levelsWild[s] == bestLevels[s]); if (crB.levelsWild[s] == -1 || crW.levelsWild[s] == -1) { totalLevelUnknown = true; } if (crB.levelsWild[s] > crW.levelsWild[s]) { probabilityBest *= .7; } } crB.levelsWild[7] = crB.levelsWild.Sum(); crW.levelsWild[7] = crW.levelsWild.Sum(); crB.name = Loc.s("BestPossible"); crW.name = Loc.s("WorstPossible"); crB.recalculateCreatureValues(levelStep); crW.recalculateCreatureValues(levelStep); pedigreeCreatureBest.totalLevelUnknown = totalLevelUnknown; pedigreeCreatureWorst.totalLevelUnknown = totalLevelUnknown; int mutationCounterMaternal = mother.Mutations; int mutationCounterPaternal = father.Mutations; crB.mutationsMaternal = mutationCounterMaternal; crB.mutationsPaternal = mutationCounterPaternal; crW.mutationsMaternal = mutationCounterMaternal; crW.mutationsPaternal = mutationCounterPaternal; pedigreeCreatureBest.Creature = crB; pedigreeCreatureWorst.Creature = crW; lbBPProbabilityBest.Text = Loc.s("ProbabilityForBest") + ": " + Math.Round(100 * probabilityBest, 1).ToString() + "%"; // set probability barChart offspringPossibilities1.wildLevels1 = mother.levelsWild; offspringPossibilities1.wildLevels2 = father.levelsWild; offspringPossibilities1.calculate(); // highlight parents int hiliId = comboIndex * 2; for (int i = 0; i < pcs.Count; i++) { pcs[i].highlight = (i == hiliId || i == hiliId + 1); } }
private Creature ConvertCreature(ImportedCreature lc, int?levelStep) { var owner = String.IsNullOrWhiteSpace(lc.Imprinter) ? lc.Tamer : lc.Imprinter; int[] wildLevels = new int[] { -1, -1, -1, -1, -1, -1, -1, -1 }; // -1 is unknown int[] tamedLevels = new int[8]; if (lc.WildLevels != null) { wildLevels = ConvertLevels(lc.WildLevels, lc.BaseLevel - 1); } if (lc.TamedLevels != null) { tamedLevels = ConvertLevels(lc.TamedLevels); } string convertedSpeciesName = ConvertSpecies(lc.Type); // fix for wrong TE (bug in ark-tools) TODO. got it fixed in ark-tools? // if it got fixed in ark-tools, use // double te = lc.TamingEffectiveness; double te = 1 / (2 - lc.TamingEffectiveness); var creature = new Creature(convertedSpeciesName, lc.Name, owner, lc.Tribe, lc.Female ? Sex.Female : Sex.Male, wildLevels, tamedLevels, te, !string.IsNullOrWhiteSpace(lc.Imprinter), lc.ImprintingQuality, levelStep); creature.imprinterName = lc.Imprinter; creature.guid = Utils.ConvertIdToGuid(lc.Id); creature.domesticatedAt = DateTime.Now; // TODO: convert ingame-time to realtime? creature.addedToLibrary = DateTime.Now; creature.mutationsMaternal = lc.MutationsFemaleLine; creature.mutationsPaternal = lc.MutationsMaleLine; // If it's a baby and still growing, work out growingUntil if (lc.Baby || (!lc.Baby && !String.IsNullOrWhiteSpace(lc.Imprinter))) { int i = Values.V.speciesNames.IndexOf(convertedSpeciesName); double maturationTime = Values.V.species[i].breeding.maturationTimeAdjusted; if (lc.TamedTime < maturationTime) { creature.growingUntil = DateTime.Now + TimeSpan.FromSeconds(maturationTime - lc.TamedTime); } } // Ancestor linking is done later after entire collection is formed - here we just set the guids if (lc.FemaleAncestors != null && lc.FemaleAncestors.Count > 0) { var femaleAncestor = lc.FemaleAncestors.Last(); creature.motherGuid = Utils.ConvertIdToGuid(femaleAncestor.FemaleId); creature.motherName = femaleAncestor.FemaleName; creature.isBred = true; } if (lc.MaleAncestors != null && lc.MaleAncestors.Count > 0) { var maleAncestor = lc.MaleAncestors.Last(); creature.fatherGuid = Utils.ConvertIdToGuid(maleAncestor.MaleId); creature.fatherName = maleAncestor.MaleName; creature.isBred = true; } if (lc.Colors != null) { creature.colors = ConvertColors(lc.Colors); } if (lc.Dead) { creature.status = CreatureStatus.Dead; // dead is always dead } if (!lc.Dead && creature.status == CreatureStatus.Dead) { creature.status = CreatureStatus.Unavailable; // if found alive when marked dead, mark as unavailable } creature.recalculateAncestorGenerations(); creature.recalculateCreatureValues(levelStep); return(creature); }
private void setParents(int comboIndex) { if (comboIndex < 0 || comboIndex > combinedTops[0].Count) { pedigreeCreatureBest.Clear(); pedigreeCreatureWorst.Clear(); labelInfo.Visible = false; labelProbabilityBest.Text = ""; return; } int? levelStep = creatureCollection.getWildLevelStep(); Creature crB = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep); Creature crW = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep); Creature mother = females[combinedTops[0][comboIndex]]; Creature father = males[combinedTops[1][comboIndex]]; crB.Mother = mother; crB.Father = father; crW.Mother = mother; crW.Father = father; double probabilityBest = 1; bool totalLevelUnknown = false; // if stats are unknown, total level is as well (==> oxygen, speed) for (int s = 0; s < 7; s++) { crB.levelsWild[s] = Math.Max(mother.levelsWild[s], father.levelsWild[s]); crB.valuesBreeding[s] = Stats.calculateValue(speciesIndex, s, crB.levelsWild[s], 0, true, 1, 0); crB.topBreedingStats[s] = (crB.levelsWild[s] == bestLevels[s]); crW.levelsWild[s] = Math.Min(mother.levelsWild[s], father.levelsWild[s]); crW.valuesBreeding[s] = Stats.calculateValue(speciesIndex, s, crW.levelsWild[s], 0, true, 1, 0); crW.topBreedingStats[s] = (crW.levelsWild[s] == bestLevels[s]); if (crB.levelsWild[s] == -1 || crW.levelsWild[s] == -1) { totalLevelUnknown = true; } if (crB.levelsWild[s] > crW.levelsWild[s]) { probabilityBest *= .7; } } crB.levelsWild[7] = crB.levelsWild.Sum(); crW.levelsWild[7] = crW.levelsWild.Sum(); crB.name = "Best Possible"; crW.name = "Worst Possible"; crB.recalculateCreatureValues(levelStep); crW.recalculateCreatureValues(levelStep); pedigreeCreatureBest.totalLevelUnknown = totalLevelUnknown; pedigreeCreatureWorst.totalLevelUnknown = totalLevelUnknown; int mutationCounter = mother.mutationCounter + father.mutationCounter; crB.mutationCounter = mutationCounter; crW.mutationCounter = mutationCounter; pedigreeCreatureBest.Creature = crB; pedigreeCreatureWorst.Creature = crW; labelProbabilityBest.Text = "Probability for this Best Possible outcome: " + Math.Round(100 * probabilityBest, 1).ToString() + "%"; // set probability barChart offspringPossibilities1.wildLevels1 = mother.levelsWild; offspringPossibilities1.wildLevels2 = father.levelsWild; offspringPossibilities1.calculate(); // highlight parents int hiliId = comboOrder.IndexOf(comboIndex) * 2; for (int i = 0; i < pcs.Count; i++) { pcs[i].highlight = (i == hiliId || i == hiliId + 1); } }
private Creature convertGameObject(GameObject creatureObject, int?levelStep) { GameObject statusObject = creatureObject.CharacterStatusComponent(); string imprinterName = creatureObject.GetPropertyValue <string>("ImprinterName"); string owner = string.IsNullOrWhiteSpace(imprinterName) ? creatureObject.GetPropertyValue <string>("TamerString") : imprinterName; int[] wildLevels = Enumerable.Repeat(-1, statsCount).ToArray(); // -1 is unknown int[] tamedLevels = new int[statsCount]; for (int i = 0; i < statsCount; i++) { wildLevels[i] = statusObject.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsApplied", i)?.ByteValue ?? 0; } wildLevels[(int)StatNames.Torpidity] = statusObject.GetPropertyValue <int>("BaseCharacterLevel", defaultValue: 1) - 1; // torpor for (int i = 0; i < statsCount; i++) { tamedLevels[i] = statusObject.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsAppliedTamed", i)?.ByteValue ?? 0; } string convertedSpeciesName = convertSpecies(creatureObject.GetNameForCreature(arkData) ?? creatureObject.ClassString); float ti = statusObject.GetPropertyValue <float>("TamedIneffectivenessModifier", defaultValue: float.NaN); double te = 1f / (1 + (!float.IsNaN(ti) ? ti : creatureObject.GetPropertyValue <float>("TameIneffectivenessModifier"))); Creature creature = new Creature(convertedSpeciesName, creatureObject.GetPropertyValue <string>("TamedName"), owner, creatureObject.GetPropertyValue <string>("TribeName"), creatureObject.IsFemale() ? Sex.Female : Sex.Male, wildLevels, tamedLevels, te, !string.IsNullOrWhiteSpace(creatureObject.GetPropertyValue <string>("ImprinterName")), statusObject.GetPropertyValue <float>("DinoImprintingQuality"), levelStep ) { imprinterName = creatureObject.GetPropertyValue <string>("ImprinterName"), guid = Utils.ConvertArkIdToGuid(creatureObject.GetDinoId()), ArkId = creatureObject.GetDinoId(), ArkIdImported = true, domesticatedAt = DateTime.Now, // TODO: possible to convert ingame-time to realtime? addedToLibrary = DateTime.Now, mutationsMaternal = creatureObject.GetPropertyValue <int>("RandomMutationsFemale"), mutationsPaternal = creatureObject.GetPropertyValue <int>("RandomMutationsMale") }; // If it's a baby and still growing, work out growingUntil if (creatureObject.GetPropertyValue <bool>("bIsBaby") || !creatureObject.GetPropertyValue <bool>("bIsBaby") && !string.IsNullOrWhiteSpace(imprinterName)) { int i = Values.V.speciesNames.IndexOf(convertedSpeciesName); double maturationTime = Values.V.species[i].breeding?.maturationTimeAdjusted ?? 0; float tamedTime = gameTime - (float)creatureObject.GetPropertyValue <double>("TamedAtTime"); if (tamedTime < maturationTime) { creature.growingUntil = DateTime.Now + TimeSpan.FromSeconds(maturationTime - tamedTime); } } // Ancestor linking is done later after entire collection is formed - here we just set the guids ArkArrayStruct femaleAncestors = creatureObject.GetPropertyValue <IArkArray, ArkArrayStruct>("DinoAncestors"); StructPropertyList femaleAncestor = (StructPropertyList)femaleAncestors?.LastOrDefault(); if (femaleAncestor != null) { creature.motherGuid = Utils.ConvertArkIdToGuid(GameObjectExtensions.CreateDinoId( femaleAncestor.GetPropertyValue <int>("FemaleDinoID1"), femaleAncestor.GetPropertyValue <int>("FemaleDinoID2"))); creature.motherName = femaleAncestor.GetPropertyValue <string>("FemaleName"); creature.isBred = true; } ArkArrayStruct maleAncestors = creatureObject.GetPropertyValue <IArkArray, ArkArrayStruct>("DinoAncestorsMale"); StructPropertyList maleAncestor = (StructPropertyList)maleAncestors?.LastOrDefault(); if (maleAncestor != null) { creature.fatherGuid = Utils.ConvertArkIdToGuid(GameObjectExtensions.CreateDinoId( maleAncestor.GetPropertyValue <int>("MaleDinoID1"), maleAncestor.GetPropertyValue <int>("MaleDinoID2"))); creature.fatherName = maleAncestor.GetPropertyValue <string>("MaleName"); creature.isBred = true; } creature.colors = new int[6]; for (int i = 0; i < 6; i++) { creature.colors[i] = colorModulo(creatureObject.GetPropertyValue <ArkByteValue>("ColorSetIndices", i)?.ByteValue ?? 0); } bool isDead = creatureObject.GetPropertyValue <bool>("bIsDead"); if (isDead) { creature.status = CreatureStatus.Dead; // dead is always dead } if (!isDead && creature.status == CreatureStatus.Dead) { creature.status = CreatureStatus.Unavailable; // if found alive when marked dead, mark as unavailable } creature.recalculateAncestorGenerations(); creature.recalculateCreatureValues(levelStep); return(creature); }