Class Change: Check if (sub)class is already unlocked

Discussion in 'RPG Maker MV' started by jjleroy, Aug 29, 2017.

  1. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Hi guys, I hope you are all enjoying your summer.

    I am using Yanflys Class Change Core to have my lead actor have multiple classes to choosefrom. Every class has its own level.

    If I set the variable to Script: $gameParty.leader().level, I get the level of the class which is currently activated.

    However, is there a way to save the current level of an inactive class of the same actor into a variable?
     
    #1
  2. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Oh, nevermind. It seems it was $gameParty.leader().classLevel(id).
     
    #2
  3. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    You can use
    Code:
    $gameActors.actor(ID).classLevel(CLASS_ID)
    EDIT: Oh, you figured it out yourself already.
     
    #3
    jjleroy likes this.
  4. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Thank you anyways!

    Now I'm stuck with another thing: I would like to check with a "Conditional Branch" Event whether actor 1 has already unlocked subclass x.
    How can I do that?
     
    #4
  5. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Try
    PHP:
    $gameActors.actor(ID)._unlockedClasses.contains(CLASS_ID)
     
    #5
    jjleroy likes this.
  6. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Thank you so much!

    And one final issue:
    How can I use a script to change a certain subclasses' level?
     
    Last edited: Sep 3, 2017
    #6
  7. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @jjleroy
    To get the name you have to use $dataClasses.
    So to get the name of class 16, you do
    Code:
    $dataClasses[16].name
     
    #7
    jjleroy likes this.
  8. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Thank you so much.
    Is there also a way to show the class' icon in the text?
     
    #8
  9. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    To get the icon you use
    Code:
    $dataClasses[ID].iconIndex
    You would have to store that into a variable and then you use
    Code:
    \i[\v[VARIABLE_ID]]
    inside the text box.
     
    #9
    jjleroy likes this.
  10. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    It works!!!! Great!!! Thank you 1000000000000000000 times!!!!

    So now the very last thing I need, would be a script to uplevel a subclass.

    I was trying to set class ID 16, to level 14, by using a script call:

    $gameVariables.setValue($gameActors.actor(1).classLevel(16), 14);

    But nothing happened....
     
    #10
  11. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    To level up an actor, you can use
    Code:
    actor.levelUp(); // actor refers to an actual actor object, so $gameActors.actor(ID) e. g.
    That would raise his level for that class, I think.
     
    #11
    jjleroy likes this.
  12. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    But is there a way to level up a subclass that's not currently activated? I would like to set an initial level whenever a new class is unlocked.

    Could it have something to do with this?

    Yanfly.Subclass.Game_Actor_gainExp = Game_Actor.prototype.gainExp;
    Game_Actor.prototype.gainExp = function(exp) {
    this.gainExpSubclass(exp);
    Yanfly.Subclass.Game_Actor_gainExp.call(this, exp);
    };

    Game_Actor.prototype.gainExpSubclass = function(exp) {
    if (!this.subclass()) return;
    exp *= Yanfly.Param.SubclassExp;
    var curExp = this._exp[this._subclassId] || 0;
    var newExp = curExp + Math.round(exp * this.finalExpRate());
    this._exp[this._subclassId] = Math.max(newExp, 0);
    };
     
    #12
  13. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    So it seems the experience is saved in $gameActors.actor(1)._exp[1]. This is the experience for class 1.

    But how can I set this value = a number, like 10?
     
    #13
  14. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Try $gameActors.actor(1)._exp[1] = 10;
     
    #14
    jjleroy likes this.
  15. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    YES!!!!!!!!! It works!!!!!!!! Awesome. Amazing!

    Is there also a way to do the same just with the class' level?
     
    #15
  16. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Maybe something in here?


    Game_Actor.prototype.subclassParamBase = function(paramId) {
    if (!this.subclass()) return 0;
    var rate = Yanfly.Subclass.Param[paramId];
    if (!rate) return 0;
    if (this.subclass().baseParamFormula) {
    var formula = this.subclass().baseParamFormula[paramId];
    if (formula !== '') {
    return this.classBaseParamFormula(formula, paramId) * rate;
    }
    }
    var level = this.classLevel(this._subclassId);
    if (level > 99) {
    var i = this.subclass().params[paramId][99];
    var j = this.subclass().params[paramId][98];
    i += (i - j) * (level - 99);
    var value = i;
    } else {
    var value = this.subclass().params[paramId][level];
    }
    return value * rate;
    };
     
    #16
  17. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Nah, that's just for the base parameters.

    Does this not work?
    $gameActors.actor(ACTOR_ID)._exp[CLASS_ID] = 10;
     
    #17
  18. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    Yes that one works!!! However I would need another one so I can set the level directly instead of the exp...
     
    #18
  19. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    589
    Likes Received:
    458
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    $gameActors.actor(ACTOR_ID).changeLevel(x);
     
    #19
    jjleroy likes this.
  20. jjleroy

    jjleroy I love bananas Veteran

    Messages:
    101
    Likes Received:
    21
    Location:
    Germany
    First Language:
    German, English
    Primarily Uses:
    RMMV
    It works, but not for the subclasses unfortunately, but I will find a way around it using the experience.
    Thank you so much for your help!!! How can I ever thank you for this!
     
    #20

Share This Page