Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 369 370 [371] 372 373 ... 710

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

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5550 on: November 02, 2019, 12:05:23 AM »

How can I check if a mine has exploded? For example, if I wanted to trigger an effect upon a mine's detonation.
Logged

bcbc2425

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5551 on: November 02, 2019, 12:37:33 AM »

so, ive seen somewhere that you can modify the max ships. i need this for purely scientific reasons. more stupid capital ship spam? no no, its just science!
also is there a way to prehaps modify the ship point cap above the 500 in game?
Logged
ur mum gae

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5552 on: November 02, 2019, 03:51:02 AM »

so, ive seen somewhere that you can modify the max ships. i need this for purely scientific reasons. more stupid capital ship spam? no no, its just science!
also is there a way to prehaps modify the ship point cap above the 500 in game?
These are all options you edit in Starsector/starsector-core/data/config/settings.json:
"maxShipsInFleet":30, adjusts the number of ships that you can having in your fleet.
"maxShipsInAIFleet":30, adjusts the number of ships that AI can have in their fleet (be mindful when editing this that it will significantly alter the sorts of fleets generated by the game).
"maxBattleSize":500, adjusts the ship point cap. If you increase it, I believe this will change the slider in-game which you can then alter to suit your purposes.

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5553 on: November 02, 2019, 05:48:23 AM »

Someone explain this to me, I get this error:
Code
27061 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Error compiling [data.scripts.ai.sc_retro_ai]
java.lang.RuntimeException: Error compiling [data.scripts.ai.sc_retro_ai]
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.ai.sc_retro_ai'
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.ai.sc_retro_ai' does not declare a class with the same name
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:160)
... 7 more



Even though my ai java file start with

Code
public class sc_retro_ai implements ShipSystemAIScript {

????
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5555 on: November 02, 2019, 09:49:17 AM »

Code
package data.shipsystems.scripts.ai;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipSystemAIScript;
import com.fs.starfarer.api.combat.ShipSystemAPI;
import com.fs.starfarer.api.combat.ShipwideAIFlags;
import com.fs.starfarer.api.util.IntervalUtil;
import data.scripts.util.Utils;
import java.util.List;
import org.lazywizard.lazylib.CollectionUtils;
import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.VectorUtils;
import org.lazywizard.lazylib.combat.AIUtils;
import org.lazywizard.lazylib.combat.CombatUtils;
import org.lwjgl.util.vector.Vector2f;

Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5556 on: November 02, 2019, 09:54:22 AM »

Where is the file itself?
The error is that it can't find the file at "data.scripts.ai.sc_retro_ai", but the package line indicates the file is at "data.shipsystems.scripts.ai"

If it's at data.shipsystems.scripts.ai, then you've a reference elsewhere (probably a .csv) that you need to fix, otherwise if it's in data.scripts.ai, then change the first line to "data.scripts.ai".

...

I think.

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5557 on: November 02, 2019, 09:57:27 AM »

I think I may be ***..one typo in the Utils.java class name..that might have been it. Will test now
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5558 on: November 02, 2019, 10:28:01 AM »

How can I check if a mine has exploded? For example, if I wanted to trigger an effect upon a mine's detonation.

IIRC you'd need to track the mines from frame to frame and then possibly check if there's a DamagingProjectileAPI from its explosion to confirm it actually exploded, there's no callback to say "mine has exploded".


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.

Yeah, demolish() is left over from when that was an option, but should have still worked, in theory.

SalvageEntity performSalvage - which should be getting called during normal salvage? - will spawn a debris field and fade out/remove the entity.

Does your entity have the "salvageable" tag?

Basically the things you're doing sound like they should work and that they don't work makes it seem like there's something going wrong in the details that are not in your post, if that makes sense.


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?

Hmm - the "bizarre reason" should also be detailed in the log, no? If a rule that you're expecting isn't being searched for, that means that its trigger is not the trigger that was fired.

In your DefenderDataOverride, did you set probDefenders? It defaults to 0. I guess you must have, since the constructors all require it, but I'd make sure you're not passing in 0 for that. That'd be one reason for TriggerAutomatedDefenses not being fired.


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.

Again, the reasons for that should be in the log. If multiple rules match the trigger and conditions, and have the same number of conditions, then one will be picked randomly. You can add a " score:100" (or some other number) to individual conditions to disambiguate in cases like this.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5559 on: November 02, 2019, 11:00:26 AM »

Two part question:
A - Is there a way to check if a player has a skill or not?
B - Am I overthinking this? I want to add a hullmod that reduces the negative effect of D-Mods by 15%. However, as far as I can tell Safety Procedures halves the impact rather than reducing it by 50%. I could just go with it, but then it would break the trend of "benefits add together, negatives multiply."

oiltanker

