[Solved] Damage Skill That Also Heals

Status
Not open for further replies.

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
Just like the title says.

If I wanted to create a skill that did damage to enemies, I know how to do that, of course. But if I wanted to create a skill that damaged enemies and healed all allies for a percentage of their health, how would I do this?

upload_2018-10-16_19-12-12.png

Thank you~

~ Dragon
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,523
Reaction score
1,415
First Language
English
Primarily Uses
RMMV
You'll need some scripting knowhow to pull it off. Since everything in the damage formula box fires once per target, you can't put the healing portion in there obviously. Same with much of the yanfly custom eval stuff. HOWEVER, I did manage to find a solution which allowed me to create a similar spell (damage all enemies, heal all allies) by injecting a function call via yanfly's action sequence pack (1) using a conditional check for a section that only fires once, regardless of target count.

Here's what the skill page looks like:



And here's the note tag code I used

<follow action>
if (function(user){ Aesica.Skills.partyHeal.call(this, user, "a.luk * 0.5 + b.luk * 0.5", 0.2, 45); return true; }).call(this, user)

</follow action>


You'll want to replace the red text with your own function call.

Edit: Looking at it, I just realized I have the wrong status ailment set. So in a way, thanks for bringing that to my attention. :D
 

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
I am pleased to know I've helped you out a bit, hehe, but I'm afraid this flies right over my head as far as my own problem.

Thank you, anyway, Aesica~

~ Dragon
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Having it call a common event that checks if an actor is in the active party and heals it if that's the case should work too
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
This is why I love Yanfly's Skill Core plugin. So much customization :)

<MP Cost: 50%>

<Post-Damage Eval>
if (this.isHpEffect() && value > 0){
user.gainHp(value * 0.25)
}
</Post-Damage Eval>

I feel an explanation is in order; "this" refers to the context action, thus it's checking the skill for HP changes. value is the number displayed after the damage is dealt (positive is damage and negative is healing) and 0.25 is 25% in decimal form.
 

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
Wouldn't the user part only refer to the caster though? Or the player's team in general? I'll admit that's a little confusing. Or is it the 'actor' that refers to the character?

I'll try that out though and see if it works.

~ Dragon
 

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
I am... thoroughly amused~!

So, it works, technically speaking, buuuuttt...

upload_2018-10-17_11-15-11.png

I don't particularly care if this is fixed, so I am willing to consider this solved if no suggestions are brought forth~

~ Dragon
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
just use (value / 4) instead of (value * 0.25). It is rounded down but it returns an integer.
 

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
That doesn't change much, heh.

But I have discovered a slight problem with the skill testing that out. It heals for each enemy hit... and not once for the skill being used...

I may have to get rid of the healing factor, but any suggestions would be a great help.

~ Dragon
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
Oh, change "user.gainHp(value * 0.25)" to "user.gainHp(Math.round(value * 0.25))" to negate decimal results.

If you want it after the skill's been used, place it in a <Custom Conclude Effect> set of notetags.

EDIT: The entire party is a little tricky; you will need this line for each battle party position:

$gameParty.members()[x].gainHp(Math.round(value * 0.25))

Where x is 0 up to the last battle position -1 (i.e. a party of four will have 0, 1, 2 or 3 for x from left to right).
 
Last edited:

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
Unfortunately, I have no idea how that would work...

upload_2018-10-17_12-15-7.png

This is as far as my knowledge goes... what would I change the constant or variable to, to heal the party for 25% health after the attack?

~ Dragon
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
What you COULD try is you install Yanfly's Target Core and Damage Core then do the following:
1) Use the <Target: Everybody> notetag
2) Set the damage type to HP Damage
3) Add the following notetag to the skill:

