Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Nov 12, 2023
2 parents 6d4d848 + 67f907f commit a393a91
Show file tree
Hide file tree
Showing 34 changed files with 2,412 additions and 2,096 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@
<Compile Include="utils\ColorModeColors.cs" />
<Compile Include="utils\Convert32.cs" />
<Compile Include="utils\Debouncer.cs" />
<Compile Include="utils\ExportFolderLocation.cs" />
<Compile Include="utils\ArkInstallationPath.cs" />
<Compile Include="utils\ExtensionMethods.cs" />
<Compile Include="utils\CreatureListSorter.cs" />
<Compile Include="utils\MessageBoxes.cs" />
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<value>False</value>
</setting>
<setting name="OCRApp" serializeAs="String">
<value>ShooterGame</value>
<value>ArkAscended</value>
</setting>
<setting name="soundStarving" serializeAs="String">
<value />
Expand Down
1 change: 0 additions & 1 deletion ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ public void GenerateCreatureName(Creature creature, int[] speciesTopLevels, int[
CreatureName = NamePattern.GenerateCreatureName(creature, _sameSpecies, speciesTopLevels, speciesLowestLevels, customReplacings, showDuplicateNameWarning, namingPatternIndex, false, colorsExisting: ColorAlreadyExistingInformation);
if (CreatureName.Length > Ark.MaxCreatureNameLength)
SetMessageLabelText?.Invoke($"The generated name is longer than {Ark.MaxCreatureNameLength} characters, the name will look like this in game:\r\n" + CreatureName.Substring(0, Ark.MaxCreatureNameLength), MessageBoxIcon.Error);
else SetMessageLabelText?.Invoke();
}

public void OpenNamePatternEditor(Creature creature, int[] speciesTopLevels, int[] speciesLowestLevels, Dictionary<string, string> customReplacings, int namingPatternIndex, Action<PatternEditor> reloadCallback)
Expand Down
38 changes: 22 additions & 16 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using ARKBreedingStats.Library;
using ARKBreedingStats.miscClasses;
using ARKBreedingStats.species;
using ARKBreedingStats.values;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -198,26 +197,33 @@ public void ExtractLevels(Species species, int level, StatIO[] statIOs, double l
if (withTEff) { StatsWithTE.Add(s); }

int minLW = 0;
int maxLW;
if (stats[s].IncPerWildLevel > 0)
int maxLW = 0;
if (species.CanLevelUpWildOrHaveMutations(s))
{
double multAffinityFactor = stats[s].MultAffinity;
if (PostTamed)
if (stats[s].IncPerWildLevel > 0)
{
// the multiplicative bonus is only multiplied with the TE if it is positive (i.e. negative boni won't get less bad if the TE is low)
if (multAffinityFactor > 0)
multAffinityFactor *= lowerTEBound;
multAffinityFactor += 1;
double multAffinityFactor = stats[s].MultAffinity;
if (PostTamed)
{
// the multiplicative bonus is only multiplied with the TE if it is positive (i.e. negative boni won't get less bad if the TE is low)
if (multAffinityFactor > 0)
multAffinityFactor *= lowerTEBound;
multAffinityFactor += 1;
}
else
multAffinityFactor = 1;

maxLW = (int)Math.Round(
((inputValue.Max / multAffinityFactor - (PostTamed ? stats[s].AddWhenTamed : 0)) /
statBaseValue - 1) / stats[s].IncPerWildLevel); // floor is too unprecise
}
else
multAffinityFactor = 1;
maxLW = (int)Math.Round(((inputValue.Max / multAffinityFactor - (PostTamed ? stats[s].AddWhenTamed : 0)) / statBaseValue - 1) / stats[s].IncPerWildLevel); // floor is too unprecise
}
else
{
minLW = -1;
maxLW = -1;
{
minLW = -1;
maxLW = -1;
}
}

if (maxLW > LevelWildSum) { maxLW = LevelWildSum; }

double maxLD = 0;
Expand Down
24 changes: 17 additions & 7 deletions ARKBreedingStats/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ private void NewCollection(bool resetCollection = false)
if (!resetCollection
&& UnsavedChanges()
&& CustomMessageBox.Show(Loc.S("Collection changed discard and new?"),
Loc.S("Discard changes?"), Loc.S("Discard changes and new"), buttonCancel: Loc.S("Cancel"), icon: MessageBoxIcon.Warning) != DialogResult.Yes
)
Loc.S("Discard changes?"), Loc.S("Discard changes and new"), buttonCancel: Loc.S("Cancel"),
icon: MessageBoxIcon.Warning) != DialogResult.Yes
)
{
return;
}
Expand All @@ -43,20 +44,28 @@ private void NewCollection(bool resetCollection = false)
var (statValuesLoaded, _) = LoadStatAndKibbleValues(applySettings: false);
if (!statValuesLoaded)
{
MessageBoxes.ShowMessageBox("Couldn't load stat values. Please redownload the application.", $"{Loc.S("error")} while loading the stat-values");
MessageBoxes.ShowMessageBox("Couldn't load stat values. Please redownload the application.",
$"{Loc.S("error")} while loading the stat-values");
}
}

