sumghai / MedPod

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

Possible incompatibility with armor boosting implants at large (happens with Cybernetic Organism and Neural Network, [RH] Faction: UAC and even Royalty DLC) #17

Closed randompartyhero closed 3 years ago

randompartyhero commented 3 years ago

I managed to narrow it down to this mod

Any pawn with implants from said mod gets stuck in a diagnosing loop - no reatomizing happens, just diagnosing/100% clear. Removing the implants finally allowed the colonist to be treated by the pod.

Mod link: https://steamcommunity.com/sharedfiles/filedetails/?id=2130954176

Edit: Curiously, some implants from the mod work with the MedPod. Colonist with implants that only increase the stats like sight, consciousness, tame chance and so on work. But the one that apart from the base stats also gives a buff to armor (i.e. sharp, blunt, heat) causes the loop. I also found the issue present with the armor boosting implants from the Cybernetic Organism and Neural Network (dermaplating and exoskeleton specifically).

Okay, issue is definitely connected to parts that boost armor resistance in general. I just installed the armorskin gland from the Royalty DLC and the loop happens. Removing it from the pawn makes the pod do its magic again. The pawn had multiple implants from different mods but the Armorskin was the only one boosting armor.

sumghai commented 3 years ago

Thanks for getting back to me - this is very peculiar. I'll look into this when I have the time.

sumghai commented 3 years ago

@randompartyhero @DJNokem - I think I've figured out the root cause of the problem (as well as how to fix it).

Currently, the MedPod has a bit of code that checks to see if an implanted/prosthetic body part has any child parts, and then ignores them - this prevents the MedPod from, for example, healing the hands and fingers of an arm that has already been entirely replaced with an bionic arm.

Now, this is all fine and dandy, but if the implant belongs to the Torso, then the MedPod ignores everything below that, which practically means the MedPod now has an empty treatment plan, but other bits of code keep telling the patient to stay in the MedPod to receive (non-existent) treatment.

And the kicker is that the Royalty Death Acidifier, Armor Glands and the UAC implants in question are all Torso implants.

The solution is to basically skip checking Torso implants, which allows other body parts to be treated again.

I have a dev build with a working fix, but I'm waiting for feedback on my other FPS/lag fix before I can upload all the fixes into this repo.

MerGatto commented 3 years ago

I also ran into this problem today and dug around in the code a little. Is there any particular reason why you also skip children from implants and not just added parts? If I understand it correctly hands wouldn't be treated if the arm has a muscle stimulator for example (from EPOE mod).

Only excluding children from Added parts would probably fix the torso problem as well.

sumghai commented 3 years ago

@MerGatto - As I already mentioned:

this prevents the MedPod from, for example, healing the hands and fingers of an arm that has already been entirely replaced with an bionic arm.

And no, only excluding children from Added parts would not haved fixed the problem, as that was what caused it the the first place.

sumghai commented 3 years ago

@randompartyhero @gogochlwns @DJNokem @LastXsile @MerGatto

Please test the following development build, which contains a fix that ignores the child part checks for Torsos with implants, and should prevent pawns lying in MedPods getting stuck in the diagnosis loop:

https://github.com/sumghai/MedPod/archive/21de9991a4a422fe86c22fcfc3ccc99e29981d30.zip

If you guys can get back to me ASAP, I'll formally publish a new release this weekend.

MerGatto commented 3 years ago

Problem seems to be fixed for torsos. However I was still able to trigger an infinite diagnosis loop by damaging the fingers of an arm with implants (not replacements), like for example the Muscle stimulator from EPOE mod

MerGatto commented 3 years ago

@MerGatto - As I already mentioned:

this prevents the MedPod from, for example, healing the hands and fingers of an arm that has already been entirely replaced with an bionic arm.

And no, only excluding children from Added parts would not haved fixed the problem, as that was what caused it the the first place.

Hediff_AddedParts cause child parts to be removed. Hediff_Implants do not however. This is vanilla behavior, the PostAdd method from the Hediff_AddedParts class adds the MissingPart Hediffs to the children.

Can you give me an example where it would cause problems to try and treat children of Body parts with Hediff_Implants?

I compiled a version of MedPod locally where I don't add children of Hediff_Implants to the ignore list. I didn't run into any issues..

DJNokem commented 3 years ago

The update has fixed the torso issue for me. I've not run into any other problems but I don't a large number of mods. Thanks.

LastXsile commented 3 years ago

This seems to work just fine heals the pawn and then they get up fully healed. I don't get any deadlocks anymore. I do get an error message but it doesn't prevent it from working.

[V1024-EBF] Elite Bionics Framework has detected some mods using the unmodified GetMaxHealth() method, which violates the EBF protocol. The author(s) of the involved mod(s) should adopt the EBF to clarify their intentions. For now, the unmodified max HP is returned. The detected mod comes from: MedPod Verse.Log:Error(String, Boolean) EBF.EliteBionicsFrameworkMain:LogError(String, Boolean) EBF.Patches.Prefix_BodyPart_GetMaxHealth:PreFix(BodyPartDef, Single, Pawn) Verse.BodyPartDef:DMD<DMD?1658217088::GetMaxHealth_Patch2>(BodyPartDef, Pawn) MedPod.Building_BedMedPod:DiagnosePatient(Pawn) MedPod.Building_BedMedPod:Tick() Verse.TickList:DMD<DMD?822119936::Tick_Patch2>(TickList) Verse.TickManager:DMD<DMD?1578607616::DoSingleTick_Patch1>(TickManager) Verse.TickManager:DMD<DMD?968780288::TickManagerUpdate_Patch4>(TickManager) Verse.Game:DMD<DMD?-565676800::UpdatePlay_Patch2>(Game) Verse.Root_Play:Update()

On Wed, Jul 22, 2020 at 11:49 AM DJNokem notifications@github.com wrote:

The update has fixed the torso issue for me. I've not run into any other problems but I don't a large number of mods. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumghai/MedPod/issues/17#issuecomment-662565216, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2BG457U5TSEOMGMN253KDR44KBHANCNFSM4OY2PDBA .

sumghai commented 3 years ago

@LastXsile - Please open a separate issue for that.

I've just approved some additional tweaks and optimizations courtesy of @MerGatto, so I think I can safely say we're done here.