ThinkTree and DutyDefs - Freefolk-Rimworld-Modding/FF-Simple-Ammunition-Remastered-2.0 GitHub Wiki
This section is less of a guide and more research notes, and as improvements are made we'll update this section. In order to avoid spamming the Think Tree any changes here should be applied to the VEF itself, if multiple mods are trying to adjust how this part works it will likely make a mess.
- Reloading.JobDriver_ReloadFromInventory - Makes a pawn check their inventory to reload.
- Reloading.JobDriver_Reload - Same as above but for the ground, mainly for colonists to use stockpiles but can make NPC scavenge too.
- Reloading.JobDriver_Unload - This shouldn't need to be added anywhere, it should only be called when the player orders a pawn to.
There's a lot in the Think Tree, but these are the important parts.
Data/Core/Defs/ThinkTreeDefs/Humanlike.xml
- Line 79 Humanlike_PostMentalState Insertion hook
- Line 110 LordDuty
- Line 117 Humanlike_PostDuty Insertion hook
- Line 334 Humanlike_PreMain Insertion hook
- Line 341 MainColonistBehaviorCore
- Line 359 Humanlike_PostMain Insertion hook
This def uses the PreMain insertion hook to precede MainColonistBehaviorCore.
<ThinkTreeDef>
<defName>Reloading_AmmoReload_Colony</defName>
<insertTag>Humanlike_PreMain</insertTag>
<insertPriority>100</insertPriority>
<thinkRoot Class="ThinkNode_Priority">
<subNodes>
<li Class="ThinkNode_ConditionalColonist">
<subNodes>
<li Class="Reloading.JobGiver_ReloadFromInventory" />
</subNodes>
</li>
</subNodes>
</thinkRoot>
</ThinkTreeDef>
This is added with the vanilla Reload so colonists aren't running back for ammo constantly. ReloadFromInventory was here but it didn't have high enough priority causing colonists to try to eat, sleep, or use the toilet before trying to reload so it was moved to PreMain.
<Operation Class="PatchOperationInsert">
<xpath>/Defs/ThinkTreeDef[defName="MainColonistBehaviorCore"]/thinkRoot/subNodes/li/subNodes/li[@Class="JobGiver_Reload"]</xpath>
<value>
<li Class="Reloading.JobGiver_Reload" />
</value>
</Operation>
This is the current patch in the VEF.
<Operation Class="PatchOperationInsert">
<order>Prepend</order>
<xpath>/Defs/DutyDef/thinkNode/subNodes/li[@Class="JobGiver_AIFightEnemies"]</xpath>
<value>
<li Class="Reloading.JobGiver_ReloadFromInventory" />
</value>
</Operation>
This is an experimental patch that needs more testing, it expands NPC support.
<Operation Class="PatchOperationInsert">
<order>Prepend</order>
<xpath>Defs/DutyDef/thinkNode/subNodes/li[@Class="JobGiver_AIDefendPoint" or @Class="JobGiver_AIDefendEscortee" or @Class="JobGiver_AIDefendSelf" or @Class="JobGiver_AIFightEnemies"]] | Defs/DutyDef/thinkNode/subNodes/li/subNodes/li[@Class="JobGiver_AIDefendPoint" or @Class="JobGiver_AIDefendEscortee" or @Class="JobGiver_AIDefendSelf" or @Class="JobGiver_AIFightEnemies"] | Defs/DutyDef/thinkNode/subNodes/li/subNodes/li/subNodes/li[@Class="JobGiver_AIDefendPoint" or @Class="JobGiver_AIDefendEscortee" or @Class="JobGiver_AIDefendSelf" or @Class="JobGiver_AIFightEnemies"]</xpath>
<value>
<li Class="Reloading.JobGiver_ReloadFromInventory" />
</value>
</Operation>
Copy of above patch, but adds JobGiver_Reload so NPCs will scavenge for ammo. Can be offered through an toggleable patch
<Operation Class="PatchOperationInsert">
<order>Prepend</order>
<xpath>Defs/DutyDef/thinkNode/subNodes/li[@Class="JobGiver_AIDefendPoint" or @Class="JobGiver_AIDefendEscortee" or @Class="JobGiver_AIDefendSelf" or @Class="JobGiver_AIFightEnemies"]] | Defs/DutyDef/thinkNode/subNodes/li/subNodes/li[@Class="JobGiver_AIDefendPoint" or @Class="JobGiver_AIDefendEscortee" or @Class="JobGiver_AIDefendSelf" or @Class="JobGiver_AIFightEnemies"] | Defs/DutyDef/thinkNode/subNodes/li/subNodes/li/subNodes/li[@Class="JobGiver_AIDefendPoint" or @Class="JobGiver_AIDefendEscortee" or @Class="JobGiver_AIDefendSelf" or @Class="JobGiver_AIFightEnemies"]</xpath>
<value>
<li Class="Reloading.JobGiver_Reload" />
</value>
</Operation>
Depending on how a mod works it may need extra duties patched, so far SmurfeRim is the only example and the full patch can be found here. Since multiple mods may need to do this adjustment it will likely be merged into the VEF to avoid spam.
<Operation Class="PatchOperationInsert">
<xpath>Defs/DutyDef/thinkNode/subNodes/li[@Class="JobGiver_SmurfVillageDefense"]</xpath>
<order>Append</order>
<value>
<li Class="Reloading.JobGiver_Reload" />
</value>
</Operation>