fix(resetrace): drop every form and every mod status effect on reset

ResetRace now undoes each race's form on the spot before it touches
status effects: Aswid bat and mist, Fenrir, Skadi drake, Trol True
Form, Trenta Muspell and Sverm Ravager. Each race gets a
HardResetForReset that stops the form's coroutine, so a transform
caught mid-gesture can't finish after the reset and a revert can't
hand out its cooldown after the sweep.

The hand-written status effect list is gone. The reset now removes
everything the mod registers through Jotunn (ModRegistry), which
covers the True Form and its cooldowns, Bat and Mist Form, the
Skeleton resurrect cooldown and Skadi's ability cooldowns.

It also puts the player and the Visual back to scale 1, clears the
Sverm's static Ravager cooldown and the Trol's wasTrueFormActive flag,
and prints what it removed to the console and the BepInEx log.
This commit is contained in:
kanym 2026-10-14 16:40:27 +02:00
commit d5c2d58636
7 changed files with 336 additions and 37 deletions

View file

@ -206,11 +206,52 @@ namespace RacesOfValheim
bool isTrueFormActive = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode());
if (wasTrueFormActive && !isTrueFormActive && !isTransforming)
{
StartCoroutine(RevertTrueFormRoutine());
RunFormRoutine(RevertTrueFormRoutine());
}
wasTrueFormActive = isTrueFormActive;
}
// The one grow or shrink routine in flight, if any, so ResetRace can stop it.
private Coroutine formRoutine;
private void RunFormRoutine(System.Collections.IEnumerator routine)
{
formRoutine = StartCoroutine(routine);
}
/// <summary>
/// Drops True Form on the spot for ResetRace. Update returns on its first line for anyone
/// who is not a Trol, so its auto-revert never saw the form end. wasTrueFormActive is the
/// part that would bite later: left true, the next time this player picks Trol the first
/// Update reads it as a form that just ran out and hands out a True Form cooldown.
/// </summary>
/// <returns>True if there was a form to drop.</returns>
public bool HardResetForReset()
{
Player player = Player.m_localPlayer;
if (player == null) return false;
if (formRoutine != null)
{
StopCoroutine(formRoutine);
formRoutine = null;
}
int trueFormHash = "SE_TrolTrueForm".GetStableHashCode();
bool hadForm = isTransforming || wasTrueFormActive || player.GetSEMan().HaveStatusEffect(trueFormHash);
if (hadForm)
{
player.GetSEMan().RemoveStatusEffect(trueFormHash, true);
ZNetView nview = player.GetComponent<ZNetView>();
if (nview != null && nview.IsValid()) nview.GetZDO().Set(Trol_PlayerUpdate_Patch.TrueFormKey, false);
}
isTransforming = false;
wasTrueFormActive = false;
return hadForm;
}
private void TryTrueForm()
{
if (BossProgressionManager.GetCurrentProgressionState() < 5) return; // Requires Moder
@ -239,7 +280,7 @@ namespace RacesOfValheim
if (!isTransforming)
{
StartCoroutine(TransformToTrueFormRoutine());
RunFormRoutine(TransformToTrueFormRoutine());
}
}