Traders - Freefolk-Rimworld-Modding/FF-Simple-Ammunition-Remastered-2.0 GitHub Wiki
Patching traders is straight forward.
<Operation Class="PatchOperationAdd">
<xpath>Defs/TraderKindDef[defName="Base_Neolithic_Standard"]/stockGenerators</xpath>
<value>
<li Class="StockGenerator_SingleDef">
<thingDef>FF_Ammunition_Primitive</thingDef>
<countRange>300~500</countRange>
</li>
</value>
</Operation>
This is untested, it should add ammo to every trader that sells neolithic weapons.
<Operation Class="PatchOperationAdd">
<xpath>Defs/TraderKindDef/stockGenerators/li[@Class="StockGenerator_WeaponsRanged" and maxTechLevelGenerate="Neolithic"]/..</xpath>
<value>
<li Class="StockGenerator_SingleDef">
<thingDef>FF_Ammunition_Primitive</thingDef>
<countRange>300~500</countRange>
</li>
</value>
</Operation>
This one adds ammo to any trader with Combat in their defName.
<Operation Class="PatchOperationAdd">
<xpath>Defs/TraderKindDef/defName[contains(text(), "Combat") or contains(text(), "combat")]/../stockGenerators</xpath>
<value>
<li Class="StockGenerator_SingleDef">
<thingDef>FF_Ammunition_Primitive</thingDef>
<countRange>300~500</countRange>
</li>
</value>
</Operation>
These are not great examples, I'm still thinking of the best way to do this.
Todo
<Operation Class="XmlExtensions.ForEach">
<xpath>Defs/</xpath>
<storeIn></storeIn>
<prefixLength></prefixLength>
<apply>
<Operation Class="XmlExtensions.CreateVariable">
<storeIn></storeIn>
<value></value>
<value2></value2>
<fromXml>true</fromXml>
<defaultValue></defaultValue>
<operation></operation>
<apply>
<Operation Class="PatchOperationAdd">
<xpath></xpath>
<value>
</value>
</Operation>
</apply>
</Operation>
</apply>
</Operation>