Random Buff/Debuff (state) each round?

Ok, so I have tried this with some in battle scripted events, but I can't come up with a good way to randomize it. I'm not a programmer so I was hoping someone could help me with a simple script call?

It would be like: At the start of each round, all characters (enemies and allies) collectively get either a buff or debuff (apply a state) that is removed at the end of the entire round (or start of the next combat turn). What state is applied is selected from a predefined list.

 Has anyone done something like this before? Anyone want to take a crack at it?
state_id = rand($data_states.size - 1) + 2

($game_party.alive_members + $game_troop.alive_members).each  { |member| 

member.add_state(state_id) }

This will apply a random state from the database (excluding Death) to every living combatant.

Or if you want to have a predetermined list like you said, you could do this:

allowed_states = [2, 5, 16, 17, 20]

state_id = allowed_states[rand(allowed_states.size)]

($game_party.alive_members + $game_troop.alive_members).each  { |member| 

member.add_state(state_id) }
state_id = rand($data_states.size - 1) + 2

($game_party.alive_members + $game_troop.alive_members).each  { |member| 

member.add_state(state_id) }

This will apply a random state from the database (excluding Death) to every living combatant.

Or if you want to have a predetermined list like you said, you could do this:

allowed_states = [2, 5, 16, 17, 20]

state_id = allowed_states[rand(allowed_states.size)]

($game_party.alive_members + $game_troop.alive_members).each  { |member| 

member.add_state(state_id) }
Awesome!

Now would I drop that in as a script trigger on each turn of the battle on like the troop page?
You would indeed.
However, you should note that the commands given above will add the same state to all battlers.


If you want the battlers to get different states, you'll have to move the randomizer into the add_state-command


And the time it will stay depends on the state setting - there is no autoremoval by itself.
Thanks a lot guys! You rock!

I had to mess with state removal (as Andar suggested) but it works.

Just have to drop this page onto each troop and have it trigger each turn at the end of the turn.

Make sure to have Trihan's script that grants the states go AFTER the removal of the states.

20gekpw.jpg

 

I created new states so that they wouldn't get removed if someone gets a buff.

I had each of those state buff 150% a few stats (like one gives +150% Magic Def and Def while another buffs Atk and Magic Atk) or provide 15% Regen.

Because each state is applied at the END of the round, you can see the icon BEFORE your decide on your actions.

That worked out pretty well. Thanks all (and particularly Trihan 😀   )
Grinn, you could condense that first part into a script too. The full thing would go a little something like this:

allowed_states = [28, 29, 30, 31, 32]

allowed_states.each { |state|

  ($game_party.alive_members + $game_troop.alive_members).each { |member|

    member.remove_state(state)

  }

}

state_id = allowed_states[rand(allowed_states.size)]

($game_party.alive_members + $game_troop.alive_members).each  { |member| 

member.add_state(state_id) }

Original thread: https://forums.rpgmakerweb.com/threads/random-buff-debuff-state-each-round.39671/