From 53754d0f4eb857f13f0a8953327305ea466cb829 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..823a10a837b1b04e9d9fe1ef00b15b6befb9eba6 100644 GIT binary patch delta 6405 zcmZu$3wTu3wO)JgbI#11nam>zd6Uc}BupkGBq2|T3L%O_kf$gQO(F>x2@E8F#Q>8K zPP(?V0gi&84Sz#38LRV&5oXKu-@T5i>f53cq4LJPO8TzeJ!?>)n__vAbOS^rvV z@3r>x>^bRrkahi-J$PSz+1;7%QSADNvi(k0OjHYn5moMQ#M6(v3pbHh$(%@2^nx4F zE4^foP@`;3KTrY`FQ{Sg8ECYpqQz)BTiy*o9kG zT4z1avK+f1Aqrh@eZaC)w>Cn=bvK<2VP33XkOk`pjd`&tkF+?!U zTFfh1mbI5JWm)}6;%3JD))Fm)1+2|lO;R?zJ4%Vnw8TWnr^orUb4HH!zV>S?Xrx)s z>!sFmqr%EGOg7TmrKei8Mk%Dv^$b>IJ!E9F66>IG9q>CNlNDR(wk9^rT4Q^S zI?A967XXwlB{?NE^$K0`|D#L2L}yKK=CTj0#m?e{+l{pduH_ac=dI0$aL%Z)o^d8d z#u$m`j3EfpaXb1Ui0B1{!;Q5Fd#UeL=N)ppq(!-n;3*-Szjy^vNu8`D@w`v8l42fA zfu=AhZAq8g5~VI#>KqrMTHia1tzy^62*%T>NHfBBA|KWAa3M52+zNinIW3eFn!`I= zKspxz+9wKH8f=4fxq9veH6;`a8mHzBW=-d9vLt4q+1UtKJL2+&UQIQ~YB4OiUD6bE zqeG%ulpu?9JhY96!!U=J0!HxE5Dza?QWB(g>uZ-kg1Kje5S7y{i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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