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: Simulator Enhancements (03/13/24)

Author Topic: Removing portraits from existing vanilla factions  (Read 2342 times)

Rohzdear

  • Ensign
  • *
  • Posts: 21
    • View Profile
Removing portraits from existing vanilla factions
« on: July 21, 2020, 11:22:06 PM »

Hi there.

I am a novice in Starsector modding, and although I haven't released anything in the Forum yet I've done some small mods for personal use. I was planning on releasing a Portrait Pack with new portraits, but I was looking for a way to remove portraits added by the vanilla faction files into vanilla factions (without editing the original ones) so that, for example, Hegemony Factions characters do not appear with non-Hegemony portraits, like portrait13.png,  portrait15.png, etc.
I was unsure if there was a way to do this, as with the Portrait mod that I made all that I do is add new portraits into a custom Hegemony.FACTION file.

Thanks for the help in advance.  :D
 If this thread doesn't belong here I ask that it's moved where it'd be appropriate.

Logged

Mondaymonkey

  • Admiral
  • *****
  • Posts: 777
    • View Profile
Re: Removing portraits from existing vanilla factions
« Reply #1 on: July 22, 2020, 07:59:46 AM »

There are generally two way to do this:

1. Make your mod overwrite .faction file instead of merging. It mean, you need to copy all the data from original file, delete unwanted portraits, add your owns. Then in mod_info.json add string:
Code
    "replace":["data\\world\\factions\\hegemony.faction"]

Original file will be intact, but will not be used. Really easy to do, but can make compatibility issues with other mods, doing the same.

2. Make a script. I am not sure there are API to do this. At least, I didn't find anything in Faction.API except of "WeightedRandomPicker<String> getPortraits(Gender gender);" and the WeightedRandomPicker is something far beyond my understanding. You better ask in "misc modding questions".
Logged
I dislike human beings... or I just do not know how to cook them well.

Rohzdear

  • Ensign
  • *
  • Posts: 21
    • View Profile
Re: Removing portraits from existing vanilla factions
« Reply #2 on: July 22, 2020, 07:15:25 PM »

There are generally two way to do this:

1. Make your mod overwrite .faction file instead of merging. It mean, you need to copy all the data from original file, delete unwanted portraits, add your owns. Then in mod_info.json add string:
Code
    "replace":["data\\world\\factions\\hegemony.faction"]

Original file will be intact, but will not be used. Really easy to do, but can make compatibility issues with other mods, doing the same.

2. Make a script. I am not sure there are API to do this. At least, I didn't find anything in Faction.API except of "WeightedRandomPicker<String> getPortraits(Gender gender);" and the WeightedRandomPicker is something far beyond my understanding. You better ask in "misc modding questions".

I see. Can't say that I've ever tried anything as complex as scripts in Starsector, but I guess there's a first time for everything.
Replacing the original files sounds way easier though of course, it could conflict. Is there a lot of mods that replace the original faction files rather than merging?

Thank you very much for the help. Will ask this on the Misc Modding Questions thread.
Logged

lethargie

  • Commander
  • ***
  • Posts: 183
    • View Profile
Re: Removing portraits from existing vanilla factions
« Reply #3 on: July 24, 2020, 09:57:42 AM »

Actually it creates conflict with any mod that modify in any shape or form the file you are replacing.
Mods generally work by appending to the vanilla file, so lets take for example the hegemony.faction file:

  • game load vanilla hegemony.faction
  • game append all modification (new ship, new guns, etc)
  • game realize you have a .replace, throw to the garbage everything vanilla and all modification and pick your replace.





its not really that way inside, but the result is pretty much this. If you want to remove vanilla portrait while keeping compatibility you have two choices:

1) Edit the vanilla file. (A bit dangerous if you mess up, but its not so bad)
2) write a script that manually does all the merging the game would do, respecting the game rules for merging. Then use that merged file as a replace (You need to redo it if you change your mod list)

I actually wrote a c# script that does 2), but sharing it there was a small runtime problem for other people and life took me away from finishing it. https://fractalsoftworks.com/forum/index.php?topic=18420.msg287891#msg287891

You can try it or look at the source code if you want
« Last Edit: July 24, 2020, 09:59:52 AM by lethargie »
Logged

Mondaymonkey

  • Admiral
  • *****
  • Posts: 777
    • View Profile
Re: Removing portraits from existing vanilla factions
« Reply #4 on: July 24, 2020, 10:46:22 AM »

A
  • game load vanilla hegemony.faction
  • game append all modification (new ship, new guns, etc)
  • game realize you have a .replace, throw to the garbage everything vanilla and all modification and pick your replace.

You are correct. Although, it could be:

  • game load vanilla hegemony.faction
  • game realize you have a .replace, throw to the garbage only vanilla.
  • game append all modification (new ship, new guns, etc) to .replace instead of vanilla

That way requires .replace to be the first mod loaded and the only .replace for that file. Everything is doable, but extremely unreliable. Script is better from any point of view.
Logged
I dislike human beings... or I just do not know how to cook them well.