Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Hyperspace Topography (10/12/22)

Pages: 1 ... 614 615 [616] 617 618 ... 625

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

Timid

  • Admiral
  • *****
  • Posts: 566
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9225 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

  • Commander
  • ***
  • Posts: 221
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9226 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: 4040
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9227 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

TimeDiver

  • Commander
  • ***
  • Posts: 221
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9228 on: October 02, 2022, 06:37:33 PM »

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

Made that change and still got the CTD:
Code
if (ship != null && 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);
}
Attached starsector.log file snippet:
Quote
103061 [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)
At a glance, the error message is identical, just pointing to a different line # (since I deleted some un-necessary / duplicate lines closer to the top), still points to the same line generating the CTD if not commented out).
« Last Edit: October 02, 2022, 06:42:21 PM by TimeDiver »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9229 on: October 02, 2022, 06:37:59 PM »

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.

Iterating through the markets and calling CommodityOnMarketAPI.getMaxSupply() for the commodity you're interested in should do it.


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

(... honestly, I have no idea!)

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?

Something needs to call that code - either using the console commands, or - as you say - by editing the sector gen files.


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.

Stuff's getting loaded, and you generally can't count on the order it's loaded in, and when the objects are instantiated from the savefile, the default constructor isn't called, iirc. So if your code runs midway through the load process it needs to be real careful about what it's using and to bail out if something is null that otherwise *can't* be null. Though it seems like mods wouldn't mostly be running into this sort of thing, hmm.
Logged

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 166
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9230 on: October 02, 2022, 06:45:03 PM »


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

(... honestly, I have no idea!)

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.

Stuff's getting loaded, and you generally can't count on the order it's loaded in, and when the objects are instantiated from the savefile, the default constructor isn't called, iirc. So if your code runs midway through the load process it needs to be real careful about what it's using and to bail out if something is null that otherwise *can't* be null. Though it seems like mods wouldn't mostly be running into this sort of thing, hmm.

1. No idea if I asked before, or no idea of what's going on?
2. I guess that makes sense, but I just assumed all objects in java HAD to have their constructor called apon being instantiated. Maybe this is some reflection magic I'm unfamiliar with.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4040
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9231 on: October 02, 2022, 06:53:12 PM »

@TimeDiver

Hmm, manually log (with Global.getLogger(class)) whether each of the params in the addMessage call is null or otherwise invalid input?

Also the addMessage javadoc says you can feed it a ShipAPI directly instead of getting a FleetMemberAPI first, so might be worth trying that (even if it doesn't fix the crash the code is cleaner).
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9232 on: October 02, 2022, 06:56:51 PM »

1. No idea if I asked before, or no idea of what's going on?

The latter, unfortunately. I didn't dig into it in a ton of detail, but nothing surface-level came to mind.

Maybe this is some reflection magic I'm unfamiliar with.

(Yep! I remember being a bit surprised myself, but it makes sense that it'd have to work this way if you think about it...)
Logged

TimeDiver

  • Commander
  • ***
  • Posts: 221
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9233 on: October 02, 2022, 07:20:27 PM »

@TimeDiver

Hmm, manually log (with Global.getLogger(class)) whether each of the params in the addMessage call is null or otherwise invalid input?

Also the addMessage javadoc says you can feed it a ShipAPI directly instead of getting a FleetMemberAPI first, so might be worth trying that (even if it doesn't fix the crash the code is cleaner).
Thanks for the feedback, but I went with a kludge-y workaround; I changed the mission's flagship from the super-capital to another ship w/o modules (and applied the skill changes to that ship's captain instead) and just transfer over to the super-capital once the mission starts.
Logged

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 166
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9234 on: October 02, 2022, 07:51:51 PM »

1. No idea if I asked before, or no idea of what's going on?

The latter, unfortunately. I didn't dig into it in a ton of detail, but nothing surface-level came to mind.

Apparantly, according to a bunch of people on the unofficial discord, the bug shown in the video is actually not isolated to my mod. It happens in a bunch of saves, with varying levels of modding, and just, randomly. I haven't dug too deep into this, but from the sounds of it, this could be less of a isolated incident and some kind of underlying issue, potentially, with vanilla, although I won't discount the major possibility of some weird mod schenanigan. Here's what I asked people, and their responses:
Spoiler
https://discord.com/channels/187635036525166592/512356777451323393/1026320489687285800

niko: heloo starsector gamers
[10:31 PM]niko: has anyone ever had a weird bit of behavior in campaign where fleets fighting eachother sometimes drift away from eachother
[10:31 PM]niko: i was told tjhis was a vanilla bug at some point and im curious to if iti s
[10:31 PM]Underdrown: yeah 2 times now
[10:31 PM]mrmagolor: I've seen it
[10:32 PM]niko: really?
[10:32 PM]niko: hm
[10:32 PM]niko: https://cdn.discordapp.com/attachments/824910699415207937/1025820788667985991/Jdk7_2022.10.01_-_13.24.53.02.mp4
[10:32 PM]LifeOnHigh: same
[10:32 PM]niko: did it look like this?
[10:32 PM]niko: in any capacity?
[10:32 PM]LifeOnHigh: yes
[10:32 PM]Underdrown: yep
[10:32 PM]niko: how much in terms of similarity
[10:32 PM]niko: scale of 0% to 100%
[10:32 PM]Underdrown: even more faster for me
[10:33 PM]LifeOnHigh: happens all the time for me
[10:33 PM]niko: they just
[10:33 PM]niko: infinitely drift apart?
[10:33 PM]Yholl: yeah it happens
[10:33 PM]Underdrown: yes
[10:33 PM]niko: as if the fleets maintained their velocity
[10:33 PM]niko: and final question has anyone encountered this with only libs/very light mods
[10:33 PM]niko: /no mods
[10:33 PM]niko: i ask
[10:33 PM]niko: because im wondering if is hould tell alex this is a vanilla bug
[10:35 PM]niko: 'cause if its a vanilla bug
[10:35 PM]niko: my mod has a 100% replication rate

https://discord.com/channels/187635036525166592/187635036525166592/1026321715556520037
[10:36 PM]niko: https://discord.com/channels/187635036525166592/512356777451323393/1026320440374874222

^ i require your feedback, read the thread on this and tell me your answers to the questions if youve got any
[10:36 PM]Lasersquid112: yes, fleets will occasionally float away in combat
[10:36 PM]niko: to a similar extent to the video shown?
[10:36 PM]niko: (also important to ask how heavily your game is modded)
[10:37 PM]Jaiden1121: ive seen them fly further
[10:37 PM]Jaiden1121: they even get hit by replicating minefields when flying in combat
[10:37 PM]niko: damn
[10:37 PM]niko: okay
[10:37 PM]niko: interesting
[10:37 PM]Lasersquid112: that's legit nothing lol
[10:37 PM]Lasersquid112: they can drift forever if the battle goes long enough
[10:38 PM]niko: aight im gonna tell alex 'bout this since
[10:38 PM]niko: they dont seem aware this might be a vanilla bug
[10:38 PM]dynz: 'might'
[10:38 PM]niko: or
[10:38 PM]niko: somethin
[10:38 PM]Jaiden1121: pfft keep it
[10:38 PM]niko: ...wait nevermind i still dont know how modded the games are
[10:38 PM]niko: fools tell me
[10:38 PM]Jaiden1121: mine is modded moderately lightly
[10:38 PM]Lasersquid112: i have like,,
[10:38 PM]Lasersquid112: 127 mods?
[10:38 PM]niko: jeesus
[10:38 PM]Lasersquid112: or something idk
10:43 PM]niko: could you like, elaborate a little, for the report im gonna make to em?
[10:43 PM]niko: like, when does it happen, in what context, etc
10:43 PM]niko: and how bad
[10:44 PM]Jaiden1121: it usually happens when two large fleets fight for a bit, albeit in my experience its happened most with stations
[10:44 PM]PixiCode: I've never seen drift that bad, but i have seen drift
[10:44 PM]niko: is there any notiucable difference in the context surrounding the battles that do this compared to normal battles
[10:45 PM]Jaiden1121: non station simply starts orbiting? i guess the station faster and faster, while still being able to be effected my environmental effects such as asteroids, or in my case, mines lol
[10:45 PM]niko: (ex. the incoming fleet is going mach 9)
[10:45 PM]PixiCode: I would like to help more but it happens so rarely I don't have any details
[10:45 PM]Jaiden1121: now that? i didnt look far enough into to notice
[10:45 PM]niko: interesting
[10:45 PM]niko: thats real interesting actually
[10:45 PM]niko: because it emulates behavior of my mod when i set an orbit on my satellites
[10:45 PM]niko: thanks
[10:45 PM]niko: thisll help
[close]


And here's the modlist of jaiden:
Spoiler
[close]
The only mods enabled in my game are magiclib, lazylib, MPC, and console commands.

What I find really interesting is what Jaiden said about fleets "orbitting" the fleet they're attacking-this behavior sounds suspiciously similar to what happens when I give my satellite fleet a orbit around the planet. If you remember in my original post, I said attacking fleets would loosely "orbit" the satellite fleet in that scenario, same thing that might be happening here.
Logged

Timid

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

So what did I do wrong? Added the 'ship != null' conditional check in the wrong location?
Yes, it should be first before the first 2 checks. You already got it with that answer

presidentmattdamon

  • Commander
  • ***
  • Posts: 129
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9236 on: October 03, 2022, 09:14:42 AM »

any way we can get smething like ShipAPI.get/setCustomData except for FleetMemberAPI?
Logged

Timid

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

Can a ShipAPI get its "factionid" of its side it's fighting on or is it just fairly limited to getOwner() being enemy, friendly, or hostile?

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 166
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9238 on: October 03, 2022, 05:07:41 PM »

Can a ShipAPI get its "factionid" of its side it's fighting on or is it just fairly limited to getOwner() being enemy, friendly, or hostile?

BattleSide is not bound to a faction. IT can be a mix of different factions. Try ShipAPI.getFleetMember().getFleet().getFaction(), or some variation of that.
Logged

Cry0genic

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9239 on: October 03, 2022, 08:21:11 PM »

Something needs to call that code - either using the console commands, or - as you say - by editing the sector gen files.

That it is doable through console commands is a great relief. I'll now try to figure out how to do so through it, thanks for the reply!
Logged
Pages: 1 ... 614 615 [616] 617 618 ... 625