Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: [0.8.1a-RC8] Allied forces endlessly harass 0 CR enemy fleet, never destroy it.  (Read 3092 times)

stormbringer951

  • Commander
  • ***
  • Posts: 130
    • View Profile

Bug:

Allied forces always choose to harass 0 CR enemy fleet, never pursue and actually destroy it. Extensive modlist but I believe the core issue here is related to vanilla battle AI's decision-making about whether to pursue/harass/let go.

Repro steps:

Save folder zip.

I'm playing Nexerelin and a Tyrador Safeguard Coalition invasion fleet is over Chicomotzoc fighting the Hegemony defence station and several small response fleets.

Attempt to join the battle so you can check the status of the fleets. The Coalition fleet should have approximately 0 CR.  The Hegemony's battle station and several small response fleets will repeatedly engage it but not destroy it. Sit and watch for a while as this continues to happen.

Dock at Chicomotzoc, get Hegemony commission.

Attempt to attack enemy fleet. Whenever I joined, the battle was ongoing. The Hegemony forces will choose to harass their opponents as they try to retreat every time, despite the enemy fleet being at 0 CR.

The fleet seemed to try to flee me repeatedly, but kept on being sucked back into battle where the Hegemony would choose to harass them.

The first time, the enemy fleet ended up sitting directly over the planet and being endlessly harassed. On a later attempt to check the repro steps work, after a while I managed to get their fleet to flee me away from the radius of the battle station so I could initiate the fight. All the Coalition ships immediately blew themselves up as they entered battle.
Logged
Weapons Group Controls mod - deselect all weapon groups, hold-down hold-fire mode, toggle alternating/linked fire
Captain's Log - throw away your notepad: custom notes, ruins and salvageable reminders
Old Hyperion - for your dose of nostalgia
Adjustable Skill Thresholds - set fleet DP and fighter bay thresholds

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile

Thanks for the report! I think there are two likely-separate issues here. One is that vanilla autoresolve doesn't handle stations (as it's not something that comes up in vanilla), and the other is its decision to harass if the player joins in, for whatever reason.

I'll take a look at some point; just in general the code for handling stations both in player-involved combat and AI-vs-AI autoresolve isn't very robust and was only meant to handle the rather narrow vs-Remnant/Derelict station case, and it needs to be expanded on.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile

Nexerelin has a modified autoresolve plugin that handles stations, which appears to work adequately in most cases; but the issue I was trying to solve at the time was the station not dying, not the fleet.
If I find the time I'll look at the autoresolve debugging logs and see what's going on with the zero-CR fleet.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile

There's some weirdness where FleetMemberStatusAPI.applyHullFractionDamage() doesn't seem to be lowering the hull fraction below 0.5.

Code: java
	/**
* Damages the hull by a specified fraction if ship does not have Vast Bulk;
* else damages a randomly picked module
* @param member
* @param damageFraction
*/
protected void addDamage(FleetMemberAPI member, float damageFraction)
{
boolean hasVastBulk = member.getVariant().hasHullMod("vastbulk");
if (!hasVastBulk)
{
report("  Damage fraction: " + damageFraction);
report("  Hull before: " + member.getStatus().getHullFraction());
member.getStatus().applyHullFractionDamage(damageFraction);
report("  Hull after: " + member.getStatus().getHullFraction());
}
else {
//preventModuleRespawn(member);
addDamageToOneModule(member, damageFraction);
}
}

Code
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  - Applying damage to loser's ships
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  - --------------------------------------------
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  - Remaining damage to loser: 429.07
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  - Disabled: 16, Heavy: 8, Medium: 9, Light: 0, Unscathed: 7 (Shield ratio: 0.67)
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -       Ranseur-class Fire Support Frigate: heavy damage
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Damage fraction: 0.2516773
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull before: 0.55493486
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull after: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Damage fraction: 0.2516773
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull before: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull after: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Damage fraction: 0.2516773
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull before: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull after: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Damage fraction: 0.2516773
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull before: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull after: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Damage fraction: 0.2516773
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull before: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull after: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Damage fraction: 0.2516773
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull before: 0.5
544524 [Thread-5] INFO  exerelin.campaign.battle.NexBattleAutoresolvePlugin  -   Hull after: 0.5

I can't say for sure whether it's specific to any particular conditions (all ships have zero CR, losing fleet is retreating, etc.)

This is a fairly heavily modded game and my attempt to reproduce it with no mods other than LazyLib + console failed, but I'm not seeing how any mod code could affect the specific call, hurm...
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile

Taking a look at it, getHullFraction() returns the average hull for all modules, so I'd guess the ship in question has one module. If you want the hull fraction for the base hull, you can call getHullFraction(0).
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile

The getHullFraction() overload with integer arg isn't in 0.8.1a, unfortunately.

Anyway, I tried forcibly setting the modules' hull to zero and/or calling setDetached() on them, but returned hull fraction still doesn't drop below 0.5.
For stations with Vast Bulk I just manually track each module's hull level and detach it as needed, and destroy the central hull when all the modules are detached, but this doesn't work for regular ships. I guess this isn't solvable short of Starsector 0.9.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile

Ah, hmm. Well, I'll definitely be looking at it when updating autoresolve to handle much the same things.

As far as workarounds - your implementation of autoresolve could just ignore all this entirely, right? It's not at all obligated to use the getHullFraction() stuff etc.
Logged