Modding Help Add specific skin color, hair color, hair type, stance, personality, and items to an NPC?

Discussion in 'Starbound Modding' started by Uacher, Jul 10, 2017.

  1. Uacher

    Uacher Scruffy Nerf-Herder

    I've been working on a mod to add some unique NPCs spread throughout the game. However, I want them to wear specific attributes to make them consistent.

    How would I have to write the code in the .npctype file to force the spawned NPC use skin color, hair color, etc. that I specify?
     
  2. Sparklink

    Sparklink Ketchup Robot

    There are three ways to do this;
    1. When building your dungeon with the NPC in it you specify a seed so that the character always spawns the same way,
    2. Or you could specify what the NPC's features are in the NPC file

    "identity" : {
    "name" : "George",
    "gender" : "male",
    "hairGroup" : "hair",
    "hairType" : "male54",
    "bodyDirectives" : "?replace=ffe2c5FF=fff7ecFF?replace=ffc181FF=f9d3a9FF?replace=d39c6cFF=d3a57cFF?replace=c7815bFF=b37c5dFF",
    "emoteDirectives" : "?replace=ffe2c5FF=fff7ecFF?replace=ffc181FF=f9d3a9FF?replace=d39c6cFF=d3a57cFF?replace=c7815bFF=b37c5dFF",
    "hairDirectives" : "?replace=d9c189FF=7f5a39FF?replace=a38d59FF=5b3523FF?replace=735e3aFF=3b1f15FF"
    }

    This is an example from the NPC George who shows up at the outpost some times.

    3.You could design something like the Ester, Nuru, or the Baron if you wanted some especially unique NPCs
     
    Uacher and IHart like this.
  3. IHart

    IHart Scruffy Nerf-Herder

    Use the second solution. Seeds will be affected by modded hairs and color values.
     
  4. Uacher

    Uacher Scruffy Nerf-Herder

    The second method worked for me, but I do have a bit of a doubt: I also want the custom NPCs to have a specific personality, but I can't seem to be placing the line of code correctly. Would you happen to know where I should put the line that specifies the NPC's personality?
     
  5. Sparklink

    Sparklink Ketchup Robot

    The parameters can be placed pretty much in any order on that line. This is the parameters that need to be placed to get specific poses.
    "personalityIdle" : "idle.2",
    "personalityArmIdle" : "idle.2"
    These specify how the NPC stands when it is not moving. The parameters call upon the frames of the body and the arms respectively, so it will help to use the frames file of a humanoid as a reference. With this you can call upon any frame used in a species animation; you could even make it look like an NPC is stuck in a swim pose with his arms flying in the air. You could create an NPC with a unique pose that is not seen in game.
     
    IHart and Uacher like this.
  6. Uacher

    Uacher Scruffy Nerf-Herder

    I figured that one out after some experimenting as well, but what I mean is the way the NPC behaves to its surroundings and other NPCs. I want to give an NPC the anxious personality, for example.
     
    Last edited: Jul 12, 2017
  7. cpeosphoros

    cpeosphoros Orbital Explorer

    Hmm. I think you'd want to create a .npctype file with the anxious personality and attribute it to your npc. There seems to be no API call to set that via script, so you would have to do that at the NPC creation time.
     
  8. Uacher

    Uacher Scruffy Nerf-Herder

    I managed to get it to work, also discovered that you can actually make custom personalities by overwriting reactions with the probability of happening. However, I'm having trouble trying to figure out the actual percentage of certain reactions happening.

    For example: I can make a personality react to somebody vomiting by running way or getting annoyed or laughing. I understand that the number that goes before each reaction is the chance of the reaction triggering (1.0 being 100%). Keeping this in mind, putting all three reactions at 1.0 would split the chance of triggering to about 33%, but beyond that, I just can't figure out these percentages with 1.0s.
     
  9. katana

    katana Scruffy Nerf-Herder

    Best not to think of it like percentages, but rather as ratios.
     
  10. cpeosphoros

    cpeosphoros Orbital Explorer

    Yes, all pools which have weights work like that.

    Example, suppose a pool like this:
    • a - 3
    • b - 5
    • c - 1
    3 + 5 + 1 = 9, so a will have a 3/9 chance of happening, b a 5/9 chance and c a 1/9 chance. To get it as percentages, just execute the fractions: 33.33...% + 55.55...% + 11.11...% = 99.99...% = 100%.
     

Share This Page