MZ {SOLVED} Damage Formula with skill check?

I am trying to create a heal that will heal extra if the target is below 50%, but only if the caster has learned a certain passive skill, in my game it is skill 422. I am terrible at this and basically just winging it but here is my experimental formula that returns 0 when he actually heals.

(isLearnedSkill(422)) & (b.hp < b.mhp/2) ? 300 + a.mat * 4 : 300 + a.mat * 2;

I know I am missing something on the backend of 'isLearnedSkill' about the actor. In my action sequences I have a script for $gameActors.actor(number).isLearnedSkill(number) which works great but unfortunately there is no conditional in gamedata to look at the current target's hp, which is why I'm resorting to damage formula instead.
(isLearnedSkill(422)) & (b.hp > b.mhp/2) ? 300 + a.mat * 4 : 300 + a.mat * 2;

I know I am missing something on the backend of 'isLearnedSkill' about the actor.
Right, "isLearnedSkill" isn't anything by itself, it's a function of an actor. So you would put a.isLearnedSkill to check if the attacker has learned the skill. However, the rest of your JavaScript syntax is also wrong.

& is a bitwise operator, which is not what you are intending - you are trying to say AND, which is &&.

You also have some extraneous parentheses, which doesn't actually hurt anything, but it does make your logic more confusing.
Finally, your comparison operator is going the wrong direction, you're checking for the target to have more than 50% health, not less. So:
Code:
a.isLearnedSkill(422) && b.hp<b.mhp/2 ? 300 + a.mat * 4 : 300 + a.mat * 2;
Right, "isLearnedSkill" isn't anything by itself, it's a function of an actor. So you would put a.isLearnedSkill to check if the attacker has learned the skill. However, the rest of your JavaScript syntax is also wrong.

& is a bitwise operator, which is not what you are intending - you are trying to say AND, which is &&.

You also have some extraneous parentheses, which doesn't actually hurt anything, but it does make your logic more confusing.
Finally, your comparison operator is going the wrong direction, you're checking for the target to have more than 50% health, not less. So:
Code:
a.isLearnedSkill(422) && b.hp<b.mhp/2 ? 300 + a.mat * 4 : 300 + a.mat * 2;
Ah, you got me before I edited the < 😛
Anyways, you're the man! Thanks for clarifying it. I had a passing thought it might be as simple as a. but wanted to make sure.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-damage-formula-with-skill-check.140106/