If A Skill Has MP & TP Costs It Only Displays TP Cost

mobiusclimber

Veteran
Veteran
Joined
May 3, 2018
Messages
334
Reaction score
183
First Language
english
Primarily Uses
RMMV
Any way to get it to display both MP and TP cost? Both in the menu and in battle, it only shows TP.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
251
Reaction score
93
First Language
English
Primarily Uses
RMMZ
Is this vanilla MZ or you using some plugins=?
 

mobiusclimber

Veteran
Veteran
Joined
May 3, 2018
Messages
334
Reaction score
183
First Language
english
Primarily Uses
RMMV
I'm using some plugins but nothing that should affect this. I'm using Visustella Core & Message plugins, Galv Layer & Cam Control, and Community Lighting, plus a custom plugin Arthran made that randomizes the number of hits a skill does if you put code in the note field, but that isn't being used for the skill in question.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
251
Reaction score
93
First Language
English
Primarily Uses
RMMZ
Can you try to see if this happens without plugins too?
 

mobiusclimber

Veteran
Veteran
Joined
May 3, 2018
Messages
334
Reaction score
183
First Language
english
Primarily Uses
RMMV
Is it supposed to work that way? I mean, I'd have to make a whole new game in order to test it out since every map in my game requires at least the layers plugin to work. So I'm just wondering if you know that it's supposed to display both MP and SP or no before I go thru the trouble.
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
511
Reaction score
490
First Language
English
Primarily Uses
RMMZ
I tossed together a plugin for this. Try it out and let me know how it works for you:

JavaScript:
Window_SkillList.prototype.costWidth = function() {
    return this.textWidth('000000  ' + TextManager.tpA + TextManager.mpA);
};

Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
    const partialSpaceWidth = Math.floor(this.textWidth(' ') / 3);

    if (this._actor.skillTpCost(skill) > 0) {
        const tpValText = this._actor.skillTpCost(skill);
        const tpValWidth = this.textWidth(tpValText);
        const tpAWidth = this.textWidth(TextManager.tpA);
        var tpWidth = tpValWidth + partialSpaceWidth + tpAWidth;
        const tpValX = x + width - tpWidth;
        const tpAX = x + width - tpAWidth;
        this.changeTextColor(ColorManager.tpCostColor());
        this.drawText(tpValText, tpValX, y, tpValWidth);
        this.drawText(TextManager.tpA, tpAX, y, tpAWidth);
    }

    if (this._actor.skillMpCost(skill) > 0) {
        const mpValText = this._actor.skillMpCost(skill);
        const mpValWidth = this.textWidth(mpValText);
        const mpAWidth = this.textWidth(TextManager.mpA);
        const mpWidth = mpValWidth + partialSpaceWidth + mpAWidth;
        const mpOffset = tpWidth ? tpWidth + this.textWidth(' ') : 0;
        const mpValX = x + width - mpWidth - mpOffset;
        const mpAX = x + width - mpAWidth - mpOffset;
        this.changeTextColor(ColorManager.mpCostColor());
        this.drawText(mpValText, mpValX, y, mpValWidth);
        this.drawText(TextManager.mpA, mpAX, y, mpAWidth);
    }
};
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
511
Reaction score
490
First Language
English
Primarily Uses
RMMZ
Thanks, buddy, I'll test it out! Really appreciate it!
No problem!

*edit*
I noticed that the game in your screenshots is not at a widescreen aspect ratio. As a result, that game has a little less space for skill names than my test game did, and I didn't consider that possibility when I wrote that code. If you wind up with any issues regarding long skill names getting cut off, you might try this code instead:
JavaScript:
Window_SkillList.prototype.drawItem = function(index) {
    const skill = this.itemAt(index);
    if (skill) {
        const costWidth = this.costWidth(skill);
        const rect = this.itemLineRect(index);
        this.changePaintOpacity(this.isEnabled(skill));
        this.drawItemName(skill, rect.x, rect.y, rect.width - costWidth);
        this.drawSkillCost(skill, rect.x, rect.y, rect.width);
        this.changePaintOpacity(1);
    }
};

Window_SkillList.prototype.costWidth = function(skill) {
    let value = 0;
    if (this._actor.skillTpCost(skill) > 0) {
        value += this.textWidth(this._actor.skillTpCost(skill) + TextManager.tpA);
    }
    if (this._actor.skillMpCost(skill) > 0) {
        if (value > 0) {
            value += this.textWidth(' ');
        }
        value += this.textWidth(this._actor.skillMpCost(skill) + TextManager.mpA);
    }
    value += this.textWidth(' ');
    return value;
};

Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
    const partialSpaceWidth = Math.floor(this.textWidth(' ') / 3);

    if (this._actor.skillTpCost(skill) > 0) {
        const tpValText = this._actor.skillTpCost(skill);
        const tpValWidth = this.textWidth(tpValText);
        const tpAWidth = this.textWidth(TextManager.tpA);
        var tpWidth = tpValWidth + partialSpaceWidth + tpAWidth;
        const tpValX = x + width - tpWidth;
        const tpAX = x + width - tpAWidth;
        this.changeTextColor(ColorManager.tpCostColor());
        this.drawText(tpValText, tpValX, y, tpValWidth);
        this.drawText(TextManager.tpA, tpAX, y, tpAWidth);
    }

    if (this._actor.skillMpCost(skill) > 0) {
        const mpValText = this._actor.skillMpCost(skill);
        const mpValWidth = this.textWidth(mpValText);
        const mpAWidth = this.textWidth(TextManager.mpA);
        const mpWidth = mpValWidth + partialSpaceWidth + mpAWidth;
        const mpOffset = tpWidth ? tpWidth + this.textWidth(' ') : 0;
        const mpValX = x + width - mpWidth - mpOffset;
        const mpAX = x + width - mpAWidth - mpOffset;
        this.changeTextColor(ColorManager.mpCostColor());
        this.drawText(mpValText, mpValX, y, mpValWidth);
        this.drawText(TextManager.mpA, mpAX, y, mpAWidth);
    }
};

This isn't a vital thing, or anything like that. But the original code was reserving space for a 3 digit TP cost + a 3 digit MP cost for each skill, whereas the new code will only reserve exactly how much space it needs to display the cost. I had judged that the original method was fine, because on my test game, it still left plenty of space for a lengthy skill name, so I figured I'd save a bit on performance and just go ahead and reserve space for the maximum possible cost. But after seeing your screenshots, I'm not sure if that's actually a safe trade-off on a lower resolution game, so if your game is at default MZ resolution (or lower), then you might consider switching to this new code instead.
 
Last edited:

mobiusclimber

Veteran
Veteran
Joined
May 3, 2018
Messages
334
Reaction score
183
First Language
english
Primarily Uses
RMMV
Thanks, I'll use the new code! I tend to have long skill names, but single or double digit costs (I like to stick to low numbers for everything).
 

Latest Threads

Latest Posts

Latest Profile Posts

huge_melusine_face.png

If anyone sees this, I would love some feedback on this art for a villain in my game.
Coin Locker title screen:
Still in progress...

Screenshot_134.png
the girls.png
So, these are all the girls of the party =3 (beside the protagonist if you play as a female.)
Now, I just have one more character sheet of the guys left and I'm done with their presentations =3
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?

Forum statistics

Threads
124,443
Messages
1,163,691
Members
163,257
Latest member
ThePrussianDuck
Top