Adding items to NPC:s gift tastes

Quirinea

Farmer
I have a mod (made for 1.5) that adds new craftables (Distillery) and made lists for each for gift tastes, like this: (this list has NPC:s for a number of people from other mods, especially RSV)

"GiftTastes": {
"Love": ["George", "Pam", "Lenny", "Ezekiel", "Juliet"],
"Like": ["Clint", "Gus", "Harvey", "Kent", "Shane", "Lewis", "Linus", "Marnie", "Pierre", "Sandy", "Wizard", "Freddie", "PickledPete", "Lola", "Richard", "Jio", "Jessie"],
"Dislike": ["Krobus", "Dwarf", "Abigail", "Alex", "Caroline", "Demetrius", "Emily", "Evelyn", "Haley", "Elliott", "Leah", "Robin", "Maru", "Hekate", "Hephaestus", "Olga", "Bert", "Corine", "Ian", "Jeric", "Kenneth", "Pika", "Shiro"],
"Hate": ["Jas", "Jodi", "Penny", "Sebastian", "Sam", "Vincent", "Philip", "Aguar", "Alissa", "Flor", "Keahi", "Kiwi", "Maddie", "Trinnie", "Ysabelle", "Yuuma", "Leo"]
},

Now it seems this list wont have effect. I'm testing my mod, and so far it seems to be otherwise working.
Is there a simple way to fix this, or do I have to make it the other way round, redefining the gift tastes of every and each NPC and their cat?
 

Dyanosis

Tiller
Gift tastes, as far as I'm aware, are now defined in the JSON as TextOperations. The link I shared is to the Content Patcher wiki talking about how to edit an NPC's Gift Tastes.

I agree that it'd be so nice to be able to do it the way it was done pre-1.6, but such is life.
 

Dyanosis

Tiller
It is slightly tedious to change everything over, but you only have to do it once... or more than once, depending on how many items need it.
 

Quirinea

Farmer
Gift tastes, as far as I'm aware, are now defined in the JSON as TextOperations. The link I shared is to the Content Patcher wiki talking about how to edit an NPC's Gift Tastes.

I agree that it'd be so nice to be able to do it the way it was done pre-1.6, but such is life.
Thank you! Now I only need to find (or remember) how that is done with item names instead of numbers (that the items added through Json Assets don't have) -- I think I've needed that for making Pam ask for kvass instead of ale from the Teatotaller farmer.

(yeah, sigh -- there are some two dozens of new items; though it of course doesn't mean [number of items] time [number of villagers] new code lines -- looks like I have to make a spreadsheet... to keep count)
 

Dyanosis

Tiller
I'm not sure that you can do that with names. Pretty sure that adding Gift Tastes requires the IDs of the items. And, technically, Json Asset Items do have IDs, you'd just have to know how Json Assets generated them.

Though truthfully, your mod could be just CP and not use Json Assets. Everything Json Assets does can be done with CP now. So then you can define your own IDs and know for sure what to use.

Also, it'd be pretty easy, if you had a way to provide the items and their Gift Tastes, to write a script (a Python script, in this case) to convert the Gift Tastes from the old style to the new style. I've got something that works for converting JA (Json Assets) to CP and it converts the Gift Tastes perfectly.
 

Quirinea

Farmer
Hmmm. I remember designing an item without Json Assets, a long time ago, giving it an ID and a spot in the file. Came an update. And to my astonishment the GI palm trees dropped ugly anchovy sandwiches instead of golden coconuts... Took me some time to find out why (and redesign my mod with JA instead...)

And now I cannot find an example of how to add an item to NPC:s personal gift tastes... The examples give only an example of "Universal" which doesn't help at all (and there's no indication whether even the structure of the file is still the same -- it actually is horrible, not meant for human eyes, fields separated by slashes with nothing to identify...).

Edit: I can do it with names... I was able to make Aged Bourbon Whiskey as an universal love... (could you give me an example of adding a personal gift taste?)
(and it's almost 11 PM here so I'd better stop hitting my head into wall for today)

Edit2: Found an example I could use as a model and got it working. As I guessed the file structure is still horrible...
 
Last edited:

Dyanosis

Tiller
Hmmm. I remember designing an item without Json Assets, a long time ago, giving it an ID and a spot in the file. Came an update. And to my astonishment the GI palm trees dropped ugly anchovy sandwiches instead of golden coconuts... Took me some time to find out why (and redesign my mod with JA instead...)

And now I cannot find an example of how to add an item to NPC:s personal gift tastes... The examples give only an example of "Universal" which doesn't help at all (and there's no indication whether even the structure of the file is still the same -- it actually is horrible, not meant for human eyes, fields separated by slashes with nothing to identify...).

Edit: I can do it with names... I was able to make Aged Bourbon Whiskey as an universal love... (could you give me an example of adding a personal gift taste?)
(and it's almost 11 PM here so I'd better stop hitting my head into wall for today)

Edit2: Found an example I could use as a model and got it working. As I guessed the file structure is still horrible...
Sorry for the wait, just now seeing your reply.

Here's an example of how to add a personal Gift Taste (in this example, we're saying that Abigail loves a modded dish called Jalapeno Poppers):

JSON:
{
    "Action": "EditData",
    "Target": "Data/NPCGiftTastes",
        "TextOperations": [
            {
                "Operation": "Append",
                "Target": ["Fields", "Abigail", "1"],
                "Value": "{{ModId}}_JalapenoPoppers",
                "Delimiter": " "
            }
        ]
}
This snippet goes inside the the Changes section of your JSON. The values, as weird as it sounds, are:
  • 0 or 1 - Love
  • 2 or 3 - Like
  • 4 or 5 - Dislike
  • 6 or 7 - Hate
  • 8 or 9 - Neutral
The weird part is that it's not linear (with Neutral in the middle). I usually just do odd numbers.

For the Operation, you'll want to almost always use Append, otherwise you could end up causing issues with other mods, if they load before yours.
For the Target, you have to use the NPCs name, not their ID. So if you wanted to modify a modded NPC, you'd use their name (aka the thing you'll see in game).
For the Value, you have to use the Item's ID, not it's name. So when I referred to name earlier, I meant you can't reference an item by its name (as in what you'll see in game).
For the Delimiter, you put however you're separating your Value. This is only necessary if you have multiple values that you're going to be updating at the same time (like if you had 3 items that you wanted to add to someone's love category). It's telling SDV how to separate and interpret the values.
 

Quirinea

Farmer
OK. Yeah I found that the ID can be a string, doesn't need to be a number. Anyway, I have done the objects with JA and it seems easiest to let that be (I noticed how they were referred to in SMAPI console during game load, and -- lo and behold -- it worked).

Now I'm just wondering what is the trick to get an NPC to have an unique dialogue for certain gift (maybe I just have a silly typo and I am blind to my code). I had changed Kent's "loved gift" comment as the "My mom used to give this to me when I was a kid" (or something like that) fitted very badly with whiskey... If I just get how that's done, I could make some other tweaks. Like Pierre commenting on giving aged whiskey to Governor, or Pam expressing a special reaction to strong stuff...
 

Quirinea

Farmer
Maybe @Pathoschild could help?

I've tried all possible combinations (and some impossible) to get an unique gift response to a non-vanilla item, but no success. And searched for mods that might give me an example case.

The code snippet (with my last desperate attempt) is here:
{
"Action": "EditData",
"Target": "Characters/Dialogue/Kent",
"Entries": {
"AcceptGift_(0){{ModId}}_Wermut" :
// "AcceptGift_category_fish" :
"{{i18n: Quirinea.KentLove}}"
}
},

How should I present the added item? I got gift tastes working and there those are like "Quirinea.JADistillery_Wermut" which works, Walk to the Desert uses {{ModId}}_Item.
As I tested with the second line and gave Kent a fish, he answered with the correct line, so the module structure should be correct.

(or is it possible to give items a new category and use that? Type "category_booze" in this case. Even that would work better)

Edit: This is really peculiar. I found a mod that did add unique dialogue for non-vanilla items, and the format above is copied from there. Not working. Neither does
"AcceptGift_(0)Quirinea.JADIstillery_Wermut", were the item id is the one I've used in the actual gift tastes. It works there.
 
Last edited:

Quirinea

Farmer
Now it's getting curiouser and curiouser. I tested with a vanilla item -- coconut
(AcceptGift_(0)88).
Result: standard response. So this is getting more mystic... Maybe I do still one attempt, copying directly the example given in the Wiki.
Edit: I copied directly the example case: AcceptGift_(O)128
OUCH! Now i see it, as I really copied it with copypaste. It was an O (uppercase o) not number 0 (zero).

And more tricky and puzzling little things: extra carriage returns or something seem to make it haywire, too. I tested by commenting out lines, and only when I picked the last it worked. Hope this helps someone trying to navigate the same path through dead marshes...
 
Last edited:
Top