Skip to content

Commit

Permalink
fixed raising food calculation (#1301), added TamedDinoCharacterFoodD…
Browse files Browse the repository at this point in the history
…rainMultiplier
  • Loading branch information
cadon committed Jan 29, 2023
1 parent 2e8a069 commit fdf4d1a
Show file tree
Hide file tree
Showing 7 changed files with 3,057 additions and 2,939 deletions.
14 changes: 12 additions & 2 deletions ARKBreedingStats/raising/RaisingControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ private void FoodAmountNeeded()
if (_selectedSpecies.taming.eats?.Any() == true
&& uiControls.Trough.FoodAmountFromUntil(_selectedSpecies,
Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier,
Values.V.currentServerMultipliers.DinoCharacterFoodDrainMultiplier,
Values.V.currentServerMultipliers.TamedDinoCharacterFoodDrainMultiplier,
0, 1, out double totalFood))
{
var babyPhaseFoodValid = uiControls.Trough.FoodAmountFromUntil(_selectedSpecies,
Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier,
Values.V.currentServerMultipliers.DinoCharacterFoodDrainMultiplier,
Values.V.currentServerMultipliers.TamedDinoCharacterFoodDrainMultiplier,
0, .1, out double babyPhaseFood);

if (!string.IsNullOrEmpty(_lastSelectedFood))
Expand Down Expand Up @@ -243,12 +247,18 @@ private void UpdateMaturationProgress()
if (foodValue == 0) return;

if (uiControls.Trough.FoodAmountFromUntil(_selectedSpecies,
Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier, maturation, 0.1,
Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier,
Values.V.currentServerMultipliers.DinoCharacterFoodDrainMultiplier,
Values.V.currentServerMultipliers.TamedDinoCharacterFoodDrainMultiplier,
maturation, 0.1,
out var foodAmount))
labelAmountFoodBaby.Text = $"{Math.Ceiling(foodAmount / foodValue)} {_lastSelectedFood} ({foodAmount:0.#} food units)";

if (uiControls.Trough.FoodAmountFromUntil(_selectedSpecies,
Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier, maturation, 1,
Values.V.currentServerMultipliers.BabyFoodConsumptionSpeedMultiplier,
Values.V.currentServerMultipliers.DinoCharacterFoodDrainMultiplier,
Values.V.currentServerMultipliers.TamedDinoCharacterFoodDrainMultiplier,
maturation, 1,
out foodAmount))
labelAmountFoodAdult.Text = $"{Math.Ceiling(foodAmount / foodValue)} {_lastSelectedFood} ({foodAmount:0.#} food units)";
}
Expand Down
5,914 changes: 2,992 additions & 2,922 deletions ARKBreedingStats/settings/Settings.Designer.cs

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion ARKBreedingStats/settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private void InitializeData()
}
nudTamingSpeed.NeutralNumber = 1;
nudDinoCharacterFoodDrain.NeutralNumber = 1;
nudTamedDinoCharacterFoodDrain.NeutralNumber = 1;
nudMatingInterval.NeutralNumber = 1;
nudMatingSpeed.NeutralNumber = 1;
nudEggHatchSpeed.NeutralNumber = 1;
Expand All @@ -105,6 +106,7 @@ private void InitializeData()
// event
nudTamingSpeedEvent.NeutralNumber = 1.5M;
nudDinoCharacterFoodDrainEvent.NeutralNumber = 1;
nudTamedDinoCharacterFoodDrainEvent.NeutralNumber = 1;
nudMatingIntervalEvent.NeutralNumber = 1;
nudEggHatchSpeedEvent.NeutralNumber = 1;
nudBabyMatureSpeedEvent.NeutralNumber = 1;
Expand Down Expand Up @@ -215,6 +217,7 @@ private void LoadSettings(CreatureCollection cc)
nudBabyImprintAmount.ValueSave = (decimal)multipliers.BabyImprintAmountMultiplier;
nudTamingSpeed.ValueSave = (decimal)multipliers.TamingSpeedMultiplier;
nudDinoCharacterFoodDrain.ValueSave = (decimal)multipliers.DinoCharacterFoodDrainMultiplier;
nudTamedDinoCharacterFoodDrain.ValueSave = (decimal)multipliers.TamedDinoCharacterFoodDrainMultiplier;
nudBabyFoodConsumptionSpeed.ValueSave = (decimal)multipliers.BabyFoodConsumptionSpeedMultiplier;
#endregion
#region event-multiplier
Expand All @@ -223,6 +226,7 @@ private void LoadSettings(CreatureCollection cc)
nudBabyImprintAmountEvent.ValueSave = (decimal)multipliers.BabyImprintAmountMultiplier;
nudTamingSpeedEvent.ValueSave = (decimal)multipliers.TamingSpeedMultiplier;
nudDinoCharacterFoodDrainEvent.ValueSave = (decimal)multipliers.DinoCharacterFoodDrainMultiplier;
nudTamedDinoCharacterFoodDrainEvent.ValueSave = (decimal)multipliers.TamedDinoCharacterFoodDrainMultiplier;
nudMatingIntervalEvent.ValueSave = (decimal)multipliers.MatingIntervalMultiplier;
nudEggHatchSpeedEvent.ValueSave = (decimal)multipliers.EggHatchSpeedMultiplier;
nudBabyMatureSpeedEvent.ValueSave = (decimal)multipliers.BabyMatureSpeedMultiplier;
Expand Down Expand Up @@ -432,7 +436,7 @@ private void SaveSettings()
}