<damage formula>
if (target.isActor()){
value = -(Math.round((a.mat * 8 - b.mdf * 4) * 0.25))
} else {
value = a.mat * 8 - b.mdf * 4
</damage formula>

That will check if the target is an actor and if it is, negatises the damage (making it a heal) else it will do damage, although this might throw your animation off.
 
Last edited:

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hm... that's... actually not a bad idea~!

I will try that out immediately~!

~ Dragon

Edit//: Er... how... do you make it so you can choose either ally or enemy your target?

Ooh... wait, it's the core thingy, isn't it?
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
Hm... that's... actually not a bad idea~!

I will try that out immediately~!

~ Dragon

Edit//: Er... how... do you make it so you can choose either ally or enemy your target?

Ooh... wait, it's the core thingy, isn't it?
Yes, both Core plugins work together to create the damage formula.
 

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
I... feel like I'm getting no where.

I've installed the plug-ins and have figured out how to do the base of what I want with the skill, however... now the problem is that when enemies are selected, they take no damage. And when the party is selected... no health is gained. In addition to this, for some reason when I use the normal attack skill I can only select Bat B when I test my skills?

I am so sorry about all of this... I wish I knew what I was doing wrong.

~ Dragon
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
Have you got a screenshot of your entire skill and its' notetags?

Also, check the plugins are turned ON.

EDIT: If you still have Yanfly's skill core plugin, use the following notetag instead of <damage formula> for best results:

<Pre-Damage Eval>
if (this.isHpEffect() && value > 0){
if (target.isActor()){
value = Math.round(-value * 0.25);
}
}
</Pre-Damage Eval>

This does its' thing before the damage popups display themselves. If you want it to be a whole 25%, change "Math.round(-value * 0.25);" to "Math.round(target.mhp * -0.25);".
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
There is something I don't understand...why don't you use damage formula for something so simple instead of using tons of plugins? I really think you are making things way more complicated than they actually are. Using plugins is nice and useful when they are actually needed. Using them for something that the engine can do on its own just complicates things and requires extra bug-hunting and testing.

Using a for loop in your damage formula is enough for that. MV damage formula allows you to use many characters so you can do amazing things there. There is no need to use and configure plugins at all here.

Code:
for (var i=0; i < $gameParty.members().length; i+=1) $gameParty.members()[i].gainHp(Math.round($gameParty.members()[i].mhp * 0.25)); yourDamageGoesHere
How it works:
It scans each party member and heals for 25% of max HP. The last part should be your real damage formula. It can be the default attack formula a.atk * 4 - b.def * 2 or anything.

If you want you can allow enemies to use this skill as well but then you need a check to decide if you have to heal enemies or allies.
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
There is something I don't understand...why don't you use damage formula for something so simple instead of using tons of plugins? I really think you are making things way more complicated than they actually are. Using plugins is nice and useful when they are actually needed. Using them for something that the engine can do on its own just complicates things and requires extra bug-hunting and testing.

Using a for loop in your damage formula is enough for that. MV damage formula allows you to use many characters so you can do amazing things there. There is no need to use and configure plugins at all here.

Code:
for (var i=0; i < $gameParty.members().length; i+=1) $gameParty.members()[i].gainHp(Math.round($gameParty.members()[i].mhp * 0.25)); yourDamageGoesHere
How it works:
It scans each party member and heals for 25% of max HP. The last part should be your real damage formula. It can be the default attack formula a.atk * 4 - b.def * 2 or anything.

If you want you can allow enemies to use this skill as well but then you need a check to decide if you have to heal enemies or allies.
That's because he only wants the healing to trigger once, whereas your formulas trigger it more than once unless there's only 1 enemy, which he doesn't want to happen. Also, your formula will count each enemy which, by my understanding, should not happen as it will heal each actor a number of times equal to the number of enemies hit.

A for loop before the damage will trigger the loop on each enemy before the damage is done.

EDIT: Running that formula caused four instances of healing on the user and no-one else when hitting four enemies; the same formula, when it missed two, only healed twice.
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
A for loop before the damage will trigger the loop on each enemy before the damage is done.
You're right, I totally missed the fact that he was targeting all enemies at once. I am sorry for that. However there are ways around. You could, for example, target a single enemy and use the damage formula to deal damage to all of them (except the target because that one is going to suffer damage from the actual attack). An other option would be to trigger a switch when you actually use the skill and use that very switch to deal damage. If the switch is true/false (depending on how you want to handle this) you heal, if the value is the wrong one (this means you already healed your party) you only deal damage.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,523
Reaction score
1,415
First Language
English
Primarily Uses
RMMV
But I have discovered a slight problem with the skill testing that out. It heals for each enemy hit... and not once for the skill being used...

I may have to get rid of the healing factor, but any suggestions would be a great help.

~ Dragon
That's why I posted the solution I did, even if it might have been a bit much. The only way (that I'm aware of) to get a "targets all enemies with effect A, then targets all allies with effect B" is to invoke a script call using a part of the overall action sequence that only fires once.

You're going to have to at least get your feet wet with scripting if you want to make this particular effect work in the way you describe it.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top