scp-fs2open / fs2open.github.com

Origin Repository for SCP FreeSpace 2 Open
https://www.hard-light.net/
Other
401 stars 161 forks source link

ASSERTION: "shield_pct >= 0.0f && shield_pct <= 1.0f" at ship.cpp:10326 #3374

Closed MjnMixael closed 3 years ago

MjnMixael commented 3 years ago

Got this assert in BtA's Bringing Down the Gavel mission. I have narrowed it down to the change-ship-class sexp. Happens every single time.

Run BtA 1.5.8, play the that mission. Skip the cutscene and Alt-J to the asteroid site. There will be a couple seconds of dialog. When the convoy appears, use the specified keys (should be Alt-Shift-A, Alt-Shift-D, Alt-Shift-Z.. but you may need to check your Control Config for the custom keybinds to make sure they are set.) to take over Gavel's fighter. You'll swap into the Mustang class. Then just use Alt-Shift-D or Z to swap back to the Apollo. Assert.

MjnMixael commented 3 years ago

Further information. This mission has had no major changes since as far back as 2017. Not to say that the mission isn't doing something stupid, but this whole ship-swapping thing it does used to work. If there's a mission issue, I'd appreciate help tracking it down as the assert is less than helpful.

I can say this does occur on 21.1.0. Testing much further back is quite difficult due to the complexity of the mod.

JohnAFernandez commented 3 years ago

I reproduced it. It looks like the shield strength of the mustang at the assert is 400 but the max shield strength is 200. I haven't been able to do anything else with it yet, but I would double check that there's nothing setting the shield string too high in either sexps or in scripting.

MjnMixael commented 3 years ago

Can you clarify which mustang has that issue? Is it Alpha 1 or Diamond 1?

JohnAFernandez commented 3 years ago

Looks like Alpha 1

MjnMixael commented 3 years ago

Hmm. Well Alpha switches from a Mustang (default shield HP 200) to a Loki (default shield HP 400). There's nothing else in the mission that explicitly sets shield energy as far as I can tell. No scripts are used for this hotswap.

I copied the hotswap on/off sexps to a blank mission and did not get the assert.. so that wasn't helpful. I removed all kinds of set-armor-type (shield), ship-copy-damage (I thought this was a good lead as it copies damage from a Loki to Alpha 1. But it happens after change-ship-class and removing it did not stop the assert), etc sexps to no effect. The only sexp that actually stops the assert if removed is the change-ship-class sexp.

JohnAFernandez commented 3 years ago

hmmmmm.... Ok. Let me look at things some more. Maybe figure out why all the shield quadrants are getting set to 100 each before they are changed in change_ship_type

JohnAFernandez commented 3 years ago

You have special shield hitpoints for Diamond 1 set to 400. Those special shield hitpoints get transferred to Alpha 1, then when it tries to change back to a loki, it trips the assert.

JohnAFernandez commented 3 years ago

Ok, I'm testing a fix. It looks like the ship-copy-damage sexp neglects to copy the special shield hitpoints from the source to the target, so FSO.

Yup, fixed!