Haven't tested yet but it should work: in mission_templates, go to every mission you want to fix and where it tests for "num_active_teams_le, 1" replace the "main_hero_fallen" test with a test for "neg|all_enemies_defeated". Comment out all the parts where it says 'once the hero is fallen, act like he retreated'. If I'm reading it right that's what this block of code does, for example:
(1, 4, ti_once, [(main_hero_fallen)],
[
(assign, "$pin_player_fallen", 1),
(str_store_string, s5, "str_retreat"),
(call_script, "script_simulate_retreat", 10, 20, 1),
(assign, "$g_battle_result", -1),
(set_mission_result,-1),
(call_script, "script_count_mission_casualties_from_agents"),
(finish_mission,0)]),
I could try to make a native mission_templates.py that's been modified with just this, and actually test it, if you're willing to wait a day or two.