MV Enemies being able to switch with each other in and out of battle...

I'm curious if there's a way to get enemies to switch in and out of battle. Pokemon would be a good example of when an enemy trainer switches out a Pokemon and whatnot when it's about to faint.


I saw this but it never got a response. So I decided to make my own post. Basically I'm trying to see if I can emulate a 1 on 1 system except you and the enemy can tag in and out. I've got it working for the actors, but I'm not sure how to with enemies. I know I can make an enemy appear after another one is knocked out. but the problem is if I used that at any other time, the first enemy doesn't go away. If anyone has any ideas or suggestions, I'm all ears. thanks!
Heya!

I'm not sure if it will help--but you can make an enemy hide just like you can make them appear, by using the script command:

Code:
$gameTroop.members()[1].hide();

With the number '1' there being the index number of the enemy. I believe it starts at 0 for the first enemy, 1 for the second, etc.

So with that you can hide and make enemies appear as needed if it potentially aids in emulating such a system?

Granted, I was only able to test this on MZ, but the forum I found the snippet on from a search was for MV initially anyway, so maybe it's worth a shot?
This works on MV, thanks! I think with the power of Yanfly's Action Sequences, I can use this as an eval in a move when I want the enemy to tag in and out. I'll look and see if I can find the call for them to appear.
Glad to hear it works!

As for the call to make them appear, I believe you can just use the 'show enemy' command from the event page itself! Though you need to make sure you don't get mixed up with how the script refers to them from 0, 1, 2, etc. and the event command starts from 1.

Alternatively, I believe the script for it is

Code:
$gameTroop.members()[1].appear();

If that helps keep things more in order.

Edit: Oops, I realise you needed the code for it to work within Yanfly's system directly anyway, so it's a good thing I posted the code, haha.
thanks! now I just need to figure out how to make the skill, I've got it kind of working but there's some hiccups. Biggest being when the enemy can use the skill. I'm trying to figure out how to get the enemy to not use if they're the only member left.
Ahh, my knowledge of these kind of more advanced systems is limited admittedly--but I know you could seal particular skills either via switches (in the enemy skill list you can make it so a skill can only be used if a switch is active), or an invisible state on the enemy, which could be applied to lock that skill if and when they were the final enemy. Though that would depend entirely on how you handle other enemies dying and such and if there's a chance to apply those sort of things.
$gameTroop.aliveMembers().length > 1

I used this as a Custom Requirement for the skill. basically saying if they're the only enemy left, the move can't be used. also, I didn't have to use the hide call. You can actually just have the enemy escape oddly enough. The appear command will actually bring them back as is. sooo basically the skill makes the other enemy appear then the user escapes. the only oddity is the enemy (unlike the player) seems to lose a turn when this happens. BUT, I think I know how to fix that.

Thanks for the assistance! realizing there's a script call to make enemies hide and appear was all I need lol.
Ooh, that's handy! I'm learning stuff that'll probably help me in the future too, so it all worked out for the best I'd say. I'm still learning regarding custom javascript configuations for Yanfly/Visustella stuff which I'm sure will make my life a whole lot easier down the road. And I had no idea the escape skill worked like that--haha. I'm just imagining the enemy rushing back, like they forgot their wallet or something.

I'm glad I was able to help lead the way to the solution you were looking for, haha.
actually I was wrong about the custom requirement. didn't know hidden enemies didn't count as alive lol. so I used this instead
$gameTroop.members().length() > 1)

and because I'm using Olivia's OTB, I know how to give people an added action/turn, so the enemy isn't being skipped. yeah, I've been trying to learn as much "lunatic coding" as I can as it's been extremely helpful along the way. but yeah, thanks again for pointing me in the right direction!

EDIT: so $gameTroops.members().length() is no good either as it does the opposite and doesn't count dead enemies. sooo for anyone curious I change the requirement to the following...

$gameTroop.members()[0].isHidden() || $gameTroop.members()[1].isHidden())

this checks if enemy 1 (0) or 2 (1) is hidden. if one of them is, the other can tag out to them. if not, the move is no longer usable by the enemy.

to make note... if you're unsure of if your code is correct, type it into the console and the game will definitely let you know.

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/enemies-being-able-to-switch-with-each-other-in-and-out-of-battle.147507/