MV [Resolved] Experience bar to show up during battle (RMMV and RMMZ version)

Hello, fellow RPG makers! I'm looking for script (or a plugin) that would add an Experience bar to the battle menu that would/could replace the TP bar (I don't use it at all). I'm not picky about color or details like that as I'm good enough at Javascript and css to change that type of thing myself. Thank you in advance!



Edit: Here is the completed RMMV plugin with compatibility with Yanfly plugins (MZ version can be found below):

Spoiler: Plugin Script
Code:
/*:
@plugindesc Turns the TP bar into an EXP bar. Only use if you're not going to use the TP system at all.
@author Drakkonis
*/

var Imported = Imported || {};
Imported.Drak_TPX = true;
var TPX = TPX || {};
TPX.Parameters = PluginManager.parameters('Drak_TPX');
TPX.mode = "Percentage";

const battler_refresh = Game_BattlerBase.prototype.refresh;
Game_BattlerBase.prototype.refresh = function() {
    battler_refresh.call(this);
    if (this.isActor()) {
        this._tp = Math.round(((this.currentExp() - this.currentLevelExp()) /
                              (this.nextLevelExp() - this.currentLevelExp())) * 100);
    }
};

Game_Actor.prototype.maxTp = function() {
    return 100;
};

Game_BattlerBase.prototype.isPreserveTp = function() {
    return true;
};

// Modify Window_BattleStatus to display EXP%
Window_BattleStatus.prototype.drawActorTp = function(actor, x, y, width) {
    width = width || 96;
    const color1 = this.tpGaugeColor1();
    const color2 = this.tpGaugeColor2();
    const expRate = (actor.currentExp() - actor.currentLevelExp()) /
                    (actor.nextLevelExp() - actor.currentLevelExp());

    this.drawGauge(x, y, width, expRate, color1, color2);
  
    this.changeTextColor(this.systemColor());
    this.drawText(TextManager.tpA, x, y, 44);
  
    this.changeTextColor(this.tpColor(actor));
    this.drawText(actor.tp + "%", x + width - 64, y, 64, "right");
};
I'm on it. Should the number of TP be removed, or be replaced by a value?
You could set max TP to an actor's xp needed for level and always have the TP amount set to experience. If TP isn't used at all, even with enemies, then all you should need to do is change every actor's TP rate to 0, change the maxTp function to return the xp they need instead of 100, and in the battler's update function, set TP equal to the actor's current xp. The first thing can be done in the editor, the other two would need to be either put in a plugin or modified in the base code. Both functions to modify would be in either Game_Battler or Game_BattlerBase.
I'm on it. Should the number of TP be removed, or be replaced by a value?
Hello! Either complete removal of TP or replacing the TP bar with exp would work! I'm also looking into the suggestion from Drakkonis.

You could set max TP to an actor's xp needed for level and always have the TP amount set to experience. If TP isn't used at all, even with enemies, then all you should need to do is change every actor's TP rate to 0, change the maxTp function to return the xp they need instead of 100, and in the battler's update function, set TP equal to the actor's current xp. The first thing can be done in the editor, the other two would need to be either put in a plugin or modified in the base code. Both functions to modify would be in either Game_Battler or Game_BattlerBase.

Could you walk me through the second part, or direct me to a video/tutorial that does this? Thank you already, though!
JavaScript:
/*:
@plugindesc Turns the TP bar into an EXP bar. Only use if you're not going to use the TP system at all.
@author Drakkonis

@param dispMode
@type select
@option Current EXP
@option Percentage
@text TP Guage Display
@desc Do you want the gauge to display the EXP amount, or a percentage towards the next level?
@default Current EXP
*/

var Imported = Imported || {};
Imported.Drak_TPX = true;
var TPX = TPX || {};
TPX.Parameters = PluginManager.parameters('Drak_TPX');
TPX.mode = TPX.Parameters['dispMode'];

const battler_refresh = Game_BattlerBase.prototype.refresh; //alias the original function, so we can call the original version

Game_BattlerBase.prototype.refresh = function() {
    battler_refresh.call(this); //call the aliased (original) version of this function, since we're adding to it, not replacing it
    if (this.isActor()) {
        if (TPX.mode == "Current EXP") {
            this._tp = this.currentExp();
        } else if (TPX.mode == "Percentage") {
            this._tp = Math.round((this.currentExp() / this.nextLevelExp()) * 100);
        };
    };
};

