Soryuju

Combat Balance Enthusiast
Veteran
Joined
Apr 19, 2018
Messages
179
Reaction score
217
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,164
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
217
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
406
Reaction score
231
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,164
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.
 

SarcasticSloth

Villager
Member
Joined
Jul 11, 2018
Messages
15
Reaction score
2
First Language
English
Primarily Uses
RMMV
Edit: I was able to figure this out. I made script to check an actor's subclass and I'll add it below.


I realize I'm trying to revive a dead thread, but I just wanted to follow up on this. I have some javascript skill, but I'm still not certain how I would use the code. I want to check to see what subclass an actor has and store it in a game variable. So I assume it would,be something like $gameVariable.setValue(x, Actor._subclassId)

Code:
Code:
Game_Actor.prototype.subclass = function() {
    if (this._subclassId === undefined) this.initSubclasses();
    return $dataClasses[this._subclassId];
};
 
Last edited:

Latest Threads

Latest Profile Posts

Can you recognize where this area is from? :kaocry:
Mq9QM3h.png
For those with up to 9 elements of magic; how do you structure your database. By element? Or by what is offensive vs supportive spells?
would anyone here be interested in rough concept art for the main protagonist of my game that might get changed later? :kaoswt2:
I guess I have no idea how to properly upload a custom font lmao. The menu fonts are too damn small.

Font_Size.PNG

Forum statistics

Threads
124,437
Messages
1,163,650
Members
163,254
Latest member
debet99net
Top