Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 502 503 [504] 505 506 ... 710

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

Kenshkrix

  • Ensign
  • *
  • Posts: 46
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7545 on: June 07, 2021, 11:30:24 PM »

hey i was trying to do something crazy with hull mods.
in fact i was trying to do a few things.
dose anyone know how to:
make a hullmod place other hullmods on a ship when it is install.
    -i saw a mod that added a hullmod, forget its name, that only installed when equipping a gun on ship, so i know this is possable. no idea were to find it though, so i cant use it as a base
tell when a given hullmod is 'built in' (with story points) on a ship.
Most of the functions you're looking for are in the ShipVariantAPI (link is to the online API).
The addMod/addPermaMod and getSMods functions, in particular.

When making a hullmod you can access the ShipVariantAPI from the MutableShipStatsAPI found in the applyEffectsBeforeShipCreation function by using stats.getVariant()
If you want some specific functionality demonstrated, I could write up an example when I have free time later.

make a hullmod interface with a fleet to add crew to it (for calculating things like planet surveys, or salvaging), but not be real crew?
Making fake crew that only function for certain events would require something along the lines of setting up a dynamic stat and rewriting the corresponding plugins to take it into account.
It would probably be easier to just reduce the requirements/cost instead.
In regards to surveying it unfortunately doesn't take crew into account outside of the total multiplier, but if you don't mind reducing every cost it would work as-is.

I haven't looked into the salvaging functions very much, so I can't help with that part.
Logged

Sutopia

  • Admiral
  • *****
  • Posts: 1005
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7546 on: June 08, 2021, 12:05:46 AM »

How do I get wing's base speed from FighterWingSpecAPI?

Something like wing.getVariant().getHullSpec(). ... huh, it doesn't look like that's actually exposed there! Let me add a .getEngineSpec() method.

That wouldn't give you the true in-combat speed necessarily, though, if it was modified for that variant via a hullmod. If you're doing this in combat, you'd want to ultimately get hold of a ShipAPI for one of the fighters and get it from that.

Thanks!

I was trying to add tooltip regarding if certain bonuses apply. For context, to determine if a bomber is a bomb-bay type (Flash, Piranha). To cover mod fighters I tried using derived weapon ROF, max ammo to see how long it takes to deplete the arsenal, and compare it against the weapon range divided by bomber base speed. If bombing would take something like 75% of the travel time through full range it qualifies as a bay bomber and get additional bonuses, etc etc.

I want to display this info to player so they are well informed about these additions.
Logged


Since all my mods have poor reputation, I deem my efforts unworthy thus no more updates will be made.

AppleMarineXX

  • Lieutenant
  • **
  • Posts: 57
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7547 on: June 08, 2021, 12:30:24 AM »

I'm trying to make a custom star system. My original attempt failed miserably, so I tried to start from scratch and just make a simple star.
But even that was too hard for me, apparently.

I have the code below, but the star still isn't spawning in vanilla. My other files (WorldGen, AddMarketPlace, and ModPlugin.java) don't seem to be the issue, I compared them to other mods and they seem to be about the same.

package data.scripts.world;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Entities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.ids.Terrain;
import com.fs.starfarer.api.impl.campaign.procgen.NebulaEditor;
import com.fs.starfarer.api.impl.campaign.procgen.PlanetConditionGenerator;
import com.fs.starfarer.api.impl.campaign.procgen.StarAge;
import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;


public class UNSCStar {

   public void generate(SectorAPI sector) {
        StarSystemAPI system = sector.createStarSystem("ABCD");
        system.getLocation().set(1000,1000);
        PlanetAPI ABCD_star = system.initStar("UNSCStar",
                "star_orange",//set star type, the type IDs come from starsector-core/data/campaign/procgen/star_gen_data.csv
                900, //set radius, 900 is a typical radius size
                1000); //radius of corona terrain around star
            

   system.autogenerateHyperspaceJumpPoints(true, true);

    }



}

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7548 on: June 08, 2021, 04:05:20 AM »

Apologies for the inconvenience, but I have another script I'm having trouble.

I pieced this together to do two things: Double the OP cost of fighters, and double the wing size of fighters. Unfortunately, while it doesn't crash, it also doesn't do either of those things.
Code
package data.scripts;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;

public class YunruTwinWings extends BaseHullMod {
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

        stats.getDynamic().getMod(Stats.ALL_FIGHTER_COST_MOD).modifyMult(id, 2);

        ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
ship = (ShipAPI) stats.getEntity();
} else {
return;
}
       
        for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
            if (bay.getWing() == null) continue;
           
            FighterWingSpecAPI spec = bay.getWing().getSpec();
           
            int newWings = 2*spec.getNumFighters();

            bay.getWing().getSpec().setNumFighters(newWings);
        }
    }
   
    @Override
public boolean affectsOPCosts() {
return true;
}
}

Sutopia

  • Admiral
  • *****
  • Posts: 1005
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7549 on: June 08, 2021, 07:40:19 AM »

Apologies for the inconvenience, but I have another script I'm having trouble.

I pieced this together to do two things: Double the OP cost of fighters, and double the wing size of fighters. Unfortunately, while it doesn't crash, it also doesn't do either of those things.
Code
package data.scripts;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.loading.FighterWingSpecAPI;

public class YunruTwinWings extends BaseHullMod {
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

        stats.getDynamic().getMod(Stats.ALL_FIGHTER_COST_MOD).modifyMult(id, 2);

        ShipAPI ship = null;
if (stats.getEntity() instanceof ShipAPI) {
ship = (ShipAPI) stats.getEntity();
} else {
return;
}
       
        for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
            if (bay.getWing() == null) continue;
           
            FighterWingSpecAPI spec = bay.getWing().getSpec();
           
            int newWings = 2*spec.getNumFighters();

            bay.getWing().getSpec().setNumFighters(newWings);
        }
    }
   
    @Override
public boolean affectsOPCosts() {
return true;
}
}

I tried doing that but modifying the fighter count in spec would affect all wing of same type across the game. It also doesn’t work for setting fighter count larger than 6 the game just crashes.

Ah, right, right! The wing is only initialized when the ship is deployed. Something like this, then:

Code
for (String wingId : ship.getVariant().getFittedWings()) {
FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(wingId);
}
Logged


Since all my mods have poor reputation, I deem my efforts unworthy thus no more updates will be made.

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7550 on: June 08, 2021, 02:02:48 PM »

I'm trying to make a custom star system. My original attempt failed miserably, so I tried to start from scratch and just make a simple star.
But even that was too hard for me, apparently.

I have the code below, but the star still isn't spawning in vanilla. My other files (WorldGen, AddMarketPlace, and ModPlugin.java) don't seem to be the issue, I compared them to other mods and they seem to be about the same.

You have something like:

Code
new UNSCStar().generate(Global.getSector());

 - in your ModPlugin file correct?

You'd need it under:

Code
    @Override
    public void onNewGame()

Or, if you have it in your WorldGen file, then make sure you call that generate(sector) in your mod plugin under the same place.

Here is an example of mine:

ModPlugin:
Code
    @Override
    public void onNewGame() {
        initArcheus();
}

private static void initArcheus() {
    new archeusGen().generate(Global.getSector());
}

archeusGen file:
Code
    @Override
    public void generate(SectorAPI sector) {
        new Mordreath().generate(sector);
}
Logged

6chad.noirlee9

  • Captain
  • ****
  • Posts: 368
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7551 on: June 08, 2021, 04:13:43 PM »

Spoiler
Is it possible to check if a hullmods is s-modded?

Edit: Also, are default_ship_roles loaded on each start-up, or are they per-save?
If I remove the file from a mod, will that ship's mods stop spawning?

variant.getSMods().contains(mod id)

I believe it's loaded on each startup!

