Increase a variable based on the number of enemies hit (Resolved)

Hello,
A while ago, someone on the forum explained to me how to get a status when successfully hitting an enemy with an attack.
The formula is:


<Custom Establish Effect>
// Check if the attack is a physical attack that dealt HP damage from a critical hit.
if (this.isPhysical() && target.result().hpDamage > 0) {
user.addState(x);
}
</Custom Establish Effect>

x corresponding to the state.

Today, I need to raise a variable based on the number of enemies hit by an ability. Let me explain.
One of my characters has a powerful attack that needs to be charged before it can be used. I found several interesting ways to do it (effect passives, abilities).

I would like my character to have an area spell that adds a "charge" for each enemy hit. For that, I would like to use the formula I quoted, not to add a state, but to increase a game variable (not a variable created just for the spell).
I will then take over with a common event to use this variable more easily.
Is it possible ?

(Translation made by google, please ask me to rephrase if necessary).
The Custom Establish Effect runs once for each target, so just replace user.addState(x) with $gameVariables.setValue(x, $gameVariables.value(x) + 1)
It doesn't work but I realize that the problem may be with my initial formula.

if (this.isPhysical() && target.result().hpDamage > 0) {


I imagine that "Physical" refers to a physical attack. Here I am using a magic attack.
I don't know the terms of javascript, maybe there is a word to put in place of "Physical"? ("Magic" not working).

If so, what exactly does the word "Physical" refer to?
A "Sure Hit" attack that inflicts physical damage is considered "Physical"? (I hope the translation of "Sure Hit" will be good in English.)


Edit : It's ok, I just removed "this.isPhysical() && " because in my situation it's not useful. But I want the answers to my questions please (especially the second). This may save me from opening another topic in the future ^^"
It doesn't work but I realize that the problem may be with my initial formula.

if (this.isPhysical() && target.result().hpDamage > 0) {


I imagine that "Physical" refers to a physical attack. Here I am using a magic attack.
I don't know the terms of javascript, maybe there is a word to put in place of "Physical"? ("Magic" not working).

If so, what exactly does the word "Physical" refer to?
A "Sure Hit" attack that inflicts physical damage is considered "Physical"? (I hope the translation of "Sure Hit" will be good in English.)


Edit : It's ok, I just removed "this.isPhysical() && " because in my situation it's not useful. But I want the answers to my questions please (especially the second). This may save me from opening another topic in the future ^^"
The counterpart would be isMagical().

Certain Hit means that no kind of evasion will be factored into whether the skill hits. Physical means it will be EVA, and Magical means it will use MEV. There is no in-database delineation between a Certain Hit "physical" skill and a "magical" one, it basically affects what kind of evasion is used to calculate hit success.

It also determines counterattack/magic reflection and whether "HIT" is factored in to success. (only physical type can counter, only magical type can reflect, and only physical uses hit rate)

Another interesting feature of Certain Hit is that it disregards the target's State Rate and user's luk modifier when determining whether a state is added by the skill.
Ok, thank you for that clarification.

Original thread: https://forums.rpgmakerweb.com/threads/increase-a-variable-based-on-the-number-of-enemies-hit-resolved.148338/