Status
Not open for further replies.

Kes

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

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,607
Reaction score
3,881
First Language
Java's Crypt
Primarily Uses
RMMZ
Do you have two monsters on the enemy party?

On that last line of the script call, you're changing the HP of the second monster (index 1). It's the only thing I see that can cause a problem.
 
Last edited by a moderator:
  • Like
Reactions: Kes

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
890
First Language
German
Primarily Uses
RMMZ
Enable console and put this above the script:

Code:
p "Actors"p $game_party.membersp "Enemies"p $game_troop.members
 
  • Like
Reactions: Kes

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
880
First Language
English
Primarily Uses
RMMV
Yeah, like Hudell said, you probably need to change '$game_troop.members[1]' to '$game_troop.members[0]' if you only have one enemy.
 
Last edited by a moderator:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,599
Reaction score
12,142
First Language
English
Primarily Uses
RMVXA
That was it.  I keep forgetting that the index starts at 0.  When the last line was changed, everything went smoothly.

Thank you all so much.  I've been tearing my hair out over this.
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

I made a mini devlog about the sprite animations I've been working on! You can read it by clicking here


applebuds-dreamtrotter.gif
What happens with this list, is it currently possible to buy any of these RPGMAKER at least those that are for PC?

Combat skill combination demostration
grief... finding a font that works with the engine has been a bigger process than I thought it'd be. doesn't help MV loves to scrunch letters next to each other like a football huddle.

Forum statistics

Threads
122,182
Messages
1,147,112
Members
160,462
Latest member
LunaTheRedFox
Top