I have a system where it's basically one on one fights like Pokemon, except with a fighting game like twist where the reserve party member can hop in battle and perform an attack then leave. despite it took HOURS lol, this all works as intended. BUT, I don't want the skill usable if the other actor isn't in the party at all. I can't find a call that works for a member of the party that's NOT active in battle, but still in the party. if I can figure out the call, I can use something like Yanfly's Skill Core to set the call as a requirement for the skill or something I feel.
MV Script call for reserve members not active in battle, but still in the party...
Javascript/Plugin SupportHeya!
I assume you'd want to use a custom evaluation for something like this, right? Maybe something like
With X being the party member ID you'd need?
Granted I don't have MV installed so can't test if this way works as it should, as I was going off of what the wiki has: http://www.yanfly.moe/wiki/Skill_Core_(YEP)#Custom_Requirements_and_Execution
And MZ formats it a bit differently so I couldn't test. But maybe it'll work?
I believe replacing <Custom Requirement> with <Custom Show Eval> will hide the skill altogether if it's not possible to use, too.
I suppose this largely depends on how your reserve party is treated, though and how it interfaces with the rest of the game? Either way, I imagine you can subsitute something into that custom evaluation that would help the skill display or not.
I assume you'd want to use a custom evaluation for something like this, right? Maybe something like
Code:
<Custom Requirement>
if ($gameParty.members().contains($gameActors.actor(X))) {
value = true;
} else {
value = false;
}
</Custom Requirement>
With X being the party member ID you'd need?
Granted I don't have MV installed so can't test if this way works as it should, as I was going off of what the wiki has: http://www.yanfly.moe/wiki/Skill_Core_(YEP)#Custom_Requirements_and_Execution
And MZ formats it a bit differently so I couldn't test. But maybe it'll work?
I believe replacing <Custom Requirement> with <Custom Show Eval> will hide the skill altogether if it's not possible to use, too.
I suppose this largely depends on how your reserve party is treated, though and how it interfaces with the rest of the game? Either way, I imagine you can subsitute something into that custom evaluation that would help the skill display or not.
You're close. That will return whether the indicated actor is in the party, but it doesn't do anything to tell whether they're in combat or not.
The array that contains the active battle members is
$gameParty.battleMembers()So you could take the code given by Frigid, truncate it a bit for efficiency, and use that method to check to be in the party but not the battle party:
Code:
<Custom Requirement>
value=$gameParty.members().contains($gameActors.actor(X)) && !$gameParty.battleMembers().contains($gameActors.actor(X));
</Custom Requirement>
The other way to approach this, that might depend on what plugins you're using and how much you've customized stuff, is that by default your battle party is simply the first so many actors in your party (default 4). So you could also do
Code:
value=$gameParty.members().indexOf($gameActors.actor(X))>=4;
Glad I was on the right track at any rate, haha. Thank you for the detailed solution--I like to think I learn just as much as the people requesting aid sometimes when I take a stab at attempting to find a solution for them. : P
I tried both of these and for the first one, I would put the actor I want to come in, in both $gameActors.actor(X) right? Like $gameActors.actor(2) in both of them? when I do that, even if the person is on reserve, It won't let me use the move. I tried the other and same instance, it wouldn't let me use it. so I feel it's actually working and something is being weird perhaps?
It's weird because I know the person is in the party because Yanfly's Actor Switch still let's me switch to actor 2. so I'm not terribly sure what I did on my end to mess up and not have actor recognized as in the reserves.
Is it a case of 0 being considered as the first party member in the list, and 1 being the second, etc.? I forget if it does that there--but try turning the variable to 1 just to be sure.
Ok, I've figured a few things out... I typed the first line of code
$gameParty.members().contains($gameActors.actor(2)) && !$gameParty.battleMembers().contains($gameActors.actor(2))
into the console and out of battle it comes back as true... I also tried $gameParty.members()[1] === $gameActors.actor(2)
since there's usually only 2 party members at a time. again, came back as true. BUT, in battle both come back as false, unless actor 2 is in the battle. it's as if non-battle members don't exist to the game. it's not counting anyone who isn't in the main party... but the weirdest thing is Yanfly's Actor Switch is. I can switch between Actor 1 and 2 as normal. but I can't get anything else to recognize there's another party member.
EDIT: I think I finally found a way around it all. In the game you usually pick one of two teammates. sooo I made a variable change based on who you add to the party. and since only one of them is with you at all times, this makes things a lot easier to manage. I just have to make sure the variable is set before battle. tho I'm still gonna see if there's maybe another way since this'll make testing a pain lol.
$gameParty.members().contains($gameActors.actor(2)) && !$gameParty.battleMembers().contains($gameActors.actor(2))
into the console and out of battle it comes back as true... I also tried $gameParty.members()[1] === $gameActors.actor(2)
since there's usually only 2 party members at a time. again, came back as true. BUT, in battle both come back as false, unless actor 2 is in the battle. it's as if non-battle members don't exist to the game. it's not counting anyone who isn't in the main party... but the weirdest thing is Yanfly's Actor Switch is. I can switch between Actor 1 and 2 as normal. but I can't get anything else to recognize there's another party member.
EDIT: I think I finally found a way around it all. In the game you usually pick one of two teammates. sooo I made a variable change based on who you add to the party. and since only one of them is with you at all times, this makes things a lot easier to manage. I just have to make sure the variable is set before battle. tho I'm still gonna see if there's maybe another way since this'll make testing a pain lol.
No, all of the databases arrays leave the first element blank so that the IDs in your database match the index of the array.
Yeah, Yanfly's Battle Engine and its extensions customize a lot of stuff in battle. You could read through them to see how these functions are modified, but it sounds like you found a workaround that works well for you.
@FrigidGaze, for someone who uses MZ and not MV, your code is actually already correct. 👋
Per the OP:
The
The OP had mentioned that this is a battle skill so checking whether the party is in battle or not is irrelevant. (More on that later.) Assuming actor X had been properly defined in the database:
- During battles, your original code will return true if actor X is active in battle (i.e. the skill is enabled); false otherwise e.g. actor X is already a reserve member of the party or actor X had been switched out of the battle (i.e. the skill will be disabled).
- Outside of battles, however, the code will ALWAYS return true as long as actor X is a member of the party, battle or reserve. (This is irrelevant if the skill is defined to be only visible in the
Battle Screen.)
JavaScript:
<Custom Requirement>
var x = 1; // actor ID
value = $gameParty.members().contains($gameActors.actor(x));
</Custom Requirement>
<Custom Show Eval> notetag works too as you've described.@zerobeat032 The codes aren't working properly because of the wrong usage of
members().The first code as shown below is actually bugged when used in battle.
This is because
From the definition of $gameParty.members(), that erroneous code can be simplified during battle as follows:
The above code will thus always return false while in battle.
As for your second code @zerobeat032, the reason is similar to the first code.
When in battle,
Code:
value = $gameParty.members().contains($gameActors.actor(2)) && !$gameParty.battleMembers().contains($gameActors.actor(2))
$gameParty.members() works differently depending on whether your party is in battle or not. Per rpg_objects.js:
JavaScript:
Game_Party.prototype.members = function() {
return this.inBattle() ? this.battleMembers() : this.allMembers();
};
$gameParty.battleMembers() refers to members of the active battle party; defined as actor objects.$gameParty.allMembers() refers to all members of the party including those in the reserve; defined as actor objects.From the definition of $gameParty.members(), that erroneous code can be simplified during battle as follows:
Code:
var x = $gameParty.battleMembers().contains($gameActors.actor(2));
value = x && !x; // i.e. true && false OR false && true
As for your second code @zerobeat032, the reason is similar to the first code.
Code:
value = $gameParty.members()[1] === $gameActors.actor(2);
$gameParty.members() i.e. your active battle party is only of size 1 i.e. $gameParty.members()[1] is undefined since indices start at 0. However, outside of battle, $gameParty.members() i.e. your entire party is of size 2 and so that expression evaluates to true. Therefore you get false and true while in battle and outside of battle respectively.@zerobeat032
- Be careful when using $gameParty.members() as it's defined differently depending on whether your party is in battle or not.
- The original code from @FrigidGaze will already do the basics of what you need i.e. his code will enable or disable the usage of said skill depending on whether or not actor X is in the active battle party. This assumes the skill is ONLY usable in battle.
- If you want to check explicitly if the party is in battle or not the conditional is
$gameParty.inBattle().
Ah-hah--that's handy to know then, thank you! Sometimes that 0 being 1 thing trips me up, so I was never sure how and where it was applied.
A lucky guess, then? ; P I did THINK I was onto something at least, but wasn't sure if it exactly aligned with the OP's needs depending on how they treated and referred to the reserve members.
I finally figured it out I think lol...
$gameParty.allMembers().contains($gameActors.actor(2)) seems to work. I tested it in game and as long as actor is in the party and not actor 3, it works... and vice versa. it also works correctly if neither are in the party. I have NO idea why I didn't think to try allMembers as I've seen it before. thanks everyone for the help tho! I finally got my assist attacks set up and they work the right way. I feel I know JUST enough about Javascript to do some coding, but clearly I've got a lot more to learn.
$gameParty.allMembers().contains($gameActors.actor(2)) seems to work. I tested it in game and as long as actor is in the party and not actor 3, it works... and vice versa. it also works correctly if neither are in the party. I have NO idea why I didn't think to try allMembers as I've seen it before. thanks everyone for the help tho! I finally got my assist attacks set up and they work the right way. I feel I know JUST enough about Javascript to do some coding, but clearly I've got a lot more to learn.
Huh! Good to know, I've never had cause to look at it. I assumed it was just a plain accessor.
Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-reserve-members-not-active-in-battle-but-still-in-the-party.147589/