- Joined
- Aug 3, 2012
- Messages
- 22,724
- Reaction score
- 12,277
- First Language
- English
- Primarily Uses
- RMMZ
The following script call is a troop event. I have given it line numbers just to make it easy for me to refer to each bit. Obviously as a script call, it doesn't normally have them. This script call is on a page set to turn 1 and every subsequent turn, and the span is Turn.
a=0$game_party.members.each{|actor| #if actor.state?(77) b=(actor.hp*5/100) actor.hp-=b a+=b #end}$game_troop.members[1].hp += aWhat I think is happening with this script call is this.
Line 1 - establishes that a has a zero value at the beginning.
Line 2 - establishes that what follows is for all actors who are currently in the battle party.
Line 3 - checks whether each actor has state 77 inflicted on them
Line 4 - establishes the value of b. In this case it is equal to 5% of every actor's current HP
Line 5 - Each actor has HP to the value of b subtracted from their current HP
Line 6 - a is now given the value of b
Line 9 - An enemy (in this case the enemy with the troop ID of 1) is given HP to the new value of a
This action is in addition to the skills in the enemy's skill list.
State 77 is inflicted on all the party by an event command at turn 0. I have checked that this works by giving the state a distinctive icon and it appears at that moment. Dialogue which follows the state being inflicted runs as expected.
I choose the party's actions and at the end of that the game crashes with the following error message.
'Game_Interpret' line 1411: NoMethodError occurred
undefined method 'hp' for nil:NilClass
I cannot see what is wrong with the script call to produce that error. Could anyone help me out please?
Thank you.
a=0$game_party.members.each{|actor| #if actor.state?(77) b=(actor.hp*5/100) actor.hp-=b a+=b #end}$game_troop.members[1].hp += aWhat I think is happening with this script call is this.
Line 1 - establishes that a has a zero value at the beginning.
Line 2 - establishes that what follows is for all actors who are currently in the battle party.
Line 3 - checks whether each actor has state 77 inflicted on them
Line 4 - establishes the value of b. In this case it is equal to 5% of every actor's current HP
Line 5 - Each actor has HP to the value of b subtracted from their current HP
Line 6 - a is now given the value of b
Line 9 - An enemy (in this case the enemy with the troop ID of 1) is given HP to the new value of a
This action is in addition to the skills in the enemy's skill list.
State 77 is inflicted on all the party by an event command at turn 0. I have checked that this works by giving the state a distinctive icon and it appears at that moment. Dialogue which follows the state being inflicted runs as expected.
I choose the party's actions and at the end of that the game crashes with the following error message.
'Game_Interpret' line 1411: NoMethodError occurred
undefined method 'hp' for nil:NilClass
I cannot see what is wrong with the script call to produce that error. Could anyone help me out please?
Thank you.