Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 326 327 [328] 329 330 ... 461

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

Sundog

  • Admiral
  • *****
  • Posts: 1143
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4905 on: August 27, 2019, 04:49:17 PM »

I've been trying to pinpoint the cause of this crash for a few days, since a few people (including me) initially thought it might be caused by starship legends. It seems to be caused by some error or omission in ship_data.csv. The stack trace makes me suspect that the crash occurs when ships with erroneous ship_data.csv entries are present at a market when the player interacts with it. So my question is; what missing or invalid entry could cause an NPE on line 48 of CRPluginImpl?
Code
	public void applyMaxCRCrewModifiers(FleetMemberAPI member) {
float maxCRBasedOnLevel = 0.7f;
------>         member.getStats().getMaxCombatReadiness().modifyFlat("crew skill bonus", maxCRBasedOnLevel, "Basic maintenance");

So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
SectorManager itself has other Nexerelin dependencies, so if you go that route you'll basically end up needing to bundle the entirety of Nex with your mod. If you can't reliably import SectorManager from a script, it sounds like the only option is to compile a jar.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17243
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4906 on: August 27, 2019, 05:06:12 PM »

I've been trying to pinpoint the cause of this crash for a few days, since a few people (including me) initially thought it might be caused by starship legends. It seems to be caused by some error or omission in ship_data.csv. The stack trace makes me suspect that the crash occurs when ships with erroneous ship_data.csv entries are present at a market when the player interacts with it. So my question is; what missing or invalid entry could cause an NPE on line 48 of CRPluginImpl?
Code
	public void applyMaxCRCrewModifiers(FleetMemberAPI member) {
float maxCRBasedOnLevel = 0.7f;
------>         member.getStats().getMaxCombatReadiness().modifyFlat("crew skill bonus", maxCRBasedOnLevel, "Basic maintenance");

After looking at the code a fair bit: the only way I could see this happening is if something called member.setVariant(null, X, X); on one of the getCargo().getMothballedShips() of the submarket. That would cause the stats to be null and ... well, hmm. Testing that out produces a different crash, ugh. So I actually don't know, it's a weird one - doesn't make sense how it would happen. All the ways I can think of seem to crash earlier in other ways.

If there's a save where this is readily reproducible and you could upload the mod folder, I'd be happy to take a look.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 2821
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4907 on: August 27, 2019, 05:08:44 PM »

Quote
So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
SectorManager itself has other Nexerelin dependencies, so if you go that route you'll basically end up needing to bundle the entirety of Nex with your mod. If you can't reliably import SectorManager from a script, it sounds like the only option is to compile a jar.
Could also use some other way to detect non-random sector mode; e.g. checking if Jangala or the Corvus system exist.

Next version of Nex might just set a flag in Sector memory.
Logged

Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4908 on: August 27, 2019, 05:17:49 PM »

You could do it there, or you could provide a different plugin for the conditions. It's hard to answer the question because there's a ton of different ways you could go about this and it all depends on what exactly you want to accomplish. It's all going to require code, though.

I'm not going for anything in particular at this moment. I was looking trough the industry plugins and noticed that farming and mining don't have supply specified in their classes, and yet they produce commodities. Thought it might be located elsewhere or related to the said conditions class in some way. Thanks.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17243
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4909 on: August 27, 2019, 05:20:20 PM »

Ah - yeah, it's handled in the ResourceDepositsCondition, as you surmised.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 1797
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4910 on: August 27, 2019, 05:47:51 PM »

Thanks for the reply Alex!

I did put in a check for that, with Get_Messy being the method to find the entity;

Code
		
SectorEntityToken spawnEntityMess = Get_Messy();
if (spawnEntityMess == null) {
return null;
}

However the problem persists. Am I doing it in the wrong area?

You need to stop spawnFleet() from ever being called in the advance() method if the spawnEntity is null. Or ensure that Get_Messy() never returns null somehow.
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1143
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4911 on: August 27, 2019, 06:32:44 PM »

After looking at the code a fair bit: the only way I could see this happening is if something called member.setVariant(null, X, X); on one of the getCargo().getMothballedShips() of the submarket. That would cause the stats to be null and ... well, hmm. Testing that out produces a different crash, ugh. So I actually don't know, it's a weird one - doesn't make sense how it would happen. All the ways I can think of seem to crash earlier in other ways.
Yeah, it's bizarre. I can't imagine anything that might prevent a ship from having stats, especially anything to do with ships_data.

If there's a save where this is readily reproducible and you could upload the mod folder, I'd be happy to take a look.
I'll see if I can get a hold of one. I haven't actually experienced this crash myself.

Histidine

  • Admiral
  • *****
  • Posts: 2821
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4912 on: August 28, 2019, 05:38:36 AM »

Does the local resources submarket not update for hidden markets? If so, is there a way to change this that isn't "add the things yourself in an EveryFrameScript"?
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1314
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4913 on: August 28, 2019, 06:01:43 AM »

Quote
So basically, by copying that SectorManager.java into my mod folder, it should work without Nex?
SectorManager itself has other Nexerelin dependencies, so if you go that route you'll basically end up needing to bundle the entirety of Nex with your mod. If you can't reliably import SectorManager from a script, it sounds like the only option is to compile a jar.
Could also use some other way to detect non-random sector mode; e.g. checking if Jangala or the Corvus system exist.

Next version of Nex might just set a flag in Sector memory.

Or I can just ship 2 different version of the ModPlugin
Logged

NoFoodAfterMidnight

  • Ensign
  • *
  • Posts: 39
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4914 on: August 28, 2019, 07:41:10 AM »

I'm at my wit's end trying to figure out how to remove a buff from a FleetMemberAPI after it's been salvaged by a player. The buff applies a bonus to a bunch of stats in MutableStatsAPI through the buff's Apply(), and I've added a custom unapply() method to remove the buffs when called or the buff expires. I've tried adding BuffManagerAPI.removeBuff()/setting the duration to 0 to ShipRecoverySpecial, using the right buff ID, but it's not working. Is there an every-frame method in the campaign screen I can refer to the player's fleet then shove some remove buff methods into?

Is there something totally simple I'm missing that can easily remove the effects of buffs, or am I just failing to implement it being removed on salvage?

Or for what I'm doing, just changing a ship's MutableStatsAPI, would it be easier to modify them directly without using buffs? Are MutableStatsAPI's reset on a ship's destruction/recovery?
« Last Edit: August 28, 2019, 07:47:40 AM by NoFoodAfterMidnight »
Logged

Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4915 on: August 28, 2019, 09:25:32 AM »

Is it possible to get the monthly income total of a faction? Or is it tracked only for the player?

Also, getAvailable from the commodity tracker gets the max export or the total value? I'm want to sum up the total units of commodities produced by a faction. I found getTotalSupply in the CommodityStatTracker, but its' usage seems to be related to the demand in some way ( as in float demand = com.getDemand().getDemandValue(); -> float supply = demand; ->totalSupply += supply;) so I'm not sure if that's what I'm looking for. Nvm, figured it out.
« Last Edit: August 28, 2019, 10:10:00 AM by Salv »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17243
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4916 on: August 28, 2019, 09:36:04 AM »

I'm at my wit's end trying to figure out how to remove a buff from a FleetMemberAPI after it's been salvaged by a player. The buff applies a bonus to a bunch of stats in MutableStatsAPI through the buff's Apply(), and I've added a custom unapply() method to remove the buffs when called or the buff expires. I've tried adding BuffManagerAPI.removeBuff()/setting the duration to 0 to ShipRecoverySpecial, using the right buff ID, but it's not working. Is there an every-frame method in the campaign screen I can refer to the player's fleet then shove some remove buff methods into?

Is there something totally simple I'm missing that can easily remove the effects of buffs, or am I just failing to implement it being removed on salvage?

Or for what I'm doing, just changing a ship's MutableStatsAPI, would it be easier to modify them directly without using buffs? Are MutableStatsAPI's reset on a ship's destruction/recovery?

You need to use a buff because the stats are not persistent just get recreated when needed, and the modifiers (from hullmods, captains, skills, buffs, etc) get applied at that point. If you're calling getBuffManager().removeBuff(), that should trigger a stats update, which would mean the stats get recreated without the effect of the removed buff.

It's hard to say exactly what might be going on without seeing a bit of code.


Is it possible to get the monthly income total of a faction? Or is it tracked only for the player?

Technically possible, but it's really only meant to be player-facing and AI colonies aren't balanced around that.
Logged

Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4917 on: August 28, 2019, 09:44:18 AM »

Technically possible, but it's really only meant to be player-facing and AI colonies aren't balanced around that.

Is int total = (int) (report.getRoot().totalIncome - report.getRoot().totalUpkeep); from public void doCustomProduction close to what I could use as the starting point of reference?
« Last Edit: August 28, 2019, 09:48:45 AM by Salv »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17243
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4918 on: August 28, 2019, 09:49:04 AM »

No, that's just the player's monthly income report. You want market.getNetIncome() for whatever markets you're interested in. For getting the markets, see the code in Misc.getFactionMarkets().
Logged

Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4919 on: August 28, 2019, 09:56:11 AM »

Okay. Thank you again.
Logged
Pages: 1 ... 326 327 [328] 329 330 ... 461