I'm making an ability for one of my characters to take on the class of another character mid battle. The problem is i dont know how to store a class ID in a variable or how to change the targets class to that variable. Help would be apreciated, thank you.
Changing classes using variables?
RPG Maker MZ SupportPut this in a Variable OP
Get Class ID from x-th actor in your party:
Replace x with the index. Sorry, I don't remember whether you need to type 0 or 1, just try it out.
This call returns 0 when this actor isn't present in your party.
Get Class ID from x-th actor from your database:
Put this in a Script Call
Set Class from x-th actor in your party by Variable
Set Class from x-th actor from your database
Get Class ID from x-th actor in your party:
Code:
$gameParty.members()[x] ? $gameParty.members()[x].currentClass().id : 0
This call returns 0 when this actor isn't present in your party.
Get Class ID from x-th actor from your database:
Code:
$gameActors.actor(x).currentClass().id
Put this in a Script Call
Set Class from x-th actor in your party by Variable
Code:
$gameParty.members()[x].changeClass($gameVariables.value(1), true)
Set Class from x-th actor from your database
Code:
$gameActors.actor(x).changeClass($gameVariables.value(1), true)
Your question doesn't really provide enough context to just give you an answer.
Broadly speaking, you store a class ID the same way you store anything else in a variable, the script call for that is in the pinned thread of script calls and should pop right up when you Google the question.
But what's your point of reference for the class ID? Whose class ID? A specific other actor? Is this a skill targeting a party member of the player's choice and you're using that actor's class?
Broadly speaking, you store a class ID the same way you store anything else in a variable, the script call for that is in the pinned thread of script calls and should pop right up when you Google the question.
But what's your point of reference for the class ID? Whose class ID? A specific other actor? Is this a skill targeting a party member of the player's choice and you're using that actor's class?
it's targeting a party member of the players choice. I'm not really in the clearest of headscpaces when facing multipe problems so i'm not the bets at explaining when i'm like that sorry. The other problem im facing is actually reverting back to the original class once the effect ends, but i cant figure out how to run a common event through a state, searches suggest its impossible, and plugins suggest yanfly but as an MZ dev thats not an option.
Okay i'll give a spacific explination of the skill
Party member 5 is the only one with access to the skill.
The variable checks what the target party members current class is and applies that class to party member 5
i needed this done by variables as i use a class changing system.
the skill is supposed to end after 4 turns or at the end of battle.
For flair i also wanted to change the actors battle image to the target actor but that may be a bit much considering i dont know how i would change it back, as i assume it wouldn't be able to do that automaticaly after the effect ends, especially not if i somehow do it without a state
Correct, you can't "run a common event through a state," you'd need to do this through code. Yanfly's plugins are written for MV, but there are MZ plugins which do the same things.
The direct port of Yanfly's plugins for MZ is done by VisuStella, but if you're not already using their products you can do this with my lighter weight Eval Tags plugin.
You would give the skill the notetag:
Code:
<Action Apply Eval>
user.origClass = user.currentClass().id;
user.changeClass(target.currentClass().id, true);
// Specify the ID of your state on this line
user.addState(69);
</Action Apply Eval>
Then, give the state the notetag:
Code:
<State Remove Eval>
user.changeClass(user.origClass, true);
delete user.origClass;
</State Remove Eval>
I am in fact using visustella plugins, though i cant find anything relating to common events in the skillstates core and i couldnt find out what other plugin would do the same thing. But i’ll try the one you suggested thank you
Does your plugin also allow the battler change or is that too far fetched?
That's not what I said - my plugin will not work correctly if you have VisuStella plugins in your project.
I'm really not sure what you're doing to confuse yourself - you seem to be going at right angles to everything I told you 😛
The VisuStella Battle Core has an entire section of the table of contents dedicated to Mechanics-Related notetags.
You would change what I wrote as Action Apply Eval to JS Post-Apply As User.
Similarly, the Skills and States Core has a section in their table of contents for state notetags, On Add/Erase/Expire.
So you would change what I wrote as State Remove Eval to JS On Erase State.
You can look up - again in the pinned thread of script calls, or via Google - the syntax to change the battler image and add that code in.
It also sounds like you're going for a full transformation state, and there are many tutorial articles and threads about how to do that. For example:
How to implement every possible Yanfly Tips & Tricks effect in MZ with VisuStella plugins
Hi all. This is by far one of the biggest topics I've seen people asking about, to the point where I've been commissioned twice to make an MZ project containing all of the T&T effects. So I figured I'd make a topic about how to implement them all yourselves. If no other plugins are specified...
forums.rpgmakerweb.com
I've had a look through the battle core and skillstates core again, both manually and using the find function on the term "common event" and i see nothing in either to add a common event to a state. as for the second part of your post. i am not experienced in any form of coding, so i just got really confused and lsot, i'm sorry
Just putting it out there, thats because that visustella plugin doesnt specifically add the ability to run a common event from a state. it allows you to run javascript in more places, and with that, you can you can use the engine's script calls to run a common event from a state. Theyre not going to list every little thing you can do with JS inside their documentation when you can do just about anything with JS. They'd just document what features the plugin itself adds
although if youre already using JS in a notetag and you know how to write the thing you want your common event to do, youre generally better off skipping the common event and doing the thing you want directly in the notetag, like as already shown with changing class
I think doing it through common event would be easier for my brain to handle. adding every single feature through JS sounds a bit crazy for my 0 experience brain. I wouldn't even know where to start consdiering i already have a list of 10 actorsd to choose from and with more to come. I guees i'll attempt to figure out how to run the event through javascript. thank you.
I suggest you try to un-fixate yourself on common events if you're trying to make the engine do things beyond what it's made to do.
The majority of plugins do not tie into common events, because the engine can't just run a common event whenever you want - there are specific times when they execute. So if you want something to happen outside of those timing windows, you use code.
I was confused because I already told you this, then you went back to talking about common events again.
You put this code in two places - the skill and the state. You are not required to do anything with a list of ten actors. You are not required to write any code yourself, you copy and paste.
What is so difficult?
Anyway, if that doesn't work for you, maybe someone else will be able to help with whatever method you're going for. Good luck with your project.
The majority of plugins do not tie into common events, because the engine can't just run a common event whenever you want - there are specific times when they execute. So if you want something to happen outside of those timing windows, you use code.
I was confused because I already told you this, then you went back to talking about common events again.
I just don't know what you're talking about. I gave you the code to do this above. I gave you a link to Trihan's thread which has code you copy and paste.
You put this code in two places - the skill and the state. You are not required to do anything with a list of ten actors. You are not required to write any code yourself, you copy and paste.
What is so difficult?
Anyway, if that doesn't work for you, maybe someone else will be able to help with whatever method you're going for. Good luck with your project.
I was under the impression your code only worked for one actor, i wouldnt know how to open a list for the player to choose what actor they want actor 5 to copy through notetags alone. Im so lost and confused and im sorry im so dumb i really want tk make this but i just cant figure out all this code stuff, and even the slightest adjustment to anything terrifies me cus i might end up messing this or that up with no clue how to fix it let alone how to make the code correctly, i’m really sorry.
as he already said, you dont have to adjust what he gave you to make it work. so long as the skill with that skill tag is used on any actor, and they get the associated state with that state tag in it, itll change the class and change it back.
Trihan already has what you need for the visual transformation typed out. all you have to do is copy it into the state and then change the file names and indices (highlighted in green and purple) for the ones your project uses
I’ve given it an attempt. I copy pasted the code, and replaced the notetags with the visustella ones as instructed, but nothing happened when using the skill
its best to show exactly what your skill/state looks like and provide the exact contents of their noteboxes so that no guessing games have to be played in figuring out what went wrong, but also just to make sure - you did save your project after putting the notetags in? changes to noteboxes and plugins arent saved to the game until you save the project
i see it now
dont use <JS Post-Apply as User>. its not meant for skills
use <JS Post-Apply> instead
dont use <JS Post-Apply as User>. its not meant for skills
use <JS Post-Apply> instead
Yep that seems to have fixed it, class changing works now. But i looked through the code att_turan left, the one about how to implement all yanfly tricks in visustella. and i'm not sure how to go about the visual transformation. i doubt it'd be easy to make actor 5 replace its own battler with taht of the selected actor rather than a set file.
i missed that point then. you need some small adjustments then.
add this somewhere inside the skill notetag:
Code:
user.transformTarget = target;
Code:
const charName = user.transformTarget._characterName;
const charIndex = user.transformTarget._characterIndex;
const faceName = user.transformTarget._faceName;
const faceIndex = user.transformTarget._faceIndex;
const battlerName = user.transformTarget._battlerName;
Original thread: https://forums.rpgmakerweb.com/threads/changing-classes-using-variables.170923/