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 ... 368 369 [370] 371 372 ... 706

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

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5535 on: October 31, 2019, 02:58:35 PM »

Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.

Thank you!
Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5536 on: October 31, 2019, 03:12:30 PM »

Is there a way to reliably adjust maxShipsInAIFleet within the game, i.e. outside of directly editing settings.json? I threw the following piece of code together based very loosely on this means of adjusting maxIndustries:

Hmm, not really, no - the way it works for maxIndustries is... very situational. I did make some changes to SettingsAPI that makes it doable in the next release, though.

int maxShipsInAIFleet = Global.getSettings().getInt("maxShipsInAIFleet");
maxShipsInAIFleet = 30 + OverMax;

This doesn't actually do anything - "int maxShipsInAIFleet" is a local variable that is assigned the value returned by the getInt() method; changing it will not influence anything outside the method you're in.
Well, something more to look forward to in the next version of Starsector!

Yeah, I really doubted that it was affecting anything, but in my brief tests I was seeing fleets that go over the max and I wasn't sure what was responsible. It seems that if you set a faction's NumShips doctrine high enough, some fleets are not affected by the fleep cap. Thanks for your answer!

EDIT: Alternatively, is there some way in the API to reload settings.json? I know you can turn on DevMode -> Simulator -> Press F8, but I don't think that's something to be done while actually playing the game.

oiltanker

  • Ensign
  • *
  • Posts: 7
  • Regular person
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5537 on: October 31, 2019, 03:17:38 PM »

I am that type of guy that likes program logic more than text rule sets.
How do I create a salvage interaction upon selecting an option in InteractionDialogPlugin implementation?

Code example:
Code
@Override
public void optionSelected(OptionId option, String optionText) {
if (option == OptionId.INIT) {
dialogInit();
} else if ...
} else if (option == OptionId.CONFIRM_DECONSTRUCT) {
String locationType = null;
...

replaceEntity(playerFleet.getStarSystem(), target, locationType, Factions.NEUTRAL);
// TODO: Get some resources back through salvage                                                < ---- ---- ----
leaveDialog();
}
}
« Last Edit: October 31, 2019, 03:20:15 PM by oiltaker »
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5538 on: October 31, 2019, 07:36:20 PM »

Is there a good way to determine if a distant fleet would want to attack the player fleet if the two were close to each other? Failure to account for third parties wouldn't be a problem. Neither would only working for ModularFleetAIs. I thought this would do the trick, but I'm still getting false positives:
Code
npcFleet.getAI().pickEncounterOption(null, playerFleet, true) == CampaignFleetAIAPI.EncounterOption.ENGAGE

My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?
I hope so! The biggest obstacle would be changing the hull ID of module slots at runtime. Variants expose getStationModules(), which I think returns a map with slot IDs as keys and hull IDs as values. I don't know if it would work, but you might try overwriting those values. After that, you could add a hullmod to the core ship that checks which modules are installed to decide which effects to apply.

Thank you!
No problem  :)

How do I create a salvage interaction upon selecting an option in InteractionDialogPlugin implementation?
That depends on what you're trying to do. "Salvage interaction" is extremely ambiguous. You might try taking a look at some of the classes in com.fs.starfarer.api.impl.campaign.rulecmd.salvage

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5539 on: October 31, 2019, 07:59:13 PM »

My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?
I hope so! The biggest obstacle would be changing the hull ID of module slots at runtime. Variants expose getStationModules(), which I think returns a map with slot IDs as keys and hull IDs as values. I don't know if it would work, but you might try overwriting those values. After that, you could add a hullmod to the core ship that checks which modules are installed to decide which effects to apply.
Right now I am already having trouble getting the second part "checks which modules are installed to decide which effects to apply." to work, i can't use applyEffectBefore creation and neither applyEffectAfter so i don't know how to proceed. Tomorrow i will try using advanceInCampaign instead.
Logged
Check out my ships

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5540 on: October 31, 2019, 08:46:50 PM »

Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.

Right, yeah! But - use Gender.MALE and Gender.FEMALE - I don't think "ANY" will work here.

My objective would be having a modular ship and allow the player to swap any modules by some kind of dialogue option in a special station and have those modules change how the main ship operates, can that be done?

Hmm - maybe? I think you might have some problems if the player, say, saves off an autofit goal variant and then tries to apply it to a ship that has a different set of modules. That, I think, would likely cause a crash. But just as far as the effects you're talking about, that sounds doable with some built-in hullmods in the main body of the ship. In general, I'm not sure if this is 100% doable and/or will work smoothly, iirc some stuff assumes the module hull types don't change so it's... going against the grain, at best.

i can't use applyEffectBefore creation

Hmm, why not? I'd expect that's the one you'd want to use, it being the one that gets called in the campaign...


EDIT: Alternatively, is there some way in the API to reload settings.json? I know you can turn on DevMode -> Simulator -> Press F8, but I don't think that's something to be done while actually playing the game.

