How to check an actor’s subclass?

Soryuju

Combat Balance Enthusiast
Veteran
Joined
Apr 19, 2018
Messages
179
Reaction score
213
First Language
English
Primarily Uses
RMMV
I’ve got actors who have selectable main classes and subclasses in my project, and I’m trying to figure out how to check an actor’s current subclass so I can use the subclass ID as a condition for various events, evals, etc.

I’ve seen the script call below recommended elsewhere to accomplish this, but every time I use it, I get errors as soon as the script is called:

a.subclass().id === x

Where x is the subclass ID. So for example, I tried something like this with Yanfly’s Auto Passive States plugin:

<Custom Passive Condition>
if (user.subclass().id === 1) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>

The above code (written in the State notebox) caused the game to immediately crash when an actor who had both the passive state and the designated subclass went into battle.

I also get errors when trying to use the code in battle events with this format:

$gameActors.actor(x).subclass().id === y

Where x is the actor ID and y is the subclass ID. The consistent errors lead me to believe there’s something fundamentally wrong with the way I’m using the script call, rather than the specific events or plugins I’m trying to use it with.

Can anyone give me some insight into where I’m going wrong? Thanks!
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Actors don't have subclasses in default RMMV so if you're using a plugin you should say which one and provide a link.
 

Soryuju

Combat Balance Enthusiast
Veteran
Joined
Apr 19, 2018
Messages
179
Reaction score
213
First Language
English
Primarily Uses
RMMV
It’s Yanfly’s Subclass plugin, sorry (http://yanfly.moe/2015/11/29/yep-34-subclass/).

Yanfly’s Class Change Core and Subclass plugins don’t list any JS functions in their help files, so the script call I described above is all I have to go on. It was mentioned in a few older threads I found about Yanfly’s Subclass plugin, but I haven’t been able to get it working properly.
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
399
Reaction score
221
First Language
English
Primarily Uses
RMMV
I'm not using Yanfly's Auto Passive States but I'm using a similar script to evaluate whether skills are available based on the actors subclass.

<Custom Show Eval>

if (user.subclass() !== null) {

if (user.subclass().id === 6) {

visible = true;

} else {

visible = false;

}

} else {

visible = false;

}

</Custom Show Eval>

The only difference is I have the statement nested to prevent errors in the console when the character isn't using a subclass (it ends up displaying the skill if no subclass is selected without this), so I'm inclined to say the issue might not be with your script.

I've tried running your second code as well and it appears to evaluate fine, again only throwing errors when there is no subclass selected.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Here's the definition of the subclass() method:
Code:
Game_Actor.prototype.subclass = function() {
    if (this._subclassId === undefined) this.initSubclasses();
    return $dataClasses[this._subclassId];
};
So you'd be able to use the actor property _subclassId directly also.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top