Trying to make a drain life/blood weapon buff

I'm trying to make an hp drain buff, like a dark knight blood weapon skill from FF, is there a way to make this on MZ? I made a state that last 5 turns to act as the buff for blood weapon and a formula. when i test it, buff less i do the normal attack damage on the attack skill, but when i have the buff it heals but doesn't do any damage.

a.atk * 4 - b.def * 2 && a.isStateAffected(41) ? a.gainHp((a.atk * 4 - b.def * 2)/2) : a.atk * 4 - b.def * 2

Is there a plugin or something in the formula I'm missing? only drain life stuff I find are plugins for MV or formulas for VX.
Hmmm, I think it should be:

Code:
if (a.isStateAffected(41)) {a.gainHp((a.atk*4-b.def*2)/2)}; (a.atk*4-b.def*2)/2
As a note - this is the kind of thing you want to be careful about putting into the damage formula.

If an actor with this skill has the Auto Battle trait, or if you give the skill to an enemy, they will gain HP from the script call even if they don't end up using the skill.

It's better to put that into notetags in the skill - you can use my Eval Tags plugin or VisuStella's Battle Core.
Someone on the rpg maker discord figured it out and it triggers only when someone has a drain buff.
Code:
dmg = (formula); if (a.isStateAffected(41)) a.gainHp(dmg/2); dmg
Someone on the rpg maker discord figured it out
That isn't functionally different from what @rpgLord69 gave you on Sunday. Little more efficient, but what he gave you does the same thing.
Ya, it was sent to me before I got a response in here so I posted it.
Talk about netiquette, jeez. Just so you know, this is how you get people to not help you in the future. Truly unbelievable.

Talk about netiquette, jeez. Just so you know, this is how you get people to not help you in the future. Truly unbelievable.

That isn't functionally different from what @rpgLord69 gave you on Sunday. Little more efficient, but what he gave you does the same thing.
How so, I got a response from the discord faster than I did on the forums and I posted it here, yes it was close the one rpglord posted, but its just another way to say the same thing. I had no disrespect, I'm just posting what I got before I saw his post. Your acting like I did a terrible thing for looking through multiple sources. Would it have just been better if I left this thread with no response, because I believe that would be worse than not having confirmation that the problem had been solved, not to mention having different versions of the same code is nice for others. ATT_Turan said it was a little bit more efficient, this gives anyone else who wants to do this options.
If the issue had been solved elsewhere, you should have posted it back here asap so as to not waste anybody's time. That's the responsibility that comes with posting a question. Plus, not even a thank you to @rpgLord69 for his efforts. But if that's all strange and occult to you, let's just agree to disagree. Good luck with your project.
If the issue had been solved elsewhere, you should have posted it back here asap so as to not waste anybody's time. That's the responsibility that comes with posting a question. Plus, not even a thank you to @rpgLord69 for his efforts. But if that's all strange and occult to you, let's just agree to disagree. Good luck with your project.
Reposting back here asap Isn't always possible, people have lives and aren't always able to check every place they have asked questions. The fact that I gave a response is better than nothing. yes @rpgLord69 had put in effort but am I suppose to thank every single response I get everywhere I make a thread even if I don't see it or get to test it?
am I suppose to thank every single response I get everywhere I make a thread even if I don't see it or get to test it?
Yes
Reposting back here asap Isn't always possible, people have lives and aren't always able to check every place they have asked questions
You obviously had enough time to check discord.
Chill everyone. To be fair, not everyone remembers to post on their threads either, or even gets notifications that there is a response. Maybe it would be best to not assume the worst?

Also as it is solved, I'm going to close the thread too. If the OP wants it reopened please report this post and ask it to be reopened.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-a-drain-life-blood-weapon-buff.166909/