Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Mod Request : Increased Flagship Ordanance Points  (Read 4666 times)

Kreldin Foxclaw

  • Ensign
  • *
  • Posts: 13
    • View Profile
Mod Request : Increased Flagship Ordanance Points
« on: August 28, 2019, 11:33:58 PM »

Greetings, and thanks for taking the time to read this.

I recently got into the game in the last week or so, and after an extremely rocky start and a few swearwords have rapidly come to love the game. Added a number of mods after about a half a day, and really enjoy the depth and breadth of the gameplay, both on and off the battlefield. I've played about 40 hours so far. Founded my first colony a few hours ago, starting to explore how to make it successful.

One of the things I'm enjoying the most is the ship outfitting, and seeing the difference having different setups makes to a ship and it's capabilities. I'm always fighting to squeeze the most out of every OP I can get my hands on, and never seem to have quite enough for what I want to do. For the most part, I like that. It's those hard decisions that really makes the choices worthwhile. However when it comes to my flagship, I find myself wishing I had a lot more OP to play with.

In Strategy games, particularly those with RPG elements, I've always leaned towards having one main wrecking ball of a unit with smaller units for support, as opposed to a mixed, balanced force. A paramount paragon of perfect power among practical but paltry peers with which to punish my pitiful enemies, and to focus my offence around. Such as NSC's Flagship for Stellaris, the Titans in Sins of a Solar Empire, or the Experimentals in Supreme commander, for example. I'm not looking for something massively overpowered, but more something that noticeably stands out from it's peers, that makes you think 'oshit' when you discover it, unless you have a similar superunit with which to counter it, thus resulting in a clash of titans and an epic and pivotal battle.

What I'm requesting specifically, is a mod that allows your fleet flagship to have greatly increased OP, perhaps something like 100% (or 90%, since the skilltree has 10% to all ships anyway). I dont feel this would lead to unkillable ships, since you're still limited to your weapon slots, flux venting, and the fact that there's really very few stacking bonuses among hullmods. But, with the extra OP to play with, it would allow your flagship to not have to compromise on choice, and to take the range of upgrades that lets it really shine and stand out above the rank and file in a battle.

The only real suggestions I have for this are either a hullmod that can only be applied to a Flagship (possibly increasing the monthly maintenance to account for the extra complexity of the then upgraded ship), or a modified or new skill in the skill tree that allows for this.

I haven't the first clue how to implement a mod like this, or even if it's possible, as my modding and coding experience runs to a grand total of 3 stellaris mods, each of which only change a single line of code. Unfortunately, while I have a lot of free time, my home life is stressful and not conducive to learning. If someone were able to help me with this, I could  at least probably give them something for the trouble and time spent.

I'd really appreciate any input on this, even if it's just to tell me its a silly idea, or unbalanced in either direction.

Thankyou for your time,

Kreldin.
Logged

Dostya

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #1 on: August 29, 2019, 10:21:58 AM »

What you're asking for is possible isasmuch as you can create a skill that'll give the flagship of whoever's using it more ordnance points. It is not possible to limit it to the player, so you'll be prone to running into AI ships that have as much ordnance as your ship does. You can manage it fairly simply. I'm going to run through modifying an existing skill because it's easier all around, but you can delve deeper if you want.

Go into starsector-core and open starsector.api.zip, go down the path until you're in starfarer.api.zip\com\fs\starfarer\api\impl\campaign\skills\

Open up ship design - one of those skills involves changing ship ordnance points. Also, you now know where to find script implementations of everything in Starsector so there's that. Now, go into starsector-core\data\characters\skills (not in the zip file). Add a new folder named scripts.

Pick out the skill you think this'll fit in. Now, without some shenanigans you'd need to compile a new .jar to make this work, but we can slot it in pretty easily thanks to Starsector's previous implementation of skill scripting. You'll want to add

Code
{"type":"SHIP", "script":"data.characters.skills.scripts.flagshipordnance"},

 to the line of whichever level you want the flagship skill to take effect in.

Go into the scripts folder. Make a new file called flagshipordnance.java

Code
package data.characters.skills.scripts;

import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;

public class flagshipordnance implements FleetStatsSkillEffect {

public void apply(MutableCharacterStatsAPI stats, String id, float level) {
stats.getShipOrdnancePointBonus().modifyFlat(id, [YOUR NUMBER]f);
}

public void unapply(MutableCharacterStatsAPI stats, String id) {
stats.getShipOrdnancePointBonus().unmodify(id);
}

public String getEffectDescription(float level) {
return "Increases flagship ordnance points by [YOUR NUMBER]";
}

public String getEffectPerLevelDescription() {
return null;
}

public ScopeDescription getScopeDescription() {
return ScopeDescription.SHIP;
}
}

That should do the trick. You can apply most of this to modifying current skills, though creating new ones outright is a bit more involved. The usual caveats about untested code apply. I may have made a typo somewhere but if you're familiar with programming syntax errors should be readily fixable - just open up starsector.log in the starsector-core folder and unfuck whatever I messed up.

Ordinarily the ordnance point bonus is along the lines of
Code
stats.getShipOrdnancePointBonus().modifyPercent(id, OP_BONUS);
So if modifyFlat doesn't work copy the old line in and change the bonus to 100f. Or something along those lines. You'll probably want to do some testing.
« Last Edit: August 29, 2019, 10:24:15 AM by Dostya »
Logged

Kreldin Foxclaw

  • Ensign
  • *
  • Posts: 13
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #2 on: August 29, 2019, 02:33:39 PM »

Thank you very much for the help on this. It's taking me some time to understand the code, since I have zero experience with coding, but your instructions are very clear, and i'll give them a try this evening and let you know how it goes.
Logged

