RacesOfValheim/JotunnModStub/Fenrir/FenrirStatusEffects.cs
kanym af58fcec0d feat(fenrir): each form has a job once all three are unlocked
The Fenring and the Cultist ran at +100% while the Ulv, the form that
looks made for travel, ran at +50%. Now the Ulv is the travel form at
+100%, and the Fenring and the Cultist drop to +50%.

The Fenring holds the line: every hit on it lands 30% lighter. The
Cultist keeps its damage and pays for it: every hit lands 25% harder.
The scale sits in a new SE_FenrirFormBuff.OnDamaged, which runs on the
player's own machine before armor, so it covers hits from any client.

Speed and the damage factor are set on the live effect each time a form
is taken, so the Wolf and the Ulv can share SE_WolfForm with different
speeds, and a changed value applies without a relog. The speed keys
were renamed (Ulv Speed Bonus, Wolf Speed Bonus, Fenring And Cultist
Speed Bonus) so a saved .cfg cannot keep the old order. Suggested by
Lexsonn.
2026-11-02 16:23:35 +01:00

65 lines
2.2 KiB
C#

using System.Collections;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using UnityEngine.UI; // Added for UI
namespace RacesOfValheim
{
public class SE_FormCooldown : StatusEffect
{
public override void Stop()
{
base.Stop();
if (Player.m_localPlayer != null && FenrirConfig.ReadyMessage.Value)
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_ready", m_name));
}
}
}
/// <summary>
/// A form's buff, plus a scale on the hits it takes: the Fenring holds the line on less, the
/// Cultist pays for its fire with more. SEMan.OnDamaged runs in Character.RPC_Damage on the
/// owner's machine, ahead of armor and the health loss, so the scale reaches every hit,
/// whoever's machine the attacker is on.
/// </summary>
public class SE_FenrirFormBuff : SE_Stats
{
public float m_damageTakenFactor = 1f;
public override void OnDamaged(HitData hit, Character attacker)
{
base.OnDamaged(hit, attacker);
if (!Mathf.Approximately(m_damageTakenFactor, 1f)) hit.ApplyModifier(m_damageTakenFactor);
}
}
public class SE_FenrirCurse : SE_Stats
{
public override void Setup(Character character)
{
base.Setup(character);
if (character == Player.m_localPlayer)
{
Player.m_localPlayer.m_customData["FenrirCurse_Active"] = "true";
}
}
public override void UpdateStatusEffect(float dt)
{
base.UpdateStatusEffect(dt);
int state = BossProgressionManager.GetCurrentProgressionState();
m_fallDamageModifier = FenrirProgression.GetFallDamageModifier(state);
// SE_Stats.ModifySpeed adds baseSpeed * m_speedModifier, so this is the bonus alone:
// 0 is vanilla speed, 0.03 is +3%. A leading 1.0f here was a flat +100%.
m_speedModifier = FenrirProgression.GetSpeedModifier(state);
m_jumpModifier = new Vector3(0, FenrirProgression.GetJumpModifier(state), 0);
}
}
}