Adding HIT and CRIT to the status window

Wasser J. Hans

Villager
Member
Joined
Jun 22, 2017
Messages
29
Reaction score
1
First Language
German
Primarily Uses
RMMV
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:




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

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 ).
 
Last edited:

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
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:

 
Last edited:

Wasser J. Hans

Villager
Member
Joined
Jun 22, 2017
Messages
29
Reaction score
1
First Language
German
Primarily Uses
RMMV
Thanks a lot both of you. Those are both very good solutions. I'll try them both and see what works best.
 

Wasser J. Hans

Villager
Member
Joined
Jun 22, 2017
Messages
29
Reaction score
1
First Language
German
Primarily Uses
RMMV
Hi again,
so this both works perfectly.

@ Zevia
Is there any way to rename cri and hit?
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
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.
 

Wasser J. Hans

Villager
Member
Joined
Jun 22, 2017
Messages
29
Reaction score
1
First Language
German
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,551
Members
137,837
Latest member
Dabi
Top