Auto-translated
Drmax4, here's an idea you could try (the script won't be simple):
1) Remove quests like "the hero must survive" from the main quests. In this case, if all heroes and Castles are lost, the game shouldn't register it as a loss. (I think there was such an option, if I'm not mistaken). If that doesn't work, then we'll have to come up with another event to transition the player.
2) Detect the player's loss event. For example, using a trigger for the end of a battle (COMBAT_RESULTS_TRIGGER), check how many heroes (GetPlayerHeroes) and Castles (GetObjectOwner for all Castles on the map) the player has left.
3) At the same time, the second player can have their AI disabled (EnableHeroAI), have no Castles, and generally not have their turn displayed at all (DoNotGiveTurnToPlayerAIIfNoTownsAndActiveHeroes). Or simply disable the AI for the heroes, and let the Castle stand idle. You can also place the heroes in reserve (there is such a function in the map editor). I'm not sure what exactly you want to achieve.
4) At the desired event, the heroes, Castles, and anything else needed are transferred to the ownership of player 1 using the SetObjectOwner function.