Modding Help How can I add more clothing variety to a type of NPC?

Discussion in 'Starbound Modding' started by Blake81, Jun 13, 2019.

  1. Blake81

    Blake81 Cosmic Narwhal

    After countless space battles with my mech, and always fighting the same black-clad, bandanna/hood wearing Bandits in space that I fought on planetside, I thought it'd be nice if I could give the standard Bandits more choices of clothes/hats to spawn with. However, no matter what I do, I CTD non-stop before even starting.

    When I went inside of bandit.npctype and found these lines:

    "head" : [ { "name" : "bandithat1" }, { "name" : "bandithat2" } ],
    "chest" : [ { "name" : "explorerchest" } ],
    "legs" : [ { "name" : "explorerlegs" } ],

    I presumed they are the item pool from where the procedural generator picks up the NPCs outfit. However, as soon as I copied that bandit.npctype into my mods folder (mods\modfolder\npcs\bandit.npctype.patch),and added that .patch at its end, the game won't even start up.

    https://pastebin.com/T4AZhmAH
    (Crash Log here)

    I haven't even changed anything INSIDE the file yet, and it still tells me something's wrong.

    Is there something I should be doing to the file other than adding the .patch? I'm pretty sure I'm making some really noobish mistake here...

    Thanks in advance.
     
  2. The | Suit

    The | Suit Agent S. Forum Moderator

  3. Blake81

    Blake81 Cosmic Narwhal

    Ohh, that's good reference material- didn't knew about the _metadata thing. Still tho, the most important part of patching, it doesn't truly EXPLAIN what you're doing; it just says remove all inside the .patch and paste this there:

    [ { "op": "replace", "path" : "/shortdescription", "value": "Test Flashlight" }, { "op": "replace", "path" : "/lightColor", "value": [100,100,100] } ]

    What does each of those functions do? What does "op" stands for? I don't quite understand, and sadly that tutorial doesn't explain...

    This isn't quite my first time modding SB; what I usually do is that I download an existing mod that resembles to the one I wanna make, look at how it's made, reverse-engineer the procedure, and shape that mod into the one I want; I've never created a .patch from scratch, but I've modified them before. However, this time around, I was unable to find any mod that replaced NPC clothing, so I had to start from zero.

    I've seen other tutorials around, but it's always on item creation, quests, or planets. Are there any tutorials like that one on NPCs?
     
  4. projectmayhem

    projectmayhem Spaceman Spiff

    https://chbrown.github.io/rfc6902/

    that website will be your patch making friend.
    Take the file you want to change, paste all its code into the left box.
    then change the code how you want, in your case, add some extra clothing options.
    Now, take that new code and put it in the right box
    click the button and it makes a patch for you, now you just gotta copy it and name it to match the file + .patch


    I am not 100% for sure, but i think op stand stand operation
    So, an operation that "replaces" a value. the path is like the road map to the value. The value is what you want to add/change/replace
    You can google all the operations, the only ones ive ever used are replace, add, and i think i used remove once
     
  5. The | Suit

    The | Suit Agent S. Forum Moderator

    You make a good point, I should explain it better in the next update.
    I just didn't feel it is relevant considering whether you know what OP is or not really don't change anything in the end of the day.
     
  6. Blake81

    Blake81 Cosmic Narwhal

    Yeah, but still it feels a bit cookbook-ey; a few more examples with different kinds of mods would also be nice; Add/Modify and NPC type, create a custom furniture, change how existing furniture works (say, turn a bench into a bed, or vice versa). I like to have an understanding of WHAT am I doing; makes spotting errors much easier, as well as gives you the skill and knowledge to replicate it later.

    I know everyone learns differently, but I usually have a much easier time dismantling an existing thing and remaking it to fit my needs (.... which now that I think about it, isn't that how most base building in SB works,hah? :p )

    Ohh! Now that's a sweet deal.
     
    Last edited: Jun 14, 2019
  7. Blake81

    Blake81 Cosmic Narwhal

    One quick, last question.

    [
    {
    "op": "add",
    "path": "/items/override/0/1/0/head/0/parameters",
    "value": {
    "colorIndex": 1
    }
    },
    {
    "op": "add",
    "path": "/items/override/0/1/0/head/1/parameters",
    "value": {
    "colorIndex": 1
    }
    },
    {
    "op": "replace",
    "path": "/items/override/0/1/0/head/1/name",
    "value": "swamphat"
    }
    ]

    Is there any way to choose more than one color each? Say, colorIndex be 1,2,3. I tried just setting it like that, and it crashed....
     
    Last edited: Jun 14, 2019
  8. projectmayhem

    projectmayhem Spaceman Spiff

    when there are multiple choices, it needs an array to choose from. So you will need to add [ ] brackets, to let it know there are multiple choices. (I hope I said that right, im still learning a lot of this stuff, so someone correct me if i explained that wrong. But the code would look like this...


    Code:
    [
      {
        "op": "replace",
        "path": "/items/override/0/1/0/head/0/parameters/colorIndex",
        "value": [ 1,2,3,4,5,6]
      }
    ]
     
  9. The | Suit

    The | Suit Agent S. Forum Moderator

    The irony though what you asking for is a cookbook at that point isn't it?
    The more examples of how to do specific situations is exactly that.

    The idea behind the book is to teach you basic techniques once you finish it you will be able to create your own items by simply following the same rules you learned from the book and simply use that information by looking at the existing code and reason the solution for your self.
     

Share This Page