feat(aswid): running water weakness and a seasick camera
Swimming costs double stamina, scaled on vanilla's own swim charge so its drowning check does the rest at high settings. Over deep water in the Ocean, swimming or flying, the Aswid loses health and stamina each second; a boat protects. A gentle camera roll plays while the sea hurts, kept local through ConfigSync so a server cannot force it on anyone.
This commit is contained in:
parent
9149d3f0b5
commit
5c41d80cae
14 changed files with 173 additions and 3 deletions
|
|
@ -874,6 +874,60 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (__instance != Player.m_localPlayer || !AswidRace.IsAswid()) return;
|
||||
v *= AswidConfig.StaminaCostMultiplier.Value;
|
||||
|
||||
if (Aswid_SwimCost_Patch.Swimming && AswidConfig.RunningWaterEnabled.Value)
|
||||
{
|
||||
v *= AswidConfig.SwimStaminaMultiplier.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks the frames where vanilla charges for a swim stroke, so Aswid_UseStamina_Patch can
|
||||
/// make that one cost dearer. Player.OnSwimming is the only place swimming spends stamina,
|
||||
/// and it also runs the drowning check right after - which is what makes a high multiplier
|
||||
/// play as "cannot swim" without any code of ours deciding who drowns.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "OnSwimming")]
|
||||
public static class Aswid_SwimCost_Patch
|
||||
{
|
||||
public static bool Swimming { get; private set; }
|
||||
|
||||
public static void Prefix(Player __instance)
|
||||
{
|
||||
Swimming = __instance == Player.m_localPlayer;
|
||||
}
|
||||
|
||||
public static void Finalizer()
|
||||
{
|
||||
Swimming = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The seasick camera: a slow roll while the open sea is hurting the Aswid. Applied after
|
||||
/// vanilla has settled the camera's rotation for the frame, as a roll around the view axis,
|
||||
/// so it never moves where the player aims - only how the horizon sits.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(GameCamera), "GetCameraPosition")]
|
||||
public static class Aswid_SeaCameraSway_Patch
|
||||
{
|
||||
private const float DegreesAtStrengthOne = 4f;
|
||||
private static float sway;
|
||||
|
||||
public static void Postfix(float dt, ref Quaternion rot)
|
||||
{
|
||||
bool on = AswidRace.AtSea && AswidConfig.SeaCameraSway.Value && AswidRace.IsAswid() &&
|
||||
Player.m_localPlayer != null && !Player.m_localPlayer.IsDead();
|
||||
|
||||
// Eased in and out over about a second, so leaving the sea does not snap the horizon.
|
||||
sway = Mathf.MoveTowards(sway, on ? 1f : 0f, dt);
|
||||
if (sway <= 0f) return;
|
||||
|
||||
float t = Time.time;
|
||||
float roll = (Mathf.Sin(t * 0.9f) + 0.4f * Mathf.Sin(t * 2.3f)) * DegreesAtStrengthOne *
|
||||
AswidConfig.SeaCameraSwayStrength.Value * sway;
|
||||
rot *= Quaternion.AngleAxis(roll, Vector3.forward);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue