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); In-development patch notes for Starsector 0.98a (2/8/25)

Author Topic: Hard Flux Drain Per Cap  (Read 4639 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Hard Flux Drain Per Cap
« on: March 19, 2016, 10:59:28 PM »

OK, I tested out one of my suggestions (Hard Flux constant drain per Cap) in the last round of feedback; the results were very good (for the AI) and not terribly OP (for the player).

Code used:
Spoiler
Code: java
//Drains a smallish amount of Hard Flux per second, depending on ship size and total Flux Capacity.
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ViewportAPI;
import java.util.List;


public class FluxCapHardFluxDrain implements EveryFrameCombatPlugin
{
private CombatEngineAPI engine;

    @Override
public void init(CombatEngineAPI engine) {
this.engine = engine;
}
       
    @Override
public void advance(float amount, List events)
{
// Obvious exploits are obvious
if (engine == null) return;
if (engine.isPaused()) return;
float drainFraction = 150f;

for (ShipAPI ship : engine.getShips()){
//Skip all the ships that this shouldn't apply to, like ships that are Phased, Venting, etc., etc.
if(!ship.isAlive() || !ship.isPhased() || ship.getFluxTracker().isOverloadedOrVenting() || ship.getHardFluxLevel() <= 0f) continue;
//If the ship qualifies for a drain, drain now.
//Start by computing the Drain Threshold, which is a ratio of Capacity vs. a number that results in total drain / second.
//Small stuff gets a better (lower) number here, because they get significantly less Capacity per OP, etc.
switch(ship.getHullSize()){
case DESTROYER:
drainFraction = 250f;
break;
case CRUISER:
drainFraction = 350f;
break;
case CAPITAL_SHIP:
drainFraction = 500f;
break;
}
//Now apply the drainThreshold vs Capacity and time elapsed to get the amount of Hard Flux drain this frame
drainFraction = (ship.getMutableStats().getFluxCapacity().getModifiedValue() / drainFraction) * amount * engine.getTimeMult().getModifiedValue();
//How much Hard Flux should we have now?
if (ship.getFluxTracker().getHardFlux() - drainFraction < 0f) {
ship.getFluxTracker().setHardFlux(0f);
} else {
drainFraction = ship.getFluxTracker().getHardFlux() - drainFraction;
//Set it.
ship.getFluxTracker().setHardFlux(drainFraction);
}
}
}

@Override
public void renderInWorldCoords(ViewportAPI vapi) {
}

@Override
public void renderInUICoords(ViewportAPI vapi) {
}
}
[close]

Main benefits of this code, when tested:

1.  The AI benefits quite a lot from this, just like the AI benefits disproportionately from SO and from Captains w/ level-10 Power Management.  

2.  Why does the AI benefit so much from anything that provides a drain on Hard Flux, moreso than the player?  

A.  The player is usually out-numbered, and so there may be multiple foes taking hits for Hard Flux.
B.  This drain basically makes the player attempting to kite everything to death much harder, because the player must focus, rather than gradually building up Hard Flux on all nearby foes whilst retreating / Vent-spamming.  It's another time-pressure device, in that sense.
C.  For larger ships, even though the proportion is lower, the total Capacity is high enough that it's a significant drain vs. low-DPS weapons that are particularly good to kite gradually with.
D.  This isn't enough drain to do anything significant to the outcome vs. high-alpha weapons or Kinetics that are focused on kiting outcomes at good tradeoffs, such as Railgun spammers or Light Needler burst-alpha.  It's mainly good against slow kiting tactics (i.e., the stuff that the game balance is supposed to prevent) rather than focused alphas (which are Fun).

3.  The ability to put a genuinely-useful emphasis on Capacity is nice.  It gives ships with high Capacity that are otherwise pretty lame, like the Aurora, a genuine benefit, in terms of survivability.

4.  It really doesn't change outcomes with player ships much.  This isn't a tool you can use to make a Paragon significantly more invulnerable than it already is with a leveled character, for example; compared to the 20% drain from Combat, this is minor.  It's really something that needs to be seen as a fleet-tactics buff more than anything else, because it levels the playing field quite a lot when the AI has more ships than the player.
« Last Edit: March 20, 2016, 10:11:32 AM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Hard Flux Drain Per Cap
« Reply #1 on: March 19, 2016, 11:44:55 PM »

Sorry to nitpick but your code sample has several problems.

  • The collision class check should not be used.  Ships that are in phase don't necessarily have NONE collision, and ships with NONE collision aren't necessarily in phase.  Use ship.isPhased() instead.
  • The check for ship.isHulk() is redundant and should be removed.
  • It's extremely unlikely that a ship could not be in play if you're grabbing it from engine.getShips(), so you don't need engine.isEntityInPlay().
  • drainThreshold should be a local variable in the advance function.  There is no reason to keep it in the heap.
  • Instead of using ship.is*() checks, it would be more efficient to do a switch on hull size.
  • drainThreshold should be range checked so you don't set flux below 0.
  • Don't use engine.getElapsedInLastFrame(), just use the "amount" parameter passed into the advance function.
  • Time manipulation is not taken into account; use the getTimeMult() mutable stat as a coefficient for "amount".
  • "drainThreshold" is not really an accurate variable name.  Something like "drainFraction" maybe?
« Last Edit: March 19, 2016, 11:53:52 PM by Dark.Revenant »
Logged

Auraknight

  • Commander
  • ***
  • Posts: 126
  • I am a Knight of Aura.
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #2 on: March 20, 2016, 12:17:18 AM »

This is interesting, but I have a small worry. Just starting out on a new save in SS+ with a whole slew of mods, and getting an early wipe, I respawn in a small ship, against one half-health, and CR pirate enforcer. This ship i've just spawned in has a single railgun, some harpoons, and inconsequential energy weapon. With the railgun, i was able to plink away hard flux onto this enforcer, at a constant rate while side-flying most of it's shots, and shielding the rest. Would this free hard flux drain prevent a situation where a wounded ship like this could be picked off by my fresh frigate? I wasn't dealing a whole lot of hard flux very fast.
Logged
~Aura be with you

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #3 on: March 20, 2016, 10:10:19 AM »

Quote
This is interesting, but I have a small worry. Just starting out on a new save in SS+ with a whole slew of mods, and getting an early wipe, I respawn in a small ship, against one half-health, and CR pirate enforcer. This ship i've just spawned in has a single railgun, some harpoons, and inconsequential energy weapon. With the railgun, i was able to plink away hard flux onto this enforcer, at a constant rate while side-flying most of it's shots, and shielding the rest. Would this free hard flux drain prevent a situation where a wounded ship like this could be picked off by my fresh frigate? I wasn't dealing a whole lot of hard flux very fast.
Potentially, it could, but in that case, no; a Destroyer with a weak Capacity won't have enough drain to survive that.

Against a wounded Paragon, though, yes.  Which is perfectly reasonable and you're not likely to run into a Paragon with a low-level Captain anyhow, so they probably have Power Management 10, which is way more powerful, in terms of practical survivability.

Where you'd run into serious trouble is another scenario, where you're in that weak ship facing down 4 Frigates.  You can't just close and kite each of them, gradually wearing down their capacity to fire back; if you can't concentrate fire on one of them long enough to push their shield down, you'll lose.  This makes things considerably harder (in a good way), when the CR time-clock is ticking.

Quote
Sorry to nitpick but your code sample has several problems.
Yeah, this is what happens when I write something in 15 minutes late at night after work, lol.  Fixed.  I didn't know about the hullSize enum; that'll be handy in a bunch of places.  isEntityInPlay() is a check I learned I needed for AIs, where the unlikely happens; probably overkill here; I don't know why isAlive() / isHulk() are two things, tbh; it's redundant; isDestroyed() and a DestroyEntity(CombatEntityAPI) method should exist, but doesn't- perhaps it's time to ask for that in the API.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25134
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #4 on: March 20, 2016, 10:19:40 AM »

Hmm. I'm curious about this in particular -

Where you'd run into serious trouble is another scenario, where you're in that weak ship facing down 4 Frigates.  You can't just close and kite each of them, gradually wearing down their capacity to fire back; if you can't concentrate fire on one of them long enough to push their shield down, you'll lose.  This makes things considerably harder (in a good way), when the CR time-clock is ticking.

Is gradually driving up the hard flux of several ships at the same time something you're able to do vs the vanilla AI, as a viable tactic? I'd expect them to just back off, hide behind their allies, and drop shields/vent. Since, iirc, you've worked on your own ship AI: is this perhaps an issue you're seeing with that?
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #5 on: March 20, 2016, 10:47:32 AM »

Nah, it's one of the chief ways you can kill the Vanilla AI, especially killing off Destroyer / Frigate packs with a single ship that can't just alpha them and leave, but has enough speed to keep pressure up but can Vent-spam (think Medusa, upgraded Wolf, Tempest) or is SO.

You get them all Hard Flux > 60% with kiting passes, preferably with a Beam on them to keep them from Venting, then they're not shooting very much but they aren't going to Vent yet.  Then you kill one of them without letting the others get far enough away to feel "safe" enough to Vent.  There is a cusp there where the AI basically quits being rational about its Flux levels and doesn't seem to recognize that it'd be pretty safe to Vent right now because it has buddies around, or that it's worse to not Vent, because that means it's giving up DPS it could be contributing.  It's a similar problem to the issue of Armor-heavies not knowing when / if to drop shields and tank hits (although the answer now, with ubiquitous EMP and armor tanks being largely too slow to get stuck in, is largely, "nevah!").

This isn't a problem I've found a really elegant solution for over here yet, although I think that getting a nearby-friendly count and adjusting how aggressively it Vents or drops shields based on that is probably a start; I get why it's difficult to get this fixed from the AI POV. 

This makes a small difference, though, because the player can't just push a static number up and gradually push the AIs into a corner where they can be exploited. 

The Vanilla AI does massively better with SO builds and Power Management 10, though, if you're wondering why I went ahead and did this thing, because both things create this scenario, but more potently.  Both together are pretty scary, in terms of combat power changes; the only thing that keeps it reasonable is that very few ships can use SO efficiently enough to make up for the CR timer, if flown by the AI, and it's only really nasty at the high end of Tech where you can afford the OPs.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25134
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #6 on: March 20, 2016, 10:57:43 AM »

Would you mind pointing me to a specific ship configuration (sans skills, if possible) you can do this with, vs a set of sim opponents? That would be *great* as a starting point for me to address this problem.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #7 on: March 20, 2016, 11:15:42 AM »

Sans skills?  Lasher w/ Augmented Engines, Railguns and ITU and a single torpedo to keep the AI's shields up and discourage Venting, vs. anything that's slower than it that doesn't have Light Needlers, sans skills.  Wolf can do it at base OP, but it's harder.

You can even do this with the default pair of Enforcers, with practice, but it works quite well against slower packs of anything, really.  The Enforcers also hose themselves by using Burn Drive when I'm ready to deal DPS to their weakened front armor and their Flux is high, rather than letting their buddy pressure me whilst they Vent.

The real winner, in large fleet engagements, is the Tempest, with skills; it can basically stun-lock large swarms of Frigates while getting in killing ranges occasionally.  I've watched an AI Tempest I configured / leveled kill most of a Pirate fleet solo just by keeping everybody's Flux up and being fast enough to dash in and out repeatedly.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25134
    • View Profile
Re: Hard Flux Drain Per Cap
« Reply #8 on: March 20, 2016, 11:24:51 AM »

Thank you - made a note, will take a look at this. As you say, doesn't seem like it'll be trivial to solve, but should be doable if I can reproduce it reliably enough to test/iterate with.
Logged