Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Weird Bug with getHardFluxDissipationFraction  (Read 1507 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Weird Bug with getHardFluxDissipationFraction
« on: June 26, 2013, 09:37:19 PM »

Basically, if any values are set for getHardFluxDissipationFraction via MutableShipStatsAPI, sometimes the Hard Flux gets set to zero all of a sudden (i.e. all in one game-frame, not just "fast"). 

It can be reproduced pretty easily by giving a ship a fair amount of it like so:

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

public class FluxPipeline extends BaseHullMod {
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getHardFluxDissipationFraction().modifyFlat(id,5f);
}

public String getDescriptionParam(int index, HullSize hullSize) {
return null;
}


}
...and then getting shot on purpose a lot.  It usually happens when Hard Flux hits zero while Soft Flux is > 0.

While I'm talking about this... can we get an explanation of how that value works in the game's formula? 

I've been going off of what was in the source for the character Perk, where it talks about "percentages", but percentages applied how, exactly? 

Is a value of 1.0f just the current Flux Dissipation rate derived from all bonuses removed from Hard Flux every second? 

If so, no problem, just trying to understand what, exactly, I'm monkeying around with while playing with this stuff, as I probably need to make it scalar, rather than how I have it now, where it's doing flat adding regardless of Flux Dissipation.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Weird Bug with getHardFluxDissipationFraction
« Reply #1 on: June 27, 2013, 09:48:35 AM »

Haven't looked into exactly why it's getting set to 0 instantly, but the value for getHardFluxDissipationFraction is supposed to be within the range [0, 1]. Added some code to clamp it to that.

While I'm talking about this... can we get an explanation of how that value works in the game's formula? 

It's the amount of hard flux dissipation that happens while shields are up, expressed as a fraction of the ship's modified flux dissipation.

So, 0 is the "standard" behavior - no hard flux dissipation while shields are up.

A value of 1 means that hard flux can dissipate while shields are up as if they weren't.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Weird Bug with getHardFluxDissipationFraction
« Reply #2 on: June 27, 2013, 09:52:10 AM »

Righto; that's what I figured was happening. 

I think I had values > 1 and they were getting applied on some frames, but not others, perhaps because it was driving numbers negative or something; I've fixed all that to keep the total effect <= 1 even at max hero buffs, which appears to fix most of the issue :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Weird Bug with getHardFluxDissipationFraction
« Reply #3 on: June 27, 2013, 09:55:31 AM »

Ah, makes sense. Looking at the code, the assumption that the value is <=1 being broken could indeed drive the current flux to be negative...
Logged