Chaos Project

RPG Maker => General Discussion => Troubleshooting / Help => Topic started by: Makoto77 on March 18, 2020, 07:04:46 pm

Title: [XP] Sync Character Levels?
Post by: Makoto77 on March 18, 2020, 07:04:46 pm
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?
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on March 18, 2020, 07:17:57 pm
Would help to know how you are handling transformations.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on March 18, 2020, 08:11:58 pm
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)
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on March 19, 2020, 12:14:57 am
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.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on March 19, 2020, 12:53:16 pm
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?
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on March 19, 2020, 03:14:31 pm
Why would it not? How about you try it out and report your findings.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on March 20, 2020, 11:45:00 am
The problem is I don't fully understand how. I'm trying to do it but IDK really.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 01:00:57 am
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.
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on June 27, 2020, 01:32:38 am
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.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 01:34:30 am
Ah, thanks. So I have to use that script?
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on June 27, 2020, 01:50:13 am
It's a script call. It's the very last event command.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 01:51:49 am
Okay.  I assume ID refers to the actor level's variable, and TARGET_LEVEL is the level to be replaced?
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on June 27, 2020, 02:02:06 am
No, it's the actor's ID in the database.
With this script call, you don't need to use game variables anymore.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 02:26:53 am
Ah.
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 04:42:04 pm
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.
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on June 27, 2020, 07:04:21 pm
$game_actors[9].level = $game_actors[15].level

You're new to this scripting thing, huh
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 07:13:49 pm
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.
Title: Re: [XP] Sync Character Levels?
Post by: KK20 on June 27, 2020, 09:21:41 pm
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).
Title: Re: [XP] Sync Character Levels?
Post by: Makoto77 on June 27, 2020, 10:29:57 pm
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.