Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 436 437 [438] 439 440 ... 711

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

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6555 on: June 21, 2020, 05:56:20 AM »

So I'm at a loss trying to get Shared Flux to work on a individual ship basis.
I tried:
Code
package data.scripts;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.impl.hullmods.SharedFluxSink;

public class SharedShipFluxSink extends SharedFluxSink {

@Override
public void advanceInCombat(ShipAPI ship, float amount) {
super.advanceInCombat(ship, amount);

if (!ship.isAlive()) return;

CombatEngineAPI engine = Global.getCombatEngine();

String key = SINK_DATA_KEY + "_" + ship.getId();

FluxSinkData data = (FluxSinkData) engine.getCustomData().get(key);
if (data == null) {
data = new FluxSinkData();
engine.getCustomData().put(key, data);

for (ShipAPI module : ship.getChildModulesCopy()) {
if (module.getStationSlot() == null || !module.isAlive() || !Misc.isActiveModule(module)) continue;
float d = module.getMutableStats().getFluxDissipation().getModifiedValue();
d *= FLUX_FRACTION;
data.dissipation.put(module, d);
}
}
}
}
But then I get
Code
java.lang.RuntimeException: Error compiling [data.scripts.SharedShipFluxSink]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/scripts/SharedShipFluxSink.java', Line 37, Column 26: Member with "/*default*/" access cannot be accessed from type "data.scripts.SharedShipFluxSink".
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
I dislike bumping, but I've failed to make progress on this front still, and now it is become irritant :P

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6556 on: June 21, 2020, 10:07:00 AM »

Which line is line 37?

The error is saying that you're trying to access a data member that was declared without a public/protected/private modifier (which IIRC defaults to protected? Honestly, I kind of forget). But since it's Janino (and not a proper IDE), it could also be something going wrong with it...
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6558 on: June 21, 2020, 02:44:55 PM »

Right, so that means you can't access data.dissipation due to it having the default access modifier. Easiest way around it is probably to make your own copy of that class, too.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6559 on: June 21, 2020, 02:57:15 PM »

Thanks, will try that now!
EDIT: That worked a charm, thanks a million!

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6560 on: June 22, 2020, 03:44:59 AM »

Is there a way to set a ship's fighter replacement rate?
Logged

Professor Pinkie

  • Ensign
  • *
  • Posts: 23
  • Best cupcakes in a sector!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6561 on: June 22, 2020, 04:54:21 AM »

Hello again!

I encountered a problem, trying to create a chain of station modules, something like that:

Main hull -> module A -> module B -> module C.

The point is that if a player loses module C, he still has others, but if he loses module A, then all subsequent modules destroyed with it.

The problem is that the game persistently loads only the main hull and module A, but not the subsequent ones. I suspect that I ran into a wall of vanilla functionality. So the question is: am I doing something wrong or is an additional plugin really needed here? All the same, I would like to stay within the vanilla, if possible.

Thank you!
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6562 on: June 22, 2020, 05:27:52 AM »

I encountered a problem, trying to create a chain of station modules, something like that:

Main hull -> module A -> module B -> module C.

The point is that if a player loses module C, he still has others, but if he loses module A, then all subsequent modules destroyed with it.
You can't stack modules on other modules. There is a workaround: you make each module a child of the mothership, then use code to change their positions every frame. Chain-reaction destruction has to be coded manually too.

Here's a guide how to do it.
Logged

Professor Pinkie

  • Ensign
  • *
  • Posts: 23
  • Best cupcakes in a sector!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6563 on: June 22, 2020, 06:14:12 AM »

Sir, this is exactly what I need!

Unfortunately, I barely understand Java, and therefore I can hardly reproduce the logic. Can I just steal this splendor "symbol to symbol"? However, even in this case I’m not sure that I will succeed. Worth to try.
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6564 on: June 22, 2020, 06:59:16 AM »

Be my guest.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6565 on: June 22, 2020, 07:03:16 AM »

So open question: What do the various columns in hullmods.csv do? The wiki is quite outdated.
Specifically, I'm unsure as to what tags and uitags accepts and does, and the difference between hidden and hiddeneverywhere.

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6566 on: June 22, 2020, 10:08:24 AM »

Is there a way to set a ship's fighter replacement rate?

Built in hullmod:

Code
MutableShipStatsAPI.getFighterRefitTimeMult()

So open question: What do the various columns in hullmods.csv do? The wiki is quite outdated.
Specifically, I'm unsure as to what tags and uitags accepts and does, and the difference between hidden and hiddeneverywhere.

A bit of guess, but I think "Hidden" prevents it from dropping or being sold in markets but it is still visible in the refit screen - like the XIV Battlegroup hullmod - while "HiddenEverywhere" makes the hullmod completely invisible yet still apply its effects.

