Tried it out with a fresh game and it still behaves the same as before: I die, the battle continues until all my men are slain, then I get the screen saying: You retreated from battle, showing no casualties on either side. After that, I get the "You are captured" screen.
Must be something inherent to the mod.
What I wonder is why it doesn't give me the victory when I am down and my men have killed all the enemies. When they've done so, they DO begin cheering, but I don't get the message that the battle is won. Is it because when you are flagged as being downed, a victory becomes impossible?
UPDATE:
I tried it with a clean extraction from the module system, with only the adjusted line inserted into it, and I get the right thing this time. So it is indeed related to the mod. I even tried a savegame that had been there before the change and it wen't smooth.
2nd UPDATE:
By comparing the values of the .txt file with the python code, I've found out that there's a crapload of additional functionality
common_battle_tab_press,
#RIGHT HERE#
(ti_question_answered, 0, 0, [],
[(store_trigger_param_1,":answer"),
(eq,":answer",0),
(assign, "$pin_player_fallen", 0),
(try_begin),
(store_mission_timer_a, ":elapsed_time"),
(gt, ":elapsed_time", 20),
(str_store_string, s5, "str_retreat"),
(call_script, "script_simulate_retreat", 10, 20),
(try_end),
(call_script, "script_count_mission_casualties_from_agents"),
(finish_mission,0),]),
Between the tab functionality and the 'Do you wish to retreat?' pop-up. It's probably there for a reason, though I can imagine changing the way the tab functions would mess things up properly. Definately means that your piece of code works in general, Frogmeister
3rd UPDATE
I managed to get a victory now despite me being out cold because I removed the check to see if the player is down from the common_battle_check_victory_condition script. Problem is now that the game doesn't register it as a victory, so you won't get loot or exp for it. Argh! Screw this, I'll just go bug the maker of the mod to place your code into my fave mod, Keedo.