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)

Pages: 1 ... 382 383 [384] 385 386 ... 706

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

King Alfonzo

  • Admiral
  • *****
  • Posts: 679
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5745 on: November 24, 2019, 03:33:05 PM »

This problem appears to be probably caused by a mispelling in my economy file.
What leads you to believe that's the case? I didn't see anything wrong with it either, although it's certainly possible that we're both overlooking something. That error makes it look like there's something wrong with a list of numbers in a json file though, which your economy file doesn't (and afaik shouldn't) contain.

In the log the last thing to load is the economy file, and then the game crashes. Knowing my luck there's probably some hidden character in there causing me grief from copy-pasting from a csv.

Also I'm not sure that weighted picker for Trashman would get systems with rings in them, wouldn't you need to also determine if the system had a ring with asteroids?

How can I make the drones spawned by a shipsystem stop where they are spawned? I tried setting their acceleration to 0 while leaving a good deceleration, but the only thing that happens is they keep floating away in the direction of the mothership's velocity when they spawned...

For that you need to 'fix' where the drone is in the system rather than the drone's acceleration. I suggest you look up the beholder's shipsystem in Ship and Weapon Pack by DarkRevanant, which shows how the drones are placed. It should be simple to just set a lot of these values to 0 to get what you want.

Also you will want the drone to have a high acceleration and speed so that it'll consistently stay where it's supposed to, instead of trailing behind the ship if it ends up getting whacked at high speed.

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5746 on: November 24, 2019, 03:53:45 PM »

For that you need to 'fix' where the drone is in the system rather than the drone's acceleration. I suggest you look up the beholder's shipsystem in Ship and Weapon Pack by DarkRevanant, which shows how the drones are placed. It should be simple to just set a lot of these values to 0 to get what you want.

Also you will want the drone to have a high acceleration and speed so that it'll consistently stay where it's supposed to, instead of trailing behind the ship if it ends up getting whacked at high speed.
Ah, sorry, I meant that I want to drones to stay where they are spawned and not follow the ship or move anywhere at all. Like dropping mines or something similar.
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 679
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5747 on: November 24, 2019, 11:55:33 PM »

Ah, sorry, I meant that I want to drones to stay where they are spawned and not follow the ship or move anywhere at all. Like dropping mines or something similar.

Then try speed 0, with acceleration and decelleration set to maximum, see if that does it.

I've redone my economy file by hand from the bottom up, and still no dice. I have no clue what has gone wrong. Here's a longer take of the log, maybe that might make things clearer?

Code
118171 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\DIABLEAVIONICS (data\campaign\econ/diableavionics_fob.json)]
118174 [Thread-4] INFO  com.fs.starfarer.campaign.econ.A  - Loading star system: diableavionics_outerTerminus.json
118181 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\DIABLEAVIONICS (data\campaign\econ/diableavionics_outerTerminus.json)]
118185 [Thread-4] INFO  com.fs.starfarer.campaign.econ.A  - Loading star system: FPE_danube.json
118188 [Thread-4] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [DIRECTORY: C:\Program Files (x86)\Fractal Softworks\Starsector\starsector-core\..\mods\FPE (data\campaign\econ/FPE_danube.json)]
118206 [Thread-8] INFO  sound.oo0O  - Cleaning up music with id [miscallenous_main_menu.ogg]
118688 [Thread-10] INFO  sound.oo0O  - Creating streaming player for music with id [miscallenous_main_menu.ogg]
118689 [Thread-10] INFO  sound.null  - Playing music with id [miscallenous_main_menu.ogg]
118963 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: org.json.JSONException: JSONArray[1] is not a number.
java.lang.RuntimeException: org.json.JSONException: JSONArray[1] is not a number.
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.N.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.K.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.if.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.Ò00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.json.JSONException: JSONArray[1] is not a number.
at org.json.JSONArray.getDouble(JSONArray.java:249)
at com.fs.starfarer.campaign.econ.A.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.A.o00000(Unknown Source)
... 14 more

Link to the file here, again.

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5748 on: November 25, 2019, 12:09:16 AM »

Then try speed 0, with acceleration and decelleration set to maximum, see if that does it.
Unfortunately, it doesn't work. What seems to happen is that the drones snap into their orbits (and jittering quite a bit probably because I set their accel to 99999). Setting accel and decel at a reasonable 50 while setting top speed to 0 has no effect either - they just continue to follow their orbits as normal.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5749 on: November 25, 2019, 08:34:53 AM »

Hmm, if that's all you need, maybe something like this in your ModPlugin implementation, to provide a custom drone AI that doesn't do anything except stop?

Code
	public PluginPick<ShipAIPlugin> pickDroneAI(final ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system) {
if (<not your drone>) return null;
return new PluginPick<ShipAIPlugin>(new ShipAIPlugin() {
ShipwideAIFlags flags = new ShipwideAIFlags();
public void forceCircumstanceEvaluation() {
}
public void advance(float amount) {
drone.giveCommand(ShipCommand.DECELERATE, null, 0);
}
public void setDoNotFireDelay(float amount) {

}
public boolean needsRefit() {
return false;
}
public ShipwideAIFlags getAIFlags() {
return flags;
}
public void cancelCurrentManeuver() {

}
public ShipAIConfig getConfig() {
return null;
}
}, PickPriority.MOD_SPECIFIC);
}
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5750 on: November 25, 2019, 09:06:14 AM »

How to get:
a) a valid random system with an asteroid field/ring
b) a valid random market
Using these collections you should be able to fill a WeightedRandomPicker or other collection with systems or markets that meet your criteria:
Code: java
Global.getSector().getEconomy().getMarketsCopy();
Global.getSector().getStarSystems();

I hate to ask for more spoonfeeding, but can you be more specific? Examples do more than a thousand words. Looking at Starfarer API doesn't help at all.
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5751 on: November 25, 2019, 11:10:42 AM »

Sure, so you'll probably want to do something like this:
Code: java
	static final Set<String> VALID_TERRAIN_FEATURES = new HashSet<>();
static {
VALID_TERRAIN_FEATURES.add(Terrain.ASTEROID_BELT);
VALID_TERRAIN_FEATURES.add(Terrain.RING);
}
StarSystemAPI chooseRandomRingSystem() {
Random random = new Random();
WeightedRandomPicker<StarSystemAPI> eligibleSystems = new WeightedRandomPicker<>(random);

for(StarSystemAPI system : Global.getSector().getStarSystems()) {
int validTerrainCount = 0;

for(CampaignTerrainAPI terrain : system.getTerrainCopy()) {
if(VALID_TERRAIN_FEATURES.contains(terrain.getType())) {
validTerrainCount += 1;
}
}

if(validTerrainCount > 0) {
eligibleSystems.add(system, validTerrainCount);
}
}

return eligibleSystems.pick(random);
}
I haven't tested this method, and I'm sure you'll need to make a lot of changes to get it working the way you want, but it should choose a random system with at least one belt or ring. The more belts or rings a system has, the more likely it will be chosen. You can do the same type of thing with markets. The difficult part about things like this is making sure you don't choose something you shouldn't.

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5752 on: November 25, 2019, 12:02:03 PM »

Thankings you muchly!
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5753 on: November 25, 2019, 06:35:35 PM »

Hmm, if that's all you need, maybe something like this in your ModPlugin implementation, to provide a custom drone AI that doesn't do anything except stop?

Code
	public PluginPick<ShipAIPlugin> pickDroneAI(final ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system) {
if (<not your drone>) return null;
return new PluginPick<ShipAIPlugin>(new ShipAIPlugin() {
ShipwideAIFlags flags = new ShipwideAIFlags();
public void forceCircumstanceEvaluation() {
}
public void advance(float amount) {
drone.giveCommand(ShipCommand.DECELERATE, null, 0);
}
public void setDoNotFireDelay(float amount) {

}
public boolean needsRefit() {
return false;
}
public ShipwideAIFlags getAIFlags() {
return flags;
}
public void cancelCurrentManeuver() {

}
public ShipAIConfig getConfig() {
return null;
}
}, PickPriority.MOD_SPECIFIC);
}
Thank you very much Alex, this worked perfectly!
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5754 on: November 26, 2019, 08:18:02 AM »

So if I were to do something crazy like this:
Code
    public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {
            stats.getHighExplosiveShieldDamageTakenMult().modifyMult(id, 4);
            stats.getKineticShieldDamageTakenMult().modifyMult(id, 0);
    }
How much awareness would the AI have that it should fire HE at that ship's shields rather than kinetic? I feel like the answer was "none" long ago, but I was hoping that might've changed.


Thankings you muchly!
No problem  :)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5755 on: November 26, 2019, 08:32:10 AM »

Yeah, the answer is "none", unfortunately. It's aware of shield efficiency and base vs-shields damage type modifiers, but not modifiers to those modifiers. Even if it were, that'd be another step to something that's qualitatively different than a change by some smaller percentage. Autofiring weapons are not aware of either (since it's not the individual weapon's job to decide), and the ship AI will largely just let stuff autofire while it feels it has flux to burn. There are other considerations there, but none of them are damage type modifiers vs a particular target.
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5756 on: November 26, 2019, 08:52:12 AM »

Ok, gotcha. Thanks!

Nerzhull_AI

  • Commander
  • ***
  • Posts: 186
  • Do you exist in your dreams?
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5757 on: November 26, 2019, 02:50:37 PM »

In vanilla settings.json, at plugins section, there's following lines:
Code
"newGameCreationEntryPoint":"data.scripts.world.SectorGen",
"newGameSectorProcGen":"com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen",

My mod should override SectorProcGen and SectorGen. In mod's setting file i've put following lines:
Code
"plugins":{        
        "newGameSectorProcGen":"data.scripts.SectorProcGenMod",
        "newGameCreationEntryPoint":"data.scripts.world.SectorGenMod",
    },
It works for SectorProcGenMod, but doesn't for SectorGenMod. Why?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5758 on: November 26, 2019, 04:18:39 PM »

Are any other mods enabled? If multiple mods try to override a plugin this way the results are undefined (in practice, they depend on mod load order).
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5759 on: November 26, 2019, 09:28:51 PM »

How can you check if a ship currently has the zero flux boost? I'd check if flux == 0 but there are some boosts that make it not actually 0.
Logged
Pages: 1 ... 382 383 [384] 385 386 ... 706