Kreldin Foxclaw

  • Ensign
  • *
  • Posts: 13
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #3 on: August 29, 2019, 05:21:52 PM »

Greetings, and thanks again for the help. After some initial confusion due to a misread, I implemented the changes/additions as directed, and opted to go for a %age increase over a flat one, to better balance smaller flagships.

Upon starting the game up, it crashed while loading, giving me the following error: https://i.imgur.com/9ZCtIAP.png, requiring me to change 'FleetStatsSkillEffect' to 'CharacterStatsSkillEffect' to match the wording in ShipDesign.java

Starting the game up again gave me a different error : https://i.imgur.com/TGuoKtU.png, requireing me to change 'ScopeDescription.SHIP' to 'ScopeDescription.PILOTED_SHIP' in an attempt to match the wording for the commander's piloted flagship (found from MissileSpecialization.java).

This time the game loaded fine, and I loaded into my save also with no issues. I opened the refit window, which was selected to one of my tankers, but upon selecting my flagship, the game hung for a moment, then crashed with an error message simply telling me to check the logfile. The only line that seemed relevent was the last one, stating :

'89846 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException
java.lang.ClassCastException'

I am unsure what the issue here may be, or how to approach solving it, so any further assistance would be appreciated.
Logged

Dostya

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #4 on: August 29, 2019, 06:31:50 PM »

Did the rest of the error look roughly akin to this by any chance?

Code
53209 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ClassCastException: data.characters.skills.scripts.SDL4 cannot be cast to com.fs.starfarer.api.characters.ShipSkillEffect
java.lang.ClassCastException: data.characters.skills.scripts.SDL4 cannot be cast to com.fs.starfarer.api.characters.ShipSkillEffect
at com.fs.starfarer.loading.SkillSpec$SkillEffectSpec.oO0000(Unknown Source)
at com.fs.starfarer.campaign.CharacterStats.applyPersonalToStats(Unknown Source)
*snip*
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)

EDIT: Actually, I'm all but certain it did. Reviewing the API it looks like you can increase ordnance points fleetwide, but not on a per-ship basis. Sorry for the waste of time.
« Last Edit: August 29, 2019, 06:40:48 PM by Dostya »
Logged

Kreldin Foxclaw

  • Ensign
  • *
  • Posts: 13
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #5 on: August 29, 2019, 06:54:46 PM »

Not a waste of time at all, I've learned a great deal in a short span of time, and had fun poking code. It also given me an idea. There's a modded Hullmod that actually grants extra OP, at the cost of a significant chance of malfunction in combat. Is there a way of adding a similar hullmod, that provides either a % increase to OP, or a flat amount based on class, then limiting it so that either A) Only flagships can equip the hullmod, B) Only the player has access to the hullmod in question (to prevent the AI from slapping them on all ships if (A) fails) or, C) both (For balance purposes on a public release of the mod if the AI running around with Boosted OP ships becomes problematic.)
« Last Edit: August 29, 2019, 06:56:28 PM by Kreldin Foxclaw »
Logged

Dostya

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #6 on: August 29, 2019, 07:24:54 PM »

Absent modifying the game with some dedicated compiled scripts, not to my knowledge.
Logged

Kreldin Foxclaw

  • Ensign
  • *
  • Posts: 13
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #7 on: August 29, 2019, 07:54:35 PM »

How difficult would it be to create an event, or say, a quest where the reward is a the Op boosting hullmod as a blueprint? that way, the only way to get the blueprint, and thus the hullmod, would be by completing that quest, preventing the AI from getting it. Are there currently any hullmods only the player has access to?
Logged

Dostya

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #8 on: August 30, 2019, 12:09:02 AM »

The only thing that the player has access to that the AI doesn't is AFAIK buildings, barring Nexerelin on that last one. Everything else, to the best of my knowledge, is mixed into a randomizer somewhere. In terms of creating an event or a quest, assuming you're willing to get into scripting, not overly difficult. You will need to script the effects of any new hullmod. Adding in a means of increasing flagship OP is far more difficult since you'd have to add to the API outright instead of taking advantage of existing tools. I'd advise looking into the vanilla mission generators in starfarer.api.zip\com\fs\starfarer\api\impl\campaign\missions\ as well as the tutorials in Modding Resources to get into script compilation. As well, you should hop into the Discord channel and ask around in the modding channels when you get stuck. Vayra's gotten into adding a mission and bounty framework in Vayra's Sector that'll probably be easier than coding from scratch, though you'll have to hit him up on questions about that since I haven't even glanced at it.

I really do recommend the Discord. You're hitting the limits of where I've gone in Starsector and there are many tools, resources, and much willing help in the rest of community available to call on. Have fun.
Logged

Kreldin Foxclaw

  • Ensign
  • *
  • Posts: 13
    • View Profile
Re: Mod Request : Increased Flagship Ordanance Points
« Reply #9 on: August 30, 2019, 12:18:11 AM »

Thanks, utilising the discord server isnt something that had occoured to me, I'll take a look at it soon. Currently i've kind of hacked in a possible method, by modifying the file for ShadowDragon8685's Relaxed logistics to make the Solar Shielding (something I never bother with anyway) to cost -30/-60/-90/-150, since according to that modpage, the AI don't use logistics mods, partly since supplies and fuel arent things they consume. I've yet to see enemy ships with the hullmod, though it's only been a few months ingame. I'm going to keep an eye out for it. If, as I suspect, the AI never use the Solar shielding because it's a logistics mod, despite the modified OP cost, then problem pretty much solved, since I can just apply it to my flagship, and ignore it on other ships, since it wasnt ever really worth the OP to me anyway.

Thanks again for all your assistance, you've really helped me get a bearing on how to go about looking into this.
« Last Edit: August 30, 2019, 12:19:45 AM by Kreldin Foxclaw »
Logged