Ludeon Forums

RimWorld => Releases => Mods => Outdated => Topic started by: twoski on August 24, 2016, 11:31:27 PM

Title: [A18] Improved Surgery
Post by: twoski on August 24, 2016, 11:31:27 PM
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.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: 123nick on August 25, 2016, 12:08:16 AM
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
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: System.Linq on August 25, 2016, 12:17:14 AM
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);
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: MoatBordered on August 25, 2016, 12:53:31 AM
Looks promising.

I just have to change the <workerClass> of mod surgeries so they use your surgery changes, right?
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on August 25, 2016, 07:41:08 AM
Yes,  all i did was make new worker classes that inherit from old ones.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on August 25, 2016, 07:43:11 AM
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.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: System.Linq on August 25, 2016, 03:05:31 PM
Reflection allows you to access internal/private methods and classes so you don't have to reduce compatibility by overwriting those fields and methods.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: SpaceDorf on August 25, 2016, 06:45:15 PM
The obvious question has not been asked yet :)

Does it work with DESurgery ?
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on August 25, 2016, 07:14:58 PM
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
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on August 25, 2016, 07:31:18 PM
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.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: Deimos Rast on August 26, 2016, 04:17:10 PM
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
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on August 26, 2016, 07:28:00 PM
I'd have to look at DE surgeries and see what it does exactly but chances are they will conflict.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: 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.
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on August 30, 2016, 09:28:21 AM
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
Title: Re: [A14] Improved Surgery - Now with 25% More Gangrene
Post by: l2evy on August 30, 2016, 11:00:00 AM
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!
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 01, 2016, 12:44:05 AM
I tried to create patches for this mod to go along with EPOE standalone and EPOE + Realistic Medical System for EPOE. Let me know if it works for you! I did some basic testing and organs were getting initial rejection / prosthesis had the "just installed" modifier, failures resulted in Improved Surgery's failure state.

Steam Workshop links here. (https://ludeon.com/forums/index.php?topic=24975.msg255480#msg255480)

Place after EPOE/RMS/ImprovedSurgery in your load order.
(http://i.imgur.com/wVx8rPD.jpg)
EPOE + RMS + IS + Patch
(http://i.imgur.com/5PXc3Uq.jpg)
EPOE + IS + Patch

[attachment deleted by admin - too old]
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on September 01, 2016, 08:11:25 AM
Cool,  if you could put it on steam i can link it on the steam page for this as well since i get people asking about epoe periodically.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 01, 2016, 04:02:57 PM
I'd like to know if it works for people, though (in a long running game, I tested it very briefly). I have 0 coding knowledge/experience, I just looked at your DLL and the XML files and decided to give it a go.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on September 01, 2016, 10:16:44 PM
i added links to those compatibility patches, cheers
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 02, 2016, 10:03:33 PM
Made some untested patches for Glitter Tech. Uploading here for people who don't want to use the Workshop / don't have a Steam copy.

First one is for Glitter Tech, second one for Glitter Tech (No Surgery).

[attachment deleted by admin - too old]
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Serenity on September 06, 2016, 08:12:21 AM
I'd also love compatibility with DE-Surgeries. Though to be honest, at the moment having what's there behave properly is probably more important than more options.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: okiri on September 07, 2016, 02:19:38 PM
I don't know if its a compatibility issue but when I use this mod along with de surgeries and epoe(w/ patch) anesthesia on patients stay even though they don't have the debuff on their health tab. This happens with any surgery.     
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on September 07, 2016, 03:56:54 PM
i haven't seen this issue with this mod installed alone, are those mods known to conflict with eachother?
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 07, 2016, 05:21:14 PM
I'd wager it has something to do with a HeDiff that gets applied but then conflicts between the mods.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: 123nick on September 07, 2016, 05:37:05 PM
if i were using EPOE, RMS, AND glittertech (no surgery), would i use the 2 patches? the epoe + RMS patch, AND the glittertech (no surgery) patch?
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: okiri on September 07, 2016, 05:40:15 PM
Quote from: Dingo on September 07, 2016, 05:21:14 PM
I'd wager it has something to do with a HeDiff that gets applied but then conflicts between the mods.
After the ticks for anesthetic finish they stay unconscious with a 10% I entered dev mode and healed the brain which caused them to wake up, but this is not what I want :(
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on September 07, 2016, 07:57:43 PM
i don't think my mod would cause that problem, it doesn't apply any hediffs of that nature.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 08, 2016, 12:47:02 AM
@123nick, I actually answered that question on the Workshop too! So here's my answer there:

QuoteThe "Glitter Tech (No Surgery)" patch enabled Improved Surgery for exactly 1 artificial part which is the exoskeleton, so yeah I don't see why it wouldn't work. There is an internal logic to it if you ever take a look inside the mod folders (I don't do anything to the code, only the specific surgeries).

If you want to use that mod combo I recommend you have the following load order:
*Glitter Tech (No Surgery)
*EPOE
*RMS
*Improved Surgery
*Glitter Tech NS + Improved Surgery Patch
*EPOE + RMS + Improved Surgery Patch

Having said that, if Glitter Tech and EPOE conflict in other ways this won't fix it for you.

@okiri I'm pretty sure Improved Surgery isn't responsible for your troubles, it's likely a conflict between DESurgeries and EPOE.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: okiri on September 08, 2016, 12:54:06 AM
I think it was my bionic Lumi which is 66 years old and anesthisia hits her like a truck, 12 days to wake. Although i disabled desurgery...thanks for the help
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: 123nick on September 08, 2016, 04:15:37 PM
Quote from: Dingo on September 08, 2016, 12:47:02 AM
@123nick, I actually answered that question on the Workshop too! So here's my answer there:

QuoteThe "Glitter Tech (No Surgery)" patch enabled Improved Surgery for exactly 1 artificial part which is the exoskeleton, so yeah I don't see why it wouldn't work. There is an internal logic to it if you ever take a look inside the mod folders (I don't do anything to the code, only the specific surgeries).

If you want to use that mod combo I recommend you have the following load order:
*Glitter Tech (No Surgery)
*EPOE
*RMS
*Improved Surgery
*Glitter Tech NS + Improved Surgery Patch
*EPOE + RMS + Improved Surgery Patch

Having said that, if Glitter Tech and EPOE conflict in other ways this won't fix it for you.

@okiri I'm pretty sure Improved Surgery isn't responsible for your troubles, it's likely a conflict between DESurgeries and EPOE.

thanks! IIRC, glittertech and EPOE never conflicted before, so i dont see why it would now.

edit: another thing i just realized, A Dog Said, does it conflict/work with that mod too ? i assume it may need yet another patch.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 08, 2016, 04:20:50 PM
A Dog Said doesn't conflict with any mod, I don't think. It does require a patch XML to use Improved Surgery, however.

*Edit: Alright I made some. I'm gonna make a list here of all the patches I've made so far with 3rd party download links for people who don't use Steam.

Improved Surgery Patches (A15c):

Improved Surgery for Expanded Prosthetics & Organ Engineering (EPOE) (https://steamcommunity.com/sharedfiles/filedetails/?id=756408576)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqdV91SHQzWXVocDg)

Improved Surgery for Expanded Prosthetics & Organ Engineering (EPOE) with Realistic Medical System (https://steamcommunity.com/sharedfiles/filedetails/?id=756408699)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqOTAyNUplSkR2eU0)

Improved Surgery for Glitter Tech (https://steamcommunity.com/sharedfiles/filedetails/?id=756983842)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqVElMd2EtOEtwa1E)

Improved Surgery for Glitter Tech (No Surgery) (https://steamcommunity.com/sharedfiles/filedetails/?id=756983976)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqZWVnVVd6ZW53TkE)

Improved Surgery for A Dog Said... (https://steamcommunity.com/sharedfiles/filedetails/?id=760262076)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqSUFJaEE5NUlIa1E)

Improved Surgery for A Dog Said... (Lite) (https://steamcommunity.com/sharedfiles/filedetails/?id=760264154)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqLVJKM0lwQk9jNFE)

Improved Surgery for A Dog Said... (No Crafting) (https://steamcommunity.com/sharedfiles/filedetails/?id=760264341)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqTzBaa0Q3TE4xRFE)

Improved Surgery for DE Surgeries (https://steamcommunity.com/sharedfiles/filedetails/?id=764734484)
*(Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqVXFyQ191YkpxbHM)

You can also find all of these on Github here (https://github.com/FudgePoly/ImprovedSurgeryPatches/releases) if you prefer.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: TrashMan on September 10, 2016, 04:08:37 PM
How to get the EPOE patch without Steam?
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Nictis on September 12, 2016, 10:02:22 PM
Quote from: twoski on August 24, 2016, 11:31:27 PM

- 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 like to think of it as the doctor either sneezing on your open wound or spitting in it. Would certainly explain the social debuff...
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Nictis on September 12, 2016, 10:04:00 PM
Quote from: Dingo on September 08, 2016, 04:20:50 PM
A Dog Said doesn't conflict with any mod, I don't think. It does require a patch XML to use Improved Surgery, however.

*Edit: Alright I made some. I'm gonna make a list here of all the patches I've made so far with 3rd party download links for people who don't use Steam.

Improved Surgery Patches (A15c):

Improved Surgery for Expanded Prosthetics & Organ Engineering (EPOE) (https://steamcommunity.com/sharedfiles/filedetails/?id=756408576) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqZ0dzZ0NVaElMVkk)

Improved Surgery for Expanded Prosthetics & Organ Engineering (EPOE) with Realistic Medical System (https://steamcommunity.com/sharedfiles/filedetails/?id=756408699) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqX1RFTlZPeDFqdUk)

Improved Surgery for Glitter Tech (https://steamcommunity.com/sharedfiles/filedetails/?id=756983842) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqWTNCMlVjRlg3YjQ)

Improved Surgery for Glitter Tech (No Surgery) (https://steamcommunity.com/sharedfiles/filedetails/?id=756983976) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqZGFidm1UTlhLcUk)

Improved Surgery for A Dog Said... (https://steamcommunity.com/sharedfiles/filedetails/?id=760262076) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqWmlYcXFXWE83cDg)

Improved Surgery for A Dog Said... (Lite) (https://steamcommunity.com/sharedfiles/filedetails/?id=760264154) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqV09EMzBfMGhLY00)

Improved Surgery for A Dog Said... (No Crafting) (https://steamcommunity.com/sharedfiles/filedetails/?id=760264341) / (Non-Steam Link Here!) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqc1ZUSjBWWUpyMEE)

You can also find all of these on Github here (https://github.com/FudgePoly/ImprovedSurgeryPatches/releases) if you prefer.
Thanks man, that is a huge help.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Serenity on September 18, 2016, 06:53:19 AM
Can you install multiple of these patches at the same time? I assume yes, but I want to make sure :)
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Dingo on September 18, 2016, 07:22:01 AM
Yes, you can install multiple patches.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: Mackinz on September 21, 2016, 06:23:44 PM
Can I request a compatibility patch for this mod (http://steamcommunity.com/sharedfiles/filedetails/?id=754081820) as well? It seems to be an alternative to EPOE for certain chronic conditions.
Title: Re: [A15] Improved Surgery - Now with 25% More Gangrene
Post by: twoski on September 21, 2016, 06:43:33 PM
Thanks to Dingo there is a compatibility patch for DE Surgeries: http://steamcommunity.com/sharedfiles/filedetails/?id=764734484
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Dingo on September 22, 2016, 03:51:25 AM
Quote from: Mackinz on September 21, 2016, 06:23:44 PM
Can I request a compatibility patch for this mod (http://steamcommunity.com/sharedfiles/filedetails/?id=754081820) as well? It seems to be an alternative to EPOE for certain chronic conditions.

I don't think so. ConditionReplacement uses a custom DLL just like Improved Surgery, it has its own methods.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Dingo on September 26, 2016, 10:40:19 PM
All of my compatibility patches have been updated (I am also updating them on the Workshop). I am an idiot and had no clue about using proper abstract bases, so now everything should work without errors or soft/hidden errors.

Please download the new versions for whichever ones you are using from this post (https://ludeon.com/forums/index.php?topic=24975.msg261909#msg261909).
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Jamestec on September 27, 2016, 01:25:41 AM
In the latest (26/09/16?) compatibility patch for Improved Surgery and A Dog Said, there are duplicate entries for BionicLegBase and SimpleLegBase in the XML.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Dingo on September 27, 2016, 04:33:54 AM
You're right, I missed that. Will fix.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Adventurer on September 27, 2016, 06:07:00 AM
Dingo, does there need to be a compatibility patch for Mechanite Augments?

https://ludeon.com/forums/index.php?topic=19952.0
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: skullywag on September 27, 2016, 06:23:35 AM
Once 1000101 gets a version CCL out for A15 would this mod move to detouring the recipe workers? this is infinitley more compatible and wouldnt require all these patches (these could however be employed if CCL was ever not available for long periods which we are hoping wont happen again).
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Dingo on September 27, 2016, 07:14:31 AM
Quote from: Adventurer on September 27, 2016, 06:07:00 AM
Dingo, does there need to be a compatibility patch for Mechanite Augments?

https://ludeon.com/forums/index.php?topic=19952.0

Yes, but I don't feel like making more patches atm (working on a fork for kaptain_kavern's XML explanation project). It's extremely easy to do, go ahead if you want to (just look at my github for an example and you'll get it right away).

@Skully That would be ideal, to be honest. Or you could just use the mod-friendly overrides thing; I'm positive that will be added to CCL as well in the future.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on September 27, 2016, 09:52:30 AM
Quote from: skullywag on September 27, 2016, 06:23:35 AM
Once 1000101 gets a version CCL out for A15 would this mod move to detouring the recipe workers? this is infinitley more compatible and wouldnt require all these patches (these could however be employed if CCL was ever not available for long periods which we are hoping wont happen again).

i really do not like the idea of depending on CCL, maybe someday when it becomes more stable it will be a viable option, but for now RimWorld is still in development and i imagine that CCL will  be out of commission for long periods with each major update.

or maybe with luck tynan will make improvements to modding and CCL won't have to implement this detouring feature.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: skullywag on September 27, 2016, 10:11:15 AM
CCL is very stable. The issue you have is its time to update which i believe is unfounded as per everyone else who has an issue with that element. Yes its taken longer this alpha but its been a perfect storm, all team members had real life things to deal with and we had very little warning about the release compared to the ones prior. With the new ILSpy and such we should be faster going forward, we are also talking about splitting the library up a little so modders who dont need detours arent left waiting if for some reason we arent as quick as wed like to be.

Tynan is never going to add detouring into core, people need to stop thinking that has any chance of happening, the support cost is just not feasible for him to add it.

All im saying is your current way is not mod compatible hence all the patches, the way im proposing would mean no need for them, but you could use them if for whatever reason CCL is not available. Its win win here for you cant see a reason you wouldnt use it when its available.

But you have your opinion and I have no right to dissuade you from that. So ill leave it there.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on September 27, 2016, 10:29:48 AM
I think it would be a good idea to split the pure programmer utility stuff like detouring into another mod since i can't imagine that stuff would be affected too much, if at all, by rimworld updates. Maybe huge updates would change things but overall i think that might be the best way to avoid future downtime.

I don't want to depend on CCL currently because basically every person i know who uses RimWorld mods has been less than happy about CCL being out of commission for a fairly long time. With that downtime, every mod using CCL has been effectively (temporarily) wiped out. Maybe it's irregular but it's still something for me to worry about.

Ultimately a developer has 2 choices. Either they can wait for CCL to update so they can use whatever programmer utility stuff is bundled with it, or they can just do things themselves without worrying about dependencies. I chose the latter based on my own needs, and mainly based on the fact that i don't know when CCL will be updated and i'd rather not wait around.

Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: skullywag on September 27, 2016, 10:38:08 AM
But what im saying is you are in a position where you cannot lose, for now continue as you are, when CCL is released you do the detours that are necessary and depend on it, if A16 drops and CCL isnt gonna be updated in your timeframe, you edit your xml and point it at your custom workers, and update your patches (which will have to be done anyway). So now you dont HAVE to wait for CCL but if its up to date you can use and gain all the compatibility that comes with it.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on September 27, 2016, 12:47:07 PM
Well once CCL comes out i could make a branch that uses it.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Thirite on September 27, 2016, 07:24:53 PM
Just wanted to say kudos for an absolutely essential mod. Cheers
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Serenity on September 27, 2016, 08:30:26 PM
I'm not quite sure this is really working for me. I still get surgery failures  - and with that cut up body parts - left and right. But I installed it the way it was recommended. Maybe the many patches mess things up:

EPOE
A Dog Said Lite
Realistic Medical System (EPOE)
Improved Surgery
EPOE + RMS + IS patch
A Dog Said Lite + IS patch

The part where prosthetics aren't destroyed works though. Maybe I just expected even less mutilation...
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Dingo on September 27, 2016, 08:51:55 PM
The question is, are your major or minor failures resulting in body parts being flat out removed for no reason? IS still has failure states, it's not "surgery guaranteed to work", it just makes the failure states way more logical. If you're getting surgical cuts and minor/major infections on failure and you're getting the body part back with less HP then it works as intended.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Serenity on September 27, 2016, 08:55:54 PM
I don't think I've had body parts being removed yet. Nobody has died from surgeries. That's good. In vanilla that probably would have happened already.

Didn't get an infection yet. But lots and lots of cuts. I suppose I expected the cuts to be rarer and infections more common.

EDIT:
Well, scratch that. My level 18 surgeon just killed someone during a lung transplant. In a sterile room on a good hospital bed with normal medicine  :'(

Apparently he removed her neck(?!), her left arm and her right kidney. WTF?! Oh, and she was his daughter. I think I'm gonna stop playing iron man...
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Dingo on September 27, 2016, 09:13:53 PM
Death on surgery isn't removed. You still have "deathOnFailedSurgeryChance"... It sounds like it's working fine for you, just bad RNG. You could just describe your ideal surgery mod maybe twoski will implement some changes to the code if it's a good suggestion.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Serenity on September 27, 2016, 09:54:36 PM
Maybe make the chance skill dependent? That low level surgeons screw up is ok. Especially with complicated operations. But above a certain point deaths should not happen during routine surgeries (unless maybe when you operate on the brain or something like that). Especially not like that.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Thirite on September 28, 2016, 01:46:07 AM
Quote from: Serenity on September 27, 2016, 09:54:36 PM
Maybe make the chance skill dependent? That low level surgeons screw up is ok. Especially with complicated operations. But above a certain point deaths should not happen during routine surgeries (unless maybe when you operate on the brain or something like that). Especially not like that.
Agreed. I don't have much free time to play so I've not experienced this myself- but a doctor level 10~ or higher shouldn't have a chance to kill a patient on a simple procedure. 15 should remove the chance on organ transplant, and at 20 remove the risk of failure completely.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on September 28, 2016, 09:33:52 AM
i never messed with the surgery failure chances. i can share the algorithm here and maybe someone can come up with a better way that makes high level surgeons less likely to fail. currently, surgery failure is based off of skill, type of medicine used, cleanliness of the room, and i think that vitals monitors and hospital beds can buff this as well.

and yes, it it still possible to kill people on critical failures. maybe i could tweak this to be more common for rookie surgeons and less common for pros.

i will share some of the algorithms here later today when i get time.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: BetaSpectre on October 02, 2016, 11:18:23 PM
+1
The mod or the update in rimworld seemed to have increased my chance of surgery fails xD, but I like how it's "realistic"
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: faltonico on January 03, 2017, 03:08:24 AM
I ragequited my current A16 colony because fixing a toe chopped up the whole leg of one of my pawns...
I refuse to play without this mod now... I went back to my A15 colony -_-'
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Adalah217 on January 03, 2017, 03:29:59 AM
Quote from: faltonico on January 03, 2017, 03:08:24 AM
I ragequited my current A16 colony because fixing a toe chopped up the whole leg of one of my pawns...
I refuse to play without this mod now... I went back to my A15 colony -_-'

You can fix body parts in dev mode for little things like that ;D
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on January 05, 2017, 10:08:09 AM
can anyone confirm whether failures in .16 still destroy prosthetics?

i was told that .16 has much less random failures in surgery so this mod will likely become obsolete. if failures destroy prosthetics still then i might patch it to not delete them
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: swampslug on January 05, 2017, 04:34:20 PM
As far as I can tell failures still destroy prostheses. Furthermore the medical potency of medicine has been reduced so surgery failure is more likely with anything less than Glitterworld medicine.
To balance this, there is a 50% chance of a failure being minor (prosthesis lost and minor damage to target area or directly connected body part), a 40% chance of a failure being critical (as minor but more damaging) and a 10% chance of it being ridiculous (lots of damage and random body part affected).

Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: jmababa on January 19, 2017, 01:38:40 AM
could you post where we can download alternate than steam the improved surgery using ludeon site version of game and don't want to put it on steam
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on January 19, 2017, 08:49:55 AM
https://bitbucket.org/twoski/rimworldmods/downloads

note that it only works in a15 for the time being.

since people still seem to have a lot of issues with surgery failures i will be updating this mod to a16 soon
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: twoski on January 19, 2017, 06:50:38 PM
Okay so i looked through the surgery failure code and it looks like they did add localized damage in the minor and catastrophic failures. So when you get a minor failure the damage will be near the part being operated on.

That said, failing to install implants will still destroy them (which is nonsense in my opinion) so it looks like this mod is still relevant.

Check the OP for the latest update.
Title: Re: [A16] Improved Surgery
Post by: Thirite on January 19, 2017, 09:12:24 PM
Awesome, I was waiting for this mod to get updated.
Title: Re: [A15] Improved Surgery - Less Randomness In Failures
Post by: Jorlem on January 20, 2017, 07:28:31 AM
Quote from: twoski on January 19, 2017, 06:50:38 PM
Okay so i looked through the surgery failure code and it looks like they did add localized damage in the minor and catastrophic failures. So when you get a minor failure the damage will be near the part being operated on.

That said, failing to install implants will still destroy them (which is nonsense in my opinion) so it looks like this mod is still relevant.

Check the OP for the latest update.
Does the update fix the ridiculous failure rates in A16 as well?
Title: Re: [A16] Improved Surgery
Post by: twoski on January 20, 2017, 08:43:48 AM
Compared to A15, A16 has almost identical failure rates. The only difference is that they introduced a new level of failure. I will attempt to explain (roughly) how the failures work using 10-sided dice.

In vanilla a15 failures:

Roll a d10. If the number is 5 or more, the failure is minor. If the number is 4 or less, the failure is catastrophic.

In vanilla a16 failures:

Roll a d10. If the number is 5 or more, the failure is minor. If the number is 4 or less, roll again.
If the new number is 2 or higher, the failure is catastrophic. If the number is 1, the failure is "ridiculous".

In Improved Surgery a16 failures:

Roll a d10. If the number is 4 or more, the failure is minor. If the number is 3 or less, roll again.
If the new number is 2 or higher, the failure is catastrophic. If the number is 1, roll again.
If the new number is 7 or higher, the failure is "ridiculous". Otherwise, the failure is catastrophic and will guarantee an infection.


I think my version is a lot better balanced. I made minor failures more likely to be the outcome by tweaking the thresholds, and i also added an extra tier of failure before "ridiculous". So in practice, it will be extremely rare to cause ridiculous failures.

One thing that i think would be interesting to implement would be some sort of weighting system based on skill. Unskilled doctors should have a greater chance to cause catastrophic failures (or worse).
Title: Re: [A16] Improved Surgery
Post by: Jorlem on January 20, 2017, 04:21:28 PM
Quote from: twoski on January 20, 2017, 08:43:48 AM
Compared to A15, A16 has almost identical failure rates.
As I understand it, the change in A16 was a massive nerf to medicine (except glitter), not to the surgery success rates themselves. As all surgeries require meds of some sort, the end result is that surgeries fail far more often than they did in earlier alphas.  See this thread (https://ludeon.com/forums/index.php?topic=28867.0) for more detail.
Title: Re: [A16] Improved Surgery
Post by: twoski on January 20, 2017, 05:33:52 PM
ah, i worded it poorly. i should say, compared to a15, a16 failures are nearly identical in execution, but more common due to the nerfing of medicine. so there's a bit of confirmation bias i think.
Title: Re: [A16] Improved Surgery
Post by: twoski on January 20, 2017, 05:49:23 PM
Okay, i've made some minor tweaks to medical potency:

- Herbal medicine is now 0.5 potency (was 0.4)
- Regular medicine is now 0.75 potency (was 0.7)
- Glitterworld medicine is now 1.5 potency (was 1.6)

Based off the potency chart on the wiki, glitterworld was a bit over the top and herbal medicine was pretty crap. So this effectively equalizes things a bit better and you can see now based on the new numbers that regular medicine is 150% better than herbal, and glitterworld medicine is 200% better than regular.
Title: Re: [A16] Improved Surgery
Post by: Jorlem on January 20, 2017, 06:01:06 PM
:D

Thank you. It has been immensely frustrating watching my skill 16 doctor consistently fail to put peg legs on prisoners, and kill them when giving them dentures.
Title: Re: [A16] Improved Surgery
Post by: Jorlem on January 20, 2017, 07:26:21 PM
Sorry for the double post, but I needed to report a weird bug that I'm seeing now with the mod enabled.  When I had my best surgeon try to install a peg leg on someone that had their right leg shot off, the surgeon kept repeating the operation until it failed catastrophically.  That is, a successful operation consumed the log and the herbal med, but did not add the peg leg to the character, and the surgery bill was not cleared until the operation failed.
Title: Re: [A16] Improved Surgery
Post by: twoski on January 20, 2017, 08:07:26 PM
So you have any other surgery mods? I'll look into it and see if I can find any issues on my end
Title: Re: [A16] Improved Surgery
Post by: Napple on January 20, 2017, 08:14:18 PM
So how does this compare with the less arbitrary surgery mod by Psychology.
Title: Re: [A16] Improved Surgery
Post by: Jorlem on January 20, 2017, 10:43:05 PM
Quote from: twoski on January 20, 2017, 08:07:26 PM
So you have any other surgery mods? I'll look into it and see if I can find any issues on my end
None of the other mods I had active should be altering surgery, as far as I'm aware.

Here's the other mods I have active, leaving out this mod:

HugsLib
M Pawn Death RNG Remover
OSHA Compliance
Chemfuel Generator
LT-Doormat
Step Awat From The Medicine
Craftable Drugs
Set-Up Camp
Camping Stuff
I Can Fix It!
Path Avoid
Temperature Gauge
Snowy Trees
Mod List Backup
Hand Me That Brick
RT Fuse
RD - Fire Department
QualityBuilder
Title: Re: [A16] Improved Surgery
Post by: Dingo on January 21, 2017, 04:12:01 AM
You should consider detouring with HugsLib instead of replacing the XML recipe classes. Since A16 now has one functional (HugsLib) and one semi-functional (CCL) libraries for it I don't see why you wouldn't.

I've been getting some requests to update my patch XMLs to A16 but I think it's unnecessary and less compatible than a detour.
Title: Re: [A16] Improved Surgery
Post by: twoski on January 21, 2017, 12:37:04 PM
okay, adding the detours with hugslib wasn't so bad. this mod should now be more compatible with other surgery mods. bear in mind that any other mod that detours the surgery recipes will conflict with this one.
Title: Re: [A16] Improved Surgery
Post by: twoski on January 21, 2017, 12:45:50 PM
Quote from: Jorlem on January 20, 2017, 07:26:21 PM
Sorry for the double post, but I needed to report a weird bug that I'm seeing now with the mod enabled.  When I had my best surgeon try to install a peg leg on someone that had their right leg shot off, the surgeon kept repeating the operation until it failed catastrophically.  That is, a successful operation consumed the log and the herbal med, but did not add the peg leg to the character, and the surgery bill was not cleared until the operation failed.

i found the cause of this bug and fixed it so you should be in the clear now
Title: Re: [A16] Improved Surgery
Post by: sleepytaco on January 23, 2017, 05:40:21 AM
Quote from: twoski on January 21, 2017, 12:45:50 PM
Quote from: Jorlem on January 20, 2017, 07:26:21 PM
Sorry for the double post, but I needed to report a weird bug that I'm seeing now with the mod enabled.  When I had my best surgeon try to install a peg leg on someone that had their right leg shot off, the surgeon kept repeating the operation until it failed catastrophically.  That is, a successful operation consumed the log and the herbal med, but did not add the peg leg to the character, and the surgery bill was not cleared until the operation failed.

i found the cause of this bug and fixed it so you should be in the clear now

Hmm I guess thats what I was seeing.  I tried on a bunch of prisoners, always resulting in death.  I also tried a bionic jaw removal, which also resulted in death.  This is with a 18 skill doctor using herbal meds, so I suppose thats probably why 100% of my surgeries fail, but it seems rather obscene.
Title: Re: [A16] Improved Surgery
Post by: Jorlem on January 23, 2017, 02:12:58 PM
Quote from: twoski on January 21, 2017, 12:45:50 PM
Quote from: Jorlem on January 20, 2017, 07:26:21 PM
Sorry for the double post, but I needed to report a weird bug that I'm seeing now with the mod enabled.  When I had my best surgeon try to install a peg leg on someone that had their right leg shot off, the surgeon kept repeating the operation until it failed catastrophically.  That is, a successful operation consumed the log and the herbal med, but did not add the peg leg to the character, and the surgery bill was not cleared until the operation failed.
i found the cause of this bug and fixed it so you should be in the clear now
Thank you.  I'll give it a try later today. :)
Title: Re: [A16] Improved Surgery
Post by: twoski on June 03, 2017, 09:54:47 PM
updated to a17, cheers. post any bug reports on the steam page please!
Title: Re: [A17] Improved Surgery
Post by: AzXeus on June 14, 2017, 05:41:35 AM
does this mod fix the vanilla bug of medicine potency values not applying to surgery?
https://ludeon.com/forums/index.php?topic=32763.0
Title: Re: [A17] Improved Surgery
Post by: twoski on June 14, 2017, 09:21:02 AM
i wasn't aware of that bug, and by the looks of it, tynan was not aware of it either.

if true, then it appears that medical potency may not have an effect on surgery in a17.
Title: Re: [A17] Improved Surgery
Post by: AzXeus on June 15, 2017, 05:07:37 AM
yeah.. do you know if you'll be able to fix it?
Title: Re: [A17] Improved Surgery
Post by: twoski on June 15, 2017, 01:35:29 PM
i will try messing around with it this weekend. the problem seems to be that surgeries delete the medicine when they start, so the function that checks the potency defaults to 100% potency since there's no medicine object
Title: Re: [A17] Improved Surgery
Post by: twoski on June 17, 2017, 09:33:07 PM
ok so this mod does detour the surgery recipe functions but it has no control over the ingredients being passed to the recipe. so if something is broken then i'm afraid i don't have much control over it at the moment.
Title: Re: [A17] Improved Surgery
Post by: AzXeus on June 18, 2017, 04:43:01 PM
and i guess there's no way to hook the initialisation of the recipe to find the potency of medicine from the instigator and store it into a different variable for use in the recipe later huh?  :-\
Title: Re: [A17] Improved Surgery
Post by: twoski on June 19, 2017, 01:31:27 PM
i might be able to do some hacky stuff but it would make the mod less compatible with others and it probably wouldn't be worth the trouble since Tynan is aware of the bug and it will be fixed next patch.

the bug seems balanced anyhow... all medicines have the potency of regular medicine when doing surgeries for now. which means herbal meds got a buff and glitterworld meds got a debuff.
Title: Re: [A17] Improved Surgery
Post by: Dima_ on July 05, 2017, 04:03:26 PM
I'm installing a peg leg with this mod, and even though my colonist fails, i'm not getting any damaged peg legs back.
this is the mod list
http://imgur.com/a/aNxr9
Title: Re: [A17] Improved Surgery
Post by: twoski on July 06, 2017, 07:16:21 PM
2 theories - either the organ harvesting mod messes with the surgery code and ruins my detour, or the surgery bug (that tynan will fix soon i'm sure) is making my mod not work properly
Title: Re: [A17] Improved Surgery
Post by: Dima_ on July 09, 2017, 04:18:50 PM
well, do you think it would be possible to make a patch for EPOE and cybernetic storm? because anyone who's using this mod has a pretty high chance of using one of those too tbh.
Title: Re: [A17] Improved Surgery
Post by: twoski on July 12, 2017, 09:03:52 AM
i can't really do much else, if EPOE and cybernetic storm used HugsLib then our mods would probably be compatible.

This may just be related to the current surgery bug which Tynan will have to fix though, and not related to mods clashing.
Title: Re: [A17] Improved Surgery
Post by: fatm3l on December 12, 2017, 11:25:36 AM
Update b18 plss
Title: Re: [A17] Improved Surgery
Post by: RemingtonRyder on December 12, 2017, 11:28:36 AM
(http://static.tvtropes.org/pmwiki/pub/images/MTG-ThreadNecromancer_3198.jpg)
Title: Re: [A17] Improved Surgery
Post by: Jastro on December 12, 2017, 02:50:18 PM
Here's an unofficial update to B18

Steam (http://steamcommunity.com/sharedfiles/filedetails/?id=1229709097)
Dropbox (https://www.dropbox.com/s/xrof3utoejfm6wy/Improved%20Surgery%20B18.rar?dl=0)
Title: Re: [A17] Improved Surgery
Post by: twoski on December 13, 2017, 10:31:46 AM
You beat me to the punch ;)

I'll work on getting my update out tonight.