Question about damage formula either healing or damaging?

I was hoping somebody could help me out. I'm trying to make my wind spell either damage or heal depending on what is being targeted. So far I have this for my damage formula: if (b.isActor()) {b.gainHp (a.mat * 6)} else {a.mat * 6 - b.mdf * 4}.
So far if I target the enemy with the skill it will damage them, but when I target an ally the game crashes and says, Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is nonfinite.
Any help will be greatly appreciated.

I've moved this thread to MV Support. Thank you.

Assuming your skill has the <Enemy or Actor Select> notetag, I solved this using Yanfly's skill core plugin by having the damage in the initial formula and the following notetag for healing:

<Post-Damage Eval>
if (b.isActor()){
b.gainHp(a.mat * 6)
}
</Post-Damage Eval>

That seems to ignore the damage present when an actor is selected.
Thank you. You're the best!

Original thread: https://forums.rpgmakerweb.com/threads/question-about-damage-formula-either-healing-or-damaging.96614/