if (_creatureCollection.serverMultipliers == null)
_creatureCollection.serverMultipliers = Values.V.serverMultipliersPresets.GetPreset(ServerMultipliersPresets.Official);
// use previously used multipliers again in the new file
ServerMultipliers oldMultipliers = _creatureCollection.serverMultipliers;
var oldMultipliers = _creatureCollection.serverMultipliers
?? Values.V.serverMultipliersPresets.GetPreset(ServerMultipliersPresets.Official);
var asaMode = _creatureCollection.Game == Ark.Asa;

_creatureCollection = new CreatureCollection
{
serverMultipliers = oldMultipliers,
ModList = new List<Mod>()
};

if (asaMode)
{
_creatureCollection.Game = Ark.Asa;
ReloadModValuesOfCollectionIfNeeded(true, false, false);
}

pedigree1.Clear();
breedingPlan1.Clear();
creatureInfoInputExtractor.Clear(true);
Expand Down
28 changes: 9 additions & 19 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ private void Form1_Load(object sender, EventArgs e)
// if no export folder is set, try to detect it
if ((Properties.Settings.Default.ExportCreatureFolders == null
|| Properties.Settings.Default.ExportCreatureFolders.Length == 0)
&& ExportFolderLocation.GetListOfExportFolders(
&& ArkInstallationPath.GetListOfExportFolders(
out (string path, string steamPlayerName)[] arkInstallFolders, out _))
{
var orderedList = ExportFolderLocation.OrderByNewestFileInFolders(arkInstallFolders.Select(l => (l.path, l)));
var orderedList = ArkInstallationPath.OrderByNewestFileInFolders(arkInstallFolders.Select(l => (l.path, l)));

Properties.Settings.Default.ExportCreatureFolders = orderedList
.Select(f => $"{f.steamPlayerName}||{f.path}").ToArray();
Expand Down Expand Up @@ -1990,23 +1990,8 @@ private void OpenSettingsDialog(SettingsTabPages page = SettingsTabPages.Unknown
if (_creatureCollection.Game != gameSettingBefore)
{
// ASA setting changed
var asaCurrentlyLoaded = _creatureCollection.modIDs?.Contains(Ark.Asa) == true;

if ((_creatureCollection.Game == Ark.Asa) ^ asaCurrentlyLoaded)
{
if (asaCurrentlyLoaded)
{
_creatureCollection.modIDs.Remove(Ark.Asa);
_creatureCollection.ModList.RemoveAll(m => m.id == Ark.Asa);
}
else
{
if (_creatureCollection.modIDs == null) _creatureCollection.modIDs = new List<string>();
_creatureCollection.modIDs.Insert(0, Ark.Asa);
}
_creatureCollection.modListHash = 0; // making sure the mod values are reevaluated
ReloadModValuesOfCollectionIfNeeded(!asaCurrentlyLoaded, false, false);
}
var loadAsa = gameSettingBefore != Ark.Asa;
ReloadModValuesOfCollectionIfNeeded(loadAsa, false, false);
}

ApplySettingsToValues();
Expand Down Expand Up @@ -3822,5 +3807,10 @@ private void CbLibraryInfoUseFilter_CheckedChanged(object sender, EventArgs e)
{
LibraryInfo.SetColorInfo(speciesSelector1.SelectedSpecies, CbLibraryInfoUseFilter.Checked ? (IList<Creature>)ApplyLibraryFilterSettings(_creatureCollection.creatures).ToArray() : _creatureCollection.creatures, CbLibraryInfoUseFilter.Checked, tlpLibraryInfo);
}

private void discordServerToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start(RepositoryInfo.DiscordServerInviteLink);
}
}
}
56 changes: 30 additions & 26 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private bool ExtractLevels(bool autoExtraction = false, bool statInputsHighPreci
numericUpDownImprintingBonusExtractor.ValueSave = (decimal)_extractor.ImprintingBonus * 100;
numericUpDownImprintingBonusExtractor_ValueChanged(null, null);

var possibleExtractionIssues = IssueNotes.Issue.None;
var possibleExtractionIssues = IssueNotes.Issue.CreatureLevel;
if (cbExactlyImprinting.Checked)
possibleExtractionIssues |= IssueNotes.Issue.ImprintingLocked;

Expand Down Expand Up @@ -443,7 +443,7 @@ private bool ExtractLevels(bool autoExtraction = false, bool statInputsHighPreci
labelTE.BackColor = Color.Transparent;
}

SetWildSpeedLevelAccordingToOthers();
SetWildUnknownLevelsAccordingToOthers();

lbSumDomSB.Text = _extractor.LevelDomSum.ToString();
ShowSumOfChosenLevels();
Expand Down Expand Up @@ -749,49 +749,53 @@ private void SetLevelCombination(int s, int i, bool validateCombination = false)
if (validateCombination)
{
SetUniqueTE();
SetWildSpeedLevelAccordingToOthers();
SetWildUnknownLevelsAccordingToOthers();
ShowSumOfChosenLevels();
}
}

