[A18] Improved Surgery

Started by twoski, August 24, 2016, 11:31:27 PM

Previous topic - Next topic

twoski

Note: This mod uses HugsLib. If you do not have that mod installed you will get errors. Grab it: https://ludeon.com/forums/index.php?topic=28066.0

This mod tweaks surgery to be a bit more forgiving.
   
- Failures no longer instantly destroy prosthetics/bionics/implants being installed. The item that was being installed will be returned, but with less health. This means that if you are installing an item that is worn out or damaged, failing too many times will destroy it.

- Extreme failures which cause random body part damage are much less likely to occur. In these cases, it will more likely be a major failure that causes an infection instead.


Other surgery mods may possibly conflict with this one.

Get it now: http://steamcommunity.com/sharedfiles/filedetails/?id=751352140

Non-steam link (and source code): https://bitbucket.org/twoski/rimworldmods/downloads

Licensing:

You may include this mod in a modpack, however do keep in mind that i may update it. It is better if you add this to a steam-based modpack since steam automatically updates when i submit my changes.

You may derive from this mod but please add a visible link to this mod if you do.

123nick

Quote from: twoski on August 24, 2016, 11:31:27 PM
This mod makes surgery slightly less random.

- Failures no longer automatically destroy prosthetics/bionics/implants being installed. The item that was being installed will be returned, but with less health. This means that if you are installing an item that is worn out or damaged, failing too many times will destroy it.

- Failures no longer damage or remove random body parts, and will prioritize adding surgical cuts on body parts that are near the part being operated on.

- Minor failures now have a small chance to cause an infection on the body part being operated on. Major failures have a higher chance.



I had to do some fancy footwork to make this mod function - chances are it will conflict with any other mod that alters how surgery works.

Get it now: http://steamcommunity.com/sharedfiles/filedetails/?id=751352140

Non-steam link (and source code): https://bitbucket.org/twoski/rimworldmods/downloads

Licensing:

You may include this mod in a modpack, however do keep in mind that i may update it. It is better if you add this to a steam-based modpack since steam automatically updates when i submit my changes.

You may derive from this mod but please add a visible link to this mod if you do.

man, this mod is amazing! i know a ton of people who dont like it when there is a surgey on a leg and they accidentally cut a patients heart out :P

System.Linq

#2
A word of advice, twoski: You don't need to copy every part of MedUtil over to your mod. You can simply do the following:


                var MedicalRecipesUtility = Type.GetType("RimWorld.MedicalRecipesUtility, Assembly-CSharp, Version=0.14.6054.28275, Culture=neutral, PublicKeyToken=null");
                var restore = MedicalRecipesUtility.GetMethod("RestorePartAndSpawnAllPreviousParts", BindingFlags.Static | BindingFlags.Public);
                if(restore != null)
                    restore.Invoke(MedicalRecipesUtility, new object[] { pawn, part, billDoer.Position });
                else
                    Log.ErrorOnce("Unable to reflect MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts!", 305432421);


This will make it easier to tell what's part of the mod and what's not so I can make Psychology compatible with it. Also, you can detour your modified MedUtil methods (if there are any) straight into MedUtil that way to make it even easier.

Also, fantastic mod, one of those things that makes you wonder why it's not vanilla.

P.S. Please remove instadeath on surgery failure.

e: On second thought, it would be easier for you to build compatibility into your mod than mine. Please add this code to your build and tell users to load your mod after Psychology:


CheckSurgeryFail:
            if (!patient.Dead)
            {
                TryGainBotchedSurgeryThought(patient, surgeon);
            }
            else
            {
                ThoughtDef kp = ThoughtDef.Named("KilledPatientBleedingHeart");
                if(kp != null)
                    surgeon.needs.mood.thoughts.memories.TryGainMemoryThought(kp, patient);
            }

ApplyOnPawn:
                MedUtil.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position);
                ThoughtDef rp = ThoughtDef.Named("ReplacedPartBleedingHeart");
                if (rp != null)
                    billDoer.needs.mood.thoughts.memories.TryGainMemoryThought(rp, pawn);

MoatBordered

Looks promising.

I just have to change the <workerClass> of mod surgeries so they use your surgery changes, right?

twoski

Yes,  all i did was make new worker classes that inherit from old ones.

twoski

#5
I will add reflection in.  I ended up copying stuff to my own util class because a lot of things are internal or cannot be called from my mod and i got lazy.

System.Linq

Reflection allows you to access internal/private methods and classes so you don't have to reduce compatibility by overwriting those fields and methods.

SpaceDorf

The obvious question has not been asked yet :)

Does it work with DESurgery ?
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

twoski

my mod changes RecipeDefs for most surgery types. So if other mods do this too, then there's gonna be a problem

it likely won't cause crashes but if another mod overrides my mod's RecipeDefs then my mod effectively does nothing

twoski

Could someone here give me a quick tip on how to add text note at the top left of the screen? Like when you fail a surgery and it says "[Pawn] failed their surgery in a minor way" up there.

Deimos Rast

this looks like it has a lot of what I want, but I think I'll wait for compat with DE surgeries
might be hard to do from reading over this it sounds like
#StopPluginAbuse

twoski

I'd have to look at DE surgeries and see what it does exactly but chances are they will conflict.

Aristocat

#12
I haven't used this, but I would like to integrate this into my mod pack. Since I use DEsurgeries and EPOE I can probably make them compatible.

twoski

Quote from: Aristocat on August 30, 2016, 06:15:23 AM
I haven't used this, but I would like to integrate this into my mod pack. Since I use DEsurgeries and EPOE I can probably make them compatible.

sure

l2evy

#14
Quote from: Aristocat on August 30, 2016, 06:15:23 AM
I haven't used this, but I would like to integrate this into my mod pack. Since I use DEsurgeries and EPOE I can probably make them compatible.

EPOE and DESurgery Support for this mod I would def use it. Surgery would be even more fun then!
Mod Maintainer/Coder of: