MZ Draw Experience Gauges for Class and SubClasses (Class Change VS)

Happy Monday all!

I am looking for a way to draw Actor level gauges for the primary class and any subclasses I want to focus on in the same way the VisuStella allows you to use the:

this.drawActorLevel function.

Except naturally that function doesn't exist outside of VisuStella based windows/scenes

Anyone have a function handy to create this Gauge:

1688395726366.png


And to be able to tie it not only to the primary class but also create separate ones that are focused on multiclass tiers.
(Technically drawActorLevel does exist in the core scripts, it just doesn't include a gauge.)

I don't really know anything about VisuStella's Class Change System, but...

MZ's core scripts implement gauges as Sprite_Gauge: each one is assigned a battler reference _battler and a type _statusType (e.g. "hp"). From there, the sprite updates itself.

Unless VisuStella's implementation of that exp gauge supports subclasses in some way, I'm guessing you'll need an add-on plugin of some kind to define the "subclass exp" gauge type(s).

Alternatively you could go the MV route and paint it on the window's contents bitmap~
JavaScript:
// gauge background
this.contents.fillRect(x, y, width, height, color0);
// gauge filled area
this.contents.gradientFillRect(x + 1, y + 1, fillW, fillH, color1, color2);
You'd need to replace x, y, width, etc with actual values. Without plugins, actor exp across all classes is stored in the form _exp = { classId: exp }. E.g. to get the exp actor ID 1 has in class ID 2:
JavaScript:
$gameActors.actor(1)._exp[2]
Getting the experience for a given level is somewhat involved, but doable (cf expForLevel rmmz_objects.js). VisuStella's plugin might offer shortcuts...?

Painting/blitting might actually be a better option in this case (assuming nothing else clears the contents), since it presumably won't need to be redrawn while you're still on that scene.
Coming back to this,

I gave up on the gauges (for now at least) but do still need a way to directly draw the Current and Needed EXP for multiclasses.


I am using the function :

this.drawText("Exp" + " " + actor.currentExp() + "/" + actor.expForLevel(nextprimLevel) , x, y, width);

currently to track Exp for the primary class.

nextprimLevel = actor.level + 1,


But I can't figure if there's any way to do this for a multiclass tier as well.
Like I mentioned, unless VisuStella's plugin offers a shortcut then expForLevel only works for the current class: there is no core script method to calculate "experience for level" for another class. And since you might be using (obfuscated) plugins that alter how the exp/level thresholds are calculated, that could be...tricky to duplicate via scripting. 😴

A workaround may be to change the actor's class, draw the exp values, then change back? E.g.
JavaScript:
const origId = actor.currentClass().id;  // remember starting class
// NB: VisuStella's multiclasses() includes ALL applicable classes
for (const class of actor.multiclasses()) {
  actor.changeClass(class.id, true);  // true = retain exp
  this.drawText(`Exp ${actor.currentExp()} / ${actor.nextLevelExp()}`, x, y, width);
  y += this.lineHeight();  // next row
}
actor.changeClass(origId, true);  // change back and pretend nothing happened

Edit: actually, you may be able to replace this.drawText(text, x, y, width) with this.drawExpInfo(x, y). As the name may suggest, that's what the default status window uses to draw its exp info block. If it shows VisuStella's gauge, though, then that might expose the workaround, depending on how they've implemented the gauge.
Ill play around with it. The only concern I have is that I'm trying to display information for both the main and subclass at the same time on the same page.
I'm trying to display information for both the main and subclass at the same time on the same page.
Fortunately, that's exactly the idea behind my example: show "current / next" exp for all classes.
So had some help from Nao on the VS discord to get up to the following point:
// Draw Armoire Rank // this.contents.fontSize = 30; const subClass = actor.getMulticlassAtTier(2)?.id; // if check for Unranked Class is equipped at all before running this section if (subClass != 9){ const subClassLvl = actor.classLevel(subClass) const subClassName = actor.multiclass(2).name; const subClassWidth = this.textWidth(subClassName) + 8; const subClassHeight = this.contents.fontSize this.drawTextEx(subClassName, ax, ay + 2, subClassWidth); this.resetFontSettings(); this.contents.fontSize = 24; this.drawText("Lv" + " " + subClassLvl, ax + subClassWidth - 64, ay + 4) this.resetFontSettings(); // Draw Equipped Armoire// const weaponSlotId = 1; const weapon = actor.equips()[weaponSlotId]; const weaponName = weapon ? weapon.name : ''; const weaponIcon = weapon && weapon.iconIndex > 0 ? weapon.iconIndex : 0; const weaponIconSize = 24; const ax2 = ax + 4; const ay2 = subClassHeight + 8 this.drawResizedIconWithText(weaponIcon, weaponName, ax2, ay2, weaponIconSize, resizedFontSize,4); // Draw Arm Exp Required this.contents.fontSize = 22; const subCurrent = actor._exp[subClass]; this.drawText(subCurrent , ax2 + 4, gy + this.contents.fontSize + 8); this.resetFontSettings();


With the result so far being the current Exp of the subclass set to tier 2.
Screenshot 2023-07-05 173006.png



Screenshot 2023-07-05 173205.png


So The exp is being tracked correctly. However I still can't figure out a method of expForLevel for the subclass like you said @caethyril.


What kills me is that their is 100% some way of checking, because subclass Level and Exp gets drawn in the Class Change System's Class scene:

1688594547691.png


I just really want to avoid using this scene altogether because players can't manually change their classes in this scene, so it feels pointless to have enabled.


Will be trying your method out next
Its working 90%. with your script plus my changes to make it match the primary class.


Can load up and check all 4 Actors.

However if I switch back to an Actor (either by cycling with Q/E, or back to the main menu and reselecting them) that has already been loaded up it breaks and gives me the following message:

1688596818388.png



1688596859846.png


the problem lines are apparently:

const subClass = actor.getMulticlassAtTier(2)?.id; // if check for Unranked Class is equipped at all before running this section if (subClass != 9){ const subClassLvl = actor.classLevel(subClass)


This is the full code I'm using for this section. Our focus is on the area where "Bracelet Lv1" and the items below it are drawn

1688597338143.png




//////// ARMOIRE COLUMN //////////////// // Draw Armoire Rank // this.contents.fontSize = 30; const subClass = actor.getMulticlassAtTier(2)?.id; // if check for Unranked Class is equipped at all before running this section if (subClass != 9){ const subClassLvl = actor.classLevel(subClass) const subClassName = actor.multiclass(2).name; const subClassWidth = this.textWidth(subClassName) + 8; const subClassHeight = this.contents.fontSize this.drawTextEx(subClassName, ax, ay + 2, subClassWidth); this.resetFontSettings(); this.contents.fontSize = 24; this.drawText("Lv" + " " + subClassLvl, ax + subClassWidth - 64, ay + 4) this.resetFontSettings(); // Draw Equipped Armoire// const weaponSlotId = 1; const weapon = actor.equips()[weaponSlotId]; const weaponName = weapon ? weapon.name : ''; const weaponIcon = weapon && weapon.iconIndex > 0 ? weapon.iconIndex : 0; const weaponIconSize = 24; const ax2 = ax + 4; const ay2 = subClassHeight + 8 this.drawResizedIconWithText(weaponIcon, weaponName, ax2, ay2, weaponIconSize, resizedFontSize,4); // Draw Arm Exp Required this.contents.fontSize = 22; const origId = actor.currentClass().id; // remember starting class // NB: VisuStella's multiclasses() includes ALL applicable classes for (const subclassCheck of actor.multiclasses()) { actor.changeClass(subClass, true); // true = retain exp const nextsubLevel = actor.level + 1 const subCurrent = actor.currentExp() - actor.expForLevel(nextsubLevel - 1); const subNext = actor.expForLevel(nextsubLevel) - actor.expForLevel(nextsubLevel - 1); const subExp = "Exp" + " " + subCurrent + "/" + subNext; this.drawText(subExp , ax2 + 4, gy + this.contents.fontSize + 8); y += this.lineHeight(); // next row } actor.changeClass(origId, true); // change back and pretend nothing happened this.resetFontSettings();

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/draw-experience-gauges-for-class-and-subclasses-class-change-vs.158918/