Spoiler
5338348 [Thread-3] INFO  com.fs.starfarer.api.impl.campaign.intel.SurveyPlanetMissionIntel  - Created SurveyPlanetMissionIntel: Bhelxiope, faction: Mayasura
5340199 [Thread-3] INFO  sound.oo0O  - Cleaning up music with id [Seeking_Answers.ogg]
5340207 [Thread-7] INFO  sound.oo0O  - Cleaning up music with id [Sovereignty.ogg]
5340314 [Thread-9] INFO  sound.oo0O  - Creating streaming player for music with id [Ambush.ogg]
5340319 [Thread-9] INFO  sound.OooO  - Playing music with id [Ambush.ogg]
5341292 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteSegment.isInSystem(RouteManager.java:141)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager$RouteData.getInterpolatedHyperLocation(RouteManager.java:379)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.shouldSpawn(RouteManager.java:651)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.spawnAndDespawn(RouteManager.java:617)
   at com.fs.starfarer.api.impl.campaign.fleets.RouteManager.advance(RouteManager.java:577)
   at com.fs.starfarer.api.impl.campaign.CoreScript.advance(CoreScript.java:128)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(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.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

got the above error when the bounty i was after was about to show up in campaign
i cant tell by looking what may be causing the error
was hoping someone else could point me in the right direction
i have a LOT of mods so......shot in the dark

Ahh, can't really say what mod it might be from. This looks like it's caused by a RouteSegment whose "from" entity was removed from the Sector entirely, which means it was probably a non-permanent object such as a fleet. Fixed up that particular crash on my end, but, right, impossible to tell from the stack trace what mod might've caused it, or, indeed, if it was a combination of mods, or a mod plus vanilla. For example, it looks like a mod doing seeming something unrelated (such as dynamically removing a planet) could cause this.

Is it possible to check if a hullmods is s-modded?
ShipVariantAPI has a getSMods() method, so you could presumably do a check against that.

(Right! Ninja'ed - I appreciate you taking the time to answer, that really helps me a lot.)
[close]

ah so i guess i will just have to check for updates and do some more testing
Logged
edit: edit: maybe were just falling with style LOL.  make a bubble, make the space in front of it smaller and just fall forward

AppleMarineXX

  • Lieutenant
  • **
  • Posts: 57
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7552 on: June 08, 2021, 06:10:59 PM »

Spoiler
I'm trying to make a custom star system. My original attempt failed miserably, so I tried to start from scratch and just make a simple star.
But even that was too hard for me, apparently.

I have the code below, but the star still isn't spawning in vanilla. My other files (WorldGen, AddMarketPlace, and ModPlugin.java) don't seem to be the issue, I compared them to other mods and they seem to be about the same.

You have something like:

Code
new UNSCStar().generate(Global.getSector());

 - in your ModPlugin file correct?

You'd need it under:

Code
    @Override
    public void onNewGame()

Or, if you have it in your WorldGen file, then make sure you call that generate(sector) in your mod plugin under the same place.

Here is an example of mine:

ModPlugin:
Code
    @Override
    public void onNewGame() {
        initArcheus();
}

private static void initArcheus() {
    new archeusGen().generate(Global.getSector());
}

archeusGen file:
Code
    @Override
    public void generate(SectorAPI sector) {
        new Mordreath().generate(sector);
}
[close]

I... think?

My ModPlugin (UNSCModPlugin) has:

Code
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

public class UNSCModPlugin extends BaseModPlugin

{

    public void onNewGame() {
        Global.getLogger(this.getClass()).info("Hooray My mod plugin in a jar is loaded! (UNSC)");
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UNSC");
        initUNSC();
    }

private static void initUNSC() {
        new UNSCWorldGen().generate(Global.getSector());
    }

}

And my gen file (UNSCWorldGen) goes as:

Code
package data.scripts.world;



import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;

public class UNSCWorldGen implements SectorGeneratorPlugin {
@Override
    public void generate(SectorAPI sector) {
SharedData.getData().getPersonBountyEventData().addParticipatingFaction("UNSC");
       
new UNSCStar().generate(sector);

    }



}

(And then my UNSCStar File)
Code
package data.scripts.world;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Entities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.ids.Items;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.impl.campaign.ids.Terrain;
import com.fs.starfarer.api.impl.campaign.procgen.NebulaEditor;
import com.fs.starfarer.api.impl.campaign.procgen.PlanetConditionGenerator;
import com.fs.starfarer.api.impl.campaign.procgen.StarAge;
import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
import com.fs.starfarer.api.impl.campaign.terrain.HyperspaceTerrainPlugin;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;


public class UNSCStar {

   public void generate(SectorAPI sector) {
        StarSystemAPI system = sector.createStarSystem("ABCD");
        system.getLocation().set(1000,1000);
        PlanetAPI ABCD_star = system.initStar("UNSCStar",
                "star_orange",//set star type, the type IDs come from starsector-core/data/campaign/procgen/star_gen_data.csv
                900, //set radius, 900 is a typical radius size
                1000); //radius of corona terrain around star


system.autogenerateHyperspaceJumpPoints(true, true);

    }



}

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7553 on: June 08, 2021, 07:03:24 PM »

I... think?

Looks right.

Only other things I can think of is that you haven't added the modPlugin file to the mod_info.json but then I'm not sure if the mod would even show up. The other thing would be needing to set the StarSystem type by:

Code
		system.setType(StarSystemType.NEBULA);

- before you call initStar().

I'm out of ideas after that sorry.  :(
Logged

AppleMarineXX

  • Lieutenant
  • **
  • Posts: 57
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7554 on: June 08, 2021, 09:51:45 PM »

I... think?

Looks right.

Only other things I can think of is that you haven't added the modPlugin file to the mod_info.json but then I'm not sure if the mod would even show up. The other thing would be needing to set the StarSystem type by:

Code
		system.setType(StarSystemType.NEBULA);

- before you call initStar().

I'm out of ideas after that sorry.  :(

It turns out that I forgot to add the modPlugin to the modinfo file. It runs now, but then crashes with the following error:

Fatal: Error loading [data.scripts.UNSCModPlugin]
Cause: File 'data/scripts/UNSCModPlugin.java', Line 18, Column 25:
Cannot determine simple type name 'UNSCWorldGen'
Check starsector.log for more info.

Where the log says:
Spoiler
java.lang.RuntimeException: Error loading [data.scripts.UNSCModPlugin]
   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/UNSCModPlugin.java', Line 18, Column 25: Cannot determine simple type name "UNSCWorldGen"
   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
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/UNSCModPlugin.java', Line 18, Column 25: Cannot determine simple type name "UNSCWorldGen"
   at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
   at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5398)
   at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:5207)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5188)
   at org.codehaus.janino.UnitCompiler.access$12600(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitReferenceType(UnitCompiler.java:5119)
   at org.codehaus.janino.Java$ReferenceType.accept(Java.java:2880)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:5675)
   at org.codehaus.janino.UnitCompiler.access$15000(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$16.visitNewClassInstance(UnitCompiler.java:5144)
   at org.codehaus.janino.Java$NewClassInstance.accept(Java.java:4082)
   at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)
   at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:7333)
   at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3873)
   at org.codehaus.janino.UnitCompiler.access$6900(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:3263)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
   at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:3290)
   at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:4368)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2662)
   at org.codehaus.janino.UnitCompiler.access$4400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$7.visitMethodInvocation(UnitCompiler.java:2627)
   at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:3974)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2654)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1643)
   at org.codehaus.janino.UnitCompiler.access$1100(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:936)
   at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2097)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:958)
   at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1007)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2293)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:822)
   at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:794)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:507)
   at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
   at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
   at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
   at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
   at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
   at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
   at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
   ... 5 more
