Events such as GlobalSetEvent can only be in the IF part of the code, not the AND. The solution would be to have that event store a variable in a Database, and then check for that in the AND.

Regarding your question, I would suggest looking at Zixzax in the Story code; I know he is one of the NPCs who changes his dialog file midgame. I believe it works by assigning a new dialog file from a Database to the character after the DialogEnded of their previous dialog fires.