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 ... 297 298 [299] 300 301 ... 706

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

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4470 on: March 14, 2019, 09:51:14 PM »

Correct! To be perfectly clear: what you've got now works but just doesn't show the right values in the tooltip.
okay, I know..
Logged
My mods


Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4471 on: March 15, 2019, 12:45:03 PM »

Hi, sorry to busy you, but for a purpose to add variant with filled with 4-6 mods but maybe not all enabled, i add them on a another place, where i load them if needed. They are 100% like vanilla variant else.
This is the method addCustomVariant:
https://bitbucket.org/Snrasha/gs/src/master/src/data/scripts/campaign/GS_TinyFleetFactoryV2.java
Quote
37671 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
   at com.fs.starfarer.campaign.fleet.CampaignFleetMemberView.renderWeapons(Unknown Source)
   at com.fs.starfarer.campaign.fleet.CampaignFleetMemberView.renderSingle(Unknown Source)

But, if i have not problem for add a normal ship before, i got a big problem of ships with modules, where these modules do not spawn.
Then, DR has explain me than i needed a existant variant. This is what i have done, but now, i got a problem than i cannot found...

The variant used, here,  is the Cathedral from SWP and do not have any decorative weapon, just one built-in weapon(redeemer), many modules and many built-in hullmods.

Thank for help me to explain what i have go wrong on my thing.
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4472 on: March 15, 2019, 12:49:37 PM »

I *think* this could be caused by having an invalid weapon slot ID in a variant. IIRC I'd changed the code to throw a more meaningful error when this happens. (Checking: yep, I did.)
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4473 on: March 15, 2019, 01:02:19 PM »

I *think* this could be caused by having an invalid weapon slot ID in a variant. IIRC I'd changed the code to throw a more meaningful error when this happens. (Checking: yep, I did.)

How this is possible, when i just used the variant gived per the game? (For some others cases)
https://bitbucket.org/Snrasha/gs/src/master/data/config/gsounty/gladiator_variants/cathedral/
He do not have any invalid weapon slot ID. Like this is the same(who him, load correctly) than one of SWP?  (And for module, they look all good)


EDIT: (yeah, same time than i posted this thing)
Nothing modified except than now, i break the loop when i search a variant valid to use.
Spoiler
[close]
But work now. What?
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4474 on: March 15, 2019, 01:12:58 PM »

Another possibility could be an invalid weapon ID. But I'm not sure I understand exactly what you mean as far as what works/doesn't work/etc; what I'm saying is just based on the stack trace and what might cause that specific exception.
Logged

AngelOfDeathIX

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4475 on: March 20, 2019, 01:57:29 AM »

Hey, I'm new to modding this game.  I've got ship and weapon modding down no problem, but now that I'm trying to make a faction to use the stuff I've made, I hit a wall.  Got the faction to show up in game, got the star system generated, now I just need to add a market to one of the planets.  I cannot for the life of me figure out how to do this.  The closest that I've gotten is for the planet to register as "under the control" of my faction, but when I go to it, it only has one dialogue option and when you mouse over the conditions at the top right, it puts the "hovered over" click on repeat.  Here is the code for my market:

Spoiler
Code
		PlanetAPI ventor_ii = system.addPlanet("ventor_ii", ventor_star, "Ventor II", "terran-eccentric", 180, 145, radiusAfter1+2600, 210);
        SectorEntityToken ventor_station = system.addCustomEntity(
                "ventor_station",
                "Ventor II Station",
                "station_side04",
                "ventoran");
        ventor_station.setCircularOrbitPointingDown(system.getEntityById("ventor_ii"), 275, 600, 45);
SectorEntityToken system1 = system.getEntityById("ventor_ii");



MarketAPI ventor_ii_market = Global.getFactory().createMarket("ventor_market", ventor_ii.getName(), 8);
ventor_ii_market.setPlanetConditionMarketOnly(false);
ventor_ii_market.addCondition(Conditions.HABITABLE);
ventor_ii_market.addCondition(Conditions.MILD_CLIMATE);
ventor_ii_market.addCondition(Conditions.ORE_RICH);
ventor_ii_market.addCondition(Conditions.RARE_ORE_RICH);
ventor_ii_market.addCondition(Conditions.ORGANICS_PLENTIFUL);
ventor_ii_market.addCondition(Conditions.FARMLAND_ADEQUATE);
ventor_ii_market.addCondition(Conditions.POPULATION_8);
ventor_ii_market.getFirstCondition(Conditions.HABITABLE).setSurveyed(true);
ventor_ii_market.setPrimaryEntity(ventor_ii);
ventor_ii.setMarket(ventor_ii_market);
ventor_ii_market.setFactionId("ventoran");
ventor_ii_market.addIndustry(Industries.POPULATION);
ventor_ii_market.addIndustry(Industries.STARFORTRESS);
ventor_ii_market.addIndustry(Industries.FARMING);
ventor_ii_market.addIndustry(Industries.MEGAPORT);
ventor_ii_market.addIndustry(Industries.HEAVYBATTERIES);
ventor_ii_market.addIndustry(Industries.HIGHCOMMAND);
ventor_ii_market.addIndustry(Industries.MINING);
ventor_ii_market.addIndustry(Industries.ORBITALWORKS);
ventor_ii_market.addIndustry(Industries.REFINING);
ventor_ii_market.addIndustry(Industries.FUELPROD);
PlanetAPI ventor_iia = system.addPlanet("ventor_iia", ventor_ii, "Ventor IIa", "barren", 180, 65, 450, 40);
[close]

That is in my Mod Plugin .java. 
Result:
Spoiler
[close]
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4476 on: March 20, 2019, 09:20:00 AM »

Hey, I'm new to modding this game.  I've got ship and weapon modding down no problem, but now that I'm trying to make a faction to use the stuff I've made, I hit a wall.  Got the faction to show up in game, got the star system generated, now I just need to add a market to one of the planets.  I cannot for the life of me figure out how to do this.  The closest that I've gotten is for the planet to register as "under the control" of my faction, but when I go to it, it only has one dialogue option and when you mouse over the conditions at the top right, it puts the "hovered over" click on repeat.  Here is the code for my market:

Spoiler
Code
		PlanetAPI ventor_ii = system.addPlanet("ventor_ii", ventor_star, "Ventor II", "terran-eccentric", 180, 145, radiusAfter1+2600, 210);
        SectorEntityToken ventor_station = system.addCustomEntity(
                "ventor_station",
                "Ventor II Station",
                "station_side04",
                "ventoran");
        ventor_station.setCircularOrbitPointingDown(system.getEntityById("ventor_ii"), 275, 600, 45);
SectorEntityToken system1 = system.getEntityById("ventor_ii");



MarketAPI ventor_ii_market = Global.getFactory().createMarket("ventor_market", ventor_ii.getName(), 8);
ventor_ii_market.setPlanetConditionMarketOnly(false);
ventor_ii_market.addCondition(Conditions.HABITABLE);
ventor_ii_market.addCondition(Conditions.MILD_CLIMATE);
ventor_ii_market.addCondition(Conditions.ORE_RICH);
ventor_ii_market.addCondition(Conditions.RARE_ORE_RICH);
ventor_ii_market.addCondition(Conditions.ORGANICS_PLENTIFUL);
ventor_ii_market.addCondition(Conditions.FARMLAND_ADEQUATE);
ventor_ii_market.addCondition(Conditions.POPULATION_8);
ventor_ii_market.getFirstCondition(Conditions.HABITABLE).setSurveyed(true);
ventor_ii_market.setPrimaryEntity(ventor_ii);
ventor_ii.setMarket(ventor_ii_market);
ventor_ii_market.setFactionId("ventoran");
ventor_ii_market.addIndustry(Industries.POPULATION);
ventor_ii_market.addIndustry(Industries.STARFORTRESS);
ventor_ii_market.addIndustry(Industries.FARMING);
ventor_ii_market.addIndustry(Industries.MEGAPORT);
ventor_ii_market.addIndustry(Industries.HEAVYBATTERIES);
ventor_ii_market.addIndustry(Industries.HIGHCOMMAND);
ventor_ii_market.addIndustry(Industries.MINING);
ventor_ii_market.addIndustry(Industries.ORBITALWORKS);
ventor_ii_market.addIndustry(Industries.REFINING);
ventor_ii_market.addIndustry(Industries.FUELPROD);
PlanetAPI ventor_iia = system.addPlanet("ventor_iia", ventor_ii, "Ventor IIa", "barren", 180, 65, 450, 40);
[close]

That is in my Mod Plugin .java.  
Result:
Spoiler
[close]

I think you're actually just missing a few small things, like setting the market conditions to 'surveyed' and maybe adding the submarkets. BUT, for the sake of futureproofing and making it easier for you to do this again later when you want to add more markets, maybe try adding an addMarketplace() function to one of your scripts and calling that instead!

Here's mine, you can copy it entirely if you want:

Code: java
public static MarketAPI addMarketplace(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities, String name,
            int size, ArrayList<String> marketConditions, ArrayList<String> submarkets, Boolean WithJunkAndChatter, Boolean PirateMode) {
        EconomyAPI globalEconomy = Global.getSector().getEconomy();
        String planetID = primaryEntity.getId();
        String marketID = planetID + "market";

        MarketAPI newMarket = Global.getFactory().createMarket(marketID, name, size);
        newMarket.setFactionId(factionID);
        newMarket.setPrimaryEntity(primaryEntity);
        newMarket.getTariff().modifyFlat("generator", newMarket.getFaction().getTariffFraction());

        if (submarkets != null) {
            for (String market : submarkets) {
                newMarket.addSubmarket(market);
            }
        }

        for (String condition : marketConditions) {
            try {
                newMarket.addCondition(condition);
            } catch (RuntimeException e) {
                newMarket.addIndustry(condition);
            }
        }

        if (connectedEntities != null) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }

        globalEconomy.addMarket(newMarket, WithJunkAndChatter);
        primaryEntity.setMarket(newMarket);
        primaryEntity.setFaction(factionID);

        if (connectedEntities != null) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
                entity.setFaction(factionID);
            }
        }

        if (PirateMode) {
            newMarket.setEconGroup(newMarket.getId());
            newMarket.setHidden(true);
            primaryEntity.setSensorProfile(1f);
            primaryEntity.setDiscoverable(true);
            primaryEntity.getDetectedRangeMod().modifyFlat("gen", 5000f);
            newMarket.getMemoryWithoutUpdate().set(DecivTracker.NO_DECIV_KEY, true);
        } else {
            for (MarketConditionAPI mc : newMarket.getConditions()) {
                mc.setSurveyed(true);
            }
            newMarket.setSurveyLevel(SurveyLevel.FULL);
        }
        
        newMarket.reapplyIndustries();
        return newMarket;
    }

and then in your systemgen script you would call it like so:

Code: java
// the Kadur are reduced to hiding in their heavily-guarded star fortress, towed here through hyperspace following the final battle over Oasis
        SectorEntityToken khs_refugestation = system.addCustomEntity("khs_refugestation", "Star Fortress Requiem", "station_side06", "kadur_remnant");
        khs_refugestation.setInteractionImage("illustrations", "industrial_megafacility");
        khs_refugestation.setCustomDescriptionId("khs_requiem");
        khs_refugestation.setCircularOrbitPointingDown(gehennaII, 0, 220, 70);
        
        MarketAPI khs_refugestationmarket = addMarketplace(
                "kadur_remnant", // faction id
                khs_refugestation, // id or reference of the PRIMARY ENTITY (i.e. in this case the station, could be that or the planet for you)
                null, // LIST of secondary entities, if you want a typical station-and-planet market you'd put a single-item list with one of them in it here
                "Star Fortress Requiem", // name of the market
                5, // size of the market
                new ArrayList<>(
                        Arrays.asList( // list of market_condition and/or industry ids
                                "population_5",
                                "frontier",
                                "headquarters",
                                "stealth_minefields",
                                "khs_kadur_refugees",
                                "khs_kadur_majority",
                                "khs_hardened_populace",
                                "dark",
                                "hydroponics_complex",
                                Industries.POPULATION,
                                Industries.SPACEPORT,
                                Industries.HEAVYBATTERIES,
                                Industries.MILITARYBASE,
                                Industries.WAYSTATION,
                                Industries.STARFORTRESS_MID)),
                new ArrayList<>(
                        Arrays.asList( // which submarkets to generate
                                Submarkets.GENERIC_MILITARY,
                                Submarkets.SUBMARKET_BLACK,
                                Submarkets.SUBMARKET_OPEN,
                                Submarkets.SUBMARKET_STORAGE)),
                                true, // with junk and chatter?
                                false); // pirate mode? (i.e. hidden)
        
        // can't figure out how to add items inside my addmarketplace, too complicated, just brute force it separately
        khs_refugestationmarket.addIndustry(Industries.ORBITALWORKS,new ArrayList<>(Arrays.asList(Items.PRISTINE_NANOFORGE)));
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

AngelOfDeathIX

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4477 on: March 20, 2019, 12:54:16 PM »

I missed quite a few necessary imports so digging for those was a pain, but I finally got it to work, and it works perfectly.  Thanks so much for helping and letting me use your code!
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4478 on: March 20, 2019, 09:06:30 PM »

I missed quite a few necessary imports so digging for those was a pain, but I finally got it to work, and it works perfectly.  Thanks so much for helping and letting me use your code!

Cheers! And sorry about the imports -- I'm used to modders using an IDE like Netbeans, which handles those automatically. Maybe something to look into for you, there's a pretty good tutorial for setting it up on the forums. And you can always pop by #creative_corner in the unofficial discord if you need more help. :)
« Last Edit: March 20, 2019, 09:08:24 PM 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

manictiger

  • Ensign
  • *
  • Posts: 21
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4479 on: March 25, 2019, 08:49:49 PM »

Is there a way to get a specific blueprint to spawn on a specific planet?  I'm trying to make an "extinct faction" that has left behind its blueprints on its former capital planet.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4480 on: March 28, 2019, 03:38:05 PM »

So I'm making a bunch of custom market conditions for some planets, but it seems that the scan screen doesn't compute their effect at all (whether it is hazard or accessibility changes from other conditions I'm making):



The code is nothing special, just a modification of existing vanilla conditions (the commented out portion didn't worked either:

Spoiler
Code: Java
public class US_virus extends BaseHazardCondition implements MarketImmigrationModifier {

    private float DEFENSE_MALUS = 0.5f;
   
    @Override
    public void apply(String id) {
       
        super.apply(id);
//        Object test = Global.getSettings().getSpec(ConditionGenDataSpec.class, condition.getId(), true);
//        if (test instanceof ConditionGenDataSpec) {
//            ConditionGenDataSpec spec = (ConditionGenDataSpec) test;
//            float hazard = spec.getHazard();
//            if (hazard != 0) {
//                market.getHazard().modifyFlat(id, hazard, condition.getName());
//            }
//        }
       
        market.getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).modifyMult(id, DEFENSE_MALUS, "Lingering Virus");
        market.addTransientImmigrationModifier(this);
    }

    @Override
    public void unapply(String id) {
        super.unapply(id);
//        market.getHazard().unmodify(id);
        market.getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).unmodify(id);
        market.removeTransientImmigrationModifier(this);
    }

    @Override
    public void modifyIncoming(MarketAPI market, PopulationComposition incoming) {
        incoming.add(Factions.POOR, 10f);
        incoming.getWeight().modifyFlat(getModId(), getThisImmigrationBonus(), Misc.ucFirst(condition.getName().toLowerCase()));
    }

    private float getThisImmigrationBonus() {
        return -3*market.getSize();
    }
   
    @Override
    protected void createTooltipAfterDescription(TooltipMakerAPI tooltip, boolean expanded) {
        super.createTooltipAfterDescription(tooltip, expanded);
        tooltip.addPara(
                "%s defense rating.",
                10f,
                Misc.getHighlightColor(),
                "" + (int)((DEFENSE_MALUS-1)*100) + "%"
        );
        tooltip.addPara(
                "%s population growth (based on market size).",
                10f,
                Misc.getHighlightColor(),
                "" + (int) getThisImmigrationBonus()
        );
    }
}
[close]

Am I missing something here?
Logged
 

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4481 on: March 28, 2019, 03:59:21 PM »

Hmm - seeing the pre-survey screen that shows what the hazard rating is comprised of would be helpful. Nothing jumps out as being wrong here - unless, is the "Military Virus" condition marked as something that's not shown until the planet is surveyed? Hazard-rating-affecting conditions can not require surveying, as the cost of a full survey depends on the hazard rating.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4482 on: March 28, 2019, 04:13:57 PM »

Right, it is indeed a discoverable condition and I would have liked to keep it that way but I could live with without. Other conditions I have though really wouldn't feel right to be shown without a survey though.
Stuff like a "Floating Continent" that reduce the hazard of some gas giants, a "Crashed Terraformation Drone" that lower the hazard rating but only for small colonies, or a "Space Elevator" that increases accessibility for small colonies too.
Logged
 

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4483 on: March 28, 2019, 04:18:16 PM »

Stuff that increases accessibility should be fine, I *think*. I also believe that the hazard conditions should start working once they're discovered - perhaps just not being reflected in the "colonize" screen, but it might update properly if you actually colonize, or even re-open the colonize screen. Didn't look much into the code, though, so not 100% sure.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4484 on: March 28, 2019, 04:25:50 PM »

That's the issue, neither the accessibility or the hazard seems to be updated when trying to colonize, or even when leaving the planet and then going back to try to colonize it. The modifiers do get applied correctly once the planet is colonized but it's not reflected in any way before that, which is less than idea.
« Last Edit: March 28, 2019, 04:29:04 PM by Tartiflette »
Logged
 
Pages: 1 ... 297 298 [299] 300 301 ... 706