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 ... 360 361 [362] 363 364 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5415 on: October 18, 2019, 05:06:49 PM »

The default value in the settings.json file only factors in if you're running the game on that PC for the first time, I believe.
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 #5416 on: October 18, 2019, 07:31:38 PM »

The default value in the settings.json file only factors in if you're running the game on that PC for the first time, I believe.

Oh ok that makes sense. I'm sure I have changed it since then. I wasn't sure if this also included the first time a new mod was installed or what it would actually override as far as player-specific selections go.

If the mod sets the maximum or minimum lower than the current setting, does that affect things?
Logged

Alex

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

Not actually 100% sure what happens if the maximum is set to below the currently-selected value :)
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 #5418 on: October 18, 2019, 09:05:17 PM »

Not actually 100% sure what happens if the maximum is set to below the currently-selected value :)

It adjusts the currently-selected value to the defined max. Just tried it out to verify. Nice! :)
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5419 on: October 19, 2019, 02:51:24 AM »

So, I have a weird issue with reportPlayerOpenedMarket and the listener would fire up every time the player landed anywhere that a market dialog can be opened. It seemed weird that it would just deduct credits for landing on an abandoned station or market, how would I remedy this by making sure the market is not unowned?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5420 on: October 19, 2019, 08:41:49 AM »

Something like:
if (!market.getFaction().isNeutral())

Or thereabouts.
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 #5421 on: October 19, 2019, 10:31:50 AM »

When using:

Code

stats.getEntity().getOwner()


If I want to check whether the player is the owner I would check for it being 0, right? And AI is 1?

So to filer out all non-player owned ships I would use:

Code

if (stats.getEntity().getOwner() != 0) {
     stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, RECOVER_CHANCE);
}

« Last Edit: October 19, 2019, 10:43:47 AM by Morrokain »
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5422 on: October 19, 2019, 10:47:14 AM »

Why would this:
Code
if (result.size() < 4 && knownSkillCount < maxSkillsPerOfficer) {
            for (String id : result) {
                nonMaxedSkills.remove(id);
            }
            /*
            if (!nonMaxedSkills.isEmpty()) {
                String pick = nonMaxedSkills.pickAndRemove().toString();
                knownSkills.remove(pick);
                result.add(pick);

            }
            */
            for(int i = 0; i < (skillsAmount-skillCount-1); i++){
                String pick = nonMaxedSkills.pickAndRemove().toString();
                knownSkills.remove(pick);
                result.add(pick);
                skillCount =+1;
            }
        }
        log.info("Officer's skill list.");

produce this:
Code
1671189 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at data.scripts.OfficerLevelupPluginImplMod.pickLevelupSkills(OfficerLevelupPluginImplMod.java:148)
at com.fs.starfarer.rpg.OfficerData.makeSkillPicks(Unknown Source)
at com.fs.starfarer.rpg.OfficerData.levelUp(Unknown Source)
at com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent.createOfficer(OfficerManagerEvent.java:381)
at com.fs.starfarer.api.impl.campaign.events.OfficerManagerEvent.createOfficer(OfficerManagerEvent.java:346)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.addCommanderAndOfficers(FleetFactoryV3.java:866)
at com.fs.starfarer.api.impl.campaign.fleets.FleetFactoryV3.createFleet(FleetFactoryV3.java:375)
at com.fs.starfarer.api.impl.campaign.procgen.themes.RemnantStationFleetManager.spawnFleet(RemnantStationFleetManager.java:63)
at com.fs.starfarer.api.impl.campaign.fleets.SourceBasedFleetManager.advance(SourceBasedFleetManager.java:121)
at com.fs.starfarer.campaign.BaseLocation.advanceEvenIfPaused(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
at com.fs.starfarer.BaseGameState.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$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Line 148 is "String pick = nonMaxedSkills.pickAndRemove().toString();"

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5423 on: October 19, 2019, 11:57:40 AM »

Can a ship module have its own modules?
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5424 on: October 19, 2019, 01:28:30 PM »

@Morrokain: Yeah, that's all correct. getOwner() can sometimes return values other than 0 and 1, but I don't recall why. You might want to consider using getOriginalOwner instead, as it is possible for entities to switch sides.

@Crimson Sky Gaurdian: The only way I can think of for that to happen is if you fed nonMaxedSkills a null

@Sinosauropteryx: Black magic!

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5425 on: October 19, 2019, 01:51:03 PM »

@Morrokain: Yeah, that's all correct. getOwner() can sometimes return values other than 0 and 1, but I don't recall why. You might want to consider using getOriginalOwner instead, as it is possible for entities to switch sides.

Thanks for the tip, will do!
Logged

boggled

  • Admiral
  • *****
  • Posts: 1127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5426 on: October 19, 2019, 01:57:05 PM »

I'm working on a terraforming mod. I'm using the following code to remove a frozen planet and replace it with a water planet:
Code
String newPlanetType = "water";
CampaignPlanet oldPlanet = (CampaignPlanet)this.market.getPrimaryEntity();
CampaignPlanet newPlanet = null;
newPlanet = new CampaignPlanet(oldPlanet.getId(), oldPlanet.getName(), newPlanetType, oldPlanet.getRadius(), oldPlanet.getLocation().x, oldPlanet.getLocation().y, (CampaignEntity)oldPlanet.getLightSource());
newPlanet.setContainingLocation(oldPlanet.getContainingLocation());
newPlanet.setOrbit(oldPlanet.getOrbit());
newPlanet.setMarket(this.market);
newPlanet.setMemory(oldPlanet.getMemory());
newPlanet.setFaction(oldPlanet.getFaction());

this.market.getStarSystem().removeEntity(oldPlanet);
this.market.getStarSystem().addEntity(newPlanet);

this.market.setPrimaryEntity(newPlanet);
But if I try to get the planet type ID with the following code, it still returns "frozen" despite the oldPlanet SectorEntityToken having been removed and the newPlanet set as the primary entity.
Code
this.market.getPlanetEntity().getTypeId()
This prevents farming/aquaculture from working properly on the market as it gets the planet type ID to determine which variant to use. I think this may happen because objects cannot be removed from the connectedEntities LinkedHashSet in the Market class. When getPlanetEntity() iterates through connectedEntities, it will always return the first item placed on the list (the old frozen planet PlanetAPI) even though newPlanet is now the primary entity.

Whether or not I'm correct about why this occurs, is there any change I can make to my code so farming/aquaculture will correctly identify the new planet type? Thank you!
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5427 on: October 19, 2019, 02:33:57 PM »

When getPlanetEntity() iterates through connectedEntities, it will always return the first item placed on the list (the old frozen planet PlanetAPI) even though newPlanet is now the primary entity.
After taking a look, that seems very likely to me. I noticed that getConnectedEntities returns the field itself, rather than a copy, so you should be able to remove the old planet from the set.

boggled

  • Admiral
  • *****
  • Posts: 1127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5428 on: October 19, 2019, 04:48:58 PM »

After taking a look, that seems very likely to me. I noticed that getConnectedEntities returns the field itself, rather than a copy, so you should be able to remove the old planet from the set.
This solved the problem. Thanks for your help!
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5429 on: October 19, 2019, 08:20:47 PM »

No problem. Glad that did the trick  :)
Pages: 1 ... 360 361 [362] 363 364 ... 706