feat(aswid): running water covers rivers and lakes; sway on boats
Open water now means any water: swimming in it, or flying over a metre or more of it, sea, river or lake. Standing on anything solid stays safe, so docks, bridges and wading do not count. On a boat there is still no burn or drain, but the camera keeps swaying. 'Ocean Only' restores the sea-only behaviour, and the settings say Open Water instead of Open Sea. Also rewrites the README's per-boss Aswid section from the code: it listed stats, unlocks and an aura that no longer exist.
This commit is contained in:
parent
a00db24ebd
commit
c76341af0d
12 changed files with 85 additions and 57 deletions
|
|
@ -1514,22 +1514,30 @@ namespace RacesOfValheim
|
|||
|
||||
private static readonly int OpenSeaHash = "SE_AswidOpenSea".GetStableHashCode();
|
||||
|
||||
/// <summary>True while the open sea is hurting the local Aswid. Read by the camera sway.</summary>
|
||||
public static bool AtSea { get; private set; }
|
||||
// How deep the water under an airborne Aswid has to be before it counts. Keeps a hop over
|
||||
// a puddle or a swamp ditch from registering; a bat over a river or a lake still does.
|
||||
private const float MinFlyOverDepth = 1f;
|
||||
|
||||
/// <summary>True while the local Aswid is out on the water, boat or not. Read by the camera sway.</summary>
|
||||
public static bool OnWater { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dagaz's running water: the Ocean biome burns and drains an Aswid in it or over it,
|
||||
/// swimming or flying - a bat cannot simply cross the sea. A boat carries you across, as
|
||||
/// the lore allows, so standing on one, steering one or sitting in one protects you.
|
||||
/// Dagaz's running water: open water burns and drains an Aswid in it or over it, swimming
|
||||
/// or flying - a bat cannot simply cross a lake or the sea. A boat carries you across, as
|
||||
/// the lore allows: on board there is no burn and no drain, but the sea still turns your
|
||||
/// stomach, so the camera keeps swaying.
|
||||
/// </summary>
|
||||
private void UpdateOpenSea(float dt)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
SEMan seman = player.GetSEMan();
|
||||
|
||||
AtSea = OnOpenSea(player);
|
||||
bool onBoat = OnBoat(player);
|
||||
bool exposed = !onBoat && InOpenWater(player);
|
||||
OnWater = AswidConfig.RunningWaterEnabled.Value && (exposed || (onBoat && BiomeAllowed(player)));
|
||||
|
||||
bool has = seman.HaveStatusEffect(OpenSeaHash);
|
||||
if (!AtSea)
|
||||
if (!exposed)
|
||||
{
|
||||
if (has) seman.RemoveStatusEffect(OpenSeaHash, true);
|
||||
return;
|
||||
|
|
@ -1549,17 +1557,34 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
private static bool OnOpenSea(Player player)
|
||||
private static bool OnBoat(Player player)
|
||||
{
|
||||
return player.GetStandingOnShip() != null || player.IsAttachedToShip() || player.GetControlledShip() != null;
|
||||
}
|
||||
|
||||
/// <summary>The Ocean-only setting, if on, limits everything here to the sea.</summary>
|
||||
private static bool BiomeAllowed(Player player)
|
||||
{
|
||||
return !AswidConfig.WaterOceanOnly.Value || player.GetCurrentBiome() == Heightmap.Biome.Ocean;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In water or over it. Valheim has one water plane for the sea, the rivers and the lakes
|
||||
/// alike, so "the terrain under you is below the water level" finds all three. Swimming
|
||||
/// counts wherever it happens. In the air it takes a metre of water below, so a jump over
|
||||
/// a puddle does not; standing on anything solid - a dock, a bridge, a shallow bank you
|
||||
/// are wading on - does not count, since the ground ray only sees terrain and would
|
||||
/// otherwise read a dock as open water.
|
||||
/// </summary>
|
||||
private static bool InOpenWater(Player player)
|
||||
{
|
||||
if (!AswidConfig.RunningWaterEnabled.Value) return false;
|
||||
if (player.GetCurrentBiome() != Heightmap.Biome.Ocean) return false;
|
||||
if (player.GetStandingOnShip() != null || player.IsAttachedToShip() || player.GetControlledShip() != null) return false;
|
||||
if (!BiomeAllowed(player)) return false;
|
||||
if (player.IsSwimming()) return true;
|
||||
if (player.IsOnGround() || ZoneSystem.instance == null) return false;
|
||||
|
||||
// The Ocean biome reaches up the beaches, so being in it is not enough: the seabed
|
||||
// under you has to be below the water. A shore walk stays dry; a swim or a flight
|
||||
// out past the shallows does not.
|
||||
if (ZoneSystem.instance == null) return false;
|
||||
return ZoneSystem.instance.GetGroundHeight(player.transform.position) < ZoneSystem.instance.m_waterLevel;
|
||||
float depth = ZoneSystem.instance.m_waterLevel - ZoneSystem.instance.GetGroundHeight(player.transform.position);
|
||||
return depth >= MinFlyOverDepth;
|
||||
}
|
||||
|
||||
private void UpdateAswidState()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue