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
|
|
@ -247,7 +247,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
formExpireTime = 0f;
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_fades"));
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
RunFormRoutine(RevertToHumanRoutine());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -687,7 +687,7 @@ namespace RacesOfValheim
|
|||
|
||||
if (isTransformed)
|
||||
{
|
||||
StartCoroutine(RevertToHumanRoutine());
|
||||
RunFormRoutine(RevertToHumanRoutine());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -707,7 +707,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
activeRules = rules;
|
||||
StartCoroutine(TransformRoutine(rules));
|
||||
RunFormRoutine(TransformRoutine(rules));
|
||||
}
|
||||
|
||||
private Vector3 GetFormScale(SkadiProgression.FormType form)
|
||||
|
|
@ -914,6 +914,57 @@ namespace RacesOfValheim
|
|||
if (se != null) se.m_ttl = seconds;
|
||||
}
|
||||
|
||||
// The one transform or revert 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 the drake form on the spot for ResetRace. Update bails out on its first line for
|
||||
/// anyone who is not a Skadi, so once the race changes nothing in this class ever looks at
|
||||
/// the form again - a Skadi reset in drake form stayed a drake for good. No message and no
|
||||
/// cooldown here, unlike ExecuteReversion.
|
||||
/// </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;
|
||||
foreach (var f in player.GetComponentsInChildren<DrakeFormBehavior>(true)) Destroy(f.gameObject);
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
nview.GetZDO().Set("Skadi_Form", "");
|
||||
nview.GetZDO().Set("RacesOfValheim_SkadiForm", "");
|
||||
}
|
||||
|
||||
PlayerVisualHider.Show(player.transform.Find("Visual"), "skadi-reset");
|
||||
player.GetSEMan().RemoveStatusEffect("SE_SkadiForm".GetStableHashCode(), true);
|
||||
}
|
||||
|
||||
isTransformed = false;
|
||||
isTransformingSequence = false;
|
||||
formExpireTime = 0f;
|
||||
activeRules = null;
|
||||
return hadForm;
|
||||
}
|
||||
|
||||
private void ExecuteReversion()
|
||||
{
|
||||
Transform playerVisual = Player.m_localPlayer.transform.Find("Visual");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue