From 27abf821fcaae78dc3080e724d03ed9a737f9cc5 Mon Sep 17 00:00:00 2001 From: Dominic Barber Date: Tue, 28 May 2024 11:35:59 +0100 Subject: [PATCH] add LungRot fix --- Assemblies/Pharmacist.dll | Bin 18432 -> 18944 bytes Source/PharmacistUtility.cs | 91 +++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/Assemblies/Pharmacist.dll b/Assemblies/Pharmacist.dll index decb1fe06077e3aa3031120c88ee130d0fc95686..d9f8f2847d112467f30231264cb6b635fa5a5dc8 100644 GIT binary patch delta 6405 zcmZu$34B!5x&O{N_uiSgGnpj`*&#CtNhT8#CJ9LhM1&AUB1l+7HcbKv7zqp{fTaN@ zVNqE`<87flmWNUlH?T$&TD4MqKJzLqTHaGzT&VTAp@rJ&v#;X&pEJW|-_7s-@Av<{ z@0{;D>pgSReLw5|5xf7M`n@MV{tLyg_bJEkWMQIOD2$l$U=yBx+}*f|yh`RonxdE7 zh+gV_qr^R{iD;6vbQ3)xdIL$Wy+khX^^HW+tN7bJ8gdIkpcaVph+XDyxAfcn2X9)8MN!QHddf z8P+0R#j>sadAWSu9{})@o96;N4k9WM(8MLq0dgr(G~|t#`CvT0tYj zdR8y9mKl}SAj4!st=)RMRcn+%`b5uSCDsE*4lA_|8`lH>VGLqnE7R7@23xCbudqC; z&VCEaw|3bVvI5KQ7{Y>9g`+DWgn&MK7h-9VD(eMD8Y}GkFGnVuUJgSyI!Ie1Atfz6 zBcpQ|bde%}(xs)QrKf*Sm-_$c(y!22y{SfHiV~zZ2s_aqS889N%BRXSS4W| zOoOI4C~YZM+mfX&Rq7mY*wDl?489mq$uJW>n|kFl?u2#>!q^6{>pfPIRVAgcqCQD)#nq5tRHAAj$=qRc|R*PWC>z1aV z8yynMq7+$N;Gu0i5`j6g1TciBhj?VEl2RabSYNpOQOrFfgs7ZmAgY7N$Ajt6#ad%T z$YW9mlU==^bY-vu+HW)*&=i)XH}kvP`SNJ-B)mswu7#T>(5Js{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!S%tna3!?ZIL*ao;hCpdtO>q$Yr&Fm&GO|{%PVPe-KyrzYiG1iZ&(}K($>6jW$l*D zZI|BwqsY9&fv!U)F`&PD&`b|>AFyXl zDe*rXSm43G%>r}$-4B~)p!=}BZOUBj8GrXP_DfSPV=oNpmw&~a*qX-7^;=f2Znv#z z6``u~s`4?_l|)`f&ib{@ts9zGw6tv=YMYkMg5SNyzbCe!UQXN1c(yLXGtK_T=|SU5 zh+j^#e>c6Le&)cbtZj#U3%er|ZW}fE(`9lV>n1L}x_#q{RV$ZXxq0oX)};$#E8CV{ z)w1E*SnK+gOB4C?m9qAltFF3YVZ+kD=eB(_qGOXm_Z&|KMJe%LRy?EC$6v{LJX&2l zBl)jfIp0gAoZlY~@`cOoTW0*L?WvpOZzB3yEjQ^QW&66ia<5Q}bO0z9>wvwtu9+>d zzo{$4ROen166NHuCtQ*1nu+sk3$4aqyS?U$Rjw**2>Fbm>Y@L*BAwwNH0@7khEs+a ksM6jrYZR-p2WPFdU!AeUs!#mSdehV)|Ljj$f2HGp0nH#jfdBvi diff --git a/Source/PharmacistUtility.cs b/Source/PharmacistUtility.cs index 62215d4..e72fea8 100644 --- a/Source/PharmacistUtility.cs +++ b/Source/PharmacistUtility.cs @@ -6,42 +6,55 @@ using RimWorld; using Verse; -namespace Pharmacist { - public enum InjurySeverity { +namespace Pharmacist +{ + + public enum InjurySeverity + { Minor, Major, LifeThreathening, Operation } - public enum Population { + public enum Population + { Colonist, Prisoner, Guest, Animal } - public static class PharmacistUtility { - public static InjurySeverity GetTendSeverity(this Pawn patient) { + public static class PharmacistUtility + { + public static InjurySeverity GetTendSeverity(this Pawn patient) + { if (!HealthAIUtility.ShouldBeTendedNowByPlayer(patient)) // .ShouldBeTendedNow( patient ) ) -{ + { return InjurySeverity.Minor; } System.Collections.Generic.List hediffs = patient.health.hediffSet.hediffs; - int ticksToDeathDueToBloodLoss = HealthUtility.TicksUntilDeathDueToBloodLoss( patient ); + int ticksToDeathDueToBloodLoss = HealthUtility.TicksUntilDeathDueToBloodLoss(patient); // going to die in <6 hours, or any tendable is life threathening if (ticksToDeathDueToBloodLoss <= GenDate.TicksPerHour * 6 || hediffs.Any(h => h.CurStage?.lifeThreatening ?? false) || - hediffs.Any(NearLethalDisease)) { + hediffs.Any(NearLethalDisease) || + hediffs.Any(h => IsBloodRot(h) && h.Severity > PharmacistSettings.medicalCare.DiseaseThreshold) + ) + { return InjurySeverity.LifeThreathening; } // going to die in <12 hours, or any immunity < severity and can be fatal, or death by a thousand cuts imminent if (ticksToDeathDueToBloodLoss <= GenDate.TicksPerHour * 12 || hediffs.Any(PotentiallyLethalDisease) || - DeathByAThousandCuts(patient)) { + DeathByAThousandCuts(patient) || + hediffs.Any(IsBloodRot) || + hediffs.Any(IsLungRot) + ) + { return InjurySeverity.Major; } @@ -49,12 +62,15 @@ public static InjurySeverity GetTendSeverity(this Pawn patient) { return InjurySeverity.Minor; } - private static bool PotentiallyLethalDisease(Hediff h) { - if (!h.TendableNow()) { + private static bool PotentiallyLethalDisease(Hediff h) + { + if (!h.TendableNow()) + { return false; } - if (h.def.lethalSeverity <= 0f) { + if (h.def.lethalSeverity <= 0f) + { return false; } @@ -62,7 +78,8 @@ private static bool PotentiallyLethalDisease(Hediff h) { return compImmunizable != null; } - private static bool NearLethalDisease(Hediff h) { + private static bool NearLethalDisease(Hediff h) + { HediffComp_Immunizable compImmunizable = h.TryGetComp(); return PotentiallyLethalDisease(h) && !compImmunizable.FullyImmune && @@ -70,34 +87,51 @@ private static bool NearLethalDisease(Hediff h) { compImmunizable.Immunity < PharmacistSettings.medicalCare.DiseaseMargin + h.Severity; } - private static bool DeathByAThousandCuts(Pawn patient) { + private static bool IsBloodRot(Hediff h) + { + return h.def.defName == "BloodRot"; + } + + private static bool IsLungRot(Hediff h) + { + return h.def.defName == "LungRot"; + } + + private static bool DeathByAThousandCuts(Pawn patient) + { // number of bleeding wounds > threshold return patient.health.hediffSet.hediffs.Count(hediff => hediff.Bleeding) > PharmacistSettings.medicalCare.MinorWoundsThreshold; } - public static Population GetPopulation(this Pawn patient) { - if (patient.RaceProps.Animal) { + public static Population GetPopulation(this Pawn patient) + { + if (patient.RaceProps.Animal) + { return Population.Animal; } - if (patient.IsColonist) { + if (patient.IsColonist) + { return Population.Colonist; } - if (patient.IsPrisonerOfColony) { + if (patient.IsPrisonerOfColony) + { return Population.Prisoner; } return Population.Guest; } - public static MedicalCareCategory TendAdvice(Pawn patient) { + public static MedicalCareCategory TendAdvice(Pawn patient) + { InjurySeverity severity = patient.GetTendSeverity(); return TendAdvice(patient, severity); } - public static MedicalCareCategory TendAdvice(Pawn patient, InjurySeverity severity) { + public static MedicalCareCategory TendAdvice(Pawn patient, InjurySeverity severity) + { Population population = patient.GetPopulation(); MedicalCareCategory pharmacist = PharmacistSettings.medicalCare[population][severity]; @@ -106,19 +140,22 @@ public static MedicalCareCategory TendAdvice(Pawn patient, InjurySeverity severi #if DEBUG Log.Message( "Pharmacist :: Advice" + - $"\n\tpatient: {patient?.LabelShort}" + - $"\n\tpopulation: {population}" + - $"\n\tseverity: {severity}" + - $"\n\tplayerSettings: {playerSetting}" + - $"\n\tpharmacist: {pharmacist}"); + $"\tpatient: {patient?.LabelShort}" + + $"\tpopulation: {population}" + + $"\tbloodRot: {patient.health.hediffSet.hediffs.Exists(IsBloodRot)}" + + $"\tlungRot: {patient.health.hediffSet.hediffs.Exists(IsLungRot)}" + + $"\tseverity: {severity}" + + $"\tplayerSettings: {playerSetting}" + + $"\tpharmacist: {pharmacist}"); #endif // return lowest - if (pharmacist < playerSetting) { + if (pharmacist < playerSetting) + { return pharmacist; } return playerSetting; } } -} +} \ No newline at end of file