feat(aswid): sunlight, fire and pierce weaknesses
Each has its own switch under 'Aswid - Weaknesses'. Sunlight: by day under open sky, slower regen and movement and a slow burn that stops at 30% health; roofs, dungeons, Swamp, Mistlands, night and Eclipse shield you. Fire +25% until Fader, pierce +20%; both applied after resistances and armor, so meads still help and Mist Form stays pierce-immune.
This commit is contained in:
parent
77cdc67e97
commit
9149d3f0b5
13 changed files with 191 additions and 0 deletions
|
|
@ -508,6 +508,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
updateTimer = 0f;
|
||||
UpdateAswidState();
|
||||
UpdateSunlight(UpdateInterval);
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -1452,6 +1453,61 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Fader's Surtling form ends it, unless the setting keeps it for good.</summary>
|
||||
public static bool HasFireWeakness(int state)
|
||||
{
|
||||
if (!AswidConfig.FireWeaknessEnabled.Value) return false;
|
||||
return !(AswidConfig.FaderRemovesFireWeakness.Value && state >= 8);
|
||||
}
|
||||
|
||||
private static readonly int SunlightHash = "SE_AswidSunlight".GetStableHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// The V Rising weakness: by day, under open sky, the sun saps the Aswid. Anything that
|
||||
/// keeps the sky off you counts as shade - a roof by vanilla's own shelter test, a dungeon,
|
||||
/// the Swamp's and Mistlands' gloom, the night, and the Aswid's own Eclipse, which makes
|
||||
/// that spell an answer to the sun rather than only a damage boost.
|
||||
/// </summary>
|
||||
private void UpdateSunlight(float dt)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
SEMan seman = player.GetSEMan();
|
||||
|
||||
bool exposed = InSunlight(player);
|
||||
bool has = seman.HaveStatusEffect(SunlightHash);
|
||||
|
||||
if (!exposed)
|
||||
{
|
||||
if (has) seman.RemoveStatusEffect(SunlightHash, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!has) seman.AddStatusEffect(SunlightHash, true);
|
||||
(seman.GetStatusEffect(SunlightHash) as SE_AswidSunlight)?.Refresh();
|
||||
|
||||
// SetHealth rather than Damage or UseHealth: a burn every second should not stagger,
|
||||
// interrupt a swing or flash the screen red each time. Never below the floor, so
|
||||
// the sun can wear you down but never be what kills you.
|
||||
float floor = player.GetMaxHealth() * AswidConfig.SunHealthFloor.Value;
|
||||
float health = player.GetHealth();
|
||||
float loss = AswidConfig.SunHealthLossPerSecond.Value * dt;
|
||||
if (loss > 0f && health > floor)
|
||||
{
|
||||
player.SetHealth(Mathf.Max(floor, health - loss));
|
||||
}
|
||||
}
|
||||
|
||||
private bool InSunlight(Player player)
|
||||
{
|
||||
if (!AswidConfig.SunlightEnabled.Value) return false;
|
||||
if (EnvMan.instance == null || !EnvMan.IsDay()) return false;
|
||||
if (IsEclipseActive) return false;
|
||||
if (player.InInterior() || player.InShelter()) return false;
|
||||
|
||||
Heightmap.Biome biome = player.GetCurrentBiome();
|
||||
return biome != Heightmap.Biome.Swamp && biome != Heightmap.Biome.Mistlands;
|
||||
}
|
||||
|
||||
private void UpdateAswidState()
|
||||
{
|
||||
AswidSpectralClaw.PurgeAll(Player.m_localPlayer); // feature disabled for now, see AswidSpectralClaw.cs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue