spawnThingOnRemoved Help

Started by Papriko, May 01, 2020, 02:54:28 AM

Previous topic - Next topic

Papriko

Hello Everyone,

I am working on a mod where I want to be able to spawn an item when an hedif is removed.

What I have been attempting is to xpath spawnThingOnRemoved into the Carcinoma hediff so that when the "excise carcinoma" recipe is called to remove the hediff, it'll spawn an item.

I only see the core organs and implants using this tag naturally, but I can't get it to work for any other hediff.

The plan is to have a custom mechanoid infection that you can remove and get components, or a mod specific resource from vanilla carcinoma.

I'm not even sure if this can be done with only XML but the spawnThingOnRmoved tag seems to be exactly what I am looking for.

Any assistance would be amazing.

K

It comes down to the way that recipes are created for removing Hediffs. Only the Recipe_RemoveImplant code actually tries to use the spawnThingOnRemoved field, and only artificial parts use that recipe. Unfortunately, most Hediffs are removed using Recipe_RemoveHediff which doesn't try to spawn anything on removal. You would likely need to make a new Recipe class to do this and xpath replace the old one that the Hediff you want to affect is using.

Papriko

Ah beautiful!

It took a bit of tinkering but that did the trick.

Thanks so much!