Help with MV to MZ scripting

I have recently started porting my project over to MZ, but I'm having trouble porting over the scripts I've written in MV.
Specifically, I use a script that checks which if an actor in a specific party position has a specific class and another script
that checks if a specific actor has a specific skill. I would appreciate if anyone could help me translate this code from MV to MZ.

Below is the code for checking actor party position and class:
JavaScript:
$gameActors.actor($gameParty._actors[1])._classId == 20 || $gameActors.actor($gameParty._actors[1])._classId == 17

Below is the code for checking for specific skills:
JavaScript:
$gameParty.members().some(actor => actor.hasSkill(ID))
Without plugins, I believe those both work identically in MV and MZ.

I would suggest this for the first one, though:
JavaScript:
[17, 20].some(classId => $gameParty.members()[1].isClass($dataClasses[classId]))
I.e. "is party member #2 (first follower) class ID 17 or 20?".
Thank you, I forgot that 0 is the player and 1 is the first follower. So every time I tried the code it just
wouldn't work.
Without plugins, I believe those both work identically in MV and MZ.

I would suggest this for the first one, though:
JavaScript:
[17, 20].some(classId => $gameParty.members()[1].isClass($dataClasses[classId]))
I.e. "is party member #2 (first follower) class ID 17 or 20?".
Oh, I see!

I also notice you have this:
JavaScript:
$gameParty.members().some(actor => actor.hasSkill(ID))
Which means "does some party member have skill ID". Hopefully you've defined ID somewhere, or are replacing it with an actual number.

However, if you actually want this:
checks if a specific actor has a specific skill.
That would be something simpler, e.g.
  • $gameParty.members()[0].hasSkill(123) - "does the party leader have skill ID 123?"; or
  • $gameActors.actor(1).hasSkill(123) - "does actor ID 1 have skill ID 123?".
Oh, I see!

I also notice you have this:

Which means "does some party member have skill ID". Hopefully you've defined ID somewhere, or are replacing it with an actual number.

However, if you actually want this:

That would be something simpler, e.g.
  • $gameParty.members()[0].hasSkill(123) - "does the party leader have skill ID 123?"; or
  • $gameActors.actor(1).hasSkill(123) - "does actor ID 1 have skill ID 123?".
Those will save me a lot of time, I appreciate that. But I do have one more question. Do you know any script that would have my skill change the battle background at the start of the skill but when the skill is over it changes the
battle background back to whatever it was before the intial change.
To change the battleback(s) mid-battle, you could try script calls like this:
JavaScript:
const ss = SceneManager._scene._spriteset;
// Set to "Crystal / (None)".
ss._back1Sprite.bitmap = ImageManager.loadBattleback1("Crystal");
ss._back2Sprite.bitmap = ImageManager.loadBattleback2("");
JavaScript:
const ss = SceneManager._scene._spriteset;
// Reset to map settings.
const [ s1, s2 ] = [ ss._back1Sprite, ss._back2Sprite ];
s1.bitmap = s1.battleback1Bitmap();
s2.bitmap = s2.battleback2Bitmap();
However, I think you would need a plugin to trigger the script call at the "start" of the skill (and at the end, unless you're OK using a common event for that).
To change the battleback(s) mid-battle, you could try script calls like this:
JavaScript:
const ss = SceneManager._scene._spriteset;
// Set to "Crystal / (None)".
ss._back1Sprite.bitmap = ImageManager.loadBattleback1("Crystal");
ss._back2Sprite.bitmap = ImageManager.loadBattleback2("");
JavaScript:
const ss = SceneManager._scene._spriteset;
// Reset to map settings.
const [ s1, s2 ] = [ ss._back1Sprite, ss._back2Sprite ];
s1.bitmap = s1.battleback1Bitmap();
s2.bitmap = s2.battleback2Bitmap();
However, I think you would need a plugin to trigger the script call at the "start" of the skill (and at the end, unless you're OK using a common event for that).
Thank you thank you thank you, your a life saver. And yea I used a common event to change the battle background and the skill works great

Original thread: https://forums.rpgmakerweb.com/threads/help-with-mv-to-mz-scripting.168714/