aliens

Author Topic: [FIXED] Crew don't get to eject if craft was retreating when destroyed by HK  (Read 1844 times)

Offline zRrr

  • Sergeant
  • **
  • Posts: 31
    • View Profile
When XCom craft is destroyed by Hunter-Killer ufo, pilots and passangers usually get a chance to survive and end up transferred to home base. But when "Disengage" button is pressed, they never escape.

I believe this happens because "Disengage" button sets _end field to true, and then check at DogfightState.cpp:1444 skips call to evacuateCrew (sorry, forum does not allow me to post github link).

Attached save for Piratez with craft types edited for demonstration. Intercept ufo, get shot to last bits of health, press retreat. There will be no gals in transfer, and no "Vessel lost" message either.

Offline Vakrug

  • Colonel
  • ****
  • Posts: 320
    • View Profile
Re: Crew don't get to eject if craft was retreating when destroyed by HK
« Reply #1 on: November 01, 2023, 10:27:20 am »
I knew that something is wrong with "evacuation", but I couldn't figure out what exactly, because problem seems to be very inconsistent. Now I know that  "Disengage" button is the culprit. Thanks!

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Crew don't get to eject if craft was retreating when destroyed by HK
« Reply #2 on: November 01, 2023, 11:52:24 am »
yeah, the dogfightstate is beyond help
it's not possible to maintain or extend it anymore without a complete rewrite

anyway, I checked where I could move this function to always trigger, but I haven't found a single suitable place
I will move it outside of this class, but it will be at a cost:

a/ it will be called not only for HKs, but for all UFOs
b/ I will change the evac defaults from 100% to 0% (for OG/OXC compatibility), so mods that don't specify them explicitly (including XPiratez) will break... and will have to add the desired values in the next version explicitly

Offline zRrr

  • Sergeant
  • **
  • Posts: 31
    • View Profile
Re: Crew don't get to eject if craft was retreating when destroyed by HK
« Reply #3 on: November 01, 2023, 06:04:54 pm »
Wish I could be more helpful.

I think it is safe to pull craft handling part outside of if (!_end) {} block, since crafts are not shared between DogfightState instances, and cleanup code there is called at most once per instance.

Or, to preserve symmetry, fatal damage to craft can do _end = false; like it is done with damage to ufo.

I've did a few tests with both of changes, they fix this issue and do not break anything at first glance, but it is hard to be sure...

Offline Dioxine

  • Commander
  • *****
  • Posts: 5455
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Crew don't get to eject if craft was retreating when destroyed by HK
« Reply #4 on: November 02, 2023, 01:43:57 pm »
yeah, the dogfightstate is beyond help
it's not possible to maintain or extend it anymore without a complete rewrite

anyway, I checked where I could move this function to always trigger, but I haven't found a single suitable place
I will move it outside of this class, but it will be at a cost:

a/ it will be called not only for HKs, but for all UFOs
b/ I will change the evac defaults from 100% to 0% (for OG/OXC compatibility), so mods that don't specify them explicitly (including XPiratez) will break... and will have to add the desired values in the next version explicitly

Just please give me a heads-up for this.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Crew don't get to eject if craft was retreating when destroyed by HK
« Reply #5 on: November 04, 2023, 11:28:02 am »
Just please give me a heads-up for this.

You can configure the defaults already in the current version:

Code: [Select]
pilotsEmergencyEvacuationSurvivalChance: 100
crewEmergencyEvacuationSurvivalChance: 100

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
a/ it will be called not only for HKs, but for all UFOs
b/ I will change the evac defaults from 100% to 0% (for OG/OXC compatibility), so mods that don't specify them explicitly (including XPiratez) will break... and will have to add the desired values in the next version explicitly

a/ done here: https://github.com/MeridianOXC/OpenXcom/commit/57c2ebeef5ec69be9828eeedc03f1694eb871c7a
b/ not done

PS: if somebody wants to attack battleships with skyrangers in vanilla, and wants the soldiers onboard to die, mod the survival odds back to zero... I'm not changing the OXCE default value just for this corner case