How To Make A Passive Affect 1 Random Enemy?

Hi, not sure if this is an incredibly easy or hard ask, but I wanted to make 2 passive states that are fairly similar.

The first one is, a passive state that at the start of the battle, randomly targets one enemy and then disappears for the rest of the battle when that enemy dies.

The other one is roughly the same except, after that enemy dies, it randomly affects another target and so on.

Any help?
Hi, not sure if this is an incredibly easy or hard ask, but I wanted to make 2 passive states that are fairly similar.
Im assuming youre using Yanfly's plugins? by default the engine doesnt have "passive states"

The first one is, a passive state that at the start of the battle, randomly targets one enemy and then disappears for the rest of the battle when that enemy dies.
im not exactly sure what youre going for here. Targets a random enemy to do what? what should it do? by that description, it sounds like it could just be a troop event that puts a state without a duration on a random troop member. if the enemy dies, the state disappears with them by default

The other one is roughly the same except, after that enemy dies, it randomly affects another target and so on.
this one doesnt sound like it would have to be a passive by that description alone either. it would be the same thing above where a troop event gives an infinite state to a random enemy, but youd have to patch the buffs and states plugin to allow death removal (described here), and it would have a remove effect to add the state to another single ally so that dying makes it jump to another enemy.

If these dont sound like theyd work maybe describe in greater detail what each one does and how theyre supposed to work?
Im assuming youre using Yanfly's plugins? by default the engine doesnt have "passive states"


im not exactly sure what youre going for here. Targets a random enemy to do what? what should it do? by that description, it sounds like it could just be a troop event that puts a state without a duration on a random troop member. if the enemy dies, the state disappears with them by default


this one doesnt sound like it would have to be a passive by that description alone either. it would be the same thing above where a troop event gives an infinite state to a random enemy, but youd have to patch the buffs and states plugin to allow death removal (described here), and it would have a remove effect to add the state to another single ally so that dying makes it jump to another enemy.

If these dont sound like theyd work maybe describe in greater detail what each one does and how theyre supposed to work?
The first one applies a state to a random enemy that makes them attack their allies, which is why I want it to disappear after that enemy dies.
The second one lowers agility of the enemy by 50%, and when they die, applies to another random enemy.
I didn't explain what they do because it's a variety of different states I can input into them for future use.
Also yes, I'm using yanfly passives.
The first one applies a state to a random enemy that makes them attack their allies, which is why I want it to disappear after that enemy dies.
Ok, i think i see it now.
for both of these you want a passive state on for an actor thatll make it so that a random enemy gets a state, right? that was unclear before

if you give your passives this tag it should apply the states at random
Code:
<Custom Battle Effect>
var enemy = user.opponentsUnit().aliveMembers()[Math.randomInt(user.opponentsUnit().aliveMembers().length)];
enemy.addState(x);
</Custom Battle Effect>

then if you patch the plugin, for your 2nd state's applied state you can adjust above into a remove effect and switch the both the opponentsUnits to friendsUnit to have it jump on death
Ok, i think i see it now.
for both of these you want a passive state on for an actor thatll make it so that a random enemy gets a state, right? that was unclear before

if you give your passives this tags it should apply the states at random
Code:
<Custom Battle Effect>
var enemy = user.opponentsUnit().aliveMembers()[Math.randomInt(user.opponentsUnit().aliveMembers().length)];
enemy.addState(x);
</Custom Battle Effect>

then if you patch the plugin, for your 2nd state's applied state you can adjust above into a remove effect and switch the both the opponentsUnits to friendsUnit to have it jump on death
Yeah sorry for the confusion, also thank you.

Also also, I'm not exactly familiar with patching plugins (never heard the phrase before)? Is it like adjusting settings in the plugin options or physically coding into the passive that it jumps to another enemy friendly unit? I'm unfamiliar with coding, sorry.
I'm not exactly familiar with patching plugins
in the original buffs and states plugin, state removal effects dont actually trigger when the battler with the state dies. So in order to make it be able to run removal effects on death, you have to make an edit to the plugin's code. you do that by either opening up the plugin with some text editor and directly changing the code inside it, or you create a separate plugin that modifies its behavior and place it after the original inside your plugin manager.

in the linked page there will be instructions on what specifically to do
in the original buffs and states plugin, state removal effects dont actually trigger when the battler with the state dies. So in order to make it be able to run removal effects on death, you have to make an edit to the plugin's code. you do that by either opening up the plugin with some text editor and directly changing the code inside it, or you create a separate plugin that modifies its behavior and place it after the original inside your plugin manager.

in the linked page there will be instructions on what specifically to do
Oh I see, that's currently out of my reach since I'm not familiar with coding, and don't start computer programming until fall so I'll see if there any plausible alternative solutions.
I'm not familiar with coding
Youre not actually coding anything for this. The code is already provided in the thread, its just a matter of reading what to do with it.
for that one you just have to copy whats there, paste it into a text editor (notepad will do fine), save it as a .js file and put it into your plugin manager

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-passive-affect-1-random-enemy.164007/