private void PbCreatureColorsExtractor_Click(object sender, EventArgs e) { var creature = new Creature { Species = speciesSelector1.SelectedSpecies, levelsWild = GetCurrentWildLevels(true), levelsDom = GetCurrentDomLevels(true) }; creature.tamingEff = _extractor.UniqueTamingEffectiveness(); creature.isBred = rbBredExtractor.Checked; creature.imprintingBonus = _extractor.ImprintingBonus; creatureInfoInputExtractor.SetCreatureData(creature); creature.RecalculateAncestorGenerations(); creature.RecalculateNewMutations(); creature.RecalculateCreatureValues(CreatureCollection.CurrentCreatureCollection.wildLevelStep); creature.ExportInfoGraphicToClipboard(CreatureCollection.CurrentCreatureCollection); }
private void pictureBoxColorRegionsTester_Click(object sender, EventArgs e) { var creature = new Creature { Species = speciesSelector1.SelectedSpecies, levelsWild = GetCurrentWildLevels(false), levelsDom = GetCurrentDomLevels(false), tamingEff = TamingEffectivenessTester, isBred = rbBredTester.Checked, imprintingBonus = (double)numericUpDownImprintingBonusTester.Value / 100 }; creatureInfoInputTester.SetCreatureData(creature); creature.RecalculateAncestorGenerations(); creature.RecalculateNewMutations(); creature.RecalculateCreatureValues(CreatureCollection.CurrentCreatureCollection.wildLevelStep); creature.ExportInfoGraphicToClipboard(CreatureCollection.CurrentCreatureCollection); }
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[Values.STATS_COUNT], null, 100, true, levelStep: levelStep); Creature crW = new Creature(currentSpecies, "", "", "", 0, new int[Values.STATS_COUNT], 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 < Values.STATS_COUNT; s++) { if (s == (int)StatNames.Torpidity) { continue; } 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] = StatValueCalculation.CalculateValue(currentSpecies, 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] = StatValueCalculation.CalculateValue(currentSpecies, 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 *= probabilityHigherLevel; } } crB.levelsWild[(int)StatNames.Torpidity] = crB.levelsWild.Sum(); crW.levelsWild[(int)StatNames.Torpidity] = 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)}%"; // set probability barChart offspringPossibilities1.Calculate(currentSpecies, mother.levelsWild, father.levelsWild); // highlight parents int hiliId = 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) { if (!Values.V.TryGetSpeciesByClassName(creatureObject.ClassString, out Species species)) { // species is unknown, creature cannot be imported. // use name-field to temporarily save the unknown classString to display in a messagebox return(new Creature { name = creatureObject.ClassString }); } GameObject statusObject = creatureObject.CharacterStatusComponent(); // error while deserializing that creature if (statusObject == null) { return(null); } string imprinterName = creatureObject.GetPropertyValue <string>("ImprinterName"); string owner = string.IsNullOrWhiteSpace(imprinterName) ? creatureObject.GetPropertyValue <string>("TamerString") : imprinterName; int[] wildLevels = Enumerable.Repeat(-1, Values.STATS_COUNT).ToArray(); // -1 is unknown int[] tamedLevels = new int[Values.STATS_COUNT]; for (int i = 0; i < Values.STATS_COUNT; 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 < Values.STATS_COUNT; i++) { tamedLevels[i] = statusObject.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsAppliedTamed", i)?.ByteValue ?? 0; } 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(species, 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"), flags = creatureObject.GetPropertyValue <bool>("bNeutered") ? CreatureFlags.Neutered : CreatureFlags.None }; // If it's a baby and still growing, work out growingUntil if (creatureObject.GetPropertyValue <bool>("bIsBaby") || !creatureObject.GetPropertyValue <bool>("bIsBaby") && !string.IsNullOrWhiteSpace(imprinterName)) { double maturationTime = species.breeding?.maturationTimeAdjusted ?? 0; float tamedTime = _gameTime - (float)creatureObject.GetPropertyValue <double>("TamedAtTime"); if (tamedTime < maturationTime - 120) // there seems to be a slight offset of one of these saved values, so don't display a creature as being in cooldown if it is about to leave it in the next 2 minutes { 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(Utils.ConvertArkIdsToLongArkId( 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] = creatureObject.GetPropertyValue <ArkByteValue>("ColorSetIndices", i)?.ByteValue ?? 0; } bool isDead = creatureObject.GetPropertyValue <bool>("bIsDead"); if (isDead) { creature.Status = CreatureStatus.Dead; // dead is always dead } if (creatureObject.IsCryo) { creature.Status = CreatureStatus.Cryopod; } creature.RecalculateCreatureValues(levelStep); return(creature); }