Unforbidding pawns on death

Started by smoq2, January 23, 2015, 05:56:00 AM

Previous topic - Next topic

smoq2

Where can I find the instruction that automatically forbids a corpse once a pawn dies? I wish to deactivate it.


smoq2

Ok, no luck finding help with this solution, so I'll try differently.

Is there some kind of trigger that is called in case of pawn's death? Somewhere within the Defs or within the code.

I could bind my code that will unforbid a pawn if killed under specific circumstances.

Rikiki

In Pawn_HealthTracker, you have a function:
private void PawnKilled(DamageInfo? dinfo, HealthDiff healthDiff)
But this is private! ;) So you would have to overwrite the callers... and so on!

Anyway, to get those functions called, you have to overwrite the core Pawn class which is not a good idea to maintain mods compatibility. >:(
There is already a mod which automatically do this kind of thing.

smoq2

#3
Quote from: Rikiki on February 02, 2015, 11:28:02 AM
In Pawn_HealthTracker, you have a function:
private void PawnKilled(DamageInfo? dinfo, HealthDiff healthDiff)
But this is private! ;) So you would have to overwrite the callers... and so on!

Anyway, to get those functions called, you have to overwrite the core Pawn class which is not a good idea to maintain mods compatibility. >:(
There is already a mod which automatically do this kind of thing.

Yep, figured it would be better to just make a periodic check which would just see if there are any forbidden corpses around every now and then - that's what the "auto hauler" mod you mentioned does.

Anyway, thanks a lot. I'll go on from here. Oh, and many thanks to the author of the aforementioned mod for supplying his source code.

[EDIT]

However, this solution does not suit me in the long term, as it prevents the player from forbidding a corpse (should he wish to do so), as the method would just unforbid it during the next planned check. Hence I wanted it to be unforbid only once (on death). Unless there is some way to either: check if the forbidding was done by the player OR store a bool whether the corpse was already unfrobidden once, it won't do.

Wastelander

QuoteHowever, this solution does not suit me in the long term, as it prevents the player from forbidding a corpse (should he wish to do so), as the method would just unforbid it during the next planned check. Hence I wanted it to be unforbid only once (on death). Unless there is some way to either: check if the forbidding was done by the player OR store a bool whether the corpse was already unfrobidden once, it won't do.

I don't have my decompiler in front of me, but how about this: Pawns are Things, so they can have ThingComps. How about overriding the Human definition, including a custom comp, that unforbids the corpse on death? You could either execute on RareTick, or there's even a "PostApplyDamage" method that looks useful for this.