Status
Not open for further replies.

Kes

Veteran
Veteran
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.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,607
Reaction score
3,882
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
881
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,724
Reaction score
12,277
First Language
English
Primarily Uses
RMMZ
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 Profile Posts

Happy treason day, Colonial friends <3

I am officially amused. One of the NPCs in my project is basically meant as the guy you check in with to point you where you should go next, including if you’ve been away for a bit and have forgotten.

I can conclusively say he does his job nicely. I was out of town over the weekend. I had forgotten what I was working on, so I checked what I had last done with him for a reminder. ^.^
While talking about anime with a friend got the idea of doing this. :kaopride:
4m6nhlF.jpg

Character: Mirajane Strauss from Fairy Tail.
Dog saliva is an antiseptic.
NghNgE9.gif

Forum statistics

Threads
123,333
Messages
1,155,836
Members
161,755
Latest member
shirouinazuki
Top