Making an actor invisible in battle?

I haven't looked super closely at what Kenen gave you, but you should not be using both of these solutions.

What I'm giving you has the commands to change opacity directly in applying and removing the state. You shouldn't also have code to do that in one of the underlying game functions.
Yeah I figured as much. That's why like I said I completely disabled Kenen's. The only part of yours that is working at the moment is the turning the actor invisible part. The Transformed state being ended isn't removing the Captured state from the actor and they aren't turning visible again when it's removed either.

Was what you gave me intended to be used with yanfly's state categories? I wasn't clear on if it was or wasn't. It looks like that is unfortunately one of her paid plugins.
Was what you gave me intended to be used with yanfly's state categories? I wasn't clear on if it was or wasn't.

Easiest way requires Yanfly's Buffs & States and State Categories. If you don't have the latter, there can be a more complex workaround.
I think I was pretty clear 😉

It's actually not too complex to try this workaround. This will go in your death state, ID 1.
Code:
<Custom Apply Effect>
if (target._captured)
    target._captured.removeState(X);
</Custom Apply Effect>
where, again, X is the ID of the state that goes on the target.

And add to your enemy transform state's Remove Effect the line
Code:
delete user._captured;
I think I was pretty clear 😉

It's actually not too complex to try this workaround. This will go in your death state, ID 1.
Code:
<Custom Apply Effect>
if (target._captured)
    target._captured.removeState(X);
</Custom Apply Effect>
where, again, X is the ID of the state that goes on the target.

And add to your enemy transform state's Remove Effect the line
Code:
delete user._captured;
Sorry I wasn't sure if you were giving me the workaround at the time ^_^;;;;;

Okidokie as soon as I have a chance I'll give that a try. Thank you for your help and patience!
I think I was pretty clear 😉

It's actually not too complex to try this workaround. This will go in your death state, ID 1.
Code:
<Custom Apply Effect>
if (target._captured)
    target._captured.removeState(X);
</Custom Apply Effect>
where, again, X is the ID of the state that goes on the target.

And add to your enemy transform state's Remove Effect the line
Code:
delete user._captured;
Hmm still no luck. This is how I have it in currently:

Transformed state(16):
Code:
<Custom Apply Effect>
// Check if the user is an enemy.
if (user.isEnemy()) {
  // Archive the previous enemy ID.
  user._prevEnemyId = user._enemyId;
  // Set the target enemy ID you want the enemy to change into.
  var transformEnemyId = 6;
  // Transform the user.
  user.transform(transformEnemyId);
}
</Custom Apply Effect>


<Custom Remove Effect>
// Check if the user is an enemy.
if (user.isEnemy()) {
  // Retrieve the archived enemy ID.
  var transformEnemyId = user._prevEnemyId;
  // Transform the enemy back
  user.transform(transformEnemyId);
  // Clear the archived data.
  user._prevEnemyId = undefined;
delete user._captured;
}
</Custom Remove Effect>

Captured State(17):
Code:
<Custom Apply Effect>
target.battler().opacity=0;
origin._captured=target;
</Custom Apply Effect>

Knockout State(01):
Code:
State #1 will be automatically added when
HP reaches 0.

<Custom Apply Effect>
if (target._captured)
    target._captured.removeState(17);
</Custom Apply Effect>

And it's still not removing the state from the actor when the transformed state is "defeated" and transforms back. Also while it's not necessary since they're supposed to be removed anyway, just in case it's relevant information the actors do not become visible if the state expires naturally either.

Edit: This might be something completely unrelated or it might be connected. I also noticed something super weird with the transforms. The HP is doing something weird. I forgot that early on I noticed that when the transformed state was defeated rather than removing the state and switching back the battle would just end, so I had the capture attack also add the invincible state to the enemy.

