+
+
+
+
\ No newline at end of file
diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
index cd753c7..4c6332d 100644
--- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
+++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
@@ -191,6 +191,7 @@
+
diff --git a/Source/ArachnaeSwarm/HediffGiver_RandomWithSeverity.cs b/Source/ArachnaeSwarm/HediffGiver_RandomWithSeverity.cs
new file mode 100644
index 0000000..5c96c00
--- /dev/null
+++ b/Source/ArachnaeSwarm/HediffGiver_RandomWithSeverity.cs
@@ -0,0 +1,54 @@
+using Verse;
+
+namespace ArachnaeSwarm
+{
+ ///
+ /// A custom HediffGiver that is similar to HediffGiver_Random,
+ /// but allows specifying a random severity range for the given hediff.
+ ///
+ public class HediffGiver_RandomWithSeverity : HediffGiver
+ {
+ // XML configurable fields
+ public float mtbDays;
+ public FloatRange severityRange = new FloatRange(0.01f, 1f);
+
+ public override void OnIntervalPassed(Pawn pawn, Hediff cause)
+ {
+ // Calculate the chance based on Mean Time Between (MTB) days and pawn-specific factors
+ float mtb = this.mtbDays;
+ float chanceFactor = ChanceFactor(pawn);
+ if (chanceFactor != 0f && Rand.MTBEventOccurs(mtb / chanceFactor, 60000f, 60f))
+ {
+ // Try to apply the hediff with our custom logic
+ if (TryApplyWithCustomSeverity(pawn))
+ {
+ // If successful, send a letter to the player
+ SendLetter(pawn, cause);
+ }
+ }
+ }
+
+ ///
+ /// Applies the hediff and then sets its severity to a random value within the specified range.
+ ///
+ /// The pawn to apply the hediff to.
+ /// True if the hediff was successfully applied, false otherwise.
+ private bool TryApplyWithCustomSeverity(Pawn pawn)
+ {
+ // First, apply the hediff using the base class logic.
+ // This will add the hediff with its default initial severity.
+ if (base.TryApply(pawn))
+ {
+ // If the hediff was successfully added, find it.
+ Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(this.hediff);
+ if (hediff != null)
+ {
+ // Set its severity to a random value from our configured range.
+ hediff.Severity = this.severityRange.RandomInRange;
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file