Yes if you set up the events the right way.
You should make the boss attack "if boolean 'pain state' is not true".
You can put a timer to the pain state boolean so it gets reset to not true always after a while.
If you use functions you should remember that the whole function is run immediately when called. The boss can not go in pain state mid function, the boss either is or is not in pain state the moment the function is called. You should set you events in a way that the attack functions are not executed if the boss is in pain state. Since the functions are run immediately when called it makes no sense to try to stop the function if the boss is in pain state, it's way more practical to check if the boss is in pain state before the attack function is executed.