YEP_ClassChangeCore sealing class change on a per actor basis

Discussion in 'Javascript/Plugin Support' started by ramza, Apr 27, 2018.

Thread Status:
Not open for further replies.
  1. ramza

    ramza Lunatic Coder Veteran

    Messages:
    541
    Likes Received:
    296
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Good evening folks.

    I was messing around with my project a bit this morning, specifically with the YEP_ClassChangeCore plugin, and discovered an unfortunate bug.

    Steps to reproduce:
    • Unlock several classes for one or more actors, either by plugin command, or by using the event command to change classes.
    • Use the plugin command DisablePrimaryClassChange n where 'n' is the actor ID of the above actor.
    • Note that this actor can still change classes in the class change menu, despite the help information indicating otherwise.
    • The actor._canChangeClass value is updated to 'false' from undefined, as expected, but the menu doesn't seem to check this value before allowing a class change in the scene.
    I don't know about how menu scene work to quickly figure this out on my own, so I'm hoping someone else maybe already fixed this problem and is willing to share it, or knows how to fix it quickly.

    Thanks in advance.
     
    #1
  2. Luckysince97

    Luckysince97 Veteran Veteran

    Messages:
    49
    Likes Received:
    18
    Location:
    Canada, Quebec, Montreal
    First Language:
    French
    Primarily Uses:
    RMMV
    First thing first, did you update , yanfly change some thing in it core for 1.6.1. update, so it migth be a good thing to check what version of classchangecore you have, here the link to the changelog dont forget to change the yep core itself...http://yanfly.moe/yep/changelog/
     
    #2
  3. ramza

    ramza Lunatic Coder Veteran

    Messages:
    541
    Likes Received:
    296
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    I am using the latest version of all Yanfly plugins.

    Your query actually made me remember that I'm also using a plugin I made myself for auto-optimizing equipment when class changing which does override the default onItemOk bind of the class change core. I looked into it further though, and this isn't the problem.

    I did find what the problem was though, and I will share it, just in case anyone else has the same issue down the road and finds this in a google search or something.

    The problem is that the function Game_Actor.prototype.canChangeClass() is designed to overwrite the _canChangeClass value on the party member with whatever the default value on $GameParty.members()[x].actor() is. The way the function was scripted, it was designed to check if the _canChangeClass value existed in an if statement, but that statement will return false if the value is undefined, or if it is false, causing it to return the default actor value of true instead. I modified the function to be more specific. It will now retain a false value if you have used the plugin command to disable class change for an actor, causing the class change scene to correctly grey-out the ability to change primary classes.

    Code:
    Game_Actor.prototype.canChangeClass = function() {
        if (this._canChangeClass != undefined) {
            return this._canChangeClass;
        } else {
            this._canChangeClass = this.actor().canChangeClass;
            return this._canChangeClass;
        }
    };
     
    #3
  4. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,797
    Likes Received:
    7,616
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #4
Thread Status:
Not open for further replies.

Share This Page