draughfirstdraft

This commit is contained in:
Ferdinando 2026-08-02 08:30:53 +02:00
commit be2f7a73cd
8 changed files with 555 additions and 163 deletions

View file

@ -35,7 +35,22 @@ namespace RacesOfValheim
public static bool UseItem_Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui)
{
Player player = __instance as Player;
if (player == null || player != Player.m_localPlayer || !DraughRace.IsDraugh() || item == null || item.m_shared == null) return true;
if (player == null || player != Player.m_localPlayer || item == null || item.m_shared == null) return true;
// Prevent non-Draughs from eating Human Meat
if (item.m_dropPrefab != null && item.m_dropPrefab.name == "HumanMeat")
{
if (!DraughRace.IsDraugh())
{
player.Message(MessageHud.MessageType.Center, "This rotting flesh is fatal to the living.");
return false; // Block consumption
}
// If it IS a Draugh, let them consume it via native mechanics
return true;
}
// Normal Draugh Food restrictions
if (!DraughRace.IsDraugh()) return true;
// Intercept right click on raw items.
// In UseItem, if it's a Consumable, Valheim will process it. If it's our EdibleUncooked_, it's a Consumable!
@ -64,6 +79,12 @@ namespace RacesOfValheim
if (ate)
{
inventory.RemoveItem(item, 1);
var consumeEffects = Traverse.Create(player).Field("m_consumeItemEffects").GetValue<EffectList>();
if (consumeEffects != null) consumeEffects.Create(player.transform.position, Quaternion.identity, player.transform, 1f, -1);
var zanim = Traverse.Create(player).Field("m_zanim").GetValue<ZSyncAnimation>();
if (zanim != null) zanim.SetTrigger("eat");
}
return false; // Skip native UseItem
}