Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
773
Reaction score
276
First Language
English
Primarily Uses
RMMV
Hello!

Would someone be able to help me create a plugin to adjust an odd default behavior of how MV lists skills?

By default, the order in which skills are listed (such as in battle) has the skills listed by database ID order. However, if an actor gains access to a skill through an equipment, that skills will always be listed at the bottom of the list, regardless of it's database ID.

Ideally, I'd like all skills regardless of how they are learned to be listed by database ID.

Let me know if you have any questions.

Thank you!
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,843
Reaction score
9,236
First Language
Indonesian
Primarily Uses
N/A
I don't know about MV code, but this is written in MZ and I would assume the same in MV.
JavaScript:
Game_Actor.prototype.skills = function() {
    const list = [];
    for (const id of this._skills.concat(this.addedSkills())) {
        if (!list.includes($dataSkills[id])) {
            list.push($dataSkills[id]);
        }
    }
    return list;
};
Which makes sense why it behaves that way (the added skill from trait is added later to the list)
The solution should be as simple as just adding a sort function after that. Save this as a new plugin.
JavaScript:
(() => {
    actorSkills = Game_Actor.prototype.skills
    Game_Actor.prototype.skills = function(){
        return actorSkills.call(this).sort((a,b) => { return a.id - b.id })
    }
})()
I haven't tested it yet, but the solution shouldn't be too far from this.
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
773
Reaction score
276
First Language
English
Primarily Uses
RMMV
I don't know about MV code, but this is written in MZ and I would assume the same in MV.
Tested it out in MV, and it seems to be working great! Thank you very much!
 

Latest Threads

Latest Posts

Latest Profile Posts

A shotgun is not a rifle. Huh.
SIGH its so hard to convince my friend that making a game for fun and making one to sell takes different planning. I don't care about weird bothersome ways of doing things in a game made for fun, but when you are planning to market it, there is some stuff that you just have to streamline or cut out.
It might be a little bit boring and tedious, but building that database of armor, items, weapons and skills are super important.
More words of wisdom: Trying to make everyone happy will just make you miserable.

Forum statistics

Threads
124,384
Messages
1,163,261
Members
163,184
Latest member
282065
Top