[close]

I'm using Notepad++ right now, which seems to be an issue that has popped up in other threads...

EDIT
Guess which chucklenut forgot to add "import data.scripts.world.UNSCWorldGen;" to the ModPlugin file.
« Last Edit: June 08, 2021, 09:56:34 PM by AppleMarineXX »
Logged

alaricdragon

  • Commander
  • ***
  • Posts: 162
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7555 on: June 08, 2021, 11:20:49 PM »

hey i was trying to do something crazy with hull mods.
in fact i was trying to do a few things.
dose anyone know how to:
make a hullmod place other hullmods on a ship when it is install.
    -i saw a mod that added a hullmod, forget its name, that only installed when equipping a gun on ship, so i know this is possable. no idea were to find it though, so i cant use it as a base
tell when a given hullmod is 'built in' (with story points) on a ship.
Most of the functions you're looking for are in the ShipVariantAPI (link is to the online API).
The addMod/addPermaMod and getSMods functions, in particular.

When making a hullmod you can access the ShipVariantAPI from the MutableShipStatsAPI found in the applyEffectsBeforeShipCreation function by using stats.getVariant()
If you want some specific functionality demonstrated, I could write up an example when I have free time later.

make a hullmod interface with a fleet to add crew to it (for calculating things like planet surveys, or salvaging), but not be real crew?
Making fake crew that only function for certain events would require something along the lines of setting up a dynamic stat and rewriting the corresponding plugins to take it into account.
It would probably be easier to just reduce the requirements/cost instead.
In regards to surveying it unfortunately doesn't take crew into account outside of the total multiplier, but if you don't mind reducing every cost it would work as-is.

