Displaying variables like states and resistances?

Hey everyone, I'm pretty much a Javascript newbie, and I'm trying to take the plunge to learn a little bit about the language and how it relates to MV in order to tweak a plugin that's almost perfect in presentation, but displays information I don't need.

So I'm using an old character select screen from 2016 made by MogHunter. Currently when you scroll over a character, it shows information like class and their individual stats with this line here:

Code:
Scene_CharSelect.prototype.refreshParameters = function() {
    this._parameters.bitmap.clear();
    var xr = Moghunter.charSel_parX;
    var yr = Moghunter.charSel_parY;
    this.drawPar(this.actor().currentClass().name,xr + 130,yr + 5);
    this.drawPar(this.actor().hp,xr + 10,yr + 50);
    this.drawPar(this.actor().mp,xr + 130,yr + 50);
    this.drawPar(this.actor().atk,xr + 10,yr + 95);
    this.drawPar(this.actor().def,xr + 130,yr + 95);
    this.drawPar(this.actor().mat,xr + 10,yr + 140);
    this.drawPar(this.actor().mdf,xr + 130,yr + 140);
    this.drawPar(this.actor().agi,xr + 10,yr + 185);
    this.drawPar(this.actor().luk,xr + 130,yr + 185);  
};

Which from messing around with it, I understand how it functions for the most part. Sadly I didn't need any of that stuff. So my next question is, can I pull other values from individual characters outside of stats, like states their currently afflicted with, weapon types they can equip, weaknesses/resistances and so on?

I've successfully gotten it to display an actors nickname by reading a bunch of other plugin codes and messing around. But I can't seem to find any examples of something like the examples I'm looking for above. Anyone know the how I'd call the rest of the variables up?

Thanks!
These will all require loops, partly because you don't know how many results you're going to get ahead of time. Mog's plugin might have pre-existing methods for getting/drawing (some of) this stuff, not sure. This also complicates the display: you'll have to choose whether to display only the first X things, or use a scrolling list or animated/marquee effect or something. 😅

Valid weapon types: you can loop over all weapon types and check each one against the actor's traitset, e.g.
JavaScript:
var len = $dataSystem.weaponTypes.length;  // number of weapon types (including empty first one)
var act = this.actor();                    // actor to check
var res = [];                              // valid weapon type IDs (output array)
for (var n = 1; n < len; n++) {            // loop
  if (act.isEquipWtypeOk(n)) {             // is equippable?
    res.push($dataSystem.weaponTypes[n]);  // add type name to output
  }
};
As mentioned, you'll then need to figure out the display stuff. 😅

State rates can be retrieved via the elementRate method. Note that to get a "resistance" value, you'll need to do 1 (i.e. 100%) minus that value, e.g.
JavaScript:
var rate = this.actor().elementRate(1);  // rate of element 1
var resist = 1 - rate;  // "resistance" to element 1
To identify weak/strong elements you'll need to loop through all elements and check their values against certain thresholds, e.g. maybe rate values below 1 count as "resistance" and values above 1 count as "weakness". 😴

For states: battlers have a _states property, an array of state IDs active on the user, so you could use that~
JavaScript:
this.actor()._states.forEach(function(id) {
  // stuff here will be done once per "id" value
});
...or you could use the states method to get an array of state objects ($dataStates, cf. States.json in your project's data folder), from which you can retrieve data like name, icon, etc:
JavaScript:
var stateData = this.actor().states().map(function(state) {
  return { name: state.name, icon: state.iconIndex };
});
If you just want the icons, an alternative approach could be either the stateIcons method (only states) or the allIcons method (includes buffs/debuffs), which simply returns a list of iconIndex values, e.g.
JavaScript:
this.actor().allIcons().forEach(function(iconIndex) {
  // this._theWindow.drawIcon(iconIndex, x, y);
  // something like that, need appropriate window reference and x/y positions ^-^'
});


If you're new to arrays, you might find this article helpful~
😤
Thank you so much! Everything you've shared and the link provided look like they give me the exact tools I'm looking for! As someone who's a newb at this, I greatly appreciate the time you took share the info!
You're welcome! 😂

Just realised you might also want to check the parameter buff/debuff values, too...they're 0 by default (no buffs/debuffs); -1 means 1 debuff level, +2 means 2 buff levels, etc. Each base param has an ID: 0~7 corresponding to MHP, MMP, ATK, DEF, MAT, MDF, AGI, and LUK respectively. You can retrieve the buff level for a particular paramId using the buff method, e.g.
JavaScript:
var paramId = 0;  // MHP
var buffLevel = this.actor().buff(paramId);

Original thread: https://forums.rpgmakerweb.com/threads/displaying-variables-like-states-and-resistances.117696/