diff --git a/JotunnModStub/Sverm/SvermGjallPatches.cs b/JotunnModStub/Sverm/SvermGjallPatches.cs index 0251861..6168866 100644 --- a/JotunnModStub/Sverm/SvermGjallPatches.cs +++ b/JotunnModStub/Sverm/SvermGjallPatches.cs @@ -29,6 +29,28 @@ namespace RacesOfValheim return thrall != null && thrall.m_commandingRace == SvermConfig.RaceId; } + // ── The nest is immune to its own brood ────────────────────────────── + + /// A Sverm troop, or a tick one of them hatched: anything the colony itself put on the field. + private static bool IsColonyMember(Character attacker) + { + if (attacker == null) return false; + return IsSvermTroop(attacker) || attacker.GetComponent() != null; + } + + // RPC_Damage and not Damage: that is where the hit lands on the piece's owner, whoever threw it. + // A raid is where it showed - bombs, ticks' bursts and troop swings all go through here. + [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] + public static class Sverm_Nest_BroodImmunity_Patch + { + public static bool Prefix(WearNTear __instance, HitData hit) + { + if (hit == null || __instance.GetComponent() == null) return true; + + return !IsColonyMember(hit.GetAttacker()); + } + } + // ── Friendly fire ──────────────────────────────────────────────────── [HarmonyPatch(typeof(Projectile), nameof(Projectile.Setup))]