Modding Help Creating custom NPC

Discussion in 'Starbound Modding' started by lerdarim, Oct 26, 2019.

  1. lerdarim

    lerdarim Void-Bound Voyager

    Hello. So i'm into creating a custom npc merchant. I've created a .npctype file, but game crashes on loading with log indicating exception on that file. I guess i have to register my new npc name somewhere akin to new weapon abilities, but i fail to find any file with non-random npc lists at all. Any info on what must be modified to create a custom npc?
     
  2. Zaakari

    Zaakari Pangalactic Porcupine

    Hey,
    Can you post the files that you are working on, so that we can see what you have so far?
     
  3. lerdarim

    lerdarim Void-Bound Voyager

    Was about to post the code, but it struck me with a guess what could be wrong. I was setting "type" variable as "merchant" and game didn't like the fact i had two different merchant types. So basically i replaced that with his name and it works like a charm. Thanks for reply though. I was wondering why nobody ever answers, but i guess i should put in much more info...
     
  4. Zaakari

    Zaakari Pangalactic Porcupine

    Good job figuring it out.
    That, and also not everyone (myself included) checks the forums every hour. So one has to be willing to wait a day or two (though sooner is always nicer).
     
  5. lerdarim

    lerdarim Void-Bound Voyager

    Yea, i know everyone has their own business and in no way i blame anybody for not helping)

    Since this thread exists already tho, i've got a couple new questions about npcs:
    1. How can i force npc to always sit on one place? I mean crouch and not move anywhere. Is there any behaviour like that by default?
    Code:
    "reactions" : {
          "spontaneous" : [
            [1.0, "sit", { "timeRange" : [0.6,0.2]}]
          ]
        },
    
    I have this piece of code i copied and modified, though i don't have a clue what these timeranges mean and, since it's "spontaneous", it's most likely not what i'm looking for. But i couldn't find any list of reactions or behaviours available.

    2. Is it possible to always randomize the dialog message on interact? For example,
    Code:
    "dialog" : {
          "converse" : {
            "default" : {
              "default" : [
                "Howdy",
                "Hello",
                "Hi, <entityname>!"
              ]
            }
          }
        }
    if i spawn npc with such code, he gets random line out of those three and always uses only that one. What's fascinating, if you give him a few different sounds on interact, they are randomized each time.

    3. How can i set one's hair color? Captain Noble's npctype has this
    Code:
        "bodyDirectives" : "?replace=fff8b5=fff8b5?replace=fde03f=fde03f?replace=f6b919=f6b919",
        "hairDirectives" : "?replace=fff8b5=fff8b5?replace=fde03f=fde03f?replace=f6b919=f6b919",
    
    and i'm pretty sure it's tree hex colors, but those are all shades of yellow so i dunno which one in which string controls hair color and even if i set every hex number to 000000 to create a totally pitch black person, he still has the yellow hair...
     
  6. Zaakari

    Zaakari Pangalactic Porcupine

    1. Have you had a look at some of the outpost npc's that don't move? Such as "/ncps/outpost/nuruoutpost.npctype".
    I know they aren't sitting, but they also don't move around.

    3. As I understand it, each "replace" set searches the image in question for pixels matching the colour of the first hexadecimal value ("fff8b5" in this case).
    If a match is found, it is replaced by the second hexadecimal value (which in this case also happens to be "fff8b5").
    So it won't help to replace all of the values with one colour. You will need to replace the second value of each set to be the colours that you want the hair to assume.
     
  7. lerdarim

    lerdarim Void-Bound Voyager

    Tbh didn't know which of em doesn't move. I'll take a look at nuru.

    And yes, i did assume that too about replacement. Tried changing only the second color in each replace, no effect. However, where does it search for that color? Without those lines npc will have random hair, which means that replacement wouldn't work at all. Not mentioning that the Noble's replacements then do nothing, replacing a color by itself.
     
  8. Zaakari

    Zaakari Pangalactic Porcupine

    Okay, I just created a patch file for the "nobleclue.npctype" containing the following:
    Code:
    [
      { "op": "replace",
        "path": "/identity/hairDirectives",
        "value": "?replace=fff8b5=101010?replace=fde03f=101010?replace=f6b919=101010"
      },
      { "op": "replace",
        "path": "/identity/bodyDirectives",
        "value": "?replace=fff8b5=101010?replace=fde03f=101010?replace=f6b919=101010"
      }
    ]
    At first, I only had the "hairDirectives" replacement; and--like you--I also didn't notice any change. However, this is likely because he is wearing a hat, and therefore his hair is not getting drawn.
    The second time, I added the "bodyDirectives" replacement; and he definitely changed colour.

    As for what image the replace directives are using, you can see in his ".npctype" file that his hair is "male20".
    Knowing that he is a novakid, go to the directory "/humanoid/novakid/hair", and you will find the image "male20.png".
    If you inspect this image in an editor, you will find the colours being replaced in the hair directives.

    The reason his default replace directives are using the same colour for source and replacement, is that he is supposed to be yellow (so no need to change anything).
     
  9. lerdarim

    lerdarim Void-Bound Voyager

    Huh, fascinating. Why would they add such a replacement in a first place... I've managed to find my colors though and replace them in npc file, looks exactly how i need. Thanks on this one.

    I have a new problem though. Do you know of any way to play chat sound only on certain events, like with chat bubbles? E.g. when you interact with npc or when you leave his shop. Every npc i looked into just has a bunch of sounds played randomly (that's logical for the game though since they are short and similar) on each dialogue speech. I'm afraid i already know the answer, but maybe is there a way to control their sounds? Or maybe at least reduce the rate at which they talk (sometimes they randomly say a few line almost in a row).
     

Share This Page