tags I think is just for autofit and probably the ones that are visible under starsector core are the only ones - but again a guess.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6567 on: June 22, 2020, 11:53:28 AM »

Okay, weird compilation error:
Code
2312 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.hullmods.YunruFighterModules'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.hullmods.YunruFighterModules' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more
The reason it makes no sense is because, well, it's untrue:
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import java.util.List;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;

public class YunruFighterModules extends BaseHullMod {
    //////////
    // This section of code was taken largely from the Ship and Weapon Pack mod.
    // I did not create it. Credit goes to DarkRevenant.
    //////////
    private static void advanceChild(ShipAPI child, ShipAPI parent) {
        ShipEngineControllerAPI ec = parent.getEngineController();
        /* Mirror parent's fighter commands */
        if (child.hasLaunchBays()) {
            if (parent.getAllWings().size() == 0 && (Global.getCombatEngine().getPlayerShip() != parent || !Global.getCombatEngine().isUIAutopilotOn()))
                parent.setPullBackFighters(false); // otherwise module fighters will only defend if AI parent has no bays
            if (child.isPullBackFighters() ^ parent.isPullBackFighters()) {
                child.giveCommand(ShipCommand.PULL_BACK_FIGHTERS, null, 0);
            }
            if (child.getAIFlags() != null) {
                if (((Global.getCombatEngine().getPlayerShip() == parent) || (parent.getAIFlags() == null))
                        && (parent.getShipTarget() != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                } else if ((parent.getAIFlags() != null)
                        && parent.getAIFlags().hasFlag(AIFlags.CARRIER_FIGHTER_TARGET)
                        && (parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET) != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET));
                } else if (parent.getShipTarget() != null){
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                }
            }
        }
    }
}

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6568 on: June 22, 2020, 11:56:56 AM »

Okay, weird compilation error:
Spoiler
Code
2312 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
java.lang.RuntimeException: Error compiling [data.scripts.hullmods.YunruFighterModules]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.hullmods.YunruFighterModules'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.hullmods.YunruFighterModules' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more
[close]
The reason it makes no sense is because, well, it's untrue:
Spoiler
Code
package data.scripts.hullmods;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.*;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
import java.util.List;
import com.fs.starfarer.api.combat.ShipEngineControllerAPI.ShipEngineAPI;

public class YunruFighterModules extends BaseHullMod {
    //////////
    // This section of code was taken largely from the Ship and Weapon Pack mod.
    // I did not create it. Credit goes to DarkRevenant.
    //////////
    private static void advanceChild(ShipAPI child, ShipAPI parent) {
        ShipEngineControllerAPI ec = parent.getEngineController();
        /* Mirror parent's fighter commands */
        if (child.hasLaunchBays()) {
            if (parent.getAllWings().size() == 0 && (Global.getCombatEngine().getPlayerShip() != parent || !Global.getCombatEngine().isUIAutopilotOn()))
                parent.setPullBackFighters(false); // otherwise module fighters will only defend if AI parent has no bays
            if (child.isPullBackFighters() ^ parent.isPullBackFighters()) {
                child.giveCommand(ShipCommand.PULL_BACK_FIGHTERS, null, 0);
            }
            if (child.getAIFlags() != null) {
                if (((Global.getCombatEngine().getPlayerShip() == parent) || (parent.getAIFlags() == null))
                        && (parent.getShipTarget() != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                } else if ((parent.getAIFlags() != null)
                        && parent.getAIFlags().hasFlag(AIFlags.CARRIER_FIGHTER_TARGET)
                        && (parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET) != null)) {
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getAIFlags().getCustom(AIFlags.CARRIER_FIGHTER_TARGET));
                } else if (parent.getShipTarget() != null){
                    child.getAIFlags().setFlag(AIFlags.CARRIER_FIGHTER_TARGET, 1f, parent.getShipTarget());
                }
            }
        }
    }
}
[close]

It *might* be because you are missing this import:

Code
import com.fs.starfarer.api.combat.BaseHullMod;

Which is what your class is attempting to extend.

*Edit* Ah ok upon a second look I see you technically import the entire combat directory so maybe not, but it might be worth a try to make an explicit import just in case the compiler likes that better for some reason. Other than that I have no clue lol.
« Last Edit: June 22, 2020, 11:59:46 AM by Morrokain »
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6569 on: June 22, 2020, 12:03:28 PM »

First off; oof, how'd I miss that?
Second, the error still occurs, with the same report, sadly.

EDIT: I have to have a duplicate somewhere, because I changed the name and it's coming up with the exact same report, including filename.
Pages: 1 ... 436 437 [438] 439 440 ... 711