RimWorld

RimWorld

Survival Tools Reborn
Lecris  [developer] Apr 11, 2020 @ 4:39am
Guide: Add Survival Tool usage to a modded job
If you find a job that does not correctly utilizes the survival tools (doesn't scale with the tool speed or does not degrade the tool), let us know so that we include the patch for everyone.

The structure of jobs in Rimworld is as follows:
  • The JobDriver is in principle the most basic action a pawn makes: it performs the job at each tick.
  • The WorkGiver is the abstract work that the player controls: it is enabled/disabled by the player and it decides what series of jobs to perform (e.g. Go to object, cut blocking tree, haul material, build frame).

The structure of the autopatch implemented in this mod that should patch all JobDrivers and WorkGivers to use Survival Tools is as follows:
  1. Search through all JobDrivers: if an unpatched stat is found (e.g. construction speed) change it to the tool equivalent (ConstructionSpeed_Tool) according to the rules in StatPatch.xml (or equivalent patch files). Add Tool_Degrade functionality if applicable
  2. Make a list of all JobDefs that call these JobDrivers: intermediate step, not important here.
  3. Search through all WorkGivers: if a WorkGiver calls one of the JobDefs above, patch it so it toggles the need for tools and other higher level AI decisions.

You can check for yourself what the autopatch has done in the gamelog: Search for " [jelly.survivaltoolsreborn] Stats auto patched: ". You should find a somewhat structured log of the process above. Exactly what they mean can be searched for in the source code.

The structure of the XML that decides how to patch these jobs is as follows:
<SurvivalTools.StatPatchDef> <defName>Name_For_Others_To_Patch</defName> <!--Stats that need patching--> <oldStat>ConstructionSpeed</oldStat> <newStat>ConstructionSpeed_Tool</newStat> <!--Should Tool_Degrade junction be added?--> <addToolDegrade>true/false</addToolDegrade> <!--Search all JobDrivers, which to be included, which to be excluded--> <patchAllJobDrivers>true/false</patchAllJobDrivers> <JobDriverList> <li>JobDriver_To_Patch</li> </JobDriverList> <JobDriverExemption> <li>JobDriver_To_Ignore</li> </JobDriverExemption> <!--If not necessarily a JobDriver, but still needs patching--> <OtherTypes> <li>JobDriver_To_Patch</li> </OtherTypes> <!--Search all WorkGivers with Exception, or directly patch from a list--> <patchAllWorkGivers>true/false</patchAllWorkGivers> <WorkGiverList> <li>JobDriver_To_Patch</li> </WorkGiverList> <WorkGiverExemption> <li>WorkGiver_To_Ignore</li> </WorkGiverExemption> </SurvivalTools.StatPatchDef>
Last edited by Lecris; Apr 11, 2020 @ 4:42am