Yanfly Class System SubClass Conditional branch check Crash

Hi!

As the title says, i'm trying to run a conditional branch check, with Yanfly's Class System subclass, and it works just when the check returns true, if it's false, it'll always crash my game.
What i want to archive is, change the actor's graphic based on the current class or subclass at the start of the battle so, i need to be able to check for both options, true or false to make the said change.

This is one of the script calls i'm trying to use:

Ruby:
$game_actors[2].subclass.id == 29

And the script can be grabbed here:

Yanfly Class System

There's any solution to this problem?
Moved to: RGSSx Script Support

Does it give you an error message when it crashes? Telling us what that is will probably be helpful.

$game_actors[2] refers to the 3rd actor (2nd follower). Do you have 3 party members? Does your 3rd party member HAVE a subclass?

Without having any more info, I'd say try changing it to this:
Code:
$game_actors[2].subclass && $game_actors[2].subclass.id == 29

so it only checks the id if they HAVE a subclass.
Thanks @Shaz you're amazing!!

This line of code, that you provided did the trick, but for some reason, the $game_actors[2] returns the data from the second actor in my database, and $game_actors[1] from the first, i just use two actors in most parts of my game and it is working this way so far, maybe i misunderstood you?

But anyway, my problem has been solved, thread can be closed now.
For the second party member it should read:

Ruby:
actor = $game_party.actors[1]

Then you can use just actor as a variable, like a substitute for the whole $game_party.actors[2] piece of code to perform the rest of the tasks.
For the second party member it should read:

Ruby:
actor = $game_party.actors[1]

Then you can use just actor as a variable, like a substitute for the whole $game_party.actors[2] piece of code to perform the rest of the tasks.

This is really meant to be used with RGSS3? Cause looks like it doesn't works here and more like some RMMV stuff, but thanks for trying to help in make things easier, i appreciate that.

1662861237099.png
Cause looks like it doesn't works here and more like some RMMV stuff,
Then that's you're issue, if you have this script in your plugin list, then remove it and add in the correct one.
This thread is RGSS script support forum not MV.
The MV commands for Yanfly's MV plugin is different
Replace $game_party.actors with $game_party.members because in ACE the actors array consists of ID's instead of actual heroes. The members method transforms the ID's into actual party members.
This thread is RGSS script support forum not MV.

I believe the OP is using VX Ace as the script they linked to is an Ace script. The command worked when the actor DID have the subclass, just not when they didn't. If it was a case of an Ace script in an MV project, I'd expect it to crash every time. And when they used my altered (Ace) script call, it stopped crashing.

@Arkhanis can you please confirm what engine you are using? It is a little confusing, as your profile says you mainly use MV.
Then that's you're issue, if you have this script in your plugin list, then remove it and add in the correct one.
This thread is RGSS script support forum not MV.
The MV commands for Yanfly's MV plugin is different
Ohh i guess you got me wrong here, maybe my spelling? Just to clarify, my issue has already been solved by Shaz's fist post as i stated some comments above, that said, i also tried what Kyonides shared, just to see if it could make it easier with smaller script calls, but the method actors, as the picture i provided shows, doesn't seems to exists or either have some incompatibility with other scripts i dunno, whatever's the case, this game of mines is an RPG Maker VX Ace one, i just said that the line of code $game_party.actors[1], make it equals to a variable named actor(as he suggested to make things easier) is not working for me, hope I've made it a bit more clear. But anyways, things are all good and solved, thanks everyone for the support.
I believe the OP is using VX Ace as the script they linked to is an Ace script. The command worked when the actor DID have the subclass, just not when they didn't. If it was a case of an Ace script in an MV project, I'd expect it to crash every time. And when they used my altered (Ace) script call, it stopped crashing.

@Arkhanis can you please confirm what engine you are using? It is a little confusing, as your profile says you mainly use MV.
I guess he just misunderstood my words, sorry if if my spelling or the overall logic of the sentences are not comprehensible. But problem has been solved.
$game_party.actors is a private variable. It has no attr_reader defined, so you cannot use it for script calls by default.

$game_party.members is the array I was thinking of, where the party leader is 0, the first follower is 1, etc. This contains your actors in the order they were added to the party.

$game_actors gives you an array of all actors, where the index is the actor id, and $game_actors[0] is null. This will give you any actor you ask for, even if they've never been added to the party.


Thread closed

(next time you're done with a topic, please report it for it to be closed, as mods won't always see a comment in a post)

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-class-system-subclass-conditional-branch-check-crash.151189/