Passive ability to heal self for % when healing others?

Hey everyone,

I'm designing a party member that is a healer and want them to have a passive ability that is basically 'Whenever [this character] uses a healing spell, [this character] also heals themselves for 20% of the amount healed.' So basically, if you heal a party member for 100 HP, then you also heal yourself for 20 HP.

However, I'm not sure how to go about implementing this - if it's even possible at all. I figure I will have to maybe have a special notetag or common event tied to each healing spell the character gets, but I'm not really sure how to approach it.

Anyone have any suggestions or advice?

Thanks! 🙂
It's definitely possible, in fact I've seen exactly that. I'm not sure if it was a plugin, I'll look around and try to find it. I'd bet that even if it isn't what I"m thinking of, that there is a yanfly plugin for it.
I think this might have been a Yanfly Tips and Tricks video on YouTube but I'm not sure
Good call! I was able to find this:


Which is SO CLOSE to what I'm trying to do. The problem is, while this is a state effect that anyone can take advantage of, I only want this one character to benefit from it. So only this one character gets the healing link benefit when they cast a healing spell, and no one else. I would also like for it to not proc on item-based healing, though they may be a bit trickier so I'll be content even if we can't get that aspect working.
Edit: Sorry, I linked the wrong skill. I'll update shortly.
Still working on it, here is one place that has a HoT that gets activated when you heal a party member.:

Same person's plugin, but this is only the caster.

Edit: I'm sure it would be a simple matter to change the code to instantly heal instead of healing over time. I can't stop to check it out myself, but the code is pretty short.

Edit: Sorry, I linked the wrong skill. I'll update shortly.

This one could work, if we set the passive state to only function for one turn, it should (in theory) do all that healing in one turn instead of spread over three?

And this line:
target.addState(164)

Could we instead change it to:
self.addState(164)

Or would that mess some other parts up? I'm not super knowledgeable on JS, but Yanfly's text seems pretty self-explatory.
I think you could do this in the damage formula itself. Give that character a blank passive state, let's say state 15 just as an example. Let's further say you want the caster to heal for 50% of the amount the spell heals for (let's say twice the caster's magic attribute).

In your healing spells' damage formula, put in something like this, assuming you're using the caster's magic attribute (and have the type set to HP Recover of course):

a.isStateAffected(15) ? a.mat * 2 && a.gainHp(a.mat) : a.mat * 2;

I've simplified the math on it, let's say you wanted 20% self-heal instead, then:


a.isStateAffected(15) ? a.mat * 2 && a.gainHp((a.mat * 2) * 0.2) : a.mat * 2;

You could read that as:

If caster has state 15, then:
a.mat *2
a.gainHp((a.mat *2) * 0.2
else
a.mat * 2

So it checks if the caster has state 15, and if so, it heals the target for their magic attack value x2, and heals the caster for their magic attack value x2 times 0.2, giving 20% of the original.

I've never actually tried something like this though, so feel free to tell me "Dirge you're a dolt and that would never work" haha

EDIT: I can think of an even more efficient way to do it, actually, using Pivoo's new Scriptlets plugin, if you're interested, which would allow you to change the self-heal rate dynamically based on whatever conditions you want
Thanks for working all that out! I can totally try that out, but...

EDIT: I can think of an even more efficient way to do it, actually, using Pivoo's new Scriptlets plugin, if you're interested, which would allow you to change the self-heal rate dynamically based on whatever conditions you want

I wouldn't mind giving this a go if you think it's easier. Is it this? I will admit, it looks a bit...daunting, haha.
No worries, no guarantees it'll work. I've been in a damage formula headspace for a couple days while working out how to handle dynamic damage bonuses vs. enemy types in my game, which makes use of that Scriptlets plugin, as well.

Scriptlets is actually really easy to use, but configuring it is tougher. Let me see if I can come up with some code that will work.
No worries, no guarantees it'll work. I've been in a damage formula headspace for a couple days while working out how to handle dynamic damage bonuses vs. enemy types in my game, which makes use of that Scriptlets plugin, as well.

Scriptlets is actually really easy to use, but configuring it is tougher. Let me see if I can come up with some code that will work.

Thanks, I really appreciate it. It does look like something I'll probably mess with in the future, since I'm probably going to try and implement more complex stuff like this in my game going forward.
I feel stupid for how easy this was, although this solution does require a plugin. Use Yanfly's skill core plugin. I added the following to the note tag of heal (make a custom skill if you don't want this effect on everyone's heal skill):
Spoiler: Heal Notetag
Code:
<Post-Damage Eval>
     var heal = Math.floor(value * 0.2);
     a.gainHp(-heal);
</Post-Damage Eval>
Edit: Just because it feels good to figure things out:
Spoiler: What happiness looks like.
ImJFJeW.png
Edit: On a side note, if there were a way to pass the value of that heal and the actor that did the healing to a common event, that would be just as easy without a plugin. I wish I knew more about scripting.
I just spent ages with Pivoo coming up with a really slick scriptlet for it and come back and find bhindi has done it in a much simpler way. LOL. His way is better for this application.
I have been playing around and put this in the healing formula. I can't figure out why it works the way it does, but it heals the correct amount on the target, and heals for two numbers that add up to around 20% of the target's heal on the caster.
Spoiler: Why does this almost work?
Code:
a.gainHp(.2*(200+a.mat));200+a.mat;
This is without using any plugins.

Edit: I have been looking at this page which is a wonderful sort of tutorial for this type of thing. Still trying to fully understand it though.
Spoiler: Restructured the code slightly for readability.
Code:
heal=200+a.mat; a.gainHp(.2*heal); heal;
Huh, interesting. The way I solved it was using Pivoo's Scriptlets plugin, with the following formula in the healing skill:

Math.floor(a.mat * 2 + $js.run(3,a))

And the scriptlet that "$js.run(3,a)" is referencing is this:

Code:
var user = arguments[0][1];
var note = $dataActors[user.actorId()].note;
if (/<healer>/i.test(note)){
    user.gainHp(Math.round((user.mat * 2) * ($gameVariables.value(101) / 10)));
}
return 0;

Which is great. I'd set variable 101 in my test game to be 2. It checks if the user has the <healer> notetag, too. Of course it requires some customization - and it would need to be duplicated with a new gainHp formula for each healing skill - but it would allow you to use anything you can store in a variable as the base for the self-heal percent.
Lol. I just came up with the Math.floor as well, we solved it for this case. Just put this into the damage formula and it gives a heal to the target and a 20% heal to the caster. The two numbers that I was getting earlier were a whole and a decimal part.
Spoiler: Final Solution
Just put this in your healing formula area
Code:
heal=(200+a.mat); a.gainHp(Math.floor(heal*.2)); heal;
Edit: @Dirge: That makes total sense because I referenced what the Pivoo scriptlet was referencing. I'll have to check out the Pivoo stuff when I get a chance.

I am jealous of the people who already know all of these references. It's kind of disappointing actually that the solution was so easy, but wasn't so easily found.
Oh, I came up with it by chopping up code someone else helped me with for a different thing, and Pivoo fixed it for me when I had it needlessly complex.

I actually think using the scriptlets approach would work better for @esterk 's needs, because it allows the actor to be notetagged as <healer>. Then, when the spell is used by an actor without that tag, it just heals the target normally, but when the <healer> uses it, it heals them for the defined amount as well.
I see what you mean. At the moment, I don't even think my suggestion does any additional healing to the caster on self-cast. It only self-heals for 20 percent if it's cast on another person. I wonder if there is no a and b designation on a self cast.
Wow, this is all awesome stuff. It's cool to see you guys work through it and it helps me understand it a bit better as well. So is the Scriplets approach the best solution in this case? It seems like the other option @bhindi1224 presented I would be making two different healing skills in the game, one for general use (that has no notetag) and one just for this character (that has the notetag).

if we are looking at using the Scriplets code, I'm reading over it and wanted to make sure I have this right. So do I use the scriplet in the damage line for the kill or the notetag? Otherwise, once that;s in place, the scriplet references this:

var user = arguments[0][1];
var note = $dataActors[user.actorId()].note;
if (/<healer>/i.test(note)){ user.gainHp(Math.round((user.mat * 2) * ($gameVariables.value(101) / 10))); } return 0;

And if the user has the <healer> notetag, they heal for their Magic Attack * 2 * 20% (if the variable 101 is set to 2). So if their Magic Attack is 50, they would then heal themselves for 20 HP.
The one that I came up with requires no plugins at all. You can just create a skill and put that tiny bit of code into the skill's formula area. What it won't do is extra healing if the caster puts it on himself.
Spoiler: No plugins solution
Code:
heal=(200+a.mat); a.gainHp(Math.floor(heal*.2)); heal;
2U5j8uH.png
Ohhh I see! That's okay though, because I don't think I want him gaining extra healing if he heals himself anyway. Only if he heals another target.

Original thread: https://forums.rpgmakerweb.com/threads/passive-ability-to-heal-self-for-when-healing-others.85532/