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.

[XP]Copying a player chosen name to another actor

Hi, I've had a look to see if this has been asked before but it didn't seem like it had...

I'm going to implement an event-based class change system in my game by having various actors for each class. This is so the stats will change as well as the skills learned. The necessary actor will be leveled up appropriately when the main character changes class.

The problem I'm having is with the name changing mechanic. I want the player to be able to choose the name for the main character but this needs to copy across to all the actors used for the main character. I tried experimenting with the event functions but was forced to admit defeat. Apologies if the solution is really simple and I'm just stupid and missed it

My project is being made in RPG Maker XP. If anyone has an idea how this could be that would be great. I suspect the solution will be script related but I unfortunately have little to no scripting skills.
 
You'd have to call a script in the event
Ruby:
$game_actors[1].name = $game_actors[2].name

So that will set actor 1's name to actor 2's name

If you have batches of actors that represent the class set for a single game character then you can do clever for-looping to change them all, however isn't it easier to just change the actor's class itself?

EDIT: Here's how you would copy classes, again it's a script call event
Ruby:
swap_class = $game_actors[2].class_id

$game_actors[1].class_id = swap_class

$swap_class = nil

So what you'd do is have your normal characters then add a new character for each class and then you can assign your character's classes using that script call, you'd have to un-equip items and clean up any problems with class swapping afterwards though.

I did this in VX, so not sure about how it works in XP

EDIT2: And RGSS scripters please excuse my syntax, I'm guessing having the world "class" in a variable name is sinful in someway.


EDIT3: Also, if you want to learn how to do these additional scriptlets yourself, I looked at Game_Actor in the script editor and inspected the public instance variables (AKA member variables or attributes), there you can see these fields (In VX at least):
Ruby:
  attr_reader   :name                     # name

  attr_reader   :character_name           # character graphic filename

  attr_reader   :character_index          # character graphic index

  attr_reader   :face_name                # face graphic filename

  attr_reader   :face_index               # face graphic index

  attr_reader   :class_id                 # class ID

  attr_reader   :weapon_id                # weapon ID

  attr_reader   :armor1_id                # shield ID

  attr_reader   :armor2_id                # helmet ID

  attr_reader   :armor3_id                # body armor ID

  attr_reader   :armor4_id                # accessory ID

  attr_reader   :level                    # level

  attr_reader   :exp                      # experience

  attr_accessor :last_skill_id            # for cursor memory: Skill

Using the code I posted above, you should be able to read each of these variables at each index for your actors, however keep in mind that there is a line-length limit in the script event call, which is why I created a variable "$swap_class" and used that to store the actor 2 class_id as swap_class is shorter than writing game_actors[2].class_id so gave me back that line space.
 
Thank you so much, this did exactly what I wanted.

I'm using different actors so that each class will have different stats. Also, I have found that when changing classes any skills that would have been learned at lower levels aren't added. I find having different actors works better for me.

Thank you again
 
MiatheRabbit":2hrt7nlm said:
Thank you so much, this did exactly what I wanted.

I'm using different actors so that each class will have different stats. Also, I have found that when changing classes any skills that would have been learned at lower levels aren't added. I find having different actors works better for me.

Thank you again
You would solve that by setting level to 1 and then increment upwards, I believe (Maybe wrongly?) that stats will modify and scale accordingly, oh well I guess the only cool thing you get from my way is you can have cross-ability classes.
 

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