Resurrecting Pawns?

Started by katjezz, November 22, 2016, 08:13:46 AM

Previous topic - Next topic

katjezz

Is this possible in any way? Does the game allow for this in its code, and could that be made into a mod?

Like a pawn dies in a fight, you bring the body to some kind of resurrection device and then resurrect him?

skullywag

Yep totally, all corpses hold an "innerPawn" which is all the details about the that pawn.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

14m1337

I smell an interesting mod coming soon....
Quick_Silver - The One And Lonely
My posts may sometimes be filled with (sarcastic) humor - it's up to you to find it out on your own.
Usually drunk on Mondays from 21:00 to 03:00 CEST.

Robostove

Resurrecting pawns is easy enough. Use that innerPawn in the corpse, assign it new instances of stances, needs and mindState (these were destroyed when the pawn was killed).

You also need to change the healthState of the pawn from PawnHealthState.Dead to PawnHealthState.Mobile. An easy way to accomplish this is simply calling innerPawn.health.Reset(), although this has the unfortunate side effect of clearing all hediffs (injuries, missing limbs, whatever) that were on the pawn. Great if you want the pawn totally restored, not so great if you just want a living version of the existing pawn.

The problem with trying to maintain existing injuries is that health.healthState is private -- you can't just flip it to PawnHealthState.Mobile. I've tried doing a deepcopy of the existing hediffs before calling health.Reset(), but always get a game crash due to access violations.

Does anyone know a method to force change a field that is private?

RawCode

access violations?
lal!
use reflection, it allows to ignore all and any "visibility" rules.

protip, spawning new pawn and setting it's personality also works, and it works better then recovering "dead" pawn.

keeping all damage and injury, well, not possible without some hooks, in other case pawn will die again next tick.

Robostove

Thanks for the tip RawCode, I can't believe how simple that was - reflection is amazing.

mazacik

Is any of you going to attempt to make a mod for resurrecting pawns? If not, I might try myself

RawCode

you are a bit two years late
https://ludeon.com/forums/index.php?topic=5224.msg50259#msg50259

still, you can make such mod using "modern" techniques like detours\hooks\injections and for current version, it requested on regular basis.

Kapun

I have a mod idea: harvesting bionic bodyparts from cadavers through surgery. Is it hard to implement?

Illusion Distort

Short answer: Not "that" hard.

But you would have to do some wizardry with the way the game handles the bionics. If I remember right it is hardwired in the game that bodypartrecipies are only avaliable on living pawns. Not my area of expertice. :D