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:
parent
a772164668
commit
f51afd3a80
4 changed files with 126 additions and 9 deletions
|
|
@ -68,6 +68,13 @@ namespace RacesOfValheim
|
|||
/// <summary>
|
||||
/// Clears the current race and reopens the selection menu. Shared by the resetrace console
|
||||
/// command and the Race Menu Ward, so both paths clean up exactly the same state.
|
||||
///
|
||||
/// Every status effect a race can leave running is removed here, not just the "stats"
|
||||
/// ones - a cooldown SE left ticking after a reset is invisible until the player picks
|
||||
/// the same race again and finds an ability still locked out for a timer nobody can see.
|
||||
/// The item purge runs LAST, after the ZDO already reads "Human": RaceClawSet.For and
|
||||
/// SvermVisuals.IsSvermPlayer both read the race live off the player, so purging before
|
||||
/// the race actually changes would find nothing foreign yet.
|
||||
/// </summary>
|
||||
public static void ResetRace()
|
||||
{
|
||||
|
|
@ -100,11 +107,21 @@ namespace RacesOfValheim
|
|||
player.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.StatsSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeCdSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.RunicPingCdSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.StatsSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.PurpleRainCdSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.PortalCdSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(SvermConfig.StatsSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(SvermConfig.StingerSE.GetStableHashCode());
|
||||
player.GetSEMan().RemoveStatusEffect(SvermConfig.StingerCdSE.GetStableHashCode());
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
|
||||
|
||||
// Only after the ZDO above already says "Human" - see the class doc comment.
|
||||
RaceItemCleanup.PurgeForeignRaceItems(player);
|
||||
|
||||
if (Instance != null)
|
||||
{
|
||||
if (FenrirRace.Instance != null) FenrirRace.Instance.ForceRevert();
|
||||
|
|
@ -819,6 +836,12 @@ namespace RacesOfValheim
|
|||
// The Dvergar needs no entry here: its tint is applied by the UpdateColors postfix
|
||||
// every time Valheim refreshes the body, rather than being stored on the player.
|
||||
|
||||
// Heals a save that got stuck holding another race's permanent claws BEFORE this
|
||||
// purge existed - runs on every spawn rather than only from ResetRace, so a
|
||||
// player who already has the bug is fixed by logging in, not by finding the Ward
|
||||
// and resetting a race they may not even want to leave.
|
||||
RaceItemCleanup.PurgeForeignRaceItems(__instance);
|
||||
|
||||
// Check for Race Selection
|
||||
if (!__instance.m_customData.ContainsKey("Race"))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue