[XP] Sync Character Levels?

Started by Makoto77, March 18, 2020, 07:04:46 pm

Previous topic - Next topic

Makoto77

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?

KK20

Would help to know how you are handling transformations.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

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)

KK20

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.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

March 19, 2020, 12:53:16 pm #4 Last Edit: March 19, 2020, 03:13:17 pm by KK20
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?

KK20

Why would it not? How about you try it out and report your findings.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

The problem is I don't fully understand how. I'm trying to do it but IDK really.

Makoto77

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.

KK20

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.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

Ah, thanks. So I have to use that script?

KK20

It's a script call. It's the very last event command.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

Okay.  I assume ID refers to the actor level's variable, and TARGET_LEVEL is the level to be replaced?

KK20

No, it's the actor's ID in the database.
With this script call, you don't need to use game variables anymore.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77


Makoto77

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.

KK20

$game_actors[9].level = $game_actors[15].level

You're new to this scripting thing, huh

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

June 27, 2020, 07:13:49 pm #16 Last Edit: June 27, 2020, 08:14:10 pm by Makoto77
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.

KK20

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

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Makoto77

June 27, 2020, 10:29:57 pm #18 Last Edit: June 27, 2020, 10:32:46 pm by Makoto77
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.