Merge branch 'localisation' into localisation-turkish

This commit is contained in:
kanym 2026-11-11 15:57:30 +01:00
commit e76b7a960e
11 changed files with 265 additions and 47 deletions

View file

@ -38,6 +38,37 @@ namespace RacesOfValheim
} }
} }
/// <summary>
/// Hair and beard never attach to an Alfr. Every equipment change makes the game write the
/// profile's hair back (Humanoid.SetupVisEquipment), and ApplyHairless only clears it on its
/// 0.5s pass, so players saw the hair flash in for a moment. Zeroing the hash here, where
/// VisEquipment spawns the model, means it never appears. Covers remote players too, since
/// their visuals go through the same call.
/// </summary>
[HarmonyPatch(typeof(VisEquipment), "SetHairEquipped")]
public static class Alfar_SetHairEquipped_Patch
{
public static void Prefix(VisEquipment __instance, ref int hash)
{
if (hash != 0 && IsAlfarVis(__instance)) hash = 0;
}
}
[HarmonyPatch(typeof(VisEquipment), "SetBeardEquipped")]
public static class Alfar_SetBeardEquipped_Patch
{
public static void Prefix(VisEquipment __instance, ref int hash)
{
if (hash != 0 && IsAlfarVis(__instance)) hash = 0;
}
}
private static bool IsAlfarVis(VisEquipment vis)
{
Player player = vis.GetComponent<Player>();
return player != null && AlfarVisuals.IsAlfarPlayer(player);
}
/// <summary> /// <summary>
/// The character preview on the main menu is a Player too, with the saved race in its custom data /// The character preview on the main menu is a Player too, with the saved race in its custom data
/// and no ZNetView. Its Update may never run, so a small driver on it keeps the look: skin, hair, /// and no ZNetView. Its Update may never run, so a small driver on it keeps the look: skin, hair,

View file

