Starbound

Starbound

Not enough ratings
Book Of Spirits Patching Guide
By Chofranc
This guide is for patching the Starbound mod Book of Spirits - NPC & Monster Name Displayer to add in-built support for custom NPCS, Monsters and chatty objects.
   
Award
Favorite
Favorited
Unfavorite
Introduction
This mod have high priority and should load before any other mods that uses its features so isn't necesary to include it in your metadata file. The main features of this mod includes displaying the name of the entity, a custom title if it haves one and in the case of monsters, it displays if they are of a rare breed(Albino Poptop, Fire Gleap, etc) and elite.

There are two displayers, name displayer and title displayer which will automatically show depending on the configuration of the entity which i will describe in the sections below.

Also, when i mention that something is harmless, that means that your mod will function normally even if "Book of Spirits - NPC & Monster Name Displayer" isn't installed.

I recommend you to unpack the mod since there are some files that you may need to copy into your mod and it can help you to understand better what you need to patch.

Naming rules for hostile NPCS:
I set a fixed name for generic hostile NPCs(bandits, zombies, lackeys, etc) since in most video games only important hostile NPCs have name to highlight their importance over mobs.
NPC parameters
The name displayer picks any of the following configuration of the NPC as their name:
  • npcname variable.
  • name variable that can be assigned within their identity table.
  • the random generated name that is assigned to them.
This is a personal preference but you may want to set a name for generic hostile NPCs(Zombies, Bandits, Lackeys, etc) that act as monsters.

The title displayer picks the following variable that is added by this mod which is harmless:
  • displayTitle

There is also a new harmless behaviour script that is added by this mod that you must copy if there is an NPC that is overriding the base behaviour script(Merchants for example), you can find it here:
  • /scripts/bookofspirits/bookofspirits_interact_support.lua
This script shows the displayer when interacting(E) with an NPC. If the displayer doesn't shows up when interacting, you need to add this script to your NPC.
NPC Patching-Support
The following is the patching proccess but you can add it directly into your mod, i think that is easier to understand the variable positions this way.

To give an NPC a title and if is overriding the behaviour script(IE: merchant.npctype):
[ [{ "op" : "add", "path" : "/displayTitle", "value" : "Merchant"}] ,[{ "op": "add", "path": "/scripts/-", "value": "/scripts/bookofspirits/bookofspirits_interact_support.lua" }] ]

Result:
{ "type" : "merchant", "baseType" : "base", ... "displayTitle" : "Merchant", "scripts" : [ "/npcs/bmain.lua" ,"/scripts/bookofspirits/bookofspirits_interact_support.lua" ] }

To set a fixed name for the npc(mutantminer.npctype):
[{ "op" : "add", "path" : "/identity", "value": { "name":"Mutant Miner" }}]

Result:
{ "identity" : { "name":"Mutant Miner" } }
Chatty Objects Parameters
The following variables and script are harmless and are added by this mod:

The name displayer picks the following configuration of the object as their npc name:
  • npcName

The title displayer picks the following variable that is added by this mod which is harmless:
  • displayTitle

There is also a new script that that you must copy into your mod:
  • /scripts/bookofspirits/bookofspirits_interact_support.lua
This script shows the displayer when interacting(E) with an Object. If the displayer doesn't shows up when interacting, you need to add this script to your Object.

Warning:
  • You cannot use this feature if the object haves an "interactAction" parameter.
  • You can only use this feature if the object can be made "chatty", usually have "scripts" and "chatOptions" arrays.
Chatty Object Patching-Support
To give an object a name and title(IE: techlabscientist.object):
[ [{ "op" : "add", "path" : "/npcName", "value" : "Elliot"}] ,[{ "op" : "add", "path" : "/displayTitle", "value" : "Tech Lab Scientist"}] ,[{ "op": "add", "path": "/scripts/-", "value": "/scripts/bookofspirits/bookofspirits_interact_support.lua" }] ]

