Custom skill giving error

An opening admission - I am not a scripter, so I expect the mistake to be pretty basic.

I have a skill where the damage formula is too long to fit into the formula box. So I came up with this (where has the Code icon gone?).

# This has 3 effects
# Heal (always) at a cost of 5MP (set in data base)
# If the ally has Poison, remove Poison at the cost of 3MP
# If the ally has Venom, remove Venom at the cost of 10MP
#
#
class Game_Battler < Game_BattlerBase
def whistle_heal(a, b)
if b.state?(2); b.remove_state(2); a.mp-=3
end
if b.state?(57); b.remove_state(57); a.mp-=10
end
b.hp+=50
end
end

That version takes the 5MP and does nothing

Version 2
class Game_Battler < Game_BattlerBase
def whistle_heal(a, b)
if b.state?(2); b.remove_state(2); a.mp-=3;
if b.state?(57); b.remove_state(57); a.mp-=10;
b.hp+=50
end
end

That gives the error
upload_2017-2-12_11-47-19.png


So does putting the mp requirements onto a new line each, and/or taking out assorted semi-colons.

Can anyone sort this out please?
Thanks.
I don't see any ends between your ifs on version 2, and there is no end after the last if either. What happens if you add those (2 ends, one after each if statement is done in version 2)
Sorry, I'm a bit confused. If I put those two ends in, don't I just finish up with version 1 again?
You're right. But you do have to have those two ends somewhere, they can't just disappear. So yes, the error in version 2 is it has two ends missing (for the two ifs). I hadn't looked at version 1 yet though, still pondering why that one does nothing but costs the mp.
Slight update on what version one achieves. Because poison normally goes at the end of battle, I found that I had to reduce the character's HP before the skill would work. It then restored the HP and removed the poison. It does nothing for state 57, venom.

I have double and triple checked - it is state 57 in the States tab, in the script and in the event I used to inflict it on someone, so it's not that I'm trying to cure a different state by accident.

EDIT
Scrap some of that - it is simply removing the 5MP per attempt to heal. When I did my final test I forgot that I had reverted the skill damage formula to the original which had the element to remove poison. My problem stems from the fact that there isn't enough room in the formula box for the removal of state 57 (venom) as well.
Don't use such chaos in formatting, that will make your code look ugly and exponentially increases the chance to trigger errors by typos or missing/too many end lines.

Code:
class Game_Battler < Game_BattlerBase

  def whistle_heal(a, b)
    if b.state?(2)
      b.remove_state(2)
      a.mp -= 3
    end
    if b.state?(57)
      b.remove_state(57)
      a.mp -= 10
    end
    return 50
  end

end

This code works, provided you know how to use it.

If you simply use whistle_heal(a,b) in your damage formula, it won't work. It would actually crash your game, but since there is a rescue method called on the damage formula calculation, it will simply continue with 0 as a result.

You must use a.whistle_heal(a,b), because the method you made is in Game_Battler, and can only be used on a battler object.
So, use that in your formula box while selecting the "HP Heal" damage type, and it will work.

Completely unrelated... Did they change the font of the forum, or the new font I see comes from my PC somehow? 😳
@Sixth that works perfectly, thanks. And you guessed right, I only had whistle_heal(a,b) in the formula box, not a.whistle_heal(a,b) But I'm glad you set out the code the way you did, as I can now see how it should be done, not the endless lines of my own attempt.

Thank you very much indeed. I have a couple of other skills where I want more than one effect, and now I can go ahead and create them.

On your unrelated note - yes, the font is different on this forum.

Original thread: https://forums.rpgmakerweb.com/threads/custom-skill-giving-error.74806/