Add a state only if an attack does damage??? script help?

Hey there! I'm working on something of a vampire game and one of the mechanics is a "feed" attack that, as I'm sure you can assume drains the HP of the enemy and gains it to yourself. However, as you level up you gain more powerful versions of the attack that can add states to the effected opponent.

Why I can't just use the "add state" effect is because there are certain enemies that you cannot use your feed on until you gain the more powerful versions. I've accomplished this by setting each "feed" to its own "element" (I have no other need for elements in this game) and if an enemy shouldn't be effected then it just has immunity to attacks with that element. This all works fine, except of course the "add state" will always come into effect regardless of if the attack did damage.

So, I assume the solution is to write a script that's basically:

if (attack does damage) then b.add_state(feed #)

but I have a somewhat tentative grasp on scripting and don't know how to go about this...and of course if anyone knows an easier/better way of doing this let me know! I'd prefer to avoid more plugins but if you have one that does *exactly this* I wouldn't be against it.
First of all there is a very simple solution to your problem: create different skills with the same name and then whenever your player learns a new version replace the old version with the new one. This way only the stronger version applies a state.

That said, if you want your weaker version to apply a state too (only to weak enemies though) you can add it in your damage formula. If I am not wrong it should be something like this:
Code:
b.element_rate(id) > 0 ? b.add_state(state_id) : nil; your_damage_formula

That only applies your state if the enemy is not immune to a certain element
First of all there is a very simple solution to your problem: create different skills with the same name and then whenever your player learns a new version replace the old version with the new one. This way only the stronger version applies a state.

That said, if you want your weaker version to apply a state too (only to weak enemies though) you can add it in your damage formula. If I am not wrong it should be something like this:
Code:
b.element_rate(id) > 0 ? b.add_state(state_id) : nil; your_damage_formula

That only applies your state if the enemy is not immune to a certain element

Aaahhh thank you so much! I was almost figuring it out too but dang this is way easier than the route I was going...thank you!

Original thread: https://forums.rpgmakerweb.com/threads/add-a-state-only-if-an-attack-does-damage-script-help.97250/