Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Mar 2, 2024
2 parents 4412144 + 681fea6 commit 61333e5
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 51 deletions.
86 changes: 51 additions & 35 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ private Creature ImportExportGunFiles(string[] filePaths, out bool creatureAdded
{
multipliersImportSuccessful = ImportExportGun.SetServerMultipliers(_creatureCollection, esm, Path.GetFileNameWithoutExtension(filePath));
serverImportResult = serverImportResultTemp;
continue;
if (multipliersImportSuccessful == true)
continue;
}

importFailedCounter++;
Expand Down Expand Up @@ -896,28 +897,46 @@ private Creature ImportExportGunFiles(string[] filePaths, out bool creatureAdded
: c, oldName: alreadyExistingCreature?.name)).ToArray();

lastAddedCreature = newCreatures.LastOrDefault();
if (lastAddedCreature != null)
var creatureWasAdded = lastAddedCreature != null;
if (creatureWasAdded)
{
creatureAdded = true;
// calculate level status of last added creature
DetermineLevelStatusAndSoundFeedback(lastAddedCreature, playImportSound);
}

_creatureCollection.MergeCreatureList(newCreatures, true);
UpdateCreatureParentLinkingSort(false);
_creatureCollection.MergeCreatureList(newCreatures, true);
UpdateCreatureParentLinkingSort(false);

// apply naming pattern if needed. This can only be done after parent linking to get correct name pattern values related to parents
Species lastSpecies = null;
Creature[] creaturesOfSpecies = null;
foreach (var c in persistentCreaturesAndOldName)
{
copiedNameToClipboard = SetNameOfImportedCreature(c.creature, lastSpecies == c.creature.Species ? creaturesOfSpecies : null, out creaturesOfSpecies, new Creature(c.creature.Species, c.oldName), totalCreatureCount);
lastSpecies = c.creature.Species;
if (c.oldName == null) totalCreatureCount++; // if creature was added, increase total count for name pattern
}

UpdateListsAfterCreaturesAdded(Properties.Settings.Default.AutoImportGotoLibraryAfterSuccess);

// apply naming pattern if needed. This can only be done after parent linking to get correct name pattern values related to parents
Species lastSpecies = null;
Creature[] creaturesOfSpecies = null;
foreach (var c in persistentCreaturesAndOldName)
if (Properties.Settings.Default.AutoImportGotoLibraryAfterSuccess)
{
tabControlMain.SelectedTab = tabPageLibrary;
if (listBoxSpeciesLib.SelectedItem != null &&
listBoxSpeciesLib.SelectedItem != lastAddedCreature.Species)
listBoxSpeciesLib.SelectedItem = lastAddedCreature.Species;
SelectCreatureInLibrary(lastAddedCreature);
}
else
{
EditCreatureInTester(lastAddedCreature);
}
}
else if (multipliersImportSuccessful == true)
{
copiedNameToClipboard = SetNameOfImportedCreature(c.creature, lastSpecies == c.creature.Species ? creaturesOfSpecies : null, out creaturesOfSpecies, new Creature(c.creature.Species, c.oldName), totalCreatureCount);
lastSpecies = c.creature.Species;
if (c.oldName == null) totalCreatureCount++; // if creature was added, increase total count for name pattern
SetCollectionChanged(true);
}

UpdateListsAfterCreaturesAdded();

var resultText = (importedCounter > 0 || importFailedCounter > 0
? $"Imported {importedCounter} creatures successfully.{(importFailedCounter > 0 ? $"Failed to import {importFailedCounter} files. Last error:{Environment.NewLine}{lastError}" : $"{Environment.NewLine}Last file: {lastCreatureFilePath}")}"
: string.Empty)
Expand All @@ -927,24 +946,16 @@ private Creature ImportExportGunFiles(string[] filePaths, out bool creatureAdded
+ serverImportResult);

SetMessageLabelText(resultText, importFailedCounter > 0 || multipliersImportSuccessful == false ? MessageBoxIcon.Error : MessageBoxIcon.Information, lastCreatureFilePath);

if (lastAddedCreature != null)
{
tabControlMain.SelectedTab = tabPageLibrary;
if (listBoxSpeciesLib.SelectedItem != null &&
listBoxSpeciesLib.SelectedItem != lastAddedCreature.Species)
listBoxSpeciesLib.SelectedItem = lastAddedCreature.Species;
_ignoreNextMessageLabel = true; // keep import message
SelectCreatureInLibrary(lastAddedCreature);
}
if (creatureWasAdded)
_ignoreNextMessageLabel = true; // ignore message of selected creature (is shown after some delay / debouncing)

return alreadyExistingCreature;
}

