Skill that deals damage and heals user by a percentage?

● ARCHIVED · READ-ONLY
Started by JtheDuelist 13 posts View original ↗
  1. 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)
  2. r=(your damage formula); a.gainhp(a.hp*0.2); r
  3. 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...
  4. 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.
  5. 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
  6. Javascript is case-sensitive. Look closely and you'll see it :)
  7. Aloe Guvner said:
    Javascript is case-sensitive. Look closely and you'll see it
    I don't see it...
  8. On your first post you wrote "a.gainHp" but in your damage formula you wrote "a.gainHP"
  9. Aloe Guvner said:
    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?
  10. 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));

    For old versions of MV
    Code:
    a.friendsUnit().aliveMembers().forEach(function(friend) {friend.gainHp(friend.hp * 0.2)});
  11. @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?
  12. JtheDuelist said:
    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"
  13. @Aloe Guvner I am on 1.5.2

    EDIT: The old version worked- thanks.