Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Nerzhull_AI on September 20, 2019, 04:44:19 PM

Title: [REDACTED] systems
Post by: Nerzhull_AI on September 20, 2019, 04:44:19 PM
Is there any way to increase amount of [REDACTED]-infested systems generated at the start of the new game?
Title: Re: [Redacted] systems
Post by: Harmful Mechanic on September 20, 2019, 05:10:24 PM
Yes, but you'll need to replace the script RemnantThemeGenerator.java with an altered version.

The relevant section of code is here:
Code
	public static final int MIN_CONSTELLATIONS_WITH_REMNANTS = 15;
public static final int MAX_CONSTELLATIONS_WITH_REMNANTS = 25;

public static float CONSTELLATION_SKIP_PROB = 0.25f;

Turn the min and max numbers up and you should be good to go.
Title: Re: [Redacted] systems
Post by: Nerzhull_AI on September 20, 2019, 05:31:36 PM
Yes, but you'll need to replace the script RemnantThemeGenerator.java with an altered version.

The relevant section of code is here:
Code
	public static final int MIN_CONSTELLATIONS_WITH_REMNANTS = 15;
public static final int MAX_CONSTELLATIONS_WITH_REMNANTS = 25;

public static float CONSTELLATION_SKIP_PROB = 0.25f;

Turn the min and max numbers up and you should be good to go.
Nvm, found it. Can't express how grateful i am.
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 20, 2019, 06:21:48 PM
This is gonna be FUN.
(https://i.imgur.com/qfQltQH.jpg)
(https://i.imgur.com/CXtdB5L.jpg)
Title: Re: [Redacted] systems
Post by: Nerzhull_AI on September 21, 2019, 12:21:04 PM
Yes, but you'll need to replace the script RemnantThemeGenerator.java with an altered version.

The relevant section of code is here:
Code
	public static final int MIN_CONSTELLATIONS_WITH_REMNANTS = 15;
public static final int MAX_CONSTELLATIONS_WITH_REMNANTS = 25;

public static float CONSTELLATION_SKIP_PROB = 0.25f;

Turn the min and max numbers up and you should be good to go.
Okay, i'm doing something wrong.
So, i changed MIN_CONSTELLATIONS_WITH_REMNANTS to 75, MAX_CONSTELLATIONS_WITH_REMNANTS to 125, and overall amount of constellations up to 300, using Grand Sector mod. Also turned CONSTELLATION_SKIP_PROB=0f
I started new game, and decided to check through devmode on, ctrl+z and going "outside", and i got only 22 remnant beacons.
I turned Grand Sector off, and cranked up both sector size in settings, and "count" in SectorProcGen.java, but got the same result.
Spoiler
(https://i.imgur.com/hWYKSAI.jpg)
[close]
Broadcasts the Distress Call.
Title: Re: [REDACTED] systems
Post by: Mar Sara on September 21, 2019, 05:21:36 PM
Where did you put the new file?
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 21, 2019, 05:44:54 PM
Where did you put the new file?
Long story short, i discovered me being slightly [redacted] and look into starfarer.api.jar, extracted RemnantThemeGenerator.class, replaced MIN_CONSTELLATIONS_WITH_REMNANTS and MAX_CONSTELLATIONS_WITH_REMNANTS in it using some software, placed redacted RemnantThemeGenerator.class back into .jar, but it doesn't seems to work, still got 20 remnant systems
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 04:49:03 PM
At this point, i just wonder if there's some sneaky file that overrides this data. Can't find it though.
Tried implementing these changes as a mod, got same result.
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 05:07:45 PM
Ok, two things.
First:
Spoiler
(https://i.imgur.com/9mOYqyu.jpg)
[close]
Second: i'm pretty sure i break something.
Spoiler
public void generateForSector(ThemeGenContext context, float allowedUnusedFraction) {
      
      float total = (float) (context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction;
      if (total <= 0) return;
      
      int num = (int) StarSystemGenerator.getNormalRandom(MIN_CONSTELLATIONS_WITH_REMNANTS, MAX_CONSTELLATIONS_WITH_REMNANTS);
      //if (num > total) num = (int) total;
[close]

Also, apparently, i'm unable do the same through mod. Feelsbad.
Title: Re: [REDACTED] systems
Post by: Yunru on September 22, 2019, 05:14:53 PM
So from what I'm reading, total (which is (context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction) is a secret cap, above and beyond MAX_CONSTELLATIONS_WITH_REMNANTS.

Odd that it's a float though, I always thought that those were <1.

For a lark, try instead replacing it with something like:
Code
(context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction * 20

Or if you can find allowedUnusedFraction somewhere, try upping that.
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 05:39:00 PM
For a lark, try instead replacing it with something like:
Code
(context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction * 20
Or if you can find allowedUnusedFraction somewhere, try upping that.
Nah, if i do that this way it will probably generate zero remnants, since total will be smaller.
I'm currently searching for allowedUnusedFraction, but so far i didn't found it.

Also, i'd appreciated if someone posted at least rough instruction how to implement these changes through mod. Right now i only have vague memories of java, some mods as a references/examples and well, that's it.
Title: Re: [REDACTED] systems
Post by: Yunru on September 22, 2019, 05:41:57 PM
Nah, if i do that this way it will probably generate zero remnants, since total will be smaller.
Why would multiplying total make it smaller?
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 05:57:37 PM
Nah, if i do that this way it will probably generate zero remnants, since total will be smaller.
Why would multiplying total make it smaller?
Spoiler
float total = (float) (context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction;
      if (total <= 0) return;
      
      int num = (int) StarSystemGenerator.getNormalRandom(MIN_CONSTELLATIONS_WITH_REMNANTS, MAX_CONSTELLATIONS_WITH_REMNANTS);
      if (num > total) num = (int) total;
[close]
Well, if MIN_CONSTELLATIONS_WITH_REMNANTS=75, and MAX_CONSTELLATIONS_WITH_REMNANTS=125, num will be somewhere in-between, let's say 100. If number > total => number==total, so maximum possible amount of remsystems decreases.
Since total is something similar to "constellations free for new themes", by multiplying allowedUnusedFraction we decreasing "total" number.
At least this is what i'm seeing here.

Also, i found this:
Spoiler
   public interface ThemeGenerator {
   String getThemeId();
   
   void generateForSector(ThemeGenContext context, float allowedUnusedFraction);
   
   /**
    * Themes with lower "order" values get their shot at generating content first.
    * @return
    */
   int getOrder();
   
   
   /**
    * What fraction of the Sector this theme wants to be used for, relative to other themes.
    *
    * The fraction it gets is weight / (total weight of all themes).
    *
    * Base value is 100.
    *
    * @return
    */
   float getWeight();

   Random getRandom();
   void setRandom(Random random);
}
[close]
So it make sense.
Title: Re: [REDACTED] systems
Post by: Yunru on September 22, 2019, 06:02:05 PM
Spoiler
float total = (float) (context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction;
      if (total <= 0) return;
      
      int num = (int) StarSystemGenerator.getNormalRandom(MIN_CONSTELLATIONS_WITH_REMNANTS, MAX_CONSTELLATIONS_WITH_REMNANTS);
      if (num > total) num = (int) total;
[close]
Well, if MIN_CONSTELLATIONS_WITH_REMNANTS=75, and MAX_CONSTELLATIONS_WITH_REMNANTS=125, num will be somewhere in-between, let's say 100. If number > total => number==total, so maximum possible amount of remsystems decreases.
Since total is something similar to "constellations free for new themes", by multiplying allowedUnusedFraction we decreasing "total" number.
At least this is what i'm seeing here.
Right, so let's say total, as is, is 90.
Sticking * 20 on the end now makes total 1800. So now the cap for the maximum number of systems is 20 times higher.
Code
if (num > total) num = (int) total;
Means that if num is higher than total, it is set to total. So the higher total is, the higher num can be before getting capped, not the lower.
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 06:04:08 PM
Spoiler
float total = (float) (context.constellations.size() - context.majorThemes.size()) * allowedUnusedFraction;
      if (total <= 0) return;
      
      int num = (int) StarSystemGenerator.getNormalRandom(MIN_CONSTELLATIONS_WITH_REMNANTS, MAX_CONSTELLATIONS_WITH_REMNANTS);
      if (num > total) num = (int) total;
[close]
Well, if MIN_CONSTELLATIONS_WITH_REMNANTS=75, and MAX_CONSTELLATIONS_WITH_REMNANTS=125, num will be somewhere in-between, let's say 100. If number > total => number==total, so maximum possible amount of remsystems decreases.
Since total is something similar to "constellations free for new themes", by multiplying allowedUnusedFraction we decreasing "total" number.
At least this is what i'm seeing here.
Right, so let's say total, as is, is 90.
Sticking * 20 on the end now makes total 1800. So now the cap for the maximum number of systems is 20 times higher.
Code
if (num > total) num = (int) total;
Means that if num is higher than total, it is set to total. So the higher total is, the higher num can be before getting capped, not the lower.
Oh, i'm just [REDACTED] and didn't saw that ")" in before allowedUnusedFraction.
Thanks for pointing that out.
Maybe i shouldn't do this at 4 a.m. after busy day. Oh well.
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 06:55:42 PM
Or if you can find allowedUnusedFraction somewhere, try upping that.
Okaaaay, i think i found it.
Code
public class SectorThemeGenerator {

public static List<ThemeGenerator> generators = new ArrayList<ThemeGenerator>();

static {
generators.add(new DerelictThemeGenerator());
generators.add(new RemnantThemeGenerator());
generators.add(new RuinsThemeGenerator());
generators.add(new MiscellaneousThemeGenerator());
}

public static void generate(ThemeGenContext context) {
Collections.sort(generators, new Comparator<ThemeGenerator>() {
public int compare(ThemeGenerator o1, ThemeGenerator o2) {
int result = o1.getOrder() - o2.getOrder();
if (result == 0) return o1.getThemeId().compareTo(o2.getThemeId());
return result;
}
});

float totalWeight = 0f;
for (ThemeGenerator g : generators) {
totalWeight += g.getWeight();
g.setRandom(StarSystemGenerator.random);
}

for (ThemeGenerator g : generators) {
float w = g.getWeight();

float f = 0f;
if (totalWeight > 0) {
f = w / totalWeight;
} else {
if (w > 0) f = 1f;
}
//g.setRandom(StarSystemGenerator.random);
g.generateForSector(context, f);

//float used = context.majorThemes.size();
totalWeight -= w;

}
}




}
getWeight always returns 100, so f (allowedUnusedFraction) is always 0.25
Still not sure what context.majorThemes.size returns, but here's thing, context.constellations.size() should return 100 in base game, and i got ~20 systems in first playthrough. Maybe "majorThemes" just unused in base game, hell if i'm know. If it is that way, remnants capped at 25% of free sector systems = 25 remnant systems maximum at default map. Since i changed amount of constellations through mod, maybe it just returned base value of 100 and *** me. I'll try something to see how it works.
Title: Re: [REDACTED] systems
Post by: Nerzhull_AI on September 22, 2019, 07:16:06 PM
So i turned Grand Sector off, changed number of cinstellations from 100 to 300, adjusted overall sector size and MIN/MAX remnant system to 75 and 125 respectfully. Reverted other changes back to default.
(https://i.imgur.com/EraOUwN.jpg)
It seems that i'm done with researching game files. So the only thing i need right now is info about how i make these adjustments as a mod package, without direct intervention into the game files.
And maybe some more info about derelict motherships. It seems that cryosleeper count is hard 2, but there's some magick with motherships that i'm unsure of.