/// <summary>
/// Call after creatures were added (imported) to the library. Updates parent linkings, creature lists, set collection as changed
/// </summary>
private void UpdateCreatureParentLinkingSort(bool updateLists = true)
private void UpdateCreatureParentLinkingSort(bool updateLists = true, bool goToLibraryTab = false)
{
UpdateParents(_creatureCollection.creatures);

Expand All @@ -956,19 +967,19 @@ private void UpdateCreatureParentLinkingSort(bool updateLists = true)
UpdateIncubationParents(_creatureCollection);

if (updateLists)
UpdateListsAfterCreaturesAdded();
UpdateListsAfterCreaturesAdded(goToLibraryTab);
}

/// <summary>
/// Updates lists after creatures were added, recalculates library info, e.g. top stats.
/// </summary>
private void UpdateListsAfterCreaturesAdded()
private void UpdateListsAfterCreaturesAdded(bool goToLibraryTab)
{
// update UI
SetCollectionChanged(true);
UpdateCreatureListings();

if (_creatureCollection.creatures.Any())
if (goToLibraryTab && _creatureCollection.creatures.Any())
tabControlMain.SelectedTab = tabPageLibrary;

// reapply last sorting
Expand Down Expand Up @@ -1038,19 +1049,24 @@ private void AsbServerDataSent(ProgressReportAsbServer data)
DetermineLevelStatusAndSoundFeedback(creature, Properties.Settings.Default.PlaySoundOnAutoImport);

_creatureCollection.MergeCreatureList(new[] { creature }, true);
UpdateCreatureParentLinkingSort();
var gotoLibraryTab = Properties.Settings.Default.AutoImportGotoLibraryAfterSuccess;
UpdateCreatureParentLinkingSort(goToLibraryTab: gotoLibraryTab);

if (resultText == null)
resultText = $"Received creature from server: {creature}";

SetMessageLabelText(resultText, MessageBoxIcon.Information);

tabControlMain.SelectedTab = tabPageLibrary;
if (listBoxSpeciesLib.SelectedItem != null &&
listBoxSpeciesLib.SelectedItem != creature.Species)
listBoxSpeciesLib.SelectedItem = creature.Species;
_ignoreNextMessageLabel = true;
SelectCreatureInLibrary(creature);
if (gotoLibraryTab)
{
tabControlMain.SelectedTab = tabPageLibrary;
if (listBoxSpeciesLib.SelectedItem != null &&
listBoxSpeciesLib.SelectedItem != creature.Species)
listBoxSpeciesLib.SelectedItem = creature.Species;

_ignoreNextMessageLabel = true;
SelectCreatureInLibrary(creature);
}
return;
}

