MV Having trouble using Yanfly's Custom Counter Condition tag

Hello everyone, I'm having trouble trying to get one of my character's counter skill(s) working utilizing the <Custom Counter Condition> note tag with Yanfly's Counter Control (I have version 1.10). No matter what eval I seem to put in, the same skill is only ever countered with, despite its conditions returning false.

I've searched ahead of time to see if anyone else was having this problem and came across this thread. I tried the "solution" but it still didn't work for me: still doing as it was before & broke counters when only one enemy was left.
I have the plugin right under YEP Battle Engine for what its worth (as I use none of the other plugins above it on the wiki).

The battle I tested with had 4 alive enemies. They had a testable amount of HP so none died during the testing until like 3-4+ turns off of pure counters. Did this trial about 10+ times also with a CNT rate of 60%. Also did a new, blank project with only YEP Battle Engine, YEP Passive States and YEP Counter Control. Got same results.
Screenshots of my settings are here, here and here.

The passive state has this (main project):
Code:
<Counter Skills: 111, 114>

The first skill (that is always countering regardless of its condition being false) is ID 111 and has the following code:
JavaScript:
<Custom Counter Condition>
   if ($gameTroops.aliveMembers().length <= 3) {
     condition = true;
   } else {
     condition = false;
   }
</Custom Counter Condition>
The second skill (that is never used even if its condition is true) is ID 114 and has:
JavaScript:
<Custom Counter Condition>

   if ($gameTroops.aliveMembers().length >= 4) {

     condition = true;

   } else {

     condition = false;

   }
</Custom Counter Condition>
So essentially ID 111 is only supposed to happen if there are 3 or less enemies while 114 only happens if enemy count is 4 or more.

I even did
JavaScript:
$gameTroops.aliveMembers().length === 2
for skill 111 and it still functioned when attacked when enemy count wasn't 2.

Anyway, I'm not really sure what I'm doing wrong - if anything.
It's troop, singular, not troops. You could also make all of the code for the conditions more efficient, but that's the basis of your problem, you're referencing a game variable that doesn't exist (if you opened the console, you'd probably see errors about it).

For example, your 111 could simply say:
Code:
condition=$gameTroop.aliveMembers().length<=3;
It's troop, singular, not troops.
Oops, my bad.
Yeah, first thing I did was open the console, but I saw no errors pointing to it, so it left me even more perplexed.

I'm assuming the tag is supposed to be:
Code:
<Custom Counter Condition>
condition=$gameTroop.aliveMembers().length<=3;
</Custom Counter Condition>

I tried copy-pasting your code and the first skill is still only being used (swapped both skills' conditions to see if it would use the second skill).
Then you should post screenshots of both skills. It seems likely that one of them has an error in the rest of its configuration that makes the actor unable to use it.
Then you should post screenshots of both skills. It seems likely that one of them has an error in the rest of its configuration that makes the actor unable to use it.
Using the clean database when you first start a project.
Only thing changed was char name and graphic. No skill costs were adjusted.
Skill 9 - Fire
Skill 10 - Spark
Counter state
Participating enemies
Countering
If I only put <Counter Skills: 10> (Spark) for the state
Counter control plugin settings
Plugins
Have you tried using the regular conditions list, then an Eval: condition? It does seem like something isn't working properly, I'll poke at it on my end for you.

Edit: Based on my initial troubleshooting, it seems that the custom conditions aren't actually being read and saved into the skills. I'll see if I can fix it, but it won't be until tonight.
I just substituted
Code:
<Counter Condition>
magical hit
single target
</Counter Condition>
for Fire
and
Code:
<Counter Condition>
physical hit
single target
</Counter Condition>
for Spark

and Fire is still only used. Enemies are only using the default Attack action so it should have no business activating Fire (GIF) if I'm understanding the regular conditions list correctly.

Edit: didn't see your edit. Thank you putting your time aside to try and help, I really appreciate it.
I just substituted...for Spark and Fire is still only used.
That one I can't duplicate, putting those conditions in Fire make it not get used for me. Did you try my suggestion above of using the Eval condition? It would be the same code I gave you for the custom, starting with $gameTroop.

I'll poke at it in a while, because something is wrong in the code end regarding the custom.

Edit: Alright, @Thornton - here we go. I got it to work as expected, it'll require you to edit the plugin file with a text editor (such as Notepad++).

Make line 1105 read:
Code:
    if (!this.meetCounterConditionsEval(skill, subject, target)) return false;

Then...I can't figure out the original logic of this function. But it will work if we make these changes, and I haven't seen it break anything else yet. Change line 1112 to read:
Code:
    if (skill.counterConditionEval=='') return true;

and then line 1122:
Code:
    var code = skill.counterConditionEval;

Making those changes, the existing custom conditions work exactly as expected in my test project.
Did you try my suggestion above of using the Eval condition? It would be the same code I gave you for the custom, starting with $gameTroop.
Yeah, some weird stuff happened where Spark would indeed counter, but then its the only thing used even when the conditions were false, but the moment I changed Fire's magic hit condition back to physical it was Fire only. /shrug

Not all heroes wear capes - thank you! This edit works perfectly and everything is working as intended. Thanks for helping me again, can't thank you enough! :LZSproud:
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/having-trouble-using-yanflys-custom-counter-condition-tag.141850/