Making a skill cause a random state.

I want to make a skill that at random causes a state. Specifically, the states with the IDs 2, 3, 4, 5, 6, 7, 26, 29, and 30. I think I've seen a script for this before but is it possible to do it with an attack formula? What would said formula be, if it can be done with an attack formula?
In the damage formula: 


b.add_state([2,3,4,5,6,7,26,29,30][rand(9)])
@Shaz Thank you, I'm glad I don't need a script for this one simple thing after all!

Original thread: https://forums.rpgmakerweb.com/threads/making-a-skill-cause-a-random-state.73827/