I thought that might be the issue with what we're working on so I took it off but still, any time the transformed state reached 0hp unless the enemy has the Invincible state on, the battle ends and when they transform back otherwise, they keep the transformed state's hp rather than the original form's hp as I believe the plugin is intended to do. So maybe something is going wrong with Yanfly's script? Idk I'm just spitballing.
I guess I never explicitly told you to add a notetag to the captured state to change the opacity back.
Code:
<Custom Remove Effect>
user.battler().opacity=255;
delete origin._captured;
</Custom Remove Effect>

I'm having a hard time with the other part of it, because I don't understand what your intention is with "the party can transform the enemy back."

Do they not simply kill the enemy before it gets away with the captured actor? Is there something else involved?
I guess I never explicitly told you to add a notetag to the captured state to change the opacity back.
Code:
<Custom Remove Effect>
user.battler().opacity=255;
delete origin._captured;
</Custom Remove Effect>

I'm having a hard time with the other part of it, because I don't understand what your intention is with "the party can transform the enemy back."

Do they not simply kill the enemy before it gets away with the captured actor? Is there something else involved?
Yeah apologies, I'm still that stage of new/learning where specificity is super important.

Sorry! To clarify, what I want, and by my understanding this is how yan's enemy transformations are supposed to work, is: Say the characters are fighting a knight with 1000hp. They deal about 300 damage before it uses Capture on one of the actors. It transforms into knight carrying bag with about 200hp. They do 200 damage to it and it transforms back to knight with 700 hp. And according to Yan's video on the subject they can transform multiple times per battle. That's my goal.
Hey just following up on this 🙂 Does anyone know if I'm at least going the right direction to do what I want?
Say the characters are fighting a knight with 1000hp. They deal about 300 damage before it uses Capture on one of the actors. It transforms into knight carrying bag with about 200hp. They do 200 damage to it and it transforms back to knight with 700 hp.
And do you have that implemented?

Does anyone know if I'm at least going the right direction to do what I want?
Concisely, please, what exactly works and doesn't at this point?
And do you have that implemented?


Concisely, please, what exactly works and doesn't at this point?
You bet! So as I listed in the last code update this is what I have under the transformed state:
Code:
<Custom Apply Effect>
// Check if the user is an enemy.
if (user.isEnemy()) {
  // Archive the previous enemy ID.
  user._prevEnemyId = user._enemyId;
  // Set the target enemy ID you want the enemy to change into.
  var transformEnemyId = 6;
  // Transform the user.
  user.transform(transformEnemyId);
}
</Custom Apply Effect>


<Custom Remove Effect>
// Check if the user is an enemy.
if (user.isEnemy()) {
  // Retrieve the archived enemy ID.
  var transformEnemyId = user._prevEnemyId;
  // Transform the enemy back
  user.transform(transformEnemyId);
  // Clear the archived data.
  user._prevEnemyId = undefined;
delete user._captured;
}
</Custom Remove Effect>

According to Yanfly's video and article http://www.yanfly.moe/wiki/Enemy_Transformations_(MV_Plugin_Tips_&_Tricks) it looks like I should have it correct?

Right now what works:
Enemy transforms successfully using the skill showing both stats, skills, and sprite successfully switched to new form.
Enemy does turn back if timer expires
Enemy successfully applied Captured state to Actor when Capture skill is used.
Captured Actor successfully turns invisible when captured.

What doesn't work:
Unless enemy has Invincible state added, when defeated while transformed they are defeated altogether and the battle ends.
If enemy has Invincible state added, or the state expires due to turn time the enemy turns back but retains the stats of the transformed enemy rather than returning to their own at the time of transforming.
Defeating the transformed enemy and de-transforming them before the state expires does not remove the Captured state from the captured actor and does not return their visibility to 255.
I thought the progressive states plugin would allow me to move from the Captured state to knockout once timer runs out but it doesn't seem to be working but I was very tired when working with on this step before and may just need further testing.
Hey all! I'm just following up on this thread again. I really don't want to give up hope on this project but I'm still pretty badly stumped.

Original thread: https://forums.rpgmakerweb.com/threads/making-an-actor-invisible-in-battle.159849/