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:
parent
65b488b5dc
commit
d5c2d58636
7 changed files with 336 additions and 37 deletions
|
|
@ -53,11 +53,11 @@ namespace RacesOfValheim
|
|||
|
||||
if (IsTransformed)
|
||||
{
|
||||
TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
||||
formRoutine = TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
TrentaRace.Instance.StartCoroutine(TransformRoutine(player));
|
||||
formRoutine = TrentaRace.Instance.StartCoroutine(TransformRoutine(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,10 +68,51 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (IsTransformed && !isTransformingSequence)
|
||||
{
|
||||
TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
||||
formRoutine = TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
||||
}
|
||||
}
|
||||
|
||||
// The one transform or revert routine in flight, if any, so ResetRace can stop it.
|
||||
private static Coroutine formRoutine;
|
||||
|
||||
/// <summary>
|
||||
/// Drops the Muspell on the spot for ResetRace. ForceRevert would get there too, from
|
||||
/// TrentaRace.Update, but a frame and a half-second tween later - after ResetRace has
|
||||
/// already reopened the menu - and not at all if the reset lands mid-gesture.
|
||||
/// </summary>
|
||||
/// <returns>True if there was a form to drop.</returns>
|
||||
public static bool HardResetForReset(Player player)
|
||||
{
|
||||
if (player == null) return false;
|
||||
|
||||
if (formRoutine != null && TrentaRace.Instance != null)
|
||||
{
|
||||
TrentaRace.Instance.StopCoroutine(formRoutine);
|
||||
}
|
||||
formRoutine = null;
|
||||
|
||||
bool hadForm = IsTransformed || isTransformingSequence || currentTransformation != null;
|
||||
if (hadForm)
|
||||
{
|
||||
if (currentTransformation != null) Object.Destroy(currentTransformation);
|
||||
currentTransformation = null;
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_MuspellForm", false);
|
||||
|
||||
Transform playerVisual = player.transform.Find("Visual");
|
||||
if (playerVisual != null)
|
||||
{
|
||||
playerVisual.localScale = Vector3.one;
|
||||
playerVisual.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
IsTransformed = false;
|
||||
isTransformingSequence = false;
|
||||
return hadForm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by Purple Rain instead of its usual staff_summon trigger whenever Muspell is
|
||||
/// active - The Elder's own root-summon gesture, played on the transformation clone's
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue