sumghai / MedPod

Advanced regenerative medical beds for RimWorld
Other
14 stars 15 forks source link

Pawns do not automatically use MedPods for Food Poisoning #41

Closed sumghai closed 3 years ago

sumghai commented 3 years ago

Describe the bug:

Reddit user u/katzenfaust86 reported (via a snarky fan comic) that pawns with only food poisoning will not automatically use MedPods.

Expected behavior:

Pawns should automatically use MedPods when they experience food poisoning.

Steps to reproduce:

  1. Build a MedPod (Standard or Lux)
  2. Apply the Food Poisoning hediff to an otherwise-healthy human colonist pawn with no implants or other hediffs
  3. Observe the pawn not using the MedPod

Additional information:

Further correspondence with u/katzenfaust86 suggests that this is actually vanilla behaviour - pawns with food poisoning would generally not automatically seek any medical beds to rest in.

Additionally, if the pawn has other tendable injuries/diseases/hediffs in addition to food poisoning, all hediffs will be treated successfully when the pawn automatically uses the MedPod.

System and Game Configuration

Note: as u/katzenfaust86 themselves did not file this bug report, it is assumed that the issue is reproduceable by the mod author himself.

Operating System: Microsoft Windows 10 (64-bit) Physical RAM: 16.0 GB RimWorld base game version: 1.2.2753 RimWorld DLCs loaded: none MedPod mod version: 1.1.5 MedPod mod downloaded from: GitHub Your mod list: Harmony 2.0.4, Core, MedPod 1.1.5

Declaration

I hereby verify that:

sumghai commented 3 years ago

After testing this myself on a stripped-down savegame, I've found that while pawns with only Food Poisoning won't automatically use the MedPod, they can at least be manually told to do so via the right-click context Float Menu.

As for making this process automatic, the problem is that JobGiver_PatientGoToBed.TryIssueJobPackage can't be easily modified to support it, if it is even possible:

If the pawn cannot lay down for timetable reasons, doesn't need surgery and doesn't need tending Don't create a job (and break execution)

If the the pawn cannot lay down because they are disturbed Don't create a job (and break execution)

Otherwise, look for a suitable bed

If a bed can't be found Don't create a job (and break execution)

Otherwise, create a LayDown job with the bed as the target



* On the other hand, the MedPod mod's equivalent method for checking whether or not a pawn needs medical bed rest requires **_foreknowledge_** of what hediffs a **_particular_** MedPod is/isn't allowed to treat (to support different MedPod models), before deciding whether or not to assign them to use said MedPod.

* Prefix patching `TryIssueJobPackage` with MedPod logic would mean the game needs information that isn't available until **_later_** in the execution flow.

* Postfix patching `TryIssueJobPackage` with MedPod logic would mean the vanilla execution flow (with its less-inclusive rules for what constitutes a "treatable condition") would take precedence over the MedPod's (wider) rules.

**tl;dr** Harmony Patching isn't a viable way to solve this problem.
sumghai commented 3 years ago

A workaround is to use xpath PatchOperations to mark the FoodPoisoning hediff as <tendable>true</tendable>, which tricks the unmodified vanilla JobGiver_PatientGoToBed.TryIssueJobPackage into telling pawns with the hediff to always seek medical bed rest, whether or not the target bed is a MedPod.

In-universe, it could be said that Food Poisoning is debilitating enough to require rest and medicine, rather than the current vanilla behavior of just "waiting it out".

sumghai commented 3 years ago

I've put together the PatchOp, which seems to work.

A side effect is that without MedPods, patients who use vanilla hospital beds will require medicine to treat food poisoning, which sort of reflects how severe cases of the condition are dealt with in real life anyway.

sumghai commented 3 years ago

After testing the dev build, u/katzenfaust86 noted that while it works in principle:

In which case, there's no need to fix this.