MZ paramBasePlus equivalent for xparam?

Hi, I'm working on my first plugin so I have very much to learn.
My idea is to modify battle scene since I only have one character to use.
ScreenPlug4.png

ScreenPlug2.png


This is what I have made untill now. There is a window close to the character one to show some of his main statistics, and based on buffs/debuffs that stats change turning green or red. I'm using "paramBasePlus" as reference to see if the vale of current "param" changes, this way i can use the right color (red for decrement, green for increment). My problem is that I have not found any "xparamBasePlus" or equivalent to do the same work with the Critic and Evasion rates. Could you suggest me any work around?

This is the part of code i'm actually using:

JavaScript:
// Update window's contents
    Scene_Battle.prototype.refreshBattleActorStatsWindow = function () {
        this._BattleActorStatsWindow.contents.clear();
        var lineHeight = this._BattleActorStatsWindow.lineHeight();

        // Statistiche del giocatore
        var playerActor = $gameParty.leader();
        var playerStatistics = [
            { name: "Attacco", value: $gameParty.members()[0].param(2) }, //ATK
            { name: "Difesa", value: $gameParty.members()[0].param(3) }, // DEF
            { name: "Critico", value: $gameParty.members()[0].xparam(1) }, // CRI
            { name: "Evasione", value: $gameParty.members()[0].xparam(3) }, // EVA
        ];
        const playerStatisticsOriginal = [
            { name: "Attacco", value: $gameParty.members()[0].paramBasePlus(2) }, //ATK
            { name: "Difesa", value: $gameParty.members()[0].paramBasePlus(3) }, // DEF
            //{ name: "Critico", value: $gameParty.members()[0].xparamBasePlus(1) }, // CRI
            //{ name: "Evasione", value: $gameParty.members()[0].xparamBasePlus(3) }, // EVA
        ];


        // Draw actor stats
        this._BattleActorStatsWindow.drawText($gameParty.members()[0].name(), 0, 0, this._BattleActorStatsWindow.contentsWidth(), 'center');
        // flat stats (ATK, DEF)
        for (var i = 0; i < 2; i++) { //(var i = 0; i < playerStatistics.length; i++)
            var stat = playerStatistics[i];
            var statOriginal = playerStatisticsOriginal[i];
            if (stat.value > statOriginal.value) { var text = stat.name + " -> " + "\\c[3]" + stat.value + "\\c[0]"; }
            if (stat.value < statOriginal.value) { var text = stat.name + " -> " + "\\c[2]" + stat.value + "\\c[0]"; }
            if (stat.value == statOriginal.value) { var text = stat.name + " -> " + stat.value; }
            this._BattleActorStatsWindow.drawText(text, 0, lineHeight * (i + 1), this._BattleActorStatsWindow.contentsWidth(), 'left');
        } // stats with % (CRI, EVA)
        for (var i = 2; i < 4; i++) { //(var i = 0; i < playerStatistics.length; i++)
            var stat = playerStatistics[i];
            var text = stat.name + " -> " + stat.value + "%";
            if (stat.value > statOriginal.value) { var text = stat.name + " -> " + "\\c[3]" + stat.value + "%\\c[0]"; }
            if (stat.value < statOriginal.value) { var text = stat.name + " -> " + "\\c[2]" + stat.value + "%\\c[0]"; }
            if (stat.value == statOriginal.value) { var text = stat.name + " -> " + stat.value + "%"; }
            this._BattleActorStatsWindow.drawText(text, 0, lineHeight * (i + 1), this._BattleActorStatsWindow.contentsWidth(), 'left');
        }

// Enemy stats -> to develope

Thanks.
Because there isn't one.

The regular parameters work that way because of how they're constructed. Any time you want to know one of the parameters of an actor, it starts with value for their class at their level.

Say, a level 5 warrior has 3 ATK.

That isn't stored on the actor anywhere, it's in the database from your class settings.

So it takes that database value, then adds any modifiers, buff multipliers, all the stuff that is stored on the actor.

The xparams and sparams are different because they have no base value in the database. They come entirely from traits, and the engine doesn't care where traits come from (your actor entry, class entry, weapons/armor you have equipped, states...). So to get the value of your x/sparams, all it does is add up all the traits on the actor.

So...you could do something with your colors, but you have to decide how you want it to work. You could simply say "if the actor has buffs on the parameter it'll be green, if it has debuffs it'll be red."

But that wouldn't reflect negative values coming from states, if you have any of that stuff in your game.
based on buffs/debuffs that stats change turning green or red

If you only want the coloration based on states, you'd have to check the actor's states and compare the total result of any modifications to the x-param. Something like this:

JavaScript:
// ugly modifications to Window_Status for example purposes
Window_StatusParams.prototype.maxItems = function() {
    return 1;
};
Window_StatusParams.prototype.drawItem = function(index) {
    const rect = this.itemLineRect(index);
    const paramId = index + 2;
    const name = 'Crit Rate'; // hardcoded for demo purposes
    const value = Math.round($gameParty.members()[0].xparam(2) * 100) + '%'; // hardcoded for demo purposes
    this.changeTextColor(ColorManager.systemColor());
    this.drawText(name, rect.x, rect.y, rect.width);
    this.changeTextColor(ColorManager.exParamColor(this._actor, 2))
    this.drawText(value, rect.x, rect.y, rect.width, "right");
};
// evaluate a battler's states for changes to an x-param and return a color
ColorManager.exParamColor = function(battler, paramId) {
    const states = battler.states();
    let values = []; 
    // check actor's states for ex-param value modifications
    for (const state of states) {
        for (const trait of state.traits) {
            if (trait.code === 22 && trait.dataId === paramId) values.push(trait.value);
        }
    }
    // get the sum of the modifications
    const netChange = values.reduce((partialSum, a) => partialSum + a, 0);
    // return color code based on sum 
    if (netChange > 0) {
        return ColorManager.powerUpColor();
    } else if (netChange < 0) {
        return ColorManager.powerDownColor();
    } else {
        return ColorManager.normalColor();
    }
}

Not thoroughly tested, and may need to be optimized, but that's a general idea.

In this example, Reid has a +5% CRI state and a -10% CRI state, resulting in a negative net change and the power down color.

mz_crit.png
Thank you, your answers were very helpful.

Original thread: https://forums.rpgmakerweb.com/threads/parambaseplus-equivalent-for-xparam.159698/