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

@ -185,7 +185,7 @@ namespace RacesOfValheim {
if (isTransformed)
{
StartCoroutine(RevertToHumanRoutine());
RunFormRoutine(RevertToHumanRoutine());
return;
}
@ -213,7 +213,7 @@ namespace RacesOfValheim {
}
}
StartCoroutine(TransformIntoWolfRoutine(rules));
RunFormRoutine(TransformIntoWolfRoutine(rules));
}
/// <summary>
@ -256,11 +256,63 @@ namespace RacesOfValheim {
return "$rov_msg_fenrir_formname_fenrir";
}
// The one transform or revert routine in flight, if any, so ResetRace can stop it. A
// revert left to finish on its own lands its cooldown after the reset has already swept
// the status effects, and the next Fenrir starts locked out.
private Coroutine formRoutine;
private void RunFormRoutine(IEnumerator routine)
{
formRoutine = StartCoroutine(routine);
}
/// <summary>
/// Drops whatever form is up, immediately, for ResetRace: no poof, no message, and no
/// cooldown - ExecuteReversion hands one out, which is right for a form running out and
/// wrong for a player leaving the race.
/// </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;
}
bool hadForm = isTransformed || isTransformingSequence || currentTransformation != null;
if (hadForm)
{
if (currentTransformation != null) Destroy(currentTransformation);
currentTransformation = null;
DestroyAllForms();
ZNetView nview = player.GetComponent<ZNetView>();
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_FenrirForm", "");
PlayerVisualHider.Show(player.transform.Find("Visual"), "fenrir-reset");
player.GetSEMan().RemoveStatusEffect("SE_FenrirForm".GetStableHashCode());
player.GetSEMan().RemoveStatusEffect("SE_CultistForm".GetStableHashCode());
player.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode());
}
isTransformed = false;
isTransformingSequence = false;
activeRules = null;
revertMessage = null;
sunSicknessTimer = 0f;
return hadForm;
}
public void ForceRevert()
{
if (isTransformed && !isTransformingSequence)
{
StartCoroutine(RevertToHumanRoutine());
RunFormRoutine(RevertToHumanRoutine());
}
}