MV Changing actor state based on position in party

230159.png

I'm using common events to add states to party members, but my goal is to target them based on their position in the party as opposed to their ID.

For example: in this case, the goal is to add the state to whichever actor is in the third position of the party.
I assume the solution has to do with the "Variable" option, but I haven't figure out how to use that.

Thanks in advance.
the variable needs to contain the ID of the actor you want as a target.

and in this specific case, that is very easy to do.

use control variable : Game Data : Party Member #3 to get the ID of the actor in third party position, then use that variable in the change state command for the actor.
the variable needs to contain the ID of the actor you want as a target.

and in this specific case, that is very easy to do.

use control variable : Game Data : Party Member #3 to get the ID of the actor in third party position, then use that variable in the change state command for the actor.
Hey, thanks for the help. What you said worked but now a have a new problem.
174510.png

When using conditional branches to check for states I doesn't give me an option to use variable as opposed to actor.
I also looked into the "control variable" menu and it doesn't seem to have an option for checking states, so I don't know how else to do this.
you are completely right about this.
There are possible workarounds, but unfortunately you haven't given enough information to choose which workaround would be usable as they all have restrictions.

For example the most common workaround for the conditional branch is to make one conditional branch for each actor, placing the commands if that actor has the state in that branch. if an actor doesn't have the state it gets skipped, allowing multiple possibles to be processed one after another.

However that makes for rather long events if you have a lot of actors. So another option is to use scripts to extract the required IDs to variables, but that is more complex and only used if you have a lot of actors.
For example: in this case, the goal is to add the state to whichever actor is in the third position of the party.
if you use script you wouldnt need to to deal with variables. a script call you can use to do just what you mentioned is
Code:
var actor = $gameParty.members()[2]
if (actor)
  actor.addState(x)
and that'd add state x to the 3rd party member
Then to change the party slot just change the [2] on the first line to the party slot youre thinking of -1
the most common workaround for the conditional branch is to make one conditional branch for each actor
(...) if an actor doesn't have the state it gets skipped
I don't think this works for what I'm trying to do. The state must be applied (or in this case, removed) from the actor in the third position exclusively.

The party has four active members; the first two are static while the last two can be switched. The goal is have party member 1 use skills that affect party member 3, while party member 2 affects party member 4. The idea is that they are "connected" and their skills reflect that.
var actor = $gameParty.members()[2]
if (actor)
actor.addState(x)
How do I make that script check for what state the actor currently has?
I recall seeing some type of large document containing all the javascript commands for variables, which should help with this, but I can't find it...

If it's not obvious, I never learned programing so I'm still pretty lost, even when it comes to finding the resources.
How do I make that script check for what state the actor currently has?
What will you be using that check for? Going off of...
my goal is to target them based on their position in the party as opposed to their ID.

For example: in this case, the goal is to add the state to whichever actor is in the third position of the party.
The script above will allow you to just add the states to the nth party member directly. Im not sure what youll be checking for and why
What will you be using that check for?
On the second image I posted, it shows a conditional branch checking if the actor has the knockout status.
The code you provided works for the question in the OP (thanks for that, by the way), but doesn't help for the problem I asked about in my second post.
but doesn't help for the problem I asked about in my second post.
And that's the main point why I wrote you don't give enough information for us to select the correct workaround for you.

Checking for the knockout state is especially questionable because that state as several hardcoded consequences in the engine.
You'll need to give a more detailed description of your system before anyone can give you the correct code.
That is because javascript code is not only more powerfull but also more complex than event code, and we need to know the exact use to write the correct code.
but doesn't help for the problem I asked about in my second post
ah. i see now. i had thought it was all about that first question
for conditions, youll have to use script to avoid the mess of default commands you'd need to use otherwise.
your script condition for the conditional branch event would be
Code:
$gameParty.members()[2] && $gameParty.members()[2].isStateAffected(x)
to check if party member 3 has a specific state. then you can then also save the id of the party member within a certain slot with the standard control variables event command and have the other commands that take variables use that

1748135738548.png
This worked perfectly. Thank you so much for the help. ( º-º)/

Original thread: https://forums.rpgmakerweb.com/threads/changing-actor-state-based-on-position-in-party.177873/