Skill with damage based on user buffs?

I was planning on making a skill that does damage based upon how many of the user's stats are currently being buffed. My first idea was to have the skill trigger a common event, which uses conditional branches to check each stat and see if it is being buffed, and if it is, then +1 is added to a corresponding variable. Then, the skill would do damage based on the value of that variable. However, I wasn't quite sure how to get the common event to check for buffs, if it is possible. If there's some way to accomplish this or another method that would work, I would love to hear it.

Similarly, I had an idea for a skill that would deal damage to all enemies with additional damage for each status ailment (state) they were affected by. I was thinking to accomplish this the same way, but again I wasn't sure how. I noticed that conditional branches can check for states on an enemy, but it wouldn't necessarily be the enemy targeted by the skill if I understand it correctly.

Any help with these ideas would be great. Thanks!
Just like you can access a.atk or a.agi for damage formulas, you can also access how many buffs a character has on each parameter, via two methods:
1. a.paramBuffRate(paramIdHere), which gives you the actual multiplier from the buffs (1.0 for no changes, 1.25 for one stack, 1.5 for two, 0.75 for one debuff).
2. a._buffs[paramIdHere], which gives you the flat number of buffs, or a negative number if they have debuffs.

Parameter ids are as such:
0 = mhp
1 = mmp
2 = atk
3 = def
4 = mat
5 = mdf
6 = agi
7 = luc

That's for buffs and debuffs, States are handled completely differently. If you aren't looking just for specific states, b.states().length would tell you how many the target has. If you do want to check based on the specific kinds (maybe you have "buff" and "ailment" status effects you want to track separately), look into Yanfly's Buffs & States Core and State Categories.
That sounds much simpler than the way I was planning it. Just to make sure I have it straight, if I want the ability to do damage based on the flat number of buffs affecting the user, I would use a.buffs() with the ID of the buff, and I could do this for each buff? Or would I only need to do it once but include the parameter IDs of each stat? The way I wanted it to happen is that each stat being buffed adds damage to the ability, disregarding any stat that is being buffed twice (aka two stacks of an attack buff still acts as one bonus for the damage).

For the state ability, I would want it to be only specific states, so I'll check out Yanfly's plugins. That method makes sense though. Btw, is there any database or tutorial for learning the different things I can do in the damage formula box?

Original thread: https://forums.rpgmakerweb.com/threads/skill-with-damage-based-on-user-buffs.111020/