Faolyn
(she/her)
That is also true.I have a radical suggestion for that situation: Speak up! Point out that you messed up royal, you now realise that this encounter stinks, and ask if it is ok for the players that you retroactively fix up some stuff so you can actually get to have some fun.
My guess is that most players would approciate that honesty, and be more than happy to have you reset the entire thing once you realised you were way off the mark. Or maybe just skip to some desired outcome.
And, of course, there are non-cheaty ways to get around these issues as well. Like running away. Weak enemies could flee into a area they know well enough to avoid the hazards but the PCs might have problems should they choose to follow. A too-powerful BBEG could leave if they hit half or one-quarter hp, swearing revenge--after all, even if the GM "knows" that they'd be able to defeat the PCs with a few more lucky rolls, the foe doesn't know that.
(There's too much fighting to the death in D&D. You don't even need to make morale checks here; just decide how logical it is that the enemy is really willing to risk getting killed for this fight.)