Add force-feed fallback to TryConsumeMob to bypass stomach limits on execute

This commit is contained in:
Ferdinando 2026-07-31 09:27:07 +02:00
commit 6170c060ac

View file

@ -1085,6 +1085,28 @@ namespace RacesOfValheim
// If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated)
AswidRace.BypassAswidFoodCheck = true;
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;
if (successfullyEaten)