fix: race buildings keep their own message when an item is used on them

Humanoid.UseItem shows the generic $msg_cantuseon whenever the
interactable's UseItem returns false, covering the refusal message the
building had just shown. Same fix as the Trol totem in v1.4.18, applied
to the Servant table, Dvergar barrel and bank, Fenrir trough, Draugr and
Skeleton piles, Blood Refinery, Grove and Composter: an item in hand
always counts as handled. Empty-handed interactions are unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Ferdinando 2026-09-18 17:13:16 +02:00
commit 5f74c57e72
10 changed files with 55 additions and 9 deletions

View file

@ -79,14 +79,16 @@ namespace RacesOfValheim
private bool OnAddMeat(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return TryAdd(user, item, isMeat: true);
return TryAdd(user, item, isMeat: true) || item != null;
}
private bool OnAddBone(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return TryAdd(user, item, isMeat: false);
return TryAdd(user, item, isMeat: false) || item != null;
}
// Both switches treat an item in hand as handled whatever TryAdd says: false makes
// Humanoid.UseItem cover our own message with the generic "$msg_cantuseon".
private bool TryAdd(Humanoid user, ItemDrop.ItemData item, bool isMeat)
{
if (user == null) return false;

View file

@ -64,7 +64,8 @@ namespace RacesOfValheim
if (item != null)
{
player.Message(MessageHud.MessageType.Center, "$msg_wontwork");
return false;
// True, not false: false makes Humanoid.UseItem cover the message with $msg_cantuseon.
return true;
}
if (Servant() != null)

View file

@ -65,7 +65,14 @@ namespace RacesOfValheim
/// Raw flesh feeds it, a Draugr trophy is a whole batch, an Elite trophy is an officer, and a
/// Greater Cursed Bone upgrades it. Empty hands just report.
/// </summary>
// With an item in hand every outcome counts as handled, refusals included: false makes
// Humanoid.UseItem cover our own message with the generic "$msg_cantuseon".
private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return Use(user, item) || item != null;
}
private bool Use(Humanoid user, ItemDrop.ItemData item)
{
if (user == null) return false;

View file

@ -67,7 +67,9 @@ namespace RacesOfValheim
if (!DvergarRace.IsDvergar())
{
player.Message(MessageHud.MessageType.Center, "The ledger is not written for you.");
return false;
// With an item in hand, false makes Humanoid.UseItem cover this message with its
// generic "$msg_cantuseon"; true tells it the use was handled here.
return item != null;
}
// The Queen's drop in hand rewrites the ledger: coin on the table, and two more crews.
@ -79,24 +81,26 @@ namespace RacesOfValheim
if (item != null)
{
player.Message(MessageHud.MessageType.Center, "$msg_wontwork");
return false;
return true;
}
return OpenStore(player);
}
// Every refusal still returns true: this only runs from an item use, where false would
// make Humanoid.UseItem replace our message with the generic "$msg_cantuseon".
private bool TryUpgrade(Player player, ItemDrop.ItemData item)
{
if (IsUpgraded())
{
player.Message(MessageHud.MessageType.Center, "It has already had one.");
return false;
return true;
}
if (BossProgressionManager.GetCurrentProgressionState() < DvergarBanco.UpgradeProgressionState)
{
player.Message(MessageHud.MessageType.Center, "Not while she still sits under the mist.");
return false;
return true;
}
player.GetInventory().RemoveItem(item, 1);

View file

@ -63,9 +63,12 @@ namespace RacesOfValheim
if (!DvergarBotte.IsBrew(prefabName))
{
player.Message(MessageHud.MessageType.Center, "$msg_wontwork");
return false;
return true;
}
return Fill(player, inventory, item, prefabName);
// Always true from an item use, refusals included: false makes Humanoid.UseItem
// cover Fill's own message with the generic $msg_cantuseon.
Fill(player, inventory, item, prefabName);
return true;
}
// Bare hands: pour a round if there is one, otherwise go looking for something to pour.

View file

@ -272,7 +272,14 @@ namespace RacesOfValheim
// ---------------------------------------------------------------- interaction
// With an item in hand every outcome counts as handled, refusals included: false makes
// Humanoid.UseItem cover our own message with the generic "$msg_cantuseon".
private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return Use(user, item) || item != null;
}
private bool Use(Humanoid user, ItemDrop.ItemData item)
{
if (user == null) return false;

View file

@ -68,7 +68,14 @@ namespace RacesOfValheim
/// Empty hands were free to use for this because the pile's own hover already carries the
/// status the Draugh needs an empty-handed click to report.
/// </summary>
// With an item in hand every outcome counts as handled, refusals included: false makes
// Humanoid.UseItem cover our own message with the generic "$msg_cantuseon".
private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return Use(user, item) || item != null;
}
private bool Use(Humanoid user, ItemDrop.ItemData item)
{
Player player = user as Player;
if (player == null) return false;

View file

@ -77,7 +77,14 @@ namespace RacesOfValheim
/// click means. Holding flesh feeds it; empty hands tap it when it is ready and otherwise
/// just report what it is doing.
/// </summary>
// With an item in hand every outcome counts as handled, refusals included: false makes
// Humanoid.UseItem cover our own message with the generic "$msg_cantuseon".
private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return Use(user, item) || item != null;
}
private bool Use(Humanoid user, ItemDrop.ItemData item)
{
if (user == null) return false;

View file

@ -257,7 +257,14 @@ namespace RacesOfValheim
/// doing. Loading a tank before the tree has grown is allowed on purpose - there is no reason
/// to make the player come back twice.
/// </summary>
// With an item in hand every outcome counts as handled, refusals included: false makes
// Humanoid.UseItem cover our own message with the generic "$msg_cantuseon".
private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item)
{
return Use(user, item) || item != null;
}
private bool Use(Humanoid user, ItemDrop.ItemData item)
{
if (user == null) return false;