Making a skill do more damage based on X, Y, and Z

Hello, so, I am trying to create an ability that does more and more damage based on how many "states" the enemy current has on it. 

I currently use one that looks like this:

b.state?(2) ? r = a.atk*7; r = a.atk*2; r - b.def *2 

This makes it so that if the enemy has state#2 (poison) it takes (atk*7) in damage, otherwise it only does (a.atk*2).

Now, my goal is to try and make an ability that does damage like so:

a.atk*3 =  base damage

a.atk*5 = with X state on target

a.atk*7 = with X and Y state on target 

a.atk*9 = with X, Y, and Z state on target

Is this possible? If, so, can anyone show me how to accomplish this?

Thanks for the help!
Have a read through this thread: http://forums.rpgmakerweb.com/index.php?/topic/38270-50-chance-to-die-after-using-a-skill/

It highlights some of the things that can be done.

Enjoy ^_^
That looks wonderful, but it's far beyond my understanding lol. >_<
http://www.rpgmakervxace.net/topic/8986-skill-ideas-you-can-do-with-custom-formula/

Scroll down to Xypher's response to Harmill having essentially the same question. His is pointed towards the skill being stronger based on total number of states, but you could use this one specifically just for the states you want by limiting the number of state IDs in the 'd' variable.
@CharocalKidd - this is perfect, thank you for the link!

Original thread: https://forums.rpgmakerweb.com/threads/making-a-skill-do-more-damage-based-on-x-y-and-z.38431/