Result:
{ "objectName" : "techlabscientist", "colonyTags" : ["outpost"], ... "npcName" : "Elliot", "displayTitle" : "Tech Lab Scientist", "scripts" : ["/scripts/chattyObject.lua","/scripts/bookofspirits/bookofspirits_interact_support.lua"] }
Monster Parameters
The name displayer picks the following configuration of the monster as their name:
  • shortdescription

The title displayer picks the following variable that is added by this mod which is harmless:
  • displayTitle(this is added as an statusProperties)

Note:
Rare Monsters variants have a custom title in the format(check /monsters/flyers/agrobat/iceagrobat.monstertype.patch):
^yellow; Rare Breed ^reset;

There is also a new harmless script that is added by this mod that you must copy if there is a Monster that can be set as elite or that can have dynamic custom titles and dynamic names such as Generated monsters:
  • /scripts/bookofspirits/bookofspirits_monster_support.lua

There is also a new file that contains additional configurations for Generated Monsters that you must check if adding new types of generated monsters, it will be explained in more detail in their corresponding section:
  • /monsters/bookofspirits_generated.config


Monster Patching-Support
To give a Monster a name, title and display it as elite if is configured as elite(IE: punchy.monstertype):
[ [{ "op" : "add", "path" : "/shortdescription", "value" : "Punchy"}] ,[{ "op" : "add", "path" : "/baseParameters/statusSettings/statusProperties/displayTitle", "value" : "Test Dummy"}] ,[{ "op" : "add", "path" : "/baseParameters/scripts/-", "value" : "/scripts/bookofspirits/bookofspirits_monster_support.lua"}] ]

Result:
{ "type" : "punchy", "categories" : [], ... "shortdescription" : "Punchy", "baseParameters" : { "statusSettings" : { "statusProperties" : { "displayTitle" : "Test Dummy" } } ,"scripts" : [ "/monsters/monster.lua", ,"/scripts/bookofspirits/bookofspirits_monster_support.lua" ] } }
Generated Monster Parameters
Generated Monsters have a whole new configuration file that contains parameters to set the name and custom title for generated monsters based on their parts.

The config file: /monsters/bookofspirits_generated.config

There is also a new script: "/scripts/bookofspirits/bookofspirits_monster_support.lua" that must be copied into your mod and added into the script array of the generated monster.

skillPrefixes
This is a JSON array of objects that contains a list of the skill types from the special skill of the monster that will be used to determine the prefix of the monster name.
  • name: is the string name that will displayed along side the monster name.
  • skillName: is the skill name type(IE: inkSprayAttack) that will be used to compare if the monster haves that skill.
  • asSuffix(optional): if set to true, the skill name will be added after the monster name.

monsterTypes
This contains a list with the name of the monster type and its variants. This list is used to determine the monster name and title based on the head part of the monster or an specific part pattern of your choice.

  • monster type(IE: "largeflying"): the name of the list should be the name of the "type" parameter of the .monstertype file.
  • variants: in this JSON array of objects, you put the different part combinations that the generated monster can have.

Variants Parameters
This JSON array of objects contains a series of variables which will be used to configure the generated monster name and title based on the parts given in their entry. It supports multiple parts pattern but its recommended to put entries with just the head part first.

  • name: the monster name that will be displayed.
  • title(optional): the title that will be displayed.
  • prefix(optional): a prefix that will be added to the monster name.
  • parts: this is an array of strings that contains the name of the folder containing the part of the monster.
  • addSkillPrefix(optional): if set to false, it will not add an skill Prefix to the monster name.

Note:
If you want to set an specific pattern, that particular entry must have all the part types used by the monster type.
IE: largefish: uses 3 parts as configured in their "parts" array
so, the pattern should have 3 parts as well:
{"name" : "SunShark", "title" : "Large Fish Monster", "parts" : ["shark","sunfish","sunfish"]}



Generated Monsters Patching-Support For New Types
For this example i will use the "sb_hugebiped.monstertype" of Betabound which is a new type of generated monster.

