Fractal Softworks Forum
February 23, 2019, 06:08:40 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Starsector 0.9a is out! (11/16/18); In-dev patch notes for 0.9.1a (01/31/19)
 
   Home   Help Search Login Register  
Pages: 1 ... 248 249 [250] 251 252 ... 291
  Print  
Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 670865 times)
Morrokain
Admiral
*****
Posts: 548


Megalith Dreadnought - Archean Order


View Profile
« Reply #3735 on: January 07, 2018, 11:05:55 PM »


I did paste this into Hybrasil.java:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", hybrasil_star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_culann");

And it seemed to work fine - planet shows up, can click show planet info fine.

Wow yup, copy-pasted my code into that file, removed the other one, and it solves the issue. Hm. So I guess I have to copy/replace each system file that I want to add things to.
« Last Edit: January 07, 2018, 11:07:26 PM by Morrokain » Logged
King Alfonzo
Captain
****
Posts: 454


[[THESIS SUBMISSION INTENSIFIES]]


View Profile Email
« Reply #3736 on: January 08, 2018, 01:35:27 AM »

IIRC FleetFactoryV2 does need a market - if you don't provide one, it'll look for the nearest one of the same faction, and if that fails, I think it will abort. So if a faction doesn't have any markets, that'll be trouble.

What defines a 'market' exactly? Is it a planet? Or is it a planet with an interactable store etc.?
« Last Edit: January 08, 2018, 02:29:10 AM by King Alfonzo » Logged

Histidine
Admiral
*****
Posts: 2055



View Profile WWW Email
« Reply #3737 on: January 08, 2018, 04:49:16 AM »

IIRC FleetFactoryV2 does need a market - if you don't provide one, it'll look for the nearest one of the same faction, and if that fails, I think it will abort. So if a faction doesn't have any markets, that'll be trouble.

What defines a 'market' exactly? Is it a planet? Or is it a planet with an interactable store etc.?
"Planet/station with store" (or a planet/station combination, like Jangala) is probably a sufficient player-facing description, yeah.

If you don't have or want one, you can create a fake market for the script, like so:
MarketAPI fakeMarket = Global.getFactory().createMarket("spawner_fake_market", "[market name]", [market size]);

Make sure to change your spawner code so that it doesn't try to spawn fleets at the market's location, since the fake market doesn't have one.
Logged

Alex
Administrator
Admiral
*****
Posts: 13184


View Profile
« Reply #3738 on: January 08, 2018, 08:40:23 AM »


I did paste this into Hybrasil.java:

PlanetAPI penumbros = system.addPlanet("penumbros_archeus", hybrasil_star, "Penumbros", "jungle", 45f, 180f, 15000f, 600f);
penumbros.setCustomDescriptionId("planet_culann");

And it seemed to work fine - planet shows up, can click show planet info fine.

Wow yup, copy-pasted my code into that file, removed the other one, and it solves the issue. Hm. So I guess I have to copy/replace each system file that I want to add things to.

You really shouldn't need to, that code doesn't care where it runs. Well, I mean, if you want autogenerated jump-points related to what you're adding, that could be a problem since that's called from Hybrasil.java etc. But that aside, I don't see why you couldn't do what you're doing - I suspect the issue was how you got the star, and it wasn't the right entity. For example, maybe you got hold of the star's gravity well in hyperspace instead?
Logged
Morrokain
Admiral
*****
Posts: 548


Megalith Dreadnought - Archean Order


View Profile
« Reply #3739 on: January 08, 2018, 12:00:05 PM »

You really shouldn't need to, that code doesn't care where it runs. Well, I mean, if you want autogenerated jump-points related to what you're adding, that could be a problem since that's called from Hybrasil.java etc. But that aside, I don't see why you couldn't do what you're doing - I suspect the issue was how you got the star, and it wasn't the right entity. For example, maybe you got hold of the star's gravity well in hyperspace instead?

Yeah I don't really understand it myself.  Smiley The ambiguity of the error makes it quite difficult to place.

The only other thing I could come up with, after pondering it quite a bit, was the use of the "new" operator somehow causing weirdness. At first I thought it was that the star had to just be initialized for some reason, but that doesn't make sense.


My thought process
: When I generated a custom planet and market - literally using the exact same method - in Galatia for use with the tutorial, it seemed to work just fine. The market showed up and you could click "Show Info" on any relevant entity. The market conditions appeared, etc. That's why I blindly re-used that method in 3 new systems, because it seemed "tried and tested." Not so.

Now, the only difference between anything implemented between those two planets is that one has a custom implemented market script, like Derinkuyu, and one does not. So, also like Derinkuyu, the market is added to the global economy during: ArcheusTutorialMissionEvent.endGalatiaPortionofMission() using:

        Global.getSector().getEconomy().addMarket(eldrus.getMarket());

where:

"eldrus" is returned by:

       SectorEntityToken eldrus = system.getEntityById("eldrus");


That being said, I had originally populated two additional planets in Isirah, again same method, and added markets to them using a .JSON file in the data/campaign/econ directory - and that also causes the error.  Roll Eyes
The market works fine, you can go there, see fleets spawn, even dock and buy things but the second you try and view the planet info, or any other planet that would pull its info within its range, you get the error.


Edit** Ok... you know what, looking at it again, I wonder if the key here is:

system.getEntityById("eldrus")

being used to put the market into the economy.


So,
Here is the script generating eldrus in galatia:
        StarSystemAPI system = sector.getStarSystem("galatia");

        // create the star and generate the hyperspace anchor for this system
        PlanetAPI star = system.getStar();

        // SectorEntityToken creation goes from star -> fringe
        PlanetAPI eldrus = system.addPlanet("eldrus", star, "Eldrus", "barren", 130f, 120f, 12000f, 600f);
        eldrus.setCustomDescriptionId("planet_eldrus");
        eldrus.setFaction(ArcheusFactions.ARCHEUS);
        eldrus.setInteractionImage("illustrations", "vacuum_colony");


        // create a market for eldrus - not connected to the rest of the economy to start with
        MarketAPI market = Global.getFactory().createMarket("eldrus_market", eldrus.getName(), 0);
        market.setSize(1);

        market.setSurveyLevel(MarketAPI.SurveyLevel.FULL);
        market.setPrimaryEntity(eldrus);

        market.setFactionId(eldrus.getFaction().getId());
        market.addCondition(Conditions.POPULATION_2);
        market.addCondition(Conditions.OUTPOST);

        market.addSubmarket(Submarkets.SUBMARKET_OPEN);
        market.addSubmarket(Submarkets.SUBMARKET_BLACK);
        market.addSubmarket(Submarkets.SUBMARKET_STORAGE);

        eldrus.setMarket(market);
        market.getCommDirectory().addMissionBoard();
        eldrus.addScript(new GalatiaMarketScript(market));



And one making a station in corvus:
        StarSystemAPI system = sector.getStarSystem("corvus");
        PlanetAPI star = system.getStar();

        //add station
        SectorEntityToken tg_station = system.addCustomEntity("jangalas_rest_station", "Jangala's Rest", "station_side02", ArcheusFactions.TRADERGUILDS);
        tg_station.setCircularOrbitPointingDown(star, 315f, 7000f, 360f);
        tg_station.setCustomDescriptionId("traderguilds_station_corvus");


The station has a market added through the .JSON file. -No error.

The planet has a market added to the global economy as displayed above. -No error.

Now if I put this:
        PlanetAPI penumbros = system.addPlanet("penumbros_archeus", star, "Penumbros", "jungle", 145, 180, 7000, 600);
        penumbros.setCustomDescriptionId("planet_penumbros");

        SectorEntityToken fortress = system.addCustomEntity("eldritch_fortress", "Eldritch Fortress", "station_side03", ArcheusFactions.ARCHEUS);
        fortress.setCircularOrbitPointingDown(system.getEntityById("penumbros_archeus"), 140f, 250f, 600f);
        fortress.setCustomDescriptionId("eldritch_fortress");
        fortress.setInteractionImage("illustrations", "eldritch_fortress");


 in either file at all, whether I add a market through the JSON file, or not, but I don't do what I did with Eldrus and add a market to the global economy in ArcheusTutorialMissionEvent.endGalatiaPortionofMission() like above. -Error.

That's the extent to which I understand what's going on. So, if anyone sees something I don't here please let me know! I would really like to not run into this error again in the future.  Tongue
« Last Edit: January 08, 2018, 12:20:57 PM by Morrokain » Logged
King Alfonzo
Captain
****
Posts: 454


[[THESIS SUBMISSION INTENSIFIES]]


View Profile Email
« Reply #3740 on: January 08, 2018, 02:56:18 PM »

Make sure to change your spawner code so that it doesn't try to spawn fleets at the market's location, since the fake market doesn't have one.

Um, forgive me Hist, but, how? I could set up the weighted picker to pick the fake market, but then how do you tell the game to spawn from an object and not the market? I think this is the fundamental things I couldn't, and still can't, wrap my head around. I mean, I think I can see bits and pieces in the IBB script about picking the nearest market, and a separate picker that picks a hideout location, with the idea that the IBB fleet picks the market then spawns at the hideout location, but what I don't understand is how this is done.

Regardless, you and Alex have been a tremendous help thus far, and I thank you profusely for helping me out thus far.
Logged

NightKev
Commander
***
Posts: 104


View Profile
« Reply #3741 on: January 09, 2018, 04:51:13 AM »

I've been trying to change the personality of a ship based on which hullmod it has (no effect if the ship has an officer) and so far I think I've been successful, but there doesn't seem to be a way to detect when hullmods are removed and thus restore the ship to the default "Steady" personality, since it seems changing the ship's personality is permanent (unless I've missed a non-permanent method of doing it?). Is there any way to work around this?

For reference, the code for my hullmod is here:
Code:
package org.tc.autonomous;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.ShipAPI;
import org.apache.log4j.Logger;

public abstract class AbstractPersonalityHullMod extends BaseHullMod {
    private static Logger LOG = Global.getLogger(AutonomousCommandsPlugin.class);
    private static final String PREFIX = "autonomous_personality_";

    private String personality;

    AbstractPersonalityHullMod(String personality) {
        this.personality = personality;
    }

    @Override
    public boolean isApplicableToShip(ShipAPI ship) {
        for (String hullMod : ship.getVariant().getHullMods()) {
            if (hullMod.startsWith(PREFIX) && !hullMod.equals(PREFIX + personality)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public String getUnapplicableReason(ShipAPI ship) {
        return "Personality hullmods are mutually exclusive";
    }

    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        if (ship.getCaptain() != null && ship.getCaptain().isDefault()) {
            ship.getCaptain().setPersonality(personality);
            LOG.info("Personality [" + personality + "] applied to ship [" + ship.getName() + "]");
        }
    }
}
Logged
Histidine
Admiral
*****
Posts: 2055



View Profile WWW Email
« Reply #3742 on: January 09, 2018, 06:17:13 AM »

Make sure to change your spawner code so that it doesn't try to spawn fleets at the market's location, since the fake market doesn't have one.

Um, forgive me Hist, but, how? I could set up the weighted picker to pick the fake market, but then how do you tell the game to spawn from an object and not the market? I think this is the fundamental things I couldn't, and still can't, wrap my head around. I mean, I think I can see bits and pieces in the IBB script about picking the nearest market, and a separate picker that picks a hideout location, with the idea that the IBB fleet picks the market then spawns at the hideout location, but what I don't understand is how this is done.
Code: (java)

CampaignFleetAPI fleet = FleetFactoryV2.createFleet(params);

SectorEntityToken spawnEntity = methodToGetASpawnPoint();  // like a planet or such
LocationAPI location = spawnEntity.getContainingLocation();  // a star system, or hyperspace
// adds our new fleet into the containing location
location.addEntity(fleet);
// positions fleet on top of the spawn entity
fleet.setLocation(spawnEntity.getLocation().x, spawnEntity.getLocation().y);


Or to spawn in hyperspace near the player, LuddicPathFleetManager does this:
Code: (java)

Vector2f loc = Misc.pickHyperLocationNotNearPlayer(target.getLocation(), Global.getSettings().getMaxSensorRange() + 500f);
Global.getSector().getHyperspace().addEntity(fleet);
fleet.setLocation(loc.x, loc.y);
Logged

Alex
Administrator
Admiral
*****
Posts: 13184


View Profile
« Reply #3743 on: January 09, 2018, 10:42:01 AM »

I've been trying to change the personality of a ship based on which hullmod it has (no effect if the ship has an officer) and so far I think I've been successful, but there doesn't seem to be a way to detect when hullmods are removed and thus restore the ship to the default "Steady" personality, since it seems changing the ship's personality is permanent (unless I've missed a non-permanent method of doing it?). Is there any way to work around this?

Hmm - one thing that comes to mind is creating a ship AI in your mod's ModPlugin.pickShipAI() and using the ShipAIConfig.personalityOverride to set the personality, which will only last for the duration of the battle.

See: CoreLifecyclePluginImpl.pickShipAI() for an example of how that might work. That one sets a specific AI config for automated ships; in your case you'd test for the presence of your relevant hullmods and set the personality override based on that.

This will not be compatible with mods that modify ship AI, though - i.e. if another mod wants to modify the ship AI config based on some parameters, only one will take effect - but I'm not sure how much of a practical issue that is.

Edit: added ShipAIPlugin.getConfig() method to make this sort of stuff easier and doable on the fly.
Logged
King Alfonzo
Captain
****
Posts: 454


[[THESIS SUBMISSION INTENSIFIES]]


View Profile Email
« Reply #3744 on: January 11, 2018, 01:36:10 AM »

Code: (java)

CampaignFleetAPI fleet = FleetFactoryV2.createFleet(params);

SectorEntityToken spawnEntity = methodToGetASpawnPoint();  // like a planet or such
LocationAPI location = spawnEntity.getContainingLocation();  // a star system, or hyperspace
// adds our new fleet into the containing location
location.addEntity(fleet);
// positions fleet on top of the spawn entity
fleet.setLocation(spawnEntity.getLocation().x, spawnEntity.getLocation().y);


Or to spawn in hyperspace near the player, LuddicPathFleetManager does this:
Code: (java)

Vector2f loc = Misc.pickHyperLocationNotNearPlayer(target.getLocation(), Global.getSettings().getMaxSensorRange() + 500f);
Global.getSector().getHyperspace().addEntity(fleet);
fleet.setLocation(loc.x, loc.y);



Hot Damn Histidine thank you! I finally have a working script that spawns things from entities! Many thanks for the help, Hist!

EDIT: ...aaaand now something has gone horribly wrong.

I've been using GetMaxFleets to try and keep the amount of spawned fleets low. For the following example, I have set the number of fleets for the red and orange faction (and probably every single other unidentified contact in the following image) to 1:


Yeah, that hasn't happened.

Now, I currently have three different fleetmanagers within this mod, and one of them has a maxfleets of 10, and the other two has their MaxFleets set to 1. So, within the context of a single mod, if you set different maxfleets, does it just pick the largest and use it for all of them? Or am I doing something horrifically wrong?

Code:
public class DracoFleetManager extends BaseLimitedFleetManager {
public static int DRACO_MAX_FLEETS = 1;

@Override
protected int getMaxFleets() {
return DRACO_MAX_FLEETS;
}
...

Code:
public class MessFleetManager extends BaseLimitedFleetManager {
public static int MESS_MAX_FLEETS = 10;

@Override
protected int getMaxFleets() {
return MESS_MAX_FLEETS;
}
...

Code:
public class FangFleetManager extends BaseLimitedFleetManager {
public static int FANG_MAX_FLEETS = 1;

@Override
protected int getMaxFleets() { return FANG_MAX_FLEETS; }
...
« Last Edit: January 12, 2018, 03:19:19 PM by King Alfonzo » Logged

Morrokain
Admiral
*****
Posts: 548


Megalith Dreadnought - Archean Order


View Profile
« Reply #3745 on: January 13, 2018, 07:20:35 AM »

How easy would it be to remove the flux generation of the "Engage Fighters" command?
Logged
Alex
Administrator
Admiral
*****
Posts: 13184


View Profile
« Reply #3746 on: January 13, 2018, 10:04:24 AM »

How easy would it be to remove the flux generation of the "Engage Fighters" command?

Basically impossible, it's hardcoded.
Logged
Morrokain
Admiral
*****
Posts: 548


Megalith Dreadnought - Archean Order


View Profile
« Reply #3747 on: January 13, 2018, 10:26:36 AM »

How easy would it be to remove the flux generation of the "Engage Fighters" command?

Basically impossible, it's hardcoded.

Ah ok that's what I suspected. Thanks!  Smiley
Logged
King Alfonzo
Captain
****
Posts: 454


[[THESIS SUBMISSION INTENSIFIES]]


View Profile Email
« Reply #3748 on: January 13, 2018, 08:21:31 PM »

Update on my rampant spawning bug, check the log. I am bamboozled.

The message is consistent when looking for the fleet manager:

Code:
508730 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - 0 out of a maximum 1 fleets in play for [data.campaign.fleets.DracoFleetManager]
508735 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - Could not spawn fleet - returned null
508735 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - 0 out of a maximum 1 fleets in play for [data.campaign.fleets.FangFleetManager]
508741 [Thread-4] INFO  com.fs.starfarer.api.impl.campaign.fleets.BaseLimitedFleetManager  - Could not spawn fleet - returned null

This is clearly wrong, as the game is spawning the fleets at the right place, but doesn't seem to be aware that it is spawning the fleet. Or it's spawning the fleet on a null response? But then, why is it working for the Mess faction file, but not these two, considering the coding language is almost identical? I am really confused by this - would anyone have an inkling of what I've done wrong?

EDIT: There was some remaining code from the LuddicPathFleetManager that looked for a source market. Without this section of code, the fleetmanager worked perfectly. I still don't get why the fleetmanager worked the way it did though.

Many thanks for everyone for the help!

EDIT2: So, so very sorry guys. The absolutely final question I'll ask for the forseeable future: How does one effect the post-battle loot drops? I've taken a gander through the core game and the Templar mod, as well as the forum and it's not really clear to me. Aim is to add a commodity to drop post-battle for a specific faction - not from an event, but in general. Now I've seen something in the SeededRemnantFleetManager about this, but it refers to tags which as far as I can tell, don't actually match with the commodity information. If anyone could put me to rights, I'd appreciate it.
« Last Edit: January 13, 2018, 11:42:34 PM by King Alfonzo » Logged

Soren
Admiral
*****
Posts: 597


Ego-tripping the light fantastic.


View Profile
« Reply #3749 on: January 14, 2018, 08:14:18 PM »

Quick question, is it possible to reduce the range of weapons only for a single mount type? I'm looking to reduce the range of only ballistic weapons with a hullmod.

Specifically, I'm looking to reduce ballistic weapon range by 100 for smalls, 200 for mediums, and 300 for larges. Might add a PD exception.
« Last Edit: January 14, 2018, 08:38:12 PM by Soren » Logged

"The law, in its majestic equality, forbids the rich as well as the poor to sleep under bridges, to beg in the streets, and to steal bread."

Auf Wiedersehen vom Nazi-Dreck!
Pages: 1 ... 248 249 [250] 251 252 ... 291
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2006-2011, Simple Machines
Simple Audio Video Embedder
Valid XHTML 1.0! Valid CSS!