Class-changing item?

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.
As far as I know, here is the actual script call:
Code:
$gameActors.actor(actorId).changeClass(n, keepExp)
I got it from here.
Just have it trigger a common event, should be dead easy 😀
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?
Just have it trigger a common event, should be dead easy 😀
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.
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.
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.
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.
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.
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. 😛
@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 🙂

Original thread: https://forums.rpgmakerweb.com/threads/class-changing-item.147875/