There isn't, no - some of the settings wouldn't take effect and it'd be a bit of a mess without a decent amount of code to help it along...




I am that type of guy that likes program logic more than text rule sets.
How do I create a salvage interaction upon selecting an option in InteractionDialogPlugin implementation?

Code example:
Code
@Override
public void optionSelected(OptionId option, String optionText) {
if (option == OptionId.INIT) {
dialogInit();
} else if ...
} else if (option == OptionId.CONFIRM_DECONSTRUCT) {
String locationType = null;
...

replaceEntity(playerFleet.getStarSystem(), target, locationType, Factions.NEUTRAL);
// TODO: Get some resources back through salvage                                                < ---- ---- ----
leaveDialog();
}
}


Something like:

dialog.setInteractionTarget(entity);
RuleBasedInteractionDialogPluginImpl plugin = new RuleBasedInteractionDialogPluginImpl("OpenInteractionDialog");
dialog.setPlugin(plugin);
plugin.init(dialog);

Would switch the dialog to another target ("entity") and fire off the initial interaction within the same dialog. Of course, that would use the rules specified in rules.csv for that interaction. If you want to avoid using rules.csv entirely, you'd have to re-code the salvage interaction from scratch, since the vanilla one is implemented using rules.csv.


Is there a good way to determine if a distant fleet would want to attack the player fleet if the two were close to each other? Failure to account for third parties wouldn't be a problem. Neither would only working for ModularFleetAIs. I thought this would do the trick, but I'm still getting false positives:
Code
npcFleet.getAI().pickEncounterOption(null, playerFleet, true) == CampaignFleetAIAPI.EncounterOption.ENGAGE

That should work, actually; it's the method the fleets use when deciding to pursue or run away under the hood, too. The results *are* cached for 3 seconds, btw, so maybe that accounts for some discepancies?
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5541 on: October 31, 2019, 09:05:57 PM »

Code: java
WeightedRandomPicker<String> portriatIDs = Global.getSector().getFaction(Factions.PLAYER).getPortraits(FullName.Gender.ANY);
From there, you should be able to modify portraitIDs any way you like.

Right, yeah! But - use Gender.MALE and Gender.FEMALE - I don't think "ANY" will work here.


Thanks for the clarification! :)- I am working on getting this into the next update alongside faction-specific blueprints based upon commission status.
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5542 on: October 31, 2019, 09:36:21 PM »


i can't use applyEffectBefore creation

Hmm, why not? I'd expect that's the one you'd want to use, it being the one that gets called in the campaign...

Do the modules exist during applyEffectBefore? Aren't they added on after the ship is created? Also how to get the ship through stats again?
Logged
Check out my ships

oiltanker

  • Ensign
  • *
  • Posts: 7
  • Regular person
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5543 on: November 01, 2019, 03:37:32 AM »

Is there a way to open a faction setup dialog (as when starting the first colony) inside InteractionDialogPrlugin implementation?
Is it possible to prompt player input string (like when prompting for a colony name) in same circumstances?
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 #5544 on: November 01, 2019, 05:04:14 AM »


So I've just done this several times with several tweaks and it's still not making sense. Here's the breakdown of the outputs that occur.

Ahh, I mean starsector.log, not the on-screen output in the game.

Thanks for that. I figured out the problem was the game was not acknowledging the $tag, and changed it appropriately. Now I've run into two problems.

The first is a nullPointerException soft lock on salvaging. This is because I'm trying to use-
Code
salvage.addSpecial(new SpecialItemData("hullmod", "hmi_subliminal"), 1);
-to add a hullmod blueprint of a hullmod. However, the game doesn't recognise it. I think it's because 'hullmod' isn't the right term for what I'm trying to add. What is the correct classification for a hullmod blueprint?

The second is the actual defender fleet. I have no idea how to do this. I was under the impression I could use DefenderPluginOverride in the system gen file to get what I want, but it's clear the system I have set up doesn't acknowledge the defenders and skips straight to the salvage. I've looked at SalvageGenFromSeed, and I can't make heads or tales of it due to SalvageDefenderModificationPluginImpl being buried inside it, meaning I'm unsure what to extend. Could anyone help me with this please?

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5545 on: November 01, 2019, 06:54:48 AM »

I have a rather simple hullmod that doubles energy weapon damage (side question: do beams count as energy weapons? I ask because they have their own entry) but increases flux by 1.5x.

It works fine, but how do I get the changes to be displayed in the refit screen (as currently it only shows the base damage and base flux)?

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5546 on: November 01, 2019, 05:43:09 PM »

Really need help getting the modules during advanceInCampaignor applyEffectsBeforeShipCreation, nothing i do work, i don't even get a crash, just nothing happens, here my current attempt

Code
public void advanceInCampaign(FleetMemberAPI member, float amount) {
    super.advanceInCampaign(member, amount);
    MutableShipStatsAPI stats = member.getStats();
    if(stats != null && stats.getEntity() instanceof ShipAPI) {
    ShipAPI ship = (ShipAPI) stats.getEntity();
    if(ship != null) {
    List<ShipAPI> modules = ship.getChildModulesCopy();
        float cargo = 0;
            if(modules != null) {
            for(ShipAPI m : modules) {
            //todo check the type of wagon
            cargo += 1000f;
            }
            }
            stats.getCargoMod().modifyFlat("trainCargoBonus", cargo);
    }   
    }   
    }
Logged
Check out my ships

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5547 on: November 01, 2019, 06:02:57 PM »

Is there a way to open a faction setup dialog (as when starting the first colony) inside InteractionDialogPrlugin implementation?
Is it possible to prompt player input string (like when prompting for a colony name) in same circumstances?

See: CampaignUIAPI.showPlayerFactionConfigDialog()

The first is a nullPointerException soft lock on salvaging. This is because I'm trying to use-
Code
salvage.addSpecial(new SpecialItemData("hullmod", "hmi_subliminal"), 1);
-to add a hullmod blueprint of a hullmod. However, the game doesn't recognise it. I think it's because 'hullmod' isn't the right term for what I'm trying to add. What is the correct classification for a hullmod blueprint?

See: special_items.csv for the correct ID. (It's "modspec")


The second is the actual defender fleet. I have no idea how to do this. I was under the impression I could use DefenderPluginOverride in the system gen file to get what I want, but it's clear the system I have set up doesn't acknowledge the defenders and skips straight to the salvage. I've looked at SalvageGenFromSeed, and I can't make heads or tales of it due to SalvageDefenderModificationPluginImpl being buried inside it, meaning I'm unsure what to extend. Could anyone help me with this please?

Putting a DefenderDataOverride into the entity's memory under the MemFlags.SALVAGE_DEFENDER_OVERRIDE key /should/ work.  If your custom entity has also got an entry in salvage_entity_gen_data.csv, you could set the defender info there.


I have a rather simple hullmod that doubles energy weapon damage (side question: do beams count as energy weapons? I ask because they have their own entry) but increases flux by 1.5x.

It's based on the weapon type, so beams count (or don't) based on that.

It works fine, but how do I get the changes to be displayed in the refit screen (as currently it only shows the base damage and base flux)?

If you mean the weapon tooltip, that'll only show the base stats. If you mean the flux generation of the weapon groups, IIRC that should reflect changes but I'm not 100% sure. If it doesn't, then you can't.


Really need help getting the modules during advanceInCampaignor applyEffectsBeforeShipCreation, nothing i do work, i don't even get a crash, just nothing happens, here my current attempt

Don't try to get ShipAPIs, those don't exist at that point. You want variants; see: FleetMemberAPI.getVariant().getModuleVariant() and a bunch of other related methods.
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5548 on: November 01, 2019, 06:49:28 PM »

Don't try to get ShipAPIs, those don't exist at that point. You want variants; see: FleetMemberAPI.getVariant().getModuleVariant() and a bunch of other related methods.
Yeah this limits a lot what i wanted to do, but at least it works for now, thanks.

Logged
Check out my ships

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 #5549 on: November 01, 2019, 09:49:09 PM »

See: special_items.csv for the correct ID. (It's "modspec")

Thanks for that! Works perfectly in that regard. However, now something stranger is happening - the station doesn't demolish once it's been salvaged. I tried to add 'SalvageEntity demolish' after 'HMINightmareStation genNightmareLoot' (the script that determines what the station drops) but that didn't work. I tried to find in the files where this occurs, but I'm unsure whether 'demolish' is just a command for when you shoot a salvage entity and turn it into a debris field, or if it's run immediately after salvaging to generate the debris field.

Putting a DefenderDataOverride into the entity's memory under the MemFlags.SALVAGE_DEFENDER_OVERRIDE key /should/ work.  If your custom entity has also got an entry in salvage_entity_gen_data.csv, you could set the defender info there.

No dice I'm afraid. Putting DefenderOverride doesn't work, and putting it in the salvage_entity_gan_data doesn't work either. According to the log it goes from the initial step of finding hmi_nightmarestationOpenDialog (OpenInteractionDialog), like it should, and then for some bizarre reason skips straight to hmi_nightmarestationContinueDefenders (BeginSalvage). According to the rule checks, hmi_nightmarestationdefender_Desc (TriggerAutomatedDefenses) is not even searched for. hmi_nightmarestationOpenDialog (OpenInteractionDialog) uses "SalvageGenFromSeed/ShowDefaultVisual/FireBest SalvageCheckHostile" as the script - is this incorrect?

EDIT: Even worse, it appears now every single time I salvage something, it uses hmi_nightmarestationContinueDefenders as the default BeginSalvage option. This is getting increasingly bizarre.

Many thanks for the help thus far.

Pages: 1 ... 368 369 [370] 371 372 ... 706