Skill that deals damage and heals user by a percentage?

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,186
Reaction score
1,440
First Language
English
Primarily Uses
Other
I am trying to do a skill that deals damage to an enemy while healing that deals damage using both the user's Def and M.Def instead of Atk and the user by 20% of the user's HP, but the healing seems to be exactly what I had set (.2).
Can anyone help fix my formula?

Code:
100 + (a.def * 4 + a.mdef * 4 - b.def * 2); a.gainHp(0.2)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,837
Reaction score
7,896
First Language
German
Primarily Uses
RMMV
r=(your damage formula); a.gainhp(a.hp*0.2); r
 

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,186
Reaction score
1,440
First Language
English
Primarily Uses
Other
That worked- thank you. Know if I could only figure how to do this for my party-wide healing version of the skill.

EDIT: Well that broke something- my skill is healing the user, but dealing 0 damage to the enemy....

EDIT 2: Fixed the problem of 0 damage- I was using a.mdef instead of a.mdf...

EDIT 3: New problem:
error.png

EDIT 4: This healing effect itself is causing the error- guess I'll have to split this into two skills with the same name...
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,837
Reaction score
7,896
First Language
German
Primarily Uses
RMMV
The damage formula in your screenshot is NOT what I wrote.
There is a reason why I used the temporary variable r that way.
The damage is always the last number processed in the damage formula, no matter what.
 

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,186
Reaction score
1,440
First Language
English
Primarily Uses
Other
Well, you should of said the Rs were mandatory...

EDIT 1: Nope, your formula didn't work...
error2.png

EDIT 2: I just noticed I added an extra )- my mistake.

EDIT 3: WHAT THE FLIP AM I DOING WRONG?!
error3.png
 
Last edited:

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,119
First Language
English
Primarily Uses
RMMV
Javascript is case-sensitive. Look closely and you'll see it :)
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,119
First Language
English
Primarily Uses
RMMV
On your first post you wrote "a.gainHp" but in your damage formula you wrote "a.gainHP"
 

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,186
Reaction score
1,440
First Language
English
Primarily Uses
Other
On your first post you wrote "a.gainHp" but in your damage formula you wrote "a.gainHP"
PoF.png
I tried that and it worked... Now how would I change a.gainHp to affect the entire party?
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,119
First Language
English
Primarily Uses
RMMV
You can iterate over $gameParty but then it would always be the heroes who get healed. The way to do it so both enemies or actors could use the skill is like this. Remove your previous gainHp of course, so the caster isn't healed twice.
Code:
a.friendsUnit().aliveMembers().forEach(friend => friend.gainHp(friend.hp * 0.2));

Code:
a.friendsUnit().aliveMembers().forEach(function(friend) {friend.gainHp(friend.hp * 0.2)});
 

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,186
Reaction score
1,440
First Language
English
Primarily Uses
Other
@Aloe Guvner So, basically this?

Code:
r=100 + (a.def * 4 + a.mdf * 4 - b.def * 2); a.friendsUnit().aliveMembers().forEach(friend => friend.gainHp(friend.hp * 0.2)); r

EDIT: Tried this as is- got an error "Unexpected token =>"

Actually, this skill was going to be player only, so how would I use $gameParty in this case?
 
Last edited:

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,119
First Language
English
Primarily Uses
RMMV
EDIT: Tried this as is- got an error "Unexpected token =>"

If you have an old version of MV, then use the code I put in the box titled "For old versions of MV"
 

Latest Threads

Latest Profile Posts

>Testing with fonts change.
>Tries installing a plugin. Doesn't work.
>Tries changing the plugin commands. Doesn't work.
>Tries installing another plugin. Doesn't work.
>Changes a few more plugin commands. Doesn't work.
>Goes directly to the gamefont file and changes the src. Works.

YYEEEAAAAHHHAAAA

Perseverance is key, bois and girls.
What Reviews say on RPG Maker MZ?
Looking back at some sketches, and game design documents on my PC dated summer of 2015. I started development with the release of MZ, but in 2015, I felt a strong desire to make a game out of the blue. I remember feeling sad for no apparent reason, and all these ideas rushed into my head. Now that I think about it, since that day, everything has become easier to do on my PC . . . it’s very creepy.
Everything's going to be alright! We're all in this together. <3
Aaaaannd published my game's tech demo. :D

Feel free to download and play it. And give feedback!

Forum statistics

Threads
107,802
Messages
1,032,317
Members
139,947
Latest member
bitepp
Top