Remember to copy "/scripts/bookofspirits/bookofspirits_monster_support.lua" into your mod in the same folder path.

To give support for a new generated monster type(add it directly into your mod or patch it if you are patching other user's mod):
[ [{ "op" : "add", "path" : "/baseParameters/scripts/-", "value" : "/scripts/bookofspirits/bookofspirits_monster_support.lua"}] ]

Result:
{ "type" : "sb_hugebiped", "categories" : ["sb_hugebiped"], ... ,"baseParameters" : { "scripts" : [ "/monsters/monster.lua", "/monsters/sb_miniboss.lua" ,"/scripts/bookofspirits/bookofspirits_monster_support.lua" ] } }

Then you must patch the file "/monsters/bookofspirits_generated.config" as a file "/monsters/bookofspirits_generated.config.patch":
[ { "op": "add", "path": "/monsterTypes/sb_hugebiped", "value": { "variants": [ { "name": "Birdzilla", "title": "Huge Biped Monster", "parts": ["beak"] }, { "name": "Dragonzilla", "title": "Huge Biped Monster", "parts": ["dragon"] }, { "name": "Featherzilla", "title": "Huge Biped Monster", "parts": ["feather"] }, { "name": "Rhinozilla", "title": "Huge Biped Monster", "parts": ["rhino"] } ] } } ]

Result:
{ ,"monsterTypes" : { "largeflying" : {...} ... ,"sb_hugebiped" : { "variants" : [ {"name" : "Birdzilla","title" : "^red;Huge Biped Monster","parts" : ["beak"]} ,{"name" : "Dragonzilla", "title" : "^red;Huge Biped Monster","parts" : ["dragon"]} ,{"name" : "Featherzilla","title" : "^red;Huge Biped Monster","parts" : ["feather"]} ,{"name" : "Rhinozilla","title" : "^red;Huge Biped Monster","parts" : ["rhino"]} ] } } }
Generated Monster Patching-Support Existing Type
To add a new variant to an existing monster type(IE: largequadruped.monstertype), you must patch the file "/monsters/bookofspirits_generated.config" as a file "/monsters/bookofspirits_generated.config.patch":
[ { "op": "add", "path": "/monsterTypes/largequadruped/variants/-", "value": {"name": "New Quadruped 1","title": "Large Quadruped Monster", "parts": ["blabla1"]} } ,{ "op": "add", "path": "/monsterTypes/largequadruped/variants/-", "value": {"name": "New Quadruped 2","title": "Large Quadruped Monster", "parts": ["blabla2"]} } ]

Result:
,"monsterTypes" : { "largeflying" : {...} ... ,"largequadruped" : { "variants" : [ {"name" : "Anthurix","prefix" : "Adult", "title" : "Large Quadruped Monster","parts" : ["arrow"]} ... ,{"name": "New Quadruped 1","title": "Large Quadruped Monster", "parts": ["blabla1"]} ,{"name": "New Quadruped 2","title": "Large Quadruped Monster", "parts": ["blabla2"]}
3 Comments
0A0 23 Jan @ 8:36am 
Oh I'm talking about this guide. I think you forget to copy those lua I mentioned.
I am not good at English. Sorry for my poor expression.
Chofranc  [author] 23 Jan @ 7:03am 
@0A0 Yes, if the object is missing a chattyObject script but it can have support for it(it doesn't have an interactAction parementer), you must add it since is the script that handles the dialogue of the object. Some objects have a custom version of chattyObject.lua with a different name so in that case, isn't necessary to add it, if the custom script contains config.getParameter("chatOptions", {}), you don't need to add "/scripts/chattyObject.lua".

If it doesn't have the chatOptions parameter(the array that contains the dialogue), you must also add it.
0A0 19 Jan @ 10:38pm 
-Chatty Objects Parameters- PART "/scripts/chattyObject.lua" is missing.
And -Chatty Object Patching-Support- Part, "/scripts/chattyObject.lua" also need to be add in its patch file, right?:mbgaan: