I'm making a game right now, and the characters are able to transform. However, I need to sync the Level between the transformed character and the untransformed one. How can I do this?
Would help to know how you are handling transformations.
The character would theoretically (It's not yet fully implemented) use a skill that triggers a common event that transforms them. Each one has a different skill, and each one would have a different common event (to account for different characters transforming)
So...are you handling the transformation by removing the actual actor and adding a "transformed" actor? You can just store the actual actor's Level to a variable (Control Variables... -> Set -> Actor's Level) and then 'Change Level...' of the transformed actor by setting it equal to that variable.
Oh, thanks! I think I might do the opposite, actually, as the "base" actor is not fit for combat, and the transformed one is more for combat.
Will this work with multiple transformations?
Why would it not? How about you try it out and report your findings.
The problem is I don't fully understand how. I'm trying to do it but IDK really.
I can't set an actor's level to equal the variable; I can only make the variable subtract or add to the actor's level, meaning that while it does work as intended when the actor is level 1 (level remains untouched), at higher levels, the actor's level (and stats) increase.
You could just do some game variable math. You use three variables: current level, target level, and the difference between the two. Then, you just increase the level based on the difference.
The scripted way would be to just do
$game_actors[ID].level = TARGET_LEVEL
replacing ID and TARGET_LEVEL obviously.
Ah, thanks. So I have to use that script?
It's a script call. It's the very last event command.
Okay. I assume ID refers to the actor level's variable, and TARGET_LEVEL is the level to be replaced?
No, it's the actor's ID in the database.
With this script call, you don't need to use game variables anymore.
Ah.
The script doesn't seem to work. I'm using actor ID 9 as one of the base characters (there's a lot of characters), and I'm trying to copy actor ID 15's level (the transformed version of ID 9) to actor ID 9, but it sets actor ID 9's level to 15.
$game_actors[9].level = $game_actors[15].level
You're new to this scripting thing, huh
I also tried that at the same time I tried the other method, but the game crashed.
EDIT: I was mistaken, it was actor ID 7, not 9. I changed the script to reflect that (just replaced the 9 with a 7). The game crashed regardless.
Would be more helpful to understand what the cause of the error is. You should always provide the error message so scripters know where to start looking to debug it.
I'm guessing it has to do with the small text area, forcing you to use two lines. In which case
$game_actors[7].level =
$game_actors[15].level
Because doing something like
$game_actors[7].level = $game_actors
[15].level
or similar is syntactically incorrect. Ruby reads and executes each line one at a time; it's not smart enough to know that the [15] is supposed to be in-front of $game_actors (because the first line is technically valid syntax).
Yes, it has been split into two lines.
If another error happens, I'll send the error message.
EDIT: Thanks a lot, the script worked.