Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Error in custom script call to add actor to the party

Merk

Member

Hello,

In my game, I'm trying to create an event that adds a new actor to the party roster. You get to select the actor's gender, class, and name, and then the actor is initialized and added to your party. I am also using Yanfly's Party Management Script, although that seems to be stable. Because the standard Event Commands don't allow you to add a party member who's actor ID is variable, I am using the following loophole: Only Actor ID 1 (the first in the database) is ever modified during the Event (The player begins with Actor 2 in his or her party). The gender (and therefore sprite & face), class, and name are all entered for actor 1, and then I use a script call Event Command as follows:

$game_actors[$game_variables[1] + 3].setup($game_variables[1] + 3)
$game_actors[$game_variables[1] + 3].name = $game_actors[1].name
$game_actors[$game_variables[1] + 3].character_name = $game_actors[1].character_name
$game_actors[$game_variables[1] + 3].character_index = $game_actors[1].character_index
$game_actors[$game_variables[1] + 3].face_name = $game_actors[1].face_name
$game_actors[$game_variables[1] + 3].face_index = $game_actors[1].face_index
$game_actors[$game_variables[1] + 3].class_id = $game_actors[1].class_id
$game_party.add_actor($game_variables[1] + 3)

The first game variable, referred to by $game_variables[1] is a counter keeping track of how many times the "add a new party member" task has been performed. I've set some of the attributes of Game_Actor, such as character_name and character_index to accessor instead of reader. Then the "proper" actor (that is, the one that will actually be added to the party) gets the name, graphics, and class from Actor 1.

After the script call, the event concludes by setting Actor 1's name and graphics to blank & iterating the "add a new party member" variable.

The Issue

I can add actors to my party, but when trying to check the Status of a newly added member, the game crashes, and I receive the following error:

Script 'Window_Status' line 102: TypeError occurred.

nil can't be coerced into Fixnum

Line 102 in Window Status reads as follows:

s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp

What I guess is happening is that my script call to "copy actor 1 into actor v1 + 3" isn't properly copying enough of the data from actor 1.

Can anyone offer some insight into what is actually happening, and what I might be able to do to fix it? Thank you very much.

Edit:

I seem to have fixed this myself by modifying the custom script like this:

$game_actors[$game_variables[1] + 3].name = $game_actors[1].name
$game_actors[$game_variables[1] + 3].character_name = $game_actors[1].character_name
$game_actors[$game_variables[1] + 3].character_index = $game_actors[1].character_index
$game_actors[$game_variables[1] + 3].face_name = $game_actors[1].face_name
$game_actors[$game_variables[1] + 3].face_index = $game_actors[1].face_index
$game_actors[$game_variables[1] + 3].class_id = $game_actors[1].class_id
$game_actors[$game_variables[1] + 3].init_exp
$game_party.add_actor($game_variables[1] + 3)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top