More Verbose Console? / Make MV Show Its Work?

KFDirector

Warper
Member
Joined
Mar 22, 2016
Messages
4
Reaction score
2
First Language
English
Primarily Uses
RMMV
Is there any way to make the F8 console - or anything else that works alongside RPG Maker MV - more explicit about some of its calculations? The F8 Console helped when I actually had bad js throwing true errors, but now I'm past errors into just bugs.

With some of the plugins I have installed, I'm trying to figure out why the parameters I've input into the database have resulted in some of the output I'm seeing, and it'd be useful to figure out what steps it's going through. For instance, I have four characters who should have all started with 100% hit rates, but between the ICFSoft_ParamsCore, Ramza_DualWield, and Ramza_WeaponFormula, and possibly my own ineptitude at stringing together equations, I have two characters who end up with a Hit Rate of 100% and two with 10% Hit Rates. The problem could be still deeper, but if there's anyway to make MV actually show its work, I could figure out the answer a lot faster (or the next time I mess something up).

Or if not on the status screen, at least in battle. I definitely have one issue traced to Ramza_WeaponFormula or more likely how I'm using it, but if there's any way I could get MV to show or log its calculations in battle I could nail down what step is causing one character's attacks to constantly register as 0 damage.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
The console itself is just a handy "notepad" that the game can jot things down on if/when it's commanded to do so, e.g.
JavaScript:
console.log('Hello world!');
console.error('Something went wrong!');
So, unfortunately, I think it depends a bit on how the plugins themselves work, and whether you can find an appropriate place to insert such statements into the code for debugging/demystifying purposes. More details on the functions offered by the console object can be found here:

In case it helps for your particular case, here are some methods from the core script files (v1.6.2) regarding default calculation of basic, extra, and special params:
JavaScript:
Game_BattlerBase.prototype.paramPlus = function(paramId) {
    return this._paramPlus[paramId];
};

Game_BattlerBase.prototype.paramRate = function(paramId) {
    return this.traitsPi(Game_BattlerBase.TRAIT_PARAM, paramId);
};

Game_BattlerBase.prototype.param = function(paramId) {
    var value = this.paramBase(paramId) + this.paramPlus(paramId);
    value *= this.paramRate(paramId) * this.paramBuffRate(paramId);
    var maxValue = this.paramMax(paramId);
    var minValue = this.paramMin(paramId);
    return Math.round(value.clamp(minValue, maxValue));
};

Game_BattlerBase.prototype.xparam = function(xparamId) {
    return this.traitsSum(Game_BattlerBase.TRAIT_XPARAM, xparamId);
};

Game_BattlerBase.prototype.sparam = function(sparamId) {
    return this.traitsPi(Game_BattlerBase.TRAIT_SPARAM, sparamId);
};

Game_Actor.prototype.paramBase = function(paramId) {
    return this.currentClass().params[paramId][this._level];
};

Game_Actor.prototype.paramPlus = function(paramId) {
    var value = Game_Battler.prototype.paramPlus.call(this, paramId);
    var equips = this.equips();
    for (var i = 0; i < equips.length; i++) {
        var item = equips[i];
        if (item) {
            value += item.params[paramId];
        }
    }
    return value;
};
So by default, Base params are the most complex: basic value (for actors, this is from their class) + "plus" value (permanent bonus + equips), all scaled by the rate determined by the product of traits and (de)buffs, then capped between min & max. Extra and Special params are simply determined by the sum or product of relevant traits, respectively. Naturally, though, plugins can change any of this. :kaoswt:

You could get, say, the "plus" value for the MHP param of actor ID 1 like this:
JavaScript:
$gameActors.actor(1).paramPlus(0)
To get this value to show in the console, you can either type it directly into the console and press Enter, or stick it in a console.log statement in a script somewhere, as described earlier. The calculation of this value might or might not have been affected by a plugin, depending on how the plugin was written.

Note that if you're consistently getting 0 damage with a certain formula, that can indicate an error in the formula, since any error or non-numerical result returns a value of zero~
JavaScript:
Game_Action.prototype.evalDamageFormula = function(target) {
    try {
        var item = this.item();
        var a = this.subject();
        var b = target;
        var v = $gameVariables._data;
        var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
        var value = Math.max(eval(item.damage.formula), 0) * sign;
		if (isNaN(value)) value = 0;
		return value;
    } catch (e) {
        return 0;
    }
};
 

KFDirector

Warper
Member
Joined
Mar 22, 2016
Messages
4
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thank you to both of you!

Make use of the Chromium devtools debugger and breakpoints.
For other newbs who might come after me, this was very correct to what I asked for - I specifically had never heard of breakpoints, and found the basics here (https://developers.google.com/web/tools/chrome-devtools/javascript/breakpoints) to explain what that was.

Making good use of it may require a trickier problem than I actually turned out to have and understanding everything I'm seeing in the console to suss out what the problems could be turned out to be even harder than I guessed, but I think this will be very useful in the future!

Note that if you're consistently getting 0 damage with a certain formula, that can indicate an error in the formula, since any error or non-numerical result returns a value of zero~
I checked and checked the formatting of my javascript math, thinking that the problem was the formula as a whole was glitchy or valuating to NaN...and the problem turned out to be a misspelled custom parameter much earlier in the formula. I didn't realize that any error would result in the entire thing returning zero, so I improperly narrowed my search and missed the misspelling earlier in the formula.

...

As for my hit problems, checking the $gameActors.actor(1).xparam(0), xparamBase(0), and xparamPlus(0) for several actors pointed in the direction of my problems there. (Ultimately, I was trying to be too clever and make things interact that weren't designed to interact in that way.)

Thank you both for your help.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

have another character sheet! ill probably add some more details before i make my thread for this project
Every time the official RMWeb account makes a post, I think it's @Eliaquim writing it!

It's driving me crazy, but it's also wonderfully hilarious.
// Looks at Elfkisser, realizes he'd have to either install Windows 10 or compile it for Linux
// Didn't install Elfkisser.
Too much effort for a curiosity. :popcorn:
I was just high-fiving myself for all I've learnt in the engine, and how far I've come, only to forget to remove the Immortal state from a semi-scripted battle. Now the enemy never dies and I feel so smart >.>
Playtest your stuff. Always playtest.

Forum statistics

Threads
99,224
Messages
963,230
Members
130,813
Latest member
Gremter
Top