Yanfly Counter Control - Counter Only If User Has Taken Damage?

I know I've been making a lot of help topics lately. I've just being doing a lot of JavaScript-related things lately, and running into issues with all of them. This one in particular has been a MASSIVE headache.

It's related to my last question, concerning the same boss and same batch of Elemental Barrier states. To save some time on behalf of the reader, each state has a specific element it's weak to, one element it's immune to, and two it resists. If the weakness is struck, the state is removed. After much headache I managed to figure out how to get the state removal bit to work properly.

However, now I'm having a new issue with the same states. In case the player gets smart and tries bypassing the whole barrier change business by using a non-elemental spell, I want the state to trigger a counter that drains all the player's MP.

My first thought was to use Yanfly's Counter Control. This is the notetag I put into the Counter Skill:
<Counter Condition>
Not Element: 1
Not Element: 2
Not Element: 3
Not Element: 4
</Counter Condition>

This does indeed make the counter skill proc when struck with a non-elemental spell. Unfortunately, it doesn't take into account whether or not the non-elemental spell actually does damage. So not only does it counter the big damage non-elemental spells I want it to counter, it also counters my enemy scan skill, my debuff skills, and so on.

I should note that the two strongest non-elemental spells are Certain Hit, so I can't use that property either.

I want the counter to only proc when the boss takes non-elemental damage. Fortunately, Counter Control has an Eval condition. Unfortunately, absolutely nothing I could think of to put into it worked:
  • I first tried this.isDamage(). That gave me a "function is undefined" error.
  • Then I tried baseDamage (the variable used in the Damage formula, if the Damage Core is to be believed). I got the same result.
  • My next attempt was target.result().hpDamage > 0. That didn't give me an error, but the counter doesn't proc at all.
  • Then I figured that since it's the user using the counter, I'd try user.result().hpDamage > 0. No error, but the counter still didn't proc at all.
I cannot believe it's really this difficult to make a counter proc only when taking damage. I feel like I'm missing something here, and would be deeply grateful if anyone could point me in the right direction.
Well, I managed to come up with a working stopgap issue that didn't involve Counter Control. For the curious, what I did was again adapt Yanfly's Greater Undead code into this (requires Buffs and States and Element Cores):

Spoiler: Counter Code
<Custom Respond Effect>
// Make sure this is damage that comes from the attacker
if (target.result().hpDamage > 0 && target !== user) {
// Get this action's elements
var elements = this.getItemElements();
// Create a list of the valid elements
var validElements = [1, 2, 3, 4];
// Set the initial valud flag to false
var valid = false;
// Loop through the elements
while (validElements.length > 0) {
// Get the currently looped element
var elementId = validElements.shift();
// Check if the action's elements have a valid element
if (elements.contains(elementId)) {
// If it does, set the valid flag to true
valid = true;
}
}
// Check if the element is valid
if (valid) {
// Get the element needed to break the barrier
var ice = 3
// Check if the necessary element is among them
if (elements.contains(ice)) {
// Play animation
target.startAnimation(56);
// Get the status effect ID.
var stateId = 11;
// Remove the status effect from target.
target.removeState(stateId);
}
} else {
// Retaliate with MP loss
user.startAnimation(102);
BattleManager.actionWaitForAnimation();
user.gainMp(-user.mp);
}
}
</Custom Respond Effect>

As far as I can tell, it works as intended. The response is not technically an attack, but it looks enough like one for me, and the important part is that it procs when hit when hit with non-elemental damage. Elemental damage is fine, and it won't proc when hit with a non-attacking skill either. The downside is that it'll interrupt attacking motions, but after the sheer frustration I had with Counter Control I'll take it.

With all that being said...I do plan on making counterattacks a part of at least several enemy's strategies, and quite possibly making some available to the player as well, and I'd very much like them to be actual counterattacks and not just stopgap solutions like this state here.

Is it possible at all for Counter Control to distinguish between damaging and non-damaging skills (outside of separating those skills into separate skill types)? If not, is there another plugin that does and can do all the other things Counter Control can do?

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-counter-control-counter-only-if-user-has-taken-damage.82653/