You should never apply effects like this in the damage formula. While it might appear to work correctly in your testing, it can cause an issue when this skill is usable by an enemy, or by an actor who happens to be controlled by AI (via confusion, auto-battle, etc).
That issue is that when the engine is trying to decide which action an AI controlled battler takes, it evaluates the damage formula for every possible skill it could use, and then executes the one with the greatest effect. That works fine normally, but with your example skill above, when it goes to check if this skill should be used, it will turn on your switch regardless of whether this skill ends up being used or not. You might not ever see this happen if the skill can only be used by actors, and the actors can never auto-battle, or otherwise have effects that could cause them to need to evaluate their skill damage in this way, but it's still an avenue in which unexpected behavior could come up if you end up adding in something later.
If you're using the VS plugins, I'd recommend using a <JS Pre-Damage> tag on the skill to set the switch if the hprate() is valid instead, which will only happen when the skill is actually used (and if it actually hits too). If you're not using VS plugins, you could use a common event instead. That might not be as good as checking right when the damage formula is applied, but it might be better to work around it than to have what you currently do in the damage formula.