Adding HIT and CRIT to the status window

Hello everbody,

as described in the title id like to add the stats CRIT and HIT to the Status window.
Right now the window looks like this:


qdCm9B7


I added a pugin to show only the stats i want to be shown:

Spoiler
Window_Status.prototype.drawParameters = function(x, y) {
var lineHeight = this.lineHeight();
var paramsToDraw = [ 2, 4, 6, 3];
for (var i = 0; i < paramsToDraw.length; i++) {
var y2 = y + lineHeight * i;
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramsToDraw), x, y2, 160);
this.resetTextColor();
this.drawText(this._actor.param(paramsToDraw), x + 160, y2, 60, 'right');
}
};

what i want to achieve is that the stats for CRIT chance and HIT chance are shown below the other stats ( marked green in the screenshot ).
I modified your code some and added a couple functions:
Code:
(function() {
    'use strict';

    var X_PARAM_TERMS = ['Hit', 'Crit'];

    Window_Status.prototype.drawParameters = function(x, y) {
        var lineHeight = this.lineHeight();
        var paramsToDraw = [ 2, 4, 6, 3];
        var xParamsToDraw = [0, 2];
        this.drawParams(x, y, paramsToDraw);
        this.drawXParams(x, y + (lineHeight * paramsToDraw.length), xParamsToDraw);
    };

    Window_Status.prototype.drawParams = function(x, y, paramIds, terms) {
        var lineHeight = this.lineHeight();
        for (var i = 0; i < paramIds.length; i++) {
            var y2 = y + (lineHeight * i);
            var paramId = paramIds[i];
            this.changeTextColor(this.systemColor());
            this.drawText(terms ? terms[i] : TextManager.param(paramId), x, y2, 160);
            this.resetTextColor();
            var text = terms ? (this._actor.xparam(paramId) * 100) + '%' : this._actor.param(paramId);
            this.drawText(text, x + 160, y2, 60, 'right');
        }
    };

    Window_Status.prototype.drawXParams = function(x, y, xParamIds) {
        this.drawParams(x, y, xParamIds, X_PARAM_TERMS);
    };
})();

A couple things of note:

TextManager does not have a term for crit and, as a general rule, doesn't really support terms for X Params, so you'll have to find another way to get the text for anything besides hit. In the snippet I have above, I just made it a constant array.

Your original code will throw errors on this line:
Code:
this.drawText(TextManager.param(paramsToDraw), x, y2, 160);
The "param" function for both TextManager and Game_BattlerBase/Game_Actor expects an Id, so you need to pass in an Integer, not an entire Array.

Hit and crit are also percentages, so by default, they'll display as something like "0.95" and "0.04", so when drawing them, you'll probably want to multiply them by 100 and add a percentage sign after. The snippet I wrote will do something like that.

Including that code as a Plugin to my project, I get the following:

Spoiler: Sample Status Window
HyQFrd2.png
Pretty sure ICF-Soft has a few plugins that might help.

https://forums.rpgmakerweb.com/index.php?threads/icf-soft-status-menu.72882/
Thanks a lot both of you. Those are both very good solutions. I'll try them both and see what works best.
Hi again,
so this both works perfectly.

@ Zevia
Is there any way to rename cri and hit?
Sure: on the line where it says
Code:
var X_PARAM_TERMS = ['Hit', 'Crit'];
Just change them to whatever you want.

I didn't make it configurable via the Plugin interface since it seemed like you were trying out doing some code on your own.
Oh it was Right in front of me the whole time.

Actually i am trying out. But im really new to all of this.

Thank you again.

Original thread: https://forums.rpgmakerweb.com/threads/adding-hit-and-crit-to-the-status-window.105647/