How to set pawns on fire ? (spontaneous self-combustion)

Started by Reize81, May 20, 2019, 03:40:34 PM

Previous topic - Next topic

Reize81

I am working on a personal mod which adds a variety of guns with special abilities. One of them is a pistol which fires incendiary rounds that have a chance to set the pawn which got hit on fire. I made this part work.
White phosphorus is a substance which ignites when it dries and which was used in WWII phosphor bombs. To simulate this behavior I would like to add a chance for spontaneous self-combustion which is acquired when the pawn is hit by the bullet and which leads to self-combustion a day or so after the battle. I want to simulate bits of white phosphorous which cling to the pawns clothes and ignite when they dry, for example during surgery/treatment when the bullet is removed.
Basically I want to add a randomly applied timer for spontaneous combustion. I thought something like a hediff which is given like carcinoma or dementia during toxic buildup.

          <li Class="HediffGiver_Random">
            <hediff>Carcinoma</hediff>
            <mtbDays>438</mtbDays>
            <canAffectAnyLivePart>true</canAffectAnyLivePart>
          </li>

Then I would have to create a hediff which results in spontaneous combustion. Can I somehow make a hediff apply a damageDef like "Flame" ?
I could use <becomeVisible>false</becomeVisible> to hide the acquired hediff and <severityPerDay>1.0</severityPerDay> to reach a severity of 1.0 after one day and then the stage of severity 1.0 would have to apply the damageDef "Flame". Could this work?
I thought of rewriting the damageDef with a radius restricted to one tile and without any sound. If a mote is required, I could use a transparent one and I could set the damage to be really small. The desired result would be spontaneous combustion. Any ideas how this could work?
Another question about the <mtbDays> - is it correct to assume that smaller numbers represent a higher chance of acquiring the hediff?
Because I couldn't figure out a working way with the damageDef I thought maybe I could create a mental state which leads to spontaneous combustion. Like Fire Starting Spree but with the pawn itself as the only target. Unfortunately, I guess the behavior of the Fire Starting Spree isn't controlled by .xml code and requires more programming than I am able to do.
In Job_Misc.xml there is an Ignite JobDef - so maybe I could somehow make the pawn ignite itself? Any ideas?

Mehni

Oh RimWorld. Never change.

There's no path in XML which results in setting a pawn on fire. You'll need some C# to reach these new heights (or depths) of messed up.

The Fire Starting Spree is the closest alternative to it which can be done in XML alone. Same way dementia causes a confused wander, any hediff can trigger any mental state.

Kirby23590

I have been running around with a mod i found in the workshop called Ignite everything.

It's more like how the raiders when they are attacking your colony are able to set fire on your wooden or metal structures... I mostly use it easily burn unwanted corpses or items and creating burning pillars to collapse mountains...

Though the mod is only in the Steam Workshop...

One "happy family" in the rims...
Custom font made by Marnador.



LWM

If you end up making this happen, I volunteer for adding a Thought Hediff "We[/They] committed a war crime.  They burned alive.  It was horrifying."

As far as C# projects go, this one is probably fairly easy?

--LWM

jonbrant

I found this via google, trying to do the same thing.
I figured it out, figured I'd share for others wanting the same

It takes some C# as mentioned, but in your bullet class, override Impact

Something like this:
protected override void Impact(Thing hitThing) {
if (Def != null && hitThing != null && hitThing is Pawn hitPawn)
    {
       hitPawn.TryAttachFire(1);
}
}


Check out Jecrell's Plague Gun tutorial if you don't know how to get this far, this is his code