fix(claws): stop permanent claws from getting stuck in inventory after a race switch

Aswid's Claws of the Beast, Fenrir's Cursed Claws and Sverm's Vilebone
Maulclaws are all m_questItem so the game refuses to drop, trade or
tombstone them - the mod's way of saying "these are part of your
body". But none of the code enforcing that ever checked whether the
player was STILL that race, and nothing removed the item when they
switched away, so a player who was ever Fenrir or Sverm and then
became anything else was left holding claws with no way to shed them:
not by dying, not by breaking them, not by relogging.

- RaceClaws.cs / SvermClawSlot.cs: the SetupDragItem prefixes that
  block moving/dropping the claws now also check that the item still
  belongs to the player's CURRENT race, so an already-mismatched pair
  becomes draggable again immediately.
- RaceItemCleanup.cs (new): central purge that unequips and removes
  any claws (plus the disabled Aswid spectral claw) that don't match
  the player's current race.
- Wired into ResetRace() - the Race Menu Ward's actual reset path -
  so a reset now clears every race-specific status effect (several
  cooldown SEs were missing entirely: Dvergar's Runic Ping/Overcharge,
  Trenta's Purple Rain/Portal, all of Sverm's) as well as the items.
- Also wired into PlayerSpawnPatch so an ALREADY-stuck save heals
  itself on next login, without the player needing to find the Ward.
This commit is contained in:
kanym 2026-08-12 13:04:40 +02:00
commit f51afd3a80
4 changed files with 126 additions and 9 deletions

View file

@ -265,6 +265,13 @@ namespace RacesOfValheim
/// in order to change exactly one of them, and it cost the player four slots. The claws are
/// visible now, which is also more honest: they are part of the character, and the character
/// can see them.
///
/// Only refused while the player IS CURRENTLY a Sverm. A player who has switched race carries
/// a pair that RaceItemCleanup should have already removed, but this check is what stops a
/// leftover pair from being undraggable forever if that cleanup has not run yet for any
/// reason - the quest-item flag already keeps them off the ground and out of a tombstone, so
/// a race check missing here was the one thing standing between "stuck until logout" and
/// "stuck permanently".
/// </summary>
[HarmonyPatch(typeof(InventoryGui), "SetupDragItem")]
public static class Sverm_SetupDragItem_Patch
@ -272,11 +279,9 @@ namespace RacesOfValheim
public static bool Prefix(ItemDrop.ItemData item)
{
if (!SvermClawSlot.IsClaws(item)) return true;
if (Player.m_localPlayer == null || !SvermVisuals.IsSvermPlayer(Player.m_localPlayer)) return true;
if (Player.m_localPlayer != null)
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "They are part of your hands.");
}
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "They are part of your hands.");
return false;
}
}