Force traders carry some items?

Started by AnotherFireFox, July 23, 2018, 06:00:05 AM

Previous topic - Next topic

AnotherFireFox

Like potato seeds from Seeds Please, something you'll be in a deep trouble without...

PleccyMM

There are three factors that caravans will check before an item gets added to its pack. These are:

  • Price
  • Tech level
  • Commonality
Each of these are defined in the code in different ways and I'm going to teach you how to add them and what they do. Firstly price is determined under the statBases section under MarketValue, each trade ship/caravan generates with a set amount of silver and will work out how to spend this silver on the resources available to it - naturally the huge futuristic spaceships will have more money than the tribal caravans. Generally the game will pick at random which items it takes and which it leaves unless the generateCommonality tag is specified. By default this is set to 1 and as such doesn't regularly appear in a lot of the itemDefs but when it is present and set above 1 it will cause the game to priorities buying the item over others. Probably the best example of this is the power helmet; its generateCommonality is set to 2 meaning that if possible a caravan is likely to stock it over a normal helmet, which has a generateCommonality of 1. Finally, we have techLevel. This tag, alongside the factionPrerequisiteTags tag, will clarify which traders should be carrying the item, example: if you set the techLevel to Spacer it won't spawn with tribal caravans and instead only on trade ships and occasionally caravans from more advanced factions. All this combined tells every caravan what it should stock, if it can stock and what to priorities stocking.

Everything I said above is all well and good if you are looking to create your own item however you seem to want to modify an already existing mod. To do this you'll need to take the info I've just taught you, most importantly the generateCommonality part, and create a patch for the Seeds Please mod. What you'll need to do is set the generateCommonality part up by more than 1 for it to hopefully appear more commonly within caravans. If you need help with how to patch already existing code might I suggest checking This and This as they are both excellent tutorials on how to properly patch. If you need any more help let me know - PleccyMM

AnotherFireFox

Quote from: PleccyMM on July 23, 2018, 02:28:58 PM
There are three factors that caravans will check before an item gets added to its pack. These are:

  • Price
  • Tech level
  • Commonality
Each of these are defined in the code in different ways and I'm going to teach you how to add them and what they do. Firstly price is determined under the statBases section under MarketValue, each trade ship/caravan generates with a set amount of silver and will work out how to spend this silver on the resources available to it - naturally the huge futuristic spaceships will have more money than the tribal caravans. Generally the game will pick at random which items it takes and which it leaves unless the generateCommonality tag is specified. By default this is set to 1 and as such doesn't regularly appear in a lot of the itemDefs but when it is present and set above 1 it will cause the game to priorities buying the item over others. Probably the best example of this is the power helmet; its generateCommonality is set to 2 meaning that if possible a caravan is likely to stock it over a normal helmet, which has a generateCommonality of 1. Finally, we have techLevel. This tag, alongside the factionPrerequisiteTags tag, will clarify which traders should be carrying the item, example: if you set the techLevel to Spacer it won't spawn with tribal caravans and instead only on trade ships and occasionally caravans from more advanced factions. All this combined tells every caravan what it should stock, if it can stock and what to priorities stocking.

Everything I said above is all well and good if you are looking to create your own item however you seem to want to modify an already existing mod. To do this you'll need to take the info I've just taught you, most importantly the generateCommonality part, and create a patch for the Seeds Please mod. What you'll need to do is set the generateCommonality part up by more than 1 for it to hopefully appear more commonly within caravans. If you need help with how to patch already existing code might I suggest checking This and This as they are both excellent tutorials on how to properly patch. If you need any more help let me know - PleccyMM

Thanks, Comonnality was what I was looking for!