@ -413,6 +413,27 @@ namespace RacesOfValheim
return true; return true;
} }
private static readonly System.Collections.Generic.Dictionary<string, ItemDrop.ItemData.SharedData> weapons =
new System.Collections.Generic.Dictionary<string, ItemDrop.ItemData.SharedData>();
/// <summary>
/// A creature's own attack item (dragon_bite, SeekerBrute_ram...), read once and cached,
/// null if the game has none by that name. A hand-built swing skips Attack, and Attack is
/// where vanilla plays the item's m_triggerEffect and m_hitEffect, so a form that wants the
/// creature's real swing and impact sounds plays them from here.
/// </summary>
public static ItemDrop.ItemData.SharedData CreatureWeapon(string prefabName)
{
if (string.IsNullOrEmpty(prefabName)) return null;
if (weapons.TryGetValue(prefabName, out ItemDrop.ItemData.SharedData cached)) return cached;
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(prefabName);
ItemDrop.ItemData.SharedData shared = prefab != null ? prefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared : null;
if (shared == null) Jotunn.Logger.LogWarning($"[FormMelee] No attack item '{prefabName}'; that swing stays silent.");
weapons[prefabName] = shared;
return shared;
}
public static void LogHit(string form, IDestructible target, float damage) public static void LogHit(string form, IDestructible target, float damage)
{ {
if (!FenrirConfig.DebugFormHits.Value) return; if (!FenrirConfig.DebugFormHits.Value) return;

View file

@ -1,7 +1,7 @@
{ {
"name": "RacesOfValheim", "name": "RacesOfValheim",
"description": "A Valheim mod that adds eleven custom playable races (Alfar, Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", "description": "A Valheim mod that adds eleven custom playable races (Alfar, Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
"version_number": "1.6.9", "version_number": "1.6.10",
"website_url": "", "website_url": "",
"dependencies": [ "dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333", "denikson-BepInExPack_Valheim-5.4.2333",

View file

@ -16,7 +16,7 @@ namespace RacesOfValheim
{ {
public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginGUID = "com.nandor.racesofvalheim";
public const string PluginName = "Races Of Valheim"; public const string PluginName = "Races Of Valheim";
public const string PluginVersion = "1.6.9"; public const string PluginVersion = "1.6.10";
private readonly Harmony harmony = new Harmony(PluginGUID); private readonly Harmony harmony = new Harmony(PluginGUID);

View file

@ -311,6 +311,29 @@ namespace RacesOfValheim
return true; return true;
} }
/// <summary>
/// How many hit events the form's clips have sent: the dragon's own "Hit" event, which
/// CharacterAnimEvent hands to the player's OnAttackTrigger and SkadiBlockAttackTriggerPatch
/// counts here instead of letting it through. FenrirForms.AttackEvents, the same idea.
/// </summary>
public static int AttackEvents { get; private set; }
public static void NotifyAttackTrigger() => AttackEvents++;
// Longest a melee waits for its Hit event before landing anyway, from the trigger. The
// slowest blow is the Moder's claw at 2.0 s of 3.75 s; a clip that never sends one must
// not leave the swing hitting nothing.
private const float HitEventTimeout = 3f;
/// <summary>
/// Waits for the clip's own blow. A fixed 0.5 s used to land every melee early, read off the
/// game's clips: Moder bite 0.60 s and claws 2.0 s, Fader bite 1.27 s, claws 1.24 s, spin 1.30 s.
/// </summary>
private IEnumerator WaitForHit(int baseline, float started)
{
while (AttackEvents == baseline && Time.time - started < HitEventTimeout) yield return null;
}
private IEnumerator PerformAttackCoroutine(int button) private IEnumerator PerformAttackCoroutine(int button)
{ {
lastAttackTime = Time.time; lastAttackTime = Time.time;
@ -409,13 +432,18 @@ namespace RacesOfValheim
breathingUntil = Time.time + projDelay + projCount * 0.05f + 0.5f; breathingUntil = Time.time + projDelay + projCount * 0.05f + 0.5f;
} }
int hitBaseline = AttackEvents;
float triggeredAt = Time.time;
SetAttackTrigger(attackTrigger); SetAttackTrigger(attackTrigger);
yield return new WaitForSeconds(projDelay);
if (isMelee) if (isMelee)
{ {
ExecuteMeleeDamage(MODER_MELEE_DAMAGE, MELEE_RADIUS); yield return WaitForHit(hitBaseline, triggeredAt);
ExecuteMeleeDamage(MODER_MELEE_DAMAGE, MELEE_RADIUS, MeleeWeapon(attackTrigger));
}
else
{
yield return new WaitForSeconds(projDelay);
} }
if (!isMelee && projName != null) if (!isMelee && projName != null)
@ -515,13 +543,18 @@ namespace RacesOfValheim
breathingUntil = Time.time + projDelay + projCount * 0.05f + 0.5f; breathingUntil = Time.time + projDelay + projCount * 0.05f + 0.5f;
} }
int hitBaseline = AttackEvents;
float triggeredAt = Time.time;
SetAttackTrigger(attackTrigger); SetAttackTrigger(attackTrigger);
yield return new WaitForSeconds(projDelay);
if (isMelee) if (isMelee)
{ {
ExecuteMeleeDamage(meleeDamage, meleeRadius); yield return WaitForHit(hitBaseline, triggeredAt);
ExecuteMeleeDamage(meleeDamage, meleeRadius, MeleeWeapon(attackTrigger));
}
else
{
yield return new WaitForSeconds(projDelay);
} }
if (!isMelee && projName != null) if (!isMelee && projName != null)
@ -583,7 +616,28 @@ namespace RacesOfValheim
// The dragon forms never go through Humanoid.StartAttack - SkadiAttackPatch blocks it, and // The dragon forms never go through Humanoid.StartAttack - SkadiAttackPatch blocks it, and
// they carry no weapon - so the bite, claw and spin animations landed no damage at all and // they carry no weapon - so the bite, claw and spin animations landed no damage at all and
// simply burned eitr. Sweep for targets the way FenrirBehaviors does for its claws. // simply burned eitr. Sweep for targets the way FenrirBehaviors does for its claws.
private void ExecuteMeleeDamage(float baseDamage, float radius) private string FormLabel => formRules != null ? formRules.Form.ToString() : "Skadi form";
/// <summary>
/// The real creature's attack item behind each melee trigger, for its impact sound. The
/// Fader's spin has no item of its own in the game's manifest, so it borrows the claw's.
/// </summary>
private string MeleeWeapon(string trigger)
{
bool fader = formRules != null && formRules.Form == SkadiProgression.FormType.SkeletonDragon;
switch (trigger)
{
case "attack_bite": return fader ? "Fader_Bite" : "dragon_bite";
case "attack_claw_left": return "dragon_claw_left";
case "attack_claw_right": return "dragon_claw_right";
case "attack_ClawL": return "Fader_Claw_Left";
case "attack_ClawR": return "Fader_Claw_Right";
case "attack_Spin": return "Fader_Claw_Left";
default: return null;
}
}
private void ExecuteMeleeDamage(float baseDamage, float radius, string weapon)
{ {
if (Player.m_localPlayer == null) return; if (Player.m_localPlayer == null) return;
@ -598,6 +652,8 @@ namespace RacesOfValheim
int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle"); int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle");
Collider[] hits = Physics.OverlapSphere(attackPoint, radius, layerMask); Collider[] hits = Physics.OverlapSphere(attackPoint, radius, layerMask);
FormMelee.LogSwing(FormLabel, hits.Length);
ItemDrop.ItemData.SharedData shared = FormMelee.CreatureWeapon(weapon);
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>(); System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false; bool hitCreature = false;
@ -613,18 +669,29 @@ namespace RacesOfValheim
if (characterTarget != null && characterTarget == Player.m_localPlayer) continue; if (characterTarget != null && characterTarget == Player.m_localPlayer) continue;
GameObject targetObj = (target as MonoBehaviour)?.gameObject; GameObject targetObj = (target as MonoBehaviour)?.gameObject;
if (targetObj != null) // Marked only once it is hit, further down: marking it here let the first collider
{ // found (a limb outside the arc) rule out a body squarely in the swing.
if (hitObjects.Contains(targetObj)) continue; if (targetObj != null && hitObjects.Contains(targetObj)) continue;
hitObjects.Add(targetObj);
}
Vector3 targetCenter = hit.bounds.center; Vector3 targetCenter = hit.bounds.center;
Vector3 dirToTarget = (targetCenter - playerPos).normalized; Vector3 dirToTarget = (targetCenter - playerPos).normalized;
if (!fullCircle && Vector3.Angle(forward, dirToTarget) >= 70f) continue; float angle = Vector3.Angle(forward, dirToTarget);
if (!fullCircle && angle >= 70f)
{
FormMelee.LogMiss(FormLabel, hit, $"outside the swing arc ({angle:0} deg)");
continue;
}
// FormMelee.CanReach, not a bare Linecast. The Linecast tested the piece layer and
// counted the target's own collider as cover, so anything living on that layer
// could never be hit: the T.W.I.G. training dummy is a Humanoid whose only collider
// is on "piece". Wildlife sits on "character" and was never affected.
Vector3 eyePos = playerPos + Vector3.up * 1.5f; Vector3 eyePos = playerPos + Vector3.up * 1.5f;
if (Physics.Linecast(eyePos, targetCenter, out RaycastHit rayHit, LayerMask.GetMask("Default", "static_solid", "terrain", "piece"))) continue; if (!FormMelee.CanReach(eyePos, attackPoint, hit, target, out string cover))
{
FormMelee.LogMiss(FormLabel, hit, "no clear line, blocked by '" + cover + "'");
continue;
}
HitData hitData = new HitData(); HitData hitData = new HitData();
// Frost-flavoured maul; SkadiDamagePatch tops this up with the per-tier frost bonus. // Frost-flavoured maul; SkadiDamagePatch tops this up with the per-tier frost bonus.
@ -640,8 +707,11 @@ namespace RacesOfValheim
hitData.m_toolTier = 0; hitData.m_toolTier = 0;
hitData.SetAttacker(Player.m_localPlayer); hitData.SetAttacker(Player.m_localPlayer);
if (targetObj != null) hitObjects.Add(targetObj);
FormMelee.LogHit(FormLabel, target, totalDamage);
target.Damage(hitData); target.Damage(hitData);
FormMelee.GrantAdrenaline(target); FormMelee.GrantAdrenaline(target);
shared?.m_hitEffect.Create(targetCenter, Quaternion.identity);
if (characterTarget != null) hitCreature = true; if (characterTarget != null) hitCreature = true;
} }

View file

@ -408,7 +408,11 @@ namespace RacesOfValheim
public static bool Prefix(Humanoid __instance) public static bool Prefix(Humanoid __instance)
{ {
if (__instance != Player.m_localPlayer) return true; if (__instance != Player.m_localPlayer) return true;
return __instance.GetComponentInChildren<DrakeFormBehavior>() == null; if (__instance.GetComponentInChildren<DrakeFormBehavior>() == null) return true;
// The dragon's own clip calling its blow: the hit cue for the form's melee.
DrakeFormBehavior.NotifyAttackTrigger();
return false;
} }
} }
} }

