Help With NPC Hapiness

RoboBro🌳

Skeletron
Does anyone know how to add happiness dialogue?

1660186178232.png


If anyone knows how to, can you put a snippet/tell me what to write to add it?

Thanks!
 
Dialogs is handled by the localization file

You will have to create a en-US.hjson file like this one: tModLoader/en-US.hjson at 1.4 · tModLoader/tModLoader
You don't need ALL that code (mostly delete almost all of it) but look at lines 124 and downwards. You'll need something like this.
 
Also do you know how to add unique dialogue for each liked/disliked biome and npc?
C#:
    public class SomeNPC : ModNPC
    {

        public override void SetStaticDefaults()
        {
            // Your code
            //...
            //...
            // happiness
            NPC.Happiness
                .SetBiomeAffection<ForestBiome>(AffectionLevel.Like) // prefers the forest.
                .SetBiomeAffection<SnowBiome>(AffectionLevel.Dislike) // dislikes the snow.
                .SetBiomeAffection<ExampleSurfaceBiome>(AffectionLevel.Love) // likes the Example Surface Biome
                .SetNPCAffection(NPCID.Dryad, AffectionLevel.Love) // Loves living near the dryad.
                .SetNPCAffection(NPCID.Guide, AffectionLevel.Like) // Likes living near the guide.
                .SetNPCAffection(NPCID.Merchant, AffectionLevel.Dislike) // Dislikes living near the merchant.
                .SetNPCAffection(NPCID.Demolitionist, AffectionLevel.Hate); // Hates living near the demolitionist. // < Mind the semicolon!
        }
And the text can be configured in the localization file, as I showed above
2.
View attachment 379931
I've created the .hjson file, but how would I do it with code like this?
Unfortunately, happiness dialogs can only be added using the method I showed
 
C#:
    public class SomeNPC : ModNPC
    {

        public override void SetStaticDefaults()
        {
            // Your code
            //...
            //...
            // happiness
            NPC.Happiness
                .SetBiomeAffection<ForestBiome>(AffectionLevel.Like) // prefers the forest.
                .SetBiomeAffection<SnowBiome>(AffectionLevel.Dislike) // dislikes the snow.
                .SetBiomeAffection<ExampleSurfaceBiome>(AffectionLevel.Love) // likes the Example Surface Biome
                .SetNPCAffection(NPCID.Dryad, AffectionLevel.Love) // Loves living near the dryad.
                .SetNPCAffection(NPCID.Guide, AffectionLevel.Like) // Likes living near the guide.
                .SetNPCAffection(NPCID.Merchant, AffectionLevel.Dislike) // Dislikes living near the merchant.
                .SetNPCAffection(NPCID.Demolitionist, AffectionLevel.Hate); // Hates living near the demolitionist. // < Mind the semicolon!
        }
And the text can be configured in the localization file, as I showed above
2.

Unfortunately, happiness dialogs can only be added using the method I showed
i fixed it. now im updating their shops and adding a new npc
 
me confused :(
 
Last edited:
Back
Top Bottom