(MZ not MV) how do you turn on a switch in a damage formula?

Just wondering how to have a damage formula turn on a switch or turn off a switch. How do i do this?
Like this:
Code:
$gameSwitches.setValue(1, true); a.atk * 4 - b.def * 2

Also you might be interested in ready this tutorial, which provides a lot of useful information about the Damage Formula for MV (and incidentally MZ too):

edit: change true to "false" to turn off. If you want it to toggle, you can use conditionals as described in the tutorial.

Original thread: https://forums.rpgmakerweb.com/threads/mz-not-mv-how-do-you-turn-on-a-switch-in-a-damage-formula.126725/