View file

@ -46,6 +46,7 @@ namespace RacesOfValheim
public static ConfigEntry<float> RavagerYawDegrees; public static ConfigEntry<float> RavagerYawDegrees;
public static ConfigEntry<float> RavagerAttackOffsetValue; public static ConfigEntry<float> RavagerAttackOffsetValue;
public static ConfigEntry<bool> RavagerSlamCraterValue; public static ConfigEntry<bool> RavagerSlamCraterValue;
public static ConfigEntry<float> RavagerDamageShareValue;
// ─── Colony caps ───────────────────────────────────────────────────── // ─── Colony caps ─────────────────────────────────────────────────────
// Every ceiling on how many things the colony can have alive at once, in one section, so // Every ceiling on how many things the colony can have alive at once, in one section, so
@ -231,6 +232,11 @@ namespace RacesOfValheim
"The middle-click slam digs into the ground where it lands, like a pickaxe blow. " + "The middle-click slam digs into the ground where it lands, like a pickaxe blow. " +
"Never inside a ward you have no access to."); "Never inside a ward you have no access to.");
RavagerDamageShareValue = config.Bind(ravager, "Ravager Attack Damage", 1f,
new ConfigDescription("Share of a real Seeker Brute's damage each Ravager attack deals. " +
"Your Unarmed skill then scales it the way it scales a weapon: about 40% at level 0, " +
"about 92% at level 100.", new AcceptableValueRange<float>(0.1f, 2f)));
EmberGlowStrength = config.Bind(ember, "Glow Strength", SvermConfig.EmberGlowStrength, EmberGlowStrength = config.Bind(ember, "Glow Strength", SvermConfig.EmberGlowStrength,
"How hot the chitin burns at Fader. This multiplies an HDR colour and it is applied " + "How hot the chitin burns at Fader. This multiplies an HDR colour and it is applied " +
"to the chest, the legs and the helmet at once, so it goes a very long way. Settled " + "to the chest, the legs and the helmet at once, so it goes a very long way. Settled " +
@ -364,6 +370,7 @@ namespace RacesOfValheim
public static float RavagerYaw => RavagerYawDegrees?.Value ?? 0f; public static float RavagerYaw => RavagerYawDegrees?.Value ?? 0f;
public static float RavagerAttackOffset => RavagerAttackOffsetValue?.Value ?? 1.5f; public static float RavagerAttackOffset => RavagerAttackOffsetValue?.Value ?? 1.5f;
public static bool RavagerSlamCrater => RavagerSlamCraterValue?.Value ?? true; public static bool RavagerSlamCrater => RavagerSlamCraterValue?.Value ?? true;
public static float RavagerDamageShare => RavagerDamageShareValue?.Value ?? 1f;
public static bool Spines => SpinesEnabled?.Value ?? false; public static bool Spines => SpinesEnabled?.Value ?? false;
public static float SizeSmall => SpineSizeSmall?.Value ?? SvermConfig.SpineSizeSmall; public static float SizeSmall => SpineSizeSmall?.Value ?? SvermConfig.SpineSizeSmall;

View file

@ -24,6 +24,29 @@ namespace RacesOfValheim
{ {
public string Trigger; public string Trigger;
public HitData.DamageTypes Damage; public HitData.DamageTypes Damage;
/// <summary>The Brute weapon itself, for its swing (m_triggerEffect) and impact
/// (m_hitEffect) sounds. Vanilla plays both inside Attack, which this form never runs,
/// so without them every hit landed silent. Null if the weapon was missing.</summary>
public ItemDrop.ItemData.SharedData Shared;
/// <summary>The weapon's own push (m_attackForce), tool tier and swing arc, the way
/// TrolTrueFormModel.Profile carries the troll's.</summary>
public float PushForce;
public int ToolTier;
public float Angle;
}
/// <summary>
/// One blow's damage: the Brute's, times Ravager Attack Damage, times the Unarmed skill
/// factor the way a weapon's skill scales it (0.25-0.55 at level 0, 0.85-1 at 100).
/// TrolTrueFormModel.DamageFor does the same with Clubs for the troll.
/// </summary>
public static HitData.DamageTypes DamageFor(Player player, Profile profile)
{
HitData.DamageTypes damage = profile.Damage.Clone();
damage.Modify(SvermConfigManagement.RavagerDamageShare * player.GetRandomSkillFactor(Skills.SkillType.Unarmed));
return damage;
} }
private static Profile bite; private static Profile bite;
@ -72,6 +95,10 @@ namespace RacesOfValheim
{ {
Trigger = shared.m_attack != null ? (shared.m_attack.m_attackAnimation ?? "") : "", Trigger = shared.m_attack != null ? (shared.m_attack.m_attackAnimation ?? "") : "",
Damage = shared.m_damages, Damage = shared.m_damages,
Shared = shared,
PushForce = shared.m_attackForce,
ToolTier = shared.m_toolTier,
Angle = shared.m_attack != null ? shared.m_attack.m_attackAngle : 90f,
}; };
Jotunn.Logger.LogInfo($"[Sverm] Ravager Strain reads '{profile.Trigger}' off '{sourcePrefabName}' - " + Jotunn.Logger.LogInfo($"[Sverm] Ravager Strain reads '{profile.Trigger}' off '{sourcePrefabName}' - " +

View file

@ -794,7 +794,7 @@ namespace RacesOfValheim
{ {
if (FormStagger.AttackInterrupted) return; if (FormStagger.AttackInterrupted) return;
if (slam) Slam(profile, radius, leftY, rightY, dropSamples); if (slam) Slam(profile, radius, leftY, rightY, dropSamples);
else ExecuteDamage(profile, radius); else ExecuteDamage(profile, radius, false);
}, () => }, () =>
{ {
if (leftClaw == null || rightClaw == null) return; if (leftClaw == null || rightClaw == null) return;
@ -828,7 +828,11 @@ namespace RacesOfValheim
{ {
Player player = Player.m_localPlayer; Player player = Player.m_localPlayer;
if (player != null) if (player != null)
ApplyDamageInSphere(player.transform.position + Vector3.up, SvermConfig.RavagerTauntRadius, profile.Damage); {
// No Strike: the roar above is the taunt's sound, the weapon's would double it.
if (ApplyDamageInSphere(player.transform.position + Vector3.up, SvermConfig.RavagerTauntRadius, profile, true))
FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
}
}, null); }, null);
isAttacking = false; isAttacking = false;
@ -844,6 +848,11 @@ namespace RacesOfValheim
{ {
if (hasForwardSpeed) anim.SetFloat("forward_speed", 0f); if (hasForwardSpeed) anim.SetFloat("forward_speed", 0f);
// The Brute weapon's swing sound, which vanilla plays in Attack.Start (the bite's
// snap, the ram's charge, the slam's wind-up). The taunt's weapon has none.
Player player = Player.m_localPlayer;
if (player != null) profile.Shared?.m_startEffect.Create(player.transform.position, player.transform.rotation, player.transform);
if (string.IsNullOrEmpty(profile.Trigger) || !knownTriggers.Contains(profile.Trigger)) return false; if (string.IsNullOrEmpty(profile.Trigger) || !knownTriggers.Contains(profile.Trigger)) return false;
anim.SetTrigger(profile.Trigger); anim.SetTrigger(profile.Trigger);
@ -944,14 +953,14 @@ namespace RacesOfValheim
Transform claw = StrikingClaw(leftY, rightY, samples); Transform claw = StrikingClaw(leftY, rightY, samples);
if (claw == null) if (claw == null)
{ {
ExecuteDamage(profile, radius); ExecuteDamage(profile, radius, true);
Player player = Player.m_localPlayer; Player player = Player.m_localPlayer;
if (player != null) if (player != null)
DigCrater(player.transform.position + player.transform.forward * SvermConfigManagement.RavagerAttackOffset); DigCrater(player.transform.position + player.transform.forward * SvermConfigManagement.RavagerAttackOffset);
return; return;
} }
ApplyDamageInSphere(claw.position + Vector3.up * 0.5f, radius, profile.Damage); Strike(claw.position + Vector3.up * 0.5f, radius, profile, true);
DigCrater(claw.position); DigCrater(claw.position);
} }
@ -985,14 +994,14 @@ namespace RacesOfValheim
/// FenrirBehaviors.ExecuteClawDamage, unchanged in shape: a sphere swept against the same /// FenrirBehaviors.ExecuteClawDamage, unchanged in shape: a sphere swept against the same
/// broad layer mask every melee form in this mod already uses. /// broad layer mask every melee form in this mod already uses.
/// </summary> /// </summary>
private void ExecuteDamage(SvermRavagerAttacks.Profile profile, float radius) private void ExecuteDamage(SvermRavagerAttacks.Profile profile, float radius, bool slam)
{ {
Player player = Player.m_localPlayer; Player player = Player.m_localPlayer;
if (player == null) return; if (player == null) return;
float reach = SvermConfigManagement.RavagerAttackOffset; float reach = SvermConfigManagement.RavagerAttackOffset;
Vector3 attackPoint = player.transform.position + player.transform.forward * reach + Vector3.up; Vector3 attackPoint = player.transform.position + player.transform.forward * reach + Vector3.up;
ApplyDamageInSphere(attackPoint, radius, profile.Damage); Strike(attackPoint, radius, profile, slam);
} }
private const string CraterPrefab = "digg_v3"; private const string CraterPrefab = "digg_v3";
@ -1015,26 +1024,40 @@ namespace RacesOfValheim
if (crater != null) Object.Instantiate(crater, ground.point, Quaternion.identity); if (crater != null) Object.Instantiate(crater, ground.point, Quaternion.identity);
} }
private const string FormLabel = "Ravager";
private static readonly int HitMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece",
"piece_nonsolid", "terrain", "character", "character_net", "character_ghost",
"hitbox", "character_noenv", "vehicle");
/// <summary> /// <summary>
/// The actual sweep, shared by every attack this form has (the three forward swings and /// The actual sweep, shared by every attack this form has. TrolTrueFormHit.SphereHit in
/// the taunt's own AoE) - only the sphere's centre and radius differ between them. /// shape: a forward swing stays inside its arc (the Brute's own, widened to 75 degrees each
/// side the way the troll's is), the slam's claws and the taunt reach all around, and
/// FormMelee.CanReach keeps a blow from landing through a wall. Each target that takes the
/// blow plays the Brute weapon's own impact effect, which vanilla plays inside Attack.
/// ///
/// m_skill is Swords, deliberately NOT Unarmed: Sverm_Damage_Patch rewrites any Unarmed /// m_skill is Swords, deliberately NOT Unarmed: Sverm_Damage_Patch rewrites any Unarmed
/// hit from a Sverm into the Chitin Claws' own tier damage, and that patch fires for THIS /// hit from a Sverm into the Chitin Claws' own tier damage, and that patch fires for THIS
/// call too, since it hooks Character.Damage itself rather than caring who dealt the hit. /// call too, since it hooks Character.Damage itself rather than caring who dealt the hit.
/// Swords keeps that rewrite from overwriting the Brute's real numbers with the claws'. /// Swords keeps that rewrite from overwriting the Brute's numbers with the claws'. It is
/// the Brute weapons' own skill too. The damage still scales with Unarmed (DamageFor).
/// </summary> /// </summary>
private static void ApplyDamageInSphere(Vector3 center, float radius, HitData.DamageTypes damage) /// <returns>True if the blow landed on a creature, so the caller raises the skill.</returns>
private static bool ApplyDamageInSphere(Vector3 center, float radius, SvermRavagerAttacks.Profile profile, bool allAround)
{ {
Player player = Player.m_localPlayer; Player player = Player.m_localPlayer;
if (player == null) return; if (player == null) return false;
int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", Vector3 pos = player.transform.position;
"piece_nonsolid", "terrain", "character", "character_net", "character_ghost", Vector3 forward = player.transform.forward;
"hitbox", "character_noenv", "vehicle"); float halfAngle = allAround ? 180f : Mathf.Max(75f, profile.Angle * 0.5f);
HitData.DamageTypes damage = SvermRavagerAttacks.DamageFor(player, profile);
Collider[] hits = Physics.OverlapSphere(center, radius, layerMask); Collider[] hits = Physics.OverlapSphere(center, radius, HitMask);
FormMelee.LogSwing(FormLabel, hits.Length);
var hitObjects = new System.Collections.Generic.HashSet<GameObject>(); var hitObjects = new System.Collections.Generic.HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider hit in hits) foreach (Collider hit in hits)
{ {
@ -1042,35 +1065,65 @@ namespace RacesOfValheim
if (hit.attachedRigidbody != null && hit.attachedRigidbody.gameObject == player.gameObject) continue; if (hit.attachedRigidbody != null && hit.attachedRigidbody.gameObject == player.gameObject) continue;
IDestructible target = hit.GetComponentInParent<IDestructible>(); IDestructible target = hit.GetComponentInParent<IDestructible>();
if (target == null) continue; if (target == null || (target is Character self && self == player)) continue;
if (target is Character characterTarget && characterTarget == player) continue;
// Marked only once it is hit, further down, so a limb outside the arc does not rule
// out a body squarely in the swing.
GameObject targetObj = (target as MonoBehaviour)?.gameObject; GameObject targetObj = (target as MonoBehaviour)?.gameObject;
if (targetObj != null) if (targetObj != null && hitObjects.Contains(targetObj)) continue;
{
if (hitObjects.Contains(targetObj)) continue;
hitObjects.Add(targetObj);
}
Vector3 targetCenter = hit.bounds.center; Vector3 targetCenter = hit.bounds.center;
Vector3 dirToTarget = (targetCenter - player.transform.position).normalized; Vector3 flat = targetCenter - pos;
flat.y = 0f;
float angle = flat.sqrMagnitude > 0.0001f ? Vector3.Angle(forward, flat) : 0f;
if (angle > halfAngle)
{
FormMelee.LogMiss(FormLabel, hit, $"outside the swing arc ({angle:0} deg)");
continue;
}
if (!FormMelee.CanReach(player.GetEyePoint(), center, hit, target, out string cover))
{
FormMelee.LogMiss(FormLabel, hit, "no clear line, blocked by '" + cover + "'");
continue;
}
HitData hitData = new HitData(); HitData hitData = new HitData();
hitData.m_damage = damage; hitData.m_damage = damage;
hitData.m_point = targetCenter; hitData.m_point = targetCenter;
hitData.m_dir = dirToTarget; hitData.m_dir = (targetCenter - pos).normalized;
hitData.m_pushForce = 40f; hitData.m_pushForce = profile.PushForce;
hitData.m_skill = Skills.SkillType.Swords; hitData.m_skill = Skills.SkillType.Swords;
hitData.m_dodgeable = true; hitData.m_dodgeable = true;
hitData.m_blockable = true; hitData.m_blockable = true;
hitData.m_hitType = HitData.HitType.PlayerHit; hitData.m_hitType = HitData.HitType.PlayerHit;
hitData.m_toolTier = 100; hitData.m_toolTier = (short)profile.ToolTier;
hitData.SetAttacker(player); hitData.SetAttacker(player);
if (targetObj != null) hitObjects.Add(targetObj);
FormMelee.LogHit(FormLabel, target, damage.GetTotalDamage());
target.Damage(hitData); target.Damage(hitData);
FormMelee.GrantAdrenaline(target); FormMelee.GrantAdrenaline(target);
profile.Shared?.m_hitEffect.Create(targetCenter, Quaternion.identity);
if (target is Character) hitCreature = true;
} }
return hitCreature;
}
/// <summary>
/// One blow of a Ravager attack: the Brute weapon's trigger effect (the slam's landing
/// thud; the bite and the ram have none), the sweep, and the Unarmed experience vanilla
/// pays inside Attack for a swing that reached a creature. The Ravager fights unarmed like
/// the rest of the Sverm, so that is the skill it trains.
/// </summary>
private static void Strike(Vector3 center, float radius, SvermRavagerAttacks.Profile profile, bool allAround)
{
Player player = Player.m_localPlayer;
if (player == null) return;
profile.Shared?.m_triggerEffect.Create(center, player.transform.rotation);
if (ApplyDamageInSphere(center, radius, profile, allAround)) FormMelee.RaiseSkill(Skills.SkillType.Unarmed);
} }
} }
} }