// Torpidity is handled differently by the game, IwM has no effect. Set IwM to 1.
// Also see https://github.com/cadon/ARKStatsExtractor/issues/942 for more infos about this.
// See https://github.com/cadon/ARKStatsExtractor/issues/942 for more infos about this.
_cc.serverMultipliers.statMultipliers[Stats.Torpidity][3] = 1;

_cc.singlePlayerSettings = cbSingleplayerSettings.Checked;
Expand All @@ -447,6 +451,7 @@ private void SaveSettings()
#region non-event-multiplier
_cc.serverMultipliers.TamingSpeedMultiplier = (double)nudTamingSpeed.Value;
_cc.serverMultipliers.DinoCharacterFoodDrainMultiplier = (double)nudDinoCharacterFoodDrain.Value;
_cc.serverMultipliers.TamedDinoCharacterFoodDrainMultiplier = (double)nudTamedDinoCharacterFoodDrain.Value;
_cc.serverMultipliers.MatingSpeedMultiplier = (double)nudMatingSpeed.Value;
_cc.serverMultipliers.MatingIntervalMultiplier = (double)nudMatingInterval.Value;
_cc.serverMultipliers.EggHatchSpeedMultiplier = (double)nudEggHatchSpeed.Value;
Expand All @@ -461,6 +466,7 @@ private void SaveSettings()
if (_cc.serverMultipliersEvents == null) _cc.serverMultipliersEvents = new ServerMultipliers();
_cc.serverMultipliersEvents.TamingSpeedMultiplier = (double)nudTamingSpeedEvent.Value;
_cc.serverMultipliersEvents.DinoCharacterFoodDrainMultiplier = (double)nudDinoCharacterFoodDrainEvent.Value;
_cc.serverMultipliersEvents.TamedDinoCharacterFoodDrainMultiplier = (double)nudTamedDinoCharacterFoodDrainEvent.Value;
_cc.serverMultipliersEvents.MatingIntervalMultiplier = (double)nudMatingIntervalEvent.Value;
_cc.serverMultipliersEvents.EggHatchSpeedMultiplier = (double)nudEggHatchSpeedEvent.Value;
_cc.serverMultipliersEvents.BabyCuddleIntervalMultiplier = (double)nudBabyCuddleIntervalEvent.Value;
Expand Down Expand Up @@ -757,6 +763,7 @@ void ParseAndSetStatMultiplier(int multiplierIndex, string regexPattern)
ParseAndSetValue(nudBabyImprintAmount, @"BabyImprintAmountMultiplier ?= ?(\d*\.?\d+)");
ParseAndSetValue(nudBabyCuddleInterval, @"BabyCuddleIntervalMultiplier ?= ?(\d*\.?\d+)");
ParseAndSetValue(nudBabyFoodConsumptionSpeed, @"BabyFoodConsumptionSpeedMultiplier ?= ?(\d*\.?\d+)");
ParseAndSetValue(nudTamedDinoCharacterFoodDrain, @"TamedDinoCharacterFoodDrainMultiplier ?= ?(\d*\.?\d+)");

ParseAndSetCheckbox(cbSingleplayerSettings, @"bUseSingleplayerSettings ?= ?(true|false)");
ParseAndSetValue(nudMaxServerLevel, @"DestroyTamesOverLevelClamp ?= ?(\d+)");
Expand Down Expand Up @@ -989,6 +996,7 @@ private void ApplyMultiplierPreset(ServerMultipliers sm, bool onlyStatMultiplier
{
nudTamingSpeed.ValueSave = (decimal)sm.TamingSpeedMultiplier;
nudDinoCharacterFoodDrain.ValueSave = (decimal)sm.DinoCharacterFoodDrainMultiplier;
nudTamedDinoCharacterFoodDrain.ValueSave = (decimal)sm.TamedDinoCharacterFoodDrainMultiplier;
nudEggHatchSpeed.ValueSave = (decimal)sm.EggHatchSpeedMultiplier;
nudBabyMatureSpeed.ValueSave = (decimal)sm.BabyMatureSpeedMultiplier;
nudBabyImprintingStatScale.ValueSave = (decimal)sm.BabyImprintingStatScaleMultiplier;
Expand Down
24 changes: 24 additions & 0 deletions ARKBreedingStats/settings/Settings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ You can also select the text of the settings and drag&&drop the selectio
<metadata name="aTImportFileLocationBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="dgvFileLocation_Change.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ImportWithQuickImport.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvFileLocation_Delete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="aTImportFileLocationBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="label24.Text" xml:space="preserve">
<value>The creature data can be directly imported from the save-game, if you have access to that. This is also possible via an ftp-adress.
If you set the according files below, you can start the process automatically from the file-menu.</value>
Expand All @@ -149,6 +161,18 @@ If you set the according files below, you can start the process automatically fr
<metadata name="aTExportFolderLocationsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>262, 17</value>
</metadata>
<metadata name="dgvExportFolderChange.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvExportFolderDelete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvExportMakeDefault.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="aTExportFolderLocationsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>262, 17</value>
</metadata>
<data name="label25.Text" xml:space="preserve">
<value>In ARK you can export a creature (hold use while looking at a creature, then choose "Options" - "Export" from the wheel).
Note: Parents and the mutations count are only exported and imported if you have opened the ancestor tab of the creature before the export!
Expand Down
4 changes: 4 additions & 0 deletions ARKBreedingStats/species/TamingData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public class TamingData
/// </summary>
public double babyFoodConsumptionMult;
/// <summary>
/// Extra multiplier for food consumption once a creature is mature. Only few species use this, e.g. Giganotosaurus, Carcharodontosaurus, Titanosaur and Titans.
/// </summary>
public double adultFoodConsumptionMult = 1;
/// <summary>
/// Factor for affinity if tamed awake.
/// </summary>
public double wakeAffinityMult;
Expand Down
24 changes: 11 additions & 13 deletions ARKBreedingStats/uiControls/Trough.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ARKBreedingStats.species;
using System.Collections.Generic;
using System;
using ARKBreedingStats.species;

namespace ARKBreedingStats.uiControls
{
Expand Down Expand Up @@ -30,28 +30,26 @@ public class Trough
/// <summary>
/// Calculates the needed food from a specific maturation to a specific maturation.
/// </summary>
public static bool FoodAmountFromUntil(Species species, double babyFoodConsumptionSpeedMultiplier, double currentMaturation, double untilMaturation, out double totalFood)
public static bool FoodAmountFromUntil(Species species, double babyFoodConsumptionSpeedMultiplier, double dinoFoodDrainMultiplier, double tamedDinoFoodDrainMultiplier, double fromMaturation, double untilMaturation, out double totalFood)
{
totalFood = 0;
if (currentMaturation == untilMaturation) return true;
if (species?.taming == null || species.breeding == null || currentMaturation > untilMaturation || untilMaturation > 1) return false;
if (fromMaturation == untilMaturation) return true;
if (species?.taming == null || species.breeding == null || fromMaturation > untilMaturation || untilMaturation > 1) return false;

// food rate in hunger units/s
// max food rate at maturation 0 %
var maxFoodRate = species.taming.foodConsumptionBase * species.taming.babyFoodConsumptionMult * babyFoodConsumptionSpeedMultiplier;
const double baseMinFoodRate = 0.000155; // taken from crumplecorn
// min food rate at maturation 100 %
var minFoodRate = baseMinFoodRate * species.taming.babyFoodConsumptionMult * babyFoodConsumptionSpeedMultiplier;
var minFoodRate = species.taming.foodConsumptionBase * dinoFoodDrainMultiplier * tamedDinoFoodDrainMultiplier;
// max food rate at maturation 0 %
var maxFoodRate = minFoodRate * species.taming.babyFoodConsumptionMult * babyFoodConsumptionSpeedMultiplier;
var foodRateDecay = minFoodRate - maxFoodRate;

// to get the current food rate for a maturation value: maxFoodRate + maturation * foodRateDecay
var foodRateStart = maxFoodRate + currentMaturation * foodRateDecay;
var foodRateStart = maxFoodRate + fromMaturation * foodRateDecay;
var foodRateEnd = maxFoodRate + untilMaturation * foodRateDecay;

// calculate area of rectangle and triangle on top to get the total food needed
// assuming foodRateStart > foodRateEnd
totalFood = species.breeding.maturationTimeAdjusted * ((untilMaturation - currentMaturation) * (foodRateEnd + 0.5 * (foodRateStart - foodRateEnd)));

totalFood = species.breeding.maturationTimeAdjusted * ((untilMaturation - fromMaturation) * (foodRateEnd + 0.5 * Math.Abs(foodRateStart - foodRateEnd)));

return true;
}
}
Expand Down
6 changes: 5 additions & 1 deletion ARKBreedingStats/values/ServerMultipliers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ARKBreedingStats.values
public class ServerMultipliers
{
/// <summary>
/// statMultipliers[statIndex][m], m: 0:tamingadd, 1:tamingmult, 2:levelupdom, 3:levelupwild
/// statMultipliers[statIndex][m], m: 0:tamingAdd, 1:tamingMult, 2:levelUpDom, 3:levelUpWild
/// </summary>
[JsonProperty]
public double[][] statMultipliers;
Expand All @@ -19,6 +19,8 @@ public class ServerMultipliers
public double TamingSpeedMultiplier { get; set; }
[JsonProperty]
public double DinoCharacterFoodDrainMultiplier { get; set; }
[JsonProperty]
public double TamedDinoCharacterFoodDrainMultiplier { get; set; }

[JsonProperty]
public double MatingSpeedMultiplier { get; set; }
Expand All @@ -45,6 +47,7 @@ internal void SetDefaultValues(StreamingContext context)
{
TamingSpeedMultiplier = 1;
DinoCharacterFoodDrainMultiplier = 1;
TamedDinoCharacterFoodDrainMultiplier = 1;
MatingIntervalMultiplier = 1;
EggHatchSpeedMultiplier = 1;
MatingSpeedMultiplier = 1;
Expand Down Expand Up @@ -81,6 +84,7 @@ public ServerMultipliers Copy(bool withStatMultipliers)
{
TamingSpeedMultiplier = TamingSpeedMultiplier,
DinoCharacterFoodDrainMultiplier = DinoCharacterFoodDrainMultiplier,
TamedDinoCharacterFoodDrainMultiplier = TamedDinoCharacterFoodDrainMultiplier,
MatingIntervalMultiplier = MatingIntervalMultiplier,
EggHatchSpeedMultiplier = EggHatchSpeedMultiplier,
MatingSpeedMultiplier = MatingSpeedMultiplier,
Expand Down

0 comments on commit fdf4d1a

Please sign in to comment.