Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Planet Search Overhaul (07/13/24)

Author Topic: How to add a newly created ship to a faction's fleets and markets  (Read 18246 times)

King Alfonzo

  • Admiral
  • *****
  • Posts: 688
  • -- D O C T O R --
    • View Profile

Are you a real modder? Have you ever caught a good bug, like a, like a real master coder? Well then, have you ever opened up someone else's source folder?



(Edited 2nd October 2021 for 0.95a)

In order to understand what you need to do, I'll start with the outline of a basic mod. A really damn basic one is my 'Lion's Guard' mod. All it does is add Lion's Guard skins to Sindrain Diktat. Such a thing is actually pretty basic, and is the first one I ever attempted. I'll go through it with a hypothetical example, and it should be easy to figure out what you need to do working sideways or backwards what I've shown here.

SO, we begin in the mods folder. Note, in each picture, I have included at the top the address bar, so you can figure out where we are. For instance, my mods folder is in the Starsector folder, which is in the Fractal Softworks folder etc. etc:



And look - I have selected my mod folder. Let us enter into it's wicked demesne, and determine it's contents:



Here we have three things that are the absolute BASIC you need to mod:
1) A data folder. All the stuff that describes how things work goes here.
2) A graphics folder. This is where all your tasty bote images live.
3) A TERRIFYING and SPOOKY mod_info.json file. This file is how the game figures out that the mod exists, and what it needs to do to plug it into your game.

Let's have a gander at the mod_info.json. You can look at it with wordpad or notepad...but I very, very, very, VERY strongly suggest - nay DEMAND you use Notepad++. It's free, and it's just flat out better than wordpad and notepad. Let's look at my mod_info.json file in notepad++



The basis of this file is found in EVERY mod. Literally, every mod has this, otherwise the game won't plug it into the game. So you can essentially copy-paste this form another mod, and alter it for your own needs. It's somewhat self-explanatory:

"id" - What your mod uses to refer to itself code-wise. This can be anything, but often for simplicity sake you make it the same name as the folder your mod is in. Not really important for this level, but becomes important in more complicated projects.
"name" - The name that pops up in the mod directory when you start the game. Is pretty much the visible name of your mod to everyone else.
"author" - The Incredibly Handsome Individual who made the mod. Mesotronik is also an acceptable input here.
"version" - The version of your mod. When you update or improve the mod, you can increase the number here. Or write 'Dragons r kewl' for one version, and 'Alex is da bomb' in the next. Except don't actually do that - use numbers so players can easily determine if they are out of date or not.
"description" - The description that shows up in the mod directory when you start the game. Usually a bit of a blurb on what's in the mod, or what the faction is, or the password to Alex's twitter account.
"gameVersion" - The game version this mod has been made for. For the current build, it's "0.8.1a"

Simple as that. So copy-paste a mod_info.json from another mod into your mod folder (Blackrock is a good mod to do this from, because Blackrock has the Nevermore, instantly making it twenty times cooler than every mod out there), open it up with notepad++, change it, and save it.

Now let's go back to my trusty mod folder.



Now you know what that mod_info.json file does. Not very scary is it? Let's have a peek inside that graphics folder.



This is what it looks like. There's a hullmods folder, but that's not important here. What is important is the ships folder - this is where the image files for your ships are. If you're using a ship editor, this is where it or maybe you should save the image files. Within the context of this walkthrough, it's not vital, but it is good to know where it SHOULD be. Back to the mod folder:



And now, we plunge headfirst with reckless abandon into the briney waters of the data folder:



Again, ignore the hullmods folder. What is important is the 'campaign' folder, the 'hulls' folder, the 'variants' folder, and the 'world' folder. Let's start with the hulls folder.  The 'hulls' folder holds the information about your ship, containing .ship files and ship_data.csv. Let's have a gander inside:



Oh, what do you know! There's a ship there, called XIV_noscope_420 that has 20 TPC pulse lasers. This .shipfile was generated using a ship editor, and tells the game stuff about your ship, like it's shape, how big it is, how big it's shields are, how TPC pulse lasers it has, and so on. Also in this folder is the ship_data.csv file. This contains information about your ship that modders like to change a lot, like armour, hitpoints, ordinance points, fuel use, cargo - essentially everything that pops up in the 'stats' region when you look at the ship info. You can use either a ship editor, or Excel to look at this data.

Ammendum: There is a caveat to this file that doesn't immediately become obvious, which is the 'tags' column. This column essentially says what blueprint the hull belongs to. So, you can get a family of ships under, say, the 'noscope_bp' by adding noscope_bp to this column. Or, if you want it to be apart of the base tech, low tech, midline tech or high tech lines, then add 'base_tech', 'lowtech_bp', 'midline_bp' and 'hightech_bp'. Or, if you want this ship to show up individually as a rare drop, then make the tag rare_bp. Where this blueprint comes in will be discussed later; for now my Lion Guard .skins and .hulls all use the 'LG_package' tag.

