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
|
|
@ -463,7 +463,7 @@ namespace RacesOfValheim
|
|||
if (EnvMan.instance != null && EnvMan.IsDay() && !isTransformingSequence &&
|
||||
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
||||
{
|
||||
StartCoroutine(RevertMistFormRoutine());
|
||||
RunFormRoutine(RevertMistFormRoutine());
|
||||
}
|
||||
|
||||
// Same rule for a night-only bat: a form the sun forbids cannot be kept through the
|
||||
|
|
@ -474,7 +474,7 @@ namespace RacesOfValheim
|
|||
EnvMan.instance != null && EnvMan.IsDay())
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_morning_sun_drives_bat_back"));
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
RunFormRoutine(RevertToHumanRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -565,7 +565,7 @@ namespace RacesOfValheim
|
|||
|
||||
if (IsTransformed)
|
||||
{
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
RunFormRoutine(RevertToHumanRoutine());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -580,18 +580,73 @@ namespace RacesOfValheim
|
|||
return;
|
||||
}
|
||||
|
||||
StartCoroutine(TransformIntoBatRoutine(rules));
|
||||
RunFormRoutine(TransformIntoBatRoutine(rules));
|
||||
}
|
||||
|
||||
// The one bat or mist routine in flight, if any. Kept so ResetRace can stop it: a
|
||||
// TransformIntoBatRoutine left running through a reset finishes its 1.1s gesture and
|
||||
// turns a freshly reset Human into a bat.
|
||||
private Coroutine formRoutine;
|
||||
|
||||
private void RunFormRoutine(System.Collections.IEnumerator routine)
|
||||
{
|
||||
formRoutine = StartCoroutine(routine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drops bat and mist form on the spot for ResetRace: no puff, no tween, nothing left
|
||||
/// running. ForceRevert is no use there - it skips a form that is still mid-gesture, and
|
||||
/// its coroutine would still be shrinking the body back after the reset has finished.
|
||||
/// </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 hadMist = mistTransformation != null || player.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode());
|
||||
bool hadBat = IsTransformed || isTransformingSequence;
|
||||
|
||||
// Also clears isTransformingSequence and puts the transform back to scale 1, which
|
||||
// covers a reset caught halfway through the bat's shrink.
|
||||
HardResetBatForm();
|
||||
|
||||
if (hadMist)
|
||||
{
|
||||
if (mistTransformation != null)
|
||||
{
|
||||
Destroy(mistTransformation);
|
||||
mistTransformation = null;
|
||||
}
|
||||
|
||||
Transform playerVisual = player.transform.Find("Visual");
|
||||
PlayerVisualHider.Show(playerVisual, "aswid-reset-mist");
|
||||
if (playerVisual != null) playerVisual.localScale = Vector3.one;
|
||||
|
||||
player.GetSEMan().RemoveStatusEffect("SE_MistForm".GetStableHashCode(), true);
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("Aswid_IsMistForm", false);
|
||||
}
|
||||
|
||||
isTransformingSequence = false;
|
||||
return hadBat || hadMist;
|
||||
}
|
||||
|
||||
public void ForceRevert()
|
||||
{
|
||||
if (IsTransformed && !isTransformingSequence)
|
||||
{
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
RunFormRoutine(RevertToHumanRoutine());
|
||||
}
|
||||
if (Player.m_localPlayer != null && Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()) && !isTransformingSequence)
|
||||
{
|
||||
StartCoroutine(RevertMistFormRoutine());
|
||||
RunFormRoutine(RevertMistFormRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -745,11 +800,11 @@ namespace RacesOfValheim
|
|||
|
||||
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
||||
{
|
||||
StartCoroutine(RevertMistFormRoutine());
|
||||
RunFormRoutine(RevertMistFormRoutine());
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(TransformIntoMistRoutine());
|
||||
RunFormRoutine(TransformIntoMistRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue