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)

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Curator

Pages: [1]
1
Modding / Re: How to replace a class?
« on: April 14, 2021, 11:17:43 AM »
You need to replace the PersonBountyManager with a version that generates instances of your person bounty class instead of the vanilla one.

I did some searching and turns out, there's a way to do it easily in the particular case of the PersonBountyManager. In your mod plugin:

Code: java
public void onGameLoad() {
  /* bounty manager is added on every game load, so we need to remove it on every game load */
  Global.getSector().removeScript(PersonBountyManager.getInstance());
  if (!sector.hasScript(MyModifiedPersonBountyManager.class)) {
    Global.getSector().addScript(new MyModifiedPersonBountyManager());
  }
}

Thank you for your help!
I'm kinda new to Java and completely new to Starsector modding, so sorry for my noobish questions, but:
1. Do I include this code into my class or I need to create some other script? If another script - what exaclty script or where can I read about it? If into my class - does '!sector' mean that I need to call it from somewhere like 'Global' cause it is marked as error if I put it like it is?
2. Do I need to change the name of my class somehow so it will be not the same as replaced class'es name from Vanilla?

2
Modding / Re: How to replace a class?
« on: April 14, 2021, 07:47:12 AM »
So I got an answer in another thread from @Histidine :
Hey!
There's no information (or I didn't find any) about replacing Vanilla classes.
Some vanilla classes, like industries, abilities and contact missions, are specified in their CSVs, so you just change the classname specified there.

For other things (pirate base generation is one), the class instance is generated by the game's "lifecycle plugin". You have to either replace that plugin (not recommended for compatibility reasons), or else run code that removes the existing script and adds your own.

For detailed help, I'd suggest a new thread in Modding, or the Misc modding questions thread.

What exactly should I do to run the code that removes the existing script and adds my own?

3
Modding / How to replace a class?
« on: April 13, 2021, 11:07:16 AM »
Hey!
I want to replace com/fs/starfarer/api/impl/campaign/intel/PersonBountyIntel.class to change the random bounty fleets size and payment calculation.
Made a .jar with my variant of PersonBountyIntel.class (saving the path), made a mod_info.json with "jar" field and even with "replace" field filled with my .jar's name and filepath. Got no effect at all. The mod is in the list, it can be loaded but no changes are applied ingame.

Any advice?

I've attached the mod folder, maybe I did some newbie mistakes?

[attachment deleted by admin]

4
Documentation / Re: Readme & Feedback
« on: April 13, 2021, 10:54:23 AM »
Hey!
There's no information (or I didn't find any) about replacing Vanilla classes.

5
Sorry about the delayed response! Got a bit sidetracked.

This is a known issue, unfortunately - the game can't handle the audio output changing after startup. I've tried some of the more obvious things as far as re-initializing its audio (though detecting when it actually needs to do it would be another hurdle), but it hasn't worked, and I haven't had the time to really dig into it. Plus, my familiarity with the underlying sound API is fairly low, so it'd be a significant effort to try to figure out, with no guarantee that it's actually possible using the stuff the game is using (i.e. LWJGL + OpenAL).

Hey. Just got the same issue when changing my audio output from speakers to bluetooth headphones.
Some googling leads to Minecraft that uses LWJGL + OpenAL too. Here are some steps that Minecraft devs do to solve this ( http://forum.lwjgl.org/index.php?topic=7081.0 ):

What could be done to resolve this? Suggestions:
- Minecraft regularly queries alcGetInteger(device, ALC_CONNECTED), via the ALC_EXT_disconnect extension. If it returns ALC_FALSE, it automatically recreates the audio context.
- Minecraft regularly queries alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER). This returns a string that describes the default audio device. If it changes, it automatically recreates the audio context.
- Minecraft queries ALC_ALL_DEVICES_SPECIFIER (also regularly updates it) and displays the list of available audio devices. Instead of changing the default audio device from the OS settings, users can change the audio device used by Minecraft itself. This is the simplest and most robust solution. I don't remember a PC game that doesn't have such an option in its audio settings.

Pages: [1]