View file

@ -15,9 +15,9 @@ Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorT
--- ---
## New in v1.6.9 ## New in v1.6.10
**Your own faction can be hit again, and race attacks train their skills.** Since Valheim 1.0 your blows passed straight through creatures of your own faction unless PvP was on, so no grudge ever started. That works again, in multiplayer too. Form attacks and powers now give XP to the skill they scale with, and Purple Rain grows with Blood Magic. Full details in the [changelog](#v169). **Drake forms hit the training dummy, the Ravager hits like a Brute, and an Alfr's hair stays gone.** Skadi's Moder and Fader melee could never hit the training dummy and landed before the animation did. The Ravager's attacks play the Brute's sounds and grow with Unarmed. Swapping items no longer flashes an Alfr's hair and beard. Full details in the [changelog](#v1610).
--- ---
@ -110,7 +110,7 @@ Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorT
- **Hive Pheromones:** No invertebrate attacks you — leeches, ticks, deathsquitos, seekers and bees all ignore you, from tier zero. - **Hive Pheromones:** No invertebrate attacks you — leeches, ticks, deathsquitos, seekers and bees all ignore you, from tier zero.
- **Toxin Immunity:** Poison cannot touch you. Blunt and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance. - **Toxin Immunity:** Poison cannot touch you. Blunt and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance.
- **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass. - **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass.
- **Ravager Strain:** After Yagluth, become a Seeker Brute, with its own bite, lunging ram and two-claw ground slam that digs the earth. The carapace is worth double. - **Ravager Strain:** After Yagluth, become a Seeker Brute, with its own bite, lunging ram and two-claw ground slam that digs the earth. Its damage grows with Unarmed. The carapace is worth double.
### 11. Alfar ### 11. Alfar
- **Eitr Shield:** Eitr is your armour: blows land on the eitr pool first, and lightning and spirit cost double. Only drowning and the edge of the world ignore it. Every food you eat also feeds the pool. - **Eitr Shield:** Eitr is your armour: blows land on the eitr pool first, and lightning and spirit cost double. Only drowning and the edge of the world ignore it. Every food you eat also feeds the pool.
@ -492,6 +492,11 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact
## Changelog ## Changelog
### v1.6.10
- **Fix - Skadi's Moder and Fader forms couldn't hit the training dummy:** their bites, claws and spin checked for cover with a line that counted the target's own body as a wall. Anything standing on the build layer, like the T.W.I.G. training dummy, could never be hit; wildlife worked. They now use the same reach check as the Fenrir forms, and each hit plays the real dragon's impact sound. The blow also lands on the clip's own hit frame instead of a fixed half second, which was early for every melee: the Moder's claws landed a second and a half before the claw came down. Thanks to lexsonn for the report. Not tested in game yet.
- **Change - Ravager Strain fights like the troll True Form:** the Brute's swing and impact sounds play on the bite, ram and slam, which were silent. Every attack that lands on a creature trains Unarmed, and the damage now grows with it the way a weapon grows with its skill: about 40% of a real Seeker Brute's at level 0, about 92% at level 100. The new key `Sverm - Ravager Strain` → `Ravager Attack Damage` (default 1) multiplies it. The bite and the ram now stay in front of you and no longer hit through walls, and each attack uses the Brute's own push and tool tier. Thanks to lexsonn for the report. Not tested in game yet.
- **Fix - Alfar hair and beard flashed in for a moment:** changing anything in your hands made the game put the character's hair and beard back, and the Alfar only took them off again half a second later. They are now blocked where the game attaches them, so they never show. Thanks to Joacwoo and Flandremonio for the report and the video. Not tested in game yet.
### v1.6.9 ### v1.6.9
- **Fix - you couldn't hit your own faction:** since Valheim 1.0, a player's hit passes through any creature the game calls friendly unless PvP is on, and the faction truce called every creature of your faction friendly. Your blows did nothing, no grudge started, and `Grudge spreads to kin` had nothing to spread. Hitting one of your own works again, and it and its kin fight back as intended. The truce still keeps them off you; it no longer shields them from you. Thanks to Joacwoo and CrimsonAiro for the reports. Not tested in game yet. - **Fix - you couldn't hit your own faction:** since Valheim 1.0, a player's hit passes through any creature the game calls friendly unless PvP is on, and the faction truce called every creature of your faction friendly. Your blows did nothing, no grudge started, and `Grudge spreads to kin` had nothing to spread. Hitting one of your own works again, and it and its kin fight back as intended. The truce still keeps them off you; it no longer shields them from you. Thanks to Joacwoo and CrimsonAiro for the reports. Not tested in game yet.
- **Fix - grudges in multiplayer:** a creature now keeps its grudge when another player's game takes over running it mid-fight, for example when the first player walks away or logs out. `Grudge spreads to kin` now also reaches kin that another player's game is running; before, they stayed calm until hit themselves. Every player needs this version: a creature run by an older client behaves the old way. Not tested in multiplayer yet. - **Fix - grudges in multiplayer:** a creature now keeps its grudge when another player's game takes over running it mid-fight, for example when the first player walks away or logs out. `Grudge spreads to kin` now also reaches kin that another player's game is running; before, they stayed calm until hit themselves. Every player needs this version: a creature run by an older client behaves the old way. Not tested in multiplayer yet.

View file

@ -1,7 +1,7 @@
{ {
"name": "RacesOfValheim", "name": "RacesOfValheim",
"description": "A Valheim mod that adds eleven custom playable races (Alfar, Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", "description": "A Valheim mod that adds eleven custom playable races (Alfar, Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
"version_number": "1.6.9", "version_number": "1.6.10",
"website_url": "", "website_url": "",
"dependencies": [ "dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333", "denikson-BepInExPack_Valheim-5.4.2333",