Expand Down
44 changes: 41 additions & 3 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,51 @@ private bool ExtractLevels(bool autoExtraction = false, bool statInputsHighPreci
ClearAll(_clearExtractionCreatureData);
var mutagenApplied = possiblyMutagenApplied || creatureInfoInputExtractor.CreatureFlags.HasFlag(CreatureFlags.MutagenApplied);
var bred = rbBredExtractor.Checked;
bool imprintingBonusChanged = false;

_extractor.ExtractLevels(speciesSelector1.SelectedSpecies, (int)numericUpDownLevel.Value, _statIOs,
for (int i = 0; i < 2; i++)
{
_extractor.ExtractLevels(speciesSelector1.SelectedSpecies, (int)numericUpDownLevel.Value, _statIOs,
(double)numericUpDownLowerTEffBound.Value / 100, (double)numericUpDownUpperTEffBound.Value / 100,
rbTamedExtractor.Checked, bred,
(double)numericUpDownImprintingBonusExtractor.Value / 100, !cbExactlyImprinting.Checked,
_creatureCollection.allowMoreThanHundredImprinting, _creatureCollection.serverMultipliers.BabyImprintingStatScaleMultiplier,
_creatureCollection.considerWildLevelSteps, _creatureCollection.wildLevelStep, statInputsHighPrecision, mutagenApplied, out bool imprintingBonusChanged);
_creatureCollection.allowMoreThanHundredImprinting,
_creatureCollection.serverMultipliers.BabyImprintingStatScaleMultiplier,
_creatureCollection.considerWildLevelSteps, _creatureCollection.wildLevelStep,
statInputsHighPrecision, mutagenApplied, out imprintingBonusChanged);

// wild claimed babies look like bred creatures in the export files, but have to be considered tamed when imported
// if the extraction of an exported creature doesn't work, try with tamed settings
if (bred && numericUpDownImprintingBonusExtractor.Value == 0 && statInputsHighPrecision)
{
var someStatsHaveNoResults = false;
var onlyStatsWithTEHaveNoResults = true;
// check if only stats affected by TE have no result
for (int s = 0; s < Stats.StatsCount; s++)
{
if (_extractor.Results[s].Count == 0)
{
someStatsHaveNoResults = true;
if (!_extractor.StatsWithTE.Contains(s))
{
// the issue is not related to TE, so it's a different issue
onlyStatsWithTEHaveNoResults = false;
}
}
}

if (!someStatsHaveNoResults || !onlyStatsWithTEHaveNoResults) break;

// issue could be a wild claimed baby that should be considered tamed
_extractor.Clear();
rbTamedExtractor.Checked = true;
bred = false;

continue;
}

break;
}

numericUpDownImprintingBonusExtractor.ValueSave = (decimal)_extractor.ImprintingBonus * 100;
numericUpDownImprintingBonusExtractor_ValueChanged(null, null);
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.importSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private async Task<string> RunSavegameImport(ATImportFileLocation atImportFileLo
await ImportSavegame.ImportCollectionFromSavegame(_creatureCollection, workingCopyFilePath,
atImportFileLocation.ServerName);

UpdateCreatureParentLinkingSort();
UpdateCreatureParentLinkingSort(goToLibraryTab: true);

// if unknown mods are used in the savegame-file and the user wants to load the missing mod-files, do it
if (_creatureCollection.ModValueReloadNeeded
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.60.2.1")]
[assembly: AssemblyFileVersion("0.60.3.0")]
[assembly: NeutralResourcesLanguage("en")]

2 changes: 1 addition & 1 deletion ARKBreedingStats/SpeciesSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void InitializeSpeciesImages(List<Species> species)
s.name.Contains("Polar") ? creatureColorsPolar : creatureColors
//colors
);
//if (!imgExists && !speciesWOImage.Contains(s.name)) speciesWOImage.Add(s.name);
//if (!imgExists && s.IsDomesticable && !speciesWOImage.Contains(s.name)) speciesWOImage.Add(s.name);
if (!imgExists || _iconIndices.Contains(speciesListName)) continue;

try
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ARK Smart Breeding": {
"Id": "ARK Smart Breeding",
"Category": "main",
"version": "0.60.2.1"
"version": "0.60.3.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
26 changes: 22 additions & 4 deletions ARKBreedingStats/importExportGun/ImportExportGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public static Creature LoadCreatureFromJson(string jsonText, string resultSoFar,
return null;
}

if (string.IsNullOrEmpty(exportedCreature.BlueprintPath))
{
resultText = "file contains no blueprint path, it's probably not a creature file"; // could be a server multipliers file
return null;
}

serverMultipliersHash = exportedCreature.ServerMultipliersHash;

return ConvertExportGunToCreature(exportedCreature, out resultText);
Expand Down Expand Up @@ -113,9 +119,15 @@ private static Creature ConvertExportGunToCreature(ExportGunCreatureFile ec, out
&& ec.OwningPlayerID == 0
;

var c = new Creature(species, ec.DinoName, !string.IsNullOrEmpty(ec.OwningPlayerName) ? ec.OwningPlayerName : !string.IsNullOrEmpty(ec.ImprinterName) ? ec.ImprinterName : ec.TamerString,
ec.TribeName, species.noGender ? Sex.Unknown : ec.IsFemale ? Sex.Female : Sex.Male, wildLevels, domLevels, mutLevels,
isWild ? -3 : ec.TameEffectiveness, !string.IsNullOrEmpty(ec.ImprinterName), ec.DinoImprintingQuality,
var isBred = !string.IsNullOrEmpty(ec.ImprinterName)
|| (ec.DinoImprintingQuality > 0 && ec.TameEffectiveness > 0.9999);

var owner = !string.IsNullOrEmpty(ec.OwningPlayerName) ? ec.OwningPlayerName
: !string.IsNullOrEmpty(ec.ImprinterName) ? ec.ImprinterName
: ec.TamerString;

var c = new Creature(species, ec.DinoName, owner, ec.TribeName, species.noGender ? Sex.Unknown : ec.IsFemale ? Sex.Female : Sex.Male,
wildLevels, domLevels, mutLevels, isWild ? -3 : ec.TameEffectiveness, isBred, ec.DinoImprintingQuality,
CreatureCollection.CurrentCreatureCollection?.wildLevelStep)
{
ArkId = arkId,
Expand Down Expand Up @@ -304,7 +316,13 @@ public static ExportGunServerFile ReadServerMultipliersFromJson(string jsonText,

internal static bool SetServerMultipliers(CreatureCollection cc, ExportGunServerFile esm, string newServerMultipliersHash)
{
if (cc == null) return false;
if (cc == null
|| esm?.TameAdd == null
|| esm.TameAff == null
|| esm.WildLevel == null
|| esm.TameLevel == null
)
return false; // invalid server multipliers

const int roundToDigits = 6;

Expand Down
52 changes: 51 additions & 1 deletion ARKBreedingStats/json/values/ASA-values.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "32.11.468629",
"version": "32.11.468631",
"format": "1.15-asa",
"mod": {
"id": "ASA",
Expand Down Expand Up @@ -1561,6 +1561,56 @@
{
"blueprintPath": "/Game/PrimalEarth/Dinos/Yutyrannus/Yutyrannus_Character_BP.Yutyrannus_Character_BP",
"skipWildLevelStats": 512
},
{
"name": "Gigantoraptor",
"blueprintPath": "/Gigantoraptor/Gigantoraptor/Gigantoraptor_Character_BP.Gigantoraptor_Character_BP",
"skipWildLevelStats": 512,
"fullStatsRaw": [
[ 770, 0.2, 0.27, 0.5, 0 ],
[ 350, 0.1, 0.1, 0, 0 ],
[ 950, 0.06, 0, 0.5, 0 ],
[ 150, 0.1, 0.1, 0, 0 ],
[ 3000, 0.1, 0.1, 0, 0.15 ],
null,
null,
[ 320, 0.02, 0.04, 0, 0 ],
[ 1, 0.05, 0.1, 0.5, 0.4 ],
[ 1, 0, 0.01, 0, 0 ],
null,
null
],
"colors": [
{ "name": "Body Main" },
{ "name": "Neck Main" },
{ "name": "Feather Tips" },
{ "name": "Feather Highlights" },
{ "name": "Legs And Beak" },
{ "name": "Feather Pattern" }
],
"immobilizedBy": [ "Chain Bola", "Large Bear Trap", "Plant Species Y" ],
"breeding": {
"gestationTime": 0,
"incubationTime": 5999.52004,
"eggTempMin": 26,
"eggTempMax": 32,
"maturationTime": 416666.667,
"matingCooldownMin": 64800,
"matingCooldownMax": 172800
},
"taming": {
"nonViolent": false,
"violent": true,
"tamingIneffectiveness": 0.06,
"affinityNeeded0": 6800,
"affinityIncreasePL": 160,
"torporDepletionPS0": 2.8333332,
"foodConsumptionBase": 0.002314,
"foodConsumptionMult": 180.0634,
"babyFoodConsumptionMult": 510
},
"TamedBaseHealthMultiplier": 1,
"displayedStats": 927
}
],
"dyeStartIndex": 128,
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/json/values/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
"mod": { "id": "919470289", "tag": "SSFlyer", "title": "SSFlyer" }
},
"ASA-values.json": {
"version": "32.11.468629",
"version": "32.11.468631",
"format": "1.15-asa",
"mod": { "id": "ASA", "tag": "", "title": "Ark: Survival Ascended", "shortTitle": "ASA" }
},
Expand Down
4 changes: 2 additions & 2 deletions ARKBreedingStats/library/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ public bool MergeCreatureList(IEnumerable<Creature> creaturesToMerge, bool addPr
string onlyThisSpeciesBlueprintAdded = null;
bool onlyOneSpeciesAdded = true;

var guidDict = creatures.ToDictionary(c => c.guid);

if (removeCreatures != null)
{
creaturesWereAddedOrUpdated = creatures.RemoveAll(c => removeCreatures.Contains(c.guid)) > 0;
}

var guidDict = creatures.ToDictionary(c => c.guid);

foreach (Creature creatureNew in creaturesToMerge)
{
if (!addPreviouslyDeletedCreatures && DeletedCreatureGuids != null && DeletedCreatureGuids.Contains(creatureNew.guid)) continue;
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/uiControls/LibraryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void AddParagraph(string text, string suffixForPlainText = null, bool bold = fal
for (int i = 0; i < Ark.ColorRegionCount; i++)
{
if (!species.EnabledColorRegions[i]) continue;
AddParagraph($"Color region {i}: {species.colors[i]?.name}", bold: true, relativeFontSize: 1.1f);
AddParagraph($"Color region {i}: {species.colors?[i]?.name}", bold: true, relativeFontSize: 1.1f);
var colorsExist = ColorsExistPerRegion[i].Count;
AddParagraph($"{colorsExist} color id{(colorsExist != 1 ? "s" : string.Empty)} available in your library:");
AddParagraph(CreateNumberRanges(ColorsExistPerRegion[i]));
Expand Down

0 comments on commit 61333e5

Please sign in to comment.