It's a limitation of the AGS text script system, that some of teh functions will be queued up and executed as the last command of the script, one such example is RunDialog().
So the actual order of your codes executed is:
character[TW].SetAsPlayer();
character[EJ].SetAsPlayer();
RunDialog(7);
One way to overcome this is, remove the character[EJ].SetAsPlayer(); line, then let the dialog calls dialog_request() to change the character back when it ends. Here are brief instructions on how to do this:
1. Remove that character[EJ].SetAsPlayer(); line from your interact with hotspot function (can also be done by adding // to the left to make it a commented line).
2. Edit the dialog's script, find where it will end and return to the game and add a line:
run-script 13. Open up the global script, and create the following function:
function dialog_request(int parameter) {
if (parameter==1) character[EJ].SetAsPlayer();
}
I know this dialog_request() thingie can be a bit confusing at first, if you want to learn more about it, you can read
this.