Anyway, we now know that I have a (hypothetical) ship that I want in the game, called XIV_noscope_420. I have the ship image in my graphics/ships folder. I have the .ship file in data/hulls, and the appropriate row of data in the ships.csv file. But how do I get it into the game so I can shoot Luddites? Let's go back to the data folder:



We've looked at the hulls folder, but now we have to go to the next step: we need a variant of the ship. INTO THE VARIANT PORTAL:



Here is the inside of the variants folder. Each and every ship has a variant file (or ten), which determines what the ship should be armed with when it spawns in a fleet. These are generated using the 'variant' mode in the ship editor. They can also be edited using notepad++, but I suggest you edit, not create, using notepad++. SO, we can observe that XIV_noscope_420 has a variant. XIV_noscope_420_best is, obviously, the best variant of XIV_noscope_420.

Now we have all the basic data the game needs to spawn my ship for a faction. It has an image in graphics/ships, a .ship file and the appropriate data in ship_data.csv in data/hulls, and a variant file in data/variants. Now, we just need to tell the game to actually do it. Let's swing back into the data folder, an OH DEAR ITS DIO:



Quick! Dodge the timestop and get into za warduo the world folder...and then the 'factions folder:



Behold! A .faction file! Or rather, TWO .faction files! Fiendish! Fabulous! Fantastic! AND, with 0.9a, the introduction of the devious, devilish and damned, default_ship_roles.json file!

The .faction files dictate some basic information about factions, like their names, campaign colours, encounter music and what ships they can use. Note: What ships they can use. These files, however, can't make planets and stations appear and put your faction on it - they can only do basic stuff. You can easily find the original in a similar location in the starsectorcore folder in the original StarSector folder. Let's open up my sindrian_diktat.faction file.



Seems very small, doesn't it? That because for a pre-existing faction, you don't have to completely remake the .faction file. You just need to make up the file in such a way that it can insert what you want into the pre-existing .faction file. Luckily for you, if you want to stick a ship into a faction and nothing else, you won't have to do much more than what I've done above - add the hull to the knownHulls section. Also make sure to put quotation marks around your hull, and place a comma after it. This tells the faction (in this case the Sindrian Diktat) it knows how to make the ship. That's it - if you want your ship in a faction, slip it in here, and the faction will know the hull.

The same goes for fighters and weapons. hullFrequency let's you control how often the ship shows up in a fleet, with big numbers (about 10) saying it'll show up a lot, and small numbers (0.5) to keep it rarer than normal. Also, MARK THIS: the LG_package is in the 'tags' section, which tells the Sindrians that hey, you can use all the ships with the LG_package in your tags column. Which means hey, you can use Lion's Guard ships if you want. You can play around with 'priorityShips' and 'ImportedShips', which are somewhat self explanatory.

Another thing to point out: If you have an array empty, for instance: "knownShips": [], with nothing inside the brackets, then that essentially multiplies the "knownShips" by zero, completely removing any ship from being known by the faction. This also occurs similarly with any other bracketed information here. When you make your file, ensure that all the brackets have information in them, or are removed completely. Remember, you don't need ALL of the information of a faction file here, just the stuff you need to change.

HOWEVER, if you're used to 0.8.1a, or you've only read up until now, you'll think that you'll only need the .faction file to get your ship in. THAT IS WHERE YOU ARE WRONG.

AND SO WAS I.


UNTIL I LEARNED OTHERWISE.


If we can return to the factions file, we can see this weird, wild and wacky default_ship_roles. Let's slip and slide into it...



And this is what we have:



This is where all the variants live! Essentially, the faction file looks for a hull, which then goes to this file to find the variants. The numbers after each variant is how often that variant will be chosen. Further, (and don't quote me on this) when all the numbers for a hull are added up, the larger this combined number is, the more often this hull will show up in the faction fleets. The 'combatsmall' and 'combatmedium' etc. are 'classes' which the game uses to figure out how 'heavy' your ship is. For instance, if XIV_noscope_420 was a giant capital ship, then I'd stick it beneath "combatCapital". If it were a small combat ship, then I'd stick it under "combatSmall". There are far more classes which you can observe in the original, however for this example I'll just casually place the name of the variant of XIV_noscope_420 under combatSmall. I make sure my name is surrounded by quotation marks, then a colon, then a number, which ends with a comma. I make sure all the { and } are closed and not putting red lines everywhere, save, then back out. Note: if you're copying from me, you don't need any of the other variants or shiprole classes in there, just your own. Just make sure that the { and }'s are all closed.

Now the game will spawn XIV_noscope_420 in the Sindrian Diktat's fleets, and with the hull system set to blare Snoop Dogg's 'Gin and Juice' everytime it's activated, I'm sure this is going to be an MLG sort of playthrough. What's more, it will now also spawn more regularly in their markets, as it also shows up in their fleets, truly dankifying the Starsector experience.

I hope this has been useful and not too complicated - it's not hard to now go back and change / tweak / alter / make your own things to your heart's content, and unsurreptitiously insert your ship into your Starsector game. I'm almost certain more experienced and eagle-eyed modders will give better and more in-depth advice, but hopefully this helps you out.

Sendrien

  • Captain
  • ****
  • Posts: 304
    • View Profile

King Alfonzo, thank you so much for this extremely detailed and helpful tutorial! So clear that even a novice like me could make it work on my first try :)

Thank you!!
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile

Dude, that post deserves its own OP... <slow clap>
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Cruis.In

  • Commander
  • ***
  • Posts: 122
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #3 on: April 13, 2019, 09:43:44 PM »

I used the hegemony faction file from starsector core data, I don't see the fields listed in it, as in your example to. is there a new way to add ships to markets and fleets now since 0.9?
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 688
  • -- D O C T O R --
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #4 on: April 14, 2019, 12:17:29 AM »

Only just realised I hadn't updated this.

Give me a couple of minutes and I'll fix this.

And it's been a couple of minutes. Enjoy!

Cruis.In

  • Commander
  • ***
  • Posts: 122
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #5 on: April 14, 2019, 02:54:19 PM »

Lol nice! This is so awesome and easy to follow. I added my ship to the game and it spawns in the fleets and it works perfectly. So once it is spawning in their fleets will I eventually see it on their market? This means I've done it right, right?

Also how about a step by step on adding a custom weapon?

I followed your steps for this, but pertaining to weapons, put them all where they needed to go, created the .wpn file .csv file for my weapons, but I am getting a null error. I suspect obviously it has to dowith pointing to graphic or sound files. Since in the ship editor when you edit the details you point the .ship file where to look for the ship graphic file. However, I didn't see this option when editing the details of the .wpn file.

So I am guessing it is looking for a weapon graphic or sound for my custom weapon and it isn't finding it.

I already used the editor to edit my variant and loaded in the weapons I made by adding a custom mod and my weapons showed up fine and I added them to the variant. So I figured out that part of the editor.

oh and just in case I wanted to build it at my colony, what blueprint does hegemony use? I can't remember the blueprints I found in game, I think I found one and can build up to battlecruisers, but I'd have to add my custom ship to the blueprint I found, to build it. Since I dont know the name o fthe one I found I'd edit all blueprints to include my ship.
« Last Edit: April 14, 2019, 02:59:56 PM by Cruis.In »
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 688
  • -- D O C T O R --
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #6 on: April 14, 2019, 07:54:41 PM »

I added my ship to the game and it spawns in the fleets and it works perfectly. So once it is spawning in their fleets will I eventually see it on their market? This means I've done it right, right?

Yes, you should eventually start seeing it in the market. This might be a bit problematic if the faction you've added it to does not have access to a Heavy industry/Orbital Works industry, however, as they won't be able to make their own ships, and thus you won't see the ship.

Also how about a step by step on adding a custom weapon?

Maybe at a later time, it's something similar and yet somewhat different. Half the time I can barely get it to work, honestly.

I followed your steps for this, but pertaining to weapons, put them all where they needed to go, created the .wpn file .csv file for my weapons, but I am getting a null error. I suspect obviously it has to dowith pointing to graphic or sound files. Since in the ship editor when you edit the details you point the .ship file where to look for the ship graphic file. However, I didn't see this option when editing the details of the .wpn file.

So I am guessing it is looking for a weapon graphic or sound for my custom weapon and it isn't finding it.

There are actually four graphic files for energy and kinetic weapons - you can get away with two if you're desperate, and one if you're hilariously lazy. They are the 'base' graphic for a turret, and a 'base' sprite for the hardpoint (which generally is thinner and longer). Then, depending on the weapon, each of the turret and hardpoint weapons also have a 'glow' sprite (often seen in energy weapons, these overlay a 'glow' over the weapon) or a 'gun' sprite (often seen with ballistic weapons, this is the sprite that corresponds with the cannon part that moves in and out as you shoot the shell). Pretty generally the 'glow' sprite is rendered over the weapon, and it's colour can be changed in the .wpn file, while the 'gun' sprite is rendered under the base sprite, and how much recoil it has is also controlled by the .wpn file.  If you're a madman there can be a third graphic for each weapon, but that's for specialty cases.

Try opening up and comparing heavyblaster.wpn, heavyac.wpn in vanilla starsector (data->weapons) to see the differences between glow and recoil, as well as seeing the general layout for the sprites.

