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)

Author Topic: Error editing skills  (Read 2708 times)

BlueskiN1980

  • Ensign
  • *
  • Posts: 2
    • View Profile
Error editing skills
« on: May 24, 2017, 02:30:46 PM »

Hello,
Sorry for making a separate topic on such a trivial issue - I tried following 2 different pieces of advice found here in the big thread, but no dice so far.

I'm trying to make a little mod that changes when and how bonuses from skills are applied. I used to do this pre- 0.8 when skill files weren't compiled and in the main game folder, but now they're in a jar file and it seems trickier to apply changes.

So, I made a mod folder with a mod_info.json file that says:
Spoiler
{
    "id": "mz_opskills",
    "name": "OP Skills",
    "author": "BlueskiN1980",
    "version": "0.1",
    "description": "A set of simple edits to skills governing ship performance in combat, designed to make them slightly more powerful than intended.",
    "gameVersion": "0.8a",
}
[close]

then I copied - for starters - 6 .skill files to mymodfolder\data\characters\skills and edited them to point at my script files like "script":"data.characters.skills.scripts.FleetLogistics$Level1"

then, I put those .java files into mymodfolder\data\characters\skills\scripts
and edited them to adjust relavent values like MAINTENANCE_COST_REDUCTION and so on.

From what I understand, a proper directory structure should be enough to make it work without compiling a .jar file because the game will compile those .java files for me. And here comes the problem:

After loading assets and clearing buffers, just before the main menu, I keep getting a crash and the following entry in the log file:

Spoiler
13054 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.characters.skills.scripts.GunneryImplants$Level1]
java.lang.RuntimeException: Error compiling [data.characters.skills.scripts.GunneryImplants$Level1]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.characters.skills.scripts.GunneryImplants$Level1
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

So is it because of an improper directory structure of my mod or should I compile the changed files into a .jar? I'm sorry if it's a stupid question, but I'm not a programmer, just a big fan of tinkering. Thank you in advance for any advice that might help me!
« Last Edit: May 24, 2017, 02:32:49 PM by BlueskiN1980 »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Error editing skills
« Reply #1 on: May 24, 2017, 02:59:19 PM »

IIRC this is because Janino (the compiler the game uses to compile .java files on startup) can't handle inner classes like this. If you move each skill's effect to a separate .java file, I believe what you're doing should work (or, at least, expose some other problems).
Logged

isaacssv552

  • Commander
  • ***
  • Posts: 215
    • View Profile
Re: Error editing skills
« Reply #2 on: May 24, 2017, 03:08:27 PM »

Hello,
Sorry for making a separate topic on such a trivial issue - I tried following 2 different pieces of advice found here in the big thread, but no dice so far.

I'm trying to make a little mod that changes when and how bonuses from skills are applied. I used to do this pre- 0.8 when skill files weren't compiled and in the main game folder, but now they're in a jar file and it seems trickier to apply changes.

So, I made a mod folder with a mod_info.json file that says:
Spoiler
{
    "id": "mz_opskills",
    "name": "OP Skills",
    "author": "BlueskiN1980",
    "version": "0.1",
    "description": "A set of simple edits to skills governing ship performance in combat, designed to make them slightly more powerful than intended.",
    "gameVersion": "0.8a",
}
[close]

then I copied - for starters - 6 .skill files to mymodfolder\data\characters\skills and edited them to point at my script files like "script":"data.characters.skills.scripts.FleetLogistics$Level1"

then, I put those .java files into mymodfolder\data\characters\skills\scripts
and edited them to adjust relavent values like MAINTENANCE_COST_REDUCTION and so on.

From what I understand, a proper directory structure should be enough to make it work without compiling a .jar file because the game will compile those .java files for me. And here comes the problem:

After loading assets and clearing buffers, just before the main menu, I keep getting a crash and the following entry in the log file:

Spoiler
13054 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.characters.skills.scripts.GunneryImplants$Level1]
java.lang.RuntimeException: Error compiling [data.characters.skills.scripts.GunneryImplants$Level1]
   at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: data.characters.skills.scripts.GunneryImplants$Level1
   at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:179)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 2 more
[close]

So is it because of an improper directory structure of my mod or should I compile the changed files into a .jar? I'm sorry if it's a stupid question, but I'm not a programmer, just a big fan of tinkering. Thank you in advance for any advice that might help me!
I can confirm that compiling the files into a .jar works. If you make major changes you should also check that the type given in the .skill file corresponds with the type used in the .java file. e.g. if the script is a fleetwide boost don't use the "SHIP" type.
Logged

BlueskiN1980

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Error editing skills
« Reply #3 on: May 24, 2017, 03:20:35 PM »

Thank you very much for your answers! I'll try separating the effects into different files first, if not - maybe it's time to learn compiling jars.
Logged