Game_Actor.prototype.maxTp = function() {
    if (TPX.mode == "Current EXP") {
        return this.nextLevelExp();
    } else return 100;
    
};

Game_BattlerBase.prototype.isPreserveTp = function() { //allows you to see the right amount of xp outside of battle
    return true;
};

I wasn't sure how you wanted it displayed, with either the exact XP numbers or a percentage, so I set up a parameter so you can choose. If I knew in advance, the code would be simpler, but this version could have a wider audience.

Just copy the code into a text file, name the file Drak_TPX.js, and stick it in your plugin folder like any other plugin. Set the parameter to how you want the gauge to display and you should be good to go. If you test with a save already in progress, it won't update until the first time the actors refresh, like when hp/mp changes, or at the start of a battle.

Side note, it's set up to where you don't need to change actor TP rates, since this sets the TP automatically, so any changes to it are reset to the xp values when it refreshes. I recommend changing the system text for TP to something like XP, though.

I made sure to put in comments to explain what everything was for, in case you wanted to peek under the hood. Might not help you if you wanted to make your own plugins, but it should at least tell you what something does.

If you have any problems, let me know. I use MZ, and don't have access to MV, but this SHOULD work in MV just as well as it does in MZ.

Apologies to CHKNRAVE for essentially hijacking the response. Didn't mean to steal your thunder. Got excited about a request that was actually in my ability to fulfill.
Apologies to CHKNRAVE for essentially hijacking the response. Didn't mean to steal your thunder. Got excited about a request that was actually in my ability to fulfill.
I wouldn't have executed it better, no worries.
Apologies to CHKNRAVE for essentially hijacking the response. Didn't mean to steal your thunder. Got excited about a request that was actually in my ability to fulfill.
Thank you so much! This turned out really great!!
What are your terms of use? Are you fine with me using it in a commercial game?
One little fix, if possible: how do I add '%' at the end of the return statement when percent display is active?
Screenshot:
Spoiler
1617029793327.png

For anyone looking to use it, a couple of notes:
(as mentioned) make sure to change the name of TP to something more appropriate (I used 'Exp').
Also, make sure you go in System and check the "display TP in Battle" button to use.
Thank you so much! This turned out really great!!
What are your terms of use? Are you fine with me using it in a commercial game?
One little fix, if possible: how do I add '%' at the end of the return statement when percent display is active?
Screenshot:

For anyone looking to use it, a couple of notes:
(as mentioned) make sure to change the name of TP to something more appropriate (I used 'Exp').
Also, make sure you go in System and check the "display TP in Battle" button to use.
That's handled in a different section I've not messed with before, where the text is actually drawn. I'll try to track it down. The percentage mode doesn't feel right without it. Might take a bit, the graphical stuff is never my strong point and the engine likes to bounce around a lot, making it difficult to track down EXACTLY what I need without screwing something ELSE up.

Thank you so much! This turned out really great!!
What are your terms of use? Are you fine with me using it in a commercial game?
One little fix, if possible: how do I add '%' at the end of the return statement when percent display is active?
Screenshot:

For anyone looking to use it, a couple of notes:
(as mentioned) make sure to change the name of TP to something more appropriate (I used 'Exp').
Also, make sure you go in System and check the "display TP in Battle" button to use.
Got it. Stick the following in the plugin, after everything else(or anywhere between functions, really. I stuck it at the end for convenience):
JavaScript:
Sprite_Gauge.prototype.drawValue = function() {
    var val = this.currentValue();
    if (this._battler && this._statusType == "tp" && TPX.mode == "Percentage") {
        val += "%";
    };

    const currentValue = val;
    const width = this.bitmapWidth();
    const height = this.bitmapHeight();
    this.setupValueFont();
    this.bitmap.drawText(currentValue, 0, 0, width, height, "right");
};

I'm fine with it being used in commercial games. With my skill level, anyone that dives into making plugins can make what I do easily. Credit me if you want, but it's a tiny basic plugin so I don't really care if you don't. Glad you like it though!
Hello fellow game-makers,
I took a somewhat long break from working on anything related to this plugin, and have decided to come back to it. I see that the original author, Drakkonis, has not been online in over 2 years, and was hoping someone would be willing to pick it up. It has 2 small problems:
1. The percent experience is based on total values rather than the percent for the individual level.
2. The % symbol does not show on the bar.
Spoiler: Example picture
1742268240788.png
2. The % symbol does not show on the bar.
did you change the plugin parameter to "Percentage"? the % should have shown up if you did.

