Skill that heals you after getting hit by certain spells

1733437213170.png

I wanted to try making it a state so i can use it as a passive ability but i cant figure it out, im open for any plugins
passive states need a plugin as they can't be done with the default engine.

and then it depends on the plugin used as those have to process the commands.
passive states need a plugin as they can't be done with the default engine.

and then it depends on the plugin used as those have to process the commands.
I use something from yanfly, dont remember, dont matter, if this will work as a skill that gives state on use then i can make it a passive, i just dont know how to do ( edit: or perhaps other way instead of state, that was just first thing that came to mind )
It's definitely doable with Yanfly Buffs and States Core and AutoPassive States. I don't know the exact scripts but there are users here who do
You'd give the state the Yanfly Buffs & States notetag
Code:
<Custom Respond Effect>
if (this.isSkill() && this.item().damage.elementId == 3)
{
    target.gainHp(Math.round(user.mhp / 10));
    target.addState(42);
}
</Custom Respond Effect>

Replace 3 with the ID of your ice element, and 42 with the ID of your state that multiplies Attack.
You'd give the state the Yanfly Buffs & States notetag
Code:
<Custom Respond Effect>
if (this.isSkill() && this.item().damage.elementId == 3)
{
    target.gainHp(Math.round(user.mhp / 10));
    target.addState(42);
}
</Custom Respond Effect>

Replace 3 with the ID of your ice element, and 42 with the ID of your state that multiplies Attack.
So it almost works, but it healed the 10% of the enemy hp which i guess is the "user.mph / 10" but after i changed it to "target.mph / 10" the skill that was supposed to deal 100 damage and then heal 45hp ( cause character has 450 ) and the thing is, it shows that it heals 45hp but the 100 damage doesnt pop up and the thing is this just takes away 10hp from him every turn and im feeling a little confused... also will this ability make him unkillable? like even if it worked it and my character would have the 100hp would it bring him to 0 and then to 45? or would he die normally as he should?
EDIT: "target.addState" works perfectly ( i attach everything there is if anything is needed )
1733532838011.png
1733532866536.png
1733532879980.png
1733532907629.png
Tip - I know English isn't your first language, but please take a moment to format your posts a bit.

It's pretty hard to understand what you're talking about with that big block of text and unending sentences.

it healed the 10% of the enemy hp which i guess is the "user.mph / 10" but after i changed it to "target.mph / 10"
Yes, sorry for the mis-type.

the skill that was supposed to deal 100 damage and then heal 45hp
If that's the order that you want it to happen, then you need to use a different notetag that happens later after the skill has hit.

100 damage doesnt pop up
If you don't get a popup after you change the notetag, you can add line of code in the middle
Code:
target.startDamagePopup();
a gainHp/Mp ran during respond hijacks the action result and makes the popup for the actual skill be its own iirc. you might have to save the result before the effect, call the popup, and then replace the result afterwards.

Code:
<Custom Respond Effect>
if (this.isSkill() && this.item().damage.elementId == 3)
{
    var result = JsonEx.makeDeepCopy(target._result);
    target.clearResult();
    target.gainHp(Math.round(target.mhp / 10));
    target.addState(42);
    target.startDamagePopup();
    target._result = result;
}
</Custom Respond Effect>
@Robro33 I still suspect it might work correctly if moved to a later notetag, but I haven't tested it and that works, too 🙂
a gainHp/Mp ran during respond hijacks the action result and makes the popup for the actual skill be its own iirc. you might have to save the result before the effect, call the popup, and then replace the result afterwards.

Code:
<Custom Respond Effect>
if (this.isSkill() && this.item().damage.elementId == 3)
{
    var result = JsonEx.makeDeepCopy(target._result);
    target.clearResult();
    target.gainHp(Math.round(target.mhp / 10));
    target.addState(42);
    target.startDamagePopup();
    target._result = result;
}
</Custom Respond Effect>
Okay so after this popup i noticed that the reason my character was losing 10hp everytime instead of 55 ( 100-45 ) was because he heals 2 times instead of 1
1733572433412.png

It could be fixed if i did half of it or if i said that skill heals you 2 times for 5% everytime you get hit but for the eye it just doesnt look that good so if there is any way of fixing it, would be nice

And to comment on my english, ye i know its not that good, but it was late at night for me and i was tired, didnt really though about what im writing... sorry

EDIT: After testing now, it seems the character is unkillable by ice spells, any way that if the damage is enough to kill him ( hp reaches 0 ) he dont heal?
Okay so after this popup i noticed that the reason my character was losing 10hp everytime instead of 55 ( 100-45 ) was because he heals 2 times instead of 1
can you show a screenshot of your plugin manager? that code should only be ran one time for every hit the target takes. it shouldnt be running twice and whatever its cause is may have other effects in other places.

EDIT: After testing now, it seems the character is unkillable by ice spells, any way that if the damage is enough to kill him ( hp reaches 0 ) he dont heal?
try
Code:
if (this.isSkill() && this.item().damage.elementId == 3 && !target.hp===0)
can you show a screenshot of your plugin manager? that code should only be ran one time for every hit the target takes. it shouldnt be running twice and whatever its cause is may have other effects in other places.


try
Code:
if (this.isSkill() && this.item().damage.elementId == 3 && !target.hp===0)
1733618126369.png
And now he dies like he should, thank you
your yanfly plugins are not in the correct order. they should be arranged in the order as they appear n teir website. if not, all kinds of issues can pop up
1733669498430.png

your yanfly plugins are not in the correct order. they should be arranged in the order as they appear n teir website. if not, all kinds of issues can pop up
Changed the plugins like they wanted ( i think ) but it didnt fix it anything

EDIT: nvm, restarted the game 2 times and now it works D: , thanks all
restarted the game 2 times and now it works
as a heads up, any changes made to your plugins or note tags do not take place until the game project has been saved. Make sure that when youre testing stuff, youve saved your project and are also not loading an old save file as that has its own issues as well.

Original thread: https://forums.rpgmakerweb.com/threads/skill-that-heals-you-after-getting-hit-by-certain-spells.173697/