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)

Author Topic: spawnShipOrWing()  (Read 3074 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
spawnShipOrWing()
« on: January 21, 2014, 07:56:41 PM »

...should have posted this here, rather than in the release thread.  Sorry.

Alex, is spawnShipOrWing() safe now, or is it still going to cause NPEs when these ships can be "captured" and the engine tries to get their FleetMemberIds?

This code appears to work now:

Code
ShipAPI thisShip = engine.getFleetManager(FleetSide.PLAYER).spawnShipOrWing("clover_Standard", missileLoc, facing);
applyCRToShip(1f, thisShip);

So I guess I'll test it and see what happens.  Guessing we're still going to see NPEs, though.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: spawnShipOrWing()
« Reply #1 on: January 21, 2014, 08:01:28 PM »

Gah.  I'm mistaken.  When a weapon with this Missile is mounted, I sometimes am crashing with this error, in the Refit screen:

Code
134203 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.movement.maneuvers.OO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.OooO$o.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.OooO.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.title.OoOO.o00000(Unknown Source)
at com.fs.starfarer.B.ØÓÒ000(Unknown Source)
at com.fs.oOOO.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Probably it's trying to instantiate a ship right then and there.  I'll test for engines being on (on the missile that does the spawn behavior) and see if that's what's up.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: spawnShipOrWing()
« Reply #2 on: January 21, 2014, 08:22:47 PM »

Hmmph. 

Even if I test with Global.getCombatEngine().isEntityInPlay(missile) and Global.getCombatEngine().isPaused(), it's throwing a NPE.  It shouldn't be ever, ever trying to spawnShipOrWing() under those circumstances, we're in Refit (kind of surprised that this script is running at all, tbh).

Since this appears to be another goofy AI issue (at least on the surface, based on the log)... I'll set up Cruisers to use my Frigate AI for a moment and see whether that stabilizes it... maybe the Cruiser's AI is going nuts because a fighter has spawned in Refit (even thought that should be impossible).
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: spawnShipOrWing()
« Reply #3 on: January 21, 2014, 08:32:07 PM »

Indeed, it's somewhere in the BasicShipAI.  Switching to my Frigate AI fixes the issue entirely, at least for NPEs in Refit.  Now I just need to test for NPEs in campaign; guessing there will still be a crash there.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: spawnShipOrWing()
« Reply #4 on: January 21, 2014, 08:52:44 PM »

OK, so now we're down to NPEs in the campaign:

Code
269859 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyExtendedCRLossIfNeeded(FleetEncounterContext.java:1472)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyCREffect(FleetEncounterContext.java:1405)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyShipLosses(FleetEncounterContext.java:1376)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyResultToFleets(FleetEncounterContext.java:1292)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.processEngagementResults(FleetEncounterContext.java:98)
at data.scripts.FleetInteractionDialogPlugin.backFromEngagement(FleetInteractionDialogPlugin.java:190)
at com.fs.starfarer.campaign.A.class.for$super(Unknown Source)
at com.fs.starfarer.B.ØÓÒ000(Unknown Source)
at com.fs.oOOO.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I need to go look at the battle code and find out what "fades out" a battle at the end (and whether that, or the user choosing to exit after the defeat of the enemy Admiral can be caught at all) and try erasing all of the instances of spawned ships at that time.  Not worrying about capturing yet.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Cosmitz

  • Admiral
  • *****
  • Posts: 758
    • View Profile
Re: spawnShipOrWing()
« Reply #5 on: January 21, 2014, 09:05:43 PM »

Am i the only one that likes watching you go through a process? :D
Logged

Uomoz

  • Admiral
  • *****
  • Posts: 2663
  • 'womo'dz
    • View Profile
Re: spawnShipOrWing()
« Reply #6 on: January 21, 2014, 09:07:04 PM »

Logged

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: spawnShipOrWing()
« Reply #7 on: January 22, 2014, 04:46:31 AM »

Am i the only one that likes watching you go through a process? :D

And the funniest (not really for him) part is, the actual amount of NPE he had to go tro before he posted each time
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: spawnShipOrWing()
« Reply #8 on: January 22, 2014, 09:57:34 AM »

Gah.  I'm mistaken.  When a weapon with this Missile is mounted, I sometimes am crashing with this error, in the Refit screen:

Code
134203 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.combat.ai.movement.maneuvers.OO0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.OooO$o.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.movement.maneuvers.OooO.o00000(Unknown Source)
at com.fs.starfarer.combat.ai.BasicShipAI.advance(Unknown Source)
at com.fs.starfarer.combat.CombatEngine.advance(Unknown Source)
at com.fs.starfarer.title.OoOO.o00000(Unknown Source)
at com.fs.starfarer.B.ØÓÒ000(Unknown Source)
at com.fs.oOOO.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Probably it's trying to instantiate a ship right then and there.  I'll test for engines being on (on the missile that does the spawn behavior) and see if that's what's up.

This appears to be happening in the title screen, not the refit screen. Would probably happen even if you didn't have the refit screen open.


OK, so now we're down to NPEs in the campaign:

Code
269859 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyExtendedCRLossIfNeeded(FleetEncounterContext.java:1472)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyCREffect(FleetEncounterContext.java:1405)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyShipLosses(FleetEncounterContext.java:1376)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.applyResultToFleets(FleetEncounterContext.java:1292)
at com.fs.starfarer.api.impl.campaign.FleetEncounterContext.processEngagementResults(FleetEncounterContext.java:98)
at data.scripts.FleetInteractionDialogPlugin.backFromEngagement(FleetInteractionDialogPlugin.java:190)
at com.fs.starfarer.campaign.A.class.for$super(Unknown Source)
at com.fs.starfarer.B.ØÓÒ000(Unknown Source)
at com.fs.oOOO.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I need to go look at the battle code and find out what "fades out" a battle at the end (and whether that, or the user choosing to exit after the defeat of the enemy Admiral can be caught at all) and try erasing all of the instances of spawned ships at that time.  Not worrying about capturing yet.

Since this one is in the FleetEncounterContext, you could actually change the code that's crashing, right? Instead of working around it, I mean.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: spawnShipOrWing()
« Reply #9 on: January 22, 2014, 10:05:53 AM »

Quote
This appears to be happening in the title screen, not the refit screen. Would probably happen even if you didn't have the refit screen open.
Yeah, it's related to the Cruiser AI (most of the ships that mount one of these "weapons" are Cruisers).

Quote
Since this one is in the FleetEncounterContext, you could actually change the code that's crashing, right? Instead of working around it, I mean.
Yeah, I think it's related to after-battle cleanup activities, specifically, fixing dead ships to the point where they can be Boarded. 

I think what I'm going to try and do is go ahead and bite the bullet and write a new version of this Dialog, just a very simplistic one for now to test and see whether that gets rid of the last of the bugs related to this.
Logged
Please check out my SS projects :)
Xeno's Mod Pack