  • Ensign
  • *
  • Posts: 7
  • Regular person
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5560 on: November 02, 2019, 02:51:10 PM »

It was told to me that through invoking rule-based interaction plugin from simple InteractionDialogPlugin, but is possible to do other way around?
Is it possible to invoke e.g. a class, or a different plugin to execute a Java code?
Logged

boggled

  • Admiral
  • *****
  • Posts: 1130
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5561 on: November 02, 2019, 05:55:03 PM »

If the player lays in a course for a planet in another system, is there a way to get the SectorEntityToken for that planet? getInteractionTarget() in CampaignFleetAPI gets a jump point in this case, not the destination planet in the other system.
Logged

King Alfonzo

  • Admiral
  • *****
  • Posts: 683
  • -- D O C T O R --
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5562 on: November 02, 2019, 08:25:31 PM »

Yeah, demolish() is left over from when that was an option, but should have still worked, in theory.

SalvageEntity performSalvage - which should be getting called during normal salvage? - will spawn a debris field and fade out/remove the entity.

Does your entity have the "salvageable" tag?

Basically the things you're doing sound like they should work and that they don't work makes it seem like there's something going wrong in the details that are not in your post, if that makes sense.

It does make sense that I'm doing something wrong, it just doesn't make sense as to what has gone wrong.

Here is the relevant section from custom_entities for the station, which has always had the 'salvageable' tag:
Code
		"hmi_station_nightmare":{
"defaultName":"Kiel Research Station", # used if name=null in addCustomEntity()
"defaultRadius":45, # used if radius<0 in addCustomEntity()
"nameInText":"Kiel research station",
"shortName":"station",
"customDescriptionId":"station_research_remnant",
"interactionImage":"graphics/illustrations/orbital_construction.jpg",
"icon":"graphics/icons/station0.png",
"iconWidth":20,
"iconHeight":20,
"sprite":"graphics/stations/station_side00.png",
"spriteWidth":40,
"spriteHeight":40,
"renderShadow":true,
"useLightColor":true,
"showInCampaign":true,
"showIconOnMap":true,
"showNameOnMap":false,
"scaleNameWithZoom":false,
"scaleIconWithZoom":true,
"tags":["has_interaction_dialog", "salvageable"],
"layers":[STATIONS], # what layer(s) to render in. See CampaignEngineLayers.java for possible values
},

Adding SalvageEntity performSalvage to genLootNightmare demolishes the station as it should, but it opens up two salvage windows simultaneously, only one of which you can access. Adding SalvageEntity demolish closes the salvage window as soon as it opens and forms the debris field. I'm unsure if I should somehow add a demolish function to genLootNightmare to run after the entity has been salvaged? After the genNightmareLoot is executed, there's nothing else showing up in the log.

Hmm - the "bizarre reason" should also be detailed in the log, no? If a rule that you're expecting isn't being searched for, that means that its trigger is not the trigger that was fired.

In your DefenderDataOverride, did you set probDefenders? It defaults to 0. I guess you must have, since the constructors all require it, but I'd make sure you're not passing in 0 for that. That'd be one reason for TriggerAutomatedDefenses not being fired.

Here is the entry in salvage_entity_gen_data, which has always had probDefenders at 1:

Code
hmi_station_nightmare,1,1000,DISCOVERABLE,2200,1000,3000,,,,hmi_nightmare,1,1,200,500,8,,,

In the log, it says that the entity is missing $hasDefenders, so it goes straight to sal_explore.
EDIT: Found the problem! I forgot to add the boss ship variant to default_roles. So when the game tried to find defenders, it couldn't, as there were no ships to select. This caused the entity to lose $hasDefenders, and thus why it was never called. Checking this by changing the faction from the dummy hmi_nightmare faction to remnant caused Remnants to spawn as the defending fleet.

Again, the reasons for that should be in the log. If multiple rules match the trigger and conditions, and have the same number of conditions, then one will be picked randomly. You can add a " score:100" (or some other number) to individual conditions to disambiguate in cases like this.

According to the log, it checks if the tag "hmi_nightmarestationtag" exists. Which it then thinks it does and uses the tag-specific salvage option, regardless if the tag is present on the entity or not. I'm unsure if it was changing the format from tag == $hmi_nightmarestationtag to $tag:hmi_nightmarestationtag fixed the problem, or removing hmi_nightmarestationtag from data/campaignid/hmi_tags.json did the trick.

Thank you so much for the help so far.

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5563 on: November 02, 2019, 11:32:30 PM »

Hiya, I'm trying to increase the size of the fleets found in Remnant-controlled systems. I thought the correct function to call was FleetFactoryV3.addFleetPoints(), but I'm less sure now as it doesn't seem to have an effect no matter what I try. My (slightly sanitized) function is:
Code: java
    public void ManualUpdateFP(CampaignFleetAPI fleet) {

        Random random = new Random();
        int combatPoints = 9;
        String FleetType = FleetTypes.PATROL_SMALL;;
        FactionDoctrineAPI doctrine = fleet.getFaction().getDoctrine();

        MarketAPI market = Global.getFactory().createMarket("fake", "fake", 5);
            market.getStability().modifyFlat("fake", 10000);
            market.setFactionId("remnant");
            SectorEntityToken token = Global.getSector().getHyperspace().createToken(0, 0);
            market.setPrimaryEntity(token);
            market.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).modifyFlat("fake", BASE_QUALITY_WHEN_NO_MARKET);
            market.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).modifyFlat("fake", 1f);
       
        FleetParamsV3 params = new FleetParamsV3(
            market,
            fleet.getLocation(),
            fleet.getFaction().getId(),
            1f,
            FleetType,
            combatPoints, // combatPts
            0f, // freighterPts
            0f, // tankerPts
            0f, // transportPts
            0f, // linerPts
            0f, // utilityPts
            0f // qualityMod
        );
        params.officerNumberBonus = doctrine.getOfficerQuality() / 5 * doctrine.getNumShips();
        params.random = random;
       
        float warships = (float) doctrine.getWarships();
        float carriers = (float) doctrine.getCarriers();
        float phase = (float) doctrine.getPhaseShips();
        float NumShipsMult = Math.max(0,doctrine.getNumShips()-5);

        float fp = NumShipsMult * combatPoints/2;
        log.info("Fleet Bonus FP is: " + fp);
        float leftOverFP = fp;
        if ((warships-1)/4 * fp > 45) {
            leftOverFP = FleetFactoryV3.addFleetPoints(fleet, random, ((warships-1)/4 * fp), params, SizeFilterMode.SMALL_IS_DESTROYER,
                ShipRoles.COMBAT_MEDIUM, ShipRoles.COMBAT_LARGE, ShipRoles.COMBAT_CAPITAL);
            log.info("Added " + ((warships-1)/4*fp-leftOverFP) + " FP in large warships to " + fleet);
        } else {
            leftOverFP = FleetFactoryV3.addFleetPoints(fleet, random, ((warships-1)/4 * fp), params, SizeFilterMode.SMALL_IS_FRIGATE,
                ShipRoles.COMBAT_SMALL, ShipRoles.COMBAT_MEDIUM, ShipRoles.COMBAT_LARGE);
            log.info("Added " + ((warships-1)/4*fp-leftOverFP) + " FP in warships to " + fleet);
        }
        leftOverFP = FleetFactoryV3.addFleetPoints(fleet, random, ((carriers-1)/4 * fp), params, SizeFilterMode.SMALL_IS_FRIGATE,
            ShipRoles.COMBAT_SMALL, ShipRoles.COMBAT_MEDIUM, ShipRoles.COMBAT_LARGE);
        log.info("Added " + ((carriers-1)/4*fp-leftOverFP) + " FP in carriers to " + fleet);
    }
It's set only to fire once per fleet when inside a system with the tag "theme_remnant", and it doesn't crash or anything: the log says (example for one fleet):
Code
55736 [Thread-4] INFO  data.scripts.DoctrineEvolution  - Fleet Bonus FP is: 117.0
55736 [Thread-4] INFO  data.scripts.DoctrineEvolution  - Added 87.0 FP in large warships to com.fs.starfarer.campaign.fleet.CampaignFleet@394c5891Remnant sub-ordo
55737 [Thread-4] INFO  data.scripts.DoctrineEvolution  - Added 29.0 FP in carriers to com.fs.starfarer.campaign.fleet.CampaignFleet@394c5891Remnant sub-ordo
55737 [Thread-4] INFO  data.scripts.ApplyRCSWChanges  - Manually updating FP for com.fs.starfarer.campaign.fleet.CampaignFleet@434ab4faRemnant fragment
So something is happening under the hood. But the fleets don't actually have any ships added, and their FP remains the same. From what I understand the function chain follows something like:
addFleetPoints() -> addShips() -> addToFleet() -> addToFleet() -> fleet.getFleetData().addFleetMember()
which is the desired outcome, so I'm unsure what exactly isn't working.

(Sorry if I've totally misread the code.)

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5564 on: November 03, 2019, 01:38:38 AM »

2 quick questions:

1) ShipAPI has a .getCaptain() and a .getOriginalCaptain() - is there an accessible way to switch the captain in combat through the API?
2) Related, is there a way to forcibly eject the player from command of a ship in combat through the API? EDIT: Figured this one out - you can spawn a command shuttle and use engine.setPlayerShipExternal(ShipAPI ship) to transfer command to it.
« Last Edit: November 03, 2019, 01:16:45 AM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it
Pages: 1 ... 369 370 [371] 372 373 ... 710