Obtain State's Stacks - Yanfly's Buff & States Core

Link to Yanfly's plugin: http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/

I am exploring the following:

A character receiving damage while having State A equipped.
State A reacts to this damage and checks every member from the enemy team.
Each enemy member that has State B would be punished.
The punishment to EACH enemy varies depending on the number of stacks they have on their State B.

I can do all of those steps except for vary the punishment depending on foreign stacks. I know how to work with stacks on the reacting/active state (State A in this case), but not how to work with stacks on a target state (State B in this case).

I know you can set state counters this way:
target.setStateCounter(stateId, 0);

But not sure how to obtain a character's state's counter/stacks.

Code:
    for (var i = 0; i < enemies.length; ++i) {             
      var enemy = enemies[i];
      if (enemy && enemy.isStateAffected(25)) {               
        haunted.push(enemy);       
        // I assume I'd check enemy. "piece of code for state counters" here.            
      }
    }
getStateCounter

Original thread: https://forums.rpgmakerweb.com/threads/obtain-states-stacks-yanflys-buff-states-core.78044/