MZ Conditional hide/show actor commands in MZ

Hiya! It's a me, AC, coming with another request!

I'm moving away now from my boss battles, which are the funnest thing for me to work on and brainstorm, to my classes and actors, admittedly the dullest part for me xD Now, something that I've been struggling to do is customize their command windows in battle. Basically, there's three commands besides your standard Guard, Attack and whatnot: Techniques, Incantations and Sorcery. The idea is that you can only see them if you have skills matching those Skill Types and disappear when you forget those skills... and I can't seem to find a way to implement that.

Visustella doesn't seem to have that as an option as far as I can tell (it seems it only exists for individual skills), and Hime's Battle Comand plugin doesn't work (I tried it and it crashes everything), so I come to ye, friends! Once again, thank you all for helping me through my journey! <3<3
If you check the console around the makeCommandList function, you can spot a VS function that has to do with making the command lists you've set with your <Battle Commands> notetag. And even with the messed code you can spot a place where it checks for the STYPE in the notetag. I added one line there to set a conditional to check if any of the actor's skills are of the stypeId that it checks with that RegExp or whatever. This seemed to work for me, but I just quickly tested it. The skilltype command didn't show when I made the actor forget the only skill they knew of that sTypeId in a troop event.

PS. My plugins aren't updated, so you might want to fetch the same function with your updated plugins and then add that same line there.

Window_ActorCommand[_0x58cf34(0x8ef)][_0x58cf34(0x338)] = function(_0x38e291) {
const _0x36800c = _0x58cf34;
_0x38e291 === _0x36800c(0x83f) && this[_0x36800c(0xae6)]();
[_0x36800c(0x3ba), 'SKILLS'][_0x36800c(0x375)](_0x38e291) && this[_0x36800c(0xa97)]();
_0x38e291 === _0x36800c(0xcd8) && this['addGuardCommand']();
_0x38e291 === 'ITEM' && this[_0x36800c(0x9f1)]();
_0x38e291 === 'STATUS' && this[_0x36800c(0x9a7)]();
_0x38e291 === 'ESCAPE' && this[_0x36800c(0x87b)]();
_0x38e291 === 'AUTO\x20BATTLE' && this[_0x36800c(0xc97)]();
if (_0x38e291[_0x36800c(0xcbb)](/STYPE: (\d+)/i)) {
const _0x4e5c23 = Number(RegExp['$1']);
if ($gameActors.actor(this._actor.actorId()).skills().some(skill => skill.stypeId === _0x4e5c23)) // EXTRA LINE
this[_0x36800c(0x31e)](_0x4e5c23);
} else {
if (_0x38e291[_0x36800c(0xcbb)](/STYPE: (.*)/i)) {
const _0x3de86a = DataManager[_0x36800c(0x915)](RegExp['$1']);
this[_0x36800c(0x31e)](_0x3de86a);
}
}
_0x38e291 === _0x36800c(0x968) && this[_0x36800c(0x34c)]();
if (_0x38e291[_0x36800c(0xcbb)](/SKILL: (\d+)/i)) {
const _0x5129d3 = Number(RegExp['$1']);
this[_0x36800c(0xb03)]($dataSkills[_0x5129d3]);
} else {
if (_0x38e291[_0x36800c(0xcbb)](/SKILL: (.*)/i)) {
const _0x1d84f7 = DataManager[_0x36800c(0x4db)](RegExp['$1']);
this[_0x36800c(0xb03)]($dataSkills[_0x1d84f7]);
}
}
_0x38e291 === _0x36800c(0x51c) && Imported[_0x36800c(0xb45)] && this[_0x36800c(0x9c3)](),
[_0x36800c(0x3bc), 'COMBAT\x20LOG'][_0x36800c(0x375)](_0x38e291) && Imported['VisuMZ_4_CombatLog'] && this[_0x36800c(0x9c1)](),
_0x38e291 === _0x36800c(0x5d6) && Imported[_0x36800c(0x8c0)] && this['addWeaponSwapCommand'](!![]),
_0x38e291 === 'GRID\x20MOVE' && Imported[_0x36800c(0x33b)] && this[_0x36800c(0xbbf)]();
}
If you check the console around the makeCommandList function, you can spot a VS function that has to do with making the command lists you've set with your <Battle Commands> notetag. And even with the messed code you can spot a place where it checks for the STYPE in the notetag. I added one line there to set a conditional to check if any of the actor's skills are of the stypeId that it checks with that RegExp or whatever. This seemed to work for me, but I just quickly tested it. The skilltype command didn't show when I made the actor forget the only skill they knew of that sTypeId in a troop event.

PS. My plugins aren't updated, so you might want to fetch the same function with your updated plugins and then add that same line there.

Window_ActorCommand[_0x58cf34(0x8ef)][_0x58cf34(0x338)] = function(_0x38e291) {
const _0x36800c = _0x58cf34;
_0x38e291 === _0x36800c(0x83f) && this[_0x36800c(0xae6)]();
[_0x36800c(0x3ba), 'SKILLS'][_0x36800c(0x375)](_0x38e291) && this[_0x36800c(0xa97)]();
_0x38e291 === _0x36800c(0xcd8) && this['addGuardCommand']();
_0x38e291 === 'ITEM' && this[_0x36800c(0x9f1)]();
_0x38e291 === 'STATUS' && this[_0x36800c(0x9a7)]();
_0x38e291 === 'ESCAPE' && this[_0x36800c(0x87b)]();
_0x38e291 === 'AUTO\x20BATTLE' && this[_0x36800c(0xc97)]();
if (_0x38e291[_0x36800c(0xcbb)](/STYPE: (\d+)/i)) {
const _0x4e5c23 = Number(RegExp['$1']);
if ($gameActors.actor(this._actor.actorId()).skills().some(skill => skill.stypeId === _0x4e5c23)) // EXTRA LINE
this[_0x36800c(0x31e)](_0x4e5c23);
} else {
if (_0x38e291[_0x36800c(0xcbb)](/STYPE: (.*)/i)) {
const _0x3de86a = DataManager[_0x36800c(0x915)](RegExp['$1']);
this[_0x36800c(0x31e)](_0x3de86a);
}
}
_0x38e291 === _0x36800c(0x968) && this[_0x36800c(0x34c)]();
if (_0x38e291[_0x36800c(0xcbb)](/SKILL: (\d+)/i)) {
const _0x5129d3 = Number(RegExp['$1']);
this[_0x36800c(0xb03)]($dataSkills[_0x5129d3]);
} else {
if (_0x38e291[_0x36800c(0xcbb)](/SKILL: (.*)/i)) {
const _0x1d84f7 = DataManager[_0x36800c(0x4db)](RegExp['$1']);
this[_0x36800c(0xb03)]($dataSkills[_0x1d84f7]);
}
}
_0x38e291 === _0x36800c(0x51c) && Imported[_0x36800c(0xb45)] && this[_0x36800c(0x9c3)](),
[_0x36800c(0x3bc), 'COMBAT\x20LOG'][_0x36800c(0x375)](_0x38e291) && Imported['VisuMZ_4_CombatLog'] && this[_0x36800c(0x9c1)](),
_0x38e291 === _0x36800c(0x5d6) && Imported[_0x36800c(0x8c0)] && this['addWeaponSwapCommand'](!![]),
_0x38e291 === 'GRID\x20MOVE' && Imported[_0x36800c(0x33b)] && this[_0x36800c(0xbbf)]();
}
Okay, not gonna lie, maybe I'm having a bit of a smooth brain moment lmao Where exactly can I find that function? I assume the bit above the EXTRA LINE is what I'm looking for, right?
Start playtest and open console with F8, write on the 'console' tab: Window_ActorCommand.prototype.makeBattleCommand (edit: and press enter)

Then click on the function that appears. It'll take you to the 'sources' tab. Near the top, click on the 'pretty print' where it asks you is it should do it. It should show the correct function now with a yellow underline. Copy that whole thing, to the final bracket, until you see like the next one starting with comma:
,
Window_ActorCommand

The EXTRA LINE I commented there is the one line I added in the function. Because even with the obfuscated code, you can spot that the place where I put it is the place where it checks the notetag for STYPE. And since the regexp thing gets the number you've written on your notetag, I assumed that the next obfuscated line adds the skill type with that id and placed it under conditional (you don't need brackets for conditional if only 1 line comes after it):

if ($gameActors.actor(this._actor.actorId()).skills().some(skill => skill.stypeId === _0x4e5c23)) // EXTRA LINE

EDIT: And I guess you need to use the <Battle Commands> notetag for that to work. Or else add the conditional to the else statement too, I think.

EDIT2: That EXTRA LINE comment just means that that was the line I added. Not that something should be written there.

EDIT3: And yeah, after you've copied the thing, paste it into a notepad file, add the extra line, save as .js file to your plugins folder and add in plugin manager after VisuStella.

EDIT4: One last edit LOL, you need to check that in the extra line that messed up variable is the same that it sets with the regexp thing (in my code: const _0x4e5c23 = Number(RegExp['$1'])😉. I don't know if it'll be the same as for me if you have later plugin versions. Don't know if the obfuscation scrambles it the same way.
Oookay, so here's how it looks in my end. Man, baby's first plugin surgery, so as expected... unsuccessful xD
Spoiler: Js notepad
1759689475223.png
Spoiler: Error message
1759692110578.png
My VS might be using something different than that 0x4e5c23.
Yeah, it's the const above (edit: above the extra line). For you it's that _0x3c6d8e thing (keep the beginning underscore).
Yay!!! It worked! The option appears when you have a matching skill and disappears when you forget it so long as you set the skills you want with the Battle Commands notetag!

But dang,seems like I'll have to rename the skill type xD

1759701566214.png
Cool.
For that problem of the text not fitting, you can go to VS Battle Core plugin settings -> Battle Layout Settings, and then under 'List Style' there's the 'Command Window Width' setting where you can change party/actor command window width (it affects both default and list styles).
rpgLord69 I owe you my life 😍 Thank you!!

Original thread: https://forums.rpgmakerweb.com/threads/conditional-hide-show-actor-commands-in-mz.180411/