Hello all!
Here's the short version: I have a state that I want to give to one enemy in battle once every couple of turns via a common event. I want the game to chose which enemy this is randomly. This code will be used for battles with as many as three enemies and as few as one, and I want to avoid giving the state to a dead enemy, as this would be pointless.
In MV by default, there exists a system for giving enemies states in battle with events. The trouble is, the existing system gives two options; either give the state to all enemies or to one enemy specifically based on ID's.
My current thinking is that I could create a variable to hold a random number between one and three, and then apply the state to whichever enemy's ID is in that variable, and then afterwards I could check to make sure that at least one enemy has the state to ensure it didn't hit a corpse or try to give a state to an enemy that isn't there, and if not, run the event again until it works.
My problems are thus: I'm not sure how I would perform such a check, I'm not keen on running a random event on a loop, as this could cause excessive run times as the event gets wrong answers over and over, and I can't help but wonder whether there's a far more elegant and effective way to do what I'm looking to do, possibly with a plugin, possibly not.
Any help you can provide would be greatly appreciated. Thank you!
Here's the short version: I have a state that I want to give to one enemy in battle once every couple of turns via a common event. I want the game to chose which enemy this is randomly. This code will be used for battles with as many as three enemies and as few as one, and I want to avoid giving the state to a dead enemy, as this would be pointless.
In MV by default, there exists a system for giving enemies states in battle with events. The trouble is, the existing system gives two options; either give the state to all enemies or to one enemy specifically based on ID's.
My current thinking is that I could create a variable to hold a random number between one and three, and then apply the state to whichever enemy's ID is in that variable, and then afterwards I could check to make sure that at least one enemy has the state to ensure it didn't hit a corpse or try to give a state to an enemy that isn't there, and if not, run the event again until it works.
My problems are thus: I'm not sure how I would perform such a check, I'm not keen on running a random event on a loop, as this could cause excessive run times as the event gets wrong answers over and over, and I can't help but wonder whether there's a far more elegant and effective way to do what I'm looking to do, possibly with a plugin, possibly not.
Any help you can provide would be greatly appreciated. Thank you!