Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.98a is out! (03/27/25)

Pages: 1 ... 682 683 [684] 685 686 ... 778

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 2326509 times)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26051
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10245 on: October 19, 2023, 12:56:30 PM »

Is it possible to get the base module of a module in the refit screen?

The ShipAPI has getParentStation but for ShipVariantAPI it doesn't have that. I have data that needs a uniqueID to save and use to reference stuff but since modules generate a fake fleetmember I couldn't really use that and the next best thing was using the base module fleetmember to have a reference to its modules. any work around or solutions for this?

Hmm, I don't think so. I'm not even sure what "base module of a module" means, modules don't have a base module - all of the modules belong to a single parent, the ship. Regardless, though, hmm - I think you might want to store that data in Global.getSectorAPI().getPersistentData() or some such - probably with a wrapping class that has all the things you need in it etc.


How would one go about/where should one look into API docs-wise for  the following task?

I've been fiddling a world script for a custom star system but I wanted to try and trigger the automated Market Conditions generator before adding my own ones and removing the ones I don't want for more variation. So for instance:

See the PlanetConditionGenerator class!


Is there a way, aside from changing a missile's velocity, to minimize the "sway" of a homing missile? They tend to travel in a snaking s pattern to their target rather than constantly keep their nose pointed. I know some missiles like the Squall will pre-aim then travel in a straight line, but they don't exhibit homing ability aside from that initial sequence.

You can add the DIRECT_AIM hint to weapon_data.csv.
Logged

nathan67003

  • Captain
  • ****
  • Posts: 259
  • Excellent imagination, mediocre implementation.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10246 on: October 20, 2023, 11:53:11 AM »

See the PlanetConditionGenerator class!
I have probably done a major goof somewhere; trying to do the market condition finagling (autogenerating, then immediately going in and removing the conditions I don't want + adding the one(s) I want) in the normal custom system script generate method is NOT going well (concurrent modification exception).

Am I missing something the API docs don't tell? Should I be doing a wait()? I've never dealt with concurrent modification exceptions before so I'm pretty much out of my depth here apart from thinking "this is probably multithreading-related".

Tangentially to this; how does one get a system's planets' nascent gravity wells to show up?
« Last Edit: October 20, 2023, 02:01:58 PM by nathan67003 »
Logged
I have some ideas but can't sprite worth a damn and the ideas imply really involved stuff which I've no clue how to even tackle.

Ruddygreat

  • Admiral
  • *****
  • Posts: 586
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10247 on: October 21, 2023, 02:41:04 AM »

Am I missing something the API docs don't tell? Should I be doing a wait()? I've never dealt with concurrent modification exceptions before so I'm pretty much out of my depth here apart from thinking "this is probably multithreading-related".

are you removing the conditions while iterating over the list?
the game does (basically) no multithreading after launch, so that's the only way to cause a concurrentModificationException

you can get around it by either getting the list's iterator and removing from there, or just making a new list (like so : new arrayList<>(oldList)) and iterating over that one while removing from the original.

Histidine

  • Admiral
  • *****
  • Posts: 5171
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10248 on: October 21, 2023, 06:07:03 AM »

I'm trying to make a pirate fleet not avoid contact with a superior player fleet on campaign map (while pirates faction is hostile to player). MEMORY_KEY_AVOID_PLAYER_SLOWLY and MEMORY_KEY_MAKE_NON_HOSTILE didn't seem to do the job. Is there something else I should try?

Relatedly, I should ask: In current (and previous) versions of the game, nearby NPC fleets will move away to 'give the player some space', which causes undesired behavior when player unintentionally or intentionally pushes around a fleet that's supposed to hold position somewhere or that's trying to travel someplace. Is this still a thing in dev version?
« Last Edit: October 21, 2023, 06:10:16 AM by Histidine »
Logged

nathan67003

  • Captain
  • ****
  • Posts: 259
  • Excellent imagination, mediocre implementation.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10249 on: October 21, 2023, 09:44:13 AM »

Am I missing something the API docs don't tell? Should I be doing a wait()? I've never dealt with concurrent modification exceptions before so I'm pretty much out of my depth here apart from thinking "this is probably multithreading-related".

are you removing the conditions while iterating over the list?
the game does (basically) no multithreading after launch, so that's the only way to cause a concurrentModificationException

you can get around it by either getting the list's iterator and removing from there, or just making a new list (like so : new arrayList<>(oldList)) and iterating over that one while removing from the original.
Ooooh, yeah, I am doing that. Gonna have a go at what you suggested, ty!
Logged
I have some ideas but can't sprite worth a damn and the ideas imply really involved stuff which I've no clue how to even tackle.

Helldiver

  • Captain
  • ****
  • Posts: 394
  • space fruit
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10250 on: October 21, 2023, 11:59:04 AM »

While looking at how certain text is set in the game, I saw that most (all?) instances of "story points" have the "story" word set by Misc.STORY, leading to the following in Misc.java:

Code
/**
* Name of "story points".
*/
public static String STORY = "story";
This seems to allow their name to be easily changed across the game. I tried my hand at changing them with a small mod and the following:
Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global.*;
import com.fs.starfarer.api.impl.campaign.ids.Strings.*;

public class StorypointMod extends BaseModPlugin {

    @Override
public void onApplicationLoad() {   

String STORY = "placeholder";


    }


}
[close]

-but I am not seeing a change (although it's not crashing). My java knowledge is next to zero so I am most certainly messing up - or I'm not understanding when this is being loaded. Thank you if you can help.
Logged
Afflictor bean plushie that glows purple when you squeeze it
30$

AtlanticAccent

  • Lieutenant
  • **
  • Posts: 80
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10251 on: October 21, 2023, 03:11:39 PM »

While looking at how certain text is set in the game, I saw that most (all?) instances of "story points" have the "story" word set by Misc.STORY, leading to the following in Misc.java:

Code
/**
* Name of "story points".
*/
public static String STORY = "story";
This seems to allow their name to be easily changed across the game. I tried my hand at changing them with a small mod and the following:
Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global.*;
import com.fs.starfarer.api.impl.campaign.ids.Strings.*;

public class StorypointMod extends BaseModPlugin {

    @Override
public void onApplicationLoad() {   

String STORY = "placeholder";


    }


}
[close]

-but I am not seeing a change (although it's not crashing). My java knowledge is next to zero so I am most certainly messing up - or I'm not understanding when this is being loaded. Thank you if you can help.

You're just setting a local variable (essentially a holder for data that you can operate on or reference later) here. This doesn't change anything about the values in the game itself. To do so, you must reference the value and alter it, like so:

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.util.Misc;

public class StorypointMod extends BaseModPlugin {
    @Override
    public void onApplicationLoad() {   
Misc.STORY = "placeholder";
    }
}
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26051
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10252 on: October 21, 2023, 03:58:44 PM »

I'm trying to make a pirate fleet not avoid contact with a superior player fleet on campaign map (while pirates faction is hostile to player). MEMORY_KEY_AVOID_PLAYER_SLOWLY and MEMORY_KEY_MAKE_NON_HOSTILE didn't seem to do the job. Is there something else I should try?

I think what you want is MemFlags.MEMORY_KEY_MAKE_AGGRESSIVE, that's the "standard" way of accomplishing this.

Relatedly, I should ask: In current (and previous) versions of the game, nearby NPC fleets will move away to 'give the player some space', which causes undesired behavior when player unintentionally or intentionally pushes around a fleet that's supposed to hold position somewhere or that's trying to travel someplace. Is this still a thing in dev version?

... they do? The only thing that comes to mind that may fit the bill is a bunch of fleets orbiting the same entity will try to de-clump by adjusting orbital periods. But that doesn't sound like what you're talking about, hmm.

Especially with regard to traveling fleets or fleets told to hold a position, nothing comes to mind that would match what you're describing. In fact just recently I was working on something that required multiple fleets to hold position next to each other (for an NPC-NPC "inspection") and that worked fine, without being affected by player proximity.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3152
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10253 on: October 21, 2023, 06:31:54 PM »

Relatedly, I should ask: In current (and previous) versions of the game, nearby NPC fleets will move away to 'give the player some space', which causes undesired behavior when player unintentionally or intentionally pushes around a fleet that's supposed to hold position somewhere or that's trying to travel someplace. Is this still a thing in dev version?

... they do? The only thing that comes to mind that may fit the bill is a bunch of fleets orbiting the same entity will try to de-clump by adjusting orbital periods. But that doesn't sound like what you're talking about, hmm.

You haven't seen that? NPC fleets try to avoid overlapping the player's fleet, interfering with whatever they are currently doing. IDK if there are any exploits from it, but it is always weird to me as a player and a little annoying from the modder side like with Hold Position as Hist mentions.

EDIT: and regarding hold position, it is annoying how bad the AI is at moving to an orbiting point to hold position on it. It misses and circles back repeatedly. For example, if I want the NPC fleet to "mine" at a spot. Orbiting the spot just isn't the same :(
« Last Edit: October 21, 2023, 06:34:51 PM by SafariJohn »
Logged

Histidine

  • Admiral
  • *****
  • Posts: 5171
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10254 on: October 21, 2023, 07:20:18 PM »

Took a couple of .gifs showing the issue.

Thanks for mentioning the aggressive flag, I'll try that!
EDIT: Huh, now non-hostile works even without aggressive, did I just not set it right the first time?
« Last Edit: October 21, 2023, 08:02:13 PM by Histidine »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26051
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10255 on: October 21, 2023, 07:45:13 PM »

Ahh, ok, I see what you mean - overlapping, right. I think that just doesn't happen super often when I'm playing, hm. Or I'm just conditioned to not notice it. Weird, but, ok, I see the code - it's... super old. But seems fine in the general case, and applies to more than just the player, but other fleets as well. Let me add a MemFlags.DO_NOT_TRY_TO_AVOID_NEARBY_FLEETS you can set to turn off this behavior.

(And, checking what I did recently for the NPC-NPC inspections - it's just overriding the action text and using fleet.setMoveDestinationOverride() to get around all of this entirely.)

EDIT: and regarding hold position, it is annoying how bad the AI is at moving to an orbiting point to hold position on it. It misses and circles back repeatedly. For example, if I want the NPC fleet to "mine" at a spot. Orbiting the spot just isn't the same :(

The thing to do here would be to orbit the same focus as the orbiting point, with the same period, once you get within a certain (very close) distance of it, no?


Took a couple of .gifs showing the issue.

Oof, thank you! Let me also auto-turn-this-off when the fleet is holding/standing down; done.
Logged

Sorrydough

  • Ensign
  • *
  • Posts: 33
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10256 on: October 21, 2023, 08:55:46 PM »

I'm making a custom AI admiral and I've run into a couple issues.

1. How do I directly tell a ship to fulfill an assignment? None of the arguments for createAssignment(assignment, target, useCommandPoint) allow me to specify which ships are actually going to fulfill this assignment, instead leaving it to the AI to determine that on its own. Sometimes I'd like to assign specific ships to do a specific function. For example to create a wolfpack of specific hulls that form up on a leader, and then the leader goes to a waypoint.

2. I can't figure out how to get the API to give me a list of assignments and what object they're attached to. (ie, defend order attached to an objective, or engage order attached to a ship).
I've made a workaround for this second one, but just in case someone knows, I'd like to use an API solution if possible instead of my own janky one.
Logged

Helldiver

  • Captain
  • ****
  • Posts: 394
  • space fruit
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10257 on: October 22, 2023, 12:09:25 AM »

You're just setting a local variable (essentially a holder for data that you can operate on or reference later) here. This doesn't change anything about the values in the game itself. To do so, you must reference the value and alter it, like so:

Spoiler
Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.util.Misc;

public class StorypointMod extends BaseModPlugin {
    @Override
    public void onApplicationLoad() {   
Misc.STORY = "placeholder";
    }
}
[close]

Thank you so much. I really need to start learning this stuff instead of winging it with reused code.
Logged
Afflictor bean plushie that glows purple when you squeeze it
30$

SafariJohn

  • Admiral
  • *****
  • Posts: 3152
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10258 on: October 22, 2023, 06:00:08 AM »

EDIT: and regarding hold position, it is annoying how bad the AI is at moving to an orbiting point to hold position on it. It misses and circles back repeatedly. For example, if I want the NPC fleet to "mine" at a spot. Orbiting the spot just isn't the same :(

The thing to do here would be to orbit the same focus as the orbiting point, with the same period, once you get within a certain (very close) distance of it, no?

I have had trouble setting fleets to orbit, but do not remember the specifics atm. Maybe I just wasn't doing it right.
Logged

Vitmainlem

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10259 on: October 22, 2023, 11:29:20 AM »

Is there a way to apply beam effect like tachyon lance with pierceSet like this:
"pierceSet": [
  PROJECTILE_FF,
  PROJECTILE_NO_FF,
  PROJECTILE_FIGHTER,
  MISSILE_FF,
  MISSILE_NO_FF,
  FIGHTER,
  SHIP,
  ASTEROID
  ],
« Last Edit: October 22, 2023, 01:01:18 PM by Vitmainlem »
Logged
Pages: 1 ... 682 683 [684] 685 686 ... 778