It looks like the Curious Case of the Unruly NPC Farmer’s destined for the cold case files. As a quick recap the mystery to be solved was discovering why the NPC farmers on my map had begun planting oilseed radish and poplar which are crops that they should not be planting. The initial investigation looked promising but at this point I’m not convinced it’s fixable, nor is it a game breaking issue, so I decided to set this aside and move on. I’ve been in touch with several map makers and the general consensus was “yeah, we’ve seen it too, but its only missions, not a big deal”.
While the new mission system seemed like a promising idea I soon found missions to be an overly simplistic and typically boring element of game play. This seems to be borne out by a poll I did on PS-SG and some discussions I had with fellow FS17 gamers on a Discord that I’m a member of. Generally the gamers in both groups reported they either didn’t bother with missions any more or just ran a few early game to build up some capital. So this basically left me with two options, release the map with missions enabled but flawed, or release the map with missions disabled.
There are pro’s and con’s to each option. Disabling the mission system would certainly nullify the NPC’s ability to plant crops they shouldn’t be planting and it could be done in such a way that the field would still be owned by the NPC, meaning that the player would still need to purchase the field before it could be worked. Another pro to not enabling missions is that it allows for the creation of more organically shaped (read not square) fields. Though Nagce Valley has its fair share of non-square fields the constraints of the field dimensioning system required for mission’s means you can only get just so creative before you hit the engines limits. Dispensing with missions altogether allows for an unconstrained hand in laying down field shapes, an example of which is Stevie’s Cherry Hills for Alan. It’s somewhat late in the game to be redesigning fields on Nagce Valley though if I do another map I may consider dispensing with missions for just this reason.
The first con to disabling missions that comes to mind is that many players expect them to be there, at least, as previously mentioned, as an early game source of revenue. Keeping missions in game also provide the player a means of reducing the cost of the field prior to purchase. Another pro for keeping missions that’s applicable even for players who choose not to run missions is that they give the map a more dynamic field. Neighboring NPC fields that cycle though the growth stages eventually being replaced by another crop adds a life to the map that empty fields do not. The only negative I can see to keeping the missions enabled is finding a way to communicate to the player the nature of the flaw on this map and how to work around it.
Unless something changes over the next few weeks Nagce Valley will be released with missions enabled if sometimes unplayable. The player will own at least one of the maps three grass fields and the starting equipment will be sufficient to get a nice grass/silage operation up and running to generate cash for those who chose to forgo contract work. For those who chose to run missions they will do so with the knowledge that given average field size on this map missions may prove to be quite lengthy in scope and that on occasion missions on some fields will not be available.
For those who are still interested in the investigation feel free to read on.
The why is most likely connected to the implementation of additional crops through the additionalMapTypes.lua. Initially I believed the errant behavior of the NPC farmers and their complete disregard for the useForFieldJob attribute was unique to may map but after conversing with several other map modders on FSUK and AEM I now believe that this behavior can affect any map in which more than two additional crop types have been added using the addtionalMapTypes.lua.
With the why likely answered it was time to dig into the how to fix part of the problem. The simple solution would be to either pull out the additional crops I added to the map or to reduce the number of additional crops from 5 to 2 (neither of which is going to happen). By default there are enough empty slots in the foliage SubLayers index system to add 2 additional crops. Adding more than two crops requires modifying the densityMapChannelOffset and the numDensityMapChannels attributes of the foliageSubLayer. I’m guessing that modifying these attributes somehow throws off the indexing system the game uses to identify which crops the NPC can plant and which crops it should not plant.
I’m guessing as the mission system is not particularly well documented by Giants and the FruitUtil table that I believe is associated with missions is not visible without using the debug utility to recursively print tables that reside within g_currentMissions. Though Giants has made recursively printing tables a bit easier than it was in the past I was unable to find any documentation on g_currentMissions and how to view any information that is contained within that table. Fortunately akuenzi over on the FSUK forum provided me with a very helpful tutorial on how to access these tables. Rather than post the how to here within the blog I’ll create a tutorial page on this site and add the information there. I’ll try to get that page up in the next week or two
The results of dumping that FruitUtil table were encouraging and I thought we were on the right track.
The table is a summarization of information pulled from several sources. The Fruit Type, FruitUtilIndex, and useForFieldJob fields were pulled from the FruitUtil table after I had dumped it to the console. The densityMapTypeIndex was pulled from the foiliageSublayer section of the map01.i3d. The last two fields, NPC should be able to plant and NPC can plant on Nagce Valley are the observable data of what should be happening on my map and what was actually happening.
The first item of interest is the useForFieldJob attribute which I believe tells the game which crops the NPC can plant and which ones it cannot pant. The same attribute is used to determine which NPC owned fields the NPC can run missions on and which ones it cannot so I makes sense that it would be used to determine crop type availability as well. The problem with this line of reasoning is that the table clearly shows the attribute is marked as false for oilseed radish, poplar, grass, and dry grass meaning that the NPC should not be able to plant the crops, which is not what I’m actually seeing in game.
The second item of interest is the mismatch in index numbers between the FruitTypeIndex and densityMapTypeIndex. I reasoned that if the game matches the useForFieldJob to an index rather than the fruit type by name (which is quite likely) than a mismatch between the two indices could result in the NPC planting crops that is should not be planting and not planting crops that it should. Disregarding the fruit type name for a moment we can see that the NPC should not be planting index 9, 10, 11, or 12.
If we add in the densityMapTypeIndex we can see that 9 and 10 now assume a useForFieldJob value of TRUE. If the index values from the densityMapTypeIndex rather than the FruitUtil index this would allow the NPC to plant oilseed radish and poplar (Grass would still be prohibited but there’s been some discrepancy between sources as to whether or not grass was part of the problem).
It seemed like I was on to a good lead. To validate the assumption I compared my table to the same data fields pulled from Stevie’s Pine Cove. I chose Pine Cove because that map implements the same additional crops as Nagce Valley and as far as I knew the NPC issue was not affecting Pine Cove. This only led to more confusion as Pine Cove had nearly the same index mismatches as Nagce Valley. Through additional testing and some communication with Stevie I discovered that the issue does in fact affect Pine Cove as well.
I thought that reordering the densityMapTypeIndex so that the indices for oilseed radish and poplar matched the FruitUtil index for those crop might be a possible solution (I was unwilling to mess with grass as that would have impacted quite a lot of work that had already been done on the map). Unfortunately this was not the case and the NPC continued to plant oilseed radish and poplar.
And that’s as far as the investigation went.