feat(aswid): bat flies on the Skadi's directed flight
The bat flew on vanilla's debug-fly flag: 50 m/s, free, blind to carry weight, and invisible to monsters until six patches lied about the flag. It now flies on m_flying with the drake's controls, moved out of SkadiPatches into a shared DirectedFlight core that both forms feed their own numbers into. Powered flight and the sprint cost stamina; out of stamina the bat glides. Encumbered flight costs 15% more, or is blocked with 'While Encumbered'. Optional duration and cooldown, off by default. The aggro/damage patches, the debug-fly speed patch and their three settings are removed; the drake's behaviour is unchanged.
This commit is contained in:
parent
824ddd8956
commit
77cdc67e97
19 changed files with 534 additions and 516 deletions
|
|
@ -674,9 +674,26 @@ namespace RacesOfValheim
|
|||
return;
|
||||
}
|
||||
|
||||
if (AswidConfig.BatEncumbered.Value == AswidConfig.EncumberedMode.Blocked && Player.m_localPlayer.IsEncumbered())
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_too_heavy_for_bat"));
|
||||
return;
|
||||
}
|
||||
|
||||
float cooldownLeft = AswidConfig.BatCooldown.Value - (Time.time - lastBatEndTime);
|
||||
if (cooldownLeft > 0f)
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_bat_cooldown", Mathf.CeilToInt(cooldownLeft)));
|
||||
return;
|
||||
}
|
||||
|
||||
RunFormRoutine(TransformIntoBatRoutine(rules));
|
||||
}
|
||||
|
||||
// When the bat form last ended, for the optional cooldown. Starts far enough back that a
|
||||
// fresh session never begins on cooldown.
|
||||
private float lastBatEndTime = -100000f;
|
||||
|
||||
// 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.
|
||||
|
|
@ -750,7 +767,7 @@ namespace RacesOfValheim
|
|||
/// Update() has already bailed out on IsDead(), so a coroutine started here would be the
|
||||
/// only thing still running on a corpse.
|
||||
///
|
||||
/// Leaving the form up costs more than a missing animation: m_debugFly stays on, so the
|
||||
/// Leaving the form up costs more than a missing animation: m_flying stays on, so the
|
||||
/// respawned player floats; Aswid_IsBatForm stays true in the ZDO, so every other client
|
||||
/// keeps drawing a bat over a body that is walking around as a person; and the 5% scale
|
||||
/// stays on the transform. Called from Aswid_BatDiesAsBat_Patch.
|
||||
|
|
@ -776,12 +793,13 @@ namespace RacesOfValheim
|
|||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
nview.GetZDO().Set("Aswid_IsBatForm", false);
|
||||
nview.GetZDO().Set(ZDOVars.s_debugFly, false);
|
||||
}
|
||||
Traverse.Create(player).Field("m_debugFly").SetValue(false);
|
||||
// Now, not when the destroyed model's OnDestroy gets round to it at the end of the frame.
|
||||
BatFormBehavior.SetFlying(false);
|
||||
|
||||
player.transform.localScale = Vector3.one;
|
||||
|
||||
lastBatEndTime = Time.time;
|
||||
IsTransformed = false;
|
||||
activeRules = null;
|
||||
isTransformingSequence = false;
|
||||
|
|
@ -881,6 +899,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
Player.m_localPlayer.transform.localScale = endScale;
|
||||
|
||||
lastBatEndTime = Time.time;
|
||||
IsTransformed = false;
|
||||
activeRules = null;
|
||||
isTransformingSequence = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue