Add force-feed fallback to TryConsumeMob to bypass stomach limits on execute
This commit is contained in:
parent
152a2f21ad
commit
6170c060ac
1 changed files with 22 additions and 0 deletions
|
|
@ -1085,6 +1085,28 @@ namespace RacesOfValheim
|
||||||
// If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated)
|
// If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated)
|
||||||
AswidRace.BypassAswidFoodCheck = true;
|
AswidRace.BypassAswidFoodCheck = true;
|
||||||
bool successfullyEaten = Player.m_localPlayer.EatFood(addedItem);
|
bool successfullyEaten = Player.m_localPlayer.EatFood(addedItem);
|
||||||
|
|
||||||
|
// Force-feed logic for aura executions
|
||||||
|
if (!successfullyEaten && bypassCooldown)
|
||||||
|
{
|
||||||
|
var m_foods = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foods").GetValue<System.Collections.Generic.List<Player.Food>>();
|
||||||
|
if (m_foods != null)
|
||||||
|
{
|
||||||
|
Player.Food existing = m_foods.Find(f => f.m_item.m_shared.m_name == addedItem.m_shared.m_name);
|
||||||
|
if (existing != null)
|
||||||
|
{
|
||||||
|
m_foods.Remove(existing);
|
||||||
|
}
|
||||||
|
else if (m_foods.Count >= 3)
|
||||||
|
{
|
||||||
|
m_foods.Sort((a, b) => (b.m_time / b.m_item.m_shared.m_foodBurnTime).CompareTo(a.m_time / a.m_item.m_shared.m_foodBurnTime));
|
||||||
|
m_foods.RemoveAt(0); // Remove the most digested food
|
||||||
|
}
|
||||||
|
successfullyEaten = Player.m_localPlayer.EatFood(addedItem);
|
||||||
|
Jotunn.Logger.LogInfo($"[AswidDebug] Force-feed attempted. Result: {successfullyEaten}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AswidRace.BypassAswidFoodCheck = false;
|
AswidRace.BypassAswidFoodCheck = false;
|
||||||
|
|
||||||
if (successfullyEaten)
|
if (successfullyEaten)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue