Branching paths based on how battle ends

In my game, you can defeat the enemy in two ways, fighting or sparing them, which triggers two different paths in the story. So using the if I lose/if I win conditions under the battle processing event to trigger different switches doesn't work, as the player winning using either method would trigger the same path. Is there a way around this?

I tried using a switch and the following code, but it doesn't work. No matter whether I spare the enemy or not, it goes to the evil route. (I know that the first script, which is under the Common Event for sparing, is being triggered since gameMessageBubble works).
Mb, I think I found the problem, the second script is triggered before the first. I didn't know that would happen.

Original thread: https://forums.rpgmakerweb.com/threads/branching-paths-based-on-how-battle-ends.166243/