/// <summary>
/// The wild speed level is calculated indirectly by using all unused stat-levels.
/// Some wild stat levels have no effect on the stat value, often that's speed or sometimes oxygen.
/// The wild levels of these ineffective stats can be calculated indirectly if there is only one of them.
/// </summary>
private void SetWildSpeedLevelAccordingToOthers()
private void SetWildUnknownLevelsAccordingToOthers()
{
// wild speed level is wildTotalLevels - determinedWildLevels. sometimes the oxygenlevel cannot be determined as well
bool unique = true;
// wild speed level is wildTotalLevels - determinedWildLevels. sometimes the oxygen level cannot be determined as well
var unknownLevelIndices = new List<int>();
int notDeterminedLevels = _statIOs[Stats.Torpidity].LevelWild;
for (int s = 0; s < Stats.StatsCount; s++)
{
if (s == Stats.SpeedMultiplier || s == Stats.Torpidity)
continue;
if (_statIOs[s].LevelWild >= 0)
if (s == Stats.Torpidity || !speciesSelector1.SelectedSpecies.UsesStat(s))
{
notDeterminedLevels -= _statIOs[s].LevelWild;
continue;
}
else

if (_statIOs[s].LevelWild < 0)
{
unique = false;
break;
unknownLevelIndices.Add(s);
continue;
}
notDeterminedLevels -= _statIOs[s].LevelWild;
}
if (unique)
{
// if all other stats are unique, set speedlevel
_statIOs[Stats.SpeedMultiplier].LevelWild = Math.Max(0, notDeterminedLevels);
_statIOs[Stats.SpeedMultiplier].BreedingValue = StatValueCalculation.CalculateValue(speciesSelector1.SelectedSpecies, Stats.SpeedMultiplier, _statIOs[Stats.SpeedMultiplier].LevelWild, 0, true, 1, 0);
}
else

switch (unknownLevelIndices.Count)
{
// if not all other levels are unique, set speed and not known levels to unknown
for (int s = 0; s < Stats.StatsCount; s++)
{
if (s == Stats.SpeedMultiplier || !_activeStats[s])
case 0:
// no unknown levels, nothing to do
return;
case 1:
// if all other stats are unique, set level
var statIndex = unknownLevelIndices[0];
_statIOs[statIndex].LevelWild = Math.Max(0, notDeterminedLevels);
_statIOs[statIndex].BreedingValue = StatValueCalculation.CalculateValue(speciesSelector1.SelectedSpecies, statIndex, _statIOs[statIndex].LevelWild, 0, true, 1, 0);
return;
default:
// if not all other levels are unique, set the indifferent stats to unknown
foreach (var s in unknownLevelIndices)
{
_statIOs[s].LevelWild = -1;
}
}
return;
}
}

Expand Down
Loading

0 comments on commit a393a91

Please sign in to comment.