How to make a character learn a skill if an enemy or all enemies has a specific state?

Hello!
I'm new in making an RPG game and I just wanna ask the question that is in the title.
Basically, I have a tutorial battle for my first main character in my game where if he uses "stun" skill that I've made for him, it will cause a sort of stun state for an enemy. Then, if he gets all the enemies stunned, then he now gets to use this other skill that will instantly KO all the enemies. My problem is that I don't know how to implement the KO skill after all enemies are stunned.

Does anyone know how to implement this? I don't have any screenshots yet but I'll provide some of needed.
Thanks again! :3
You run a Common Event every turn on every Troop that first checks how many enemies there are in the encounter (inflict invisible State on all enemies, then count via a variable how many enemies got inflicted to get that number). Then check all enemies if they are inflicted with State, and count that up in another variable. If the variables for monster count and Stun state are equal, Change Skill on character to add the new Skill. If the variables are not equal, remove that Skill from the character. At the end (or at the very beginning), reset the variables so they can be re-used next turn and wipe the invisible State used for counting.
Oh wow! Thank you for the fast reply!
I'll be sure to try that!
Can you pls give like a screenshot of the code cause I'm a little confused on what to do....
Sorry for the inconvenience 🙁
You run a Common Event every turn on every Troop that first checks how many enemies there are in the encounter (inflict invisible State on all enemies, then count via a variable how many enemies got inflicted to get that number). Then check all enemies if they are inflicted with State, and count that up in another variable. If the variables for monster count and Stun state are equal, Change Skill on character to add the new Skill. If the variables are not equal, remove that Skill from the character. At the end (or at the very beginning), reset the variables so they can be re-used next turn and wipe the invisible State used for counting.
Can you pls give like a screenshot of the code cause I'm a little confused on what to do....
Sorry for the inconvenience 🙁
Event starts by resetting the count, then inflict Enemy Count state on all enemies. Check for each enemy whether they're inflicted, and if so, count +1.
RPG1.png


Same process next, but for checking the Stun instead (without inflicting it to enemies through the event, of course...)
RPG2.png


Lastly, check whether the Stun count matches the Enemy count (meaning all enemies present are currently Stunned), and change Skills accordingly to the conditions.
RPG3.png
Event starts by resetting the count, then inflict Enemy Count state on all enemies. Check for each enemy whether they're inflicted, and if so, count +1.
View attachment 174147

Same process next, but for checking the Stun instead (without inflicting it to enemies through the event, of course...)
View attachment 174148

Lastly, check whether the Stun count matches the Enemy count (meaning all enemies present are currently Stunned), and change Skills accordingly to the conditions.
View attachment 174149
Ohhhhhh! Okie okie!
I get it now. Thanks again! :3
Sorry again for the inconvenience...
Event starts by resetting the count, then inflict Enemy Count state on all enemies. Check for each enemy whether they're inflicted, and if so, count +1.
View attachment 174147

Same process next, but for checking the Stun instead (without inflicting it to enemies through the event, of course...)
View attachment 174148

Lastly, check whether the Stun count matches the Enemy count (meaning all enemies present are currently Stunned), and change Skills accordingly to the conditions.
View attachment 174149
Okay, I have one last question.

I got it working nicely but that's without the last line in the common event

(Change Enemy State : Entire Troop, - Enemy Count)

However when I place it in the troop battle events, it only works on Condition: "Turn End", Span: "Turn"
I want to like work right at the start of the battle.
It might be my conditions or my span or maybe some of the plugins but am really confused on what to do again.
Is there a fix? If none then it's okay. I'll try to figure it out on my own. :3
I always make it a habit to set under every Troops: a page set at Condition: Turn 0, Span: Battle, which runs a Common Event that does everything you want to get done at the start of battle.
Then page 2 at Condition: Turn 1*X, Span: Turn, which activates the Common Event that does everything you want to get done at the end of each turn in battle.
I always make it a habit to set under every Troops: a page set at Condition: Turn 0, Span: Battle, which runs a Common Event that does everything you want to get done at the start of battle.
Then page 2 at Condition: Turn 1*X, Span: Turn, which activates the Common Event that does everything you want to get done at the end of each turn in battle.
Sooooo copy the same common event both event pages?

Sorry if I'm asking too much questions:hswt:
I'm just a newbie when it comes to skill creation
Yeah. And always test to make sure it really works.
Yeah. And always test to make sure it really works.
Yay! Got it working! Thanks again for all the help! :LZScat:

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/how-to-make-a-character-learn-a-skill-if-an-enemy-or-all-enemies-has-a-specific-state.131769/