diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs
index e1df615..557531c 100644
--- a/JotunnModStub/Fenrir/FenrirBehaviors.cs
+++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs
@@ -1034,25 +1034,30 @@ namespace RacesOfValheim
cultistAnim.SetFloat("sideway_speed", 0f);
// Per il Cultista usiamo esplicitamente il trigger dell'artigliata
+ int baseline = FenrirForms.AttackEvents;
+ float started = Time.time;
cultistAnim.SetTrigger("attack_claw");
FenrirAttackSync.Publish("attack_claw", "sfx_fenring_claw_start");
- yield return new WaitForSeconds(0.4f);
+ // The blow lands on the clip's own Hit event (ClawAttackCultist: 0.64 s of 1.33 s), and
+ // the lock holds until the clip is over. A fixed 0.4 s hit and a 0.5 s lock used to land
+ // the damage before the claw swung and let the next click start a new one mid-swing.
+ yield return null;
+ float length = ClipLength(1.33f);
+ yield return WaitForHit(baseline, started);
PlaySFX("sfx_fenring_claw_start");
-
ExecuteClawDamage(FenrirConfig.CultistClawDamage.Value);
- float remainingTimeToIdle = 0.5f - 0.4f;
- if (remainingTimeToIdle > 0)
- {
- yield return new WaitForSeconds(remainingTimeToIdle);
- }
-
+ yield return WaitUntilClipEnds(length, started);
cultistAnim.ResetTrigger("attack_claw");
isAttacking = false;
}
+ // Each swipe of the double claw deals this share of Double Claw Damage. Two swipes give
+ // 120% of what the old single hit dealt: a little more, for a slower swing that can be cut short.
+ private const float DoubleClawHitShare = 0.6f;
+
private IEnumerator DoubleClawRoutine()
{
isAttacking = true;
@@ -1061,24 +1066,63 @@ namespace RacesOfValheim
cultistAnim.SetFloat("forward_speed", 0f);
cultistAnim.SetFloat("sideway_speed", 0f);
+ int baseline = FenrirForms.AttackEvents;
+ float started = Time.time;
cultistAnim.SetTrigger("attack_claw_double");
FenrirAttackSync.Publish("attack_claw_double", "sfx_fenring_claw_start");
- // L'animazione double claw è più lunga, facciamo il danno un po' dopo
- yield return new WaitForSeconds(0.6f);
+ // DoubleClawAttackCultist carries two Hit events (0.64 s and 1.21 s of 1.83 s), one per
+ // swipe. It used to deal one hit at a fixed 0.6 s, so the second swipe did nothing.
+ yield return null;
+ float length = ClipLength(1.83f);
+ float damage = FenrirConfig.CultistDoubleClawDamage.Value * DoubleClawHitShare;
+ yield return WaitForHit(baseline, started);
PlaySFX("sfx_fenring_claw_start");
+ ExecuteClawDamage(damage);
- ExecuteClawDamage(FenrirConfig.CultistDoubleClawDamage.Value);
-
- // Attendiamo che l'animazione finisca (locking del giocatore)
- // L'animazione doppia del cultista dura circa 1.5 - 2 secondi
- yield return new WaitForSeconds(1.2f);
+ yield return WaitForHit(baseline + 1, started, HitEventTimeout + 0.6f);
+ PlaySFX("sfx_fenring_claw_start");
+ ExecuteClawDamage(damage);
+ yield return WaitUntilClipEnds(length, started);
cultistAnim.ResetTrigger("attack_claw_double");
isAttacking = false;
}
+ // Longest a swipe waits for its Hit event before landing anyway, measured from the trigger:
+ // a clip that never sends one must not leave the Cultist swinging at nothing.
+ private const float HitEventTimeout = 1.5f;
+
+ /// Waits until the clip has sent more than hit events since
+ /// the trigger, or until the timeout.
+ private IEnumerator WaitForHit(int seen, float started, float timeout = HitEventTimeout)
+ {
+ while (FenrirForms.AttackEvents <= seen && Time.time - started < timeout)
+ {
+ yield return null;
+ }
+ }
+
+ /// The attack clip's length, read a frame after its trigger, when the transition
+ /// into it has begun. is the clip's length in the game files.
+ private float ClipLength(float fallback)
+ {
+ AnimatorClipInfo[] clips = cultistAnim.IsInTransition(0)
+ ? cultistAnim.GetNextAnimatorClipInfo(0)
+ : cultistAnim.GetCurrentAnimatorClipInfo(0);
+ if (clips != null && clips.Length > 0 && clips[0].clip != null) return clips[0].clip.length;
+ return fallback;
+ }
+
+ /// Holds the lock until the clip has played out, clamped so a wrong reading can
+ /// neither cut a swing short nor freeze the form.
+ private IEnumerator WaitUntilClipEnds(float length, float started)
+ {
+ float remaining = Mathf.Clamp(length, 0.6f, 3f) - (Time.time - started);
+ if (remaining > 0f) yield return new WaitForSeconds(remaining);
+ }
+
private void ExecuteClawDamage(float baseDamage)
{
if (Player.m_localPlayer == null) return;
diff --git a/JotunnModStub/Fenrir/FenrirConfig.cs b/JotunnModStub/Fenrir/FenrirConfig.cs
index e9dd6e5..91718e4 100644
--- a/JotunnModStub/Fenrir/FenrirConfig.cs
+++ b/JotunnModStub/Fenrir/FenrirConfig.cs
@@ -154,7 +154,7 @@ namespace RacesOfValheim
CultistClawDamage = config.Bind(cultist, "Claw Damage", 85f,
new ConfigDescription("Base damage of the single claw (Left Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f)));
CultistDoubleClawDamage = config.Bind(cultist, "Double Claw Damage", 140f,
- new ConfigDescription("Base damage of the double claw (Middle Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f)));
+ new ConfigDescription("Base damage of the double claw (Middle Mouse), before the Unarmed skill bonus. Each of its two swipes deals 60% of it.", new AcceptableValueRange(0f, 500f)));
CultistAttackRadius = config.Bind(cultist, "Claw Attack Radius", 2.5f,
new ConfigDescription("Hit-sweep radius for both claw attacks.", new AcceptableValueRange(1f, 10f)));
CultistPushForce = config.Bind(cultist, "Claw Push Force", 30f,
diff --git a/JotunnModStub/Fenrir/FenrirFormShared.cs b/JotunnModStub/Fenrir/FenrirFormShared.cs
index 84dc78a..7ded0cd 100644
--- a/JotunnModStub/Fenrir/FenrirFormShared.cs
+++ b/JotunnModStub/Fenrir/FenrirFormShared.cs
@@ -18,6 +18,16 @@ namespace RacesOfValheim
/// form's own routines, and on every revert.
public static bool LocalAttacking { get; set; }
+ ///
+ /// How many hit events the local form's clips have fired: the creature's own "Hit" event,
+ /// which CharacterAnimEvent hands to the player's OnAttackTrigger, and BlockPlayerAttackTriggerPatch
+ /// counts here instead of letting it through. A swing waits for this to move, so its damage
+ /// lands on the clip's own blow (TrolTrueFormModel.AttackEvents, the same idea).
+ ///
+ public static int AttackEvents { get; private set; }
+
+ public static void NotifyAttackTrigger() => AttackEvents++;
+
public static bool LocalInForm(Character character)
{
if (character == null || character != Player.m_localPlayer) return false;
diff --git a/JotunnModStub/Fenrir/FenrirPatches.cs b/JotunnModStub/Fenrir/FenrirPatches.cs
index 4b91b46..cd7241d 100644
--- a/JotunnModStub/Fenrir/FenrirPatches.cs
+++ b/JotunnModStub/Fenrir/FenrirPatches.cs
@@ -56,7 +56,9 @@ namespace RacesOfValheim
{
public static bool Prefix(Humanoid __instance)
{
- return !FenrirForms.LocalInForm(__instance);
+ if (!FenrirForms.LocalInForm(__instance)) return true;
+ FenrirForms.NotifyAttackTrigger();
+ return false;
}
}