xyzeden

Villager
Member
Joined
Oct 16, 2021
Messages
17
Reaction score
6
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
368
Reaction score
1,073
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
17
Reaction score
6
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
17
Reaction score
6
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
553
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
68
Reaction score
48
First Language
English
Primarily Uses
RMMZ
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
17
Reaction score
6
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,659
Reaction score
2,751
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
17
Reaction score
6
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
68
Reaction score
48
First Language
English
Primarily Uses
RMMZ
@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

Took some trial and error, but I managed to create "visuals" for underground dig path regions.
Couldn't sleep at all so I started working on the topmost deck. I've had to make several deviations from the Imperator/Berengaria's deck-plans to accommodate MV's movement, but 100% accuracy was never my intention.
Still no name for the poor ship...:kaodes:
Screenshot-2022-06-25-053308.png
ScreenShot_6_24_2022_9_20_7.png
Here's Mike when you get a preemptive strike in battle. There's another one for when an enemy sneaks up on you too.
Suddenly, games mean nothing. The money spent was worth it to bring souls towards the light of life. May God bless my path forever. I pray that all are shaken for truth and poured out flat on the table of true understanding, knowledge, and wisdom. Bless you.

Forum statistics

Threads
123,025
Messages
1,153,497
Members
161,369
Latest member
jaycen
Top