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

@ -560,18 +560,25 @@ namespace RacesOfValheim
/// The claws cannot be picked up with the mouse. SetupDragItem is the single door every manual
/// move goes through - within the inventory, out to a chest, onto the ground, into a crafting
/// slot - so refusing here closes all of them with one prefix.
///
/// Only refused while the item is CURRENTLY that race's claws - checked against SetOwning
/// (whose set the item is) against RaceClawSet.For (what race the player is right now), not
/// merely "is this any race's claws at all". A player who has since switched race carries a
/// pair that RaceItemCleanup should have already removed, but if it has not run yet for any
/// reason, this is the difference between an item merely undraggable and one undraggable
/// forever: without the race check, nothing the player does - not death, not a tombstone, not
/// closing the item's own quest-item flag - would ever let them shed it again.
/// </summary>
[HarmonyPatch(typeof(InventoryGui), "SetupDragItem")]
public static class RaceClaws_SetupDragItem_Patch
{
public static bool Prefix(ItemDrop.ItemData item)
{
if (RaceClawSet.SetOwning(item) == null) return true;
RaceClawSet owner = RaceClawSet.SetOwning(item);
if (owner == null) return true;
if (Player.m_localPlayer == null || owner != RaceClawSet.For(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;
}
}