I haven't looked into the salvaging functions very much, so I can't help with that part.

thank you for the help and advice. because of this, my fist hullmod is about 95% complete. have not tried anything with the crew hullmod yet though.

regardless, I wish to ask this forums help once more. I have need of, in my hullmod script, getting the remaining OP that the ship has available, but i have no idea how to do so.

i found a function that might do what I want, but I have no idea how to use it
   getUnusedOP(MutableCharacterStatsAPI)
i found it in the ShipVariantAPI that was shown to me.
if anyone knows how to use it, or something else, to get unused op on a ship, i would be very grateful.
Logged

Kenshkrix

  • Ensign
  • *
  • Posts: 46
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7556 on: June 09, 2021, 07:19:15 AM »

regardless, I wish to ask this forums help once more. I have need of, in my hullmod script, getting the remaining OP that the ship has available, but i have no idea how to do so.

i found a function that might do what I want, but I have no idea how to use it
   getUnusedOP(MutableCharacterStatsAPI)
i found it in the ShipVariantAPI that was shown to me.
if anyone knows how to use it, or something else, to get unused op on a ship, i would be very grateful.
I don't know if this is the most concise way to do it, but here's an example for use on a hullmod that I got working:
int unusedOP = stats.getVariant().getUnusedOP(Global.getSector().getCharacterData().getPerson().getFleetCommanderStats());
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7557 on: June 09, 2021, 12:46:58 PM »

@AppleMarineXX If you are trying to add a nebula system, go download my Roider Union mod and look at my src/scripts/world/systems/Roider_Kiska.java code. You should copy the createNebula() and finalizeNebula() methods and use them in your system gen class the same way I did.
Logged

alaricdragon

  • Commander
  • ***
  • Posts: 162
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7558 on: June 09, 2021, 02:32:14 PM »

regardless, I wish to ask this forums help once more. I have need of, in my hullmod script, getting the remaining OP that the ship has available, but i have no idea how to do so.

i found a function that might do what I want, but I have no idea how to use it
   getUnusedOP(MutableCharacterStatsAPI)
i found it in the ShipVariantAPI that was shown to me.
if anyone knows how to use it, or something else, to get unused op on a ship, i would be very grateful.
I don't know if this is the most concise way to do it, but here's an example for use on a hullmod that I got working:
int unusedOP = stats.getVariant().getUnusedOP(Global.getSector().getCharacterData().getPerson().getFleetCommanderStats());
would that work on not player fleets?
Logged

Kenshkrix

  • Ensign
  • *
  • Posts: 46
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7559 on: June 09, 2021, 03:23:49 PM »

would that work on not player fleets?
No, you'd need to figure out where the MutableCharacterStatsAPI for that specific fleet is at, and then pass it into the getUnusedOP call from the ShipVariantAPI in question.
Something like this, maybe?
Code
int unusedOP = stats.getVariant().getUnusedOP(stats.getFleetMember().getFleetCommanderForStats().getFleetCommanderStats());
I haven't tested this, so I don't know if it works offhand.
Logged
Pages: 1 ... 502 503 [504] 505 506 ... 710