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
|
|
@ -41,6 +41,21 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> StaminaBonusPerState;
|
||||
public static ConfigEntry<float> StaminaCostMultiplier;
|
||||
|
||||
// ─── Weaknesses ──────────────────────────────────────────────────────────
|
||||
// The Discord reports said the race had no real downsides. Each weakness has its own
|
||||
// switch, so a single player can drop one; on a server the host's values win.
|
||||
public static ConfigEntry<bool> SunlightEnabled;
|
||||
public static ConfigEntry<float> SunHealthRegenPenalty;
|
||||
public static ConfigEntry<float> SunStaminaRegenPenalty;
|
||||
public static ConfigEntry<float> SunSpeedPenalty;
|
||||
public static ConfigEntry<float> SunHealthLossPerSecond;
|
||||
public static ConfigEntry<float> SunHealthFloor;
|
||||
public static ConfigEntry<bool> FireWeaknessEnabled;
|
||||
public static ConfigEntry<float> FireWeakness;
|
||||
public static ConfigEntry<bool> FaderRemovesFireWeakness;
|
||||
public static ConfigEntry<bool> PierceWeaknessEnabled;
|
||||
public static ConfigEntry<float> PierceWeakness;
|
||||
|
||||
// ─── Bat Form ────────────────────────────────────────────────────────────
|
||||
// The bat flies on the same directed flight as the Skadi's drakes (DirectedFlight.cs),
|
||||
// with its own numbers. It used to fly on vanilla's debug-fly flag: 50 m/s, free, blind
|
||||
|
|
@ -168,6 +183,30 @@ namespace RacesOfValheim
|
|||
StaminaCostMultiplier = config.Bind(stamina, "Stamina Cost Multiplier", 1f,
|
||||
new ConfigDescription("Multiplies every stamina cost: sprinting, swimming, attacks, blocking. 1 is the normal cost, 0.5 half. There is no infinite setting on purpose; set the bonuses above high instead.", new AcceptableValueRange<float>(0.1f, 2f)));
|
||||
|
||||
const string weak = "Aswid - Weaknesses";
|
||||
SunlightEnabled = config.Bind(weak, "Sunlight", true,
|
||||
new ConfigDescription("Weakens you by day while you stand under open sky. A roof (the same test as the game's Sheltered status), a dungeon, the Swamp, the Mistlands, the night and your own Eclipse all shield you.", null));
|
||||
SunHealthRegenPenalty = config.Bind(weak, "Sunlight Health Regen Penalty", 0.5f,
|
||||
new ConfigDescription("Health regeneration lost in sunlight. 0.5 = half.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
SunStaminaRegenPenalty = config.Bind(weak, "Sunlight Stamina Regen Penalty", 0.25f,
|
||||
new ConfigDescription("Stamina regeneration lost in sunlight. 0.25 = a quarter.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
SunSpeedPenalty = config.Bind(weak, "Sunlight Speed Penalty", 0.1f,
|
||||
new ConfigDescription("Movement speed lost in sunlight. 0.1 = 10% slower.", new AcceptableValueRange<float>(0f, 0.9f)));
|
||||
SunHealthLossPerSecond = config.Bind(weak, "Sunlight Health Loss Per Second", 0.5f,
|
||||
new ConfigDescription("Health the sun burns away each second. 0 turns it off.", new AcceptableValueRange<float>(0f, 10f)));
|
||||
SunHealthFloor = config.Bind(weak, "Sunlight Health Floor", 0.3f,
|
||||
new ConfigDescription("The sun stops burning at this fraction of your max health, so it weakens you but never kills you. 0.3 = 30%.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
FireWeaknessEnabled = config.Bind(weak, "Fire Weakness", true,
|
||||
new ConfigDescription("Fire, burning included, hurts more.", null));
|
||||
FireWeakness = config.Bind(weak, "Fire Weakness Amount", 0.25f,
|
||||
new ConfigDescription("Extra fire damage taken. 0.25 = 25% more. Resistance meads and armour still reduce it.", new AcceptableValueRange<float>(0f, 2f)));
|
||||
FaderRemovesFireWeakness = config.Bind(weak, "Fader Removes Fire Weakness", true,
|
||||
new ConfigDescription("Defeating Fader, the boss that grants the Surtling form, ends the fire weakness.", null));
|
||||
PierceWeaknessEnabled = config.Bind(weak, "Pierce Weakness", true,
|
||||
new ConfigDescription("Pierce damage (arrows, spears, stakes) hurts more. Mist Form's immunity still wins.", null));
|
||||
PierceWeakness = config.Bind(weak, "Pierce Weakness Amount", 0.2f,
|
||||
new ConfigDescription("Extra pierce damage taken. 0.2 = 20% more.", new AcceptableValueRange<float>(0f, 2f)));
|
||||
|
||||
const string batform = "Aswid - Bat Form";
|
||||
// Same controls as the Skadi's drake: aim with the camera, W beats forward, Shift
|
||||
// sprints, S beats backwards, and letting go hovers briefly before gliding down.
|
||||
|
|
|
|||
|
|
@ -219,6 +219,32 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fire and pierce hurt the Aswid more: fire for the old way vampires end, pierce for the
|
||||
/// stake. A plain multiplier, like the Trol's fire weakness, rather than DamageModifier.Weak,
|
||||
/// which is a fixed +50% with nothing in between. ApplyDamage runs after resistances, so a
|
||||
/// fire resistance mead still helps, and Mist Form's pierce immunity has already zeroed the
|
||||
/// pierce by the time this sees it.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage")]
|
||||
public static class Aswid_Weakness_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, ref HitData hit)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer || !AswidRace.IsAswid()) return;
|
||||
|
||||
if (AswidRace.HasFireWeakness(BossProgressionManager.GetCurrentProgressionState()) && hit.m_damage.m_fire > 0f)
|
||||
{
|
||||
hit.m_damage.m_fire *= 1f + AswidConfig.FireWeakness.Value;
|
||||
}
|
||||
|
||||
if (AswidConfig.PierceWeaknessEnabled.Value && hit.m_damage.m_pierce > 0f)
|
||||
{
|
||||
hit.m_damage.m_pierce *= 1f + AswidConfig.PierceWeakness.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), "StartAttack")]
|
||||
public static class Aswid_Attack_Patch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -65,6 +65,30 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sunlight on an exposed Aswid. Its numbers are rewritten from AswidConfig every time
|
||||
/// AswidRace.UpdateSunlight runs, so a slider moves them live; the health loss is not a stat
|
||||
/// and is applied by that same tick.
|
||||
/// </summary>
|
||||
public class SE_AswidSunlight : SE_Stats
|
||||
{
|
||||
public override void Setup(Character character)
|
||||
{
|
||||
base.Setup(character);
|
||||
name = "SE_AswidSunlight";
|
||||
m_name = "$rov_se_aswid_sunlight_name";
|
||||
m_tooltip = "$rov_se_aswid_sunlight_tooltip";
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
m_healthRegenMultiplier = 1f - AswidConfig.SunHealthRegenPenalty.Value;
|
||||
m_staminaRegenMultiplier = 1f - AswidConfig.SunStaminaRegenPenalty.Value;
|
||||
m_speedModifier = -AswidConfig.SunSpeedPenalty.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public class SE_MistForm : SE_Stats
|
||||
{
|
||||
public override void Setup(Character character)
|
||||
|
|
@ -124,6 +148,11 @@ namespace RacesOfValheim
|
|||
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(batForm, fixReference: false));
|
||||
|
||||
var sunlight = ScriptableObject.CreateInstance<SE_AswidSunlight>();
|
||||
sunlight.name = "SE_AswidSunlight";
|
||||
sunlight.m_icon = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophySurtling")?.m_itemData.m_shared.m_icons[0];
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(sunlight, fixReference: false));
|
||||
|
||||
var mistForm = ScriptableObject.CreateInstance<SE_MistForm>();
|
||||
mistForm.name = "SE_MistForm";
|
||||
mistForm.m_icon = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophyWraith")?.m_itemData.m_shared.m_icons[0];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue