Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 284 285 [286] 287 288 ... 711

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 1730155 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 #4275 on: February 08, 2019, 07:44:33 PM »

The way this works is it'll have the ORBIT_AGGRESSIVE assignment generated in pickNext(), so that's its default state - it'll chase after things it sees. But as soon as it's >1500 units away from whatever it's leashed to, it will get an ORBIT_PASSIVE assignment for 3 days, causing it to go back to the location its leashed to and stop chasing for the duration. Then it'll go back to ORBIT_AGGRESSIVE and chase again, and get leashed back if it exceeds the 1500 unit range, etc.
Well, its current assignment remains ORBIT_AGGRESSIVE when it is chasing fleet?

« Last Edit: February 08, 2019, 08:40:16 PM by Originem »
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4276 on: February 08, 2019, 08:07:58 PM »

Well, its current assignment remains ORBIT_AGGRESSIVE when it is chasing fleet?

Yes - that's what ORBIT_AGGRESSIVE means, orbit something but chase enemies if they're around.

Assignments don't just change by themselves, they have to be changed by something - usually either when one assignment runs out and it goes on to the next (if it was given multiple assignments to carry out in order), or when an assignment script added to the fleet makes some changes.
Logged

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 #4277 on: February 08, 2019, 08:41:05 PM »

It would help to know what you're actually trying to do. The inflater generates the variants, so before it runs, the "real" variants for the fleet members don't even exist. I suspect the answer is to probably either 1) write a custom inflater or 2) set the inflater to null, but it depends on what exactly you want to do. If you can be more specific, I might be able to add something on my end to make it easier to do.

I want to add a hull mod which won't be deleted when fleet is inflated or deflated.

Code
public class IL_FleetInflater extends DefaultFleetInflater {
    public IL_FleetInflater(DefaultFleetInflaterParams p) {
        super(p);
    }

    @Override
    public void inflate(CampaignFleetAPI fleet) {
        super.inflate(fleet);
        for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
            member.getVariant().addPermaMod("IL_isomery");
        }
        fleet.getFleetData().setSyncNeeded();
        fleet.getFleetData().syncIfNeeded();
    }
}

Code
 DefaultFleetInflaterParams p = new DefaultFleetInflaterParams();
        p.quality = 1f;
        p.persistent = true;
        p.seed = random.nextLong();
        p.mode = FactionAPI.ShipPickMode.PRIORITY_THEN_ALL;
        p.timestamp = params.timestamp;

        FleetInflater inflater = new IL_FleetInflater(p);
        fleet.setInflater(inflater);

will it work?
well it works.
« Last Edit: February 08, 2019, 08:49:19 PM by Originem »
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4278 on: February 08, 2019, 09:03:13 PM »

Very nice! Wasn't thinking of doing it like this but that's very clean solution.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4690
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4279 on: February 08, 2019, 10:01:19 PM »

I'm trying to spawn a ship with a specific ShipVariantAPI in combat (not a variant ID string, since I need it to obey player customisations to the variant).

Why does the ship spawned with the following code have the crash-mothballed icon on the command map and experience critical malfunctions, regardless of what CR is set to?

Code: java
	FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, variant);
member.getRepairTracker().setCR(0.7f);
member.getRepairTracker().setMothballed(false);
member.getRepairTracker().setCrashMothballed(false);
ship = engine.getFleetManager(side).spawnFleetMember(member, tempLoc, -90, 0);
ship.getLocation().set(tempLoc);
ship.setOriginalOwner(side.ordinal());
ship.setOwner(side.ordinal());
ship.setControlsLocked(false);
// set CR again because it doesn't obey the one in repair tracker
ship.setCRAtDeployment(0.7f);
ship.setCurrentCR(0.7f);
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4280 on: February 09, 2019, 08:46:05 AM »

I think that's because the newly-created member does not have any crew.

Something like:

CrewCompositionAPI crew = FactoryAPI.createCrewComposition();
crew.setCrew(member.getMinCrew());
member.setCrewComposition(crew);

Should resolve this, unless there's also another issue I'm missing.
Logged

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4281 on: February 09, 2019, 03:24:48 PM »

Is it possible to remove or add hyperspace terrain (voidclouds) outside of the sector generation phase (so as you are flying about the sector)? I tried using some of the functions in NebulaEditor, but these just seem instantly crash the game upon triggering...

If this is even possible i'd love for an example!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4282 on: February 09, 2019, 09:44:43 PM »

Is it possible to remove or add hyperspace terrain (voidclouds) outside of the sector generation phase (so as you are flying about the sector)? I tried using some of the functions in NebulaEditor, but these just seem instantly crash the game upon triggering...

If this is even possible i'd love for an example!

It should be possible, though I might be forgetting about something that would make it not so. I'd suggest posting what you did and the crash you get.
Logged

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4283 on: February 10, 2019, 03:49:47 AM »

I've currently tacked these functions onto an EveryFrameScript (fuelDepotControl) which handles control of fuel depots around gas giants, so the implementation isn't the best, it is probably just me doing something wrong/not understanding the API causing this as well!

Here's the code i'm trying as well as the errors i get:
Spoiler
Code: java
HyperspaceTerrainPlugin hyper = (HyperspaceTerrainPlugin) Misc.getHyperspaceTerrain().getPlugin(); //I also tried using Global.getSector().getHyperspace() with similar results
NebulaEditor editor = new NebulaEditor(hyper);

...

 CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet(); //Crashes if you give the functions static x and y coordinates as well

if (playerFleet.isInHyperspace())
{
    editor.clearArc(playerFleet.getLocation().x, playerFleet.getLocation().y, 0, 2f + 1f * 0.5f, 0, 360f); //I stuck both of the functions in here for the example, they crash on their own as well
    editor.setTileAt(playerFleet.getLocation().x, playerFleet.getLocation().y, 0);
}

Code: java
76739 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at control.fuelDepotControl.advance(fuelDepotControl.java:52)
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.StarfarerLauncher76739 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at control.fuelDepotControl.advance(fuelDepotControl.java:52)
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).run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[close]
« Last Edit: February 10, 2019, 08:04:46 AM by Alex »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4284 on: February 10, 2019, 08:08:59 AM »

According to this:
at control.fuelDepotControl.advance(fuelDepotControl.java:52) 

It crashes on line 52 of fuelDepotControl.java with an NPE. So that means the crash is in your code, due to trying to use a null reference.

For example, if you had code that looked like this:

NebulaEditor editor = null;
editor.clearArc(...)

It would throw an NPE on the second line, due to trying to call "clearArc" on a null reference. (I'm sure suggesting that's the actual issue, just trying to clarify what an NPE means.)
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 #4285 on: February 10, 2019, 10:05:57 AM »

What you want to do is extend BaseCampaignEventListener, which implements the CampaignEventListener interface with empty functions, and then override whatever method(s) you're interested in. The reasons for extending BaseCampaignEventListener instead of implementing CampaignEventListener directly are:

1) You don't need to add a ton of empty functions, and
2) If I add something to the CampaignEventListener interface, your code won't break since I'll also add an empty function to BaseCampaignEventListener

If you call super(true) in your implementation, that'll register the listener for you, so you just need to call "new YourClassName()" somewhere in, say, onNewGame(). I don't think there are any custom implementations of reportPlayerOpenedMarketAndCargoUpdated() in vanilla, so there's no immediate example to look at.

(I'm also going to look at weapon availability for .1, btw...)

Ah ok I didn't see that that was the impl class thanks! And on .1 I may hold off until then if you are looking at it anyway because there are a couple more pressing issues, actually.

Has anything changes with hiring officers?? I know admins were added but that is a separate rule. I'm getting index out of bounds when I call "CallEvent $ome_eventRef printSkills $id" but nothing in my code changes that to my knowledge, I just have custom rules that call it for my factions officers.

Any hints or do you need an example?

Same thing with turning in delivery missions to markets. The rules entries look the same but I noticed it it handled at the planet level now.. is the old rules portion deprecated?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4286 on: February 10, 2019, 10:09:06 AM »

Has anything changes with hiring officers?? I know admins were added but that is a separate rule. I'm getting index out of bounds when I call "CallEvent $ome_eventRef printSkills $id" but nothing in my code changes that to my knowledge, I just have custom rules that call it for my factions officers.

Any hints or do you need an example?

I'd suggest looking at the line where it throws the exception - all of this should be code you have access to the source of. That should point us towards what the issue is.


Same thing with turning in delivery missions to markets. The rules entries look the same but I noticed it it handled at the planet level now.. is the old rules portion deprecated?

Hmm, I'm not sure what you mean.
Logged

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4287 on: February 10, 2019, 11:02:00 AM »

According to this:
at control.fuelDepotControl.advance(fuelDepotControl.java:52) 

It crashes on line 52 of fuelDepotControl.java with an NPE. So that means the crash is in your code, due to trying to use a null reference.

For example, if you had code that looked like this:

NebulaEditor editor = null;
editor.clearArc(...)

It would throw an NPE on the second line, due to trying to call "clearArc" on a null reference. (I'm sure suggesting that's the actual issue, just trying to clarify what an NPE means.)

So i had a quick think and took a look at this, looks like the underlying issue was that the NebulaEditor does not survive saving and loading the game, i added a quick check for the Editor being null (thanks to Nicke535 on the discord for that idea) to the script and it now works swimmingly!
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 #4288 on: February 10, 2019, 11:04:55 AM »

I'd suggest looking at the line where it throws the exception - all of this should be code you have access to the source of. That should point us towards what the issue is.


Same thing with turning in delivery missions to markets. The rules entries look the same but I noticed it it handled at the planet level now.. is the old rules portion deprecated?

Hmm, I'm not sure what you mean.

Ok I'll take a look and get back to you on that.

Sorry, what I meant was that in .8 delivery missions were turned in at the commboard like how you turn in AI cores, but through a generated npc with a yellow quest marker attached.

When a player interacted with the new npc, a ruleset would determine if the player had the appropriate cargo and if they did, then show text to complete the mission and generate the player reward.


In .9, however, that same transaction is done when a player simply docks at a market in the market description text. So I am wondering if that is just a separate ruleset that those missions now require, and if so, is the old way in .8 and its related rules now deprecated in favor of the new system.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4289 on: February 10, 2019, 11:28:07 AM »

In .9, however, that same transaction is done when a player simply docks at a market in the market description text. So I am wondering if that is just a separate ruleset that those missions now require, and if so, is the old way in .8 and its related rules now deprecated in favor of the new system.

Unless I'm missing something, that seems incorrect. Bar delivery missions end on market interaction, but procurement missions - which involve a specific person - iirc still require getting in touch via the comm directory.
Logged
Pages: 1 ... 284 285 [286] 287 288 ... 711