Question regarding Spells/States

Hello, everyone.


I was wondering if it was possible to check if a state is active on an Ally and then not let the spell affect them if they have the state? 


I made a character have a spell that gives a state that increases the Allies MHP by 10% for the entire battle. To make it so the player doesn't go from, say, 100/100 to 100/110 MHP and be missing the 10% MHP I made it so that it also heals that player by 10% of their MHP. I want the spell to not work if the player already has the state on them so that the spell can't be used to heal the Ally by 10% of their MHP if they already have the buff(heal abuse). Is this possible without scripts/JS? 
Try giving the spell an Element and have it inflict a State that grants 0% weakness against that Element. Make sure you use the formula box to heal, not the Effects list.
If MV works like Ace, then you can put this in the damage formula box (I can't test this right now but i'm almost sure this should work)


Type: hp heal


    b.state?(x) : b.hp_rate*0.1 ? b.add_state(x)


Replace x with the id of your state
The idea that @7Soul mention works, but the code will not work on MV. (in fact this code woudn't work even on VXAce).


var result = b.isStateAffected(X) ?  0  : b.mhp * 0.1; b.addState(X); result;
Try giving the spell an Element and have it inflict a State that grants 0% weakness against that Element. Make sure you use the formula box to heal, not the Effects list.

I tried this and for some reason it heals me BEFORE it buffs me so im still 10% short on HP 🙁

The idea that @7Soul mention works, but the code will not work on MV. (in fact this code woudn't work even on VXAce).


var result = b.isStateAffected(X) ?  0  : b.mhp * 0.1; b.addState(X); result;

I copied that and put the State that buffs me in for X but it doesnt heal me. It says "0" for when it attempts to heal me.
I copied that and put the State that buffs me in for X but it doesnt heal me. It says "0" for when it attempts to heal me.

Did you notice that there are two "X" in the formula (one for isStateAffected and one for  addState) , right?


I tested it here and it worked fine.


If you added the two values, can you paste the code you used here?
Did you notice that there are two "X" in the formula (one for isStateAffected and one for  addState) , right?


I tested it here and it worked fine.


If you added the two values, can you paste the code you used here?

My bad! Tested and it works! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/question-regarding-spells-states.58817/