For missiles, it's a lot simpler, as you only need one sprite for turret, and one for hardpoint. In the missile's .wpn file, you can either chose to render the missiles on top of the sprite (for instance, atropos, where the missiles sit on the launcher) or not at all (Typhoon launcher, for instance, where the missiles sit inside the assembly).

Another problem is the projectile which your gun fires. If this is missing, then your gun might give a null crash. Again, refer back to a vanilla weapon that fires a projectile (heavyac.wpn, for instance). This will usually be one of the last lines in the .wpn file, and will point to a .proj file. This file lives in the proj folder in weapons (data->weapons->proj), and tells the game what thef bullet will pop out of the gun / what the missile will come out of the weapon looks like. If you're just starting out with a ballistic weapon, you can just co-opt a vanilla projectile - the effects are visual, but this can change if you're doing high-end coding and special on-hit effects. If you're making a missile, it's different, because the AI of the missile is stored in the .proj file. It's generally better to copy a .proj file of a missile you like the AI of, and edit it for your usage if you're new to this.

A final mention - when you get an error, you can check in the starsector-general folder for a 'log.txt' file. If you scroll right down to the end, there should be a section that says what the error was, and a guess at where it occurred. This can tell you sometimes where in a file the problem is.

oh and just in case I wanted to build it at my colony, what blueprint does hegemony use? I can't remember the blueprints I found in game, I think I found one and can build up to battlecruisers, but I'd have to add my custom ship to the blueprint I found, to build it. Since I dont know the name o fthe one I found I'd edit all blueprints to include my ship.

The base_bp is the one that everyone uses (ventures, cerberuses, etc.), the more commonly found Hegemony Auxiliary blueprint package is heg_aux_bp, while the rarer Hegemony XIV blueprint package is XIV_bp.

5WYR

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #7 on: February 26, 2020, 05:39:00 AM »

Hey everyone.

First, I'd like to thank King Alfonzo for giving me an understanding how I should get into things regarding the files, helped me alot already.
I hope this forum is somehow still alive... :)

After a first (modded) playtrough I decided to spice things up a bit and wanted to add a ship from one modded faction to another (to be more precise - i wanted that badass Pandemonium Capital Ship from Diable Avionics in my Legacy of Arkgneisis fleet, since they're lacking a bit of a punch there).
I gave it a new name (Agamemnon), created a new, blue style png and saved it into the existing LOA ships folder. I created a new (renamed, of course, i renamed everything) ship file, editet the ship_data csv with notepad, edited the variants, the default ship roles, the al_ars.faction data...

I overcame a few obstacles with typos or whatnot which prevented the game from booting and the first time i saw the loading screen i thought I've made it. Oh, silly me.

Now I've got an error log which leaves me clueless. I think it has something to do with the communications between the mods, more precise the ship isn't integrated in the base game correctly and I really don't know why :

https://ibb.co/0h1Csny

Is there anyone here who could give me a tip?
Thanks in advance.

5WYR

Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 688
  • -- D O C T O R --
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #8 on: February 26, 2020, 03:56:19 PM »

Hey 5WYR!

From the looks of things there's a problem with where the image file for the ship is. According to your log, it says "graphics/da/ships/loamt_agamemnon.png not found". This means it can't find the image file. This might because after you made the ship, you moved or renamed the image file. Go to the .ship file of your ship, open it up with notepad++ and check from 'Shipsprite' or something similar. Then go to the location it's pointing to, and see if your ship is there.

I notice that the directory goes through graphics ->da -> ships; is your ship folder sitting in a 'da' folder? That's something that's gotten me a few times - I've wondered why I keep getting cannot find errors, only to realize that for some reason that the folder director has changed.

Hope this helps!

5WYR

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #9 on: February 27, 2020, 04:05:30 AM »

Hey King Alfonzo!

Thanks for the reply. You, sir, are a lifesaver.

In the Diable Avionics mod folder there is a 'da' folder right before the 'graphics' folder, which isn't in the LOA mod.
So I changed the adressed png name but wasn't paying attention to the path.

That totally solved it. Thanks man :)
Logged

Burminsky

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #10 on: September 27, 2021, 12:54:10 AM »

Is it possible to add ships to the sale, but not to the faction fleet?
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 688
  • -- D O C T O R --
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #11 on: October 30, 2021, 10:08:14 PM »

Is it possible to add ships to the sale, but not to the faction fleet?

As far as I can tell, not without doing a high degree of coding wizardry.

tomatopaste

  • Captain
  • ****
  • Posts: 315
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #12 on: November 12, 2021, 01:14:27 AM »

Is it possible to add ships to the sale, but not to the faction fleet?

Yes, you need to implement your own submarket plugin, should be a fairly simple task with a little experience.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: How to add a newly created ship to a faction's fleets and markets
« Reply #13 on: November 12, 2021, 01:26:09 AM »

It could also be done via a listener and reportPlayerOpenedMarket.
Logged