MZ Change Actor Parameters based on Class/Level and not on ID

Hi! First of all, thank you SO much in advance for how much you are always helping me.

Second, so you know how you can easily change with an event command the Actor's Name, Image, Profile, and Class by just picking it´s ID? I would like to be able to change those but calling it if the actor member 1 in the party has an specific Class and Level, something like

If $gameParty.members()[1](actor => actor.isClass($dataClasses[11]) && actor.level >= 1 )
Then
$gameParty.members()[1].setProfile("Here is some profile text.");

But I´m not sure how to script call it properly. ( I would need it cause I´m trying to implement having duplicate actors on the game, if I can´t is okay too I can revert to how I had this prior duplicates but I wanted to try to see how it goes)

I have this script here to find any battle party member with those conditions (as the actors were unique I only needed to find if it´s ID had a specific level) but as I would have duplicates now I would like to just check if the first in the party matches the Class instead of ID and Level. In case this helps.


$gameParty.battleMembers().some(actor => actor.actorId() === 11 && actor.level >= 1 )

Thanks a million!! and sorry if it´s a bit messy writting as I was writting it I kept realizing the most direct thing I would need ahah.
As a rule of thumb, you need the arrow => when you are looking at multiple members at once (e.g is there ANY member having class xy?). While checking whether the FIRST member is from a certain class, the method is $gameParty.members()[0].isClass(...) This is not the real technical definition for the arrow symbol, but it should work for this use-case.

Furthermore, the indexing for $gameParty.members() starts at 0 if I remember correctly.

Your code should look something like this:

Code:
if ($gameParty.members()[0].isClass($dataClasses[11]) && $gameParty.members()[0].level >= 1)

Code:
$gameParty.members()[1].setProfile("Here is some profile text.");
looks correct besides that 1 needs to be a 0
As a rule of thumb, you need the arrow => when you are looking at multiple members at once (e.g is there ANY member having class xy?). While checking whether the FIRST member is from a certain class, the method is $gameParty.members()[0].isClass(...) This is not the real technical definition for the arrow symbol, but it should work for this use-case.

Furthermore, the indexing for $gameParty.members() starts at 0 if I remember correctly.

Your code should look something like this:

Code:
if ($gameParty.members()[0].isClass($dataClasses[11]) && $gameParty.members()[0].level >= 1)

Code:
$gameParty.members()[1].setProfile("Here is some profile text.");
looks correct besides that 1 needs to be a 0
Thanks a Million! it worked like a charm and I managed to figure out how to change all the other parameters too ^^ the only thing, which is the smallest detail and I could even just remove it if it was just and oddity of scriptcalling, is that the \I[68] in the Profile text doesn´t show the icon but rather just the text, is there a specific way I should write it inside a scriptcall?

Code:
$gameParty.members()[0].setProfile("Elemento \I[68] Natural.");

Thanks a mil!


1752142339680.png
Try "\\I[68]", you need to escape the \ symbol by putting another one next to it.
Try "\\I[68]", you need to escape the \ symbol by putting another one next to it.
Awesome! it worked perfectly!! thanks a million!!!

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/change-actor-parameters-based-on-class-level-and-not-on-id.178819/