Rework Skadi dragon flight, enforce form duration, surface timers in HUD
Flight ran on the debug-fly noclip, so it ignored aim entirely and needed Space/Ctrl for height. It now uses Character's native flying-creature movement with the camera's full look direction fed in each frame: - Aim steers, including climb and dive; W powers forward, releasing it holds level briefly and then settles into a glide instead of coasting along the aim vector (which let you climb forever without input). - The body actually turns now. m_flyTurnSpeed sat at Character's 12 deg/s default because the Player prefab was never set up to fly, so a quarter turn took over seven seconds and read as no rotation at all. - Touching down no longer slides you forward forever. Zeroing the fly speeds stops the character without fighting the AddForce UpdateFlying queues, which had caused frame-to-frame jitter and TAA ghosting. DurationMinutes was never wired to anything, so timed forms never expired and their cooldown, which only starts on reversion, was unreachable in practice. Timed forms now drop on their own, and both the remaining time and the cooldown show up beside the minimap as a Moder trophy icon. Attack capability was snapshotted when the form was entered, so reaching the Bonemass tier while already transformed left the drake unarmed until the player reverted and transformed again; it is re-read live now.
This commit is contained in:
parent
00b1b4e9ed
commit
cccabe16ef
5 changed files with 193 additions and 21 deletions
|
|
@ -200,6 +200,79 @@ namespace RacesOfValheim
|
|||
|
||||
|
||||
|
||||
// DrakeFormBehavior flips the player into Character's native flying-creature movement
|
||||
// (m_flying = true) instead of the old debug-fly noclip, which lets us feed it a full 3D
|
||||
// move direction. Character.UpdateFlying normally reads whatever m_moveDir the vanilla input
|
||||
// pipeline last wrote (ground-plane WASD relative to camera yaw only); this patch overwrites
|
||||
// it every frame with the camera's actual look direction (pitch included) so the player always
|
||||
// glides toward wherever the mouse is aiming, with W adding a speed boost (m_run) on top of the
|
||||
// base glide speed instead of being required just to move.
|
||||
[HarmonyPatch(typeof(Character), "UpdateFlying")]
|
||||
public static class SkadiDirectedFlightPatch
|
||||
{
|
||||
private const float TURN_SPEED = 120f;
|
||||
private const float GLIDE_SPEED = 5f;
|
||||
private const float BOOST_SPEED = 12f;
|
||||
private const float HOVER_SECONDS = 2f;
|
||||
// Tangent of the unpowered descent angle: 0.4 sinks at roughly 22 degrees below level.
|
||||
private const float DESCENT_SLOPE = 0.4f;
|
||||
|
||||
public static void Prefix(Character __instance)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer) return;
|
||||
|
||||
DrakeFormBehavior form = DrakeFormBehavior.Active;
|
||||
if (form == null || !form.IsFlying) return;
|
||||
|
||||
var traverse = Traverse.Create(__instance);
|
||||
Vector3 lookDir = Player.m_localPlayer.GetLookDir();
|
||||
bool boost = Input.GetKey(KeyCode.W);
|
||||
bool onGround = __instance.IsOnGround();
|
||||
|
||||
traverse.Field("m_run").SetValue(boost);
|
||||
traverse.Field("m_flyFastSpeed").SetValue(BOOST_SPEED);
|
||||
|
||||
// UpdateFlying rotates the body toward m_moveDir on its own, but at m_flyTurnSpeed,
|
||||
// which sits at Character's 12 deg/s default because the Player prefab was never set
|
||||
// up as a flying creature - a 90 degree turn would take over seven seconds, so the
|
||||
// model reads as not turning at all. Give it a speed that suits a flying mount.
|
||||
traverse.Field("m_flyTurnSpeed").SetValue(TURN_SPEED);
|
||||
|
||||
// Powered flight and ground contact both refresh the hover window.
|
||||
if (boost || onGround) form.LastPoweredTime = Time.time;
|
||||
|
||||
Vector3 moveDir = lookDir;
|
||||
float coastSpeed;
|
||||
|
||||
if (onGround || Time.time - form.LastPoweredTime < HOVER_SECONDS)
|
||||
{
|
||||
// Holding station: on the ground this keeps a touchdown from sliding the player
|
||||
// forward forever, and in the air it gives the beat of level flight before the
|
||||
// form starts to sink. m_moveDir stays full length so the body still turns to
|
||||
// face the camera, and zeroing the speed (rather than the rigidbody velocity)
|
||||
// avoids fighting the AddForce UpdateFlying queues, which caused visible jitter.
|
||||
coastSpeed = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unpowered flight is a glide, not a hover with a joystick: drift along the
|
||||
// heading the camera faces while losing height, so aiming at the sky without
|
||||
// holding W no longer climbs.
|
||||
Vector3 heading = new Vector3(lookDir.x, 0f, lookDir.z);
|
||||
if (heading.sqrMagnitude < 0.0001f)
|
||||
{
|
||||
heading = __instance.transform.forward;
|
||||
heading.y = 0f;
|
||||
}
|
||||
moveDir = (heading.normalized + Vector3.down * DESCENT_SLOPE).normalized;
|
||||
coastSpeed = GLIDE_SPEED;
|
||||
}
|
||||
|
||||
traverse.Field("m_moveDir").SetValue(moveDir);
|
||||
traverse.Field("m_flySlowSpeed").SetValue(coastSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), "StartAttack")]
|
||||
public static class SkadiAttackPatch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue