Changes

wikify
Line 1: Line 1: −
<pre>
+
← [[Modding:Index|Index]]
---
  −
layout: default
  −
title: NPC gift tastes
  −
intro: >
  −
    This page explains how the game calculates NPC gift tastes. This is an advanced guide for mod
  −
    developers.
  −
permalink: /for-devs/npc-gift-tastes
  −
redirect_from:
  −
    - /guides/npc-gift-tastes
  −
---
     −
## Reading the raw data
+
This page explains how the game calculates NPC gift tastes. This is an advanced guide for mod developers.
   −
### Source
+
==Data==
NPC gift tastes are stored in `Content\Data\NPCGiftTastes.xnb`, which can be
+
===Raw data===
[unpacked using XNB Extract](creating-an-xnb-mod#unpacking). Here's the raw data (as of 1.1.1) for
+
NPC gift tastes are stored in <tt>Content\Data\NPCGiftTastes.xnb</tt>, which can be [[Modding:Creating an XNB mod#unpacking|unpacked using XNB Extract]]. Here's the raw data (as of 1.1.1) for reference:
reference:
     −
```yaml
+
<source lang="yaml">
 
content:  #!Dictionary<String,String>
 
content:  #!Dictionary<String,String>
 
     Universal_Love: "74 446" #!String
 
     Universal_Love: "74 446" #!String
Line 58: Line 47:  
     Willy: " This is great! If only me ol' Pappy was around. He'd go nuts for this./72 143 149 154 276 337 698 459/This looks great. Thank you!/66 336 340 699 707 198 202 209 212 213 214 219 225 727 730 728 732/Hmmm... You like stuff like this? Huh./-7 -81 2 4 330/... *sniff*... Well I guess I can toss it into the chum bucket.//A gift! Thanks./-4 227 228 242/ " #!String
 
     Willy: " This is great! If only me ol' Pappy was around. He'd go nuts for this./72 143 149 154 276 337 698 459/This looks great. Thank you!/66 336 340 699 707 198 202 209 212 213 214 219 225 727 730 728 732/Hmmm... You like stuff like this? Huh./-7 -81 2 4 330/... *sniff*... Well I guess I can toss it into the chum bucket.//A gift! Thanks./-4 227 228 242/ " #!String
 
     Krobus: " This is an amazing gift. For my people it is a great honor to receive something like this./72 16 276 337 305 308/Thank you very much./66 336 340/Humans have... interesting tastes./-7 -81 2 330/Oh... Um. I guess I'll accept it.//Thank you.// " #!String
 
     Krobus: " This is an amazing gift. For my people it is a great honor to receive something like this./72 16 276 337 305 308/Thank you very much./66 336 340/Humans have... interesting tastes./-7 -81 2 330/Oh... Um. I guess I'll accept it.//Thank you.// " #!String
```
+
</source>
   −
### Format
+
===Format===
This contains two types of data:
+
The file contains two types of data:
   −
* _Universal tastes_ apply to all villagers. Their key is `Universal_{taste}`, and their value
+
<ul>
  is a space-delimited array of reference IDs (item ID if ≥0, category ID is <0). For example,
+
<li>''Universal tastes'' apply to all villagers. Their key is <tt>Universal_{taste}</tt>, and their value is a space-delimited array of reference IDs (item ID if ≥0, category ID is <0). For example, consider this entry:
  consider this entry:
     −
  ```yaml
+
<source lang="yaml">
  Universal_Like: "-2 -7 -26 -75 -80 72 395 613 634 635 636 637 638 724 459"
+
Universal_Like: "-2 -7 -26 -75 -80 72 395 613 634 635 636 637 638 724 459"
  ```
+
</source>
   −
  This data means villagers should have a universal like for category -2, item 72, etc.
+
This data means villagers should have a universal like for category -2, item 72, etc.</li>
   −
* _Personal tastes_ apply to a specific villager. Their key is the villager's internal name (like
+
<li>''Personal tastes'' apply to a specific villager. Their key is the villager's internal name (like <tt>Abigail</tt>), and their value alternates dialogue text with a list of reference IDs in this order: love, like, dislike, hate, and neutral. For example, consider Abigail's gift tastes:
  `Abigail`), and their value alternates dialogue text with a list of reference IDs in this order:
  −
  love, like, dislike, hate, and neutral. For example, consider Abigail's gift tastes:
     −
  ```yaml
+
<source lang="yaml">
 
   Abigail: " I seriously love this! You're the best, @!/66 128 220 226 276 611/Hey, how'd you know I was hungry? This looks delicious!//What am I supposed to do with this?/-5 -75 -79 16 245 246/What were you thinking? This is awful!/330/You brought me a present? Thanks.// "
 
   Abigail: " I seriously love this! You're the best, @!/66 128 220 226 276 611/Hey, how'd you know I was hungry? This looks delicious!//What am I supposed to do with this?/-5 -75 -79 16 245 246/What were you thinking? This is awful!/330/You brought me a present? Thanks.// "
  ```
+
</source>
   −
  By splitting the string with `/` as the delimiter, we can extract this data:
+
By splitting the string with <tt>/</tt> as the delimiter, we can extract this data:
   −
    index | taste   | reaction dialogue                                       | reference IDs
+
{| class="wikitable"
  :----- |:------- |:------------------------------------------------------- |:----------------------
+
|-
    0, 1 | love   | I seriously love this! You're the best, @!             | 66 128 220 226 276 611
+
! index
    2, 3 | like   | Hey, how'd you know I was hungry? This looks delicious! | _none_
+
! taste
    4, 5 | dislike | What am I supposed to do with this?                     | -5 -75 -79 16 245 246  
+
! reaction dialogue
    6, 7 | hate   | What were you thinking? This is awful!                 | 330
+
! reference IDs
    8, 9 | neutral | You brought me a present? Thanks.                       | _none_
+
|-
 +
| 0, 1
 +
| love
 +
| I seriously love this! You're the best, @!
 +
| 66 128 220 226 276 611
 +
|-
 +
| 2, 3
 +
| like
 +
| Hey, how'd you know I was hungry? This looks delicious!
 +
| ''none''
 +
|-
 +
| 4, 5
 +
| dislike
 +
| What am I supposed to do with this?
 +
| -5 -75 -79 16 245 246
 +
|-
 +
| 6, 7
 +
| hate
 +
| What were you thinking? This is awful!
 +
| 330
 +
|-
 +
| 8, 9
 +
| neutral
 +
| You brought me a present? Thanks.
 +
| ''none''
 +
|}
   −
  This data means she should personally love item 66, dislikes category -5, etc.
+
This data means she should personally love item 66, dislikes category -5, etc.</li>
 +
</ul>
   −
## How a gift taste is determined
+
==How a gift taste is determined==
 
The data format allows tastes to conflict in multiple ways:
 
The data format allows tastes to conflict in multiple ways:
   Line 101: Line 113:  
* and any combination of the above (e.g. between a universal item ID and personal category ID).
 
* and any combination of the above (e.g. between a universal item ID and personal category ID).
   −
The game uses a rather complicated algorithm to determine how much an NPC likes an gift (see
+
The game uses a rather complicated algorithm to determine how much an NPC likes an gift (see <tt>NPC::getGiftTasteForThisItem</tt>). Here's a cleaned up version of the algorithm in pseudocode:
`NPC::getGiftTasteForThisItem`). Here's a cleaned up version of the algorithm in pseudocode:
     −
```
+
<pre>
 
var TASTE = neutral
 
var TASTE = neutral
 
bool HAS_UNIVERSAL_ID = false
 
bool HAS_UNIVERSAL_ID = false
Line 158: Line 169:  
// part V: return taste if not overridden
 
// part V: return taste if not overridden
 
return TASTE
 
return TASTE
```
   
</pre>
 
</pre>
    
[[Category:Modding]]
 
[[Category:Modding]]
translators
8,437

edits