MV How to make certain attacks miss a certain enemy?

I have skills for various melee attacks and ranged attacks. I have also created a melee attack damage type and a ranged attack damage type (although these are kinda redundant now; see below). I want melee attacks to automatically miss (or be evaded, whichever) whenever used against flying enemies.

I tried having these flying enemies have Element Rate = Physical Melee * 0%, but that just means the attack deals no damage, but since the attack still technically hits, I still see/hear the animation and sound effect that goes with a hit, so it doesn't have the right feel for what I'm going for here.

NB: I've taken a look at this and the linked threads but none of them seemed to solve my problem, either that or I didn't understand the suggestions well enough yet (hence my above idea that I didn't like):

https://forums.rpgmakerweb.com/index.php?threads/force-a-missed-attack.78949/
It cannot be done by default.

you'll need a plugin with advanced coding (javascript) options or something like that, which is what the linked topics use - the notetags given there have no functions without the plugins that are checking and using them.

So - how much experience do you have with using plugins and/or using javascript?
In the link you provided, what's wrong with using Victor Engine's Action Dodge?

You could also use Yanfly's Hit Accuracy, although it would be a bit more convoluted.

You could also use Yanfly's Selection Core to simply prevent melee attacks from being able to target flying enemies at all.
So - how much experience do you have with using plugins and/or using javascript?
Very little, I've just started reading this after posting my question as I'm starting to see that knowing JS scripting is essential to making the sorts of changes to the default design of RPG Maker that I want to make:
@ATT_Turan
I didn't spot "Victor Engine's Action Dodge", I'll check that out (I'll point out that reading is by far my worst style of learning, so it's entirely possible that I didn't read the other threads I linked correctly).

First impressions are good from its YouTube video and what the plugin file's description says, but in practice I'm hitting an "action.item is not a function" error 🙁
This error happens on a fresh project too.
if you're hitting error messages, then that is something we can help you with.

as general advice: you normally have to start new games after adding plugins because the savefiles of older saves usually become incompatible.

For specific problems, we usually start with screenshots of the plugin manager to see which plugins you have in which order, and a screenshot of the console output of the error message.
Is this something I should ask a separate question about under RPG Maker Javascript Plugins or similar, rather than continuing this thread about, since technically I think "Victor Engine's Action Dodge" is the solution to my original problem (assuming I can get the plugin to work)? I come from a "Stack Exchange" mindset in case anyone wonders why I'm asking this, since they have a very strict "one question per thread" policy.
This forum uses a "one problem per topic" policy.
so it would be OK to continue since it is still the original problem of making that happen, although you should report it to be moved to plugin support.
I have moved this thread from RPG Maker MV Support to JavaScript/Plugin Support.
This forum uses a "one problem per topic" policy.
so it would be OK to continue since it is still the original problem of making that happen, although you should report it to be moved to plugin support.
Cool, thanks for realigning me there.

As for the error, yeah, it's happening on a fresh project with only the two default plugins that are always there, Community_Basic and MadeWithMv, both of which I switched off just in case, and then of course VE_BasicModule and VE_ActionDodge.

The error only happens when VE_ActionDodge is active, and I've also discovered that it happens even when I take away my notetag, so I think that means it's not because of me using it incorrectly...
Did you double check whether there are any plugin parameters that need to be configured?

Press F8, go to the Console tab, provide a screenshot of the error trace.
Did you double check whether there are any plugin parameters that need to be configured?
The VE_BasicModule has quite a few, but they all seem like just display text to me, so I assume they are of no consequence. VE_ActionDodge has none.

Press F8, go to the Console tab, provide a screenshot of the error trace.
I did not know about F8, thanks. The error trace is this:
error.png
Okay...there's a weird mistake in there where he passes the wrong kind of argument to his own function. Don't ask me how that happened.

Open up Action Dodge in a text editor. Go to line 439 and replace it with this:
Code:
        var elmtnValue = item.damage.elementId<0 ? subject.attackElements() : item.damage.elementId;
        elmtnValue = elmtnValue.reduce(function(r, elementId) {
Thanks for the reply. Unfortunately, now I get an "elmtnValue.reduce is not a function" error instead, although I added an "alert(elmtnValue)" between your two lines just to see what it was and it's a "1", which is the ID of my damage element, so that's something, but that's about as much as I can get with my threadbare JS abilities...
My bad, forgot the brackets.
Code:
        var elmtnValue = item.damage.elementId<0 ? subject.attackElements() : [item.damage.elementId];
        elmtnValue = elmtnValue.reduce(function(r, elementId) {
Thanks, there are now no errors. It's not quite working, however, so I assume at this point that it must be because I'm using the plugin incorrectly.

I've put "<element dodge: 1, eva +100%>" in the Note section of the enemy "Bat", which I assume should mean that anything "Physical" (element ID 1) should always miss the Bat (or rather, the Bat should always dodge such attacks)?

Scratch that; I've just tried something different in the Note section after re-reading the plugin description, and it's now working. For reference, what I've now got is:

<custom element dodge: 1, eva>
result = 100;
</custom element dodge>
I don't see why you need to use the custom notetag if you're not evaluating any code.

Per the instructions:
The % value is multiplied by the base value, while the flat and code are
added to the base. For exemple, if a battler have 10% evasion against element
ID 2. If it have <element dodge: 2, +50%>, the chance will go to 15%
(10 + 50% = 15).

So saying +100% is not a guaranteed dodge, it's just doubling their evasion parameter.

If you just change your first notetag to remove the %, it should do what you want.
Code:
<element dodge: 1, eva +100>
Ah, I see my mistake, I've increased the dodge chance by a relative amount rather than an absolute value to guarantee the dodge (well, actually my mistake was not reading the description properly, which is just typical of me).

I've replaced my notetag with yours since it's a cleaner solution, and, of course, it works just fine.

Thanks for all your help ATT_Turan 🙂
I see you've solved it, but I thought I'd mention that it is possible to make a hit look like a miss without plugins by using the damage formula, e.g.

if (b.fdr > 0) { a.atk * 4 - b.def * 2 } else { b.result().missed = true; 0 }
I.e. "if the target has positive Floor Damage rate (Sp-param) then calculate [standard damage]; otherwise set the result to a miss and do 0 damage". This "fake miss" is purely cosmetic: it'll show the appropriate popup/message but all the usual on-hit effects (e.g. Add State) will still get processed.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-certain-attacks-miss-a-certain-enemy.160698/