A common framework to change body part max HP.
The main idea is to git-clone the repo to local so that you could git-pull regularly to apply updates (if exists)
# cd to RimWorld root directory first
mkdir Mods
cd Mods
git clone https://github.com/Vectorial1024/EliteBionicsFramework.git
git pull
This mod is now being used by a few other mods to boost body part max HP values.
For more info and an updated list of mods, check out the relevant Steam Collection here: https://steamcommunity.com/workshop/filedetails/?id=2016834921
This mod has built-in integration with some other third-party mods, and such integrations are in place to ensure that those other mods can read the correct body part max HP as calculated by this framework mod.
The third-party mods are chosen because they are deemed stable enough that the IL-code patching technique utilized by this mod can easily survive long without problems; or, they are chosen because not doing so would break some features.
Currently, the following mods are supported, in no particular order:
Notably, the following mods are providing code-level integration on their side:
Note that this list does not include the mods that are using this framework to provide actual body part max HP manipulation.
For more info and an updated list of mods, check out the relevant Steam Collection here: https://steamcommunity.com/workshop/filedetails/?id=2693300854
The following mods, because of technical reasons, are perfectly compatible with EBF, and no action is required from EBF's side unless they made a breaking update:
This mod has built-in unification with some other third-party mods that also provides body part HP changing effects. This is only to allow those mods to work with EBF without issues, and I do not claim ownership to those mods.
For more info and an updated list of mods, check out the relevant Steam Collection here: https://steamcommunity.com/workshop/filedetails/?id=2828792658
Please refer to individual md files under /Docs
for detailed information of each available component.
Currently, these components are available:
In RimWorld, Hediffs may optionally carry HediffCompProperties to add flavour to the Hediff. Examples of HediffCompProperties already implemented in RimWorld are HediffCompProperties_Immunizable
(used by most, if not all, diseases and infections), HediffCompProperties_VerbGiver
(used by some bionics and other mods to e.g. increase body part melee damage; there may be other uses) and HediffCompProperties_Disappears
(used by Fibrous/Sensory Mechanite Hediffs)
Important Notice: RimWorld disallows adding multiple HediffCompProperties
onto the same Hediff. This means, mods that try to add EBF HediffCompProperties to the same bionic (e.g. vanilla Bionic Arm) will get blocked by the game, and this is out of Elite Bionics Framework's control.
HediffCompProperties
are representatives of HediffComps
. HediffCompProperties
lets us define parameters for HediffComps
to use, so HediffComps
can show our intended effect.
To add HediffCompProperties
to your Hediff
, open the XML file that contains your Hediff
, and add an li
entry to the comps
node. If the comps
node does not exist, add it first.
After adding your HediffCompProperties
, your Hediff
XML Def should look something like this:
<HediffDef>
<!-- Omitted code -->
<comps>
<!-- Adding HediffCompProperties_VerbGiver -->
<li Class="HediffCompProperties_VerbGiver">
<tools>
<li>
<label>fist</label>
<capacities>
<li>Blunt</li>
</capacities>
<power>12</power>
<cooldownTime>2</cooldownTime>
</li>
</tools>
</li>
<!-- Add complete -->
</comps>
<!-- Omitted code -->
</HediffDef>
If you want to add in more HediffCompProperties
, just add in additional li
nodes like this:
<HediffDef>
<!-- Omitted code -->
<comps>
<li Class="HediffCompProperties_VerbGiver">
<tools>
<li>
<label>fist</label>
<capacities>
<li>Blunt</li>
</capacities>
<power>12</power>
<cooldownTime>2</cooldownTime>
</li>
</tools>
</li>
<!-- Adding HediffCompProperties_MaxHPAdjust -->
<li Class="EBF.Hediffs.HediffCompProperties_MaxHPAdjust">
<linearAdjustment>40</linearAdjustment>
</li>
<!-- Add complete -->
</comps>
<!-- Omitted code -->
</HediffDef>
Sometimes, I am simply unavailable. And sometimes, some other mod gained enough popularity but I did not notice them. Such is the way of things, but this may result in broken compatibility. This may occur in the form of "EBF Protocol Violation" notices:
[V1024-EBF] Elite Bionics Framework has detected some mods using the unmodified GetMaxHealth() method, which violates the EBF protocol.
The author(s) of the involved mod(s) should adopt the EBF to clarify their intentions.
For now, the unmodified max HP is returned.
The detected mod comes from: [name]
This is mainly due to this mod adding extra information to body parts, so that only having a BodyPartDef
is no longer enough to determine the max HP. You need to pass in a BodyPartRecord
instance, so that EBF may know how to calculate the max HP.
You should differentiate between the following:
EBF.EBFEndpoints::GetMaxHealthWithEBF
or EBF.EBFEndpoints::GetBodyPartMaxHealthWithEBF
)EBF.EBFEndpoints::GetMaxHealthUnmodified
or EBF.EBFEndpoints.GetBodyPartMaxHealthUnmodified
)EBF has provided compatiblity by transpiling various other mods' DLLs via Harmony to use the EBF-compliant methods, but the best way to do this would be to write the correct code at those DLLs instead, so that the intention is the clearest.
In case you want to calculate the current max HP, I will not be providing exact code, but consider the following:
function(BodyPartRecord, Pawn) -> float
return BodyPartRecord->def::GetMaxHealth(Pawn)
Prepare:
EBF is loaded
TargetMethod: [your util function]
bool PreFix(ref float result): (note: use reflection if needed) result = EBFEndpoints.GetMaxHealthWithEBF(BodyPartRecord, Pawn); return false; // skip the original method
This will allow you to read the current max HP value while not triggering the "adopt the EBF protocol" error.