Multiple Lives - KonradHeinser/EBSGFramework GitHub Wiki
If at first you don't succeed, die die again. This hediff comp allows you to create pawns that will be resurrected after dying as long as they have still have additional lives. For your basic comp, you will need something similar to this:
<comps>
<li Class="EBSGFramework.HediffCompProperties_MultipleLives">
<extraLives>1</extraLives> <!--If -666, then this is infinite lives, always required-->
</li>
</comps>
After you've set up the maximum number of lives, you're going to need to decide what system is handling said lives, either the hediff severity or the hediff comp itself. If you use severity, then the max severity is going to determine how much hediff severity is taken each time a life is lost. These two tags are mutually exclusive
- daysToRecoverLife : Default (0) : Handled by the comp itself. If you have things that will influence hediff severity, but you don't want those things to influence life count, use this. If this is set to 0 and you aren't using severity, the pawn will never regain lives
- useSeverityNotDays : Default (False) : When set to true, this comp will use the hediff severity to determine life count, and reduce the severity whenever a life is lost (other than the final one). Each life takes an equal amount of severity, so if you have a special label for each life, make sure to set the minSeverities to those points
The revival process itself also has some customization options. Please note that even if you want a pawn to revive instantly, you'll need to set one of these so the code knows that
- hoursToRevive : Default (0) : Sets a static number of in-game hours it takes to revive. If you want to make a pawn revive instantly, set this to -1
- randomHoursToRevive : Default (0~0) : A float range that should select a random value between min~max
If you want to set up something similar to the deathless gene, where the pawn can walk off anything except losing their brain, there is a special tag you can enable
- needBrainToRevive : Default (False) : Pawn needs to have head and brain to start reviving
For additional options on conditions for the pawn to revive, you have these options
- revivalChance : Default (1) : Chance that the pawn can begin reviving. If this doesn't come to pass, then pawns with infinite lives die, and pawns with finite lives expend extra lives until Rimworld's random function gives you a lucky number
- onlyOneChance : Default (False) : Removes expending extra lives, meaning failing the random chance once results in instant death
There are also options for spawning things (i.e. ethereal objects) and sounds when the pawn begins or ends their revival process:
-
reviveStartSound : Creates a sound centered on the dead pawn's location
-
thingSpawnOnReviveStart : A single thing to spawn in the pawn's place. Can be an ethereal object that quickly goes away to create special effects
-
thingsToSpawnOnReviveStart : List version of thingSpawnOnReviveStart
-
reviveEndSound : Creates a sound centered on the dead pawn's location
-
thingSpawnOnReviveEnd : A single thing to spawn on the pawn's location. Can be an ethereal object that quickly goes away to create special effects
-
thingsToSpawnOnReviveEnd : List version of thingSpawnOnReviveEnd
The hediff comp also contains a built in Destroy on Death portion that would activate in the event that the pawn is unable to revive due to lack of lives or random chance. Note that there are risks with using this as there is a chance that this interacts poorly with other on death effects:
- deleteOnFailedRevive : Default (False) : Destroys the corpse on final death and checks for things to spawn and special sounds from the below tags
- failSound : Creates a sound centered on the dead pawn's location
- thingSpawnOnFail : A single thing to spawn in the pawn's place. Can be an ethereal object that quickly goes away to create special effects
- thingsToSpawn : List version of thingsToSpawnOnFail
If you want it to send messages/letters in certain situations, you have these available to you:
-
revivalFailedMessage : Sent when the pawn is unable to revive
-
revivalFailedLetterLabel : Label of the letter sent when the pawn is unable to revive
-
revivalFailedLetterDescription : Content of the letter sent when the pawn is unable to revive
-
revivalSuccessMessage : Sent when the pawn is revived
-
revivalSuccessLetterLabel : Label of the letter sent when the pawn is revived
-
revivalSuccessLetterDescription : Content of the letter sent when the pawn is revived
And the last thing only matters to those who want to remove the tooltip additions. By default, hovering over the hediff in the health tab will tell the player the progress (if the pawn is reviving or regaining a life), and how many lives are left (or say they have infinite lives)
- includeProgressOnTooltip : Default (True) : Shows revival or life regaining progress if applicable. Display days remaining
- includeRemainingLivesOnTooltip : Default (True) : Informs the player if the pawn is on their last life, has extra lives remaining, or if they are immortal
Adapted example from Superhero Genes. This hediff was added by a gene, and allowed the pawn to avoid death once every 15 days by immediately reviving them after death. It uses severity because the hediff is intended to provide effects based on how recently the pawn last died.
<HediffDef>
<defName>SecondHeart</defName>
<label>second heart</label>
<description>There was a description here.</description>
<isBad>false</isBad>
<hediffClass>HediffWithComps</hediffClass>
<everCurableByItem>false</everCurableByItem>
<initialSeverity>1</initialSeverity>
<maxSeverity>1</maxSeverity>
<stages>
<li>
<label>missing second heart</label>
<minSeverity>0.001</minSeverity>
</li>
<li>
<label>regrowing second heart</label>
<minSeverity>0.1</minSeverity>
<capMods>
<li>
<capacity>BloodPumping</capacity>
<offset>0.3</offset>
</li>
<li>
<capacity>Breathing</capacity>
<postFactor>0.9</postFactor>
</li>
</capMods>
</li>
<li>
<label>half-formed second heart</label>
<minSeverity>0.5</minSeverity>
<capMods>
<li>
<capacity>BloodPumping</capacity>
<offset>0.5</offset>
</li>
<li>
<capacity>Breathing</capacity>
<postFactor>0.85</postFactor>
</li>
</capMods>
</li>
<li>
<label>mostly formed second heart</label>
<minSeverity>0.75</minSeverity>
<capMods>
<li>
<capacity>BloodPumping</capacity>
<offset>0.8</offset>
</li>
<li>
<capacity>Breathing</capacity>
<postFactor>0.75</postFactor>
</li>
</capMods>
</li>
<li>
<label>second heart</label>
<minSeverity>1</minSeverity>
<capMods>
<li>
<capacity>BloodPumping</capacity>
<offset>1.0</offset>
</li>
<li>
<capacity>Breathing</capacity>
<postFactor>0.7</postFactor>
</li>
</capMods>
</li>
</stages>
<comps>
<li Class="HediffCompProperties_SeverityPerDay">
<severityPerDay>0.067</severityPerDay>
</li>
<li Class="EBSGFramework.HediffCompProperties_MultipleLives">
<extraLives>1</extraLives>
<useSeverityNotDays>True</useSeverityNotDays>
<hoursToRevive>-1</hoursToRevive>
</li>
</comps>
</HediffDef>