1. The percent experience is based on total values rather than the percent for the individual level.
even if you did have the parameter to "Percentage", the exp percentage would be based on the percentage of total exp gained and the total exp for the next level, which would mean itd never be empty after lv 1 and would practically always be full later on.

replace the line
this._tp = Math.round((this.currentExp() / this.nextLevelExp()) * 100);
with
Code:
this._tp = Math.round(((this.currentExp()-this.currentLevelExp()) / (this.nextLevelExp()-this.currentLevelExp())) * 100);
did you change the plugin parameter to "Percentage"? the % should have shown up if you did.


even if you did have the parameter to "Percentage", the exp percentage would be based on the percentage of total exp gained and the total exp for the next level, which would mean itd never be empty after lv 1 and would practically always be full later on.

replace the line

with
Code:
this._tp = Math.round(((this.currentExp()-this.currentLevelExp()) / (this.nextLevelExp()-this.currentLevelExp())) * 100);
Yes, I did change it to percentage.
Spoiler: Parameters
1742308762634.png

The line replacement worked perfectly, thank you!
So now, it's just the concatenation with the % symbol to fix it.
So now, it's just the concatenation with the % symbol to fix it.
did you name the plugin file 'Drak_TPX.js'? if you didnt, then the parameter wont be read properly
did you name the plugin file 'Drak_TPX.js'? if you didnt, then the parameter wont be read properly
Yes. =]
i tried it myself and it works just fine. the only alteration made was changing the one line for the exp to not be total
1742333638254.png

1742333798225.png


you havent shown any screenshots but if you are sure that its set up correctly, then we can just sidestep the parameter.
change
Code:
TPX.mode = TPX.Parameters['dispMode'];
to
Code:
TPX.mode = "Percentage";
i tried it myself and it works just fine. the only alteration made was changing the one line for the exp to not be total
View attachment 334907
View attachment 334908

you havent shown any screenshots but if you are sure that its set up correctly, then we can just sidestep the parameter.
change
Code:
TPX.mode = TPX.Parameters['dispMode'];
to
Code:
TPX.mode = "Percentage";
I did share screenshots, I just put them in the spoiler. =]
I changed this code and it didn't help, so I have a feeling there's another plugin being mean. I've put it on the bottom of the list, and that didn't help.
Are you testing in MZ? I am using MV.
Edit: I figured out the problem... "Sprite_Gauge..." is an RMMZ var/call/whatever, and I just need to figure out the RMMV equivalent.
I did share screenshots, I just put them in the spoiler. =]
oops 🤣
i looked at it to see the parameter and didnt look at the name. my b

Are you testing in MZ? I am using MV.
yeah, i tested it in mz. that'd do it. i didnt notice your and drakkonis' preferred engines were different.

replace the addition made in post #8 with
Code:
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
  width = width || 96;
  var color1 = this.tpGaugeColor1();
  var color2 = this.tpGaugeColor2();
  this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
  this.changeTextColor(this.systemColor());
  this.drawText(TextManager.tpA, x, y, 44);
  this.changeTextColor(this.tpColor(actor));
  this.drawText(actor.tp+"%", x + width - 64, y, 64, 'right');
};

depending on what plugins you have some additional menus might not change
oops 🤣
i looked at it to see the parameter and didnt look at the name. my b


yeah, i tested it in mz. that'd do it. i didnt notice your and drakkonis' preferred engines were different.

replace the addition made in post #8 with
Code:
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
  width = width || 96;
  var color1 = this.tpGaugeColor1();
  var color2 = this.tpGaugeColor2();
  this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
  this.changeTextColor(this.systemColor());
  this.drawText(TextManager.tpA, x, y, 44);
  this.changeTextColor(this.tpColor(actor));
  this.drawText(actor.tp+"%", x + width - 64, y, 64, 'right');
};

depending on what plugins you have some additional menus might not change
Thank you so much for your help. I ended up completing the script before you replied and the result is in the first post, but had you not come to help, I would've taken ages to find that this was written for MZ. 👋
This thread is closed due to being reported as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/resolved-experience-bar-to-show-up-during-battle-rmmv-and-rmmz-version.134816/