Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 613 614 [615] 616 617 ... 710

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

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 231
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9210 on: October 01, 2022, 11:01:06 AM »

I think I asked this before, but never got a response (unless I did, in which case, I'm dumb).

Can anyone help me figure out this really weird fleet behavior? I use the following code:

Code
        else { //no battle? fine, i'll MAKE MY OWN
            satelliteFleet.clearAssignments(); // just in case the hold assignment all satellite fleets get is *** with a few things
            satelliteFleet.addAssignmentAtStart(FleetAssignment.INTERCEPT, fleet, 999999999, null); // again, sanity
            fleet.addAssignmentAtStart(FleetAssignment.INTERCEPT, satelliteFleet, 1, null);

            BattleAPI newBattle = Global.getFactory().createBattle(satelliteFleet, fleet); // force the satellite to engage the enemy

            // removing the createBattle doesnt fix the god damn issue where fleets drift

            battleJoined = newBattle;
        }
to spawn a satellite fleet on top of a fleet and engage them in combat if they were not already engaged in battle. The code for spawning a satellite fleet is:
Code
    public CampaignFleetAPI spawnSatelliteFleet(@NotNull Vector2f coordinates, @NotNull LocationAPI location, boolean temporary, boolean dummy) {
        CampaignFleetAPI satelliteFleet = createSatelliteFleetTemplate();

        location.addEntity(satelliteFleet);
        satelliteFleet.setLocation(coordinates.x, coordinates.y);
        if (temporary) {
            niko_MPC_temporarySatelliteFleetDespawner script = new niko_MPC_temporarySatelliteFleetDespawner(satelliteFleet, this);
            satelliteFleet.addScript(script);
            satelliteFleet.getMemoryWithoutUpdate().set(niko_MPC_ids.temporaryFleetDespawnerId, script);
        }

        satelliteFleet.addAssignment(FleetAssignment.HOLD, location.createToken(coordinates), 99999999f);

        if (dummy) {
            newDummySatellite(satelliteFleet);
        }
        else {
            newSatellite(satelliteFleet);
        }

        return satelliteFleet;
    }
, and
Code
    public CampaignFleetAPI createSatelliteFleetTemplate() {

        CampaignFleetAPI fleet = Global.getFactory().createEmptyFleet(getCurrentSatelliteFactionId(), getSatelliteFleetName(), true);
       // fleet.setFaction(getCurrentSatelliteFactionId());
        setTemplateMemoryKeys(fleet);

        fleet.setAI(new niko_MPC_satelliteFleetAI((CampaignFleet) fleet));
        fleet.addEventListener(new niko_MPC_satelliteFleetDespawnListener());

        PersonAPI aiCaptain = new AICoreOfficerPluginImpl().createPerson(Commodities.GAMMA_CORE, "derelict", null);
        fleet.setCommander(aiCaptain);

        return fleet;
    }
. The fleet AI is nothing special, it only overrides wantsToJoin and pickEncounterOption.

This is only called when a fleet reaches their interaction target, through the reportFleetReachedEntity listener. This works perfectly except for the fact that fleets act REALLY weird when you I do this. In this case, the fleet we spawn on seems to maintain their velocity and not do the "normal" thing of stop and fight the enemy. This still happens if I give the satellite fleet a intercept order and not create a new battle (relying on the satellitefleet's AI to attack the fleet). Other fleets that attack the fleets behave normally.
If I force the satellitefleet into an orbit around the planet, the fleet will actually kind of /loop around/ (as if "orbitting" in a very loose fashion) the satellite fleet, but it still won't have the expected behavior of stopping. In this scenario, any external fleet coming in to fight will also do this weird "loop" instead of stopping and fighting.
In case you wonder what I mean by "expected behavior of stopping", I mean I've always seen fleets fighting eachother kinda bump into eachother before backing off just enough to get their fleet circle borders touching and then stopping.

A video illustrating what I mean: https://cdn.discordapp.com/attachments/824910699415207937/1025820788667985991/Jdk7_2022.10.01_-_13.24.53.02.mp4

Ideally, I'd be able to keep using the createBattle method, as I store the battle in a global list for future reference.
« Last Edit: October 01, 2022, 11:12:08 AM by NikoTheGuyDude »
Logged

Mephansteras

  • Commander
  • ***
  • Posts: 102
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9211 on: October 01, 2022, 11:09:24 AM »

Is there some trick to getting mercenaries to use a ship?

I have 4 skins for one of my ships (Persean, Sindrian, Hegemony, and Mercenary). The three main factions use theirs pretty often, but I've never seen the mercenary version show up. They do use the base version of the hull, but never their exclusive version.

I've gone thought the code multiple times, but it's all being used the same for all 4 types. No errors in the log for that ship, skin, or variant either. Also doesn't seem to be a mod conflict, as I've done runs with my mod being the only enabled one and still no sightings.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9212 on: October 01, 2022, 09:54:35 PM »

Is there some trick to getting mercenaries to use a ship?

I have 4 skins for one of my ships (Persean, Sindrian, Hegemony, and Mercenary). The three main factions use theirs pretty often, but I've never seen the mercenary version show up. They do use the base version of the hull, but never their exclusive version.

I've gone thought the code multiple times, but it's all being used the same for all 4 types. No errors in the log for that ship, skin, or variant either. Also doesn't seem to be a mod conflict, as I've done runs with my mod being the only enabled one and still no sightings.
Is this just for making the skin appear in the usual autogenerated merc fleets?
If so, check if they do know the ship (requires merc tag, mercs normally don't use any other ships) by entering factioninfo mercenary in console.


How do I get a list of markets producing a given commodity?

Currently I'm going through all markets in economy and checking if they have CommoditySourceType.LOCAL for my commodity (as specified in the market's MarketShareDataAPI). But this misses any markets that are net importers, e.g. supplies on Sindria.
CommodityMarketDataAPI.getSortedProducers looks like it'd be perfect, except there's no way to get a MarketAPI from a MarketShareDataAPI.
Logged

Audax

  • Commander
  • ***
  • Posts: 155
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9213 on: October 02, 2022, 07:17:39 AM »

How does hullmod stat stacking work when using the modifyMult method on one stat?

Let us say I have a 3 hullmods that modify damage, one hullmod increases the damage by 2x, the second one reduces the damage by 1.25x and the last one increases it by 1.5x. Does it apply it one by one and if it does what determines the first one to be applied? if not how does those stats stack with each other then?

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9214 on: October 02, 2022, 09:21:20 AM »

How does hullmod stat stacking work when using the modifyMult method on one stat?

Let us say I have a 3 hullmods that modify damage, one hullmod increases the damage by 2x, the second one reduces the damage by 1.25x and the last one increases it by 1.5x. Does it apply it one by one and if it does what determines the first one to be applied? if not how does those stats stack with each other then?
Why would it matter, it's all order agnostic?
5x2x0.5 = 0.5x5x2 = 5x0.5x2

Cry0genic

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9215 on: October 02, 2022, 09:23:52 AM »

Is there a way of changing the illustrations that replaces the rotating 3D view of the planet when we dock for modded planets that doesn't need recompiling? Please correct me if I'm wrong, but the only way I know of is to open the source code for the planets, input setinteractionimage for the planet and then recompile it. Are there an easier way to do this?
Logged

Audax

  • Commander
  • ***
  • Posts: 155
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9216 on: October 02, 2022, 10:24:00 AM »

Why would it matter, it's all order agnostic?
5x2x0.5 = 0.5x5x2 = 5x0.5x2
Oh yeah, brain farting again its around 2am here XD

Mephansteras

  • Commander
  • ***
  • Posts: 102
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9217 on: October 02, 2022, 10:57:25 AM »

Is there some trick to getting mercenaries to use a ship?

I have 4 skins for one of my ships (Persean, Sindrian, Hegemony, and Mercenary). The three main factions use theirs pretty often, but I've never seen the mercenary version show up. They do use the base version of the hull, but never their exclusive version.

I've gone thought the code multiple times, but it's all being used the same for all 4 types. No errors in the log for that ship, skin, or variant either. Also doesn't seem to be a mod conflict, as I've done runs with my mod being the only enabled one and still no sightings.
Is this just for making the skin appear in the usual autogenerated merc fleets?
If so, check if they do know the ship (requires merc tag, mercs normally don't use any other ships) by entering factioninfo mercenary in console.

Yeah, shows up in their list of ships when I run that.

And I have this in the mercenary.faction file, which is just how I did it for the 3 main factions:

Code
{
    "hullFrequency":{
        "hulls":{
            "stardust_plasmaburst":0.3,
            "stardust_plasmaburst_merc":0.7,
        },
    },
    "knownShips":{
        "hulls":[
            "stardust_plasmaburst_merc",
        ],
    },
}

Really odd that it won't show up. And I have spawned one into my fleet and used it fine, so nothing wrong with the ship itself. The mercenaries just...don't want to use it.
Logged

Mephansteras

  • Commander
  • ***
  • Posts: 102
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9219 on: October 02, 2022, 11:44:34 AM »

Does it have an assigned defaultShipRoles?

Yeah, in with the other 3 variants at the same weight (5).
Logged

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 231
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9220 on: October 02, 2022, 01:57:47 PM »

Why, on game load, specifically, when conditions are applied to a market, are like, half the variables null, of CampaignPlanets, specifically, market.getPrimaryEntity()? Name is null, id is null, hell SCRIPTS is null (which is causing a very annoying NPE in my mod).

I must ask: Why? BaseCampaignEntity has a lot of these things (like script) be assigned something not-null (like a new arraylist) on constructor, so why is this... happening?

I believe this is the 3rd stage of loading, btw.
« Last Edit: October 02, 2022, 02:44:26 PM by NikoTheGuyDude »
Logged

TimeDiver

  • Captain
  • ****
  • Posts: 354
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9221 on: October 02, 2022, 03:20:10 PM »

Testing out some code I modified from Content Unlocking Missions (added to a simulator mission's MissionDefinition.json) for reporting skills added to ship captains in those missions, and setting Combat Readiness (up to a fixed limit of 100) if a hullmod or skill raises a ship's max CR above the default of 70:
Quote
      api.addPlugin(new BaseEveryFrameCombatPlugin() {
         public void init(CombatEngineAPI engine) {}
         public void advance(float amount, List events) {
            if (Global.getCombatEngine().isPaused()) {
               return;
            }
            for (ShipAPI ship : Global.getCombatEngine().getShips()) {
               if (ship.getCustomData().get("poopystinky") == null) {
                  if (ship.getCaptain() != null && ship.getOwner() == 0 && ship.getCaptain().getStats().getSkillsCopy().size() > 4) {
                     String text = "";
                     for (int u = 4; u < ship.getCaptain().getStats().getSkillsCopy().size(); u++) {
                        if (u < ship.getCaptain().getStats().getSkillsCopy().size()-1) {text = text+(((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getLevel() > 1 ?  ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+"+, " :  ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+", ");} else {text = text+(((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getLevel() > 1 ? ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+"+." :  ((MutableCharacterStatsAPI.SkillLevelAPI) ship.getCaptain().getStats().getSkillsCopy().get(u)).getSkill().getName()+".");}
                     }
                     if (ship.getFleetMember() != null && ship.getHullSize() != HullSize.FIGHTER) {
                        Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);
                     }
                  }
                  ship.setCurrentCR(ship.getCurrentCR()+ship.getMutableStats().getMaxCombatReadiness().getModifiedValue()); //Properly adds the max CR, for some reason it cannot be caught as FleetMemberAPI or this would have been easier...
                  ship.setCRAtDeployment(ship.getCRAtDeployment()+ship.getMutableStats().getMaxCombatReadiness().getModifiedValue()); //This only affects the "score" result of said mission, but the algorithm is mostly 100% since you have to basically LOSE ships to lose score. I don't think this needs setting, but eh couldn't help but tried.
                  if (ship.getCurrentCR() > 1.0f)
                     ship.setCRAtDeployment(1.0f);
                  ship.setCustomData("poopystinky", true); //Fires once per ship.
               }
            }
         }
      });
I managed to modify the code so that it doesn't CTD if fighter wings had skills of their own (test situation; some other mods' own hullmods which do that), but couldn't get it to not CTD if skills were added to the captain of a super-capital (as in, ship entry in ship_data.csv has the 'SHIP_WITH_MODULES' tag, and its .variant file has a 'modules' field).

Commenting out the following line prevents the CTD, but also won't show any added skills as the trade-off:

Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);

And clues on how to avert that, other than just commenting out said line?

EDIT: Added relevant crash data from starsector.log:
Quote
87564 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
   at com.fs.starfarer.E.C.super(Unknown Source)
   at com.fs.starfarer.combat.CombatState.addMessage(Unknown Source)
   at data.missions.ed_showcasewurg.MissionDefinition$1.advance(MissionDefinition.java:174)
   at com.fs.starfarer.title.Object.L$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.A.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.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(Thread.java:748)
« Last Edit: October 02, 2022, 03:55:07 PM by TimeDiver »
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9222 on: October 02, 2022, 03:58:51 PM »

Just do (ship != null) as well. Modules don't need captain pop-up (because they should be the same as their main ship).

TimeDiver

  • Captain
  • ****
  • Posts: 354
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9223 on: October 02, 2022, 04:40:57 PM »

Just do (ship != null) as well. Modules don't need captain pop-up (because they should be the same as their main ship).
Made that change as follows:
Code
							if (ship.getFleetMember() != null && ship.getHullSize() != HullSize.FIGHTER && ship != null) {
Global.getCombatEngine().getCombatUI().addMessage(1, ship.getFleetMember(), Misc.getPositiveHighlightColor(), ship.getName(), Misc.getTextColor(), "", Global.getSettings().getColor("standardTextColor"), "is skilled in "+text);
}

Still got a CTD, with the following starsector.log segment:
Quote
115346 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
   at com.fs.starfarer.E.D.ooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.<init>(Unknown Source)
   at com.fs.starfarer.E.C.super(Unknown Source)
   at com.fs.starfarer.combat.CombatState.addMessage(Unknown Source)
   at data.missions.ed_showcasewurg.MissionDefinition$1.advance(MissionDefinition.java:184)
   at com.fs.starfarer.title.Object.L$Oo.o00000(Unknown Source)
   at com.fs.starfarer.combat.A.new.o00000(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advanceInner(Unknown Source)
   at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
   at com.fs.starfarer.combat.CombatState.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(Thread.java:748)
So what did I do wrong? Added the 'ship != null' conditional check in the wrong location?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9224 on: October 02, 2022, 06:16:41 PM »

Your ship != null check needs to be before the other two checks (since those already expect a non-null ship)

@niko Did you see this link I showed you on Discord last time? It sounded like the problem you were having with the entity being disconnected from its market.
Logged
Pages: 1 ... 613 614 [615] 616 617 ... 710