Custom skill giving error

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
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.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
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)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Sorry, I'm a bit confused. If I put those two ends in, don't I just finish up with version 1 again?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
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? o_O
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@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.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top