xyzeden

Villager
Member
Joined
Oct 16, 2021
Messages
19
Reaction score
7
First Language
English
Primarily Uses
RMMV
Hi, I was wondering if there was a way to make an item change a character's class? I can get it working via common events, but then I'd have to list every character there, including ones who aren't in the party yet. It would be much easier if I could use "Thief Scroll" or something in order to change the selected character's class to "Thief".

I saw another thread a few years ago indicating you could input this line of script somewhere to get the job done, but I am pretty bad with scripting and I'm not sure where to put it. Doesn't work if I put it in the item's note, or put it in a "script" command in a common event.

$game_party.target_actor.change_class(3, true)

If anyone could help me out that would be nice. Sorry if this is posted in the wrong spot.
 

ShiningPhoibe

Veteran
Veteran
Joined
May 12, 2020
Messages
166
Reaction score
68
First Language
French
Primarily Uses
RMMZ
As far as I know, here is the actual script call:
Code:
$gameActors.actor(actorId).changeClass(n, keepExp)
I got it from here.
 

Iron_Brew

Veteran
Veteran
Joined
Nov 19, 2021
Messages
416
Reaction score
1,214
First Language
English
Primarily Uses
RMMV
Just have it trigger a common event, should be dead easy :D
 

xyzeden

Villager
Member
Joined
Oct 16, 2021
Messages
19
Reaction score
7
First Language
English
Primarily Uses
RMMV
As far as I know, here is the actual script call:
Code:
$gameActors.actor(actorId).changeClass(n, keepExp)
I got it from here.
Thank you very much for the reply, but I'm not sure that's exactly what I'm looking for. The items in question that change classes are supposed to be applicable to every actor, and it looks like that script is designating a specific actor to change class.

I'm just looking for a way for the item to change the class of the item's target, no matter who it is. Also, assuming there is a script to make such a thing possible, where would I put it to make it function?
 

xyzeden

Villager
Member
Joined
Oct 16, 2021
Messages
19
Reaction score
7
First Language
English
Primarily Uses
RMMV
Just have it trigger a common event, should be dead easy :D
For this in particular I'm just looking to have an item that changes anyone's class. If I were to do it through common event, the item would need a billion theoretical conditional branches to check for who is and isn't in the party.

Like yeah I could just make the event "who will become a Thief" and list everyone's name, and make them that class through the common event... but if they're not in the party, or haven't been recruited yet, that wouldn't make any sense. Just having the item straight up change the class for whoever uses it is what I'm trying to figure out.
 

BenSD

Could be anybody
Veteran
Joined
Dec 22, 2021
Messages
397
Reaction score
554
First Language
English
Primarily Uses
RMMZ
Thank you very much for the reply, but I'm not sure that's exactly what I'm looking for. The items in question that change classes are supposed to be applicable to every actor, and it looks like that script is designating a specific actor to change class.
You actually do want it to apply to a specific actor though; you want only the person this thief scroll is used on to change class, right? You just need to save the target to a variable and use that in place of actorId in what Phoibe posted. Now here's the punchline: I don't actually know much about JS, so I can't tell you how to do that...but I will tell you how I think you'd do that.

Code:
$gameVariables.setValue(x, $gameParty._targetActorId);
$gameActors.actor($gameVariables.value(x)).changeClass(n, keepExp);

So that might work...I think it will...unless there really are a ton of possible actors, though, I would personally set this as a common event anyway.
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
Here use this. In your item, set target to user. In the damage formula put this in
b.changeClass(n, true)

set n to any number based on class index, so if it is the first class in the list, then put 1 for n.
Make sure to add an effect like Gain TP 0, else you will here failed to use item sound effect. You can also call a common event that has a message say "Class change to ..." or whatever you like the message to say

Set true to false if you don't want same exp when class change.
 

xyzeden

Villager
Member
Joined
Oct 16, 2021
Messages
19
Reaction score
7
First Language
English
Primarily Uses
RMMV
Here use this. In your item, set target to user. In the damage formula put this in
b.changeClass(n, true)

set n to any number based on class index, so if it is the first class in the list, then put 1 for n.
Make sure to add an effect like Gain TP 0, else you will here failed to use item sound effect. You can also call a common event that has a message say "Class change to ..." or whatever you like the message to say

Set true to false if you don't want same exp when class change.
Ohhh thank you so much. Okay so this is exactly what I was looking for. Using the formula to dictate the class change sounds like what I was looking for perfectly... the only issue there is that with this formula, I keep getting the same crash.

failed to execute "createLinearGradient" on "canvasRenderingContext2D": float parameter 3 is non-finite

I've tried changing the targets and the empty effects for the item, and it always crashes the same. But assuming it doesn't crash when the item is used, this should solve it I think. Apparently it's from trying to draw the actor's healthbar or something, and not working.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,817
Reaction score
2,873
First Language
EN
Primarily Uses
RMMZ
Did you replace n with an actual number? You might also try adding a 0 to the end of the formula, e.g. "change the target to class ID 1, then return a value of 0":

b.changeClass(1, true); 0
By default there's a failsafe to catch non-numerical damage formula values (undefined in this case) and turn them into 0, but you might be using a plugin that removes that.

Otherwise I think Ben's idea should work if the item is only usable via the pause menu.
 

xyzeden

Villager
Member
Joined
Oct 16, 2021
Messages
19
Reaction score
7
First Language
English
Primarily Uses
RMMV
Ohhh thank you so much. Okay so this is exactly what I was looking for. Using the formula to dictate the class change sounds like what I was looking for perfectly... the only issue there is that with this formula, I keep getting the same crash.

failed to execute "createLinearGradient" on "canvasRenderingContext2D": float parameter 3 is non-finite

I've tried changing the targets and the empty effects for the item, and it always crashes the same. But assuming it doesn't crash when the item is used, this should solve it I think. Apparently it's from trying to draw the actor's healthbar or something, and not working.
This worked! Thank you so much, adding a blank number to the formula was the key. :stickytongue:
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
@xyzeden I am glad you got it working. I tested out the script on the damage formula on a fresh project with no plugins last night. I honestly forgot to add ;0 at the end. That's my bad. It was late at night when I posted.

Sorry for the mistake on my end. I hope your game achieves greatness :)
 

Latest Threads

Latest Posts

Latest Profile Posts

Every group of friends has that one "stupid friend". If you aren't sure who is the "stupid friend" in your group... it's most likely you.
Just spent 30 min growling at a mesh not importing properly to unity.
Then the programmer asked "Did you send me the updated texture?"
*Nervous laughter*
Well, that explain the transparent texture eh?
If you have ever played these games and miss them, please look forward to it.
Miss the old retro style? I'm a fan of it, especially these Famicom games.
"Dragon Ball Z from Nintendo Entertainment System"
dragonball-z.jpeg

Forum statistics

Threads
124,655
Messages
1,164,986
Members
163,471
Latest member
FM445
Top