MV YEP Counter Control: No Counter on miss

Heyho!

I'm trying to set up a skill that counters a certain element, using Yanfly's Counter Control, but only if the attack actually hits. I found similar problem in this thread: Eval conditions like target.result().hpDamage > 0 don't seem to work. Could someone with js knowledge take a look? Maybe there are other possible conditions I didn't think of?

The workaround in the other thread also won't work for me, since I'd really like to keep the other counter mechanics the plugin offers for this skill.
Have you tried these?
Code:
EVAL: !defender.result().missed
EVAL: !defender.result().evaded
I just did, but it's the same result. The counter is still triggered.
Does an eval condition like false (i.e. counter should never proc) do anything?

Line 1105 of YEP_X_CounterControl v1.10 looks suspect to me. You could try editing it to this:

if (!this.meetCounterConditionsEval(skill, subject, target)) return false;
I.e. add the return false in there. I haven't tested, so let me know if it works~
I also just found this thread, wherein line 1105 is also mentioned, amongst others, maybe that helps someone who's more knowledgeable tha me~

I'll try your solution immediately!
Does an eval condition like false (i.e. counter should never proc) do anything?

Line 1105 of YEP_X_CounterControl v1.10 looks suspect to me. You could try editing it to this:

if (!this.meetCounterConditionsEval(skill, subject, target)) return false;

I.e. add the return false in there. I haven't tested, so let me know if it works~
Yeah, I gave that fix to someone a few days ago (and in a thread I posted for Plugin Releases, except it's still waiting for approval days later 🙄)

The entire Custom Counter tag for Yanfly's counter is borked, the written code doesn't evaluate them at all. You need to change both that line and the method that processes it.

@coucassi if you look through recent threads for another about Counter Control, you'll find my fix there.

That being said...I don't think this has anything to do with this plugin. My understanding of the RPG Maker attack flow is that countering isn't checked at all unless the attack hits. You would have to add a plugin that changes to check for it in a different place.
Line 1105 of YEP_X_CounterControl v1.10 looks suspect to me. You could try editing it to this:

if (!this.meetCounterConditionsEval(skill, subject, target)) return false;
No change unfortunately. I also went and looked for @ATT_Turan s Thread. I think it's this one, right?
Here are the therein suggested changes:

Line 1105:
if (!this.meetCounterConditionsEval(skill, subject, target)) return false;

Line 1112:
if (skill.counterConditionEval=='') return true;

Line 1122:
var code = skill.counterConditionEval;

For some reason it still doesn't work for me. Just to double check that there isn't something wrong with my conditions that prevents your fixes from working: I tried these with the changes:


<Counter Condition> EVAL: !defender.result().missed EVAL: !defender.result().evaded Element: 11 </Counter Condition>

(no change, attacks still get countered if I attack with element 11, even if the attack misses.)

<Counter Condition> EVAL: target.result().hpDamage > 0 Element: 11 </Counter Condition>

(in this case there are no counters at all)
For some reason it still doesn't work for me. Just to double check that there isn't something wrong with my conditions that prevents your fixes from working: I tried these with the changes:
<Counter Condition> EVAL: !defender.result().missed EVAL: !defender.result().evaded Element: 11 </Counter Condition>

You're referencing the defender, and the defender wouldn't have any result, as they are defending, not the one that used an action.

So.

You should try:
Code:
Eval: !attacker.result().missed && !attacker.result().evaded

<Counter Condition> EVAL: target.result().hpDamage > 0 Element: 11 </Counter Condition>

(in this case there are no counters at all)
"target" isn't a keyword given by the Custom Counter plugin, just attacker and defender.
Wait ... I only want the counter to happen if the attack hits, so James Ryans idea of "not missed" and "not evaded" should return true, right?
You should try:
Code:
Eval: attacker.result().missed || attacker.result().evaded
Like you said, all conditions must be true and if I use this there has to be both a miss and an evasion - which is impossible (again like you just said), or am I totally confusing things again?

EDIT: Maybe my thread title was a bit misleading xD What I want to happen is, that the attack can only be countered, if it hits. That's what I am trying to find the right condition for, because right now the attack gets countered in any case, regardless if it hits, if it misses or if the target manages to evade.

Eval: !attacker.result().missed && !attacker.result().evaded

Okay, now I'm back in. This makes sense, but it still doesn't work. I also double checked if I made a mistake when applying your fixes, but no.
...you're referencing the defender, and the defender wouldn't have any result, as they are defending, not the one that used an action.
The action result is stored on the target/defender, not the subject/attacker. @JamesRyan's code looks correct in its syntax.

@coucassi: now that the edits have been applied, I'm guessing that a simple Eval: false in the counter conditions would be enough to prevent the counter. However, you're trying to check the original action's result...

By default, counter attacks are invoked instead of the triggering action, i.e. the original action gets replaced by the counter. It looks like Yanfly's plugin does not change the order, it simply queues the normal action (and subsequent counters) as appropriate? So I think it is like @ATT_Turan suggested earlier: when the counter conditions are checked, the result of the triggering action does not exist. To fix that, you'd need to rewrite the code to change the order of invocation. 😴
Eval: false
Using this, there are no counters at all, even on a hit.
So it won't work at all, without rewriting the code? Ahh, I'm sorry to have wasted your time, then x.x
Thanks for your help nonetheless!
The action result is stored on the target/defender, not the subject/attacker.
Ah, my bad.

Original thread: https://forums.rpgmakerweb.com/threads/yep-counter-control-no-counter-on-miss.141927/